dwm.c
changeset 1294 ef082062dccc
parent 1293 25a4affb52c5
child 1295 9f20458e3bbc
equal deleted inserted replaced
1293:25a4affb52c5 1294:ef082062dccc
    51 #define LENGTH(x)       (sizeof x / sizeof x[0])
    51 #define LENGTH(x)       (sizeof x / sizeof x[0])
    52 #define MAXTAGLEN       16
    52 #define MAXTAGLEN       16
    53 #define MOUSEMASK       (BUTTONMASK|PointerMotionMask)
    53 #define MOUSEMASK       (BUTTONMASK|PointerMotionMask)
    54 #define TAGMASK         ((int)((1LL << LENGTH(tags)) - 1))
    54 #define TAGMASK         ((int)((1LL << LENGTH(tags)) - 1))
    55 #define TEXTW(x)        (textnw(x, strlen(x)) + dc.font.height)
    55 #define TEXTW(x)        (textnw(x, strlen(x)) + dc.font.height)
       
    56 #define ISVISIBLE(x)    (x->tags & tagset[seltags])
    56 
    57 
    57 /* enums */
    58 /* enums */
    58 enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
    59 enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
    59 enum { ColBorder, ColFG, ColBG, ColLast };              /* color */
    60 enum { ColBorder, ColFG, ColBG, ColLast };              /* color */
    60 enum { NetSupported, NetWMName, NetLast };              /* EWMH atoms */
    61 enum { NetSupported, NetWMName, NetLast };              /* EWMH atoms */
    87 	float mina, maxa;
    88 	float mina, maxa;
    88 	int x, y, w, h;
    89 	int x, y, w, h;
    89 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
    90 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
    90 	int bw, oldbw;
    91 	int bw, oldbw;
    91 	uint tags;
    92 	uint tags;
    92 	Bool isbanned, isfixed, isfloating, isurgent;
    93 	Bool isfixed, isfloating, isurgent;
    93 	Client *next;
    94 	Client *next;
    94 	Client *snext;
    95 	Client *snext;
    95 	Window win;
    96 	Window win;
    96 };
    97 };
    97 
    98 
   271 void
   272 void
   272 arrange(void) {
   273 arrange(void) {
   273 	Client *c;
   274 	Client *c;
   274 
   275 
   275 	for(c = clients; c; c = c->next)
   276 	for(c = clients; c; c = c->next)
   276 		if(c->tags & tagset[seltags]) { /* is visible */
   277 		if(ISVISIBLE(c)) {
   277 			c->isbanned = False;
   278 			XMoveWindow(dpy, c->win, c->x, c->y);
   278 			if(!lt[sellt]->arrange || c->isfloating)
   279 			if(!lt[sellt]->arrange || c->isfloating)
   279 				resize(c, c->x, c->y, c->w, c->h, True);
   280 				resize(c, c->x, c->y, c->w, c->h, True);
   280 		}
   281 		}
   281 		else if(!c->isbanned) {
   282 		else {
   282 			XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
   283 			XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
   283 			c->isbanned = True;
       
   284 		}
   284 		}
   285 
   285 
   286 	focus(NULL);
   286 	focus(NULL);
   287 	if(lt[sellt]->arrange)
   287 	if(lt[sellt]->arrange)
   288 		lt[sellt]->arrange();
   288 		lt[sellt]->arrange();
   426 				c->x = sx + (sw / 2 - c->w / 2); /* center in x direction */
   426 				c->x = sx + (sw / 2 - c->w / 2); /* center in x direction */
   427 			if((c->y - sy + c->h) > sh && c->isfloating)
   427 			if((c->y - sy + c->h) > sh && c->isfloating)
   428 				c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */
   428 				c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */
   429 			if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight)))
   429 			if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight)))
   430 				configure(c);
   430 				configure(c);
   431 			if(!c->isbanned)
   431 			if(ISVISIBLE(c))
   432 				XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
   432 				XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
   433 		}
   433 		}
   434 		else
   434 		else
   435 			configure(c);
   435 			configure(c);
   436 	}
   436 	}
   603 		drawbar();
   603 		drawbar();
   604 }
   604 }
   605 
   605 
   606 void
   606 void
   607 focus(Client *c) {
   607 focus(Client *c) {
   608 	if(!c || c->isbanned)
   608 	if(!c || !ISVISIBLE(c))
   609 		for(c = stack; c && c->isbanned; c = c->snext);
   609 		for(c = stack; c && !ISVISIBLE(c); c = c->snext);
   610 	if(sel && sel != c) {
   610 	if(sel && sel != c) {
   611 		grabbuttons(sel, False);
   611 		grabbuttons(sel, False);
   612 		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
   612 		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
   613 	}
   613 	}
   614 	if(c) {
   614 	if(c) {
   637 	Client *c = NULL, *i;
   637 	Client *c = NULL, *i;
   638 
   638 
   639 	if(!sel)
   639 	if(!sel)
   640 		return;
   640 		return;
   641 	if (arg->i > 0) {
   641 	if (arg->i > 0) {
   642 		for(c = sel->next; c && c->isbanned; c = c->next);
   642 		for(c = sel->next; c && !ISVISIBLE(c); c = c->next);
   643 		if(!c)
   643 		if(!c)
   644 			for(c = clients; c && c->isbanned; c = c->next);
   644 			for(c = clients; c && !ISVISIBLE(c); c = c->next);
   645 	}
   645 	}
   646 	else {
   646 	else {
   647 		for(i = clients; i != sel; i = i->next)
   647 		for(i = clients; i != sel; i = i->next)
   648 			if (!i->isbanned)
   648 			if(ISVISIBLE(i))
   649 				c = i;
   649 				c = i;
   650 		if(!c)
   650 		if(!c)
   651 			for(; i; i = i->next)
   651 			for(; i; i = i->next)
   652 				if (!i->isbanned)
   652 				if(ISVISIBLE(i))
   653 					c = i;
   653 					c = i;
   654 	}
   654 	}
   655 	if(c) {
   655 	if(c) {
   656 		focus(c);
   656 		focus(c);
   657 		restack();
   657 		restack();
  1016 	}
  1016 	}
  1017 }
  1017 }
  1018 
  1018 
  1019 Client *
  1019 Client *
  1020 nexttiled(Client *c) {
  1020 nexttiled(Client *c) {
  1021 	for(; c && (c->isfloating || c->isbanned); c = c->next);
  1021 	for(; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
  1022 	return c;
  1022 	return c;
  1023 }
  1023 }
  1024 
  1024 
  1025 void
  1025 void
  1026 propertynotify(XEvent *e) {
  1026 propertynotify(XEvent *e) {
  1111 		y = sy;
  1111 		y = sy;
  1112 	if(h < bh)
  1112 	if(h < bh)
  1113 		h = bh;
  1113 		h = bh;
  1114 	if(w < bh)
  1114 	if(w < bh)
  1115 		w = bh;
  1115 		w = bh;
  1116 	if(!c->isbanned || c->x != x || c->y != y || c->w != w || c->h != h) {
  1116 	if(c->x != x || c->y != y || c->w != w || c->h != h) {
  1117 		c->x = wc.x = x;
  1117 		c->x = wc.x = x;
  1118 		c->y = wc.y = y;
  1118 		c->y = wc.y = y;
  1119 		c->w = wc.width = w;
  1119 		c->w = wc.width = w;
  1120 		c->h = wc.height = h;
  1120 		c->h = wc.height = h;
  1121 		wc.border_width = c->bw;
  1121 		wc.border_width = c->bw;
  1187 		XRaiseWindow(dpy, sel->win);
  1187 		XRaiseWindow(dpy, sel->win);
  1188 	if(lt[sellt]->arrange) {
  1188 	if(lt[sellt]->arrange) {
  1189 		wc.stack_mode = Below;
  1189 		wc.stack_mode = Below;
  1190 		wc.sibling = barwin;
  1190 		wc.sibling = barwin;
  1191 		for(c = stack; c; c = c->snext)
  1191 		for(c = stack; c; c = c->snext)
  1192 			if(!c->isfloating && !c->isbanned) {
  1192 			if(!c->isfloating && ISVISIBLE(c)) {
  1193 				XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
  1193 				XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
  1194 				wc.sibling = c->win;
  1194 				wc.sibling = c->win;
  1195 			}
  1195 			}
  1196 	}
  1196 	}
  1197 	XSync(dpy, False);
  1197 	XSync(dpy, False);