From bf43b6241405dffa02ae15bf4ec1d55f84ea52aa Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 8 Mar 2019 14:48:02 +0000 Subject: [keypress event] turns out we've been checking the wrong window for a matching client thus always falling back to client_current(); while the current client is problaby right in most cases, use event's subwindow (not window) to find the client. Bail early if this event came to us from a screen we don't manage. This is result of us grabing all keybindings off the root window instead of selectively. --- xevents.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/xevents.c b/xevents.c index cdbfdfc..bbf8722 100644 --- a/xevents.c +++ b/xevents.c @@ -292,7 +292,11 @@ xev_handle_keypress(XEvent *ee) KeySym keysym, skeysym; unsigned int modshift; - LOG_DEBUG3("window: 0x%lx", e->window); + LOG_DEBUG3("root: 0x%lx window: 0x%lx subwindow: 0x%lx ", + e->root, e->window, e->subwindow); + + if ((sc = screen_find(e->root)) == NULL) + return; keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0); skeysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 1); @@ -311,20 +315,17 @@ xev_handle_keypress(XEvent *ee) if (kb->press.keysym == ((modshift == 0) ? keysym : skeysym)) break; } - if (kb == NULL) return; kb->cargs->xev = CWM_XEV_KEY; switch (kb->context) { case CWM_CONTEXT_CC: - if (((cc = client_find(e->window)) == NULL) && - ((cc = client_current(NULL)) == NULL)) + if (((cc = client_find(e->subwindow)) == NULL) && + ((cc = client_current(sc)) == NULL)) return; (*kb->callback)(cc, kb->cargs); break; case CWM_CONTEXT_SC: - if ((sc = screen_find(e->window)) == NULL) - return; (*kb->callback)(sc, kb->cargs); break; case CWM_CONTEXT_NONE: -- cgit 1.4.1