diff options
Diffstat (limited to 'sway/layout.c')
-rw-r--r-- | sway/layout.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/sway/layout.c b/sway/layout.c index ed9479ab..c33291b2 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -45,6 +45,9 @@ void add_child(swayc_t *parent, swayc_t *child) { | |||
45 | void add_floating(swayc_t *ws, swayc_t *child) { | 45 | void add_floating(swayc_t *ws, swayc_t *child) { |
46 | sway_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)", child, child->type, | 46 | sway_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)", child, child->type, |
47 | child->width, child->height, ws, ws->type, ws->width, ws->height); | 47 | child->width, child->height, ws, ws->type, ws->width, ws->height); |
48 | if (!sway_assert(ws->type == C_WORKSPACE, "Must be of workspace type")) { | ||
49 | return; | ||
50 | } | ||
48 | list_add(ws->floating, child); | 51 | list_add(ws->floating, child); |
49 | child->parent = ws; | 52 | child->parent = ws; |
50 | child->is_floating = true; | 53 | child->is_floating = true; |
@@ -93,8 +96,8 @@ swayc_t *replace_child(swayc_t *child, swayc_t *new_child) { | |||
93 | 96 | ||
94 | void swap_container(swayc_t *a, swayc_t *b) { | 97 | void swap_container(swayc_t *a, swayc_t *b) { |
95 | //TODO doesnt handle floating <-> tiling swap | 98 | //TODO doesnt handle floating <-> tiling swap |
96 | if (!sway_assert(a&&b, "%s: parameters must be non null",__func__) || | 99 | if (!sway_assert(a&&b, "parameters must be non null") || |
97 | !sway_assert(a->parent && b->parent, "%s: containers must have parents",__func__)) { | 100 | !sway_assert(a->parent && b->parent, "containers must have parents")) { |
98 | return; | 101 | return; |
99 | } | 102 | } |
100 | size_t a_index = index_child(a); | 103 | size_t a_index = index_child(a); |
@@ -158,6 +161,10 @@ swayc_t *remove_child(swayc_t *child) { | |||
158 | parent->focused = NULL; | 161 | parent->focused = NULL; |
159 | } | 162 | } |
160 | } | 163 | } |
164 | // deactivate view | ||
165 | if (child->type == C_VIEW) { | ||
166 | wlc_view_set_state(child->handle, WLC_BIT_ACTIVATED, false); | ||
167 | } | ||
161 | return parent; | 168 | return parent; |
162 | } | 169 | } |
163 | 170 | ||
@@ -209,15 +216,24 @@ void move_container_to(swayc_t* container, swayc_t* destination) { | |||
209 | if (container->parent == destination) { | 216 | if (container->parent == destination) { |
210 | return; | 217 | return; |
211 | } | 218 | } |
212 | destroy_container(remove_child(container)); | 219 | swayc_t *parent = remove_child(container); |
213 | set_focused_container(get_focused_view(&root_container)); | 220 | // reset container geometry |
221 | container->width = container->height = 0; | ||
222 | |||
223 | // Send to new destination | ||
214 | if (container->is_floating) { | 224 | if (container->is_floating) { |
215 | add_floating(destination, container); | 225 | add_floating(swayc_active_workspace_for(destination), container); |
216 | } else { | 226 | } else if (destination->type == C_WORKSPACE) { |
217 | add_child(destination, container); | 227 | add_child(destination, container); |
228 | } else { | ||
229 | add_sibling(destination, container); | ||
218 | } | 230 | } |
231 | // Destroy old container if we need to | ||
232 | parent = destroy_container(parent); | ||
233 | set_focused_container(get_focused_view(&root_container)); | ||
219 | update_visibility(container); | 234 | update_visibility(container); |
220 | arrange_windows(&root_container, -1, -1); | 235 | arrange_windows(parent, -1, -1); |
236 | arrange_windows(destination->parent, -1, -1); | ||
221 | } | 237 | } |
222 | 238 | ||
223 | void update_geometry(swayc_t *container) { | 239 | void update_geometry(swayc_t *container) { |