aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-03-30 19:08:39 -0400
committerLibravatar GitHub <noreply@github.com>2018-03-30 19:08:39 -0400
commit70d9dc0b9ee9639011604a35b38b8ea03983e952 (patch)
treee2596e9cfa113efa43f2a411176c31e6208a58b1 /sway/input/cursor.c
parentMerge pull request #1665 from emersion/damage-tracking-lite (diff)
parentMerge branch 'wlroots' into client-cursors (diff)
downloadsway-70d9dc0b9ee9639011604a35b38b8ea03983e952.tar.gz
sway-70d9dc0b9ee9639011604a35b38b8ea03983e952.tar.zst
sway-70d9dc0b9ee9639011604a35b38b8ea03983e952.zip
Merge pull request #1660 from emersion/client-cursors
Handle set_cursor requests from clients
Diffstat (limited to 'sway/input/cursor.c')
-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,
81 struct sway_container *cont = 81 struct sway_container *cont =
82 container_at_cursor(cursor, &surface, &sx, &sy); 82 container_at_cursor(cursor, &surface, &sx, &sy);
83 83
84 // reset cursor if switching between clients
85 struct wl_client *client = NULL;
86 if (surface != NULL) {
87 client = wl_resource_get_client(surface->resource);
88 }
89 if (client != cursor->image_client) {
90 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
91 "left_ptr", cursor->cursor);
92 cursor->image_client = client;
93 }
94
95 // send pointer enter/leave
84 if (cont != NULL && surface != NULL) { 96 if (cont != NULL && surface != NULL) {
85 wlr_seat_pointer_notify_enter(seat, surface, sx, sy); 97 wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
86 wlr_seat_pointer_notify_motion(seat, time, sx, sy); 98 wlr_seat_pointer_notify_motion(seat, time, sx, sy);
@@ -167,7 +179,24 @@ static void handle_request_set_cursor(struct wl_listener *listener,
167 struct sway_cursor *cursor = 179 struct sway_cursor *cursor =
168 wl_container_of(listener, cursor, request_set_cursor); 180 wl_container_of(listener, cursor, request_set_cursor);
169 struct wlr_seat_pointer_request_set_cursor_event *event = data; 181 struct wlr_seat_pointer_request_set_cursor_event *event = data;
170 wlr_log(L_DEBUG, "TODO: handle request set cursor event: %p", event); 182
183 struct wl_client *focused_client = NULL;
184 struct wlr_surface *focused_surface =
185 cursor->seat->wlr_seat->pointer_state.focused_surface;
186 if (focused_surface != NULL) {
187 focused_client = wl_resource_get_client(focused_surface->resource);
188 }
189
190 // TODO: check cursor mode
191 if (focused_client == NULL ||
192 event->seat_client->client != focused_client) {
193 wlr_log(L_DEBUG, "denying request to set cursor from unfocused client");
194 return;
195 }
196
197 wlr_cursor_set_surface(cursor->cursor, event->surface, event->hotspot_x,
198 event->hotspot_y);
199 cursor->image_client = focused_client;
171} 200}
172 201
173void sway_cursor_destroy(struct sway_cursor *cursor) { 202void sway_cursor_destroy(struct sway_cursor *cursor) {