From: tokyo4j Date: Wed, 29 May 2024 15:29:59 +0000 (+0900) Subject: session-lock: fix flashing screen when the session is locked X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=9e5ea88c7005ab25d2e7b4cbd1fd80e265db9091;p=proto%2Flabwc.git session-lock: fix flashing screen when the session is locked 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. --- diff --git a/src/session-lock.c b/src/session-lock.c index 11f0c587..d9968f08 100644 --- a/src/session-lock.c +++ b/src/session-lock.c @@ -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;