aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seat.c
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2017-12-09 11:51:28 -0500
committerLibravatar Tony Crisci <tony@dubstepdish.com>2017-12-09 11:51:28 -0500
commit7c67bea942d44b93cf03c3223067d2668905a3c0 (patch)
treeb38e866cd7ec921eec8833915852cf3700101c7b /sway/input/seat.c
parentinput include directory (diff)
downloadsway-7c67bea942d44b93cf03c3223067d2668905a3c0.tar.gz
sway-7c67bea942d44b93cf03c3223067d2668905a3c0.tar.zst
sway-7c67bea942d44b93cf03c3223067d2668905a3c0.zip
sway xcursor manager
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c38
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 @@
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
8struct sway_seat *sway_seat_create(struct wl_display *display, 10struct 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
82void 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}