From 21ff87d72b44604d348cf71da3175b85ac5b2f75 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 27 Sep 2018 22:44:57 +1000 Subject: 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. --- sway/xdg_decoration.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'sway/xdg_decoration.c') 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, wl_container_of(listener, deco, destroy); deco->view->xdg_decoration = NULL; wl_list_remove(&deco->destroy.link); - wl_list_remove(&deco->surface_commit.link); + wl_list_remove(&deco->request_mode.link); wl_list_remove(&deco->link); free(deco); } -static void xdg_decoration_handle_surface_commit(struct wl_listener *listener, +static void xdg_decoration_handle_request_mode(struct wl_listener *listener, void *data) { - struct sway_xdg_decoration *decoration = - wl_container_of(listener, decoration, surface_commit); - - bool csd = decoration->wlr_xdg_decoration->current_mode == - WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; - struct sway_view *view = decoration->view; - - view_update_csd_from_client(view, csd); - - arrange_container(view->container); - transaction_commit_dirty(); + struct sway_xdg_decoration *deco = + wl_container_of(listener, deco, request_mode); + wlr_xdg_toplevel_decoration_v1_set_mode(deco->wlr_xdg_decoration, + WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); } void handle_xdg_decoration(struct wl_listener *listener, void *data) { struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data; struct sway_xdg_shell_view *xdg_shell_view = wlr_deco->surface->data; - struct wlr_xdg_surface *wlr_xdg_surface = - xdg_shell_view->view.wlr_xdg_surface; struct sway_xdg_decoration *deco = calloc(1, sizeof(*deco)); if (deco == NULL) { @@ -50,13 +41,8 @@ void handle_xdg_decoration(struct wl_listener *listener, void *data) { wl_signal_add(&wlr_deco->events.destroy, &deco->destroy); deco->destroy.notify = xdg_decoration_handle_destroy; - // Note: We don't listen to the request_mode signal here, effectively - // ignoring any modes the client asks to set. The client can still force a - // mode upon us, in which case we get upset but live with it. - - deco->surface_commit.notify = xdg_decoration_handle_surface_commit; - wl_signal_add(&wlr_xdg_surface->surface->events.commit, - &deco->surface_commit); + wl_signal_add(&wlr_deco->events.request_mode, &deco->request_mode); + deco->request_mode.notify = xdg_decoration_handle_request_mode; wl_list_insert(&server.xdg_decorations, &deco->link); } -- cgit v1.2.3-54-g00ecf