X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fscratchpad.c;h=6d83a558ccdc738e42941588536b45806ff82714;hb=fdbbae56b2b5f8049380b9456c01c3966b3b18f2;hp=9997f17df2037e9a981e2ae1a6375854391a53c9;hpb=8247f44e95b0eb7a1932bb151a34dd34cdd436cf;p=i3%2Fi3 diff --git a/src/scratchpad.c b/src/scratchpad.c index 9997f17d..6d83a558 100644 --- a/src/scratchpad.c +++ b/src/scratchpad.c @@ -4,7 +4,7 @@ * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager - * © 2009-2013 Michael Stapelberg and contributors (see also: LICENSE) + * © 2009 Michael Stapelberg and contributors (see also: LICENSE) * * scratchpad.c: Moving windows to the scratchpad and making them visible again. * @@ -21,7 +21,8 @@ void scratchpad_move(Con *con) { if (con->type == CT_WORKSPACE) { LOG("'move scratchpad' used on a workspace \"%s\". Calling it " - "recursively on all windows on this workspace.\n", con->name); + "recursively on all windows on this workspace.\n", + con->name); Con *current; current = TAILQ_FIRST(&(con->focus_head)); while (current) { @@ -39,6 +40,12 @@ void scratchpad_move(Con *con) { return; } + /* If the current con is in fullscreen mode, we need to disable that, + * as a scratchpad window should never be in fullscreen mode */ + if (focused && focused->type != CT_WORKSPACE && focused->fullscreen_mode != CF_NONE) { + con_toggle_fullscreen(focused, CF_OUTPUT); + } + /* 1: Ensure the window or any parent is floating. From now on, we deal * with the CT_FLOATING_CON. We use automatic == false because the user * made the choice that this window should be a scratchpad (and floating). @@ -53,14 +60,20 @@ void scratchpad_move(Con *con) { /* 2: Send the window to the __i3_scratch workspace, mainting its * coordinates and not warping the pointer. */ - con_move_to_workspace(con, __i3_scratch, true, true); + con_move_to_workspace(con, __i3_scratch, true, true, false); /* 3: If this is the first time this window is used as a scratchpad, we set * the scratchpad_state to SCRATCHPAD_FRESH. The window will then be * adjusted in size according to what the user specifies. */ if (con->scratchpad_state == SCRATCHPAD_NONE) { DLOG("This window was never used as a scratchpad before.\n"); - con->scratchpad_state = SCRATCHPAD_FRESH; + if (con == maybe_floating_con) { + DLOG("It was in floating mode before, set scratchpad state to changed.\n"); + con->scratchpad_state = SCRATCHPAD_CHANGED; + } else { + DLOG("It was in tiling mode before, set scratchpad state to fresh.\n"); + con->scratchpad_state = SCRATCHPAD_FRESH; + } } } @@ -78,16 +91,6 @@ void scratchpad_show(Con *con) { Con *__i3_scratch = workspace_get("__i3_scratch", NULL); Con *floating; - /* If the current con or any of its parents are in fullscreen mode, we - * first need to disable it before showing the scratchpad con. */ - Con *fs = focused; - while (fs && fs->fullscreen_mode == CF_NONE) - fs = fs->parent; - - if (fs->type != CT_WORKSPACE) { - con_toggle_fullscreen(focused, CF_OUTPUT); - } - /* If this was 'scratchpad show' without criteria, we check if the * currently focused window is a scratchpad window and should be hidden * again. */ @@ -99,6 +102,16 @@ void scratchpad_show(Con *con) { return; } + /* If the current con or any of its parents are in fullscreen mode, we + * first need to disable it before showing the scratchpad con. */ + Con *fs = focused; + while (fs && fs->fullscreen_mode == CF_NONE) + fs = fs->parent; + + if (fs && fs->type != CT_WORKSPACE) { + con_toggle_fullscreen(fs, CF_OUTPUT); + } + /* If this was 'scratchpad show' without criteria, we check if there is a * unfocused scratchpad on the current workspace and focus it */ Con *walk_con; @@ -107,14 +120,14 @@ void scratchpad_show(Con *con) { if (!con && (floating = con_inside_floating(walk_con)) && floating->scratchpad_state != SCRATCHPAD_NONE && floating != con_inside_floating(focused)) { - DLOG("Found an unfocused scratchpad window on this workspace\n"); - DLOG("Focusing it: %p\n", walk_con); - /* use con_descend_tiling_focused to get the last focused + DLOG("Found an unfocused scratchpad window on this workspace\n"); + DLOG("Focusing it: %p\n", walk_con); + /* use con_descend_tiling_focused to get the last focused * window inside this scratch container in order to * keep the focus the same within this container */ - con_focus(con_descend_tiling_focused(walk_con)); - return; - } + con_focus(con_descend_tiling_focused(walk_con)); + return; + } } /* If this was 'scratchpad show' without criteria, we check if there is a @@ -129,7 +142,7 @@ void scratchpad_show(Con *con) { floating->scratchpad_state != SCRATCHPAD_NONE) { DLOG("Found a visible scratchpad window on another workspace,\n"); DLOG("moving it to this workspace: con = %p\n", walk_con); - con_move_to_workspace(walk_con, focused_ws, true, false); + con_move_to_workspace(walk_con, focused_ws, true, false, false); return; } } @@ -169,10 +182,14 @@ void scratchpad_show(Con *con) { LOG("Use 'move scratchpad' to move a window to the scratchpad.\n"); return; } + } else { + /* We used a criterion, so we need to do what follows (moving, + * resizing) on the floating parent. */ + con = con_inside_floating(con); } /* 1: Move the window from __i3_scratch to the current workspace. */ - con_move_to_workspace(con, active, true, false); + con_move_to_workspace(con, active, true, false, false); /* 2: Adjust the size if this window was not adjusted yet. */ if (con->scratchpad_state == SCRATCHPAD_FRESH) { @@ -181,10 +198,7 @@ void scratchpad_show(Con *con) { con->rect.width = output->rect.width * 0.5; con->rect.height = output->rect.height * 0.75; floating_check_size(con); - con->rect.x = output->rect.x + - ((output->rect.width / 2.0) - (con->rect.width / 2.0)); - con->rect.y = output->rect.y + - ((output->rect.height / 2.0) - (con->rect.height / 2.0)); + floating_center(con, con_get_workspace(con)->rect); } /* Activate active workspace if window is from another workspace to ensure