about summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2013-10-25 19:46:16 +0000
committerokan <okan>2013-10-25 19:46:16 +0000
commit0c99788f66ca591381601768c53ddf4ba203372a (patch)
tree1fce649dc4d803a2fc242bc68f77a9fcd09bd535
parent0d6e8a9146309f5dab93b4d15abfa91aac31ec5f (diff)
parent6e17b41f566865629d3dd35a6a60e081e6e2b089 (diff)
downloadcwm-0c99788f66ca591381601768c53ddf4ba203372a.tar.gz
cwm-0c99788f66ca591381601768c53ddf4ba203372a.tar.xz
cwm-0c99788f66ca591381601768c53ddf4ba203372a.zip
cvsimport
-rw-r--r--calmwm.h5
-rw-r--r--client.c24
-rw-r--r--conf.c4
-rw-r--r--group.c6
-rw-r--r--kbfunc.c4
-rw-r--r--mousefunc.c10
-rw-r--r--xevents.c4
-rw-r--r--xutil.c75
8 files changed, 63 insertions, 69 deletions
diff --git a/calmwm.h b/calmwm.h
index 5430cd4..ef9cdd3 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -385,7 +385,7 @@ struct client_ctx	*client_current(void);
 void			 client_cycle(struct screen_ctx *, int);
 void			 client_cycle_leave(struct screen_ctx *,
 			     struct client_ctx *);
-void			 client_delete(struct client_ctx *);
+void			 client_delete(struct client_ctx *, int);
 void			 client_draw_border(struct client_ctx *);
 struct client_ctx	*client_find(Window);
 void			 client_freeze(struct client_ctx *);
@@ -523,11 +523,12 @@ void			 conf_screen(struct screen_ctx *);
 void			 xev_loop(void);
 
 void			 xu_btn_grab(Window, int, u_int);
-void			 xu_btn_ungrab(Window, int, u_int);
+void			 xu_btn_ungrab(Window);
 int			 xu_getprop(Window, Atom, Atom, long, unsigned char **);
 int			 xu_get_wm_state(Window, int *);
 int			 xu_getstrprop(Window, Atom, char **);
 void			 xu_key_grab(Window, u_int, KeySym);
+void			 xu_key_ungrab(Window);
 void			 xu_ptr_getpos(Window, int *, int *);
 int			 xu_ptr_grab(Window, u_int, Cursor);
 int			 xu_ptr_regrab(u_int, Cursor);
diff --git a/client.c b/client.c
index f293147..e22f4c9 100644
--- a/client.c
+++ b/client.c
@@ -145,17 +145,19 @@ client_init(Window win, struct screen_ctx *sc, int mapped)
 }
 
 void
-client_delete(struct client_ctx *cc)
+client_delete(struct client_ctx *cc, int destroy)
 {
 	struct screen_ctx	*sc = cc->sc;
 	struct winname		*wn;
 
-	XGrabServer(X_Dpy);
-	cc->state = WithdrawnState;
-	xu_set_wm_state(cc->win, cc->state);
-	XRemoveFromSaveSet(X_Dpy, cc->win);
-	XSync(X_Dpy, False);
-	XUngrabServer(X_Dpy);
+	if (destroy) {
+		XGrabServer(X_Dpy);
+		cc->state = WithdrawnState;
+		xu_set_wm_state(cc->win, cc->state);
+		XRemoveFromSaveSet(X_Dpy, cc->win);
+		XSync(X_Dpy, False);
+		XUngrabServer(X_Dpy);
+	}
 
 	TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
 	TAILQ_REMOVE(&Clientq, cc, entry);
@@ -186,15 +188,10 @@ client_delete(struct client_ctx *cc)
 void
 client_leave(struct client_ctx *cc)
 {
-	struct screen_ctx	*sc;
-
 	if (cc == NULL)
 		cc = client_current();
 	if (cc == NULL)
 		return;
-
-	sc = cc->sc;
-	xu_btn_ungrab(sc->rootwin, AnyModifier, Button1);
 }
 
 void
@@ -396,8 +393,6 @@ client_resize(struct client_ctx *cc, int reset)
 		xu_ewmh_set_net_wm_state(cc);
 	}
 
-	client_draw_border(cc);
-
 	XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x,
 	    cc->geom.y, cc->geom.w, cc->geom.h);
 	client_config(cc);
