From 1225f81a6a832fb373b3a62a932e8e0ac9a4381f Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sat, 26 Nov 2022 21:48:53 +0100 Subject: [PATCH] scene: Add fractional scale handling --- include/wlr/types/wlr_scene.h | 1 + types/scene/surface.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h index b5d37697..2a2d08da 100644 --- a/include/wlr/types/wlr_scene.h +++ b/include/wlr/types/wlr_scene.h @@ -108,6 +108,7 @@ struct wlr_scene_surface { struct wlr_addon addon; + struct wl_listener outputs_update; struct wl_listener output_enter; struct wl_listener output_leave; struct wl_listener output_present; diff --git a/types/scene/surface.c b/types/scene/surface.c index a5f9ccfc..3881fed3 100644 --- a/types/scene/surface.c +++ b/types/scene/surface.c @@ -1,9 +1,22 @@ #include #include #include +#include #include #include "types/wlr_scene.h" +static void handle_scene_buffer_outputs_update( + struct wl_listener *listener, void *data) { + struct wlr_scene_surface *surface = + wl_container_of(listener, surface, outputs_update); + + if (surface->buffer->primary_output == NULL) { + return; + } + double scale = surface->buffer->primary_output->output->scale; + wlr_fractional_scale_v1_notify_scale(surface->surface, scale); +} + static void handle_scene_buffer_output_enter( struct wl_listener *listener, void *data) { struct wlr_scene_surface *surface = @@ -140,6 +153,7 @@ static void surface_addon_destroy(struct wlr_addon *addon) { wlr_addon_finish(&surface->addon); + wl_list_remove(&surface->outputs_update.link); wl_list_remove(&surface->output_enter.link); wl_list_remove(&surface->output_leave.link); wl_list_remove(&surface->output_present.link); @@ -184,6 +198,9 @@ struct wlr_scene_surface *wlr_scene_surface_create(struct wlr_scene_tree *parent surface->surface = wlr_surface; scene_buffer->point_accepts_input = scene_buffer_point_accepts_input; + surface->outputs_update.notify = handle_scene_buffer_outputs_update; + wl_signal_add(&scene_buffer->events.outputs_update, &surface->outputs_update); + surface->output_enter.notify = handle_scene_buffer_output_enter; wl_signal_add(&scene_buffer->events.output_enter, &surface->output_enter);