diff options
author | emersion <contact@emersion.fr> | 2018-09-29 14:32:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-29 14:32:05 +0200 |
commit | a53171669a709886b0cd887bdefbe9a6ca84b39c (patch) | |
tree | 3699e9e71aa85b07068b425d1b28ba8b7672f8fb /sway/input | |
parent | Merge pull request #2729 from RyanDwyer/resize-return-false (diff) | |
parent | cursor: allow cursor_set_image to accept a NULL image to hide cursor (diff) | |
download | sway-a53171669a709886b0cd887bdefbe9a6ca84b39c.tar.gz sway-a53171669a709886b0cd887bdefbe9a6ca84b39c.tar.zst sway-a53171669a709886b0cd887bdefbe9a6ca84b39c.zip |
Merge pull request #2698 from ianyfan/hide-cursor
Only show cursor if pointer configured
Diffstat (limited to 'sway/input')
-rw-r--r-- | sway/input/cursor.c | 9 | ||||
-rw-r--r-- | sway/input/seat.c | 12 |
2 files changed, 15 insertions, 6 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index aa0e07f5..2d5d351f 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -1006,8 +1006,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) { | |||
1006 | if (seat_is_input_allowed(seat, surface)) { | 1006 | if (seat_is_input_allowed(seat, surface)) { |
1007 | wlr_seat_touch_notify_down(wlr_seat, surface, event->time_msec, | 1007 | wlr_seat_touch_notify_down(wlr_seat, surface, event->time_msec, |
1008 | event->touch_id, sx, sy); | 1008 | event->touch_id, sx, sy); |
1009 | cursor->image_client = NULL; | 1009 | cursor_set_image(cursor, NULL, NULL); |
1010 | wlr_cursor_set_image(cursor->cursor, NULL, 0, 0, 0, 0, 0, 0); | ||
1011 | } | 1010 | } |
1012 | } | 1011 | } |
1013 | 1012 | ||
@@ -1175,11 +1174,13 @@ static void handle_request_set_cursor(struct wl_listener *listener, | |||
1175 | 1174 | ||
1176 | void cursor_set_image(struct sway_cursor *cursor, const char *image, | 1175 | void cursor_set_image(struct sway_cursor *cursor, const char *image, |
1177 | struct wl_client *client) { | 1176 | struct wl_client *client) { |
1178 | if (!cursor->image || strcmp(cursor->image, image) != 0) { | 1177 | if (!image) { |
1178 | wlr_cursor_set_image(cursor->cursor, NULL, 0, 0, 0, 0, 0, 0); | ||
1179 | } else if (!cursor->image || strcmp(cursor->image, image) != 0) { | ||
1179 | wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, image, | 1180 | wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, image, |
1180 | cursor->cursor); | 1181 | cursor->cursor); |
1181 | cursor->image = image; | ||
1182 | } | 1182 | } |
1183 | cursor->image = image; | ||
1183 | cursor->image_client = client; | 1184 | cursor->image_client = client; |
1184 | } | 1185 | } |
1185 | 1186 | ||
diff --git a/sway/input/seat.c b/sway/input/seat.c index a9c564e7..4817eae7 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -368,11 +368,20 @@ static void seat_update_capabilities(struct sway_seat *seat) { | |||
368 | caps |= WL_SEAT_CAPABILITY_TOUCH; | 368 | caps |= WL_SEAT_CAPABILITY_TOUCH; |
369 | break; | 369 | break; |
370 | case WLR_INPUT_DEVICE_TABLET_TOOL: | 370 | case WLR_INPUT_DEVICE_TABLET_TOOL: |
371 | caps |= WL_SEAT_CAPABILITY_POINTER; | ||
372 | break; | ||
371 | case WLR_INPUT_DEVICE_TABLET_PAD: | 373 | case WLR_INPUT_DEVICE_TABLET_PAD: |
372 | break; | 374 | break; |
373 | } | 375 | } |
374 | } | 376 | } |
375 | wlr_seat_set_capabilities(seat->wlr_seat, caps); | 377 | wlr_seat_set_capabilities(seat->wlr_seat, caps); |
378 | |||
379 | // Hide cursor if seat doesn't have pointer capability | ||
380 | if ((caps & WL_SEAT_CAPABILITY_POINTER) == 0) { | ||
381 | cursor_set_image(seat->cursor, NULL, NULL); | ||
382 | } else { | ||
383 | cursor_set_image(seat->cursor, "left_ptr", NULL); | ||
384 | } | ||
376 | } | 385 | } |
377 | 386 | ||
378 | static void seat_apply_input_config(struct sway_seat *seat, | 387 | static void seat_apply_input_config(struct sway_seat *seat, |
@@ -552,8 +561,7 @@ void seat_configure_xcursor(struct sway_seat *seat) { | |||
552 | output->name, (double)output->scale); | 561 | output->name, (double)output->scale); |
553 | } | 562 | } |
554 | 563 | ||
555 | wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager, | 564 | cursor_set_image(seat->cursor, "left_ptr", NULL); |
556 | "left_ptr", seat->cursor->cursor); | ||
557 | wlr_cursor_warp(seat->cursor->cursor, NULL, seat->cursor->cursor->x, | 565 | wlr_cursor_warp(seat->cursor->cursor, NULL, seat->cursor->cursor->x, |
558 | seat->cursor->cursor->y); | 566 | seat->cursor->cursor->y); |
559 | } | 567 | } |