@@ -493,7 +488,6 @@ client_unhide(struct client_ctx *cc)
 	cc->flags &= ~CLIENT_HIDDEN;
 	cc->state = NormalState;
 	xu_set_wm_state(cc->win, cc->state);
-	client_draw_border(cc);
 }
 
 void
diff --git a/conf.c b/conf.c
index e2f49b4..cd8f9d2 100644
--- a/conf.c
+++ b/conf.c
@@ -649,6 +649,8 @@ conf_grab_mouse(Window win)
 {
 	struct mousebinding	*mb;
 
+	xu_btn_ungrab(win);
+
 	TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
 		if (mb->flags != MOUSEBIND_CTX_WIN)
 			continue;
@@ -661,7 +663,7 @@ conf_grab_kbd(Window win)
 {
 	struct keybinding	*kb;
 
-	XUngrabKey(X_Dpy, AnyKey, AnyModifier, win);
+	xu_key_ungrab(win);
 
 	TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
 		xu_key_grab(win, kb->modmask, kb->keysym);
diff --git a/group.c b/group.c
index d59704d..85fc921 100644
--- a/group.c
+++ b/group.c
@@ -177,7 +177,7 @@ group_movetogroup(struct client_ctx *cc, int idx)
 	struct group_ctx	*gc;
 
 	if (idx < 0 || idx >= CALMWM_NGROUPS)
-		err(1, "group_movetogroup: index out of range (%d)", idx);
+		errx(1, "group_movetogroup: index out of range (%d)", idx);
 
 	gc = &sc->groups[idx];
 	if (cc->group == gc)
@@ -240,7 +240,7 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
 	struct group_ctx	*gc;
 
 	if (idx < 0 || idx >= CALMWM_NGROUPS)
-		err(1, "group_hidetoggle: index out of range (%d)", idx);
+		errx(1, "group_hidetoggle: index out of range (%d)", idx);
 
 	gc = &sc->groups[idx];
 	group_fix_hidden_state(gc);
@@ -261,7 +261,7 @@ group_only(struct screen_ctx *sc, int idx)
 	int	 i;
 
 	if (idx < 0 || idx >= CALMWM_NGROUPS)
-		err(1, "group_only: index out of range (%d)", idx);
+		errx(1, "group_only: index out of range (%d)", idx);
 
 	for (i = 0; i < CALMWM_NGROUPS; i++) {
 		if (i == idx)
diff --git a/kbfunc.c b/kbfunc.c
index 2059b0a..3717b39 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -250,7 +250,7 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
 			label = "wm";
 			break;
 		default:
-			err(1, "kbfunc_exec: invalid cmd %d", cmd);
+			errx(1, "kbfunc_exec: invalid cmd %d", cmd);
 			/*NOTREACHED*/
 	}
 
@@ -305,7 +305,7 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
 				warn("%s", mi->text);
 				break;
 			default:
-				err(1, "kb_func: egad, cmd changed value!");
+				errx(1, "kb_func: egad, cmd changed value!");
 				break;
 		}
 	}
