improve session lock support stability
This commit is contained in:
parent
5b29514b09
commit
4a7219f03c
73
session.c
73
session.c
@ -8,28 +8,31 @@
|
||||
static struct wl_listener g_lock_new;
|
||||
static struct wl_listener g_lock_manager_destroy;
|
||||
static struct wlr_session_lock_manager_v1 *g_session_lock_manager;
|
||||
static struct diyac_server * g_server;
|
||||
static struct diyac_server *g_server;
|
||||
|
||||
static void focus_output(struct diyac_output * output)
|
||||
static void focus_output(struct diyac_output *output)
|
||||
{
|
||||
g_server->lock->focused = NULL;
|
||||
if(output)
|
||||
if (output)
|
||||
{
|
||||
g_server->lock->focused = output->lock_handle->surface->surface;
|
||||
}
|
||||
diyac_seat_focus_lock_surface(&g_server->seat, g_server->lock->focused);
|
||||
}
|
||||
|
||||
static void session_lock_update_geometry(struct diyac_output* output, bool align)
|
||||
static void session_lock_update_geometry(struct diyac_output *output, bool align)
|
||||
{
|
||||
struct wlr_box box;
|
||||
if(align)
|
||||
{
|
||||
wlr_output_layout_get_box(g_server->output_layout, output->wlr_output, &box);
|
||||
if (align)
|
||||
{
|
||||
wlr_scene_node_set_position(&output->scenes.session->node, box.x, box.y);
|
||||
wlr_log(WLR_INFO, "session_lock_update_geometry: Align lock screen on %d, %d", box.x, box.y);
|
||||
}
|
||||
wlr_scene_rect_set_size(output->lock_handle->background, box.width, box.height);
|
||||
if (output->lock_handle->surface) {
|
||||
if (output->lock_handle->surface)
|
||||
{
|
||||
wlr_log(WLR_INFO, "session_lock_update_geometry: configure lock screen %d, %d", box.width, box.height);
|
||||
wlr_session_lock_surface_v1_configure(output->lock_handle->surface, box.width, box.height);
|
||||
}
|
||||
}
|
||||
@ -41,25 +44,26 @@ static void handle_surface_map(struct wl_listener *listener, void *data)
|
||||
{
|
||||
focus_output(handle->output);
|
||||
}
|
||||
wlr_log(WLR_INFO, "handle_surface_map: surface is mapped");
|
||||
}
|
||||
|
||||
static void handle_surface_destroy(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct diyac_output_lock_handle *handle = wl_container_of(listener, handle, surface_destroy);
|
||||
|
||||
if(g_server->lock->focused == handle->surface->surface)
|
||||
if (g_server->lock->focused == handle->surface->surface)
|
||||
{
|
||||
struct diyac_output *output;
|
||||
wl_list_for_each(output, &g_server->outputs, link)
|
||||
{
|
||||
if(output == handle->output ||
|
||||
if (output == handle->output ||
|
||||
!output->lock_handle ||
|
||||
!output->lock_handle->surface ||
|
||||
!output->lock_handle->surface->surface)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(output->lock_handle->surface->surface->mapped)
|
||||
if (output->lock_handle->surface->surface->mapped)
|
||||
{
|
||||
// focus surface
|
||||
focus_output(output);
|
||||
@ -68,7 +72,7 @@ static void handle_surface_destroy(struct wl_listener *listener, void *data)
|
||||
}
|
||||
focus_output(NULL);
|
||||
}
|
||||
|
||||
wlr_log(WLR_INFO, "handle_surface_destroy: Lock surface destroyed");
|
||||
assert(handle->surface);
|
||||
handle->surface = NULL;
|
||||
wl_list_remove(&handle->surface_destroy.link);
|
||||
@ -80,7 +84,7 @@ static void handle_new_surface(struct wl_listener *listener, void *data)
|
||||
struct diyac_session_lock *lock = wl_container_of(listener, lock, new_surface);
|
||||
struct wlr_session_lock_surface_v1 *lock_surface = data;
|
||||
struct diyac_output *output = lock_surface->output->data;
|
||||
|
||||
wlr_log(WLR_INFO, "handle_new_surface: New lock surface requested");
|
||||
assert(output->lock_handle);
|
||||
|
||||
output->lock_handle->surface = lock_surface;
|
||||
@ -113,12 +117,14 @@ static void session_lock_destroy(struct diyac_session_lock *lock)
|
||||
wl_list_remove(&lock->unlock.link);
|
||||
wl_list_remove(&lock->new_surface.link);
|
||||
}
|
||||
wlr_log(WLR_INFO, "session_lock_destroy");
|
||||
free(lock);
|
||||
}
|
||||
|
||||
static void handle_unlock(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct diyac_session_lock *lock = wl_container_of(listener, lock, unlock);
|
||||
wlr_log(WLR_INFO, "handle_unlock: Lock session is unlocked");
|
||||
session_lock_destroy(lock);
|
||||
diyac_focus_topmost_view(g_server, true);
|
||||
}
|
||||
@ -127,6 +133,7 @@ static void handle_session_lock_destroy(struct wl_listener *listener, void *data
|
||||
{
|
||||
struct diyac_session_lock *lock = wl_container_of(listener, lock, destroy);
|
||||
lock->abandoned = true;
|
||||
wlr_log(WLR_INFO, "handle_session_lock_destroy: Lock session is destroyed without unlocking, session abandoned");
|
||||
wl_list_remove(&lock->destroy.link);
|
||||
wl_list_remove(&lock->unlock.link);
|
||||
wl_list_remove(&lock->new_surface.link);
|
||||
@ -135,21 +142,22 @@ static void handle_session_lock_destroy(struct wl_listener *listener, void *data
|
||||
static void handle_new_session_lock(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_session_lock_v1 *lock = data;
|
||||
if(g_server->lock)
|
||||
if (g_server->lock)
|
||||
{
|
||||
if(g_server->lock->abandoned)
|
||||
if (g_server->lock->abandoned)
|
||||
{
|
||||
session_lock_destroy(g_server->lock);
|
||||
}
|
||||
else
|
||||
{
|
||||
wlr_log(WLR_ERROR, "session already locked");
|
||||
wlr_log(WLR_ERROR, "handle_new_session_lock: session already locked");
|
||||
return;
|
||||
}
|
||||
}
|
||||
struct diyac_session_lock *session = malloc(sizeof(struct diyac_session_lock));
|
||||
if (!session) {
|
||||
wlr_log(WLR_ERROR, "session-lock: out of memory");
|
||||
if (!session)
|
||||
{
|
||||
wlr_log(WLR_ERROR, "handle_new_session_lock: out of memory");
|
||||
wlr_session_lock_v1_destroy(lock);
|
||||
return;
|
||||
}
|
||||
@ -173,8 +181,8 @@ static void handle_new_session_lock(struct wl_listener *listener, void *data)
|
||||
session->destroy.notify = handle_session_lock_destroy;
|
||||
wl_signal_add(&lock->events.destroy, &session->destroy);
|
||||
|
||||
//session->new_output.notify = handle_new_output;
|
||||
//wl_signal_add(&server.backend->events.new_output, &session->new_output);
|
||||
// session->new_output.notify = handle_new_output;
|
||||
// wl_signal_add(&server.backend->events.new_output, &session->new_output);
|
||||
|
||||
wlr_session_lock_v1_send_locked(lock);
|
||||
}
|
||||
@ -183,15 +191,13 @@ static void handle_commit(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_output_event_commit *event = data;
|
||||
struct diyac_output_lock_handle *handle = wl_container_of(listener, handle, commit);
|
||||
uint32_t require_reconfigure = WLR_OUTPUT_STATE_MODE
|
||||
| WLR_OUTPUT_STATE_SCALE | WLR_OUTPUT_STATE_TRANSFORM;
|
||||
uint32_t require_reconfigure = WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_SCALE | WLR_OUTPUT_STATE_TRANSFORM;
|
||||
if (event->state->committed & require_reconfigure)
|
||||
{
|
||||
session_lock_update_geometry(handle->output, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void handle_lock_manager_destroy(struct wl_listener *listener, void *data)
|
||||
{
|
||||
if (g_server->lock)
|
||||
@ -203,7 +209,7 @@ static void handle_lock_manager_destroy(struct wl_listener *listener, void *data
|
||||
wl_list_remove(&g_lock_manager_destroy.link);
|
||||
g_session_lock_manager = NULL;
|
||||
}
|
||||
void diyac_init_session_lock(struct diyac_server * server)
|
||||
void diyac_init_session_lock(struct diyac_server *server)
|
||||
{
|
||||
g_session_lock_manager = wlr_session_lock_manager_v1_create(server->wl_display);
|
||||
|
||||
@ -216,28 +222,28 @@ void diyac_init_session_lock(struct diyac_server * server)
|
||||
g_server = server;
|
||||
}
|
||||
|
||||
void diyac_session_lock_output(struct diyac_output * output)
|
||||
void diyac_session_lock_output(struct diyac_output *output)
|
||||
{
|
||||
if(output->lock_handle)
|
||||
if (output->lock_handle)
|
||||
{
|
||||
diyac_session_unlock_output(output);
|
||||
}
|
||||
struct diyac_output_lock_handle * handle = malloc(sizeof(struct diyac_output_lock_handle));
|
||||
if(!handle)
|
||||
struct diyac_output_lock_handle *handle = malloc(sizeof(struct diyac_output_lock_handle));
|
||||
if (!handle)
|
||||
{
|
||||
wlr_log(WLR_ERROR, "diyac_session_lock_output: out of memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
handle->tree = wlr_scene_tree_create(output->scenes.session);
|
||||
if(!handle->tree)
|
||||
if (!handle->tree)
|
||||
{
|
||||
free(handle);
|
||||
wlr_log(WLR_ERROR, "diyac_session_lock_output:Unable to create lock tree");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
float *black = (float[4]) { 0.f, 0.f, 0.f, 1.f };
|
||||
float *black = (float[4]){0.f, 0.f, 0.f, 1.f};
|
||||
handle->background = wlr_scene_rect_create(handle->tree, 0, 0, black);
|
||||
if(!handle->background)
|
||||
if (!handle->background)
|
||||
{
|
||||
free(handle);
|
||||
wlr_log(WLR_ERROR, "diyac_session_lock_output:Unable to create lock background");
|
||||
@ -253,15 +259,14 @@ void diyac_session_lock_output(struct diyac_output * output)
|
||||
output->lock_handle = handle;
|
||||
|
||||
session_lock_update_geometry(output, true);
|
||||
|
||||
}
|
||||
|
||||
void diyac_session_unlock_output(struct diyac_output * output)
|
||||
void diyac_session_unlock_output(struct diyac_output *output)
|
||||
{
|
||||
if(output->lock_handle)
|
||||
if (output->lock_handle)
|
||||
{
|
||||
wlr_scene_node_destroy(&output->lock_handle->tree->node);
|
||||
if(output->lock_handle->surface)
|
||||
if (output->lock_handle->surface)
|
||||
{
|
||||
wl_list_remove(&output->lock_handle->surface_destroy.link);
|
||||
wl_list_remove(&output->lock_handle->surface_map.link);
|
||||
|
4
view.c
4
view.c
@ -424,6 +424,10 @@ void diyac_view_sync_geo(struct diyac_view *view)
|
||||
{
|
||||
struct wlr_box size;
|
||||
int current_x, current_y, next_x, next_y;
|
||||
if(!view->mapped)
|
||||
{
|
||||
return;
|
||||
}
|
||||
wlr_scene_node_coords(&view->scene_tree->node, ¤t_x, ¤t_y);
|
||||
wlr_xdg_surface_get_geometry(view->xdg_surface, &size);
|
||||
|
||||
|
3
xdg.c
3
xdg.c
@ -208,7 +208,10 @@ static void xdg_toplevel_destroy(struct wl_listener *listener, void *data)
|
||||
wl_event_source_remove(toplevel->configuration_timeout);
|
||||
toplevel->configuration_timeout = NULL;
|
||||
}
|
||||
if(toplevel->mapped)
|
||||
{
|
||||
wl_list_remove(&toplevel->commit.link);
|
||||
}
|
||||
wl_list_remove(&toplevel->map.link);
|
||||
wl_list_remove(&toplevel->unmap.link);
|
||||
wl_list_remove(&toplevel->destroy.link);
|
||||
|
Loading…
Reference in New Issue
Block a user