diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-18 15:10:06 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-18 15:10:06 +1000 |
commit | b0a5f3a25f52bc1d48d771cb02820042006d8d9e (patch) | |
tree | e7a2e4c60e562589e3b9a54c6ce559a41dcf7534 /sway/desktop/xdg_shell.c | |
parent | Set current size when a floating xwayland view resizes (diff) | |
download | sway-b0a5f3a25f52bc1d48d771cb02820042006d8d9e.tar.gz sway-b0a5f3a25f52bc1d48d771cb02820042006d8d9e.tar.zst sway-b0a5f3a25f52bc1d48d771cb02820042006d8d9e.zip |
Store geometry in the view and handle any floating view resizing
Diffstat (limited to 'sway/desktop/xdg_shell.c')
-rw-r--r-- | sway/desktop/xdg_shell.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 2b260357..aae129bd 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <wlr/util/edges.h> | 7 | #include <wlr/util/edges.h> |
8 | #include "log.h" | 8 | #include "log.h" |
9 | #include "sway/decoration.h" | 9 | #include "sway/decoration.h" |
10 | #include "sway/desktop.h" | ||
10 | #include "sway/input/input-manager.h" | 11 | #include "sway/input/input-manager.h" |
11 | #include "sway/input/seat.h" | 12 | #include "sway/input/seat.h" |
12 | #include "sway/server.h" | 13 | #include "sway/server.h" |
@@ -122,16 +123,6 @@ static const char *get_string_prop(struct sway_view *view, | |||
122 | } | 123 | } |
123 | } | 124 | } |
124 | 125 | ||
125 | static void get_geometry(struct sway_view *view, struct wlr_box *box) { | ||
126 | struct sway_xdg_shell_view *xdg_shell_view = | ||
127 | xdg_shell_view_from_view(view); | ||
128 | if (xdg_shell_view == NULL) { | ||
129 | return; | ||
130 | } | ||
131 | struct wlr_xdg_surface *surface = view->wlr_xdg_surface; | ||
132 | wlr_xdg_surface_get_geometry(surface, box); | ||
133 | } | ||
134 | |||
135 | static uint32_t configure(struct sway_view *view, double lx, double ly, | 126 | static uint32_t configure(struct sway_view *view, double lx, double ly, |
136 | int width, int height) { | 127 | int width, int height) { |
137 | struct sway_xdg_shell_view *xdg_shell_view = | 128 | struct sway_xdg_shell_view *xdg_shell_view = |
@@ -242,7 +233,6 @@ static void destroy(struct sway_view *view) { | |||
242 | static const struct sway_view_impl view_impl = { | 233 | static const struct sway_view_impl view_impl = { |
243 | .get_constraints = get_constraints, | 234 | .get_constraints = get_constraints, |
244 | .get_string_prop = get_string_prop, | 235 | .get_string_prop = get_string_prop, |
245 | .get_geometry = get_geometry, | ||
246 | .configure = configure, | 236 | .configure = configure, |
247 | .set_activated = set_activated, | 237 | .set_activated = set_activated, |
248 | .set_tiled = set_tiled, | 238 | .set_tiled = set_tiled, |
@@ -267,8 +257,24 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
267 | } | 257 | } |
268 | 258 | ||
269 | if (view->swayc->instruction) { | 259 | if (view->swayc->instruction) { |
260 | wlr_xdg_surface_get_geometry(xdg_surface, &view->geometry); | ||
270 | transaction_notify_view_ready_by_serial(view, | 261 | transaction_notify_view_ready_by_serial(view, |
271 | xdg_surface->configure_serial); | 262 | xdg_surface->configure_serial); |
263 | } else { | ||
264 | struct wlr_box new_geo; | ||
265 | wlr_xdg_surface_get_geometry(xdg_surface, &new_geo); | ||
266 | |||
267 | if ((new_geo.width != view->width || new_geo.height != view->height) && | ||
268 | container_is_floating(view->swayc)) { | ||
269 | // A floating view has unexpectedly sent a new size | ||
270 | desktop_damage_view(view); | ||
271 | view_update_size(view, new_geo.width, new_geo.height); | ||
272 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); | ||
273 | desktop_damage_view(view); | ||
274 | transaction_commit_dirty(); | ||
275 | } else { | ||
276 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); | ||
277 | } | ||
272 | } | 278 | } |
273 | 279 | ||
274 | view_damage_from(view); | 280 | view_damage_from(view); |