aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboard.c12
-rw-r--r--layer_surface.c2
-rw-r--r--main.c2
-rw-r--r--pointer.c2
-rw-r--r--registry.c6
-rw-r--r--seat.c6
-rw-r--r--wayland.h2
7 files changed, 21 insertions, 11 deletions
diff --git a/keyboard.c b/keyboard.c
index 94bd29f..932cba7 100644
--- a/keyboard.c
+++ b/keyboard.c
@@ -11,6 +11,8 @@ void setup_keyboard(client_state* state) {
wl_keyboard_add_listener(state->keyboard, &keyboard_listener, state);
}
+// listeners
+
void wl_keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,
uint32_t format, int32_t fd, uint32_t size) {
client_state* state = data;
@@ -69,12 +71,12 @@ void wl_keyboard_leave(void *data, struct wl_keyboard *wl_keyboard,
void wl_keyboard_key(void *data, struct wl_keyboard *wl_keyboard,
uint32_t serial, uint32_t time, uint32_t key,
uint32_t key_state) {
- client_state *state = data;
+ client_state *state = data;
- xkb_keysym_t keysym = xkb_state_key_get_one_sym(state->xkb_state, key + 8);
- if (keysym == XKB_KEY_q) {
- state->running = false;
- }
+ xkb_keysym_t keysym = xkb_state_key_get_one_sym(state->xkb_state, key + 8);
+ if (keysym == XKB_KEY_q) {
+ state->running = false;
+ }
}
void wl_keyboard_modifiers(void *data, struct wl_keyboard *wl_keyboard,
diff --git a/layer_surface.c b/layer_surface.c
index 0463677..11e369c 100644
--- a/layer_surface.c
+++ b/layer_surface.c
@@ -20,6 +20,8 @@ void setup_surface(client_state* state) {
wl_display_roundtrip(state->display);
}
+// listeners
+
void configure(void *data, struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t serial, uint32_t width, uint32_t height) {
client_state* state = data;
state->width = width;
diff --git a/main.c b/main.c
index 025bf7a..a1b6337 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,3 @@
-#include <EGL/egl.h>
#include <stdio.h>
#include "state.h"
@@ -16,6 +15,7 @@ int main() {
}
setup_registry(&state);
+ setup_seat(&state);
setup_surface(&state);
if (!init_gl(&state)) {
diff --git a/pointer.c b/pointer.c
index 9d36df8..904323f 100644
--- a/pointer.c
+++ b/pointer.c
@@ -9,6 +9,8 @@ void setup_pointer(client_state* state) {
wl_pointer_add_listener(state->pointer, &pointer_listener, state);
}
+// listeners
+
void enter(void *data, struct wl_pointer *pointer, uint32_t serial,
struct wl_surface *surface, wl_fixed_t fixed_surface_x, wl_fixed_t fixed_surface_y) {
client_state* state = data;
diff --git a/registry.c b/registry.c
index bee7d1b..69f2370 100644
--- a/registry.c
+++ b/registry.c
@@ -2,7 +2,6 @@
#include <string.h>
#include "./state.h"
-#include "wayland.h"
struct wl_registry_listener registry_listener;
@@ -11,6 +10,9 @@ void setup_registry(client_state* state) {
wl_registry_add_listener(state->registry, &registry_listener, state);
wl_display_roundtrip(state->display);
}
+
+// listeners
+
void global(void *data, struct wl_registry *wl_registry, uint32_t name, const char *interface, uint32_t version) {
client_state* state = data;
@@ -20,7 +22,7 @@ void global(void *data, struct wl_registry *wl_registry, uint32_t name, const ch
state->compositor = wl_registry_bind(wl_registry, name, &wl_compositor_interface, 1);
}
else if (!strcmp(interface, wl_seat_interface.name)) {
- setup_seat(state, name);
+ state->seat = wl_registry_bind(state->registry, name, &wl_seat_interface, 1);
}
else if (!strcmp(interface, zwlr_layer_shell_v1_interface.name)) {
state->layer_shell = wl_registry_bind(wl_registry, name, &zwlr_layer_shell_v1_interface, version);
diff --git a/seat.c b/seat.c
index 6199f13..a995066 100644
--- a/seat.c
+++ b/seat.c
@@ -4,11 +4,13 @@
struct wl_seat_listener seat_listener;
-void setup_seat(client_state* state, uint32_t name) {
- state->seat = wl_registry_bind(state->registry, name, &wl_seat_interface, 1);
+void setup_seat(client_state* state) {
wl_seat_add_listener(state->seat, &seat_listener, state);
+ wl_display_roundtrip(state->display);
}
+// listeners
+
void capabilities(void *data, struct wl_seat *wl_seat, uint32_t capabilities) {
client_state* state = data;
diff --git a/wayland.h b/wayland.h
index c5f4daa..e23f91f 100644
--- a/wayland.h
+++ b/wayland.h
@@ -5,7 +5,7 @@
void setup_registry(client_state* state);
void setup_surface(client_state* state);
-void setup_seat(client_state* state, uint32_t name);
+void setup_seat(client_state* state);
void setup_pointer(client_state* state);
void setup_keyboard(client_state* state);