This commit is contained in:
Okami 2025-03-29 00:23:37 +01:00 committed by GitHub
commit a71d3929d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -59,7 +59,8 @@ static void refocus_output(struct sway_session_lock_output *output) {
}
}
static void handle_surface_map(struct wl_listener *listener, void *data) {
static void update_focus(void *data) {
struct wl_listener *listener = data;
struct sway_session_lock_output *surf = wl_container_of(listener, surf, surface_map);
if (surf->lock->focused == NULL) {
focus_surface(surf->lock, surf->surface->surface);
@ -67,6 +68,10 @@ static void handle_surface_map(struct wl_listener *listener, void *data) {
cursor_rebase_all();
}
static void handle_surface_map(struct wl_listener *listener, void *data) {
wl_event_loop_add_idle(server.wl_event_loop, update_focus, listener);
}
static void handle_surface_destroy(struct wl_listener *listener, void *data) {
struct sway_session_lock_output *output =
wl_container_of(listener, output, surface_destroy);
@ -234,6 +239,7 @@ static void handle_unlock(struct wl_listener *listener, void *data) {
struct sway_output *output = root->outputs->items[i];
arrange_layers(output);
}
cursor_rebase_all();
}
static void handle_abandon(struct wl_listener *listener, void *data) {
@ -325,11 +331,31 @@ void sway_session_lock_add_output(struct sway_session_lock *lock,
}
}
struct is_lock_surface_data {
struct wlr_surface *surface;
bool is_lock_surface;
};
static void is_lock_surface(struct wlr_surface *surface, int sx, int sy, void *data) {
struct is_lock_surface_data *is_lock_surface_data = data;
if (is_lock_surface_data->surface == surface) {
is_lock_surface_data->is_lock_surface = true;
}
}
bool sway_session_lock_has_surface(struct sway_session_lock *lock,
struct wlr_surface *surface) {
struct sway_session_lock_output *lock_output;
wl_list_for_each(lock_output, &lock->outputs, link) {
if (lock_output->surface && lock_output->surface->surface == surface) {
if (!lock_output->surface) {
continue;
}
struct is_lock_surface_data data = {
.surface = surface,
.is_lock_surface = false,
};
wlr_surface_for_each_surface(lock_output->surface->surface, is_lock_surface, &data);
if (data.is_lock_surface) {
return true;
}
}