From 396840cdf215b4affea28ac39f10f0011da94ed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Fri, 8 Dec 2023 12:52:46 -0600 Subject: [PATCH] Revert "nuke CSDs, hopefully for good!" The compositor must respond to the client requesting a change to the decoration mode, it does not matter if the compositor chooses a different mode. This reverts commit 9071ce6c848ce214939fb84f85ae77de86de88d7. --- dwl.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/dwl.c b/dwl.c index 32a4df8..bb83168 100644 --- a/dwl.c +++ b/dwl.c @@ -264,12 +264,14 @@ static void destroylocksurface(struct wl_listener *listener, void *data); static void destroynotify(struct wl_listener *listener, void *data); static void destroysessionlock(struct wl_listener *listener, void *data); static void destroysessionmgr(struct wl_listener *listener, void *data); +static void destroyxdeco(struct wl_listener *listener, void *data); static Monitor *dirtomon(enum wlr_direction dir); static void focusclient(Client *c, int lift); static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); static Client *focustop(Monitor *m); static void fullscreennotify(struct wl_listener *listener, void *data); +static void getxdecomode(struct wl_listener *listener, void *data); static void handlesig(int signo); static void incnmaster(const Arg *arg); static void inputdevice(struct wl_listener *listener, void *data); @@ -741,8 +743,13 @@ commitnotify(struct wl_listener *listener, void *data) void createdecoration(struct wl_listener *listener, void *data) { - struct wlr_xdg_toplevel_decoration_v1 *dec = data; - wlr_xdg_toplevel_decoration_v1_set_mode(dec, WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); + struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data; + Decoration *d = wlr_deco->data = calloc(1, sizeof(*d)); + + LISTEN(&wlr_deco->events.request_mode, &d->request_mode, getxdecomode); + LISTEN(&wlr_deco->events.destroy, &d->destroy, destroyxdeco); + + getxdecomode(&d->request_mode, wlr_deco); } void @@ -1124,6 +1131,17 @@ destroysessionmgr(struct wl_listener *listener, void *data) wl_list_remove(&listener->link); } +void +destroyxdeco(struct wl_listener *listener, void *data) +{ + struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data; + Decoration *d = wlr_deco->data; + + wl_list_remove(&d->destroy.link); + wl_list_remove(&d->request_mode.link); + free(d); +} + Monitor * dirtomon(enum wlr_direction dir) { @@ -1274,6 +1292,14 @@ fullscreennotify(struct wl_listener *listener, void *data) setfullscreen(c, client_wants_fullscreen(c)); } +void +getxdecomode(struct wl_listener *listener, void *data) +{ + struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data; + wlr_xdg_toplevel_decoration_v1_set_mode(wlr_deco, + WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); +} + void handlesig(int signo) {