From a88b8c1363bfcb9ddaf1311f6d1e43021a5ce180 Mon Sep 17 00:00:00 2001 From: okan Date: Thu, 17 Oct 2013 13:59:10 +0000 Subject: a few err->errx since we don't have error messages here; from Tiago Cunha --- group.c | 6 +++--- kbfunc.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/group.c b/group.c index 9e388fd..2c62ae6 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 906ca12..4c28a2b 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; } } -- cgit 1.4.1 From a70b2d81af54121eb080d7e9f149b892f78a0b67 Mon Sep 17 00:00:00 2001 From: okan Date: Sat, 19 Oct 2013 00:24:54 +0000 Subject: For clients that support WM_TAKE_FOCUS in their WM_PROTOCOLS property, send a ClientMessage event. --- client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client.c b/client.c index ee069c5..d1d6877 100644 --- a/client.c +++ b/client.c @@ -213,6 +213,8 @@ client_setactive(struct client_ctx *cc, int fg) XInstallColormap(X_Dpy, cc->colormap); XSetInputFocus(X_Dpy, cc->win, RevertToPointerRoot, CurrentTime); + if (cc->xproto & _WM_TAKE_FOCUS) + client_msg(cc, cwmh[WM_TAKE_FOCUS]); conf_grab_mouse(cc->win); /* * If we're in the middle of alt-tabbing, don't change -- cgit 1.4.1 From 083a023f2c0f36676d1015e1713ccac1b99bad59 Mon Sep 17 00:00:00 2001 From: okan Date: Sat, 19 Oct 2013 18:59:22 +0000 Subject: I believe we redraw the border in too many cases; likely a leftover from the cc->pwin days - don't redraw on every unhide, resize, and mouse move/resize Expose event (note, all Expose events trigger a redraw anyway). Tested with some finicky X apps I could think of, though I'm sure others will find more - if so, and they 'lose' the border, please report! --- client.c | 3 --- mousefunc.c | 10 ++-------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/client.c b/client.c index d1d6877..0733f88 100644 --- a/client.c +++ b/client.c @@ -398,8 +398,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); @@ -495,7 +493,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/mousefunc.c b/mousefunc.c index faf9b65..31cf951 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; -- cgit 1.4.1 From a2013ee9dd9b152c044f8120a89c3d5aa17af4ea Mon Sep 17 00:00:00 2001 From: okan Date: Sat, 19 Oct 2013 19:39:34 +0000 Subject: Using xu_btn_ungrab() buttons during client_leave doesn't work (error BadValue) when the modifier is already AnyModifier . Instead alter xu_btn_ungrab() to ungrab AnyButton/AnyModifier and call it only when a client is coming into focus in client_setactive(), instead of iterating over ignore mods - matches how we handle key grabs. --- calmwm.h | 2 +- client.c | 5 ----- conf.c | 2 ++ xutil.c | 7 ++----- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/calmwm.h b/calmwm.h index 07e223c..e888bac 100644 --- a/calmwm.h +++ b/calmwm.h @@ -511,7 +511,7 @@ 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 **); diff --git a/client.c b/client.c index 0733f88..cd0732f 100644 --- a/client.c +++ b/client.c @@ -186,15 +186,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 diff --git a/conf.c b/conf.c index ea657f1..ce3ee1e 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; diff --git a/xutil.c b/xutil.c index 543b8b0..f33fa9a 100644 --- a/xutil.c +++ b/xutil.c @@ -65,12 +65,9 @@ xu_btn_grab(Window win, int mask, u_int btn) } void -xu_btn_ungrab(Window win, int mask, u_int btn) +xu_btn_ungrab(Window win) { - u_int i; - - for (i = 0; i < nitems(ign_mods); i++) - XUngrabButton(X_Dpy, btn, (mask | ign_mods[i]), win); + XUngrabButton(X_Dpy, AnyButton, AnyModifier, win); } void -- cgit 1.4.1 From 9ff288baefadb19f50def66072d1a9a765efe5b5 Mon Sep 17 00:00:00 2001 From: okan Date: Sun, 20 Oct 2013 01:35:47 +0000 Subject: revert 1.138 (WM_TAKE_FOCUS) for now --- client.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/client.c b/client.c index cd0732f..1c41d7e 100644 --- a/client.c +++ b/client.c @@ -208,8 +208,6 @@ client_setactive(struct client_ctx *cc, int fg) XInstallColormap(X_Dpy, cc->colormap); XSetInputFocus(X_Dpy, cc->win, RevertToPointerRoot, CurrentTime); - if (cc->xproto & _WM_TAKE_FOCUS) - client_msg(cc, cwmh[WM_TAKE_FOCUS]); conf_grab_mouse(cc->win); /* * If we're in the middle of alt-tabbing, don't change -- cgit 1.4.1 From 5b733a152daa01493301333a7e756394f9b45455 Mon Sep 17 00:00:00 2001 From: okan Date: Sun, 20 Oct 2013 01:55:32 +0000 Subject: wrap key ungrab like btn ungrab, for it'll be used again --- calmwm.h | 1 + conf.c | 2 +- xutil.c | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/calmwm.h b/calmwm.h index e888bac..5a827b4 100644 --- a/calmwm.h +++ b/calmwm.h @@ -516,6 +516,7 @@ 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/conf.c b/conf.c index ce3ee1e..68a5351 100644 --- a/conf.c +++ b/conf.c @@ -663,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/xutil.c b/xutil.c index f33fa9a..30a89f8 100644 --- a/xutil.c +++ b/xutil.c @@ -102,6 +102,12 @@ xu_key_grab(Window win, u_int mask, KeySym keysym) True, GrabModeAsync, GrabModeAsync); } +void +xu_key_ungrab(Window win) +{ + XUngrabKey(X_Dpy, AnyKey, AnyModifier, win); +} + int xu_getprop(Window win, Atom atm, Atom type, long len, unsigned char **p) { -- cgit 1.4.1 From 6867821abefd761a840befcfee5a1f1f2fef9831 Mon Sep 17 00:00:00 2001 From: okan Date: Sun, 20 Oct 2013 02:00:02 +0000 Subject: shuffle --- xutil.c | 74 ++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/xutil.c b/xutil.c index 30a89f8..73dfac0 100644 --- a/xutil.c +++ b/xutil.c @@ -32,27 +32,6 @@ static unsigned int ign_mods[] = { 0, LockMask, Mod2Mask, Mod2Mask | LockMask }; -int -xu_ptr_grab(Window win, u_int mask, Cursor curs) -{ - return (XGrabPointer(X_Dpy, win, False, mask, - GrabModeAsync, GrabModeAsync, - None, curs, CurrentTime) == GrabSuccess ? 0 : -1); -} - -int -xu_ptr_regrab(u_int mask, Cursor curs) -{ - return (XChangeActivePointerGrab(X_Dpy, mask, - curs, CurrentTime) == GrabSuccess ? 0 : -1); -} - -void -xu_ptr_ungrab(void) -{ - XUngrabPointer(X_Dpy, CurrentTime); -} - void xu_btn_grab(Window win, int mask, u_int btn) { @@ -70,22 +49,6 @@ xu_btn_ungrab(Window win) XUngrabButton(X_Dpy, AnyButton, AnyModifier, win); } -void -xu_ptr_getpos(Window win, int *x, int *y) -{ - Window w0, w1; - int tmp0, tmp1; - u_int tmp2; - - XQueryPointer(X_Dpy, win, &w0, &w1, &tmp0, &tmp1, x, y, &tmp2); -} - -void -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) { @@ -108,6 +71,43 @@ xu_key_ungrab(Window win) XUngrabKey(X_Dpy, AnyKey, AnyModifier, win); } +int +xu_ptr_grab(Window win, u_int mask, Cursor curs) +{ + return (XGrabPointer(X_Dpy, win, False, mask, + GrabModeAsync, GrabModeAsync, + None, curs, CurrentTime) == GrabSuccess ? 0 : -1); +} + +int +xu_ptr_regrab(u_int mask, Cursor curs) +{ + return (XChangeActivePointerGrab(X_Dpy, mask, + curs, CurrentTime) == GrabSuccess ? 0 : -1); +} + +void +xu_ptr_ungrab(void) +{ + XUngrabPointer(X_Dpy, CurrentTime); +} + +void +xu_ptr_getpos(Window win, int *x, int *y) +{ + Window w0, w1; + int tmp0, tmp1; + u_int tmp2; + + XQueryPointer(X_Dpy, win, &w0, &w1, &tmp0, &tmp1, x, y, &tmp2); +} + +void +xu_ptr_setpos(Window win, int x, int y) +{ + XWarpPointer(X_Dpy, None, win, 0, 0, 0, 0, x, y); +} + int xu_getprop(Window win, Atom atm, Atom type, long len, unsigned char **p) { -- cgit 1.4.1 From 6e17b41f566865629d3dd35a6a60e081e6e2b089 Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 25 Oct 2013 19:46:16 +0000 Subject: A client_delete should behave differently depending on whether the triggering event was unmap (with pending destroy) log destroy; we only need to grab/ungrab the server lock, set WithdrawnState and XRemoveFromSaveSet clients coming from an unmap event - doing so for clients coming from destroy are already gone, hence we generate errors. --- calmwm.h | 2 +- client.c | 16 +++++++++------- xevents.c | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/calmwm.h b/calmwm.h index 5a827b4..4f20a81 100644 --- a/calmwm.h +++ b/calmwm.h @@ -373,7 +373,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 *); diff --git a/client.c b/client.c index 1c41d7e..d9184df 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); diff --git a/xevents.c b/xevents.c index 4b6ad60..e6247ab 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 -- cgit 1.4.1