aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-30 23:27:49 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-30 23:27:49 +1000
commit7be309710dcd679e0b570bc2f076ac00ae9ad65d (patch)
tree66f53dddfcd94217beedf25272fe427a34ab665f
parentMerge pull request #3020 from emersion/swaymsg-return-status (diff)
downloadsway-7be309710dcd679e0b570bc2f076ac00ae9ad65d.tar.gz
sway-7be309710dcd679e0b570bc2f076ac00ae9ad65d.tar.zst
sway-7be309710dcd679e0b570bc2f076ac00ae9ad65d.zip
Remove enum movement_direction
There's no point having both movement_direction and wlr_direction. This replaces the former with the latter. As movement_direction also contained MOVE_PARENT and MOVE_CHILD items, these are now checked specifically in the focus command and handled in separate functions, just like the other focus variants.
-rw-r--r--common/util.c21
-rw-r--r--include/sway/output.h2
-rw-r--r--include/sway/tree/container.h3
-rw-r--r--include/util.h11
-rw-r--r--sway/commands/focus.c98
-rw-r--r--sway/commands/move.c57
-rw-r--r--sway/tree/output.c8
7 files changed, 86 insertions, 114 deletions
diff --git a/common/util.c b/common/util.c
index 561b3804..467aa4b5 100644
--- a/common/util.c
+++ b/common/util.c
@@ -175,24 +175,3 @@ failed:
175 free(current); 175 free(current);
176 return NULL; 176 return NULL;
177} 177}
178
179bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out) {
180 switch (dir) {
181 case MOVE_UP:
182 *out = WLR_DIRECTION_UP;
183 break;
184 case MOVE_DOWN:
185 *out = WLR_DIRECTION_DOWN;
186 break;
187 case MOVE_LEFT:
188 *out = WLR_DIRECTION_LEFT;
189 break;
190 case MOVE_RIGHT:
191 *out = WLR_DIRECTION_RIGHT;
192 break;
193 default:
194 return false;
195 }
196
197 return true;
198}
diff --git a/include/sway/output.h b/include/sway/output.h
index 22cb352a..5efe1660 100644
--- a/include/sway/output.h
+++ b/include/sway/output.h
@@ -62,7 +62,7 @@ void output_begin_destroy(struct sway_output *output);
62struct sway_output *output_from_wlr_output(struct wlr_output *output); 62struct sway_output *output_from_wlr_output(struct wlr_output *output);
63 63
64struct sway_output *output_get_in_direction(struct sway_output *reference, 64struct sway_output *output_get_in_direction(struct sway_output *reference,
65 enum movement_direction direction); 65 enum wlr_direction direction);
66 66
67void output_add_workspace(struct sway_output *output, 67void output_add_workspace(struct sway_output *output,
68 struct sway_workspace *workspace); 68 struct sway_workspace *workspace);
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 920ef038..1dd23341 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -36,7 +36,6 @@ struct sway_output;
36struct sway_workspace; 36struct sway_workspace;
37struct sway_view; 37struct sway_view;
38 38
39enum movement_direction;
40enum wlr_direction; 39enum wlr_direction;
41 40
42struct sway_container_state { 41struct sway_container_state {
@@ -287,8 +286,6 @@ void container_detach(struct sway_container *child);
287void container_replace(struct sway_container *container, 286void container_replace(struct sway_container *container,
288 struct sway_container *replacement); 287 struct sway_container *replacement);
289 288
290bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out);
291
292struct sway_container *container_split(struct sway_container *child, 289struct sway_container *container_split(struct sway_container *child,
293 enum sway_container_layout layout); 290 enum sway_container_layout layout);
294 291
diff --git a/include/util.h b/include/util.h
index 19d2e7cf..c39c92b1 100644
--- a/include/util.h
+++ b/include/util.h
@@ -7,15 +7,6 @@
7#include <wlr/types/wlr_output_layout.h> 7#include <wlr/types/wlr_output_layout.h>
8#include <xkbcommon/xkbcommon.h> 8#include <xkbcommon/xkbcommon.h>
9 9
10enum movement_direction {
11 MOVE_LEFT,
12 MOVE_RIGHT,
13 MOVE_UP,
14 MOVE_DOWN,
15 MOVE_PARENT,
16 MOVE_CHILD,
17};
18
19/** 10/**
20 * Wrap i into the range [0, max[ 11 * Wrap i into the range [0, max[
21 */ 12 */
@@ -77,6 +68,4 @@ bool parse_boolean(const char *boolean, bool current);
77 */ 68 */
78char* resolve_path(const char* path); 69char* resolve_path(const char* path);
79 70
80bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out);
81
82#endif 71#endif
diff --git a/sway/commands/focus.c b/sway/commands/focus.c
index 2204f722..521b2427 100644
--- a/sway/commands/focus.c
+++ b/sway/commands/focus.c
@@ -1,4 +1,5 @@
1#include <strings.h> 1#include <strings.h>
2#include <wlr/types/wlr_output_layout.h>
2#include <wlr/util/log.h> 3#include <wlr/util/log.h>
3#include "log.h" 4#include "log.h"
4#include "sway/commands.h" 5#include "sway/commands.h"
@@ -13,20 +14,16 @@
13#include "stringop.h" 14#include "stringop.h"
14#include "util.h" 15#include "util.h"
15 16
16static bool parse_movement_direction(const char *name, 17static bool parse_direction(const char *name,
17 enum movement_direction *out) { 18 enum wlr_direction *out) {
18 if (strcasecmp(name, "left") == 0) { 19 if (strcasecmp(name, "left") == 0) {
19 *out = MOVE_LEFT; 20 *out = WLR_DIRECTION_LEFT;
20 } else if (strcasecmp(name, "right") == 0) { 21 } else if (strcasecmp(name, "right") == 0) {
21 *out = MOVE_RIGHT; 22 *out = WLR_DIRECTION_RIGHT;
22 } else if (strcasecmp(name, "up") == 0) { 23 } else if (strcasecmp(name, "up") == 0) {
23 *out = MOVE_UP; 24 *out = WLR_DIRECTION_UP;
24 } else if (strcasecmp(name, "down") == 0) { 25 } else if (strcasecmp(name, "down") == 0) {
25 *out = MOVE_DOWN; 26 *out = WLR_DIRECTION_DOWN;
26 } else if (strcasecmp(name, "parent") == 0) {
27 *out = MOVE_PARENT;
28 } else if (strcasecmp(name, "child") == 0) {
29 *out = MOVE_CHILD;
30 } else { 27 } else {
31 return false; 28 return false;
32 } 29 }
@@ -38,7 +35,7 @@ static bool parse_movement_direction(const char *name,
38 * Get node in the direction of newly entered output. 35 * Get node in the direction of newly entered output.
39 */ 36 */
40static struct sway_node *get_node_in_output_direction( 37static struct sway_node *get_node_in_output_direction(
41 struct sway_output *output, enum movement_direction dir) { 38 struct sway_output *output, enum wlr_direction dir) {
42 struct sway_seat *seat = config->handler_context.seat; 39 struct sway_seat *seat = config->handler_context.seat;
43 struct sway_workspace *ws = output_get_active_workspace(output); 40 struct sway_workspace *ws = output_get_active_workspace(output);
44 if (ws->fullscreen) { 41 if (ws->fullscreen) {
@@ -48,7 +45,7 @@ static struct sway_node *get_node_in_output_direction(
48 45
49 if (ws->tiling->length > 0) { 46 if (ws->tiling->length > 0) {
50 switch (dir) { 47 switch (dir) {
51 case MOVE_LEFT: 48 case WLR_DIRECTION_LEFT:
52 if (ws->layout == L_HORIZ || ws->layout == L_TABBED) { 49 if (ws->layout == L_HORIZ || ws->layout == L_TABBED) {
53 // get most right child of new output 50 // get most right child of new output
54 container = ws->tiling->items[ws->tiling->length-1]; 51 container = ws->tiling->items[ws->tiling->length-1];
@@ -56,7 +53,7 @@ static struct sway_node *get_node_in_output_direction(
56 container = seat_get_focus_inactive_tiling(seat, ws); 53 container = seat_get_focus_inactive_tiling(seat, ws);
57 } 54 }
58 break; 55 break;
59 case MOVE_RIGHT: 56 case WLR_DIRECTION_RIGHT:
60 if (ws->layout == L_HORIZ || ws->layout == L_TABBED) { 57 if (ws->layout == L_HORIZ || ws->layout == L_TABBED) {
61 // get most left child of new output 58 // get most left child of new output
62 container = ws->tiling->items[0]; 59 container = ws->tiling->items[0];
@@ -64,7 +61,7 @@ static struct sway_node *get_node_in_output_direction(
64 container = seat_get_focus_inactive_tiling(seat, ws); 61 container = seat_get_focus_inactive_tiling(seat, ws);
65 } 62 }
66 break; 63 break;
67 case MOVE_UP: 64 case WLR_DIRECTION_UP:
68 if (ws->layout == L_VERT || ws->layout == L_STACKED) { 65 if (ws->layout == L_VERT || ws->layout == L_STACKED) {
69 // get most bottom child of new output 66 // get most bottom child of new output
70 container = ws->tiling->items[ws->tiling->length-1]; 67 container = ws->tiling->items[ws->tiling->length-1];
@@ -72,7 +69,7 @@ static struct sway_node *get_node_in_output_direction(
72 container = seat_get_focus_inactive_tiling(seat, ws); 69 container = seat_get_focus_inactive_tiling(seat, ws);
73 } 70 }
74 break; 71 break;
75 case MOVE_DOWN: { 72 case WLR_DIRECTION_DOWN:
76 if (ws->layout == L_VERT || ws->layout == L_STACKED) { 73 if (ws->layout == L_VERT || ws->layout == L_STACKED) {
77 // get most top child of new output 74 // get most top child of new output
78 container = ws->tiling->items[0]; 75 container = ws->tiling->items[0];
@@ -81,9 +78,6 @@ static struct sway_node *get_node_in_output_direction(
81 } 78 }
82 break; 79 break;
83 } 80 }
84 default:
85 break;
86 }
87 } 81 }
88 82
89 if (container) { 83 if (container) {
@@ -95,11 +89,8 @@ static struct sway_node *get_node_in_output_direction(
95} 89}
96 90
97static struct sway_node *node_get_in_direction(struct sway_container *container, 91static struct sway_node *node_get_in_direction(struct sway_container *container,
98 struct sway_seat *seat, enum movement_direction dir) { 92 struct sway_seat *seat, enum wlr_direction dir) {
99 if (container->is_fullscreen) { 93 if (container->is_fullscreen) {
100 if (dir == MOVE_PARENT) {
101 return NULL;
102 }
103 // Fullscreen container with a direction - go straight to outputs 94 // Fullscreen container with a direction - go straight to outputs
104 struct sway_output *output = container->workspace->output; 95 struct sway_output *output = container->workspace->output;
105 struct sway_output *new_output = output_get_in_direction(output, dir); 96 struct sway_output *new_output = output_get_in_direction(output, dir);
@@ -108,9 +99,6 @@ static struct sway_node *node_get_in_direction(struct sway_container *container,
108 } 99 }
109 return get_node_in_output_direction(new_output, dir); 100 return get_node_in_output_direction(new_output, dir);
110 } 101 }
111 if (dir == MOVE_PARENT) {
112 return node_get_parent(&container->node);
113 }
114 102
115 struct sway_container *wrap_candidate = NULL; 103 struct sway_container *wrap_candidate = NULL;
116 struct sway_container *current = container; 104 struct sway_container *current = container;
@@ -122,15 +110,15 @@ static struct sway_node *node_get_in_direction(struct sway_container *container,
122 container_parent_layout(current); 110 container_parent_layout(current);
123 list_t *siblings = container_get_siblings(current); 111 list_t *siblings = container_get_siblings(current);
124 112
125 if (dir == MOVE_LEFT || dir == MOVE_RIGHT) { 113 if (dir == WLR_DIRECTION_LEFT || dir == WLR_DIRECTION_RIGHT) {
126 if (parent_layout == L_HORIZ || parent_layout == L_TABBED) { 114 if (parent_layout == L_HORIZ || parent_layout == L_TABBED) {
127 can_move = true; 115 can_move = true;
128 desired = idx + (dir == MOVE_LEFT ? -1 : 1); 116 desired = idx + (dir == WLR_DIRECTION_LEFT ? -1 : 1);
129 } 117 }
130 } else { 118 } else {
131 if (parent_layout == L_VERT || parent_layout == L_STACKED) { 119 if (parent_layout == L_VERT || parent_layout == L_STACKED) {
132 can_move = true; 120 can_move = true;
133 desired = idx + (dir == MOVE_UP ? -1 : 1); 121 desired = idx + (dir == WLR_DIRECTION_UP ? -1 : 1);
134 } 122 }
135 } 123 }
136 124
@@ -200,9 +188,8 @@ static struct cmd_results *focus_output(struct sway_seat *seat,
200 struct sway_output *output = output_by_name(identifier); 188 struct sway_output *output = output_by_name(identifier);
201 189
202 if (!output) { 190 if (!output) {
203 enum movement_direction direction; 191 enum wlr_direction direction;
204 if (!parse_movement_direction(identifier, &direction) || 192 if (!parse_direction(identifier, &direction)) {
205 direction == MOVE_PARENT || direction == MOVE_CHILD) {
206 free(identifier); 193 free(identifier);
207 return cmd_results_new(CMD_INVALID, "focus", 194 return cmd_results_new(CMD_INVALID, "focus",
208 "There is no output with that name"); 195 "There is no output with that name");
@@ -220,6 +207,31 @@ static struct cmd_results *focus_output(struct sway_seat *seat,
220 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 207 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
221} 208}
222 209
210static struct cmd_results *focus_parent(void) {
211 struct sway_seat *seat = config->handler_context.seat;
212 struct sway_container *con = config->handler_context.container;
213 if (!con || con->is_fullscreen) {
214 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
215 }
216 struct sway_node *parent = node_get_parent(&con->node);
217 if (parent) {
218 seat_set_focus(seat, parent);
219 seat_consider_warp_to_focus(seat);
220 }
221 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
222}
223
224static struct cmd_results *focus_child(void) {
225 struct sway_seat *seat = config->handler_context.seat;
226 struct sway_node *node = config->handler_context.node;
227 struct sway_node *focus = seat_get_active_tiling_child(seat, node);
228 if (focus) {
229 seat_set_focus(seat, focus);
230 seat_consider_warp_to_focus(seat);
231 }
232 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
233}
234
223struct cmd_results *cmd_focus(int argc, char **argv) { 235struct cmd_results *cmd_focus(int argc, char **argv) {
224 if (config->reading || !config->active) { 236 if (config->reading || !config->active) {
225 return cmd_results_new(CMD_DEFER, NULL, NULL); 237 return cmd_results_new(CMD_DEFER, NULL, NULL);
@@ -257,27 +269,21 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
257 return focus_output(seat, argc, argv); 269 return focus_output(seat, argc, argv);
258 } 270 }
259 271
260 enum movement_direction direction = 0; 272 if (strcasecmp(argv[0], "parent") == 0) {
261 if (!parse_movement_direction(argv[0], &direction)) { 273 return focus_parent();
274 }
275 if (strcasecmp(argv[0], "child") == 0) {
276 return focus_child();
277 }
278
279 enum wlr_direction direction = 0;
280 if (!parse_direction(argv[0], &direction)) {
262 return cmd_results_new(CMD_INVALID, "focus", 281 return cmd_results_new(CMD_INVALID, "focus",
263 "Expected 'focus <direction|parent|child|mode_toggle|floating|tiling>' " 282 "Expected 'focus <direction|parent|child|mode_toggle|floating|tiling>' "
264 "or 'focus output <direction|name>'"); 283 "or 'focus output <direction|name>'");
265 } 284 }
266 285
267 if (direction == MOVE_CHILD) {
268 struct sway_node *focus = seat_get_active_tiling_child(seat, node);
269 if (focus) {
270 seat_set_focus(seat, focus);
271 seat_consider_warp_to_focus(seat);
272 }
273 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
274 }
275
276 if (node->type == N_WORKSPACE) { 286 if (node->type == N_WORKSPACE) {
277 if (direction == MOVE_PARENT) {
278 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
279 }
280
281 // Jump to the next output 287 // Jump to the next output
282 struct sway_output *new_output = 288 struct sway_output *new_output =
283 output_get_in_direction(workspace->output, direction); 289 output_get_in_direction(workspace->output, direction);
diff --git a/sway/commands/move.c b/sway/commands/move.c
index ffe12d41..30c198e4 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -81,14 +81,14 @@ static struct sway_output *output_in_direction(const char *direction_string,
81} 81}
82 82
83static bool is_parallel(enum sway_container_layout layout, 83static bool is_parallel(enum sway_container_layout layout,
84 enum movement_direction dir) { 84 enum wlr_direction dir) {
85 switch (layout) { 85 switch (layout) {
86 case L_TABBED: 86 case L_TABBED:
87 case L_HORIZ: 87 case L_HORIZ:
88 return dir == MOVE_LEFT || dir == MOVE_RIGHT; 88 return dir == WLR_DIRECTION_LEFT || dir == WLR_DIRECTION_RIGHT;
89 case L_STACKED: 89 case L_STACKED:
90 case L_VERT: 90 case L_VERT:
91 return dir == MOVE_UP || dir == MOVE_DOWN; 91 return dir == WLR_DIRECTION_UP || dir == WLR_DIRECTION_DOWN;
92 default: 92 default:
93 return false; 93 return false;
94 } 94 }
@@ -115,7 +115,7 @@ static void workspace_focus_fullscreen(struct sway_workspace *workspace) {
115 115
116static void container_move_to_container_from_direction( 116static void container_move_to_container_from_direction(
117 struct sway_container *container, struct sway_container *destination, 117 struct sway_container *container, struct sway_container *destination,
118 enum movement_direction move_dir) { 118 enum wlr_direction move_dir) {
119 if (destination->view) { 119 if (destination->view) {
120 if (destination->parent == container->parent && 120 if (destination->parent == container->parent &&
121 destination->workspace == container->workspace) { 121 destination->workspace == container->workspace) {
@@ -126,7 +126,8 @@ static void container_move_to_container_from_direction(
126 list_swap(siblings, container_index, destination_index); 126 list_swap(siblings, container_index, destination_index);
127 } else { 127 } else {
128 wlr_log(WLR_DEBUG, "Promoting to sibling of cousin"); 128 wlr_log(WLR_DEBUG, "Promoting to sibling of cousin");
129 int offset = move_dir == MOVE_LEFT || move_dir == MOVE_UP; 129 int offset =
130 move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_UP;
130 int index = container_sibling_index(destination) + offset; 131 int index = container_sibling_index(destination) + offset;
131 if (destination->parent) { 132 if (destination->parent) {
132 container_insert_child(destination->parent, container, index); 133 container_insert_child(destination->parent, container, index);
@@ -141,7 +142,8 @@ static void container_move_to_container_from_direction(
141 142
142 if (is_parallel(destination->layout, move_dir)) { 143 if (is_parallel(destination->layout, move_dir)) {
143 wlr_log(WLR_DEBUG, "Reparenting container (parallel)"); 144 wlr_log(WLR_DEBUG, "Reparenting container (parallel)");
144 int index = move_dir == MOVE_RIGHT || move_dir == MOVE_DOWN ? 145 int index =
146 move_dir == WLR_DIRECTION_RIGHT || move_dir == WLR_DIRECTION_DOWN ?
145 0 : destination->children->length; 147 0 : destination->children->length;
146 container_insert_child(destination, container, index); 148 container_insert_child(destination, container, index);
147 container->width = container->height = 0; 149 container->width = container->height = 0;
@@ -164,10 +166,11 @@ static void container_move_to_container_from_direction(
164 166
165static void container_move_to_workspace_from_direction( 167static void container_move_to_workspace_from_direction(
166 struct sway_container *container, struct sway_workspace *workspace, 168 struct sway_container *container, struct sway_workspace *workspace,
167 enum movement_direction move_dir) { 169 enum wlr_direction move_dir) {
168 if (is_parallel(workspace->layout, move_dir)) { 170 if (is_parallel(workspace->layout, move_dir)) {
169 wlr_log(WLR_DEBUG, "Reparenting container (parallel)"); 171 wlr_log(WLR_DEBUG, "Reparenting container (parallel)");
170 int index = move_dir == MOVE_RIGHT || move_dir == MOVE_DOWN ? 172 int index =
173 move_dir == WLR_DIRECTION_RIGHT || move_dir == WLR_DIRECTION_DOWN ?
171 0 : workspace->tiling->length; 174 0 : workspace->tiling->length;
172 workspace_insert_tiling(workspace, container, index); 175 workspace_insert_tiling(workspace, container, index);
173 return; 176 return;
@@ -258,28 +261,31 @@ static void container_move_to_container(struct sway_container *container,
258 * container, switches the layout of the workspace, and drops the child back in. 261 * container, switches the layout of the workspace, and drops the child back in.
259 * In other words, rejigger it. */ 262 * In other words, rejigger it. */
260static void workspace_rejigger(struct sway_workspace *ws, 263static void workspace_rejigger(struct sway_workspace *ws,
261 struct sway_container *child, enum movement_direction move_dir) { 264 struct sway_container *child, enum wlr_direction move_dir) {
262 if (!child->parent && ws->tiling->length == 1) { 265 if (!child->parent && ws->tiling->length == 1) {
263 ws->layout = 266 ws->layout =
264 move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; 267 move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_RIGHT ?
268 L_HORIZ : L_VERT;
265 workspace_update_representation(ws); 269 workspace_update_representation(ws);
266 return; 270 return;
267 } 271 }
268 container_detach(child); 272 container_detach(child);
269 struct sway_container *new_parent = workspace_wrap_children(ws); 273 struct sway_container *new_parent = workspace_wrap_children(ws);
270 274
271 int index = move_dir == MOVE_LEFT || move_dir == MOVE_UP ? 0 : 1; 275 int index =
276 move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_UP ? 0 : 1;
272 workspace_insert_tiling(ws, child, index); 277 workspace_insert_tiling(ws, child, index);
273 container_flatten(new_parent); 278 container_flatten(new_parent);
274 ws->layout = 279 ws->layout =
275 move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; 280 move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_RIGHT ?
281 L_HORIZ : L_VERT;
276 workspace_update_representation(ws); 282 workspace_update_representation(ws);
277 child->width = child->height = 0; 283 child->width = child->height = 0;
278} 284}
279 285
280// Returns true if moved 286// Returns true if moved
281static bool container_move_in_direction(struct sway_container *container, 287static bool container_move_in_direction(struct sway_container *container,
282 enum movement_direction move_dir) { 288 enum wlr_direction move_dir) {
283 // If moving a fullscreen view, only consider outputs 289 // If moving a fullscreen view, only consider outputs
284 if (container->is_fullscreen) { 290 if (container->is_fullscreen) {
285 struct sway_output *new_output = 291 struct sway_output *new_output =
@@ -305,7 +311,8 @@ static bool container_move_in_direction(struct sway_container *container,
305 // The below loop stops once we hit the workspace because current->parent 311 // The below loop stops once we hit the workspace because current->parent
306 // is NULL for the topmost containers in a workspace. 312 // is NULL for the topmost containers in a workspace.
307 struct sway_container *current = container; 313 struct sway_container *current = container;
308 int offs = move_dir == MOVE_LEFT || move_dir == MOVE_UP ? -1 : 1; 314 int offs =
315 move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_UP ? -1 : 1;
309 316
310 while (current) { 317 while (current) {
311 list_t *siblings = container_get_siblings(current); 318 list_t *siblings = container_get_siblings(current);
@@ -642,7 +649,7 @@ static struct cmd_results *cmd_move_workspace(int argc, char **argv) {
642} 649}
643 650
644static struct cmd_results *cmd_move_in_direction( 651static struct cmd_results *cmd_move_in_direction(
645 enum movement_direction direction, int argc, char **argv) { 652 enum wlr_direction direction, int argc, char **argv) {
646 int move_amt = 10; 653 int move_amt = 10;
647 if (argc > 1) { 654 if (argc > 1) {
648 char *inv; 655 char *inv;
@@ -666,22 +673,18 @@ static struct cmd_results *cmd_move_in_direction(
666 double lx = container->x; 673 double lx = container->x;
667 double ly = container->y; 674 double ly = container->y;
668 switch (direction) { 675 switch (direction) {
669 case MOVE_LEFT: 676 case WLR_DIRECTION_LEFT:
670 lx -= move_amt; 677 lx -= move_amt;
671 break; 678 break;
672 case MOVE_RIGHT: 679 case WLR_DIRECTION_RIGHT:
673 lx += move_amt; 680 lx += move_amt;
674 break; 681 break;
675 case MOVE_UP: 682 case WLR_DIRECTION_UP:
676 ly -= move_amt; 683 ly -= move_amt;
677 break; 684 break;
678 case MOVE_DOWN: 685 case WLR_DIRECTION_DOWN:
679 ly += move_amt; 686 ly += move_amt;
680 break; 687 break;
681 case MOVE_PARENT:
682 case MOVE_CHILD:
683 return cmd_results_new(CMD_FAILURE, "move",
684 "Cannot move floating container to parent or child");
685 } 688 }
686 container_floating_move_to(container, lx, ly); 689 container_floating_move_to(container, lx, ly);
687 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 690 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
@@ -850,13 +853,13 @@ struct cmd_results *cmd_move(int argc, char **argv) {
850 } 853 }
851 854
852 if (strcasecmp(argv[0], "left") == 0) { 855 if (strcasecmp(argv[0], "left") == 0) {
853 return cmd_move_in_direction(MOVE_LEFT, argc, argv); 856 return cmd_move_in_direction(WLR_DIRECTION_LEFT, argc, argv);
854 } else if (strcasecmp(argv[0], "right") == 0) { 857 } else if (strcasecmp(argv[0], "right") == 0) {
855 return cmd_move_in_direction(MOVE_RIGHT, argc, argv); 858 return cmd_move_in_direction(WLR_DIRECTION_RIGHT, argc, argv);
856 } else if (strcasecmp(argv[0], "up") == 0) { 859 } else if (strcasecmp(argv[0], "up") == 0) {
857 return cmd_move_in_direction(MOVE_UP, argc, argv); 860 return cmd_move_in_direction(WLR_DIRECTION_UP, argc, argv);
858 } else if (strcasecmp(argv[0], "down") == 0) { 861 } else if (strcasecmp(argv[0], "down") == 0) {
859 return cmd_move_in_direction(MOVE_DOWN, argc, argv); 862 return cmd_move_in_direction(WLR_DIRECTION_DOWN, argc, argv);
860 } else if ((strcasecmp(argv[0], "container") == 0 863 } else if ((strcasecmp(argv[0], "container") == 0
861 || strcasecmp(argv[0], "window") == 0) || 864 || strcasecmp(argv[0], "window") == 0) ||
862 (strcasecmp(argv[0], "--no-auto-back-and-forth") && argc >= 2 865 (strcasecmp(argv[0], "--no-auto-back-and-forth") && argc >= 2
diff --git a/sway/tree/output.c b/sway/tree/output.c
index 632501e1..b84053d9 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -274,16 +274,14 @@ struct sway_output *output_from_wlr_output(struct wlr_output *output) {
274} 274}
275 275
276struct sway_output *output_get_in_direction(struct sway_output *reference, 276struct sway_output *output_get_in_direction(struct sway_output *reference,
277 enum movement_direction direction) { 277 enum wlr_direction direction) {
278 enum wlr_direction wlr_dir = 0; 278 if (!sway_assert(direction, "got invalid direction: %d", direction)) {
279 if (!sway_assert(sway_dir_to_wlr(direction, &wlr_dir),
280 "got invalid direction: %d", direction)) {
281 return NULL; 279 return NULL;
282 } 280 }
283 int lx = reference->wlr_output->lx + reference->width / 2; 281 int lx = reference->wlr_output->lx + reference->width / 2;
284 int ly = reference->wlr_output->ly + reference->height / 2; 282 int ly = reference->wlr_output->ly + reference->height / 2;
285 struct wlr_output *wlr_adjacent = wlr_output_layout_adjacent_output( 283 struct wlr_output *wlr_adjacent = wlr_output_layout_adjacent_output(
286 root->output_layout, wlr_dir, reference->wlr_output, lx, ly); 284 root->output_layout, direction, reference->wlr_output, lx, ly);
287 if (!wlr_adjacent) { 285 if (!wlr_adjacent) {
288 return NULL; 286 return NULL;
289 } 287 }