dwm.c
changeset 1188 1765468a0546
parent 1187 264e671527e6
child 1190 c8eaba1445a4
equal deleted inserted replaced
1187:264e671527e6 1188:1765468a0546
   158 unsigned int idxoftag(const char *t);
   158 unsigned int idxoftag(const char *t);
   159 void initfont(const char *fontstr);
   159 void initfont(const char *fontstr);
   160 Bool isoccupied(unsigned int t);
   160 Bool isoccupied(unsigned int t);
   161 Bool isprotodel(Client *c);
   161 Bool isprotodel(Client *c);
   162 Bool isurgent(unsigned int t);
   162 Bool isurgent(unsigned int t);
   163 Bool isvisible(Client *c);
   163 Bool isvisible(Client *c, Bool *cmp);
   164 void keypress(XEvent *e);
   164 void keypress(XEvent *e);
   165 void killclient(const char *arg);
   165 void killclient(const char *arg);
   166 void manage(Window w, XWindowAttributes *wa);
   166 void manage(Window w, XWindowAttributes *wa);
   167 void mappingnotify(XEvent *e);
   167 void mappingnotify(XEvent *e);
   168 void maprequest(XEvent *e);
   168 void maprequest(XEvent *e);
   285 void
   285 void
   286 arrange(void) {
   286 arrange(void) {
   287 	Client *c;
   287 	Client *c;
   288 
   288 
   289 	for(c = clients; c; c = c->next)
   289 	for(c = clients; c; c = c->next)
   290 		if(isvisible(c)) {
   290 		if(isvisible(c, NULL)) {
   291 			unban(c);
   291 			unban(c);
   292 			if(lt->isfloating || c->isfloating)
   292 			if(lt->isfloating || c->isfloating)
   293 				resize(c, c->fx, c->fy, c->fw, c->fh, True);
   293 				resize(c, c->fx, c->fy, c->fw, c->fh, True);
   294 		}
   294 		}
   295 		else
   295 		else
   467 			if((c->y - sy + c->h) > sh && c->isfloating)
   467 			if((c->y - sy + c->h) > sh && c->isfloating)
   468 				c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */
   468 				c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */
   469 			if((ev->value_mask & (CWX|CWY))
   469 			if((ev->value_mask & (CWX|CWY))
   470 			&& !(ev->value_mask & (CWWidth|CWHeight)))
   470 			&& !(ev->value_mask & (CWWidth|CWHeight)))
   471 				configure(c);
   471 				configure(c);
   472 			if(isvisible(c))
   472 			if(isvisible(c, NULL))
   473 				XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
   473 				XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
   474 		}
   474 		}
   475 		else
   475 		else
   476 			configure(c);
   476 			configure(c);
   477 	}
   477 	}
   534 	if(bgw > 0) {
   534 	if(bgw > 0) {
   535 		dc.w = bgw;
   535 		dc.w = bgw;
   536 		drawtext(geom->symbol, dc.norm, False);
   536 		drawtext(geom->symbol, dc.norm, False);
   537 		dc.x += bgw;
   537 		dc.x += bgw;
   538 	}
   538 	}
   539 	for(c = stack; c && !isvisible(c); c = c->snext);
   539 	for(c = stack; c && !isvisible(c, NULL); c = c->snext);
   540 	for(i = 0; i < LENGTH(tags); i++) {
   540 	for(i = 0; i < LENGTH(tags); i++) {
   541 		dc.w = textw(tags[i]);
   541 		dc.w = textw(tags[i]);
   542 		if(tagset[seltags][i]) {
   542 		if(tagset[seltags][i]) {
   543 			drawtext(tags[i], dc.sel, isurgent(i));
   543 			drawtext(tags[i], dc.sel, isurgent(i));
   544 			drawsquare(c && c->tags[i], isoccupied(i), isurgent(i), dc.sel);
   544 			drawsquare(c && c->tags[i], isoccupied(i), isurgent(i), dc.sel);
   674 		drawbar();
   674 		drawbar();
   675 }
   675 }
   676 
   676 
   677 void
   677 void
   678 focus(Client *c) {
   678 focus(Client *c) {
   679 	if(!c || (c && !isvisible(c)))
   679 	if(!c || (c && !isvisible(c, NULL)))
   680 		for(c = stack; c && !isvisible(c); c = c->snext);
   680 		for(c = stack; c && !isvisible(c, NULL); c = c->snext);
   681 	if(sel && sel != c) {
   681 	if(sel && sel != c) {
   682 		grabbuttons(sel, False);
   682 		grabbuttons(sel, False);
   683 		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
   683 		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
   684 	}
   684 	}
   685 	if(c) {
   685 	if(c) {
   709 focusnext(const char *arg) {
   709 focusnext(const char *arg) {
   710 	Client *c;
   710 	Client *c;
   711 
   711 
   712 	if(!sel)
   712 	if(!sel)
   713 		return;
   713 		return;
   714 	for(c = sel->next; c && !isvisible(c); c = c->next);
   714 	for(c = sel->next; c && !isvisible(c, arg ? sel->tags : NULL); c = c->next);
   715 	if(!c)
   715 	if(!c)
   716 		for(c = clients; c && !isvisible(c); c = c->next);
   716 		for(c = clients; c && !isvisible(c, arg ? sel->tags : NULL); c = c->next);
   717 	if(c) {
   717 	if(c) {
   718 		focus(c);
   718 		focus(c);
   719 		restack();
   719 		restack();
   720 	}
   720 	}
   721 }
   721 }
   724 focusprev(const char *arg) {
   724 focusprev(const char *arg) {
   725 	Client *c;
   725 	Client *c;
   726 
   726 
   727 	if(!sel)
   727 	if(!sel)
   728 		return;
   728 		return;
   729 	for(c = sel->prev; c && !isvisible(c); c = c->prev);
   729 	for(c = sel->prev; c && !isvisible(c, arg ? sel->tags : NULL); c = c->prev);
   730 	if(!c) {
   730 	if(!c) {
   731 		for(c = clients; c && c->next; c = c->next);
   731 		for(c = clients; c && c->next; c = c->next);
   732 		for(; c && !isvisible(c); c = c->prev);
   732 		for(; c && !isvisible(c, arg ? sel->tags : NULL); c = c->prev);
   733 	}
   733 	}
   734 	if(c) {
   734 	if(c) {
   735 		focus(c);
   735 		focus(c);
   736 		restack();
   736 		restack();
   737 	}
   737 	}
   928 			return True;
   928 			return True;
   929 	return False;
   929 	return False;
   930 }
   930 }
   931 
   931 
   932 Bool
   932 Bool
   933 isvisible(Client *c) {
   933 isvisible(Client *c, Bool *cmp) {
   934 	unsigned int i;
   934 	unsigned int i;
   935 
   935 
       
   936 	if(!cmp)
       
   937 		cmp = tagset[seltags];
   936 	for(i = 0; i < LENGTH(tags); i++)
   938 	for(i = 0; i < LENGTH(tags); i++)
   937 		if(c->tags[i] && tagset[seltags][i])
   939 		if(c->tags[i] && cmp[i])
   938 			return True;
   940 			return True;
   939 	return False;
   941 	return False;
   940 }
   942 }
   941 
   943 
   942 void
   944 void
  1059 void
  1061 void
  1060 monocle(void) {
  1062 monocle(void) {
  1061 	Client *c;
  1063 	Client *c;
  1062 
  1064 
  1063 	for(c = clients; c; c = c->next)
  1065 	for(c = clients; c; c = c->next)
  1064 		if((lt->isfloating || !c->isfloating) &&  isvisible(c))
  1066 		if((lt->isfloating || !c->isfloating) &&  isvisible(c, NULL))
  1065 			resize(c, mox, moy, mow - 2 * c->bw, moh - 2 * c->bw, RESIZEHINTS);
  1067 			resize(c, mox, moy, mow - 2 * c->bw, moh - 2 * c->bw, RESIZEHINTS);
  1066 }
  1068 }
  1067 
  1069 
  1068 void
  1070 void
  1069 movemouse(Client *c) {
  1071 movemouse(Client *c) {
  1113 	}
  1115 	}
  1114 }
  1116 }
  1115 
  1117 
  1116 Client *
  1118 Client *
  1117 nexttiled(Client *c) {
  1119 nexttiled(Client *c) {
  1118 	for(; c && (c->isfloating || !isvisible(c)); c = c->next);
  1120 	for(; c && (c->isfloating || !isvisible(c, NULL)); c = c->next);
  1119 	return c;
  1121 	return c;
  1120 }
  1122 }
  1121 
  1123 
  1122 void
  1124 void
  1123 propertynotify(XEvent *e) {
  1125 propertynotify(XEvent *e) {
  1290 		XRaiseWindow(dpy, sel->win);
  1292 		XRaiseWindow(dpy, sel->win);
  1291 	if(!lt->isfloating) {
  1293 	if(!lt->isfloating) {
  1292 		wc.stack_mode = Below;
  1294 		wc.stack_mode = Below;
  1293 		wc.sibling = barwin;
  1295 		wc.sibling = barwin;
  1294 		for(c = stack; c; c = c->snext)
  1296 		for(c = stack; c; c = c->snext)
  1295 			if(!c->isfloating && isvisible(c)) {
  1297 			if(!c->isfloating && isvisible(c, NULL)) {
  1296 				XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
  1298 				XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
  1297 				wc.sibling = c->win;
  1299 				wc.sibling = c->win;
  1298 			}
  1300 			}
  1299 	}
  1301 	}
  1300 	XSync(dpy, False);
  1302 	XSync(dpy, False);