Fix 'move to workspace' when used with criteria
When moving window from other (not current) workspace to another workspace with criteria we should stay on current workspace. And we should exit early when criteria was specified but didn't match any window.
This commit is contained in:
parent
4611f875ff
commit
51173baf28
|
@ -359,6 +359,15 @@ void cmd_move_con_to_workspace(I3_CMD, char *which) {
|
||||||
|
|
||||||
DLOG("which=%s\n", which);
|
DLOG("which=%s\n", which);
|
||||||
|
|
||||||
|
/* We have nothing to move:
|
||||||
|
* when criteria was specified but didn't match any window or
|
||||||
|
* when criteria wasn't specified and we don't have any window focused. */
|
||||||
|
if ((!match_is_empty(current_match) && TAILQ_EMPTY(&owindows)) ||
|
||||||
|
(match_is_empty(current_match) && focused->type == CT_WORKSPACE)) {
|
||||||
|
ysuccess(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
/* get the workspace */
|
/* get the workspace */
|
||||||
|
@ -400,9 +409,11 @@ void cmd_move_con_to_workspace_name(I3_CMD, char *name) {
|
||||||
|
|
||||||
owindow *current;
|
owindow *current;
|
||||||
|
|
||||||
/* Error out early to not create a non-existing workspace (in
|
/* We have nothing to move:
|
||||||
* workspace_get()) if we are not actually able to move anything. */
|
* when criteria was specified but didn't match any window or
|
||||||
if (match_is_empty(current_match) && focused->type == CT_WORKSPACE) {
|
* when criteria wasn't specified and we don't have any window focused. */
|
||||||
|
if ((!match_is_empty(current_match) && TAILQ_EMPTY(&owindows)) ||
|
||||||
|
(match_is_empty(current_match) && focused->type == CT_WORKSPACE)) {
|
||||||
ysuccess(false);
|
ysuccess(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -430,9 +441,11 @@ void cmd_move_con_to_workspace_name(I3_CMD, char *name) {
|
||||||
void cmd_move_con_to_workspace_number(I3_CMD, char *which) {
|
void cmd_move_con_to_workspace_number(I3_CMD, char *which) {
|
||||||
owindow *current;
|
owindow *current;
|
||||||
|
|
||||||
/* Error out early to not create a non-existing workspace (in
|
/* We have nothing to move:
|
||||||
* workspace_get()) if we are not actually able to move anything. */
|
* when criteria was specified but didn't match any window or
|
||||||
if (match_is_empty(current_match) && focused->type == CT_WORKSPACE) {
|
* when criteria wasn't specified and we don't have any window focused. */
|
||||||
|
if ((!match_is_empty(current_match) && TAILQ_EMPTY(&owindows)) ||
|
||||||
|
(match_is_empty(current_match) && focused->type == CT_WORKSPACE)) {
|
||||||
ysuccess(false);
|
ysuccess(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
18
src/con.c
18
src/con.c
|
@ -587,6 +587,16 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool
|
||||||
con = con->parent;
|
con = con->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Con *source_ws = con_get_workspace(con);
|
||||||
|
if (workspace == source_ws) {
|
||||||
|
DLOG("Not moving, already there\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Save the current workspace. So we can call workspace_show() by the end
|
||||||
|
* of this function. */
|
||||||
|
Con *current_ws = con_get_workspace(focused);
|
||||||
|
|
||||||
Con *source_output = con_get_output(con),
|
Con *source_output = con_get_output(con),
|
||||||
*dest_output = con_get_output(workspace);
|
*dest_output = con_get_output(workspace);
|
||||||
|
|
||||||
|
@ -669,8 +679,12 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool
|
||||||
/* Descend focus stack in case focus_next is a workspace which can
|
/* Descend focus stack in case focus_next is a workspace which can
|
||||||
* occur if we move to the same workspace. Also show current workspace
|
* occur if we move to the same workspace. Also show current workspace
|
||||||
* to ensure it is focused. */
|
* to ensure it is focused. */
|
||||||
workspace_show(con_get_workspace(focus_next));
|
workspace_show(current_ws);
|
||||||
con_focus(con_descend_focused(focus_next));
|
|
||||||
|
/* Set focus only if con was on current workspace before moving.
|
||||||
|
* Otherwise we would give focus to some window on different workspace. */
|
||||||
|
if (source_ws == current_ws)
|
||||||
|
con_focus(con_descend_focused(focus_next));
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL(parent, on_remove_child);
|
CALL(parent, on_remove_child);
|
||||||
|
|
Loading…
Reference in New Issue