dwm.c
changeset 1281 3e478379e74d
parent 1280 118ea4f4f554
child 1284 14929bfb8738
equal deleted inserted replaced
1280:118ea4f4f554 1281:3e478379e74d
    58 enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
    58 enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
    59 enum { ColBorder, ColFG, ColBG, ColLast };              /* color */
    59 enum { ColBorder, ColFG, ColBG, ColLast };              /* color */
    60 enum { NetSupported, NetWMName, NetLast };              /* EWMH atoms */
    60 enum { NetSupported, NetWMName, NetLast };              /* EWMH atoms */
    61 enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
    61 enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
    62 enum { ClkLtSymbol = 64, ClkStatusText, ClkWinTitle,
    62 enum { ClkLtSymbol = 64, ClkStatusText, ClkWinTitle,
    63        ClkClientWin, ClkLast };                         /* clicks */
    63        ClkClientWin, ClkRootWin, ClkLast };             /* clicks */
    64 
    64 
    65 /* typedefs */
    65 /* typedefs */
    66 typedef unsigned int uint;
    66 typedef unsigned int uint;
    67 typedef unsigned long ulong;
    67 typedef unsigned long ulong;
    68 
    68 
    82 } Button;
    82 } Button;
    83 
    83 
    84 typedef struct Client Client;
    84 typedef struct Client Client;
    85 struct Client {
    85 struct Client {
    86 	char name[256];
    86 	char name[256];
       
    87 	float mina, maxa;
    87 	int x, y, w, h;
    88 	int x, y, w, h;
    88 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
    89 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
    89 	float mina, maxa;
       
    90 	int bw, oldbw;
    90 	int bw, oldbw;
       
    91 	uint tags;
    91 	Bool isbanned, isfixed, isfloating, ismoved, isurgent;
    92 	Bool isbanned, isfixed, isfloating, ismoved, isurgent;
    92 	uint tags;
       
    93 	Client *next;
    93 	Client *next;
    94 	Client *snext;
    94 	Client *snext;
    95 	Window win;
    95 	Window win;
    96 };
    96 };
    97 
    97 
   310 buttonpress(XEvent *e) {
   310 buttonpress(XEvent *e) {
   311 	uint i, x, click;
   311 	uint i, x, click;
   312 	Client *c;
   312 	Client *c;
   313 	XButtonPressedEvent *ev = &e->xbutton;
   313 	XButtonPressedEvent *ev = &e->xbutton;
   314 
   314 
   315 	click = ClkLast;
   315 	click = ClkRootWin;
   316 	if(ev->window == barwin) {
   316 	if(ev->window == barwin) {
   317 		i = x = 0;
   317 		i = x = 0;
   318 		do
   318 		do
   319 			x += TEXTW(tags[i]);
   319 			x += TEXTW(tags[i]);
   320 		while(ev->x >= x && ++i < LENGTH(tags));
   320 		while(ev->x >= x && ++i < LENGTH(tags));
   325 		else if(ev->x > wx + ww - TEXTW(stext))
   325 		else if(ev->x > wx + ww - TEXTW(stext))
   326 			click = ClkStatusText;
   326 			click = ClkStatusText;
   327 		else
   327 		else
   328 			click = ClkWinTitle;
   328 			click = ClkWinTitle;
   329 	}
   329 	}
   330 	else if((c = getclient(ev->window)))
   330 	else if((c = getclient(ev->window))) {
       
   331 		focus(c);
   331 		click = ClkClientWin;
   332 		click = ClkClientWin;
       
   333 	}
   332 
   334 
   333 	for(i = 0; i < LENGTH(buttons); i++)
   335 	for(i = 0; i < LENGTH(buttons); i++)
   334 		if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
   336 		if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
   335 		   && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
   337 		   && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
   336 			buttons[i].func(&buttons[i].arg);
   338 			buttons[i].func(&buttons[i].arg);
  1372 	/* EWMH support per view */
  1374 	/* EWMH support per view */
  1373 	XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
  1375 	XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
  1374 			PropModeReplace, (unsigned char *) netatom, NetLast);
  1376 			PropModeReplace, (unsigned char *) netatom, NetLast);
  1375 
  1377 
  1376 	/* select for events */
  1378 	/* select for events */
  1377 	wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask
  1379 	wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask
  1378 			|EnterWindowMask|LeaveWindowMask|StructureNotifyMask;
  1380 			|EnterWindowMask|LeaveWindowMask|StructureNotifyMask;
  1379 	XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
  1381 	XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
  1380 	XSelectInput(dpy, root, wa.event_mask);
  1382 	XSelectInput(dpy, root, wa.event_mask);
  1381 
  1383 
  1382 
  1384