diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2026-01-04 19:30:53 -0700 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2026-01-04 19:31:16 -0700 |
| commit | 235de32e3b4d0ae8de984a29af9d6233c1ed1080 (patch) | |
| tree | 4dcd18c2d884b0db05b9942bb40a12f8227229d3 | |
| parent | efe34b2c98cc90ed686217ea3b0655fae1839414 (diff) | |
| download | montis-235de32e3b4d0ae8de984a29af9d6233c1ed1080.tar.gz montis-235de32e3b4d0ae8de984a29af9d6233c1ed1080.tar.bz2 montis-235de32e3b4d0ae8de984a29af9d6233c1ed1080.zip | |
[feat] Request that clients don't draw their decorations.
| -rw-r--r-- | rt/include/plugin.h | 1 | ||||
| -rw-r--r-- | rt/include/wl.h | 9 | ||||
| -rw-r--r-- | rt/src/wl.c | 45 |
3 files changed, 55 insertions, 0 deletions
diff --git a/rt/include/plugin.h b/rt/include/plugin.h index be5dbb4..4146b37 100644 --- a/rt/include/plugin.h +++ b/rt/include/plugin.h @@ -143,6 +143,7 @@ typedef struct PLUGIN { EXPORT(opqst_t (*plugin_handle_button)(struct wlr_pointer_button_event *event, uint32_t modifiers, opqst_t state)); + /* Absolute motion only for now; relative motion stays in the runtime. */ EXPORT(opqst_t (*plugin_handle_motion)( struct wlr_pointer_motion_absolute_event *event, uint32_t modifiers, opqst_t state)); diff --git a/rt/include/wl.h b/rt/include/wl.h index dc7fe9f..f10ee7d 100644 --- a/rt/include/wl.h +++ b/rt/include/wl.h @@ -22,6 +22,7 @@ #include <wlr/types/wlr_subcompositor.h> #include <wlr/types/wlr_xcursor_manager.h> #include <wlr/types/wlr_xdg_shell.h> +#include <wlr/types/wlr_xdg_decoration_v1.h> #include <wlr/util/log.h> #include <xkbcommon/xkbcommon.h> @@ -47,6 +48,9 @@ struct montis_server { struct wl_listener new_xdg_popup; struct wl_list toplevels; + struct wlr_xdg_decoration_manager_v1 *xdg_decoration_manager; + struct wl_listener new_xdg_decoration; + struct wlr_cursor *cursor; struct wlr_xcursor_manager *cursor_mgr; struct wl_listener cursor_motion; @@ -114,3 +118,8 @@ struct montis_popup { struct wl_listener destroy; }; +struct montis_xdg_decoration { + struct wlr_xdg_toplevel_decoration_v1 *decoration; + struct wl_listener request_mode; + struct wl_listener destroy; +}; diff --git a/rt/src/wl.c b/rt/src/wl.c index 7c24168..af348f3 100644 --- a/rt/src/wl.c +++ b/rt/src/wl.c @@ -822,6 +822,41 @@ static void server_new_xdg_popup(struct wl_listener *listener, void *data) wl_signal_add(&xdg_popup->events.destroy, &popup->destroy); } +static void xdg_decoration_request_mode(struct wl_listener *listener, + void *data) +{ + /* Clients can request a decoration mode; we always enforce server-side. */ + struct montis_xdg_decoration *dec = + wl_container_of(listener, dec, request_mode); + wlr_xdg_toplevel_decoration_v1_set_mode( + dec->decoration, WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); +} + +static void xdg_decoration_destroy(struct wl_listener *listener, void *data) +{ + struct montis_xdg_decoration *dec = + wl_container_of(listener, dec, destroy); + wl_list_remove(&dec->request_mode.link); + wl_list_remove(&dec->destroy.link); + free(dec); +} + +static void server_new_xdg_decoration(struct wl_listener *listener, void *data) +{ + /* Force server-side decorations to disable client-side frames. */ + struct wlr_xdg_toplevel_decoration_v1 *decoration = data; + struct montis_xdg_decoration *dec = calloc(1, sizeof(*dec)); + dec->decoration = decoration; + + dec->request_mode.notify = xdg_decoration_request_mode; + wl_signal_add(&decoration->events.request_mode, &dec->request_mode); + dec->destroy.notify = xdg_decoration_destroy; + wl_signal_add(&decoration->events.destroy, &dec->destroy); + + wlr_xdg_toplevel_decoration_v1_set_mode( + decoration, WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); +} + static void xdg_toplevel_commit(struct wl_listener *listener, void *data) { /* Called when a new surface state is committed. */ @@ -992,6 +1027,16 @@ int main(int argc, char *argv[]) server.new_xdg_popup.notify = server_new_xdg_popup; wl_signal_add(&server.xdg_shell->events.new_popup, &server.new_xdg_popup); + /* Request server-side decorations for xdg-toplevel surfaces. */ + server.xdg_decoration_manager = + wlr_xdg_decoration_manager_v1_create(server.wl_display); + if (server.xdg_decoration_manager != NULL) { + server.new_xdg_decoration.notify = server_new_xdg_decoration; + wl_signal_add( + &server.xdg_decoration_manager->events.new_toplevel_decoration, + &server.new_xdg_decoration); + } + /* * Creates a cursor, which is a wlroots utility for tracking the cursor * image shown on screen. |