diff options
-rw-r--r-- | include/sway/input/cursor.h | 1 | ||||
-rw-r--r-- | include/sway/input/seat.h | 2 | ||||
-rw-r--r-- | sway/input/seat.c | 38 |
3 files changed, 41 insertions, 0 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 91421964..aa873f46 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h | |||
@@ -5,6 +5,7 @@ | |||
5 | 5 | ||
6 | struct sway_cursor { | 6 | struct sway_cursor { |
7 | struct wlr_cursor *cursor; | 7 | struct wlr_cursor *cursor; |
8 | struct wlr_xcursor_manager *xcursor_manager; | ||
8 | 9 | ||
9 | struct wl_listener motion; | 10 | struct wl_listener motion; |
10 | struct wl_listener motion_absolute; | 11 | struct wl_listener motion_absolute; |
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index a84b7efd..f7f8a1bb 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -18,4 +18,6 @@ void sway_seat_add_device(struct sway_seat *seat, | |||
18 | void sway_seat_remove_device(struct sway_seat *seat, | 18 | void sway_seat_remove_device(struct sway_seat *seat, |
19 | struct wlr_input_device *device); | 19 | struct wlr_input_device *device); |
20 | 20 | ||
21 | void sway_seat_configure_xcursor(struct sway_seat *seat); | ||
22 | |||
21 | #endif | 23 | #endif |
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 @@ | |||
1 | #define _XOPEN_SOURCE 700 | 1 | #define _XOPEN_SOURCE 700 |
2 | #include <wlr/types/wlr_cursor.h> | 2 | #include <wlr/types/wlr_cursor.h> |
3 | #include <wlr/types/wlr_xcursor_manager.h> | ||
3 | #include "sway/input/seat.h" | 4 | #include "sway/input/seat.h" |
4 | #include "sway/input/cursor.h" | 5 | #include "sway/input/cursor.h" |
5 | #include "sway/input/input-manager.h" | 6 | #include "sway/input/input-manager.h" |
7 | #include "sway/output.h" | ||
6 | #include "log.h" | 8 | #include "log.h" |
7 | 9 | ||
8 | struct sway_seat *sway_seat_create(struct wl_display *display, | 10 | struct sway_seat *sway_seat_create(struct wl_display *display, |
@@ -29,6 +31,8 @@ struct sway_seat *sway_seat_create(struct wl_display *display, | |||
29 | WL_SEAT_CAPABILITY_POINTER | | 31 | WL_SEAT_CAPABILITY_POINTER | |
30 | WL_SEAT_CAPABILITY_TOUCH); | 32 | WL_SEAT_CAPABILITY_TOUCH); |
31 | 33 | ||
34 | sway_seat_configure_xcursor(seat); | ||
35 | |||
32 | return seat; | 36 | return seat; |
33 | } | 37 | } |
34 | 38 | ||
@@ -74,3 +78,37 @@ void sway_seat_remove_device(struct sway_seat *seat, | |||
74 | break; | 78 | break; |
75 | } | 79 | } |
76 | } | 80 | } |
81 | |||
82 | void sway_seat_configure_xcursor(struct sway_seat *seat) { | ||
83 | // TODO configure theme and size | ||
84 | const char *cursor_theme = "default"; | ||
85 | |||
86 | if (seat->cursor->xcursor_manager) { | ||
87 | wlr_xcursor_manager_destroy(seat->cursor->xcursor_manager); | ||
88 | } | ||
89 | |||
90 | seat->cursor->xcursor_manager = | ||
91 | wlr_xcursor_manager_create(NULL, 24); | ||
92 | if (sway_assert(seat->cursor->xcursor_manager, | ||
93 | "Cannot create XCursor manager for theme %s", cursor_theme)) { | ||
94 | return; | ||
95 | } | ||
96 | |||
97 | for (int i = 0; i < root_container.children->length; ++i) { | ||
98 | swayc_t *output_container = root_container.children->items[i]; | ||
99 | struct wlr_output *output = | ||
100 | output_container->sway_output->wlr_output; | ||
101 | bool result = | ||
102 | wlr_xcursor_manager_load(seat->cursor->xcursor_manager, | ||
103 | output->scale); | ||
104 | |||
105 | sway_assert(result, | ||
106 | "Cannot load xcursor theme for output '%s' with scale %d", | ||
107 | output->name, output->scale); | ||
108 | } | ||
109 | |||
110 | wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager, | ||
111 | "left_ptr", seat->cursor->cursor); | ||
112 | wlr_cursor_warp(seat->cursor->cursor, NULL, seat->cursor->cursor->x, | ||
113 | seat->cursor->cursor->y); | ||
114 | } | ||