diff --git a/mousefunc.c b/mousefunc.c
index 8053fe7..0de35c8 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -88,12 +88,9 @@ mousefunc_client_resize(struct client_ctx *cc, void *arg)
 	mousefunc_sweep_draw(cc);
 
 	for (;;) {
-		XMaskEvent(X_Dpy, MOUSEMASK|ExposureMask, &ev);
+		XMaskEvent(X_Dpy, MOUSEMASK, &ev);
 
 		switch (ev.type) {
-		case Expose:
-			client_draw_border(cc);
-			break;
 		case MotionNotify:
 			mousefunc_sweep_calc(cc, x, y,
 			    ev.xmotion.x_root, ev.xmotion.y_root);
@@ -143,12 +140,9 @@ mousefunc_client_move(struct client_ctx *cc, void *arg)
 	xu_ptr_getpos(cc->win, &px, &py);
 
 	for (;;) {
-		XMaskEvent(X_Dpy, MOUSEMASK|ExposureMask, &ev);
+		XMaskEvent(X_Dpy, MOUSEMASK, &ev);
 
 		switch (ev.type) {
-		case Expose:
-			client_draw_border(cc);
-			break;
 		case MotionNotify:
 			cc->geom.x = ev.xmotion.x_root - px - cc->bwidth;
 			cc->geom.y = ev.xmotion.y_root - py - cc->bwidth;
diff --git a/xevents.c b/xevents.c
index 1713cd5..57a43c5 100644
--- a/xevents.c
+++ b/xevents.c
@@ -113,7 +113,7 @@ xev_handle_unmapnotify(XEvent *ee)
 		 */
 		if (XCheckTypedWindowEvent(X_Dpy, cc->win,
 		    DestroyNotify, &ev) || e->send_event != 0) {
-			client_delete(cc);
+			client_delete(cc, 1);
 		} else
 			client_hide(cc);
 	}
@@ -127,7 +127,7 @@ xev_handle_destroynotify(XEvent *ee)
 	struct client_ctx	*cc;
 
 	if ((cc = client_find(e->window)) != NULL)
-		client_delete(cc);
+		client_delete(cc, 0);
 }
 
 static void
diff --git a/xutil.c b/xutil.c
index 45c19e9..ca07cae 100644
--- a/xutil.c
+++ b/xutil.c
@@ -32,6 +32,45 @@
 
 static unsigned int ign_mods[] = { 0, LockMask, Mod2Mask, Mod2Mask | LockMask };
 
+void
+xu_btn_grab(Window win, int mask, u_int btn)
+{
+	u_int	i;
+
+	for (i = 0; i < nitems(ign_mods); i++)
+		XGrabButton(X_Dpy, btn, (mask | ign_mods[i]), win,
+		    False, BUTTONMASK, GrabModeAsync,
+		    GrabModeSync, None, None);
+}
+
+void
+xu_btn_ungrab(Window win)
+{
+	XUngrabButton(X_Dpy, AnyButton, AnyModifier, win);
+}
+
+void
+xu_key_grab(Window win, u_int mask, KeySym keysym)
+{
+	KeyCode	 code;
+	u_int	 i;
+
+	code = XKeysymToKeycode(X_Dpy, keysym);
+	if ((XkbKeycodeToKeysym(X_Dpy, code, 0, 0) != keysym) &&
+	    (XkbKeycodeToKeysym(X_Dpy, code, 0, 1) == keysym))
+		mask |= ShiftMask;
+
+	for (i = 0; i < nitems(ign_mods); i++)
+		XGrabKey(X_Dpy, code, (mask | ign_mods[i]), win,
+		    True, GrabModeAsync, GrabModeAsync);
+}
+
+void
+xu_key_ungrab(Window win)
+{
+	XUngrabKey(X_Dpy, AnyKey, AnyModifier, win);
+}
+
 int
 xu_ptr_grab(Window win, u_int mask, Cursor curs)
 {
@@ -54,26 +93,6 @@ xu_ptr_ungrab(void)
 }
 
 void
-xu_btn_grab(Window win, int mask, u_int btn)
-{
-	u_int	i;
-
-	for (i = 0; i < nitems(ign_mods); i++)
-		XGrabButton(X_Dpy, btn, (mask | ign_mods[i]), win,
-		    False, BUTTONMASK, GrabModeAsync,
-		    GrabModeSync, None, None);
-}
-
-void
-xu_btn_ungrab(Window win, int mask, u_int btn)
-{
-	u_int	i;
-
-	for (i = 0; i < nitems(ign_mods); i++)
-		XUngrabButton(X_Dpy, btn, (mask | ign_mods[i]), win);
-}
-
-void
 xu_ptr_getpos(Window win, int *x, int *y)
 {
 	Window	 w0, w1;
@@ -89,22 +108,6 @@ xu_ptr_setpos(Window win, int x, int y)
 	XWarpPointer(X_Dpy, None, win, 0, 0, 0, 0, x, y);
 }
 
-void
-xu_key_grab(Window win, u_int mask, KeySym keysym)
-{
-	KeyCode	 code;
-	u_int	 i;
-
-	code = XKeysymToKeycode(X_Dpy, keysym);
-	if ((XkbKeycodeToKeysym(X_Dpy, code, 0, 0) != keysym) &&
-	    (XkbKeycodeToKeysym(X_Dpy, code, 0, 1) == keysym))
-		mask |= ShiftMask;
-
-	for (i = 0; i < nitems(ign_mods); i++)
-		XGrabKey(X_Dpy, code, (mask | ign_mods[i]), win,
-		    True, GrabModeAsync, GrabModeAsync);
-}
-
 int
 xu_getprop(Window win, Atom atm, Atom type, long len, unsigned char **p)
 {