From 7a6c7d60d5dece586654d8855f34da25e92987fa Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 20 Feb 2023 10:15:07 +0100 Subject: [PATCH] Update surface fractional scale on output change Closes: https://github.com/swaywm/sway/issues/7464 --- include/sway/surface.h | 1 + sway/desktop/output.c | 7 +++++++ sway/desktop/surface.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/sway/surface.h b/include/sway/surface.h index 506818976..a7a8ec3ff 100644 --- a/include/sway/surface.h +++ b/include/sway/surface.h @@ -15,6 +15,7 @@ struct sway_surface { struct wl_event_source *frame_done_timer; }; +void surface_update_outputs(struct wlr_surface *surface); void surface_enter_output(struct wlr_surface *surface, struct sway_output *output); void surface_leave_output(struct wlr_surface *surface, diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 141edb491..302f9fdab 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -859,6 +859,12 @@ static void update_textures(struct sway_container *con, void *data) { container_update_marks_textures(con); } +static void update_output_scale_iterator(struct sway_output *output, + struct sway_view *view, struct wlr_surface *surface, + struct wlr_box *box, void *user_data) { + surface_update_outputs(surface); +} + static void handle_commit(struct wl_listener *listener, void *data) { struct sway_output *output = wl_container_of(listener, output, commit); struct wlr_output_event_commit *event = data; @@ -873,6 +879,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { if (event->committed & WLR_OUTPUT_STATE_SCALE) { output_for_each_container(output, update_textures, NULL); + output_for_each_surface(output, update_output_scale_iterator, NULL); } if (event->committed & (WLR_OUTPUT_STATE_TRANSFORM | WLR_OUTPUT_STATE_SCALE)) { diff --git a/sway/desktop/surface.c b/sway/desktop/surface.c index 949cfdc26..68772ee0f 100644 --- a/sway/desktop/surface.c +++ b/sway/desktop/surface.c @@ -47,7 +47,7 @@ void handle_compositor_new_surface(struct wl_listener *listener, void *data) { } } -static void surface_update_outputs(struct wlr_surface *surface) { +void surface_update_outputs(struct wlr_surface *surface) { float scale = 1; struct wlr_surface_output *surface_output; wl_list_for_each(surface_output, &surface->current_outputs, link) {