aboutsummaryrefslogtreecommitdiffstats
path: root/swaylock
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-04-02 22:55:30 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-04-04 18:47:48 -0400
commit402e1d90f01256365f589972b7b2fc4462224ed1 (patch)
tree271bc483e3aff63cd11fca66b083e8a55cf41979 /swaylock
parentInitial swaylock port (diff)
downloadsway-402e1d90f01256365f589972b7b2fc4462224ed1.tar.gz
sway-402e1d90f01256365f589972b7b2fc4462224ed1.tar.zst
sway-402e1d90f01256365f589972b7b2fc4462224ed1.zip
Grab keyboard off of the seat
Diffstat (limited to 'swaylock')
-rw-r--r--swaylock/main.c51
1 files changed, 48 insertions, 3 deletions
diff --git a/swaylock/main.c b/swaylock/main.c
index 8673694d..948d661b 100644
--- a/swaylock/main.c
+++ b/swaylock/main.c
@@ -93,11 +93,51 @@ static void layer_surface_closed(void *data,
93 context->state->run_display = false; 93 context->state->run_display = false;
94} 94}
95 95
96struct zwlr_layer_surface_v1_listener layer_surface_listener = { 96static struct zwlr_layer_surface_v1_listener layer_surface_listener = {
97 .configure = layer_surface_configure, 97 .configure = layer_surface_configure,
98 .closed = layer_surface_closed, 98 .closed = layer_surface_closed,
99}; 99};
100 100
101static void keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,
102 uint32_t format, int32_t fd, uint32_t size) {
103 // TODO
104}
105
106static void keyboard_enter(void *data, struct wl_keyboard *wl_keyboard,
107 uint32_t serial, struct wl_surface *surface, struct wl_array *keys) {
108 // Who cares
109}
110
111static void keyboard_leave(void *data, struct wl_keyboard *wl_keyboard,
112 uint32_t serial, struct wl_surface *surface) {
113 // Who cares
114}
115
116static void keyboard_key(void *data, struct wl_keyboard *wl_keyboard,
117 uint32_t serial, uint32_t time, uint32_t key, uint32_t state) {
118 // TODO
119}
120
121static void keyboard_modifiers(void *data, struct wl_keyboard *wl_keyboard,
122 uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched,
123 uint32_t mods_locked, uint32_t group) {
124 // TODO
125}
126
127static void keyboard_repeat_info(void *data, struct wl_keyboard *wl_keyboard,
128 int32_t rate, int32_t delay) {
129 // TODO
130}
131
132static struct wl_keyboard_listener keyboard_listener = {
133 .keymap = keyboard_keymap,
134 .enter = keyboard_enter,
135 .leave = keyboard_leave,
136 .key = keyboard_key,
137 .modifiers = keyboard_modifiers,
138 .repeat_info = keyboard_repeat_info,
139};
140
101static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, 141static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
102 uint32_t serial, struct wl_surface *surface, 142 uint32_t serial, struct wl_surface *surface,
103 wl_fixed_t surface_x, wl_fixed_t surface_y) { 143 wl_fixed_t surface_x, wl_fixed_t surface_y) {
@@ -143,7 +183,7 @@ static void wl_pointer_axis_discrete(void *data, struct wl_pointer *wl_pointer,
143 // Who cares 183 // Who cares
144} 184}
145 185
146struct wl_pointer_listener pointer_listener = { 186static struct wl_pointer_listener pointer_listener = {
147 .enter = wl_pointer_enter, 187 .enter = wl_pointer_enter,
148 .leave = wl_pointer_leave, 188 .leave = wl_pointer_leave,
149 .motion = wl_pointer_motion, 189 .motion = wl_pointer_motion,
@@ -157,10 +197,15 @@ struct wl_pointer_listener pointer_listener = {
157 197
158static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat, 198static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
159 enum wl_seat_capability caps) { 199 enum wl_seat_capability caps) {
200 struct swaylock_state *state = data;
160 if ((caps & WL_SEAT_CAPABILITY_POINTER)) { 201 if ((caps & WL_SEAT_CAPABILITY_POINTER)) {
161 struct wl_pointer *pointer = wl_seat_get_pointer(wl_seat); 202 struct wl_pointer *pointer = wl_seat_get_pointer(wl_seat);
162 wl_pointer_add_listener(pointer, &pointer_listener, NULL); 203 wl_pointer_add_listener(pointer, &pointer_listener, NULL);
163 } 204 }
205 if ((caps & WL_SEAT_CAPABILITY_KEYBOARD)) {
206 struct wl_keyboard *keyboard = wl_seat_get_keyboard(wl_seat);
207 wl_keyboard_add_listener(keyboard, &keyboard_listener, state);
208 }
164} 209}
165 210
166static void seat_handle_name(void *data, struct wl_seat *wl_seat, 211static void seat_handle_name(void *data, struct wl_seat *wl_seat,
@@ -185,7 +230,7 @@ static void handle_global(void *data, struct wl_registry *registry,
185 } else if (strcmp(interface, wl_seat_interface.name) == 0) { 230 } else if (strcmp(interface, wl_seat_interface.name) == 0) {
186 struct wl_seat *seat = wl_registry_bind( 231 struct wl_seat *seat = wl_registry_bind(
187 registry, name, &wl_seat_interface, 1); 232 registry, name, &wl_seat_interface, 1);
188 wl_seat_add_listener(seat, &seat_listener, NULL); 233 wl_seat_add_listener(seat, &seat_listener, state);
189 } else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) { 234 } else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) {
190 state->layer_shell = wl_registry_bind( 235 state->layer_shell = wl_registry_bind(
191 registry, name, &zwlr_layer_shell_v1_interface, 1); 236 registry, name, &zwlr_layer_shell_v1_interface, 1);