layer-shell-v1: specify version in constructor

This allows compositors to indicate which features they support,
and is required to eventually make this API stable.

References: https://github.com/swaywm/sway/issues/7260
This commit is contained in:
Simon Ser 2022-11-14 09:52:13 +01:00
parent 4026da53f8
commit 9f793d3503
2 changed files with 7 additions and 4 deletions

View file

@ -122,7 +122,8 @@ struct wlr_layer_surface_v1 {
void *data; void *data;
}; };
struct wlr_layer_shell_v1 *wlr_layer_shell_v1_create(struct wl_display *display); struct wlr_layer_shell_v1 *wlr_layer_shell_v1_create(struct wl_display *display,
uint32_t version);
/** /**
* Notifies the layer surface to configure itself with this width/height. The * Notifies the layer surface to configure itself with this width/height. The

View file

@ -492,7 +492,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
free(layer_shell); free(layer_shell);
} }
struct wlr_layer_shell_v1 *wlr_layer_shell_v1_create(struct wl_display *display) { struct wlr_layer_shell_v1 *wlr_layer_shell_v1_create(struct wl_display *display,
uint32_t version) {
assert(version <= LAYER_SHELL_VERSION);
struct wlr_layer_shell_v1 *layer_shell = struct wlr_layer_shell_v1 *layer_shell =
calloc(1, sizeof(struct wlr_layer_shell_v1)); calloc(1, sizeof(struct wlr_layer_shell_v1));
if (!layer_shell) { if (!layer_shell) {
@ -500,8 +503,7 @@ struct wlr_layer_shell_v1 *wlr_layer_shell_v1_create(struct wl_display *display)
} }
struct wl_global *global = wl_global_create(display, struct wl_global *global = wl_global_create(display,
&zwlr_layer_shell_v1_interface, LAYER_SHELL_VERSION, &zwlr_layer_shell_v1_interface, version, layer_shell, layer_shell_bind);
layer_shell, layer_shell_bind);
if (!global) { if (!global) {
free(layer_shell); free(layer_shell);
return NULL; return NULL;