From d7350915d9d9d8aba936c6139aa085804548f6b1 Mon Sep 17 00:00:00 2001 From: Jarkko Oranen Date: Sun, 19 Mar 2017 16:35:04 +0200 Subject: [PATCH 1/2] The default layout of a workspace should follow the output Hardcoding it to L_HORIZ does not make sense to me, as you get the unexpected behaviour that windows will be arranged horizontally until you switch the layout. --- sway/container.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/container.c b/sway/container.c index d43ee35e..707aa4d8 100644 --- a/sway/container.c +++ b/sway/container.c @@ -218,7 +218,7 @@ swayc_t *new_workspace(swayc_t *output, const char *name) { swayc_t *workspace = new_swayc(C_WORKSPACE); workspace->prev_layout = L_NONE; - workspace->layout = L_HORIZ; + workspace->layout = default_layout(output); workspace->workspace_layout = default_layout(output); workspace->x = output->x; From 924ed6464c25219bc0dd5ed06885cd3692042a20 Mon Sep 17 00:00:00 2001 From: Jarkko Oranen Date: Sun, 19 Mar 2017 16:46:27 +0200 Subject: [PATCH 2/2] Prevent "move next" and "move prev" commands from crashing Fixes #1120 When the parent of a view is C_WORKSPACE and the movement direction is either MOVE_PREV or MOVE_NEXT, the code would attempt to move the views to the next output, but swayc_adjacent_output can't accept non-directional movement commands and causes undefined behaviour and a segfault. If the code is simply skipped, we end up in an infinite loop. Instead, we can allow containers whose parent is a C_WORKSPACE take the path that handles MOVE_PREV and MOVE_NEXT, which behaves as you would expect. I'm not certain that this fix is entirely correct as the desired behaviour of move_container is not very well defined, but it seems to work. --- sway/layout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/layout.c b/sway/layout.c index 473b74f7..69291daf 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -417,7 +417,7 @@ void move_container(swayc_t *container, enum movement_direction dir, int move_am sway_log(L_DEBUG, "container:%p, parent:%p, child %p,", container,parent,child); if (parent->layout == layout - || (layout == L_NONE && parent->type == C_CONTAINER) /* accept any layout for next/prev direction */ + || (layout == L_NONE && (parent->type == C_CONTAINER || parent->type == C_WORKSPACE)) /* accept any layout for next/prev direction */ || (parent->layout == L_TABBED && layout == L_HORIZ) || (parent->layout == L_STACKED && layout == L_VERT) || is_auto_layout(parent->layout)) {