aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-11 21:34:21 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-11 21:34:21 +1000
commit8bb40c24c7b045df0d43e9f22c096d1473f6f9f6 (patch)
tree0c4dbac1173f92337e2cff63d45c7d8fe7a3557f /sway/tree
parentIntroduce tiling_drag directive (diff)
downloadsway-8bb40c24c7b045df0d43e9f22c096d1473f6f9f6.tar.gz
sway-8bb40c24c7b045df0d43e9f22c096d1473f6f9f6.tar.zst
sway-8bb40c24c7b045df0d43e9f22c096d1473f6f9f6.zip
Implement tiling drag
Hold floating_modifier and drag a tiling view to a new location.
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c12
-rw-r--r--sway/tree/view.c2
-rw-r--r--sway/tree/workspace.c13
3 files changed, 23 insertions, 4 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 0a69f8d5..ff10c1ab 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -835,8 +835,14 @@ void container_end_mouse_operation(struct sway_container *container) {
835 struct sway_seat *seat; 835 struct sway_seat *seat;
836 wl_list_for_each(seat, &input_manager->seats, link) { 836 wl_list_for_each(seat, &input_manager->seats, link) {
837 if (seat->op_container == container) { 837 if (seat->op_container == container) {
838 seat->op_target_node = NULL; // ensure tiling move doesn't apply
838 seat_end_mouse_operation(seat); 839 seat_end_mouse_operation(seat);
839 } 840 }
841 // If the user is doing a tiling drag over this container,
842 // keep the operation active but unset the target container.
843 if (seat->op_target_node == &container->node) {
844 seat->op_target_node = NULL;
845 }
840 } 846 }
841} 847}
842 848
@@ -1086,13 +1092,13 @@ void container_insert_child(struct sway_container *parent,
1086} 1092}
1087 1093
1088void container_add_sibling(struct sway_container *fixed, 1094void container_add_sibling(struct sway_container *fixed,
1089 struct sway_container *active) { 1095 struct sway_container *active, int side) {
1090 if (active->workspace) { 1096 if (active->workspace) {
1091 container_detach(active); 1097 container_detach(active);
1092 } 1098 }
1093 list_t *siblings = container_get_siblings(fixed); 1099 list_t *siblings = container_get_siblings(fixed);
1094 int index = list_find(siblings, fixed); 1100 int index = list_find(siblings, fixed);
1095 list_insert(siblings, index + 1, active); 1101 list_insert(siblings, index + side, active);
1096 active->parent = fixed->parent; 1102 active->parent = fixed->parent;
1097 active->workspace = fixed->workspace; 1103 active->workspace = fixed->workspace;
1098 container_for_each_child(active, set_workspace, NULL); 1104 container_for_each_child(active, set_workspace, NULL);
@@ -1145,7 +1151,7 @@ void container_detach(struct sway_container *child) {
1145 1151
1146void container_replace(struct sway_container *container, 1152void container_replace(struct sway_container *container,
1147 struct sway_container *replacement) { 1153 struct sway_container *replacement) {
1148 container_add_sibling(container, replacement); 1154 container_add_sibling(container, replacement, 1);
1149 container_detach(container); 1155 container_detach(container);
1150} 1156}
1151 1157
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 65ac8b32..d4ffa06b 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -529,7 +529,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
529 529
530 view->container = container_create(view); 530 view->container = container_create(view);
531 if (target_sibling) { 531 if (target_sibling) {
532 container_add_sibling(target_sibling, view->container); 532 container_add_sibling(target_sibling, view->container, 1);
533 } else { 533 } else {
534 workspace_add_tiling(ws, view->container); 534 workspace_add_tiling(ws, view->container);
535 } 535 }
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index b8e90892..d4b57a0f 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -694,3 +694,16 @@ void workspace_get_box(struct sway_workspace *workspace, struct wlr_box *box) {
694 box->width = workspace->width; 694 box->width = workspace->width;
695 box->height = workspace->height; 695 box->height = workspace->height;
696} 696}
697
698static void count_tiling_views(struct sway_container *con, void *data) {
699 if (con->view && !container_is_floating_or_child(con)) {
700 size_t *count = data;
701 *count += 1;
702 }
703}
704
705size_t workspace_num_tiling_views(struct sway_workspace *ws) {
706 size_t count = 0;
707 workspace_for_each_container(ws, count_tiling_views, &count);
708 return count;
709}