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@
This commit is contained in:
okan 2008-05-19 12:56:58 +00:00
parent a94f4bbb7a
commit 7957a470fd
6 changed files with 23 additions and 1 deletions

View File

@ -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 *);

View File

@ -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);
}

2
conf.c
View File

@ -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 },

4
cwm.1
View File

@ -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 8 2008 $
.Dd $Mdocdate: April 15 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

View File

@ -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)
{

View File

@ -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);
}