aboutsummaryrefslogtreecommitdiff
path: root/sway/input
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-03-30 19:08:39 -0400
committerGitHub <noreply@github.com>2018-03-30 19:08:39 -0400
commit70d9dc0b9ee9639011604a35b38b8ea03983e952 (patch)
treee2596e9cfa113efa43f2a411176c31e6208a58b1 /sway/input
parent1b88eaee6b14987c585fcf149cc26f665c584d77 (diff)
parent96656427656118f2e4d725359cc880270b0e51be (diff)
Merge pull request #1660 from emersion/client-cursors
Handle set_cursor requests from clients
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/cursor.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 717d864b..d814e08e 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -81,6 +81,18 @@ static void cursor_send_pointer_motion(struct sway_cursor *cursor,
struct sway_container *cont =
container_at_cursor(cursor, &surface, &sx, &sy);
+ // reset cursor if switching between clients
+ struct wl_client *client = NULL;
+ if (surface != NULL) {
+ client = wl_resource_get_client(surface->resource);
+ }
+ if (client != cursor->image_client) {
+ wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
+ "left_ptr", cursor->cursor);
+ cursor->image_client = client;
+ }
+
+ // send pointer enter/leave
if (cont != NULL && surface != NULL) {
wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
wlr_seat_pointer_notify_motion(seat, time, sx, sy);
@@ -167,7 +179,24 @@ static void handle_request_set_cursor(struct wl_listener *listener,
struct sway_cursor *cursor =
wl_container_of(listener, cursor, request_set_cursor);
struct wlr_seat_pointer_request_set_cursor_event *event = data;
- wlr_log(L_DEBUG, "TODO: handle request set cursor event: %p", event);
+
+ struct wl_client *focused_client = NULL;
+ struct wlr_surface *focused_surface =
+ cursor->seat->wlr_seat->pointer_state.focused_surface;
+ if (focused_surface != NULL) {
+ focused_client = wl_resource_get_client(focused_surface->resource);
+ }
+
+ // TODO: check cursor mode
+ if (focused_client == NULL ||
+ event->seat_client->client != focused_client) {
+ wlr_log(L_DEBUG, "denying request to set cursor from unfocused client");
+ return;
+ }
+
+ wlr_cursor_set_surface(cursor->cursor, event->surface, event->hotspot_x,
+ event->hotspot_y);
+ cursor->image_client = focused_client;
}
void sway_cursor_destroy(struct sway_cursor *cursor) {