From 7c67bea942d44b93cf03c3223067d2668905a3c0 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 9 Dec 2017 11:51:28 -0500 Subject: sway xcursor manager --- sway/input/seat.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'sway') diff --git a/sway/input/seat.c b/sway/input/seat.c index 1a2b728c..1fd65980 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -1,8 +1,10 @@ #define _XOPEN_SOURCE 700 #include +#include #include "sway/input/seat.h" #include "sway/input/cursor.h" #include "sway/input/input-manager.h" +#include "sway/output.h" #include "log.h" struct sway_seat *sway_seat_create(struct wl_display *display, @@ -29,6 +31,8 @@ struct sway_seat *sway_seat_create(struct wl_display *display, WL_SEAT_CAPABILITY_POINTER | WL_SEAT_CAPABILITY_TOUCH); + sway_seat_configure_xcursor(seat); + return seat; } @@ -74,3 +78,37 @@ void sway_seat_remove_device(struct sway_seat *seat, break; } } + +void sway_seat_configure_xcursor(struct sway_seat *seat) { + // TODO configure theme and size + const char *cursor_theme = "default"; + + if (seat->cursor->xcursor_manager) { + wlr_xcursor_manager_destroy(seat->cursor->xcursor_manager); + } + + seat->cursor->xcursor_manager = + wlr_xcursor_manager_create(NULL, 24); + if (sway_assert(seat->cursor->xcursor_manager, + "Cannot create XCursor manager for theme %s", cursor_theme)) { + return; + } + + for (int i = 0; i < root_container.children->length; ++i) { + swayc_t *output_container = root_container.children->items[i]; + struct wlr_output *output = + output_container->sway_output->wlr_output; + bool result = + wlr_xcursor_manager_load(seat->cursor->xcursor_manager, + output->scale); + + sway_assert(result, + "Cannot load xcursor theme for output '%s' with scale %d", + output->name, output->scale); + } + + wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager, + "left_ptr", seat->cursor->cursor); + wlr_cursor_warp(seat->cursor->cursor, NULL, seat->cursor->cursor->x, + seat->cursor->cursor->y); +} -- cgit v1.2.3-54-g00ecf