X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=spectrwm.c;h=6f250722a2fd97e7edd93375c06287e40dc03490;hb=1379273ef00e95dac859a4a0e0d201c5d14411ee;hp=b21a37ffb40962d15a3631f67143ddb483369290;hpb=73d7b552f08b90bb844e329bade5794e8f5fd566;p=spectrwm.git diff --git a/spectrwm.c b/spectrwm.c index b21a37f..6f25072 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -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) { @@ -7134,7 +7157,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 +7776,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. */ @@ -7779,6 +7802,9 @@ 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)); } }