diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2019-07-08 22:29:04 +0200 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2019-07-09 02:56:55 -0400 |
commit | 538b36c0e2f9f0bf64ef473789e2598ac7d1629f (patch) | |
tree | 1014b90ce73873ed0a4a1cf0e2d5c4612a1c691d | |
parent | calibration_matrix: expect 6 individual values (diff) | |
download | sway-538b36c0e2f9f0bf64ef473789e2598ac7d1629f.tar.gz sway-538b36c0e2f9f0bf64ef473789e2598ac7d1629f.tar.zst sway-538b36c0e2f9f0bf64ef473789e2598ac7d1629f.zip |
Make mouse drag in tiled mode swap containers if no edge is selected
Now the highlighted center area of containers triggers a swap action
instead of moving around the containers.
-rw-r--r-- | include/sway/tree/container.h | 2 | ||||
-rw-r--r-- | sway/commands/swap.c | 3 | ||||
-rw-r--r-- | sway/input/seatop_move_tiling.c | 22 |
3 files changed, 18 insertions, 9 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 8448d705..adeb85ae 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -326,6 +326,8 @@ void container_detach(struct sway_container *child); | |||
326 | void container_replace(struct sway_container *container, | 326 | void container_replace(struct sway_container *container, |
327 | struct sway_container *replacement); | 327 | struct sway_container *replacement); |
328 | 328 | ||
329 | void container_swap(struct sway_container *con1, struct sway_container *con2); | ||
330 | |||
329 | struct sway_container *container_split(struct sway_container *child, | 331 | struct sway_container *container_split(struct sway_container *child, |
330 | enum sway_container_layout layout); | 332 | enum sway_container_layout layout); |
331 | 333 | ||
diff --git a/sway/commands/swap.c b/sway/commands/swap.c index b978af16..f27aa7ed 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c | |||
@@ -84,8 +84,7 @@ static void swap_focus(struct sway_container *con1, | |||
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | static void container_swap(struct sway_container *con1, | 87 | void container_swap(struct sway_container *con1, struct sway_container *con2) { |
88 | struct sway_container *con2) { | ||
89 | if (!sway_assert(con1 && con2, "Cannot swap with nothing")) { | 88 | if (!sway_assert(con1 && con2, "Cannot swap with nothing")) { |
90 | return; | 89 | return; |
91 | } | 90 | } |
diff --git a/sway/input/seatop_move_tiling.c b/sway/input/seatop_move_tiling.c index 7c31e695..e1506175 100644 --- a/sway/input/seatop_move_tiling.c +++ b/sway/input/seatop_move_tiling.c | |||
@@ -245,8 +245,12 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
245 | target_node->sway_workspace : target_node->sway_container->workspace; | 245 | target_node->sway_workspace : target_node->sway_container->workspace; |
246 | enum wlr_edges edge = e->target_edge; | 246 | enum wlr_edges edge = e->target_edge; |
247 | int after = edge != WLR_EDGE_TOP && edge != WLR_EDGE_LEFT; | 247 | int after = edge != WLR_EDGE_TOP && edge != WLR_EDGE_LEFT; |
248 | bool swap = edge == WLR_EDGE_NONE && target_node->type == N_CONTAINER; | ||
249 | |||
250 | if (!swap) { | ||
251 | container_detach(con); | ||
252 | } | ||
248 | 253 | ||
249 | container_detach(con); | ||
250 | 254 | ||
251 | // Moving container into empty workspace | 255 | // Moving container into empty workspace |
252 | if (target_node->type == N_WORKSPACE && edge == WLR_EDGE_NONE) { | 256 | if (target_node->type == N_WORKSPACE && edge == WLR_EDGE_NONE) { |
@@ -254,13 +258,17 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
254 | } else if (target_node->type == N_CONTAINER) { | 258 | } else if (target_node->type == N_CONTAINER) { |
255 | // Moving container before/after another | 259 | // Moving container before/after another |
256 | struct sway_container *target = target_node->sway_container; | 260 | struct sway_container *target = target_node->sway_container; |
257 | enum sway_container_layout layout = container_parent_layout(target); | 261 | if (swap) { |
258 | if (edge && !is_parallel(layout, edge)) { | 262 | container_swap(target_node->sway_container, con); |
259 | enum sway_container_layout new_layout = edge == WLR_EDGE_TOP || | 263 | } else { |
260 | edge == WLR_EDGE_BOTTOM ? L_VERT : L_HORIZ; | 264 | enum sway_container_layout layout = container_parent_layout(target); |
261 | container_split(target, new_layout); | 265 | if (edge && !is_parallel(layout, edge)) { |
266 | enum sway_container_layout new_layout = edge == WLR_EDGE_TOP || | ||
267 | edge == WLR_EDGE_BOTTOM ? L_VERT : L_HORIZ; | ||
268 | container_split(target, new_layout); | ||
269 | } | ||
270 | container_add_sibling(target, con, after); | ||
262 | } | 271 | } |
263 | container_add_sibling(target, con, after); | ||
264 | } else { | 272 | } else { |
265 | // Target is a workspace which requires splitting | 273 | // Target is a workspace which requires splitting |
266 | enum sway_container_layout new_layout = edge == WLR_EDGE_TOP || | 274 | enum sway_container_layout new_layout = edge == WLR_EDGE_TOP || |