diff options
-rw-r--r-- | sway/commands/move.c | 64 |
1 files changed, 12 insertions, 52 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c index 849a18ad..fc2f1cc1 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -259,50 +259,24 @@ static void container_move_to_container(struct sway_container *container, | |||
259 | * In other words, rejigger it. */ | 259 | * In other words, rejigger it. */ |
260 | static void workspace_rejigger(struct sway_workspace *ws, | 260 | static void workspace_rejigger(struct sway_workspace *ws, |
261 | struct sway_container *child, enum movement_direction move_dir) { | 261 | struct sway_container *child, enum movement_direction move_dir) { |
262 | if (!child->parent && ws->tiling->length == 1) { | ||
263 | ws->layout = | ||
264 | move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; | ||
265 | workspace_update_representation(ws); | ||
266 | return; | ||
267 | } | ||
262 | container_detach(child); | 268 | container_detach(child); |
263 | workspace_wrap_children(ws); | 269 | struct sway_container *new_parent = workspace_wrap_children(ws); |
264 | 270 | ||
265 | int index = move_dir == MOVE_LEFT || move_dir == MOVE_UP ? 0 : 1; | 271 | int index = move_dir == MOVE_LEFT || move_dir == MOVE_UP ? 0 : 1; |
266 | workspace_insert_tiling(ws, child, index); | 272 | workspace_insert_tiling(ws, child, index); |
273 | container_flatten(new_parent); | ||
267 | ws->layout = | 274 | ws->layout = |
268 | move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; | 275 | move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; |
269 | workspace_update_representation(ws); | 276 | workspace_update_representation(ws); |
270 | child->width = child->height = 0; | 277 | child->width = child->height = 0; |
271 | } | 278 | } |
272 | 279 | ||
273 | static void move_out_of_tabs_stacks(struct sway_container *container, | ||
274 | struct sway_container *current, enum movement_direction move_dir, | ||
275 | int offs) { | ||
276 | enum sway_container_layout layout = move_dir == | ||
277 | MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; | ||
278 | list_t *siblings = container_get_siblings(container); | ||
279 | if (container == current && siblings->length == 1) { | ||
280 | wlr_log(WLR_DEBUG, "Changing layout of parent"); | ||
281 | if (container->parent) { | ||
282 | container->parent->layout = layout; | ||
283 | container_update_representation(container); | ||
284 | } else { | ||
285 | container->workspace->layout = layout; | ||
286 | workspace_update_representation(container->workspace); | ||
287 | } | ||
288 | return; | ||
289 | } | ||
290 | |||
291 | wlr_log(WLR_DEBUG, "Moving out of tab/stack into a split"); | ||
292 | if (current->parent) { | ||
293 | struct sway_container *new_parent = | ||
294 | container_split(current->parent, layout); | ||
295 | container_insert_child(new_parent, container, offs < 0 ? 0 : 1); | ||
296 | container_reap_empty(new_parent); | ||
297 | container_flatten(new_parent); | ||
298 | } else { | ||
299 | // Changing a workspace | ||
300 | struct sway_workspace *workspace = container->workspace; | ||
301 | workspace_split(workspace, layout); | ||
302 | workspace_insert_tiling(workspace, container, offs < 0 ? 0 : 1); | ||
303 | } | ||
304 | } | ||
305 | |||
306 | // Returns true if moved | 280 | // Returns true if moved |
307 | static bool container_move_in_direction(struct sway_container *container, | 281 | static bool container_move_in_direction(struct sway_container *container, |
308 | enum movement_direction move_dir) { | 282 | enum movement_direction move_dir) { |
@@ -334,7 +308,6 @@ static bool container_move_in_direction(struct sway_container *container, | |||
334 | int offs = move_dir == MOVE_LEFT || move_dir == MOVE_UP ? -1 : 1; | 308 | int offs = move_dir == MOVE_LEFT || move_dir == MOVE_UP ? -1 : 1; |
335 | 309 | ||
336 | while (current) { | 310 | while (current) { |
337 | struct sway_container *parent = current->parent; | ||
338 | list_t *siblings = container_get_siblings(current); | 311 | list_t *siblings = container_get_siblings(current); |
339 | enum sway_container_layout layout = container_parent_layout(current); | 312 | enum sway_container_layout layout = container_parent_layout(current); |
340 | int index = list_find(siblings, current); | 313 | int index = list_find(siblings, current); |
@@ -343,15 +316,8 @@ static bool container_move_in_direction(struct sway_container *container, | |||
343 | if (is_parallel(layout, move_dir)) { | 316 | if (is_parallel(layout, move_dir)) { |
344 | if (desired == -1 || desired == siblings->length) { | 317 | if (desired == -1 || desired == siblings->length) { |
345 | if (current->parent == container->parent) { | 318 | if (current->parent == container->parent) { |
346 | if (!(parent && parent->is_fullscreen) && | 319 | current = current->parent; |
347 | (layout == L_TABBED || layout == L_STACKED)) { | 320 | continue; |
348 | move_out_of_tabs_stacks(container, current, | ||
349 | move_dir, offs); | ||
350 | return true; | ||
351 | } else { | ||
352 | current = current->parent; | ||
353 | continue; | ||
354 | } | ||
355 | } else { | 321 | } else { |
356 | // Special case | 322 | // Special case |
357 | if (current->parent) { | 323 | if (current->parent) { |
@@ -369,10 +335,6 @@ static bool container_move_in_direction(struct sway_container *container, | |||
369 | siblings->items[desired], move_dir); | 335 | siblings->items[desired], move_dir); |
370 | return true; | 336 | return true; |
371 | } | 337 | } |
372 | } else if (!(parent && parent->is_fullscreen) && | ||
373 | (layout == L_TABBED || layout == L_STACKED)) { | ||
374 | move_out_of_tabs_stacks(container, current, move_dir, offs); | ||
375 | return true; | ||
376 | } | 338 | } |
377 | 339 | ||
378 | current = current->parent; | 340 | current = current->parent; |
@@ -388,10 +350,8 @@ static bool container_move_in_direction(struct sway_container *container, | |||
388 | // Maybe rejigger the workspace | 350 | // Maybe rejigger the workspace |
389 | struct sway_workspace *ws = container->workspace; | 351 | struct sway_workspace *ws = container->workspace; |
390 | if (!is_parallel(ws->layout, move_dir)) { | 352 | if (!is_parallel(ws->layout, move_dir)) { |
391 | if (ws->tiling->length >= 2) { | 353 | workspace_rejigger(ws, container, move_dir); |
392 | workspace_rejigger(ws, container, move_dir); | 354 | return true; |
393 | return true; | ||
394 | } | ||
395 | } else if (ws->layout == L_TABBED || ws->layout == L_STACKED) { | 355 | } else if (ws->layout == L_TABBED || ws->layout == L_STACKED) { |
396 | workspace_rejigger(ws, container, move_dir); | 356 | workspace_rejigger(ws, container, move_dir); |
397 | return true; | 357 | return true; |