From 098cb9b7a3d7c7a8b1633809e04c9bcf34a33784 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 17 Apr 2024 11:30:46 +0200 Subject: [PATCH] xdg-shell: add wlr_xdg_toplevel_configure() A struct wlr_xdg_toplevel_configure is passed in with the whole state. This makes it a lot clearer that the size and WM state are always sent to the client. --- include/wlr/types/wlr_xdg_shell.h | 6 ++++++ types/xdg_shell/wlr_xdg_toplevel.c | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/wlr/types/wlr_xdg_shell.h b/include/wlr/types/wlr_xdg_shell.h index 854185bf..900d504c 100644 --- a/include/wlr/types/wlr_xdg_shell.h +++ b/include/wlr/types/wlr_xdg_shell.h @@ -374,6 +374,12 @@ struct wlr_xdg_positioner *wlr_xdg_positioner_from_resource( */ void wlr_xdg_surface_ping(struct wlr_xdg_surface *surface); +/** + * Configure the toplevel. Returns the associated configure serial. + */ +uint32_t wlr_xdg_toplevel_configure(struct wlr_xdg_toplevel *toplevel, + const struct wlr_xdg_toplevel_configure *configure); + /** * Request that this toplevel surface be the given size. Returns the associated * configure serial. diff --git a/types/xdg_shell/wlr_xdg_toplevel.c b/types/xdg_shell/wlr_xdg_toplevel.c index 1c4fa30c..556dcf80 100644 --- a/types/xdg_shell/wlr_xdg_toplevel.c +++ b/types/xdg_shell/wlr_xdg_toplevel.c @@ -545,6 +545,30 @@ void wlr_xdg_toplevel_send_close(struct wlr_xdg_toplevel *toplevel) { xdg_toplevel_send_close(toplevel->resource); } +uint32_t wlr_xdg_toplevel_configure(struct wlr_xdg_toplevel *toplevel, + const struct wlr_xdg_toplevel_configure *configure) { + toplevel->scheduled.width = configure->width; + toplevel->scheduled.height = configure->height; + toplevel->scheduled.maximized = configure->maximized; + toplevel->scheduled.fullscreen = configure->fullscreen; + toplevel->scheduled.resizing = configure->resizing; + toplevel->scheduled.activated = configure->activated; + toplevel->scheduled.suspended = configure->suspended; + toplevel->scheduled.tiled = configure->tiled; + + if (configure->fields & WLR_XDG_TOPLEVEL_CONFIGURE_BOUNDS) { + toplevel->scheduled.fields |= WLR_XDG_TOPLEVEL_CONFIGURE_BOUNDS; + toplevel->scheduled.bounds = configure->bounds; + } + + if (configure->fields & WLR_XDG_TOPLEVEL_CONFIGURE_WM_CAPABILITIES) { + toplevel->scheduled.fields |= WLR_XDG_TOPLEVEL_CONFIGURE_WM_CAPABILITIES; + toplevel->scheduled.wm_capabilities = configure->wm_capabilities; + } + + return wlr_xdg_surface_schedule_configure(toplevel->base); +} + uint32_t wlr_xdg_toplevel_set_size(struct wlr_xdg_toplevel *toplevel, int32_t width, int32_t height) { assert(width >= 0 && height >= 0);