Skip to content

Commit

Permalink
Fix sway_session_lock_has_surface
Browse files Browse the repository at this point in the history
Before this commit, if the cursor is at screen center, and the lock is
swaylock, the cursor would be at swaylock's subsurface(the indicator).

Since it's not the lock surface, `handle_rebase` would refuse to
rebase the cursor to there. Thereby the cursor enter event won't be
sent to swaylock.

This commit fix the issue.
  • Loading branch information
ookami committed Nov 16, 2024
1 parent 0b264db commit 6cd51ff
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion sway/lock.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <assert.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_session_lock_v1.h>
#include <wlr/types/wlr_subcompositor.h>
#include "log.h"
#include "sway/input/cursor.h"
#include "sway/input/keyboard.h"
Expand Down Expand Up @@ -331,11 +332,26 @@ void sway_session_lock_add_output(struct sway_session_lock *lock,
}
}

static bool wlr_surface_has_subsurface(struct wlr_surface *surface, struct wlr_surface *sub) {
struct wlr_subsurface *subsurface = wlr_subsurface_try_from_wlr_surface(sub);
if (!subsurface) {
return false;
}
if (!subsurface->parent) {
return false;
}
if (subsurface->parent == surface) {
return true;
}
return wlr_surface_has_subsurface(subsurface->parent, surface);
}

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 && (lock_output->surface->surface == surface
|| wlr_surface_has_subsurface(lock_output->surface->surface, surface))) {
return true;
}
}
Expand Down

0 comments on commit 6cd51ff

Please sign in to comment.