window: allow setting a buffer scale on a window
diff --git a/clients/window.c b/clients/window.c
index 4bbc614..60b78a5 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -152,7 +152,7 @@
* Prepare the surface for drawing. Makes sure there is a surface
* of the right size available for rendering, and returns it.
* dx,dy are the x,y of wl_surface.attach.
- * width,height are the new surface size.
+ * width,height are the new buffer size.
* If flags has SURFACE_HINT_RESIZE set, the user is
* doing continuous resizing.
* Returns the Cairo surface to draw to.
@@ -208,6 +208,7 @@
enum window_buffer_type buffer_type;
enum wl_output_transform buffer_transform;
+ uint32_t buffer_scale;
cairo_surface_t *cairo_surface;
@@ -1339,6 +1340,9 @@
break;
}
+ allocation.width *= surface->buffer_scale;
+ allocation.height *= surface->buffer_scale;
+
if (!surface->toysurface && display->dpy &&
surface->buffer_type == WINDOW_BUFFER_TYPE_EGL_WINDOW) {
surface->toysurface =
@@ -1397,6 +1401,21 @@
transform);
}
+void
+window_set_buffer_scale(struct window *window,
+ uint32_t scale)
+{
+ window->main_surface->buffer_scale = scale;
+ wl_surface_set_buffer_scale(window->main_surface->surface,
+ scale);
+}
+
+uint32_t
+window_get_buffer_scale(struct window *window)
+{
+ return window->main_surface->buffer_scale;
+}
+
static void frame_destroy(struct frame *frame);
static void
@@ -1635,7 +1654,8 @@
surface_width = surface->allocation.width;
surface_height = surface->allocation.height;
- transform = window_get_buffer_transform(widget->window);
+ transform = surface->buffer_transform;
+
switch (transform) {
case WL_OUTPUT_TRANSFORM_FLIPPED:
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
@@ -4071,6 +4091,7 @@
surface->window = window;
surface->surface = wl_compositor_create_surface(display->compositor);
+ surface->buffer_scale = 1;
wl_surface_add_listener(surface->surface, &surface_listener, window);
wl_list_insert(&window->subsurface_list, &surface->link);