From 7637613e871f0b2213149aaef2e1901c4a5c603a Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Tue, 5 Sep 2023 21:59:53 +0200 Subject: Remanage window after urgency flag change Fixes #5658 --- release-notes/bugfixes/5-for-window-urgent | 1 + src/handlers.c | 13 ++++++++++--- testcases/t/113-urgent.t | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 release-notes/bugfixes/5-for-window-urgent diff --git a/release-notes/bugfixes/5-for-window-urgent b/release-notes/bugfixes/5-for-window-urgent new file mode 100644 index 00000000..344b3fb2 --- /dev/null +++ b/release-notes/bugfixes/5-for-window-urgent @@ -0,0 +1 @@ +fix for_window not working with urgency flags diff --git a/src/handlers.c b/src/handlers.c index 17968a43..6ba11708 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -422,6 +422,7 @@ static void handle_configure_request(xcb_configure_request_event_t *event) { } else if (config.focus_on_window_activation == FOWA_URGENT || (config.focus_on_window_activation == FOWA_SMART && !workspace_is_visible(workspace))) { DLOG("Marking con = %p urgent\n", con); con_set_urgency(con, true); + con = remanage_window(con); tree_render(); } else { DLOG("Ignoring request for con = %p.\n", con); @@ -691,12 +692,16 @@ static void handle_client_message(xcb_client_message_event_t *event) { } } else if (event->data.data32[1] == A__NET_WM_STATE_DEMANDS_ATTENTION) { /* Check if the urgent flag must be set or not */ - if (event->data.data32[0] == _NET_WM_STATE_ADD) + if (event->data.data32[0] == _NET_WM_STATE_ADD) { con_set_urgency(con, true); - else if (event->data.data32[0] == _NET_WM_STATE_REMOVE) + con = remanage_window(con); + } else if (event->data.data32[0] == _NET_WM_STATE_REMOVE) { con_set_urgency(con, false); - else if (event->data.data32[0] == _NET_WM_STATE_TOGGLE) + con = remanage_window(con); + } else if (event->data.data32[0] == _NET_WM_STATE_TOGGLE) { con_set_urgency(con, !con->urgent); + con = remanage_window(con); + } } else if (event->data.data32[1] == A__NET_WM_STATE_STICKY) { DLOG("Received a client message to modify _NET_WM_STATE_STICKY.\n"); if (event->data.data32[0] == _NET_WM_STATE_ADD) @@ -763,6 +768,7 @@ static void handle_client_message(xcb_client_message_event_t *event) { } else if (config.focus_on_window_activation == FOWA_URGENT || (config.focus_on_window_activation == FOWA_SMART && !workspace_is_visible(ws))) { DLOG("Marking con = %p urgent\n", con); con_set_urgency(con, true); + con = remanage_window(con); } else DLOG("Ignoring request for con = %p.\n", con); } @@ -982,6 +988,7 @@ static bool handle_hints(Con *con, xcb_get_property_reply_t *reply) { bool urgency_hint; window_update_hints(con->window, reply, &urgency_hint); con_set_urgency(con, urgency_hint); + remanage_window(con); tree_render(); return true; } diff --git a/testcases/t/113-urgent.t b/testcases/t/113-urgent.t index f78226e3..f99b1942 100644 --- a/testcases/t/113-urgent.t +++ b/testcases/t/113-urgent.t @@ -50,6 +50,8 @@ my $config = <{window} == $win1->id } @content; ok(!$win1_info->{urgent}, 'win1 window is not marked urgent after focusing'); +############################################################################## +# +############################################################################## + $tmp = fresh_workspace; + $win1 = open_window(wm_class => 'special'); + $win2 = open_window; + is($x->input_focus, $win2->id, 'second window has focus'); + + cmd 'nop hello'; + set_urgency($win1, 1, $type); + sync_with_i3; + is($x->input_focus, $win1->id, 'first window got focus'); + ############################################################################## exit_gracefully($pid); -- cgit v1.2.3-54-g00ecf