JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Add event_drain() and drain EnterNotify where appropriate.
authorReginald Kennedy <rk@rejii.com>
Sun, 15 Jul 2012 15:24:52 +0000 (23:24 +0800)
committerReginald Kennedy <rk@rejii.com>
Fri, 20 Jul 2012 21:59:30 +0000 (05:59 +0800)
spectrwm.c

index f75a35e..f2c67fa 100644 (file)
@@ -2515,6 +2515,20 @@ focus_win(struct ws_win *win)
 }
 
 void
+event_drain(uint8_t rt)
+{
+       xcb_generic_event_t     *evt;
+
+       xcb_flush(conn);
+       while ((evt = xcb_poll_for_event(conn))) {
+               if (XCB_EVENT_RESPONSE_TYPE(evt) != rt)
+                       event_handle(evt);
+
+               free(evt);
+       }
+}
+
+void
 switchws(struct swm_region *r, union arg *args)
 {
        int                     wsid = args->id, unmap_old = 0;
@@ -2568,7 +2582,10 @@ switchws(struct swm_region *r, union arg *args)
                TAILQ_FOREACH(win, &old_ws->winlist, entry)
                        unmap_window(win);
 
-       xcb_flush(conn);
+       if (focus_mode == SWM_FOCUS_DEFAULT)
+               event_drain(XCB_ENTER_NOTIFY);
+       else
+               xcb_flush(conn);
 }
 
 void
@@ -2981,8 +2998,10 @@ cycle_layout(struct swm_region *r, union arg *args)
 
        stack();
 
-       a.id = SWM_ARG_ID_FOCUSCUR;
+       if (focus_mode == SWM_FOCUS_DEFAULT)
+               event_drain(XCB_ENTER_NOTIFY);
 
+       a.id = SWM_ARG_ID_FOCUSCUR;
        focus(r, &a);
 }
 
@@ -4112,6 +4131,7 @@ floating_toggle(struct swm_region *r, union arg *args)
        }
 
        xcb_flush(conn);
+       event_drain(XCB_ENTER_NOTIFY);
 }
 
 void