From 47e6a1164c25b5b49bfb919a681b88641d2ce37c Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Tue, 11 Jul 2023 15:09:14 +0300 Subject: xdg-shell: chase events update --- sway/xdg_decoration.c | 59 ++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 27 deletions(-) (limited to 'sway/xdg_decoration.c') diff --git a/sway/xdg_decoration.c b/sway/xdg_decoration.c index f7f5f5ed..fa8c6279 100644 --- a/sway/xdg_decoration.c +++ b/sway/xdg_decoration.c @@ -23,32 +23,7 @@ static void xdg_decoration_handle_request_mode(struct wl_listener *listener, void *data) { struct sway_xdg_decoration *deco = wl_container_of(listener, deco, request_mode); - struct sway_view *view = deco->view; - enum wlr_xdg_toplevel_decoration_v1_mode mode = - WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE; - enum wlr_xdg_toplevel_decoration_v1_mode client_mode = - deco->wlr_xdg_decoration->requested_mode; - - bool floating; - if (view->container) { - floating = container_is_floating(view->container); - bool csd = false; - csd = client_mode == - WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; - view_update_csd_from_client(view, csd); - arrange_container(view->container); - transaction_commit_dirty(); - } else { - floating = view->impl->wants_floating && - view->impl->wants_floating(view); - } - - if (floating && client_mode) { - mode = client_mode; - } - - wlr_xdg_toplevel_decoration_v1_set_mode(deco->wlr_xdg_decoration, - mode); + set_xdg_decoration_mode(deco); } void handle_xdg_decoration(struct wl_listener *listener, void *data) { @@ -72,7 +47,7 @@ void handle_xdg_decoration(struct wl_listener *listener, void *data) { wl_list_insert(&server.xdg_decorations, &deco->link); - xdg_decoration_handle_request_mode(&deco->request_mode, wlr_deco); + set_xdg_decoration_mode(deco); } struct sway_xdg_decoration *xdg_decoration_from_surface( @@ -85,3 +60,33 @@ struct sway_xdg_decoration *xdg_decoration_from_surface( } return NULL; } + +void set_xdg_decoration_mode(struct sway_xdg_decoration *deco) { + struct sway_view *view = deco->view; + enum wlr_xdg_toplevel_decoration_v1_mode mode = + WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE; + enum wlr_xdg_toplevel_decoration_v1_mode client_mode = + deco->wlr_xdg_decoration->requested_mode; + + bool floating; + if (view->container) { + floating = container_is_floating(view->container); + bool csd = false; + csd = client_mode == + WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; + view_update_csd_from_client(view, csd); + arrange_container(view->container); + transaction_commit_dirty(); + } else { + floating = view->impl->wants_floating && + view->impl->wants_floating(view); + } + + if (floating && client_mode) { + mode = client_mode; + } + + if (view->wlr_xdg_toplevel->base->initialized) { + wlr_xdg_toplevel_decoration_v1_set_mode(deco->wlr_xdg_decoration, mode); + } +} -- cgit v1.2.3-54-g00ecf