diff options
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r-- | sway/input/cursor.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index f970e6a2..62c74d04 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <time.h> | 7 | #include <time.h> |
8 | #include <strings.h> | 8 | #include <strings.h> |
9 | #include <wlr/types/wlr_cursor.h> | 9 | #include <wlr/types/wlr_cursor.h> |
10 | #include <wlr/types/wlr_cursor_shape_v1.h> | ||
10 | #include <wlr/types/wlr_idle.h> | 11 | #include <wlr/types/wlr_idle.h> |
11 | #include <wlr/types/wlr_pointer.h> | 12 | #include <wlr/types/wlr_pointer.h> |
12 | #include <wlr/types/wlr_touch.h> | 13 | #include <wlr/types/wlr_touch.h> |
@@ -1467,3 +1468,26 @@ void sway_cursor_constrain(struct sway_cursor *cursor, | |||
1467 | wl_signal_add(&constraint->surface->events.commit, | 1468 | wl_signal_add(&constraint->surface->events.commit, |
1468 | &cursor->constraint_commit); | 1469 | &cursor->constraint_commit); |
1469 | } | 1470 | } |
1471 | |||
1472 | void handle_request_set_cursor_shape(struct wl_listener *listener, void *data) { | ||
1473 | const struct wlr_cursor_shape_manager_v1_request_set_shape_event *event = data; | ||
1474 | struct sway_seat *seat = event->seat_client->seat->data; | ||
1475 | |||
1476 | if (!seatop_allows_set_cursor(seat)) { | ||
1477 | return; | ||
1478 | } | ||
1479 | |||
1480 | struct wl_client *focused_client = NULL; | ||
1481 | struct wlr_surface *focused_surface = seat->wlr_seat->pointer_state.focused_surface; | ||
1482 | if (focused_surface != NULL) { | ||
1483 | focused_client = wl_resource_get_client(focused_surface->resource); | ||
1484 | } | ||
1485 | |||
1486 | // TODO: check cursor mode | ||
1487 | if (focused_client == NULL || event->seat_client->client != focused_client) { | ||
1488 | sway_log(SWAY_DEBUG, "denying request to set cursor from unfocused client"); | ||
1489 | return; | ||
1490 | } | ||
1491 | |||
1492 | cursor_set_image(seat->cursor, wlr_cursor_shape_v1_name(event->shape), focused_client); | ||
1493 | } | ||