diff options
author | okan <okan> | 2019-03-11 15:25:46 +0000 |
---|---|---|
committer | okan <okan> | 2019-03-11 15:25:46 +0000 |
commit | 85d88f33042f7c397b75513e1561b361815caad7 (patch) | |
tree | 5ce311934b167cd4b8514edf062923fd2910eb84 /xevents.c | |
parent | 412b0c9ef4429d48c200910ffcc8a18b60f815ea (diff) | |
parent | 9a7528f5b99bd234f724aa229cbf75fb6a813282 (diff) | |
download | cwm-85d88f33042f7c397b75513e1561b361815caad7.tar.gz cwm-85d88f33042f7c397b75513e1561b361815caad7.tar.xz cwm-85d88f33042f7c397b75513e1561b361815caad7.zip |
cvsimport
* refs/heads/master: (23 commits) Check the atom type on propertynotify before iterating. use screen_find() for xrandr crtc changes Find the managed screen from the parent window for client_current(). Print window id in hex; while here, remove unnecessary newline. Similar to keypress event, fetch the screen from the event root window in the buttonpress handler; bail if we don't manage the screen. Allows us to find the current client based on the screen/event root. extend verbose logging for key/button events [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. add parans for readibility Teach client_current() to use a screen to find the current client instead of iterating over all (fallback if no screen provided for now). Initially convert trivial uses of client_current(). check cc->gc directly zip extra lines gc clientq inside groups, instead use the better maintained one per-screen shuffle deck chairs: rename group actions to match intent for clarity same thing as screen_find() Separate out the menu window from the client resize/move geom window; in each case, create and destroy on-demand. Isolate more menu specific code. fix a few misplaced (and misnamed) ewmh root window functions _NET_WORKAREA needs ngroups, so screen_update_geometry() needs to come after conf_group(). simplify xftcolor config Tie group number and name together during config. Move the group index (desktop number) check to the only 2 callers that require checking due to ewmh. ...
Diffstat (limited to 'xevents.c')
-rw-r--r-- | xevents.c | 85 |
1 files changed, 45 insertions, 40 deletions
diff --git a/xevents.c b/xevents.c index 8b29315..c8d85d4 100644 --- a/xevents.c +++ b/xevents.c @@ -75,11 +75,15 @@ static void xev_handle_maprequest(XEvent *ee) { XMapRequestEvent *e = &ee->xmaprequest; - struct client_ctx *cc = NULL, *old_cc; + struct screen_ctx *sc; + struct client_ctx *cc, *old_cc; - LOG_DEBUG3("window: 0x%lx", e->window); + LOG_DEBUG3("parent: 0x%lx window: 0x%lx", e->parent, e->window); - if ((old_cc = client_current()) != NULL) + if ((sc = screen_find(e->parent)) == NULL) + return; + + if ((old_cc = client_current(sc)) != NULL) client_ptrsave(old_cc); if ((cc = client_find(e->window)) == NULL) @@ -207,11 +211,9 @@ xev_handle_propertynotify(XEvent *ee) break; } } else { - TAILQ_FOREACH(sc, &Screenq, entry) { - if (sc->rootwin == e->window) { - if (e->atom == ewmh[_NET_DESKTOP_NAMES]) - xu_ewmh_net_desktop_names(sc); - } + if (e->atom == ewmh[_NET_DESKTOP_NAMES]) { + if ((sc = screen_find(e->window)) != NULL) + xu_ewmh_net_desktop_names(sc); } } } @@ -238,7 +240,11 @@ xev_handle_buttonpress(XEvent *ee) struct screen_ctx *sc; struct bind_ctx *mb; - 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; e->state &= ~IGNOREMODMASK; @@ -246,22 +252,17 @@ xev_handle_buttonpress(XEvent *ee) if (e->button == mb->press.button && e->state == mb->modmask) break; } - if (mb == NULL) return; mb->cargs->xev = CWM_XEV_BTN; switch (mb->context) { case CWM_CONTEXT_CC: if (((cc = client_find(e->window)) == NULL) && - (cc = client_current()) == NULL) + ((cc = client_current(sc)) == NULL)) return; (*mb->callback)(cc, mb->cargs); break; case CWM_CONTEXT_SC: - if (e->window != e->root) - return; - if ((sc = screen_find(e->window)) == NULL) - return; (*mb->callback)(sc, mb->cargs); break; case CWM_CONTEXT_NONE: @@ -276,7 +277,8 @@ xev_handle_buttonrelease(XEvent *ee) XButtonEvent *e = &ee->xbutton; struct client_ctx *cc; - LOG_DEBUG3("window: 0x%lx", ee->xbutton.window); + LOG_DEBUG3("root: 0x%lx window: 0x%lx subwindow: 0x%lx", + e->root, e->window, e->subwindow); if ((cc = client_find(e->window)) != NULL) { if (cc->flags & (CLIENT_ACTIVE | CLIENT_HIGHLIGHT)) { @@ -296,7 +298,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); @@ -315,20 +321,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) + 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: @@ -349,7 +352,8 @@ xev_handle_keyrelease(XEvent *ee) KeySym keysym; unsigned int i; - 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; @@ -357,7 +361,7 @@ xev_handle_keyrelease(XEvent *ee) keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0); for (i = 0; i < nitems(modkeys); i++) { if (keysym == modkeys[i]) { - if ((cc = client_current()) != NULL) { + if ((cc = client_current(sc)) != NULL) { if (sc->cycling) { sc->cycling = 0; client_mtf(cc); @@ -393,7 +397,7 @@ xev_handle_clientmessage(XEvent *ee) } } else if (e->message_type == ewmh[_NET_ACTIVE_WINDOW]) { if ((cc = client_find(e->window)) != NULL) { - if ((old_cc = client_current()) != NULL) + if ((old_cc = client_current(NULL)) != NULL) client_ptrsave(old_cc); client_show(cc); client_ptrwarp(cc); @@ -408,7 +412,9 @@ xev_handle_clientmessage(XEvent *ee) if (e->data.l[0] == (unsigned long)-1) group_movetogroup(cc, 0); else - group_movetogroup(cc, e->data.l[0]); + if (e->data.l[0] >= 0 && + e->data.l[0] < Conf.ngroups) + group_movetogroup(cc, e->data.l[0]); } } else if (e->message_type == ewmh[_NET_WM_STATE]) { if ((cc = client_find(e->window)) != NULL) { @@ -417,7 +423,9 @@ xev_handle_clientmessage(XEvent *ee) } } else if (e->message_type == ewmh[_NET_CURRENT_DESKTOP]) { if ((sc = screen_find(e->window)) != NULL) { - group_only(sc, e->data.l[0]); + if (e->data.l[0] >= 0 && + e->data.l[0] < Conf.ngroups) + group_only(sc, e->data.l[0]); } } } @@ -425,20 +433,17 @@ xev_handle_clientmessage(XEvent *ee) static void xev_handle_randr(XEvent *ee) { - XRRScreenChangeNotifyEvent *rev = (XRRScreenChangeNotifyEvent *)ee; + XRRScreenChangeNotifyEvent *e = (XRRScreenChangeNotifyEvent *)ee; struct screen_ctx *sc; - int i; - LOG_DEBUG3("new size: %d/%d", rev->width, rev->height); + LOG_DEBUG3("size: %d/%d", e->width, e->height); - i = XRRRootToScreen(X_Dpy, rev->root); - TAILQ_FOREACH(sc, &Screenq, entry) { - if (sc->which == i) { - XRRUpdateConfiguration(ee); - screen_update_geometry(sc); - screen_assert_clients_within(sc); - } - } + if ((sc = screen_find(e->root)) == NULL) + return; + + XRRUpdateConfiguration(ee); + screen_update_geometry(sc); + screen_assert_clients_within(sc); } /* @@ -479,9 +484,9 @@ xev_process(void) while (XPending(X_Dpy)) { XNextEvent(X_Dpy, &e); - if (e.type - Conf.xrandr_event_base == RRScreenChangeNotify) + if ((e.type - Conf.xrandr_event_base) == RRScreenChangeNotify) xev_handle_randr(&e); - else if (e.type < LASTEvent && xev_handlers[e.type] != NULL) + else if ((e.type < LASTEvent) && (xev_handlers[e.type] != NULL)) (*xev_handlers[e.type])(&e); } } |