diff options
author | Kirill Primak <vyivel@eclair.cafe> | 2023-07-11 15:09:14 +0300 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-11-23 19:41:57 +0100 |
commit | 47e6a1164c25b5b49bfb919a681b88641d2ce37c (patch) | |
tree | 7d801aeea31eef9ab2f60cbaaa52d2b9d55289b3 /sway/xdg_decoration.c | |
parent | Pass wl_display to wlr_output_layout (diff) | |
download | sway-47e6a1164c25b5b49bfb919a681b88641d2ce37c.tar.gz sway-47e6a1164c25b5b49bfb919a681b88641d2ce37c.tar.zst sway-47e6a1164c25b5b49bfb919a681b88641d2ce37c.zip |
xdg-shell: chase events update
Diffstat (limited to 'sway/xdg_decoration.c')
-rw-r--r-- | sway/xdg_decoration.c | 59 |
1 files changed, 32 insertions, 27 deletions
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, | |||
23 | void *data) { | 23 | void *data) { |
24 | struct sway_xdg_decoration *deco = | 24 | struct sway_xdg_decoration *deco = |
25 | wl_container_of(listener, deco, request_mode); | 25 | wl_container_of(listener, deco, request_mode); |
26 | struct sway_view *view = deco->view; | 26 | set_xdg_decoration_mode(deco); |
27 | enum wlr_xdg_toplevel_decoration_v1_mode mode = | ||
28 | WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE; | ||
29 | enum wlr_xdg_toplevel_decoration_v1_mode client_mode = | ||
30 | deco->wlr_xdg_decoration->requested_mode; | ||
31 | |||
32 | bool floating; | ||
33 | if (view->container) { | ||
34 | floating = container_is_floating(view->container); | ||
35 | bool csd = false; | ||
36 | csd = client_mode == | ||
37 | WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; | ||
38 | view_update_csd_from_client(view, csd); | ||
39 | arrange_container(view->container); | ||
40 | transaction_commit_dirty(); | ||
41 | } else { | ||
42 | floating = view->impl->wants_floating && | ||
43 | view->impl->wants_floating(view); | ||
44 | } | ||
45 | |||
46 | if (floating && client_mode) { | ||
47 | mode = client_mode; | ||
48 | } | ||
49 | |||
50 | wlr_xdg_toplevel_decoration_v1_set_mode(deco->wlr_xdg_decoration, | ||
51 | mode); | ||
52 | } | 27 | } |
53 | 28 | ||
54 | void handle_xdg_decoration(struct wl_listener *listener, void *data) { | 29 | void handle_xdg_decoration(struct wl_listener *listener, void *data) { |
@@ -72,7 +47,7 @@ void handle_xdg_decoration(struct wl_listener *listener, void *data) { | |||
72 | 47 | ||
73 | wl_list_insert(&server.xdg_decorations, &deco->link); | 48 | wl_list_insert(&server.xdg_decorations, &deco->link); |
74 | 49 | ||
75 | xdg_decoration_handle_request_mode(&deco->request_mode, wlr_deco); | 50 | set_xdg_decoration_mode(deco); |
76 | } | 51 | } |
77 | 52 | ||
78 | struct sway_xdg_decoration *xdg_decoration_from_surface( | 53 | struct sway_xdg_decoration *xdg_decoration_from_surface( |
@@ -85,3 +60,33 @@ struct sway_xdg_decoration *xdg_decoration_from_surface( | |||
85 | } | 60 | } |
86 | return NULL; | 61 | return NULL; |
87 | } | 62 | } |
63 | |||
64 | void set_xdg_decoration_mode(struct sway_xdg_decoration *deco) { | ||
65 | struct sway_view *view = deco->view; | ||
66 | enum wlr_xdg_toplevel_decoration_v1_mode mode = | ||
67 | WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE; | ||
68 | enum wlr_xdg_toplevel_decoration_v1_mode client_mode = | ||
69 | deco->wlr_xdg_decoration->requested_mode; | ||
70 | |||
71 | bool floating; | ||
72 | if (view->container) { | ||
73 | floating = container_is_floating(view->container); | ||
74 | bool csd = false; | ||
75 | csd = client_mode == | ||
76 | WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; | ||
77 | view_update_csd_from_client(view, csd); | ||
78 | arrange_container(view->container); | ||
79 | transaction_commit_dirty(); | ||
80 | } else { | ||
81 | floating = view->impl->wants_floating && | ||
82 | view->impl->wants_floating(view); | ||
83 | } | ||
84 | |||
85 | if (floating && client_mode) { | ||
86 | mode = client_mode; | ||
87 | } | ||
88 | |||
89 | if (view->wlr_xdg_toplevel->base->initialized) { | ||
90 | wlr_xdg_toplevel_decoration_v1_set_mode(deco->wlr_xdg_decoration, mode); | ||
91 | } | ||
92 | } | ||