diff options
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r-- | sway/input/cursor.c | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c new file mode 100644 index 00000000..819007d5 --- /dev/null +++ b/sway/input/cursor.c | |||
@@ -0,0 +1,128 @@ | |||
1 | #define _XOPEN_SOURCE 700 | ||
2 | #include <wlr/types/wlr_cursor.h> | ||
3 | #include "sway/cursor.h" | ||
4 | #include "log.h" | ||
5 | |||
6 | static void handle_cursor_motion(struct wl_listener *listener, void *data) { | ||
7 | struct sway_cursor *cursor = | ||
8 | wl_container_of(listener, cursor, motion); | ||
9 | struct wlr_event_pointer_motion *event = data; | ||
10 | sway_log(L_DEBUG, "TODO: handle event: %p", event); | ||
11 | } | ||
12 | |||
13 | static void handle_cursor_motion_absolute(struct wl_listener *listener, | ||
14 | void *data) { | ||
15 | struct sway_cursor *cursor = | ||
16 | wl_container_of(listener, cursor, motion_absolute); | ||
17 | struct wlr_event_pointer_motion_absolute *event = data; | ||
18 | sway_log(L_DEBUG, "TODO: handle event: %p", event); | ||
19 | } | ||
20 | |||
21 | static void handle_cursor_button(struct wl_listener *listener, void *data) { | ||
22 | struct sway_cursor *cursor = | ||
23 | wl_container_of(listener, cursor, button); | ||
24 | struct wlr_event_pointer_button *event = data; | ||
25 | sway_log(L_DEBUG, "TODO: handle event: %p", event); | ||
26 | } | ||
27 | |||
28 | static void handle_cursor_axis(struct wl_listener *listener, void *data) { | ||
29 | struct sway_cursor *cursor = | ||
30 | wl_container_of(listener, cursor, axis); | ||
31 | struct wlr_event_pointer_axis *event = data; | ||
32 | sway_log(L_DEBUG, "TODO: handle event: %p", event); | ||
33 | } | ||
34 | |||
35 | static void handle_touch_down(struct wl_listener *listener, void *data) { | ||
36 | struct sway_cursor *cursor = | ||
37 | wl_container_of(listener, cursor, touch_down); | ||
38 | struct wlr_event_touch_down *event = data; | ||
39 | sway_log(L_DEBUG, "TODO: handle event: %p", event); | ||
40 | } | ||
41 | |||
42 | static void handle_touch_up(struct wl_listener *listener, void *data) { | ||
43 | struct sway_cursor *cursor = | ||
44 | wl_container_of(listener, cursor, touch_up); | ||
45 | struct wlr_event_touch_up *event = data; | ||
46 | sway_log(L_DEBUG, "TODO: handle event: %p", event); | ||
47 | } | ||
48 | |||
49 | static void handle_touch_motion(struct wl_listener *listener, void *data) { | ||
50 | struct sway_cursor *cursor = | ||
51 | wl_container_of(listener, cursor, touch_motion); | ||
52 | struct wlr_event_touch_motion *event = data; | ||
53 | sway_log(L_DEBUG, "TODO: handle event: %p", event); | ||
54 | } | ||
55 | |||
56 | static void handle_tool_axis(struct wl_listener *listener, void *data) { | ||
57 | struct sway_cursor *cursor = | ||
58 | wl_container_of(listener, cursor, tool_axis); | ||
59 | struct wlr_event_tablet_tool_axis *event = data; | ||
60 | sway_log(L_DEBUG, "TODO: handle event: %p", event); | ||
61 | } | ||
62 | |||
63 | static void handle_tool_tip(struct wl_listener *listener, void *data) { | ||
64 | struct sway_cursor *cursor = | ||
65 | wl_container_of(listener, cursor, tool_tip); | ||
66 | struct wlr_event_tablet_tool_tip *event = data; | ||
67 | sway_log(L_DEBUG, "TODO: handle event: %p", event); | ||
68 | } | ||
69 | |||
70 | static void handle_request_set_cursor(struct wl_listener *listener, | ||
71 | void *data) { | ||
72 | struct sway_cursor *cursor = | ||
73 | wl_container_of(listener, cursor, request_set_cursor); | ||
74 | struct wlr_seat_pointer_request_set_cursor_event *event = data; | ||
75 | sway_log(L_DEBUG, "TODO: handle event: %p", event); | ||
76 | } | ||
77 | |||
78 | struct sway_cursor *sway_cursor_create(struct sway_seat *seat) { | ||
79 | struct sway_cursor *cursor = calloc(1, sizeof(struct sway_cursor)); | ||
80 | if (!sway_assert(cursor, "could not allocate sway cursor")) { | ||
81 | return NULL; | ||
82 | } | ||
83 | |||
84 | struct wlr_cursor *wlr_cursor = wlr_cursor_create(); | ||
85 | if (!sway_assert(wlr_cursor, "could not allocate wlr cursor")) { | ||
86 | free(cursor); | ||
87 | return NULL; | ||
88 | } | ||
89 | |||
90 | // input events | ||
91 | wl_signal_add(&wlr_cursor->events.motion, &cursor->motion); | ||
92 | cursor->motion.notify = handle_cursor_motion; | ||
93 | |||
94 | wl_signal_add(&wlr_cursor->events.motion_absolute, | ||
95 | &cursor->motion_absolute); | ||
96 | cursor->motion_absolute.notify = handle_cursor_motion_absolute; | ||
97 | |||
98 | wl_signal_add(&wlr_cursor->events.button, &cursor->button); | ||
99 | cursor->button.notify = handle_cursor_button; | ||
100 | |||
101 | wl_signal_add(&wlr_cursor->events.axis, &cursor->axis); | ||
102 | cursor->axis.notify = handle_cursor_axis; | ||
103 | |||
104 | wl_signal_add(&wlr_cursor->events.touch_down, &cursor->touch_down); | ||
105 | cursor->touch_down.notify = handle_touch_down; | ||
106 | |||
107 | wl_signal_add(&wlr_cursor->events.touch_up, &cursor->touch_up); | ||
108 | cursor->touch_up.notify = handle_touch_up; | ||
109 | |||
110 | wl_signal_add(&wlr_cursor->events.touch_motion, | ||
111 | &cursor->touch_motion); | ||
112 | cursor->touch_motion.notify = handle_touch_motion; | ||
113 | |||
114 | wl_signal_add(&wlr_cursor->events.tablet_tool_axis, | ||
115 | &cursor->tool_axis); | ||
116 | cursor->tool_axis.notify = handle_tool_axis; | ||
117 | |||
118 | wl_signal_add(&wlr_cursor->events.tablet_tool_tip, &cursor->tool_tip); | ||
119 | cursor->tool_tip.notify = handle_tool_tip; | ||
120 | |||
121 | wl_signal_add(&seat->seat->events.request_set_cursor, | ||
122 | &cursor->request_set_cursor); | ||
123 | cursor->request_set_cursor.notify = handle_request_set_cursor; | ||
124 | |||
125 | cursor->cursor = wlr_cursor; | ||
126 | |||
127 | return cursor; | ||
128 | } | ||