diff options
author | okan <okan> | 2018-02-06 15:05:20 +0000 |
---|---|---|
committer | okan <okan> | 2018-02-06 15:05:20 +0000 |
commit | 63ebc0cd8b65300104929d3463fed431996f4374 (patch) | |
tree | f547800ff23c62896ad849d2148ec7adf3f08f0d /xevents.c | |
parent | a0774f4777a4a94ea4bbc867c16cde3167075f80 (diff) | |
parent | f3211427c16b755db20bc71ce4074e9fb9aae8af (diff) | |
download | cwm-63ebc0cd8b65300104929d3463fed431996f4374.tar.gz cwm-63ebc0cd8b65300104929d3463fed431996f4374.tar.xz cwm-63ebc0cd8b65300104929d3463fed431996f4374.zip |
cvsimport
* refs/heads/master: (28 commits) Use screen's saved view instead of re-querying the server. Slightly expand and expose verbose debugging. add debugging for x events Add a simple debug logging mechanism. Simplification; use asprintf where appropriate now. Use func attributes where appropriate. Fix wins comparison declaration since it's unsigned from XQueryTree(). Generate name_to_func[] in a clean and readable fashion. Shrink tier[] by one after removing matchname in r1.55. If the requested group number is invalid, bail but don't kill cwm. Quick fix: exit after a failed execvp in u_spawn instead; previously we did in u_exec, but the introduction of re-exec'ing the previous invocation of cwm if 'exec_wm' failed missed the 'exec' failing path. Will likely split out as a proper fix. Only exec the fallback when in CWM_EXEC_WM state. Typo, from Julien Steinhauser. Convert menu-exec-wm from an abritrary exec menu, into a config-based menu from which one may configure (wm <name> <path_and_args>) (and choose) specific window managers to replace the running one. 'wm cwm cwm' is included by default. As done for buttonrelease, work specific un-cycling and un-highlighting actions into the keyrelease event, only performing what's actually needed for each; should result in much fewer events against keyreleases. No intended behaviour change. Merge group_toggle_membership_leave into the buttonrelease event and only do border work for a group/ungroup action. add helper function client_show to bring together like actions for unhide/raise Add support for re-exec'ing with SIGHUP; equivalent to the already built-in 'restart' function. Use poll and XNextEvent to replace XNextEvent blocking inside the x11 event handler. zap stray that snuck in ...
Diffstat (limited to 'xevents.c')
-rw-r--r-- | xevents.c | 64 |
1 files changed, 52 insertions, 12 deletions
diff --git a/xevents.c b/xevents.c index 560cbb4..6518dc0 100644 --- a/xevents.c +++ b/xevents.c @@ -77,6 +77,8 @@ xev_handle_maprequest(XEvent *ee) XMapRequestEvent *e = &ee->xmaprequest; struct client_ctx *cc = NULL, *old_cc; + LOG_DEBUG3("window: 0x%lx", e->window); + if ((old_cc = client_current()) != NULL) client_ptrsave(old_cc); @@ -93,6 +95,8 @@ xev_handle_unmapnotify(XEvent *ee) XUnmapEvent *e = &ee->xunmap; struct client_ctx *cc; + LOG_DEBUG3("window: 0x%lx", e->window); + if ((cc = client_find(e->window)) != NULL) { if (e->send_event) { client_set_wm_state(cc, WithdrawnState); @@ -109,6 +113,8 @@ xev_handle_destroynotify(XEvent *ee) XDestroyWindowEvent *e = &ee->xdestroywindow; struct client_ctx *cc; + LOG_DEBUG3("window: 0x%lx", e->window); + if ((cc = client_find(e->window)) != NULL) client_delete(cc); } @@ -121,6 +127,8 @@ xev_handle_configurerequest(XEvent *ee) struct screen_ctx *sc; XWindowChanges wc; + LOG_DEBUG3("window: 0x%lx", e->window); + if ((cc = client_find(e->window)) != NULL) { sc = cc->sc; @@ -174,6 +182,8 @@ xev_handle_propertynotify(XEvent *ee) struct screen_ctx *sc; struct client_ctx *cc; + LOG_DEBUG3("window: 0x%lx", e->window); + if ((cc = client_find(e->window)) != NULL) { switch (e->atom) { case XA_WM_NORMAL_HINTS: @@ -209,6 +219,8 @@ xev_handle_enternotify(XEvent *ee) XCrossingEvent *e = &ee->xcrossing; struct client_ctx *cc; + LOG_DEBUG3("window: 0x%lx", e->window); + Last_Event_Time = e->time; if ((cc = client_find(e->window)) != NULL) @@ -223,6 +235,8 @@ xev_handle_buttonpress(XEvent *ee) struct screen_ctx *sc; struct bind_ctx *mb; + LOG_DEBUG3("window: 0x%lx", e->window); + e->state &= ~IGNOREMODMASK; TAILQ_FOREACH(mb, &Conf.mousebindq, entry) { @@ -259,9 +273,13 @@ xev_handle_buttonrelease(XEvent *ee) XButtonEvent *e = &ee->xbutton; struct client_ctx *cc; + LOG_DEBUG3("window: 0x%lx", ee->xbutton.window); + if ((cc = client_find(e->window)) != NULL) { - if (cc->flags & CLIENT_ACTIVE) - group_toggle_membership_leave(cc); + if (cc->flags & (CLIENT_ACTIVE | CLIENT_HIGHLIGHT)) { + cc->flags &= ~CLIENT_HIGHLIGHT; + client_draw_border(cc); + } } } @@ -275,6 +293,8 @@ xev_handle_keypress(XEvent *ee) KeySym keysym, skeysym; unsigned int modshift; + LOG_DEBUG3("window: 0x%lx", e->window); + keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0); skeysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 1); @@ -322,16 +342,29 @@ xev_handle_keyrelease(XEvent *ee) { XKeyEvent *e = &ee->xkey; struct screen_ctx *sc; + struct client_ctx *cc; KeySym keysym; unsigned int i; + LOG_DEBUG3("window: 0x%lx", e->window); + if ((sc = screen_find(e->root)) == NULL) return; keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0); for (i = 0; i < nitems(modkeys); i++) { if (keysym == modkeys[i]) { - client_cycle_leave(sc); + if ((cc = client_current()) != NULL) { + if (sc->cycling) { + sc->cycling = 0; + client_mtf(cc); + } + if (cc->flags & CLIENT_HIGHLIGHT) { + cc->flags &= ~CLIENT_HIGHLIGHT; + client_draw_border(cc); + } + } + XUngrabKeyboard(X_Dpy, CurrentTime); break; } } @@ -344,6 +377,8 @@ xev_handle_clientmessage(XEvent *ee) struct client_ctx *cc, *old_cc; struct screen_ctx *sc; + LOG_DEBUG3("window: 0x%lx", e->window); + if (e->message_type == cwmh[WM_CHANGE_STATE]) { if ((cc = client_find(e->window)) != NULL) { if (e->data.l[0] == IconicState) @@ -357,10 +392,7 @@ xev_handle_clientmessage(XEvent *ee) if ((cc = client_find(e->window)) != NULL) { if ((old_cc = client_current()) != NULL) client_ptrsave(old_cc); - if (cc->flags & CLIENT_HIDDEN) - client_unhide(cc); - else - client_raise(cc); + client_show(cc); client_ptrwarp(cc); } } else if (e->message_type == ewmh[_NET_WM_DESKTOP]) { @@ -394,6 +426,8 @@ xev_handle_randr(XEvent *ee) struct screen_ctx *sc; int i; + LOG_DEBUG3("new size: %d/%d", rev->width, rev->height); + i = XRRRootToScreen(X_Dpy, rev->root); TAILQ_FOREACH(sc, &Screenq, entry) { if (sc->which == i) { @@ -414,6 +448,8 @@ xev_handle_mappingnotify(XEvent *ee) XMappingEvent *e = &ee->xmapping; struct screen_ctx *sc; + LOG_DEBUG3("window: 0x%lx", e->window); + XRefreshKeyboardMapping(e); if (e->request == MappingKeyboard) { TAILQ_FOREACH(sc, &Screenq, entry) @@ -427,6 +463,8 @@ xev_handle_expose(XEvent *ee) XExposeEvent *e = &ee->xexpose; struct client_ctx *cc; + LOG_DEBUG3("window: 0x%lx", e->window); + if ((cc = client_find(e->window)) != NULL && e->count == 0) client_draw_border(cc); } @@ -436,9 +474,11 @@ xev_process(void) { XEvent e; - XNextEvent(X_Dpy, &e); - if (e.type - Conf.xrandr_event_base == RRScreenChangeNotify) - xev_handle_randr(&e); - else if (e.type < LASTEvent && xev_handlers[e.type] != NULL) - (*xev_handlers[e.type])(&e); + while (XPending(X_Dpy)) { + XNextEvent(X_Dpy, &e); + if (e.type - Conf.xrandr_event_base == RRScreenChangeNotify) + xev_handle_randr(&e); + else if (e.type < LASTEvent && xev_handlers[e.type] != NULL) + (*xev_handlers[e.type])(&e); + } } |