diff options
-rw-r--r-- | include/sway/tree/container.h | 2 | ||||
-rw-r--r-- | include/sway/tree/view.h | 1 | ||||
-rw-r--r-- | sway/desktop/xdg_shell.c | 9 | ||||
-rw-r--r-- | sway/input/seatop_resize_floating.c | 6 | ||||
-rw-r--r-- | sway/input/seatop_resize_tiling.c | 50 | ||||
-rw-r--r-- | sway/tree/container.c | 22 |
6 files changed, 90 insertions, 0 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index fd028131..136d618b 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -219,6 +219,8 @@ void container_floating_resize_and_center(struct sway_container *con); | |||
219 | 219 | ||
220 | void container_floating_set_default_size(struct sway_container *con); | 220 | void container_floating_set_default_size(struct sway_container *con); |
221 | 221 | ||
222 | void container_set_resizing(struct sway_container *con, bool resizing); | ||
223 | |||
222 | void container_set_floating(struct sway_container *container, bool enable); | 224 | void container_set_floating(struct sway_container *container, bool enable); |
223 | 225 | ||
224 | void container_set_geometry_from_content(struct sway_container *con); | 226 | void container_set_geometry_from_content(struct sway_container *con); |
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index b495fdf9..665c516f 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -43,6 +43,7 @@ struct sway_view_impl { | |||
43 | void (*set_activated)(struct sway_view *view, bool activated); | 43 | void (*set_activated)(struct sway_view *view, bool activated); |
44 | void (*set_tiled)(struct sway_view *view, bool tiled); | 44 | void (*set_tiled)(struct sway_view *view, bool tiled); |
45 | void (*set_fullscreen)(struct sway_view *view, bool fullscreen); | 45 | void (*set_fullscreen)(struct sway_view *view, bool fullscreen); |
46 | void (*set_resizing)(struct sway_view *view, bool resizing); | ||
46 | bool (*wants_floating)(struct sway_view *view); | 47 | bool (*wants_floating)(struct sway_view *view); |
47 | void (*for_each_surface)(struct sway_view *view, | 48 | void (*for_each_surface)(struct sway_view *view, |
48 | wlr_surface_iterator_func_t iterator, void *user_data); | 49 | wlr_surface_iterator_func_t iterator, void *user_data); |
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index df751ef6..3437cc07 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c | |||
@@ -185,6 +185,14 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) { | |||
185 | wlr_xdg_toplevel_set_fullscreen(surface, fullscreen); | 185 | wlr_xdg_toplevel_set_fullscreen(surface, fullscreen); |
186 | } | 186 | } |
187 | 187 | ||
188 | static void set_resizing(struct sway_view *view, bool resizing) { | ||
189 | if (xdg_shell_view_from_view(view) == NULL) { | ||
190 | return; | ||
191 | } | ||
192 | struct wlr_xdg_surface *surface = view->wlr_xdg_surface; | ||
193 | wlr_xdg_toplevel_set_resizing(surface, resizing); | ||
194 | } | ||
195 | |||
188 | static bool wants_floating(struct sway_view *view) { | 196 | static bool wants_floating(struct sway_view *view) { |
189 | struct wlr_xdg_toplevel *toplevel = view->wlr_xdg_surface->toplevel; | 197 | struct wlr_xdg_toplevel *toplevel = view->wlr_xdg_surface->toplevel; |
190 | struct wlr_xdg_toplevel_state *state = &toplevel->current; | 198 | struct wlr_xdg_toplevel_state *state = &toplevel->current; |
@@ -260,6 +268,7 @@ static const struct sway_view_impl view_impl = { | |||
260 | .set_activated = set_activated, | 268 | .set_activated = set_activated, |
261 | .set_tiled = set_tiled, | 269 | .set_tiled = set_tiled, |
262 | .set_fullscreen = set_fullscreen, | 270 | .set_fullscreen = set_fullscreen, |
271 | .set_resizing = set_resizing, | ||
263 | .wants_floating = wants_floating, | 272 | .wants_floating = wants_floating, |
264 | .for_each_surface = for_each_surface, | 273 | .for_each_surface = for_each_surface, |
265 | .for_each_popup = for_each_popup, | 274 | .for_each_popup = for_each_popup, |
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 | } |
diff --git a/sway/tree/container.c b/sway/tree/container.c index fa1598ef..65696f15 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -746,6 +746,28 @@ void container_floating_set_default_size(struct sway_container *con) { | |||
746 | free(box); | 746 | free(box); |
747 | } | 747 | } |
748 | 748 | ||
749 | |||
750 | /** | ||
751 | * Indicate to clients in this container that they are participating in (or | ||
752 | * have just finished) an interactive resize | ||
753 | */ | ||
754 | void container_set_resizing(struct sway_container *con, bool resizing) { | ||
755 | if (!con) { | ||
756 | return; | ||
757 | } | ||
758 | |||
759 | if (con->view) { | ||
760 | if (con->view->impl->set_resizing) { | ||
761 | con->view->impl->set_resizing(con->view, resizing); | ||
762 | } | ||
763 | } else { | ||
764 | for (int i = 0; i < con->children->length; ++i ) { | ||
765 | struct sway_container *child = con->children->items[i]; | ||
766 | container_set_resizing(child, resizing); | ||
767 | } | ||
768 | } | ||
769 | } | ||
770 | |||
749 | void container_set_floating(struct sway_container *container, bool enable) { | 771 | void container_set_floating(struct sway_container *container, bool enable) { |
750 | if (container_is_floating(container) == enable) { | 772 | if (container_is_floating(container) == enable) { |
751 | return; | 773 | return; |