Bug 676: if scratchpad window is active on a non-visible workspace, then "scratchpad show" should move it to the current visible workspace.

This commit is contained in:
Peter Bui 2012-03-20 18:52:38 -04:00 committed by Michael Stapelberg
parent 9a58c1fcaa
commit a29eece9dc
1 changed files with 17 additions and 6 deletions

View File

@ -88,16 +88,21 @@ void scratchpad_show(Con *con) {
/* If this was 'scratchpad show' with criteria, we check if it matches a /* If this was 'scratchpad show' with criteria, we check if it matches a
* currently visible scratchpad window and hide it. */ * currently visible scratchpad window and hide it. */
Con *active = con_get_workspace(focused);
Con *current = con_get_workspace(con);
if (con && if (con &&
(floating = con_inside_floating(con)) && (floating = con_inside_floating(con)) &&
floating->scratchpad_state != SCRATCHPAD_NONE && floating->scratchpad_state != SCRATCHPAD_NONE &&
con_get_workspace(con) != __i3_scratch) { current != __i3_scratch) {
/* If scratchpad window is on the active workspace, then we should hide
* it, otherwise we should move it to the active workspace. */
if (current == active) {
DLOG("Window is a scratchpad window, hiding it.\n"); DLOG("Window is a scratchpad window, hiding it.\n");
scratchpad_move(con); scratchpad_move(con);
return; return;
} }
}
Con *ws = con_get_workspace(focused);
if (con == NULL) { if (con == NULL) {
/* Use the container on __i3_scratch which is highest in the focus /* Use the container on __i3_scratch which is highest in the focus
* stack. When moving windows to __i3_scratch, they get inserted at the * stack. When moving windows to __i3_scratch, they get inserted at the
@ -112,7 +117,7 @@ void scratchpad_show(Con *con) {
} }
/* 1: Move the window from __i3_scratch to the current workspace. */ /* 1: Move the window from __i3_scratch to the current workspace. */
con_move_to_workspace(con, ws, true, false); con_move_to_workspace(con, active, true, false);
/* 2: Adjust the size if this window was not adjusted yet. */ /* 2: Adjust the size if this window was not adjusted yet. */
if (con->scratchpad_state == SCRATCHPAD_FRESH) { if (con->scratchpad_state == SCRATCHPAD_FRESH) {
@ -127,5 +132,11 @@ void scratchpad_show(Con *con) {
con->scratchpad_state = SCRATCHPAD_CHANGED; con->scratchpad_state = SCRATCHPAD_CHANGED;
} }
/* Activate active workspace if window is from another workspace to ensure
* proper focus. */
if (current != active) {
workspace_show(active);
}
con_focus(con_descend_focused(con)); con_focus(con_descend_focused(con));
} }