diff options
author | Simon Ser <contact@emersion.fr> | 2022-09-05 15:51:16 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-04-14 17:07:26 +0200 |
commit | 42edd36785fac0a089d99f6b10d5ce5923c6b90f (patch) | |
tree | 571080bf7aa1c44142f2f06d9115001c79b0e8ca | |
parent | 0bb574239d3b164596677bf4cec371ff0671dc4f (diff) |
compositor: add wlr_surface_set_preferred_buffer_scale()
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/220
-rw-r--r-- | include/wlr/types/wlr_compositor.h | 11 | ||||
-rw-r--r-- | types/wlr_compositor.c | 19 |
2 files changed, 29 insertions, 1 deletions
diff --git a/include/wlr/types/wlr_compositor.h b/include/wlr/types/wlr_compositor.h index 70b219d8..f65fbf84 100644 --- a/include/wlr/types/wlr_compositor.h +++ b/include/wlr/types/wlr_compositor.h @@ -163,6 +163,8 @@ struct wlr_surface { } previous; bool opaque; + + int32_t preferred_buffer_scale; }; struct wlr_renderer; @@ -320,6 +322,15 @@ uint32_t wlr_surface_lock_pending(struct wlr_surface *surface); void wlr_surface_unlock_cached(struct wlr_surface *surface, uint32_t seq); /** + * Set the preferred buffer scale for the surface. + * + * This sends an event to the client indicating the preferred scale to use for + * buffers attached to this surface. + */ +void wlr_surface_set_preferred_buffer_scale(struct wlr_surface *surface, + int32_t scale); + +/** * Create the wl_compositor global, which can be used by clients to create * surfaces and regions. * diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c index 812dd220..e6d4c25f 100644 --- a/types/wlr_compositor.c +++ b/types/wlr_compositor.c @@ -15,7 +15,7 @@ #include "types/wlr_subcompositor.h" #include "util/time.h" -#define COMPOSITOR_VERSION 5 +#define COMPOSITOR_VERSION 6 #define CALLBACK_VERSION 1 static int min(int fst, int snd) { @@ -1089,6 +1089,23 @@ void wlr_surface_get_buffer_source_box(struct wlr_surface *surface, } } +void wlr_surface_set_preferred_buffer_scale(struct wlr_surface *surface, + int32_t scale) { + assert(scale > 0); + + if (wl_resource_get_version(surface->resource) < + WL_SURFACE_PREFERRED_BUFFER_SCALE_SINCE_VERSION) { + return; + } + + if (surface->preferred_buffer_scale == scale) { + return; + } + + wl_surface_send_preferred_buffer_scale(surface->resource, scale); + surface->preferred_buffer_scale = scale; +} + static const struct wl_compositor_interface compositor_impl; static struct wlr_compositor *compositor_from_resource( |