diff options
-rw-r--r-- | sway/tree/root.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/sway/tree/root.c b/sway/tree/root.c index 544d666a..9f6bf607 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <wlr/types/wlr_output_layout.h> | 5 | #include <wlr/types/wlr_output_layout.h> |
6 | #include "sway/desktop/transaction.h" | 6 | #include "sway/desktop/transaction.h" |
7 | #include "sway/input/seat.h" | 7 | #include "sway/input/seat.h" |
8 | #include "sway/ipc-server.h" | ||
8 | #include "sway/output.h" | 9 | #include "sway/output.h" |
9 | #include "sway/tree/arrange.h" | 10 | #include "sway/tree/arrange.h" |
10 | #include "sway/tree/container.h" | 11 | #include "sway/tree/container.h" |
@@ -75,6 +76,8 @@ void root_scratchpad_add_container(struct sway_container *con) { | |||
75 | arrange_workspace(workspace); | 76 | arrange_workspace(workspace); |
76 | seat_set_focus(seat, seat_get_focus_inactive(seat, &workspace->node)); | 77 | seat_set_focus(seat, seat_get_focus_inactive(seat, &workspace->node)); |
77 | } | 78 | } |
79 | |||
80 | ipc_event_window(con, "move"); | ||
78 | } | 81 | } |
79 | 82 | ||
80 | void root_scratchpad_remove_container(struct sway_container *con) { | 83 | void root_scratchpad_remove_container(struct sway_container *con) { |
@@ -85,45 +88,51 @@ void root_scratchpad_remove_container(struct sway_container *con) { | |||
85 | int index = list_find(root->scratchpad, con); | 88 | int index = list_find(root->scratchpad, con); |
86 | if (index != -1) { | 89 | if (index != -1) { |
87 | list_del(root->scratchpad, index); | 90 | list_del(root->scratchpad, index); |
91 | ipc_event_window(con, "move"); | ||
88 | } | 92 | } |
89 | } | 93 | } |
90 | 94 | ||
91 | void root_scratchpad_show(struct sway_container *con) { | 95 | void root_scratchpad_show(struct sway_container *con) { |
92 | struct sway_seat *seat = input_manager_current_seat(); | 96 | struct sway_seat *seat = input_manager_current_seat(); |
93 | struct sway_workspace *ws = seat_get_focused_workspace(seat); | 97 | struct sway_workspace *new_ws = seat_get_focused_workspace(seat); |
98 | struct sway_workspace *old_ws = con->workspace; | ||
94 | 99 | ||
95 | // If the current con or any of its parents are in fullscreen mode, we | 100 | // If the current con or any of its parents are in fullscreen mode, we |
96 | // first need to disable it before showing the scratchpad con. | 101 | // first need to disable it before showing the scratchpad con. |
97 | if (ws->fullscreen) { | 102 | if (new_ws->fullscreen) { |
98 | container_set_fullscreen(ws->fullscreen, false); | 103 | container_set_fullscreen(new_ws->fullscreen, false); |
99 | } | 104 | } |
100 | 105 | ||
101 | // Show the container | 106 | // Show the container |
102 | if (con->workspace) { | 107 | if (old_ws) { |
103 | container_detach(con); | 108 | container_detach(con); |
104 | } | 109 | } |
105 | workspace_add_floating(ws, con); | 110 | workspace_add_floating(new_ws, con); |
106 | 111 | ||
107 | // Make sure the container's center point overlaps this workspace | 112 | // Make sure the container's center point overlaps this workspace |
108 | double center_lx = con->x + con->width / 2; | 113 | double center_lx = con->x + con->width / 2; |
109 | double center_ly = con->y + con->height / 2; | 114 | double center_ly = con->y + con->height / 2; |
110 | 115 | ||
111 | struct wlr_box workspace_box; | 116 | struct wlr_box workspace_box; |
112 | workspace_get_box(ws, &workspace_box); | 117 | workspace_get_box(new_ws, &workspace_box); |
113 | if (!wlr_box_contains_point(&workspace_box, center_lx, center_ly)) { | 118 | if (!wlr_box_contains_point(&workspace_box, center_lx, center_ly)) { |
114 | // Maybe resize it | 119 | // Maybe resize it |
115 | if (con->width > ws->width || con->height > ws->height) { | 120 | if (con->width > new_ws->width || con->height > new_ws->height) { |
116 | container_init_floating(con); | 121 | container_init_floating(con); |
117 | } | 122 | } |
118 | 123 | ||
119 | // Center it | 124 | // Center it |
120 | double new_lx = ws->x + (ws->width - con->width) / 2; | 125 | double new_lx = new_ws->x + (new_ws->width - con->width) / 2; |
121 | double new_ly = ws->y + (ws->height - con->height) / 2; | 126 | double new_ly = new_ws->y + (new_ws->height - con->height) / 2; |
122 | container_floating_move_to(con, new_lx, new_ly); | 127 | container_floating_move_to(con, new_lx, new_ly); |
123 | } | 128 | } |
124 | 129 | ||
125 | arrange_workspace(ws); | 130 | arrange_workspace(new_ws); |
126 | seat_set_focus(seat, seat_get_focus_inactive(seat, &con->node)); | 131 | seat_set_focus(seat, seat_get_focus_inactive(seat, &con->node)); |
132 | |||
133 | if (new_ws != old_ws) { | ||
134 | ipc_event_window(con, "move"); | ||
135 | } | ||
127 | } | 136 | } |
128 | 137 | ||
129 | void root_scratchpad_hide(struct sway_container *con) { | 138 | void root_scratchpad_hide(struct sway_container *con) { |
@@ -137,6 +146,8 @@ void root_scratchpad_hide(struct sway_container *con) { | |||
137 | seat_set_focus(seat, seat_get_focus_inactive(seat, &ws->node)); | 146 | seat_set_focus(seat, seat_get_focus_inactive(seat, &ws->node)); |
138 | } | 147 | } |
139 | list_move_to_end(root->scratchpad, con); | 148 | list_move_to_end(root->scratchpad, con); |
149 | |||
150 | ipc_event_window(con, "move"); | ||
140 | } | 151 | } |
141 | 152 | ||
142 | struct pid_workspace { | 153 | struct pid_workspace { |