diff options
Diffstat (limited to 'sway/xdg_decoration.c')
-rw-r--r-- | sway/xdg_decoration.c | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/sway/xdg_decoration.c b/sway/xdg_decoration.c index ec9e8d68..fa8c6279 100644 --- a/sway/xdg_decoration.c +++ b/sway/xdg_decoration.c | |||
@@ -23,37 +23,12 @@ 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) { |
55 | struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data; | 30 | struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data; |
56 | struct sway_xdg_shell_view *xdg_shell_view = wlr_deco->surface->data; | 31 | struct sway_xdg_shell_view *xdg_shell_view = wlr_deco->toplevel->base->data; |
57 | 32 | ||
58 | struct sway_xdg_decoration *deco = calloc(1, sizeof(*deco)); | 33 | struct sway_xdg_decoration *deco = calloc(1, sizeof(*deco)); |
59 | if (deco == NULL) { | 34 | if (deco == NULL) { |
@@ -72,16 +47,46 @@ 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( |
79 | struct wlr_surface *surface) { | 54 | struct wlr_surface *surface) { |
80 | struct sway_xdg_decoration *deco; | 55 | struct sway_xdg_decoration *deco; |
81 | wl_list_for_each(deco, &server.xdg_decorations, link) { | 56 | wl_list_for_each(deco, &server.xdg_decorations, link) { |
82 | if (deco->wlr_xdg_decoration->surface->surface == surface) { | 57 | if (deco->wlr_xdg_decoration->toplevel->base->surface == surface) { |
83 | return deco; | 58 | return deco; |
84 | } | 59 | } |
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 | } | ||