diff options
-rw-r--r-- | include/wlr/types/wlr_xdg_shell.h | 17 | ||||
-rw-r--r-- | protocol/meson.build | 2 | ||||
-rw-r--r-- | types/xdg_shell/wlr_xdg_shell.c | 2 | ||||
-rw-r--r-- | types/xdg_shell/wlr_xdg_toplevel.c | 44 |
4 files changed, 63 insertions, 2 deletions
diff --git a/include/wlr/types/wlr_xdg_shell.h b/include/wlr/types/wlr_xdg_shell.h index b4ef2e94..90371282 100644 --- a/include/wlr/types/wlr_xdg_shell.h +++ b/include/wlr/types/wlr_xdg_shell.h @@ -140,8 +140,16 @@ struct wlr_xdg_toplevel_state { uint32_t min_width, min_height; }; +enum wlr_xdg_toplevel_wm_capabilities { + WLR_XDG_TOPLEVEL_WM_CAPABILITIES_WINDOW_MENU = 1 << 0, + WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE = 1 << 1, + WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN = 1 << 2, + WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE = 1 << 3, +}; + enum wlr_xdg_toplevel_configure_field { WLR_XDG_TOPLEVEL_CONFIGURE_BOUNDS = 1 << 0, + WLR_XDG_TOPLEVEL_CONFIGURE_WM_CAPABILITIES = 1 << 1, }; struct wlr_xdg_toplevel_configure { @@ -152,6 +160,7 @@ struct wlr_xdg_toplevel_configure { struct { uint32_t width, height; } bounds; + uint32_t wm_capabilities; // enum wlr_xdg_toplevel_wm_capabilities }; struct wlr_xdg_toplevel_requested { @@ -395,6 +404,14 @@ uint32_t wlr_xdg_toplevel_set_bounds(struct wlr_xdg_toplevel *toplevel, int32_t width, int32_t height); /** + * Configure the window manager capabilities for this toplevel. `caps` is a + * bitfield of `enum wlr_xdg_toplevel_wm_capabilities`. Returns the associated + * configure serial. + */ +uint32_t wlr_xdg_toplevel_set_wm_capabilities(struct wlr_xdg_toplevel *toplevel, + uint32_t caps); + +/** * Request that this toplevel closes. */ void wlr_xdg_toplevel_send_close(struct wlr_xdg_toplevel *toplevel); diff --git a/protocol/meson.build b/protocol/meson.build index 179c731d..4cc01874 100644 --- a/protocol/meson.build +++ b/protocol/meson.build @@ -1,5 +1,5 @@ wayland_protos = dependency('wayland-protocols', - version: '>=1.25', + version: '>=1.26', fallback: 'wayland-protocols', default_options: ['tests=false'], ) diff --git a/types/xdg_shell/wlr_xdg_shell.c b/types/xdg_shell/wlr_xdg_shell.c index 9008de4e..06d11847 100644 --- a/types/xdg_shell/wlr_xdg_shell.c +++ b/types/xdg_shell/wlr_xdg_shell.c @@ -3,7 +3,7 @@ #include "types/wlr_xdg_shell.h" #include "util/signal.h" -#define WM_BASE_VERSION 4 +#define WM_BASE_VERSION 5 static const struct xdg_wm_base_interface xdg_shell_impl; diff --git a/types/xdg_shell/wlr_xdg_toplevel.c b/types/xdg_shell/wlr_xdg_toplevel.c index dee2571f..878b0091 100644 --- a/types/xdg_shell/wlr_xdg_toplevel.c +++ b/types/xdg_shell/wlr_xdg_toplevel.c @@ -39,6 +39,31 @@ struct wlr_xdg_toplevel_configure *send_xdg_toplevel_configure( configure->bounds.width, configure->bounds.height); } + if ((configure->fields & WLR_XDG_TOPLEVEL_CONFIGURE_WM_CAPABILITIES) && + version >= XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION) { + size_t caps_len = 0; + uint32_t caps[32]; + if (configure->wm_capabilities & WLR_XDG_TOPLEVEL_WM_CAPABILITIES_WINDOW_MENU) { + caps[caps_len++] = XDG_TOPLEVEL_WM_CAPABILITIES_WINDOW_MENU; + } + if (configure->wm_capabilities & WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE) { + caps[caps_len++] = XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE; + } + if (configure->wm_capabilities & WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN) { + caps[caps_len++] = XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN; + } + if (configure->wm_capabilities & WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE) { + caps[caps_len++] = XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE; + } + assert(caps_len <= sizeof(caps) / sizeof(caps[0])); + + struct wl_array caps_array = { + .size = caps_len * sizeof(caps[0]), + .data = caps, + }; + xdg_toplevel_send_wm_capabilities(toplevel->resource, &caps_array); + } + size_t nstates = 0; uint32_t states[32]; if (configure->maximized) { @@ -97,6 +122,16 @@ void handle_xdg_toplevel_committed(struct wlr_xdg_toplevel *toplevel) { // is added wlr_xdg_surface_schedule_configure(toplevel->base); toplevel->added = true; + + if (toplevel->base->client->shell->version >= + XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION) { + // The first configure event must carry WM capabilities + wlr_xdg_toplevel_set_wm_capabilities(toplevel, + WLR_XDG_TOPLEVEL_WM_CAPABILITIES_WINDOW_MENU | + WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE | + WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN | + WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE); + } return; } @@ -524,3 +559,12 @@ uint32_t wlr_xdg_toplevel_set_bounds(struct wlr_xdg_toplevel *toplevel, toplevel->scheduled.bounds.height = height; return wlr_xdg_surface_schedule_configure(toplevel->base); } + +uint32_t wlr_xdg_toplevel_set_wm_capabilities(struct wlr_xdg_toplevel *toplevel, + uint32_t caps) { + assert(toplevel->base->client->shell->version >= + XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION); + toplevel->scheduled.fields |= WLR_XDG_TOPLEVEL_CONFIGURE_WM_CAPABILITIES; + toplevel->scheduled.wm_capabilities = caps; + return wlr_xdg_surface_schedule_configure(toplevel->base); +} |