X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=scrotwm.c;h=0aa4860eafb3d62556450dc29faf7bc6502da0f0;hb=bd31f84c17cd31466203ffa6b6806141c359c295;hp=307e004f4b7ccfda7f1a262043c538dc2e23000b;hpb=8c1136de23e6e1bfe951fc1e2c9f3c06ba08bda0;p=spectrwm.git diff --git a/scrotwm.c b/scrotwm.c index 307e004..0aa4860 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -100,7 +100,6 @@ static const char *cvstag = "$scrotwm$"; #endif #endif -#define SWM_DEBUG /*#define SWM_DEBUG*/ #ifdef SWM_DEBUG #define DPRINTF(x...) do { if (swm_debug) fprintf(stderr, x); } while (0) @@ -1382,6 +1381,18 @@ bar_setup(struct swm_region *r) } void +drain_enter_notify(void) +{ + int i = 0; + XEvent cne; + + while (XCheckMaskEvent(display, EnterWindowMask, &cne)) + i++; + + DNPRINTF(SWM_D_MISC, "drain_enter_notify: drained %d\n", i); +} + +void set_win_state(struct ws_win *win, long state) { long data[] = {state, None}; @@ -1519,7 +1530,7 @@ unmap_window(struct ws_win *win) if (getstate(win->id) == IconicState) return; - set_win_state(win, InactiveState); + set_win_state(win, IconicState); XUnmapWindow(display, win->id); XSetWindowBorder(display, win->id, @@ -1960,12 +1971,16 @@ switchws(struct swm_region *r, union arg *args) stack(); a.id = SWM_ARG_ID_FOCUSCUR; focus(new_ws->r, &a); + bar_update(); /* unmap old windows */ if (unmap_old) TAILQ_FOREACH(win, &old_ws->winlist, entry) unmap_window(win); + + if (focus_mode == SWM_FOCUS_DEFAULT) + drain_enter_notify(); } void @@ -2376,6 +2391,9 @@ stack(void) { } if (font_adjusted) font_adjusted--; + + if (focus_mode == SWM_FOCUS_DEFAULT) + drain_enter_notify(); } void @@ -3258,7 +3276,7 @@ resize(struct ws_win *win, union arg *args) XUngrabPointer(display, CurrentTime); /* drain events */ - while (XCheckMaskEvent(display, EnterWindowMask, &ev)); + drain_enter_notify(); } void @@ -3352,7 +3370,7 @@ move(struct ws_win *win, union arg *args) XUngrabPointer(display, CurrentTime); /* drain events */ - while (XCheckMaskEvent(display, EnterWindowMask, &ev)); + drain_enter_notify(); } /* user/key callable function IDs */ @@ -4778,10 +4796,6 @@ manage_window(Window id) XSelectInput(display, id, EnterWindowMask | FocusChangeMask | PropertyChangeMask | StructureNotifyMask); - if (win->iconic) - set_win_state(win, IconicState); - else - set_win_state(win, NormalState); /* floaters need to be mapped if they are in the current workspace */ if ((win->floating || win->transient) && (ws->idx == r->ws->idx)) @@ -5025,11 +5039,6 @@ enternotify(XEvent *e) switch (focus_mode) { case SWM_FOCUS_DEFAULT: - if (QLength(display)) { - DNPRINTF(SWM_D_EVENT, "ignore enternotify %d\n", - QLength(display)); - return; - } break; case SWM_FOCUS_FOLLOW: break; @@ -5279,6 +5288,21 @@ unmapnotify(XEvent *e) if (getstate(e->xunmap.window) == NormalState) { unmanage_window(win); stack(); + + /* giant hack for apps that don't destroy transient windows */ + /* eat a bunch of events to prevent remanaging the window */ + XEvent cne; + while (XCheckWindowEvent(display, e->xunmap.window, + EnterWindowMask, &cne)) + ; + while (XCheckWindowEvent(display, e->xunmap.window, + StructureNotifyMask, &cne)) + ; + while (XCheckWindowEvent(display, e->xunmap.window, + SubstructureNotifyMask, &cne)) + ; + /* resend unmap because we ated it */ + XUnmapWindow(display, e->xunmap.window); } } @@ -5565,7 +5589,7 @@ grab_windows(void) continue; state = getstate(wins[j]); - manage = state == IconicState || InactiveState; + manage = state == IconicState; if (wa.map_state == IsViewable || manage) manage_window(wins[j]); } @@ -5576,7 +5600,7 @@ grab_windows(void) continue; state = getstate(wins[j]); - manage = state == IconicState || InactiveState; + manage = state == IconicState; if (XGetTransientForHint(display, wins[j], &d1) && manage) manage_window(wins[j]);