From 87ae7955848439ef68c4ff3bd1b0ed87da09a3e0 Mon Sep 17 00:00:00 2001 From: nwwdles Date: Thu, 6 Aug 2020 20:54:22 +0300 Subject: [PATCH] Handle WM_CHANGE_STATE, unhide windows on focus --- src/bspwm.c | 2 ++ src/bspwm.h | 1 + src/events.c | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/src/bspwm.c b/src/bspwm.c index dca03fde..e6e2bd49 100644 --- a/src/bspwm.c +++ b/src/bspwm.c @@ -79,6 +79,7 @@ motion_recorder_t motion_recorder; xcb_atom_t WM_STATE; xcb_atom_t WM_TAKE_FOCUS; xcb_atom_t WM_DELETE_WINDOW; +xcb_atom_t WM_CHANGE_STATE; int exit_status; bool auto_raise; @@ -394,6 +395,7 @@ void setup(void) GETATOM(WM_STATE) GETATOM(WM_DELETE_WINDOW) GETATOM(WM_TAKE_FOCUS) + GETATOM(WM_CHANGE_STATE) #undef GETATOM const xcb_query_extension_reply_t *qep = xcb_get_extension_data(dpy, &xcb_randr_id); diff --git a/src/bspwm.h b/src/bspwm.h index 139d4c30..080fd188 100644 --- a/src/bspwm.h +++ b/src/bspwm.h @@ -78,6 +78,7 @@ extern motion_recorder_t motion_recorder; extern xcb_atom_t WM_STATE; extern xcb_atom_t WM_TAKE_FOCUS; extern xcb_atom_t WM_DELETE_WINDOW; +extern xcb_atom_t WM_CHANGE_STATE; extern int exit_status; extern bool auto_raise; diff --git a/src/events.c b/src/events.c index 3b82c96f..54fc8f07 100644 --- a/src/events.c +++ b/src/events.c @@ -329,6 +329,8 @@ void client_message(xcb_generic_event_t *evt) loc.node == mon->desk->focus) { return; } + set_hidden(loc.monitor, loc.desktop, loc.node, false); + arrange(loc.monitor, loc.desktop); focus_node(loc.monitor, loc.desktop, loc.node); } else if (e->type == ewmh->_NET_WM_DESKTOP) { coordinates_t dloc; @@ -337,6 +339,10 @@ void client_message(xcb_generic_event_t *evt) } } else if (e->type == ewmh->_NET_CLOSE_WINDOW) { close_node(loc.node); + } else if (e->type == WM_CHANGE_STATE) { + set_hidden(loc.monitor, loc.desktop, loc.node, + e->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC || e->data.data32[0] == XCB_ICCCM_WM_STATE_WITHDRAWN); + arrange(loc.monitor, loc.desktop); } }