diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-09-27 22:44:57 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-09-27 22:51:37 +1000 |
commit | 21ff87d72b44604d348cf71da3175b85ac5b2f75 (patch) | |
tree | de0ecfd66fd3a6957e0f8a2eb5038c785b3965c2 /sway/xdg_decoration.c | |
parent | Rename view_set_csd_from_client to view_update_csd_from_client (diff) | |
download | sway-21ff87d72b44604d348cf71da3175b85ac5b2f75.tar.gz sway-21ff87d72b44604d348cf71da3175b85ac5b2f75.tar.zst sway-21ff87d72b44604d348cf71da3175b85ac5b2f75.zip |
Improve CSD logic
This does the following:
* Removes the xdg-decoration surface_commit listener. I was under the
impression the client could ignore the server's preference and set
whatever decoration they like using this protocol, but I don't think
that's right.
* Adds a listener for the xdg-decoration request_mode signal. The
protocol states that the server should respond to this with its
preference. We'll always respond with SSD here.
* Makes it so tiled views which use CSD will still have sway decorations
rendered. To do this, using_csd had to be added back to the view struct,
and the border is changed when floating or unfloating a view.
Diffstat (limited to 'sway/xdg_decoration.c')
-rw-r--r-- | sway/xdg_decoration.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/sway/xdg_decoration.c b/sway/xdg_decoration.c index 80b2f57e..39e0df56 100644 --- a/sway/xdg_decoration.c +++ b/sway/xdg_decoration.c | |||
@@ -12,31 +12,22 @@ static void xdg_decoration_handle_destroy(struct wl_listener *listener, | |||
12 | wl_container_of(listener, deco, destroy); | 12 | wl_container_of(listener, deco, destroy); |
13 | deco->view->xdg_decoration = NULL; | 13 | deco->view->xdg_decoration = NULL; |
14 | wl_list_remove(&deco->destroy.link); | 14 | wl_list_remove(&deco->destroy.link); |
15 | wl_list_remove(&deco->surface_commit.link); | 15 | wl_list_remove(&deco->request_mode.link); |
16 | wl_list_remove(&deco->link); | 16 | wl_list_remove(&deco->link); |
17 | free(deco); | 17 | free(deco); |
18 | } | 18 | } |
19 | 19 | ||
20 | static void xdg_decoration_handle_surface_commit(struct wl_listener *listener, | 20 | static void xdg_decoration_handle_request_mode(struct wl_listener *listener, |
21 | void *data) { | 21 | void *data) { |
22 | struct sway_xdg_decoration *decoration = | 22 | struct sway_xdg_decoration *deco = |
23 | wl_container_of(listener, decoration, surface_commit); | 23 | wl_container_of(listener, deco, request_mode); |
24 | 24 | wlr_xdg_toplevel_decoration_v1_set_mode(deco->wlr_xdg_decoration, | |
25 | bool csd = decoration->wlr_xdg_decoration->current_mode == | 25 | WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); |
26 | WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; | ||
27 | struct sway_view *view = decoration->view; | ||
28 | |||
29 | view_update_csd_from_client(view, csd); | ||
30 | |||
31 | arrange_container(view->container); | ||
32 | transaction_commit_dirty(); | ||
33 | } | 26 | } |
34 | 27 | ||
35 | void handle_xdg_decoration(struct wl_listener *listener, void *data) { | 28 | void handle_xdg_decoration(struct wl_listener *listener, void *data) { |
36 | struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data; | 29 | struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data; |
37 | struct sway_xdg_shell_view *xdg_shell_view = wlr_deco->surface->data; | 30 | struct sway_xdg_shell_view *xdg_shell_view = wlr_deco->surface->data; |
38 | struct wlr_xdg_surface *wlr_xdg_surface = | ||
39 | xdg_shell_view->view.wlr_xdg_surface; | ||
40 | 31 | ||
41 | struct sway_xdg_decoration *deco = calloc(1, sizeof(*deco)); | 32 | struct sway_xdg_decoration *deco = calloc(1, sizeof(*deco)); |
42 | if (deco == NULL) { | 33 | if (deco == NULL) { |
@@ -50,13 +41,8 @@ void handle_xdg_decoration(struct wl_listener *listener, void *data) { | |||
50 | wl_signal_add(&wlr_deco->events.destroy, &deco->destroy); | 41 | wl_signal_add(&wlr_deco->events.destroy, &deco->destroy); |
51 | deco->destroy.notify = xdg_decoration_handle_destroy; | 42 | deco->destroy.notify = xdg_decoration_handle_destroy; |
52 | 43 | ||
53 | // Note: We don't listen to the request_mode signal here, effectively | 44 | wl_signal_add(&wlr_deco->events.request_mode, &deco->request_mode); |
54 | // ignoring any modes the client asks to set. The client can still force a | 45 | deco->request_mode.notify = xdg_decoration_handle_request_mode; |
55 | // mode upon us, in which case we get upset but live with it. | ||
56 | |||
57 | deco->surface_commit.notify = xdg_decoration_handle_surface_commit; | ||
58 | wl_signal_add(&wlr_xdg_surface->surface->events.commit, | ||
59 | &deco->surface_commit); | ||
60 | 46 | ||
61 | wl_list_insert(&server.xdg_decorations, &deco->link); | 47 | wl_list_insert(&server.xdg_decorations, &deco->link); |
62 | } | 48 | } |