Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
handlers.c: new focus should not end up behind fullscreen
Browse files Browse the repository at this point in the history
This was raised here:
https://www.reddit.com/r/i3wm/comments/df18aa/popup_during_fullscreen_not_behaving_the_way_i/

With this commit, _NET_ACTIVE_WINDOW requests are more similar to
focusing with cmd_focus.
  • Loading branch information
orestisfl committed Oct 8, 2019
1 parent 34c217a commit 6f82d21
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/handlers.c
Expand Up @@ -412,7 +412,7 @@ static void handle_configure_request(xcb_configure_request_event_t *event) {
if (config.focus_on_window_activation == FOWA_FOCUS || (config.focus_on_window_activation == FOWA_SMART && workspace_is_visible(workspace))) {
DLOG("Focusing con = %p\n", con);
workspace_show(workspace);
con_activate(con);
con_activate_unblock(con);
tree_render();
} 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);
Expand Down Expand Up @@ -758,7 +758,7 @@ static void handle_client_message(xcb_client_message_event_t *event) {
workspace_show(ws);
/* Re-set focus, even if unchanged from i3’s perspective. */
focused_id = XCB_NONE;
con_activate(con);
con_activate_unblock(con);
}
} else {
/* Request is from an application. */
Expand All @@ -769,8 +769,7 @@ static void handle_client_message(xcb_client_message_event_t *event) {

if (config.focus_on_window_activation == FOWA_FOCUS || (config.focus_on_window_activation == FOWA_SMART && workspace_is_visible(ws))) {
DLOG("Focusing con = %p\n", con);
workspace_show(ws);
con_activate(con);
con_activate_unblock(con);
} 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);
Expand Down Expand Up @@ -1115,14 +1114,8 @@ static void handle_focus_in(xcb_focus_in_event_t *event) {

DLOG("focus is different / refocusing floating window: updating decorations\n");

/* Get the currently focused workspace to check if the focus change also
* involves changing workspaces. If so, we need to call workspace_show() to
* correctly update state and send the IPC event. */
Con *ws = con_get_workspace(con);
if (ws != con_get_workspace(focused))
workspace_show(ws);
con_activate_unblock(con);

con_activate(con);
/* We update focused_id because we don’t need to set focus again */
focused_id = event->event;
tree_render();
Expand Down
16 changes: 16 additions & 0 deletions testcases/t/195-net-active-window.t
Expand Up @@ -149,6 +149,22 @@ send_net_active_window($scratch->id, 'pager');

is($x->input_focus, $scratch->id, 'scratchpad window is shown');

################################################################################
# Send a _NET_ACTIVE_WINDOW ClientMessage for a window behind a fullscreen
# window
################################################################################

$ws1 = fresh_workspace;
$win1 = open_window;
$win2 = open_window;
cmd 'fullscreen enable';
is_num_fullscreen($ws1, 1, '1 fullscreen window in workspace');

send_net_active_window($win1->id);

is($x->input_focus, $win1->id, 'window behind fullscreen window is now focused');
is_num_fullscreen($ws1, 0, 'no fullscreen windows in workspace');

################################################################################
# Verify that the _NET_ACTIVE_WINDOW property is updated on the root window
# correctly.
Expand Down

0 comments on commit 6f82d21

Please sign in to comment.