diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-12-09 11:51:28 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-12-09 11:51:28 -0500 |
commit | 7c67bea942d44b93cf03c3223067d2668905a3c0 (patch) | |
tree | b38e866cd7ec921eec8833915852cf3700101c7b /sway | |
parent | d76e745b738281fb98834fd5dee78f2a21727d80 (diff) |
sway xcursor manager
Diffstat (limited to 'sway')
-rw-r--r-- | sway/input/seat.c | 38 |
1 files changed, 38 insertions, 0 deletions
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 <wlr/types/wlr_cursor.h> +#include <wlr/types/wlr_xcursor_manager.h> #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); +} |