mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
session-lock: send more protocol errors
The invalid_destroy and invalid_unlock protocol errors aren't currently sent by wlroots and instead left up to the compositor. However, we can handle these as well without much additional complexity. This also adds a missing wl_resource_destroy() call if the lock is inert in lock_handle_unlock_and_destroy().
This commit is contained in:
parent
48a89179a3
commit
869af1cfbb
2 changed files with 38 additions and 2 deletions
|
@ -40,6 +40,10 @@ struct wlr_session_lock_v1 {
|
||||||
} events;
|
} events;
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
|
// private state
|
||||||
|
|
||||||
|
bool locked_sent;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_session_lock_surface_v1_state {
|
struct wlr_session_lock_surface_v1_state {
|
||||||
|
|
|
@ -126,7 +126,6 @@ static void lock_surface_handle_ack_configure(struct wl_client *client,
|
||||||
free(configure);
|
free(configure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const struct ext_session_lock_surface_v1_interface lock_surface_implementation = {
|
static const struct ext_session_lock_surface_v1_interface lock_surface_implementation = {
|
||||||
.destroy = resource_handle_destroy,
|
.destroy = resource_handle_destroy,
|
||||||
.ack_configure = lock_surface_handle_ack_configure,
|
.ack_configure = lock_surface_handle_ack_configure,
|
||||||
|
@ -306,6 +305,17 @@ static void lock_handle_unlock_and_destroy(struct wl_client *client,
|
||||||
struct wl_resource *lock_resource) {
|
struct wl_resource *lock_resource) {
|
||||||
struct wlr_session_lock_v1 *lock = lock_from_resource(lock_resource);
|
struct wlr_session_lock_v1 *lock = lock_from_resource(lock_resource);
|
||||||
if (lock == NULL) {
|
if (lock == NULL) {
|
||||||
|
// This can happen if the compositor sent the locked event and
|
||||||
|
// later the finished event as the lock is destroyed when the
|
||||||
|
// finished event is sent.
|
||||||
|
wl_resource_destroy(lock_resource);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lock->locked_sent) {
|
||||||
|
wl_resource_post_error(lock_resource,
|
||||||
|
EXT_SESSION_LOCK_V1_ERROR_INVALID_UNLOCK,
|
||||||
|
"the locked event was never sent");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,13 +324,35 @@ static void lock_handle_unlock_and_destroy(struct wl_client *client,
|
||||||
wl_resource_destroy(lock_resource);
|
wl_resource_destroy(lock_resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void lock_handle_destroy(struct wl_client *client,
|
||||||
|
struct wl_resource *lock_resource) {
|
||||||
|
struct wlr_session_lock_v1 *lock = lock_from_resource(lock_resource);
|
||||||
|
if (lock == NULL) {
|
||||||
|
// The compositor sent the finished event and destroyed the lock.
|
||||||
|
wl_resource_destroy(lock_resource);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lock->locked_sent) {
|
||||||
|
wl_resource_post_error(lock_resource,
|
||||||
|
EXT_SESSION_LOCK_V1_ERROR_INVALID_DESTROY,
|
||||||
|
"the session lock may not be destroyed while locked");
|
||||||
|
} else {
|
||||||
|
wl_resource_post_error(lock_resource,
|
||||||
|
EXT_SESSION_LOCK_V1_ERROR_INVALID_DESTROY,
|
||||||
|
"the finished event was never sent");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const struct ext_session_lock_v1_interface lock_implementation = {
|
static const struct ext_session_lock_v1_interface lock_implementation = {
|
||||||
.destroy = resource_handle_destroy,
|
.destroy = lock_handle_destroy,
|
||||||
.get_lock_surface = lock_handle_get_lock_surface,
|
.get_lock_surface = lock_handle_get_lock_surface,
|
||||||
.unlock_and_destroy = lock_handle_unlock_and_destroy,
|
.unlock_and_destroy = lock_handle_unlock_and_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
void wlr_session_lock_v1_send_locked(struct wlr_session_lock_v1 *lock) {
|
void wlr_session_lock_v1_send_locked(struct wlr_session_lock_v1 *lock) {
|
||||||
|
assert(!lock->locked_sent);
|
||||||
|
lock->locked_sent = true;
|
||||||
ext_session_lock_v1_send_locked(lock->resource);
|
ext_session_lock_v1_send_locked(lock->resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue