]> git.mdlowis.com Git - proto/labwc.git/commitdiff
session-lock: fix flashing screen when the session is locked
authortokyo4j <hrak1529@gmail.com>
Wed, 29 May 2024 15:29:59 +0000 (00:29 +0900)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Fri, 31 May 2024 02:21:29 +0000 (11:21 +0900)
The protocol says screen should be filled with opaque color when the
session is locked, but it allows some delay to wait for the session-lock
client to offer surfaces.

With this commit, filling the sceen with opaque color is delayed by 100ms.

src/session-lock.c

index 11f0c58701c8adbb37f9a9eda0b9830359fa2337..d9968f089f45b9a5e185414df028bb3909823e8e 100644 (file)
@@ -10,6 +10,7 @@ struct session_lock_output {
        struct session_lock_manager *manager;
        struct output *output;
        struct wlr_session_lock_surface_v1 *surface;
+       struct wl_event_source *blank_timer;
 
        struct wl_list link; /* session_lock_manager.outputs */
 
@@ -124,6 +125,7 @@ session_lock_output_destroy(struct session_lock_output *output)
        wl_list_remove(&output->commit.link);
        wl_list_remove(&output->destroy.link);
        wl_list_remove(&output->link);
+       wl_event_source_remove(output->blank_timer);
        free(output);
 }
 
@@ -155,6 +157,14 @@ align_session_lock_tree(struct output *output)
        wlr_scene_node_set_position(&output->session_lock_tree->node, box.x, box.y);
 }
 
+static int
+handle_output_blank_timeout(void *data)
+{
+       struct session_lock_output *lock_output = data;
+       wlr_scene_node_set_enabled(&lock_output->background->node, true);
+       return 0;
+}
+
 void
 session_lock_output_create(struct session_lock_manager *manager, struct output *output)
 {
@@ -181,6 +191,15 @@ session_lock_output_create(struct session_lock_manager *manager, struct output *
                goto exit_session;
        }
 
+       /* Delay blanking output by 100ms to prevent flashing */
+       lock_output->blank_timer =
+               wl_event_loop_add_timer(manager->server->wl_event_loop,
+                       handle_output_blank_timeout, lock_output);
+       if (!manager->locked) {
+               wlr_scene_node_set_enabled(&background->node, false);
+               wl_event_source_timer_update(lock_output->blank_timer, 100);
+       }
+
        align_session_lock_tree(output);
 
        lock_output->output = output;