xiwm

simple window manager
git clone https://git.ce9e.org/xiwm.git

commit
ce6afb97c2cebedffad6cdb01e7914ba3d2ce391
parent
4935b77a1613f5810db14602bd7e484c50d44697
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2019-10-14 06:46
treat subwindows properly

-	exclude from tab order
-	focus on them instead of transient
-	still can be focused
-	focus transient on close

Diffstat

M xiwm.c 42 ++++++++++++++++++++++++++++++------------

1 files changed, 30 insertions, 12 deletions


diff --git a/xiwm.c b/xiwm.c

@@ -48,7 +48,7 @@ struct Client {
   48    48 	unsigned int desktop;
   49    49 	Position position;
   50    50 	Bool isfixed, isfullscreen, isdock;
   51    -1 	Client *next;
   -1    51 	Client *next, *transient;
   52    52 	Window win;
   53    53 };
   54    54 
@@ -314,6 +314,17 @@ layout(void)
  314   314 }
  315   315 
  316   316 void
   -1   317 raiseclient(Client *c)
   -1   318 {
   -1   319 	Client *i;
   -1   320 
   -1   321 	XRaiseWindow(dpy, c->win);
   -1   322 	for (i = clients; i; i = i->next)
   -1   323 		if (i->transient == c)
   -1   324 			XRaiseWindow(dpy, i->win);
   -1   325 }
   -1   326 
   -1   327 void
  317   328 restack(void)
  318   329 {
  319   330 	Client *c;
@@ -324,8 +335,8 @@ restack(void)
  324   335 	if (sel[desktop]->position == PLeft || sel[desktop]->position == PRight)
  325   336 		for (c = clients; c; c = c->next)
  326   337 			if (ISVISIBLE(c) && (c->position == PLeft || c->position == PRight))
  327    -1 				XRaiseWindow(dpy, c->win);
  328    -1 	XRaiseWindow(dpy, sel[desktop]->win);
   -1   338 				raiseclient(c);
   -1   339 	raiseclient(sel[desktop]);
  329   340 	XSync(dpy, False);
  330   341 	while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
  331   342 }
@@ -445,12 +456,14 @@ detach(Client *c)
  445   456 
  446   457 	for (i = 0; i < DESKTOPS; i++)
  447   458 		if (c == sel[i])
  448    -1 			sel[i] = NULL;
   -1   459 			sel[i] = c->transient;
  449   460 }
  450   461 
  451   462 void
  452   463 focus(Client *c)
  453   464 {
   -1   465 	Client *i, *d;
   -1   466 
  454   467 	if (!c || !ISVISIBLE(c))
  455   468 		for (c = clients; c && !ISVISIBLE(c); c = c->next);
  456   469 	if (sel[desktop] && sel[desktop] != c) {
@@ -458,11 +471,15 @@ focus(Client *c)
  458   471 		XSetWindowBorder(dpy, sel[desktop]->win, COL_NORM);
  459   472 	}
  460   473 	if (c) {
  461    -1 		XSetWindowBorder(dpy, c->win, COL_HIGH);
   -1   474 		d = c;
   -1   475 		for (i = clients; i; i = i->next)
   -1   476 			if (i->transient == c)
   -1   477 				d = i;
   -1   478 		XSetWindowBorder(dpy, d->win, COL_HIGH);
  462   479 		grabbuttons(c, True);
  463    -1 		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
   -1   480 		XSetInputFocus(dpy, d->win, RevertToPointerRoot, CurrentTime);
  464   481 		XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW, 32,
  465    -1 			PropModeReplace, (unsigned char *) &(c->win), 1);
   -1   482 			PropModeReplace, (unsigned char *) &(d->win), 1);
  466   483 	} else {
  467   484 		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
  468   485 		XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
@@ -490,6 +507,7 @@ manage(Window w, XWindowAttributes *wa)
  490   507 	applyrules(c);
  491   508 	if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans)))
  492   509 		c->desktop = t->desktop;
   -1   510 	c->transient = t;
  493   511 	xsetclientdesktop(c);
  494   512 	updatewindowtype(c);
  495   513 	updatefixed(c);
@@ -771,16 +789,16 @@ focusstack(const Arg *arg)
  771   789 	if (!sel[desktop])
  772   790 		return;
  773   791 	if (arg->i > 0) {
  774    -1 		for (c = sel[desktop]->next; c && !ISVISIBLE(c); c = c->next);
   -1   792 		for (c = sel[desktop]->next; c && (!ISVISIBLE(c) || c->transient); c = c->next);
  775   793 		if (!c)
  776    -1 			for (c = clients; c && !ISVISIBLE(c); c = c->next);
   -1   794 			for (c = clients; c && (!ISVISIBLE(c) || c->transient); c = c->next);
  777   795 	} else {
  778    -1 		for (i = clients; i != sel[desktop]; i = i->next)
  779    -1 			if (ISVISIBLE(i))
   -1   796 		for (i = clients; i && i != sel[desktop]; i = i->next)
   -1   797 			if (ISVISIBLE(i) && !i->transient)
  780   798 				c = i;
  781   799 		if (!c)
  782   800 			for (; i; i = i->next)
  783    -1 				if (ISVISIBLE(i))
   -1   801 				if (ISVISIBLE(i) && !i->transient)
  784   802 					c = i;
  785   803 	}
  786   804 	if (c)