mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-25 16:42:26 +00:00
session-lock-v1: use wlr_surface_synced
This commit is contained in:
parent
aa32d1a127
commit
0ea6b6e2cc
@ -12,6 +12,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
|
||||
struct wlr_session_lock_manager_v1 {
|
||||
struct wl_global *global;
|
||||
@ -80,6 +81,8 @@ struct wlr_session_lock_surface_v1 {
|
||||
|
||||
// private state
|
||||
|
||||
struct wlr_surface_synced synced;
|
||||
|
||||
struct wl_listener output_destroy;
|
||||
};
|
||||
|
||||
|
@ -38,7 +38,7 @@ static void lock_surface_destroy(struct wlr_session_lock_surface_v1 *lock_surfac
|
||||
assert(wl_list_empty(&lock_surface->events.destroy.listener_list));
|
||||
|
||||
wl_list_remove(&lock_surface->output_destroy.link);
|
||||
|
||||
wlr_surface_synced_finish(&lock_surface->synced);
|
||||
wl_resource_set_user_data(lock_surface->resource, NULL);
|
||||
free(lock_surface);
|
||||
}
|
||||
@ -149,14 +149,14 @@ static const struct ext_session_lock_surface_v1_interface lock_surface_implement
|
||||
.ack_configure = lock_surface_handle_ack_configure,
|
||||
};
|
||||
|
||||
static void lock_surface_role_commit(struct wlr_surface *surface) {
|
||||
static void lock_surface_role_client_commit(struct wlr_surface *surface) {
|
||||
struct wlr_session_lock_surface_v1 *lock_surface =
|
||||
wlr_session_lock_surface_v1_try_from_wlr_surface(surface);
|
||||
if (lock_surface == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wlr_surface_has_buffer(surface)) {
|
||||
if (!wlr_surface_state_has_buffer(&surface->pending)) {
|
||||
wl_resource_post_error(lock_surface->resource,
|
||||
EXT_SESSION_LOCK_SURFACE_V1_ERROR_NULL_BUFFER,
|
||||
"session lock surface is committed with a null buffer");
|
||||
@ -170,15 +170,21 @@ static void lock_surface_role_commit(struct wlr_surface *surface) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((uint32_t)surface->current.width != lock_surface->pending.width ||
|
||||
(uint32_t)surface->current.height != lock_surface->pending.height) {
|
||||
if ((uint32_t)surface->pending.width != lock_surface->pending.width ||
|
||||
(uint32_t)surface->pending.height != lock_surface->pending.height) {
|
||||
wl_resource_post_error(lock_surface->resource,
|
||||
EXT_SESSION_LOCK_SURFACE_V1_ERROR_DIMENSIONS_MISMATCH,
|
||||
"committed surface dimensions do not match last acked configure");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
lock_surface->current = lock_surface->pending;
|
||||
static void lock_surface_role_commit(struct wlr_surface *surface) {
|
||||
struct wlr_session_lock_surface_v1 *lock_surface =
|
||||
wlr_session_lock_surface_v1_try_from_wlr_surface(surface);
|
||||
if (lock_surface == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
wlr_surface_map(surface);
|
||||
}
|
||||
@ -194,10 +200,15 @@ static void lock_surface_role_destroy(struct wlr_surface *surface) {
|
||||
|
||||
static const struct wlr_surface_role lock_surface_role = {
|
||||
.name = "ext_session_lock_surface_v1",
|
||||
.client_commit = lock_surface_role_client_commit,
|
||||
.commit = lock_surface_role_commit,
|
||||
.destroy = lock_surface_role_destroy,
|
||||
};
|
||||
|
||||
static const struct wlr_surface_synced_impl surface_synced_impl = {
|
||||
.state_size = sizeof(struct wlr_session_lock_surface_v1_state),
|
||||
};
|
||||
|
||||
static void lock_surface_handle_output_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct wlr_session_lock_surface_v1 *lock_surface =
|
||||
@ -268,6 +279,13 @@ static void lock_handle_get_lock_surface(struct wl_client *client,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wlr_surface_synced_init(&lock_surface->synced, surface,
|
||||
&surface_synced_impl, &lock_surface->pending, &lock_surface->current)) {
|
||||
free(lock_surface);
|
||||
wl_client_post_no_memory(client);
|
||||
return;
|
||||
}
|
||||
|
||||
lock_surface->resource = lock_surface_resource;
|
||||
wl_resource_set_user_data(lock_surface_resource, lock_surface);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user