aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sway/tree/root.h6
-rw-r--r--sway/commands/move.c2
-rw-r--r--sway/tree/container.c4
-rw-r--r--sway/tree/root.c27
4 files changed, 25 insertions, 14 deletions
diff --git a/include/sway/tree/root.h b/include/sway/tree/root.h
index c4f84207..799d751a 100644
--- a/include/sway/tree/root.h
+++ b/include/sway/tree/root.h
@@ -46,8 +46,12 @@ void root_destroy(struct sway_root *root);
/**
* Move a container to the scratchpad.
+ * If a workspace is passed, the container is assumed to have been in
+ * the scratchpad before and is shown on the workspace.
+ * The ws parameter can safely be NULL.
*/
-void root_scratchpad_add_container(struct sway_container *con);
+void root_scratchpad_add_container(struct sway_container *con,
+ struct sway_workspace *ws);
/**
* Remove a container from the scratchpad.
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 9c6e69ec..6fd66f28 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -856,7 +856,7 @@ static struct cmd_results *cmd_move_to_scratchpad(void) {
}
if (!con->scratchpad) {
- root_scratchpad_add_container(con);
+ root_scratchpad_add_container(con, NULL);
} else if (con->workspace) {
root_scratchpad_hide(con);
}
diff --git a/sway/tree/container.c b/sway/tree/container.c
index c4d21f0a..89a47151 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -1378,10 +1378,12 @@ void container_replace(struct sway_container *container,
struct sway_container *replacement) {
enum sway_fullscreen_mode fullscreen = container->fullscreen_mode;
bool scratchpad = container->scratchpad;
+ struct sway_workspace *ws = NULL;
if (fullscreen != FULLSCREEN_NONE) {
container_fullscreen_disable(container);
}
if (scratchpad) {
+ ws = container->workspace;
root_scratchpad_show(container);
root_scratchpad_remove_container(container);
}
@@ -1390,7 +1392,7 @@ void container_replace(struct sway_container *container,
container_detach(container);
}
if (scratchpad) {
- root_scratchpad_add_container(replacement);
+ root_scratchpad_add_container(replacement, ws);
}
switch (fullscreen) {
case FULLSCREEN_WORKSPACE:
diff --git a/sway/tree/root.c b/sway/tree/root.c
index 1dabc287..55d78487 100644
--- a/sway/tree/root.c
+++ b/sway/tree/root.c
@@ -54,7 +54,7 @@ void root_destroy(struct sway_root *root) {
free(root);
}
-void root_scratchpad_add_container(struct sway_container *con) {
+void root_scratchpad_add_container(struct sway_container *con, struct sway_workspace *ws) {
if (!sway_assert(!con->scratchpad, "Container is already in scratchpad")) {
return;
}
@@ -77,18 +77,23 @@ void root_scratchpad_add_container(struct sway_container *con) {
container_detach(con);
con->scratchpad = true;
list_add(root->scratchpad, con);
-
- struct sway_seat *seat = input_manager_current_seat();
- struct sway_node *new_focus = NULL;
- if (parent) {
- arrange_container(parent);
- new_focus = seat_get_focus_inactive(seat, &parent->node);
+ if (ws) {
+ workspace_add_floating(ws, con);
}
- if (!new_focus) {
- arrange_workspace(workspace);
- new_focus = seat_get_focus_inactive(seat, &workspace->node);
+
+ if (!ws) {
+ struct sway_seat *seat = input_manager_current_seat();
+ struct sway_node *new_focus = NULL;
+ if (parent) {
+ arrange_container(parent);
+ new_focus = seat_get_focus_inactive(seat, &parent->node);
+ }
+ if (!new_focus) {
+ arrange_workspace(workspace);
+ new_focus = seat_get_focus_inactive(seat, &workspace->node);
+ }
+ seat_set_focus(seat, new_focus);
}
- seat_set_focus(seat, new_focus);
ipc_event_window(con, "move");
}