]> git.mdlowis.com Git - proto/labwc.git/commitdiff
magnifier: disable direct scanout when active
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Tue, 16 Jul 2024 18:39:48 +0000 (20:39 +0200)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Wed, 17 Jul 2024 20:44:48 +0000 (22:44 +0200)
Fixes: #1980
include/labwc.h
src/magnifier.c
src/server.c

index ef7ec75d2dc5cdabb56960132ab541e393815f50..0aa4526faa391e817decc5ebf5b2867c6a360dd9 100644 (file)
@@ -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;
index 29b16154ef2b317d535f8229a129db70a000da4f..243455aa49cd7e24c4556a557f82eb223e945cb3 100644 (file)
@@ -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);
                }
        }
 
index 4721e16054c8b55f184d8ce55424675f449d11ce..b8beee2caf2af4081023fe8ab265ccca695bcd23 100644 (file)
@@ -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