Skip to content

Commit 814e88e

Browse files
ookamiOkamiW
ookami
authored andcommitted
Fix sway_session_lock_has_surface
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.
1 parent 625127d commit 814e88e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

sway/lock.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <assert.h>
22
#include <wlr/types/wlr_scene.h>
33
#include <wlr/types/wlr_session_lock_v1.h>
4+
#include <wlr/types/wlr_subcompositor.h>
45
#include "log.h"
56
#include "sway/input/cursor.h"
67
#include "sway/input/keyboard.h"
@@ -331,11 +332,26 @@ void sway_session_lock_add_output(struct sway_session_lock *lock,
331332
}
332333
}
333334

335+
static bool wlr_surface_has_subsurface(struct wlr_surface *surface, struct wlr_surface *sub) {
336+
struct wlr_subsurface *subsurface = wlr_subsurface_try_from_wlr_surface(sub);
337+
if (!subsurface) {
338+
return false;
339+
}
340+
if (!subsurface->parent) {
341+
return false;
342+
}
343+
if (subsurface->parent == surface) {
344+
return true;
345+
}
346+
return wlr_surface_has_subsurface(subsurface->parent, surface);
347+
}
348+
334349
bool sway_session_lock_has_surface(struct sway_session_lock *lock,
335350
struct wlr_surface *surface) {
336351
struct sway_session_lock_output *lock_output;
337352
wl_list_for_each(lock_output, &lock->outputs, link) {
338-
if (lock_output->surface && lock_output->surface->surface == surface) {
353+
if (lock_output->surface && (lock_output->surface->surface == surface
354+
|| wlr_surface_has_subsurface(lock_output->surface->surface, surface))) {
339355
return true;
340356
}
341357
}

0 commit comments

Comments
 (0)