Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cursor events on screen lock/unlock #8374

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions sway/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,19 @@ 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);
}
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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}
Expand Down