diff options
Diffstat (limited to 'sway/input')
-rw-r--r-- | sway/input/seatop_resize_floating.c | 6 | ||||
-rw-r--r-- | sway/input/seatop_resize_tiling.c | 50 |
2 files changed, 56 insertions, 0 deletions
diff --git a/sway/input/seatop_resize_floating.c b/sway/input/seatop_resize_floating.c index ec10cfc8..10af06fe 100644 --- a/sway/input/seatop_resize_floating.c +++ b/sway/input/seatop_resize_floating.c | |||
@@ -21,7 +21,12 @@ struct seatop_resize_floating_event { | |||
21 | static void handle_button(struct sway_seat *seat, uint32_t time_msec, | 21 | static void handle_button(struct sway_seat *seat, uint32_t time_msec, |
22 | struct wlr_input_device *device, uint32_t button, | 22 | struct wlr_input_device *device, uint32_t button, |
23 | enum wlr_button_state state) { | 23 | enum wlr_button_state state) { |
24 | struct seatop_resize_floating_event *e = seat->seatop_data; | ||
25 | struct sway_container *con = e->con; | ||
26 | |||
24 | if (seat->cursor->pressed_button_count == 0) { | 27 | if (seat->cursor->pressed_button_count == 0) { |
28 | container_set_resizing(con, false); | ||
29 | arrange_container(con); // Send configure w/o resizing hint | ||
25 | seatop_begin_default(seat); | 30 | seatop_begin_default(seat); |
26 | } | 31 | } |
27 | } | 32 | } |
@@ -170,6 +175,7 @@ void seatop_begin_resize_floating(struct sway_seat *seat, | |||
170 | seat->seatop_impl = &seatop_impl; | 175 | seat->seatop_impl = &seatop_impl; |
171 | seat->seatop_data = e; | 176 | seat->seatop_data = e; |
172 | 177 | ||
178 | container_set_resizing(con, true); | ||
173 | container_raise_floating(con); | 179 | container_raise_floating(con); |
174 | 180 | ||
175 | const char *image = edge == WLR_EDGE_NONE ? | 181 | const char *image = edge == WLR_EDGE_NONE ? |
diff --git a/sway/input/seatop_resize_tiling.c b/sway/input/seatop_resize_tiling.c index f6f106ef..0dfafbd0 100644 --- a/sway/input/seatop_resize_tiling.c +++ b/sway/input/seatop_resize_tiling.c | |||
@@ -4,6 +4,9 @@ | |||
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
5 | #include "sway/input/cursor.h" | 5 | #include "sway/input/cursor.h" |
6 | #include "sway/input/seat.h" | 6 | #include "sway/input/seat.h" |
7 | #include "sway/tree/arrange.h" | ||
8 | #include "sway/tree/container.h" | ||
9 | #include "sway/tree/view.h" | ||
7 | 10 | ||
8 | struct seatop_resize_tiling_event { | 11 | struct seatop_resize_tiling_event { |
9 | struct sway_container *con; // leaf container | 12 | struct sway_container *con; // leaf container |
@@ -12,6 +15,10 @@ struct seatop_resize_tiling_event { | |||
12 | struct sway_container *h_con; | 15 | struct sway_container *h_con; |
13 | struct sway_container *v_con; | 16 | struct sway_container *v_con; |
14 | 17 | ||
18 | // sibling con(s) that will be resized to accommodate | ||
19 | struct sway_container *h_sib; | ||
20 | struct sway_container *v_sib; | ||
21 | |||
15 | enum wlr_edges edge; | 22 | enum wlr_edges edge; |
16 | enum wlr_edges edge_x, edge_y; | 23 | enum wlr_edges edge_x, edge_y; |
17 | double ref_lx, ref_ly; // cursor's x/y at start of op | 24 | double ref_lx, ref_ly; // cursor's x/y at start of op |
@@ -19,10 +26,47 @@ struct seatop_resize_tiling_event { | |||
19 | double v_con_orig_height; // height of the vertical ancestor at start | 26 | double v_con_orig_height; // height of the vertical ancestor at start |
20 | }; | 27 | }; |
21 | 28 | ||
29 | static struct sway_container *container_get_resize_sibling( | ||
30 | struct sway_container *con, uint32_t edge) { | ||
31 | if (!con) { | ||
32 | return NULL; | ||
33 | } | ||
34 | |||
35 | list_t *siblings = container_get_siblings(con); | ||
36 | int index = container_sibling_index(con); | ||
37 | int offset = edge & (WLR_EDGE_TOP | WLR_EDGE_LEFT) ? -1 : 1; | ||
38 | |||
39 | if (siblings->length == 1) { | ||
40 | return NULL; | ||
41 | } else { | ||
42 | return siblings->items[index + offset]; | ||
43 | } | ||
44 | } | ||
45 | |||
22 | static void handle_button(struct sway_seat *seat, uint32_t time_msec, | 46 | static void handle_button(struct sway_seat *seat, uint32_t time_msec, |
23 | struct wlr_input_device *device, uint32_t button, | 47 | struct wlr_input_device *device, uint32_t button, |
24 | enum wlr_button_state state) { | 48 | enum wlr_button_state state) { |
49 | struct seatop_resize_tiling_event *e = seat->seatop_data; | ||
50 | |||
25 | if (seat->cursor->pressed_button_count == 0) { | 51 | if (seat->cursor->pressed_button_count == 0) { |
52 | if (e->h_con) { | ||
53 | container_set_resizing(e->h_con, false); | ||
54 | container_set_resizing(e->h_sib, false); | ||
55 | if (e->h_con->parent) { | ||
56 | arrange_container(e->h_con->parent); | ||
57 | } else { | ||
58 | arrange_workspace(e->h_con->workspace); | ||
59 | } | ||
60 | } | ||
61 | if (e->v_con) { | ||
62 | container_set_resizing(e->v_con, false); | ||
63 | container_set_resizing(e->v_sib, false); | ||
64 | if (e->v_con->parent) { | ||
65 | arrange_container(e->v_con->parent); | ||
66 | } else { | ||
67 | arrange_workspace(e->v_con->workspace); | ||
68 | } | ||
69 | } | ||
26 | seatop_begin_default(seat); | 70 | seatop_begin_default(seat); |
27 | } | 71 | } |
28 | } | 72 | } |
@@ -89,16 +133,22 @@ void seatop_begin_resize_tiling(struct sway_seat *seat, | |||
89 | if (edge & (WLR_EDGE_LEFT | WLR_EDGE_RIGHT)) { | 133 | if (edge & (WLR_EDGE_LEFT | WLR_EDGE_RIGHT)) { |
90 | e->edge_x = edge & (WLR_EDGE_LEFT | WLR_EDGE_RIGHT); | 134 | e->edge_x = edge & (WLR_EDGE_LEFT | WLR_EDGE_RIGHT); |
91 | e->h_con = container_find_resize_parent(e->con, e->edge_x); | 135 | e->h_con = container_find_resize_parent(e->con, e->edge_x); |
136 | e->h_sib = container_get_resize_sibling(e->h_con, e->edge_x); | ||
92 | 137 | ||
93 | if (e->h_con) { | 138 | if (e->h_con) { |
139 | container_set_resizing(e->h_con, true); | ||
140 | container_set_resizing(e->h_sib, true); | ||
94 | e->h_con_orig_width = e->h_con->width; | 141 | e->h_con_orig_width = e->h_con->width; |
95 | } | 142 | } |
96 | } | 143 | } |
97 | if (edge & (WLR_EDGE_TOP | WLR_EDGE_BOTTOM)) { | 144 | if (edge & (WLR_EDGE_TOP | WLR_EDGE_BOTTOM)) { |
98 | e->edge_y = edge & (WLR_EDGE_TOP | WLR_EDGE_BOTTOM); | 145 | e->edge_y = edge & (WLR_EDGE_TOP | WLR_EDGE_BOTTOM); |
99 | e->v_con = container_find_resize_parent(e->con, e->edge_y); | 146 | e->v_con = container_find_resize_parent(e->con, e->edge_y); |
147 | e->v_sib = container_get_resize_sibling(e->v_con, e->edge_y); | ||
100 | 148 | ||
101 | if (e->v_con) { | 149 | if (e->v_con) { |
150 | container_set_resizing(e->v_con, true); | ||
151 | container_set_resizing(e->v_sib, true); | ||
102 | e->v_con_orig_height = e->v_con->height; | 152 | e->v_con_orig_height = e->v_con->height; |
103 | } | 153 | } |
104 | } | 154 | } |