From 88a67d586c83598aba684b18b21b7f6c7509739b Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Tue, 16 Jul 2024 20:39:48 +0200 Subject: [PATCH] magnifier: disable direct scanout when active Fixes: #1980 --- include/labwc.h | 1 + src/magnifier.c | 24 +++++++++++++----------- src/server.c | 1 + 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/labwc.h b/include/labwc.h index a19f8243..751de27f 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -255,6 +255,7 @@ struct server { struct seat seat; struct wlr_scene *scene; struct wlr_scene_output_layout *scene_layout; + bool direct_scanout_enabled; /* cursor interactive */ enum input_mode input_mode; diff --git a/src/magnifier.c b/src/magnifier.c index 29b16154..243455aa 100644 --- a/src/magnifier.c +++ b/src/magnifier.c @@ -112,7 +112,6 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box return; } - /* Paste the magnified result back into the output buffer */ if (!tmp_texture) { tmp_texture = wlr_texture_from_buffer(server->renderer, tmp_buffer); } @@ -124,7 +123,6 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box } /* Extract source region into temporary buffer */ - struct wlr_render_pass *tmp_render_pass = wlr_renderer_begin_buffer_pass( server->renderer, tmp_buffer, NULL); @@ -198,6 +196,7 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box dst_box.y = oy - (height / 2); } + /* Paste the magnified result back into the output buffer */ opts = (struct wlr_render_texture_options) { .texture = tmp_texture, .src_box = src_box, @@ -241,18 +240,21 @@ output_wants_magnification(struct output *output) return output_nearest_to_cursor(output->server) == output; } +static void +enable_magnifier(struct server *server, bool enable) +{ + magnify_on = enable; + server->scene->direct_scanout = enable ? false + : server->direct_scanout_enabled; +} + /* Toggles magnification on and off */ void magnify_toggle(struct server *server) { + enable_magnifier(server, !magnify_on); + struct output *output = output_nearest_to_cursor(server); - - if (magnify_on) { - magnify_on = false; - } else { - magnify_on = true; - } - if (output) { wlr_output_schedule_frame(output->wlr_output); } @@ -268,14 +270,14 @@ magnify_set_scale(struct server *server, enum magnify_dir dir) if (magnify_on) { mag_scale += rc.mag_increment; } else { - magnify_on = true; + enable_magnifier(server, true); mag_scale = 1.0 + rc.mag_increment; } } else { if (magnify_on && mag_scale > 1.0 + rc.mag_increment) { mag_scale -= rc.mag_increment; } else { - magnify_on = false; + enable_magnifier(server, false); } } diff --git a/src/server.c b/src/server.c index 0a093930..8b595376 100644 --- a/src/server.c +++ b/src/server.c @@ -414,6 +414,7 @@ server_init(struct server *server) wlr_log(WLR_ERROR, "unable to create scene"); exit(EXIT_FAILURE); } + server->direct_scanout_enabled = server->scene->direct_scanout; /* * The order in which the scene-trees below are created determines the