aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.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/cursor.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/cursor.c')
-rw-r--r--sway/input/cursor.c128
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
6static 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
13static 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
21static 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
28static 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
35static 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
42static 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
49static 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
56static 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
63static 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
70static 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
78struct 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}