Introduce con_activate_unblock

This commit is contained in:
Orestis Floros
2019-10-09 02:31:52 +03:00
parent 465447a96b
commit 34c217acc8
3 changed files with 44 additions and 34 deletions

View File

@ -265,6 +265,41 @@ void con_activate(Con *con) {
con_raise(con);
}
/*
* Activates the container like in con_activate but removes fullscreen
* restrictions and properly warps the pointer if needed.
*
*/
void con_activate_unblock(Con *con) {
Con *ws = con_get_workspace(con);
Con *previous_focus = focused;
Con *fullscreen_on_ws = con_get_fullscreen_covering_ws(ws);
if (fullscreen_on_ws && fullscreen_on_ws != con && !con_has_parent(con, fullscreen_on_ws)) {
con_disable_fullscreen(fullscreen_on_ws);
}
con_activate(con);
/* If the container is not on the current workspace, workspace_show() will
* switch to a different workspace and (if enabled) trigger a mouse pointer
* warp to the currently focused container (!) on the target workspace.
*
* Therefore, before calling workspace_show(), we make sure that 'con' will
* be focused on the workspace. However, we cannot just con_focus(con)
* because then the pointer will not be warped at all (the code thinks we
* are already there).
*
* So we focus 'con' to make it the currently focused window of the target
* workspace, then revert focus. */
if (ws != con_get_workspace(previous_focus)) {
con_activate(previous_focus);
/* Now switch to the workspace, then focus */
workspace_show(ws);
con_activate(con);
}
}
/*
* Closes the given container.
*