From 281da1fba3c4cf7c09351c088ec4f5793f9ce96e Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 19 May 2008 12:56:58 +0000 Subject: finally implement keyboard binding for group toggling idea for the "slightly-less-abhorrent-hack-but-a-hack-nonetheless-TM" from oga@ grab and ungrab the keyboard to get around some silly X apps that like stealing events ok oga@ --- calmwm.h | 3 ++- client.c | 3 ++- conf.c | 4 +++- cwm.1 | 6 ++++-- kbfunc.c | 12 +++++++++++- xevents.c | 8 +++++++- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/calmwm.h b/calmwm.h index 20b0ace..9c65680 100644 --- a/calmwm.h +++ b/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: calmwm.h,v 1.41 2008/05/18 19:43:50 oga Exp $ + * $Id: calmwm.h,v 1.42 2008/05/19 12:56:58 okan Exp $ */ #ifndef _CALMWM_H_ @@ -434,6 +434,7 @@ void kbfunc_client_group(struct client_ctx *, void *); void kbfunc_client_nextgroup(struct client_ctx *, void *); void kbfunc_client_prevgroup(struct client_ctx *, void *); void kbfunc_client_nogroup(struct client_ctx *, void *); +void kbfunc_client_grouptoggle(struct client_ctx *, void *); void kbfunc_client_maximize(struct client_ctx *, void *); void kbfunc_client_vmaximize(struct client_ctx *, void *); void kbfunc_quit_wm(struct client_ctx *, void *); diff --git a/client.c b/client.c index a67e787..b869ab5 100644 --- a/client.c +++ b/client.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: client.c,v 1.23 2008/05/18 20:00:16 okan Exp $ + * $Id: client.c,v 1.24 2008/05/19 12:56:58 okan Exp $ */ #include "headers.h" @@ -438,6 +438,7 @@ client_unhide(struct client_ctx *cc) XMapWindow(X_Dpy, cc->win); XMapRaised(X_Dpy, cc->pwin); + cc->highlight = 0; cc->flags &= ~CLIENT_HIDDEN; xu_setstate(cc, NormalState); } diff --git a/conf.c b/conf.c index b527262..7197449 100644 --- a/conf.c +++ b/conf.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: conf.c,v 1.31 2008/05/18 19:47:19 oga Exp $ + * $Id: conf.c,v 1.32 2008/05/19 12:56:58 okan Exp $ */ #include "headers.h" @@ -117,6 +117,7 @@ conf_init(struct conf *c) conf_bindname(c, "CM-9", "group9"); conf_bindname(c, "M-Right", "nextgroup"); conf_bindname(c, "M-Left", "prevgroup"); + conf_bindname(c, "CM-g", "grouptoggle"); conf_bindname(c, "CM-f", "maximize"); conf_bindname(c, "CM-equal", "vmaximize"); conf_bindname(c, "CMS-q", "quit"); @@ -224,6 +225,7 @@ struct { { "nogroup", kbfunc_client_nogroup, 0, 0 }, { "nextgroup", kbfunc_client_nextgroup, 0, 0 }, { "prevgroup", kbfunc_client_prevgroup, 0, 0 }, + { "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, 0}, { "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, 0 }, { "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, 0 }, { "quit", kbfunc_quit_wm, 0, 0 }, diff --git a/cwm.1 b/cwm.1 index 29daa45..6eaad75 100644 --- a/cwm.1 +++ b/cwm.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwm.1,v 1.27 2008/04/15 18:33:13 okan Exp $ +.\" $OpenBSD: cwm.1,v 1.28 2008/05/19 12:56:58 okan Exp $ .\" .\" Copyright (c) 2004,2005 Marius Aamodt Eriksen .\" @@ -15,7 +15,7 @@ .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .\" The following requests are required for all man pages. -.Dd $Mdocdate: April 15 2008 $ +.Dd $Mdocdate: May 19 2008 $ .Dt CWM 1 .Os .Sh NAME @@ -83,6 +83,8 @@ Delete current window. Select group n, where n is 1-9. .It Ic C-M-0 Select all groups. +.It Ic C-M-g +Toggle a window's membership in the current group. .It Ic M-Right Switch to next group. .It Ic M-Left diff --git a/kbfunc.c b/kbfunc.c index be94be3..ef5d0da 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: kbfunc.c,v 1.22 2008/04/16 13:47:29 oga Exp $ + * $Id: kbfunc.c,v 1.23 2008/05/19 12:56:58 okan Exp $ */ #include @@ -429,6 +429,16 @@ kbfunc_client_nogroup(struct client_ctx *cc, void *arg) group_alltoggle(); } +void +kbfunc_client_grouptoggle(struct client_ctx *cc, void *arg) +{ + /* XXX for stupid X apps like xpdf and gvim */ + XGrabKeyboard(X_Dpy, cc->pwin, True, + GrabModeAsync, GrabModeAsync, CurrentTime); + + group_sticky_toggle_enter(cc); +} + void kbfunc_client_maximize(struct client_ctx *cc, void *arg) { diff --git a/xevents.c b/xevents.c index 9b44f6a..c0e53d0 100644 --- a/xevents.c +++ b/xevents.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: xevents.c,v 1.14 2008/05/18 20:06:36 okan Exp $ + * $Id: xevents.c,v 1.15 2008/05/19 12:56:58 okan Exp $ */ /* @@ -408,6 +408,7 @@ xev_handle_keyrelease(struct xevent *xev, XEvent *ee) { XKeyEvent *e = &ee->xkey; struct screen_ctx *sc = screen_fromroot(e->root); + struct client_ctx *cc = client_current(); int keysym; keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0); @@ -422,6 +423,11 @@ xev_handle_keyrelease(struct xevent *xev, XEvent *ee) */ client_mtf(NULL); + if (cc != NULL) { + group_sticky_toggle_exit(cc); + XUngrabKeyboard(X_Dpy, CurrentTime); + } + out: xev_register(xev); } -- cgit v1.2.3-2-gb3c3