From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Tue, 16 Jul 2024 18:39:48 +0000 (+0200) Subject: magnifier: disable direct scanout when active X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=40684bad9d402a91bfce90b2f45f99d09f47d75b;p=proto%2Flabwc.git magnifier: disable direct scanout when active Fixes: #1980 --- diff --git a/include/labwc.h b/include/labwc.h index ef7ec75d..0aa4526f 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -251,6 +251,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) { - struct output *output = output_nearest_to_cursor(server); - - if (magnify_on) { - magnify_on = false; - } else { - magnify_on = true; - } + enable_magnifier(server, !magnify_on); + struct output *output = output_nearest_to_cursor(server); 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 4721e160..b8beee2c 100644 --- a/src/server.c +++ b/src/server.c @@ -360,6 +360,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