aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seat.c
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2017-12-08 07:22:26 -0500
committerLibravatar Tony Crisci <tony@dubstepdish.com>2017-12-08 08:04:03 -0500
commitec7fc42a00db8c230ca1a050f0a1f7badc697fa5 (patch)
tree3e0614e8a497fbc12f2669945a43dcd310809c05 /sway/input/seat.c
parentbasic input manager and seat (diff)
downloadsway-ec7fc42a00db8c230ca1a050f0a1f7badc697fa5.tar.gz
sway-ec7fc42a00db8c230ca1a050f0a1f7badc697fa5.tar.zst
sway-ec7fc42a00db8c230ca1a050f0a1f7badc697fa5.zip
sway cursor
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index f41b6dba..459b2ee2 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -1,5 +1,7 @@
1#define _XOPEN_SOURCE 700 1#define _XOPEN_SOURCE 700
2#include <wlr/types/wlr_cursor.h>
2#include "sway/seat.h" 3#include "sway/seat.h"
4#include "sway/cursor.h"
3#include "sway/input-manager.h" 5#include "sway/input-manager.h"
4#include "log.h" 6#include "log.h"
5 7
@@ -9,16 +11,66 @@ struct sway_seat *sway_seat_create(struct wl_display *display,
9 if (!seat) { 11 if (!seat) {
10 return NULL; 12 return NULL;
11 } 13 }
14
12 seat->seat = wlr_seat_create(display, seat_name); 15 seat->seat = wlr_seat_create(display, seat_name);
16 if (!sway_assert(seat->seat, "could not allocate seat")) {
17 return NULL;
18 }
19
20 seat->cursor = sway_cursor_create(seat);
21 if (!seat->cursor) {
22 wlr_seat_destroy(seat->seat);
23 free(seat);
24 return NULL;
25 }
26
27 wlr_seat_set_capabilities(seat->seat,
28 WL_SEAT_CAPABILITY_KEYBOARD |
29 WL_SEAT_CAPABILITY_POINTER |
30 WL_SEAT_CAPABILITY_TOUCH);
31
13 return seat; 32 return seat;
14} 33}
15 34
35static void seat_add_pointer(struct sway_seat *seat,
36 struct wlr_input_device *device) {
37 // TODO pointer configuration
38 wlr_cursor_attach_input_device(seat->cursor->cursor, device);
39}
40
16void sway_seat_add_device(struct sway_seat *seat, 41void sway_seat_add_device(struct sway_seat *seat,
17 struct wlr_input_device *device) { 42 struct wlr_input_device *device) {
18 sway_log(L_DEBUG, "input add: %s", device->name); 43 sway_log(L_DEBUG, "input add: %s", device->name);
44 switch (device->type) {
45 case WLR_INPUT_DEVICE_POINTER:
46 seat_add_pointer(seat, device);
47 break;
48 case WLR_INPUT_DEVICE_KEYBOARD:
49 case WLR_INPUT_DEVICE_TOUCH:
50 case WLR_INPUT_DEVICE_TABLET_PAD:
51 case WLR_INPUT_DEVICE_TABLET_TOOL:
52 sway_log(L_DEBUG, "TODO: add other devices");
53 break;
54 }
55}
56
57static void seat_remove_pointer(struct sway_seat *seat,
58 struct wlr_input_device *device) {
59 // TODO
19} 60}
20 61
21void sway_seat_remove_device(struct sway_seat *seat, 62void sway_seat_remove_device(struct sway_seat *seat,
22 struct wlr_input_device *device) { 63 struct wlr_input_device *device) {
23 sway_log(L_DEBUG, "input remove: %s", device->name); 64 sway_log(L_DEBUG, "input remove: %s", device->name);
65 switch (device->type) {
66 case WLR_INPUT_DEVICE_POINTER:
67 seat_remove_pointer(seat, device);
68 break;
69 case WLR_INPUT_DEVICE_KEYBOARD:
70 case WLR_INPUT_DEVICE_TOUCH:
71 case WLR_INPUT_DEVICE_TABLET_PAD:
72 case WLR_INPUT_DEVICE_TABLET_TOOL:
73 sway_log(L_DEBUG, "TODO: remove other devices");
74 break;
75 }
24} 76}