]> code.delx.au - spectrwm/blobdiff - spectrwm.c
Fix keyboard move and resize operation delay.
[spectrwm] / spectrwm.c
index b21a37ffb40962d15a3631f67143ddb483369290..a94e2cd5e9c37cce6eba0e13046dd8bb768bbfb0 100644 (file)
@@ -703,6 +703,7 @@ char        *get_atom_name(xcb_atom_t);
 char   *get_notify_detail_label(uint8_t);
 char   *get_notify_mode_label(uint8_t);
 #endif
+struct ws_win  *get_pointer_win(xcb_window_t);
 struct ws_win  *get_region_focus(struct swm_region *);
 xcb_screen_t   *get_screen(int);
 char   *get_win_name(xcb_window_t);
@@ -2449,6 +2450,28 @@ restart(struct swm_region *r, union arg *args)
        quit(NULL, NULL);
 }
 
+struct ws_win *
+get_pointer_win(xcb_window_t root)
+{
+       struct ws_win                   *win = NULL;
+       xcb_query_pointer_reply_t       *r;
+
+       DNPRINTF(SWM_D_EVENT, "get_pointer_win: root: 0x%x.\n", root);
+
+       r = xcb_query_pointer_reply(conn, xcb_query_pointer(conn, root), NULL);
+       if (r) {
+               win = find_window(r->child);
+               if (win) {
+                       DNPRINTF(SWM_D_EVENT, "get_pointer_win: 0x%x.\n",
+                           win->id);
+               } else {
+                       DNPRINTF(SWM_D_EVENT, "get_pointer_win: none.\n");
+               }
+       }
+
+       return win;
+}
+
 struct swm_region *
 root_to_region(xcb_window_t root, int check)
 {
@@ -4334,7 +4357,6 @@ search_resp_uniconify(char *resp, unsigned long len)
                if (strncmp(s, resp, len) == 0) {
                        /* XXX this should be a callback to generalize */
                        set_swm_iconic(win, 0);
-                       xcb_flush(conn);
                        free(s);
                        break;
                }
@@ -4823,6 +4845,7 @@ resize_step(struct swm_region *r, union arg *args)
                return;
 
        resize(win, args);
+       focus_flush();
 }
 
 #define SWM_MOVE_STEPS (50)
@@ -4969,6 +4992,7 @@ move_step(struct swm_region *r, union arg *args)
                return;
 
        move(win, args);
+       focus_flush();
 }
 
 /* user/key callable function IDs */
@@ -7134,7 +7158,7 @@ keypress(xcb_key_press_event_t *e)
 void
 buttonpress(xcb_button_press_event_t *e)
 {
-       struct ws_win           *win;
+       struct ws_win           *win = NULL;
        struct swm_region       *r, *old_r;
        int                     i;
        int                     handled = 0;
@@ -7753,10 +7777,10 @@ unmapnotify(xcb_unmap_notify_event_t *e)
        if (win == NULL)
                return;
 
+       win->mapped = 0;
        ws = win->ws;
 
        if (getstate(e->window) == XCB_ICCCM_WM_STATE_NORMAL) {
-               win->mapped = 0;
                set_win_state(win, XCB_ICCCM_WM_STATE_ICONIC);
 
                /* If we were focused, make sure we focus on something else. */
@@ -7769,7 +7793,7 @@ unmapnotify(xcb_unmap_notify_event_t *e)
                stack();
 
                DNPRINTF(SWM_D_EVENT, "unmapnotify: focus_pending: 0x%x\n",
-                   ws->focus_pending->id);
+                   WINID(ws->focus_pending));
 
                if (focus_mode != SWM_FOCUS_FOLLOW) {
                        if (ws->focus_pending) {
@@ -7779,6 +7803,11 @@ unmapnotify(xcb_unmap_notify_event_t *e)
                }
 
                focus_flush();
+       } else if (focus_mode == SWM_FOCUS_FOLLOW) {
+               if (ws->r) {
+                       focus_win(get_pointer_win(ws->r->s->root));
+                       xcb_flush(conn);
+               }
        }
 }