about summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2018-11-14 19:22:51 +0000
committerokan <okan>2018-11-14 19:22:51 +0000
commit544b4da339347c75f56ca2229ffddb4bdcf86fa0 (patch)
tree2ec8dc8dd2c5f3cd82d7f99e54b7ef7dd20773c8
parentb4d4eba6afbc58d0a242e14a342cc42d1529bdfe (diff)
parent695eb1d8e52c8498afe342ec8ecd404fbffb9e1c (diff)
downloadcwm-544b4da339347c75f56ca2229ffddb4bdcf86fa0.tar.gz
cwm-544b4da339347c75f56ca2229ffddb4bdcf86fa0.tar.xz
cwm-544b4da339347c75f56ca2229ffddb4bdcf86fa0.zip
cvsimport
* refs/heads/master:
  Stop asking for events (NoEventMask) from menu window once done with the menu (we don't destroy it, only unmap).
  Allow 'transientfor' clients to inherit group and bwidth either during init or via property notify events. Previously only the flags were set but nothing was in the path to apply said flags and/or bwidth. Required slight of re-orgnaization of client_init.
  merge from base, from sashan@:
  Use the original client border width to adjust initial placement of clients containing {P,US}Position requests where they are explicitly set to 'ignore' in cwmrc(5); clients are unaware that their border will be altered (removed in this case) when calcuating position and thus end up a factor of their original border width off once mapped by cwm(1). cwm(1) will essentially shift the client to the edge if the original request's position and border match.
-rw-r--r--calmwm.h1
-rw-r--r--client.c42
-rw-r--r--conf.c5
-rw-r--r--menu.c1
-rw-r--r--parse.y3
-rw-r--r--xevents.c3
6 files changed, 35 insertions, 20 deletions
diff --git a/calmwm.h b/calmwm.h
index 1076f96..8e44228 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -151,6 +151,7 @@ struct client_ctx {
 	Window			 win;
 	Colormap		 colormap;
 	int			 bwidth; /* border width */
+	int			 obwidth; /* original border width */
 	struct geom		 geom, savegeom, fullgeom;
 	struct {
 		long		 flags;	/* defined hints */
diff --git a/client.c b/client.c
index ed8e914..8794f28 100644
--- a/client.c
+++ b/client.c
@@ -62,10 +62,9 @@ client_init(Window win, struct screen_ctx *sc, int active)
 		mapped = wattr.map_state != IsUnmapped;
 	}
 
-	cc = xmalloc(sizeof(*cc));
-
 	XGrabServer(X_Dpy);
 
+	cc = xmalloc(sizeof(*cc));
 	cc->sc = sc;
 	cc->win = win;
 	cc->label = NULL;
@@ -74,29 +73,33 @@ client_init(Window win, struct screen_ctx *sc, int active)
 	cc->stackingorder = 0;
 	memset(&cc->hint, 0, sizeof(cc->hint));
 	memset(&cc->ch, 0, sizeof(cc->ch));
-
 	TAILQ_INIT(&cc->nameq);
-	client_setname(cc);
 
+	cc->geom.x = wattr.x;
+	cc->geom.y = wattr.y;
+	cc->geom.w = wattr.width;
+	cc->geom.h = wattr.height;
+	cc->colormap = wattr.colormap;
+	cc->obwidth = wattr.border_width;
+	cc->bwidth = Conf.bwidth;
+
+	client_setname(cc);
 	conf_client(cc);
 
 	XGetClassHint(X_Dpy, cc->win, &cc->ch);
 	client_wm_hints(cc);
 	client_wm_protocols(cc);
 	client_getsizehints(cc);
+	client_transient(cc);
 	client_mwm_hints(cc);
 
-	cc->geom.x = wattr.x;
-	cc->geom.y = wattr.y;
-	cc->geom.w = wattr.width;
-	cc->geom.h = wattr.height;
+	if ((cc->flags & CLIENT_IGNORE))
+		cc->bwidth = 0;
 	cc->dim.w = (cc->geom.w - cc->hint.basew) / cc->hint.incw;
 	cc->dim.h = (cc->geom.h - cc->hint.baseh) / cc->hint.inch;
 	cc->ptr.x = cc->geom.w / 2;
 	cc->ptr.y = cc->geom.h / 2;
 
-	cc->colormap = wattr.colormap;
-
 	if (wattr.map_state != IsViewable) {
 		client_placecalc(cc);
 		client_resize(cc, 0);
@@ -113,8 +116,6 @@ client_init(Window win, struct screen_ctx *sc, int active)
 
 	XAddToSaveSet(X_Dpy, cc->win);
 
-	client_transient(cc);
-
 	/* Notify client of its configuration. */
 	client_config(cc);
 
@@ -130,6 +131,10 @@ client_init(Window win, struct screen_ctx *sc, int active)
 		client_unhide(cc);
 
 	if (mapped) {
+		if (cc->gc) {
+			group_movetogroup(cc, cc->gc->num);
+			goto out;
+		}
 		if (group_restore(cc))
 			goto out;
 		if (group_autogroup(cc))
@@ -760,6 +765,12 @@ client_placecalc(struct client_ctx *cc)
 			cc->geom.x = sc->view.h - cc->bwidth - 1;
 		if (cc->geom.y + cc->geom.h + cc->bwidth <= 0)
 			cc->geom.y = -(cc->geom.h + cc->bwidth - 1);
+		if (cc->flags & CLIENT_IGNORE) {
+			if (((cc->obwidth * 2) + cc->geom.x + cc->geom.w) == sc->view.w)
+				cc->geom.x += cc->obwidth * 2;
+			if (((cc->obwidth * 2) + cc->geom.y + cc->geom.h) == sc->view.h)
+				cc->geom.y += cc->obwidth * 2;
+		}
 	} else {
 		struct geom		 area;
 		int			 xmouse, ymouse;
@@ -919,10 +930,11 @@ client_transient(struct client_ctx *cc)
 	Window			 trans;
 
 	if (XGetTransientForHint(X_Dpy, cc->win, &trans)) {
-		if ((tc = client_find(trans)) != NULL && tc->gc) {
-			group_movetogroup(cc, tc->gc->num);
-			if (tc->flags & CLIENT_IGNORE)
+		if ((tc = client_find(trans)) != NULL) {
+			if (tc->flags & CLIENT_IGNORE) {
 				cc->flags |= CLIENT_IGNORE;
+				cc->bwidth = tc->bwidth;
+			}
 		}
 	}
 }
diff --git a/conf.c b/conf.c
index 9afa965..d6d88d2 100644
--- a/conf.c
+++ b/conf.c
@@ -434,16 +434,13 @@ void
 conf_client(struct client_ctx *cc)
 {
 	struct winname	*wn;
-	int		 ignore = 0;
 
 	TAILQ_FOREACH(wn, &Conf.ignoreq, entry) {
 		if (strncasecmp(wn->name, cc->name, strlen(wn->name)) == 0) {
-			ignore = 1;
+			cc->flags |= CLIENT_IGNORE;
 			break;
 		}
 	}
-	cc->bwidth = (ignore) ? 0 : Conf.bwidth;
-	cc->flags |= (ignore) ? CLIENT_IGNORE : 0;
 }
 
 void
diff --git a/menu.c b/menu.c
index 9323463..c7d2c93 100644
--- a/menu.c
+++ b/menu.c
@@ -159,6 +159,7 @@ out:
 		mi = NULL;
 	}
 
+	XSelectInput(X_Dpy, sc->menu.win, NoEventMask);
 	XSetInputFocus(X_Dpy, focuswin, focusrevert, CurrentTime);
 	/* restore if user didn't move */
 	xu_ptr_getpos(sc->rootwin, &xcur, &ycur);
diff --git a/parse.y b/parse.y
index e9dce3a..6af67dc 100644
--- a/parse.y
+++ b/parse.y
@@ -469,7 +469,8 @@ yylex(void)
 			} else if (c == '\\') {
 				if ((next = lgetc(quotec)) == EOF)
 					return (0);
-				if (next == quotec || c == ' ' || c == '\t')
+				if (next == quotec || next == ' ' ||
+				    next == '\t')
 					c = next;
 				else if (next == '\n') {
 					file->lineno++;
diff --git a/xevents.c b/xevents.c
index 6518dc0..e5c76fe 100644
--- a/xevents.c
+++ b/xevents.c
@@ -198,6 +198,9 @@ xev_handle_propertynotify(XEvent *ee)
 			break;
 		case XA_WM_TRANSIENT_FOR:
 			client_transient(cc);
+			client_draw_border(cc);
+			if (cc->gc)
+				group_movetogroup(cc, cc->gc->num);
 			break;
 		default:
 			/* do nothing */