dwm.c
changeset 1376 9b2b792dce12
parent 1374 ff5fd6693d5d
child 1377 d10040d81ef8
equal deleted inserted replaced
1375:9bd33197840f 1376:9b2b792dce12
   126 	unsigned int tags;
   126 	unsigned int tags;
   127 	Bool isfloating;
   127 	Bool isfloating;
   128 } Rule;
   128 } Rule;
   129 
   129 
   130 /* function declarations */
   130 /* function declarations */
       
   131 static void adjustborder(Client *c, Bool issingle);
   131 static void applyrules(Client *c);
   132 static void applyrules(Client *c);
   132 static void arrange(void);
   133 static void arrange(void);
   133 static void attach(Client *c);
   134 static void attach(Client *c);
   134 static void attachstack(Client *c);
   135 static void attachstack(Client *c);
   135 static void buttonpress(XEvent *e);
   136 static void buttonpress(XEvent *e);
   243 /* compile-time check if all tags fit into an unsigned int bit array. */
   244 /* compile-time check if all tags fit into an unsigned int bit array. */
   244 struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; };
   245 struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; };
   245 
   246 
   246 /* function implementations */
   247 /* function implementations */
   247 void
   248 void
       
   249 adjustborder(Client *c, Bool issingle) {
       
   250 	XWindowChanges wc;
       
   251 
       
   252 	wc.border_width = issingle ? 0 : borderpx;
       
   253 	if(c->bw != wc.border_width) {
       
   254 		c->bw = wc.border_width;
       
   255 		XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
       
   256 	}
       
   257 }
       
   258 
       
   259 void
   248 applyrules(Client *c) {
   260 applyrules(Client *c) {
   249 	unsigned int i;
   261 	unsigned int i;
   250 	Rule *r;
   262 	Rule *r;
   251 	XClassHint ch = { 0 };
   263 	XClassHint ch = { 0 };
   252 
   264 
   922 		manage(ev->window, &wa);
   934 		manage(ev->window, &wa);
   923 }
   935 }
   924 
   936 
   925 void
   937 void
   926 monocle(void) {
   938 monocle(void) {
       
   939 	unsigned int n;
   927 	Client *c;
   940 	Client *c;
   928 
   941 
   929 	for(c = nexttiled(clients); c; c = nexttiled(c->next))
   942 	for(n = 0, c = nexttiled(clients); c && n < 2; c = nexttiled(c->next), n++);
       
   943 	for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
       
   944 		adjustborder(c, n == 1);
   930 		resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints);
   945 		resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints);
       
   946 	}
   931 }
   947 }
   932 
   948 
   933 void
   949 void
   934 movemouse(const Arg *arg) {
   950 movemouse(const Arg *arg) {
   935 	int x, y, ocx, ocy, di, nx, ny;
   951 	int x, y, ocx, ocy, di, nx, ny;
  1328 void
  1344 void
  1329 showhide(Client *c) {
  1345 showhide(Client *c) {
  1330 	if(!c)
  1346 	if(!c)
  1331 		return;
  1347 		return;
  1332 	if(ISVISIBLE(c)) { /* show clients top down */
  1348 	if(ISVISIBLE(c)) { /* show clients top down */
       
  1349 		adjustborder(c, False);
  1333 		XMoveWindow(dpy, c->win, c->x, c->y);
  1350 		XMoveWindow(dpy, c->win, c->x, c->y);
  1334 		if(!lt[sellt]->arrange || c->isfloating)
  1351 		if(!lt[sellt]->arrange || c->isfloating)
  1335 			resize(c, c->x, c->y, c->w, c->h, True);
  1352 			resize(c, c->x, c->y, c->w, c->h, True);
  1336 		showhide(c->snext);
  1353 		showhide(c->snext);
  1337 	}
  1354 	}
  1391 		return;
  1408 		return;
  1392 
  1409 
  1393 	/* master */
  1410 	/* master */
  1394 	c = nexttiled(clients);
  1411 	c = nexttiled(clients);
  1395 	mw = mfact * ww;
  1412 	mw = mfact * ww;
       
  1413 	adjustborder(c, n == 1);
  1396 	resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints);
  1414 	resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints);
  1397 
  1415 
  1398 	if(--n == 0)
  1416 	if(--n == 0)
  1399 		return;
  1417 		return;
  1400 
  1418 
  1405 	h = wh / n;
  1423 	h = wh / n;
  1406 	if(h < bh)
  1424 	if(h < bh)
  1407 		h = wh;
  1425 		h = wh;
  1408 
  1426 
  1409 	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
  1427 	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
       
  1428 		adjustborder(c, False);
  1410 		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
  1429 		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
  1411 		       ? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints);
  1430 		       ? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints);
  1412 		if(h != wh)
  1431 		if(h != wh)
  1413 			y = c->y + HEIGHT(c);
  1432 			y = c->y + HEIGHT(c);
  1414 	}
  1433 	}