diff options
Diffstat (limited to 'sway/desktop/xdg_shell_v6.c')
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 73 |
1 files changed, 42 insertions, 31 deletions
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index a37a4caf..69819280 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -3,9 +3,10 @@ | |||
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <wayland-server.h> | 4 | #include <wayland-server.h> |
5 | #include <wlr/types/wlr_xdg_shell_v6.h> | 5 | #include <wlr/types/wlr_xdg_shell_v6.h> |
6 | #include "sway/server.h" | ||
7 | #include "sway/tree/arrange.h" | ||
6 | #include "sway/tree/container.h" | 8 | #include "sway/tree/container.h" |
7 | #include "sway/tree/layout.h" | 9 | #include "sway/tree/layout.h" |
8 | #include "sway/server.h" | ||
9 | #include "sway/tree/view.h" | 10 | #include "sway/tree/view.h" |
10 | #include "sway/input/seat.h" | 11 | #include "sway/input/seat.h" |
11 | #include "sway/input/input-manager.h" | 12 | #include "sway/input/input-manager.h" |
@@ -86,18 +87,15 @@ static const char *get_string_prop(struct sway_view *view, enum sway_view_prop p | |||
86 | } | 87 | } |
87 | } | 88 | } |
88 | 89 | ||
89 | static void configure(struct sway_view *view, double lx, double ly, int width, | 90 | static uint32_t configure(struct sway_view *view, double lx, double ly, |
90 | int height) { | 91 | int width, int height) { |
91 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = | 92 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = |
92 | xdg_shell_v6_view_from_view(view); | 93 | xdg_shell_v6_view_from_view(view); |
93 | if (xdg_shell_v6_view == NULL) { | 94 | if (xdg_shell_v6_view == NULL) { |
94 | return; | 95 | return 0; |
95 | } | 96 | } |
96 | 97 | return wlr_xdg_toplevel_v6_set_size( | |
97 | xdg_shell_v6_view->pending_width = width; | 98 | view->wlr_xdg_surface_v6, width, height); |
98 | xdg_shell_v6_view->pending_height = height; | ||
99 | wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); | ||
100 | view_update_position(view, lx, ly); | ||
101 | } | 99 | } |
102 | 100 | ||
103 | static void set_activated(struct sway_view *view, bool activated) { | 101 | static void set_activated(struct sway_view *view, bool activated) { |
@@ -161,10 +159,6 @@ static void destroy(struct sway_view *view) { | |||
161 | if (xdg_shell_v6_view == NULL) { | 159 | if (xdg_shell_v6_view == NULL) { |
162 | return; | 160 | return; |
163 | } | 161 | } |
164 | wl_list_remove(&xdg_shell_v6_view->destroy.link); | ||
165 | wl_list_remove(&xdg_shell_v6_view->map.link); | ||
166 | wl_list_remove(&xdg_shell_v6_view->unmap.link); | ||
167 | wl_list_remove(&xdg_shell_v6_view->request_fullscreen.link); | ||
168 | free(xdg_shell_v6_view); | 162 | free(xdg_shell_v6_view); |
169 | } | 163 | } |
170 | 164 | ||
@@ -184,18 +178,15 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
184 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = | 178 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = |
185 | wl_container_of(listener, xdg_shell_v6_view, commit); | 179 | wl_container_of(listener, xdg_shell_v6_view, commit); |
186 | struct sway_view *view = &xdg_shell_v6_view->view; | 180 | struct sway_view *view = &xdg_shell_v6_view->view; |
187 | if (view->swayc && container_is_floating(view->swayc)) { | 181 | struct wlr_xdg_surface_v6 *xdg_surface_v6 = view->wlr_xdg_surface_v6; |
188 | int width = view->wlr_xdg_surface_v6->geometry.width; | 182 | |
189 | int height = view->wlr_xdg_surface_v6->geometry.height; | 183 | if (!view->swayc) { |
190 | if (!width && !height) { | 184 | return; |
191 | width = view->wlr_xdg_surface_v6->surface->current->width; | ||
192 | height = view->wlr_xdg_surface_v6->surface->current->height; | ||
193 | } | ||
194 | view_update_size(view, width, height); | ||
195 | } else { | ||
196 | view_update_size(view, xdg_shell_v6_view->pending_width, | ||
197 | xdg_shell_v6_view->pending_height); | ||
198 | } | 185 | } |
186 | if (view->swayc->instructions->length) { | ||
187 | transaction_notify_view_ready(view, xdg_surface_v6->configure_serial); | ||
188 | } | ||
189 | |||
199 | view_update_title(view, false); | 190 | view_update_title(view, false); |
200 | view_damage_from(view); | 191 | view_damage_from(view); |
201 | } | 192 | } |
@@ -210,8 +201,13 @@ static void handle_new_popup(struct wl_listener *listener, void *data) { | |||
210 | static void handle_unmap(struct wl_listener *listener, void *data) { | 201 | static void handle_unmap(struct wl_listener *listener, void *data) { |
211 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = | 202 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = |
212 | wl_container_of(listener, xdg_shell_v6_view, unmap); | 203 | wl_container_of(listener, xdg_shell_v6_view, unmap); |
204 | struct sway_view *view = &xdg_shell_v6_view->view; | ||
205 | |||
206 | if (!sway_assert(view->surface, "Cannot unmap unmapped view")) { | ||
207 | return; | ||
208 | } | ||
213 | 209 | ||
214 | view_unmap(&xdg_shell_v6_view->view); | 210 | view_unmap(view); |
215 | 211 | ||
216 | wl_list_remove(&xdg_shell_v6_view->commit.link); | 212 | wl_list_remove(&xdg_shell_v6_view->commit.link); |
217 | wl_list_remove(&xdg_shell_v6_view->new_popup.link); | 213 | wl_list_remove(&xdg_shell_v6_view->new_popup.link); |
@@ -229,8 +225,17 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
229 | view->natural_width = view->wlr_xdg_surface_v6->surface->current->width; | 225 | view->natural_width = view->wlr_xdg_surface_v6->surface->current->width; |
230 | view->natural_height = view->wlr_xdg_surface_v6->surface->current->height; | 226 | view->natural_height = view->wlr_xdg_surface_v6->surface->current->height; |
231 | } | 227 | } |
228 | |||
232 | view_map(view, view->wlr_xdg_surface_v6->surface); | 229 | view_map(view, view->wlr_xdg_surface_v6->surface); |
233 | 230 | ||
231 | if (xdg_surface->toplevel->client_pending.fullscreen) { | ||
232 | view_set_fullscreen(view, true); | ||
233 | struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); | ||
234 | arrange_and_commit(ws); | ||
235 | } else { | ||
236 | arrange_and_commit(view->swayc->parent); | ||
237 | } | ||
238 | |||
234 | xdg_shell_v6_view->commit.notify = handle_commit; | 239 | xdg_shell_v6_view->commit.notify = handle_commit; |
235 | wl_signal_add(&xdg_surface->surface->events.commit, | 240 | wl_signal_add(&xdg_surface->surface->events.commit, |
236 | &xdg_shell_v6_view->commit); | 241 | &xdg_shell_v6_view->commit); |
@@ -238,16 +243,18 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
238 | xdg_shell_v6_view->new_popup.notify = handle_new_popup; | 243 | xdg_shell_v6_view->new_popup.notify = handle_new_popup; |
239 | wl_signal_add(&xdg_surface->events.new_popup, | 244 | wl_signal_add(&xdg_surface->events.new_popup, |
240 | &xdg_shell_v6_view->new_popup); | 245 | &xdg_shell_v6_view->new_popup); |
241 | |||
242 | if (xdg_surface->toplevel->client_pending.fullscreen) { | ||
243 | view_set_fullscreen(view, true); | ||
244 | } | ||
245 | } | 246 | } |
246 | 247 | ||
247 | static void handle_destroy(struct wl_listener *listener, void *data) { | 248 | static void handle_destroy(struct wl_listener *listener, void *data) { |
248 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = | 249 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = |
249 | wl_container_of(listener, xdg_shell_v6_view, destroy); | 250 | wl_container_of(listener, xdg_shell_v6_view, destroy); |
250 | view_destroy(&xdg_shell_v6_view->view); | 251 | struct sway_view *view = &xdg_shell_v6_view->view; |
252 | wl_list_remove(&xdg_shell_v6_view->destroy.link); | ||
253 | wl_list_remove(&xdg_shell_v6_view->map.link); | ||
254 | wl_list_remove(&xdg_shell_v6_view->unmap.link); | ||
255 | wl_list_remove(&xdg_shell_v6_view->request_fullscreen.link); | ||
256 | view->wlr_xdg_surface_v6 = NULL; | ||
257 | view_destroy(view); | ||
251 | } | 258 | } |
252 | 259 | ||
253 | static void handle_request_fullscreen(struct wl_listener *listener, void *data) { | 260 | static void handle_request_fullscreen(struct wl_listener *listener, void *data) { |
@@ -256,6 +263,7 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data) | |||
256 | struct wlr_xdg_toplevel_v6_set_fullscreen_event *e = data; | 263 | struct wlr_xdg_toplevel_v6_set_fullscreen_event *e = data; |
257 | struct wlr_xdg_surface_v6 *xdg_surface = | 264 | struct wlr_xdg_surface_v6 *xdg_surface = |
258 | xdg_shell_v6_view->view.wlr_xdg_surface_v6; | 265 | xdg_shell_v6_view->view.wlr_xdg_surface_v6; |
266 | struct sway_view *view = &xdg_shell_v6_view->view; | ||
259 | 267 | ||
260 | if (!sway_assert(xdg_surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL, | 268 | if (!sway_assert(xdg_surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL, |
261 | "xdg_shell_v6 requested fullscreen of surface with role %i", | 269 | "xdg_shell_v6 requested fullscreen of surface with role %i", |
@@ -266,7 +274,10 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data) | |||
266 | return; | 274 | return; |
267 | } | 275 | } |
268 | 276 | ||
269 | view_set_fullscreen(&xdg_shell_v6_view->view, e->fullscreen); | 277 | view_set_fullscreen(view, e->fullscreen); |
278 | |||
279 | struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); | ||
280 | arrange_and_commit(ws); | ||
270 | } | 281 | } |
271 | 282 | ||
272 | void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { | 283 | void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { |