summaryrefslogtreecommitdiff
path: root/sway/input
diff options
context:
space:
mode:
authorErik Reider <[email protected]>2023-02-14 16:51:29 +0100
committerGitHub <[email protected]>2023-02-14 10:51:29 -0500
commite78fc3364b0440ff82becbec4ae57458374a145f (patch)
tree0eb825dcc36401438543dbb6fd32ec700b4b90b7 /sway/input
parent3efd3b558fe49bc7a7f3c30c19783e3fe5efeb24 (diff)
upstream update: merge sway 1.8.1 (#111)
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/cursor.c22
-rw-r--r--sway/input/seat.c23
-rw-r--r--sway/input/tablet.c12
3 files changed, 43 insertions, 14 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 449aa430..a5f1204b 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -97,6 +97,24 @@ struct sway_node *node_at_coords(
double ox = lx, oy = ly;
wlr_output_layout_output_coords(root->output_layout, wlr_output, &ox, &oy);
+ if (server.session_lock.locked) {
+ if (server.session_lock.lock == NULL) {
+ return NULL;
+ }
+ struct wlr_session_lock_surface_v1 *lock_surf;
+ wl_list_for_each(lock_surf, &server.session_lock.lock->surfaces, link) {
+ if (lock_surf->output != wlr_output) {
+ continue;
+ }
+
+ *surface = wlr_surface_surface_at(lock_surf->surface, ox, oy, sx, sy);
+ if (*surface != NULL) {
+ return NULL;
+ }
+ }
+ return NULL;
+ }
+
// layer surfaces on the overlay layer are rendered on top
if ((*surface = layer_surface_at(output,
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY],
@@ -1322,6 +1340,10 @@ static void warp_to_constraint_cursor_hint(struct sway_cursor *cursor) {
double sy = constraint->current.cursor_hint.y;
struct sway_view *view = view_from_wlr_surface(constraint->surface);
+ if (!view) {
+ return;
+ }
+
struct sway_container *con = view->container;
double lx = sx + con->pending.content_x - view->geometry.x;
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 646f3866..28210bb5 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -176,11 +176,11 @@ static void seat_keyboard_notify_enter(struct sway_seat *seat,
state->pressed_keycodes, state->npressed, &keyboard->modifiers);
}
-static void seat_tablet_pads_notify_enter(struct sway_seat *seat,
+static void seat_tablet_pads_set_focus(struct sway_seat *seat,
struct wlr_surface *surface) {
struct sway_seat_device *seat_device;
wl_list_for_each(seat_device, &seat->devices, link) {
- sway_tablet_pad_notify_enter(seat_device->tablet_pad, surface);
+ sway_tablet_pad_set_focus(seat_device->tablet_pad, surface);
}
}
@@ -204,7 +204,7 @@ static void seat_send_focus(struct sway_node *node, struct sway_seat *seat) {
#endif
seat_keyboard_notify_enter(seat, view->surface);
- seat_tablet_pads_notify_enter(seat, view->surface);
+ seat_tablet_pads_set_focus(seat, view->surface);
sway_input_method_relay_set_focus(&seat->im_relay, view->surface);
struct wlr_pointer_constraint_v1 *constraint =
@@ -1080,9 +1080,20 @@ void seat_configure_xcursor(struct sway_seat *seat) {
bool seat_is_input_allowed(struct sway_seat *seat,
struct wlr_surface *surface) {
+ if (server.session_lock.locked) {
+ if (server.session_lock.lock == NULL) {
+ return false;
+ }
+ struct wlr_session_lock_surface_v1 *lock_surf;
+ wl_list_for_each(lock_surf, &server.session_lock.lock->surfaces, link) {
+ if (lock_surf->surface == surface) {
+ return true;
+ }
+ }
+ return false;
+ }
struct wl_client *client = wl_resource_get_client(surface->resource);
- return seat->exclusive_client == client ||
- (seat->exclusive_client == NULL && !server.session_lock.locked);
+ return seat->exclusive_client == client || seat->exclusive_client == NULL;
}
static void send_unfocus(struct sway_container *con, void *data) {
@@ -1313,7 +1324,7 @@ void seat_set_focus_surface(struct sway_seat *seat,
}
sway_input_method_relay_set_focus(&seat->im_relay, surface);
- seat_tablet_pads_notify_enter(seat, surface);
+ seat_tablet_pads_set_focus(seat, surface);
}
void seat_set_focus_layer(struct sway_seat *seat,
diff --git a/sway/input/tablet.c b/sway/input/tablet.c
index 92ede3fa..884eba74 100644
--- a/sway/input/tablet.c
+++ b/sway/input/tablet.c
@@ -334,14 +334,10 @@ static void handle_pad_tablet_surface_destroy(struct wl_listener *listener,
struct sway_tablet_pad *tablet_pad =
wl_container_of(listener, tablet_pad, surface_destroy);
- wlr_tablet_v2_tablet_pad_notify_leave(tablet_pad->tablet_v2_pad,
- tablet_pad->current_surface);
- wl_list_remove(&tablet_pad->surface_destroy.link);
- wl_list_init(&tablet_pad->surface_destroy.link);
- tablet_pad->current_surface = NULL;
+ sway_tablet_pad_set_focus(tablet_pad, NULL);
}
-void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad,
+void sway_tablet_pad_set_focus(struct sway_tablet_pad *tablet_pad,
struct wlr_surface *surface) {
if (!tablet_pad || !tablet_pad->tablet) {
return;
@@ -360,7 +356,8 @@ void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad,
tablet_pad->current_surface = NULL;
}
- if (!wlr_surface_accepts_tablet_v2(tablet_pad->tablet->tablet_v2, surface)) {
+ if (surface == NULL ||
+ !wlr_surface_accepts_tablet_v2(tablet_pad->tablet->tablet_v2, surface)) {
return;
}
@@ -368,7 +365,6 @@ void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad,
tablet_pad->tablet->tablet_v2, surface);
tablet_pad->current_surface = surface;
- wl_list_remove(&tablet_pad->surface_destroy.link);
tablet_pad->surface_destroy.notify = handle_pad_tablet_surface_destroy;
wl_signal_add(&surface->events.destroy, &tablet_pad->surface_destroy);
}