diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/layout.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/sway/layout.c b/sway/layout.c index 7f053d9b..2d29340e 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -269,13 +269,13 @@ void move_container(swayc_t *container, enum movement_direction dir) { | |||
269 | if (child->type == C_CONTAINER) { | 269 | if (child->type == C_CONTAINER) { |
270 | parent = child; | 270 | parent = child; |
271 | // Insert it in first/last if matching layout, otherwise | 271 | // Insert it in first/last if matching layout, otherwise |
272 | // inesrt it next to focused container | 272 | // insert it next to focused container |
273 | if (parent->layout == layout | 273 | if (parent->layout == layout |
274 | || (parent->layout == L_TABBED && layout == L_HORIZ) | 274 | || (parent->layout == L_TABBED && layout == L_HORIZ) |
275 | || (parent->layout == L_STACKED && layout == L_VERT)) { | 275 | || (parent->layout == L_STACKED && layout == L_VERT)) { |
276 | desired = (diff < 0) * parent->children->length; | 276 | desired = (diff < 0) * parent->children->length; |
277 | } else { | 277 | } else { |
278 | desired = index_child(child->focused); | 278 | desired = index_child(child->focused) + 1; |
279 | } | 279 | } |
280 | //reset geometry | 280 | //reset geometry |
281 | container->width = container->height = 0; | 281 | container->width = container->height = 0; |
@@ -284,7 +284,7 @@ void move_container(swayc_t *container, enum movement_direction dir) { | |||
284 | swayc_t *old_parent = remove_child(container); | 284 | swayc_t *old_parent = remove_child(container); |
285 | insert_child(parent, container, desired); | 285 | insert_child(parent, container, desired); |
286 | destroy_container(old_parent); | 286 | destroy_container(old_parent); |
287 | sway_log(L_DEBUG,"Moving to %p %d",parent, desired); | 287 | sway_log(L_DEBUG,"Moving to %p %d", parent, desired); |
288 | break; | 288 | break; |
289 | } | 289 | } |
290 | } | 290 | } |
@@ -294,6 +294,41 @@ void move_container(swayc_t *container, enum movement_direction dir) { | |||
294 | continue; | 294 | continue; |
295 | } | 295 | } |
296 | if (parent->type == C_WORKSPACE) { | 296 | if (parent->type == C_WORKSPACE) { |
297 | // If moving to an adjacent output we need a starting position (since this | ||
298 | // output might border to multiple outputs). | ||
299 | struct wlc_point abs_pos; | ||
300 | get_absolute_center_position(container, &abs_pos); | ||
301 | |||
302 | swayc_t *output = swayc_adjacent_output(parent->parent, dir, &abs_pos, true); | ||
303 | |||
304 | if (output) { | ||
305 | sway_log(L_DEBUG, "Moving between outputs"); | ||
306 | swayc_t *old_parent = remove_child(container); | ||
307 | destroy_container(old_parent); | ||
308 | |||
309 | swayc_t *dest = output->focused; | ||
310 | switch (dir) { | ||
311 | case MOVE_LEFT: | ||
312 | case MOVE_UP: | ||
313 | // reset container geometry | ||
314 | container->width = container->height = 0; | ||
315 | add_child(dest, container); | ||
316 | break; | ||
317 | case MOVE_RIGHT: | ||
318 | case MOVE_DOWN: | ||
319 | // reset container geometry | ||
320 | container->width = container->height = 0; | ||
321 | insert_child(dest, container, 0); | ||
322 | break; | ||
323 | default: | ||
324 | break; | ||
325 | } | ||
326 | // arrange new workspace | ||
327 | arrange_windows(dest, -1, -1); | ||
328 | set_focused_container(container); | ||
329 | break; | ||
330 | } | ||
331 | |||
297 | // We simply cannot move any further. | 332 | // We simply cannot move any further. |
298 | if (parent->layout == layout) { | 333 | if (parent->layout == layout) { |
299 | break; | 334 | break; |