aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-12 08:46:46 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-12 08:46:46 +1000
commit679c7eb08c16daea8e3e1cff7bcf179e116d0e8e (patch)
tree82daa71d644f15c2e1e58ca9bdb2d4e1a75d3be9 /sway
parentFix crash in workspace_wrap_children (diff)
downloadsway-679c7eb08c16daea8e3e1cff7bcf179e116d0e8e.tar.gz
sway-679c7eb08c16daea8e3e1cff7bcf179e116d0e8e.tar.zst
sway-679c7eb08c16daea8e3e1cff7bcf179e116d0e8e.zip
Minor fixes to tiling drag implementation
* Make container_add_sibling's `after` argument a boolean. * Use a constant for drop layout border * Make thickness an int * Add button state check * Move comments in seat_end_move_tiling
Diffstat (limited to 'sway')
-rw-r--r--sway/input/cursor.c22
-rw-r--r--sway/input/seat.c6
-rw-r--r--sway/tree/container.c4
3 files changed, 18 insertions, 14 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index b0f8e531..dc66d82d 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -26,6 +26,10 @@
26#include "sway/tree/workspace.h" 26#include "sway/tree/workspace.h"
27#include "wlr-layer-shell-unstable-v1-protocol.h" 27#include "wlr-layer-shell-unstable-v1-protocol.h"
28 28
29// When doing a tiling drag, this is the thickness of the dropzone
30// when dragging to the edge of a layout container.
31#define DROP_LAYOUT_BORDER 30
32
29static uint32_t get_current_time_msec() { 33static uint32_t get_current_time_msec() {
30 struct timespec now; 34 struct timespec now;
31 clock_gettime(CLOCK_MONOTONIC, &now); 35 clock_gettime(CLOCK_MONOTONIC, &now);
@@ -229,7 +233,7 @@ static void handle_move_floating_motion(struct sway_seat *seat,
229} 233}
230 234
231static void resize_box(struct wlr_box *box, enum wlr_edges edge, 235static void resize_box(struct wlr_box *box, enum wlr_edges edge,
232 size_t thickness) { 236 int thickness) {
233 switch (edge) { 237 switch (edge) {
234 case WLR_EDGE_TOP: 238 case WLR_EDGE_TOP:
235 box->height = thickness; 239 box->height = thickness;
@@ -297,15 +301,17 @@ static void handle_move_tiling_motion(struct sway_seat *seat,
297 con->parent ? container_get_box(con->parent, &parent) : 301 con->parent ? container_get_box(con->parent, &parent) :
298 workspace_get_box(con->workspace, &parent); 302 workspace_get_box(con->workspace, &parent);
299 if (layout == L_HORIZ || layout == L_TABBED) { 303 if (layout == L_HORIZ || layout == L_TABBED) {
300 if (cursor->cursor->y < parent.y + 30) { 304 if (cursor->cursor->y < parent.y + DROP_LAYOUT_BORDER) {
301 edge = WLR_EDGE_TOP; 305 edge = WLR_EDGE_TOP;
302 } else if (cursor->cursor->y > parent.y + parent.height - 30) { 306 } else if (cursor->cursor->y > parent.y + parent.height
307 - DROP_LAYOUT_BORDER) {
303 edge = WLR_EDGE_BOTTOM; 308 edge = WLR_EDGE_BOTTOM;
304 } 309 }
305 } else if (layout == L_VERT || layout == L_STACKED) { 310 } else if (layout == L_VERT || layout == L_STACKED) {
306 if (cursor->cursor->x < parent.x + 30) { 311 if (cursor->cursor->x < parent.x + DROP_LAYOUT_BORDER) {
307 edge = WLR_EDGE_LEFT; 312 edge = WLR_EDGE_LEFT;
308 } else if (cursor->cursor->x > parent.x + parent.width - 30) { 313 } else if (cursor->cursor->x > parent.x + parent.width
314 - DROP_LAYOUT_BORDER) {
309 edge = WLR_EDGE_RIGHT; 315 edge = WLR_EDGE_RIGHT;
310 } 316 }
311 } 317 }
@@ -313,7 +319,7 @@ static void handle_move_tiling_motion(struct sway_seat *seat,
313 seat->op_target_node = node_get_parent(&con->node); 319 seat->op_target_node = node_get_parent(&con->node);
314 seat->op_target_edge = edge; 320 seat->op_target_edge = edge;
315 node_get_box(seat->op_target_node, &seat->op_drop_box); 321 node_get_box(seat->op_target_node, &seat->op_drop_box);
316 resize_box(&seat->op_drop_box, edge, 30); 322 resize_box(&seat->op_drop_box, edge, DROP_LAYOUT_BORDER);
317 desktop_damage_box(&seat->op_drop_box); 323 desktop_damage_box(&seat->op_drop_box);
318 return; 324 return;
319 } 325 }
@@ -890,8 +896,8 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
890 } 896 }
891 897
892 // Handle moving a tiling container 898 // Handle moving a tiling container
893 if (config->tiling_drag && mod_pressed && !is_floating_or_child && 899 if (config->tiling_drag && mod_pressed && state == WLR_BUTTON_PRESSED &&
894 !cont->is_fullscreen) { 900 !is_floating_or_child && !cont->is_fullscreen) {
895 seat_pointer_notify_button(seat, time_msec, button, state); 901 seat_pointer_notify_button(seat, time_msec, button, state);
896 seat_begin_move_tiling(seat, cont, button); 902 seat_begin_move_tiling(seat, cont, button);
897 return; 903 return;
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 231b545b..8704f90f 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -1050,9 +1050,8 @@ static void seat_end_move_tiling(struct sway_seat *seat) {
1050 // Moving container into empty workspace 1050 // Moving container into empty workspace
1051 if (target_node->type == N_WORKSPACE && edge == WLR_EDGE_NONE) { 1051 if (target_node->type == N_WORKSPACE && edge == WLR_EDGE_NONE) {
1052 workspace_add_tiling(new_ws, con); 1052 workspace_add_tiling(new_ws, con);
1053
1054 // Moving container before/after another
1055 } else if (target_node->type == N_CONTAINER) { 1053 } else if (target_node->type == N_CONTAINER) {
1054 // Moving container before/after another
1056 struct sway_container *target = target_node->sway_container; 1055 struct sway_container *target = target_node->sway_container;
1057 enum sway_container_layout layout = container_parent_layout(target); 1056 enum sway_container_layout layout = container_parent_layout(target);
1058 if (edge && !is_parallel(layout, edge)) { 1057 if (edge && !is_parallel(layout, edge)) {
@@ -1061,9 +1060,8 @@ static void seat_end_move_tiling(struct sway_seat *seat) {
1061 container_split(target, new_layout); 1060 container_split(target, new_layout);
1062 } 1061 }
1063 container_add_sibling(target, con, after); 1062 container_add_sibling(target, con, after);
1064
1065 // Target is a workspace which requires splitting
1066 } else { 1063 } else {
1064 // Target is a workspace which requires splitting
1067 enum sway_container_layout new_layout = edge == WLR_EDGE_TOP || 1065 enum sway_container_layout new_layout = edge == WLR_EDGE_TOP ||
1068 edge == WLR_EDGE_BOTTOM ? L_VERT : L_HORIZ; 1066 edge == WLR_EDGE_BOTTOM ? L_VERT : L_HORIZ;
1069 workspace_split(new_ws, new_layout); 1067 workspace_split(new_ws, new_layout);
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 21a0cd76..df064573 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -1093,13 +1093,13 @@ void container_insert_child(struct sway_container *parent,
1093} 1093}
1094 1094
1095void container_add_sibling(struct sway_container *fixed, 1095void container_add_sibling(struct sway_container *fixed,
1096 struct sway_container *active, int side) { 1096 struct sway_container *active, bool after) {
1097 if (active->workspace) { 1097 if (active->workspace) {
1098 container_detach(active); 1098 container_detach(active);
1099 } 1099 }
1100 list_t *siblings = container_get_siblings(fixed); 1100 list_t *siblings = container_get_siblings(fixed);
1101 int index = list_find(siblings, fixed); 1101 int index = list_find(siblings, fixed);
1102 list_insert(siblings, index + side, active); 1102 list_insert(siblings, index + after, active);
1103 active->parent = fixed->parent; 1103 active->parent = fixed->parent;
1104 active->workspace = fixed->workspace; 1104 active->workspace = fixed->workspace;
1105 container_for_each_child(active, set_workspace, NULL); 1105 container_for_each_child(active, set_workspace, NULL);