aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Jamison <jackqjamison@gmail.com>2025-10-11 12:12:49 -0400
committerJack Jamison <jackqjamison@gmail.com>2025-10-11 12:12:49 -0400
commitc5dab928775cb86cc11b7e3a8493c3432e2df201 (patch)
tree9f2322e85dc8d410b7f1a9951c2213315e0d8901
parent502ffec5198dd0dbd87f8d88ff07f95f241a24f8 (diff)
changes
-rw-r--r--layer_surface.c3
-rw-r--r--main.c14
-rw-r--r--pointer.c1
-rw-r--r--registry.c8
-rw-r--r--seat.c2
-rw-r--r--wayland.h4
6 files changed, 20 insertions, 12 deletions
diff --git a/layer_surface.c b/layer_surface.c
index 11e369c..eb23da9 100644
--- a/layer_surface.c
+++ b/layer_surface.c
@@ -2,7 +2,7 @@
struct zwlr_layer_surface_v1_listener layer_surface_listener;
-void setup_surface(client_state* state) {
+void create_surface(client_state* state) {
state->surface = wl_compositor_create_surface(state->compositor);
state->layer_surface = zwlr_layer_shell_v1_get_layer_surface(
state->layer_shell, state->surface, NULL,
@@ -17,7 +17,6 @@ void setup_surface(client_state* state) {
zwlr_layer_surface_v1_set_margin(state->layer_surface, 0, 0, 0, 0);
zwlr_layer_surface_v1_set_keyboard_interactivity(state->layer_surface, ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE);
wl_surface_commit(state->surface);
- wl_display_roundtrip(state->display);
}
// listeners
diff --git a/main.c b/main.c
index a1b6337..9627cb5 100644
--- a/main.c
+++ b/main.c
@@ -14,15 +14,23 @@ int main() {
return 0;
}
- setup_registry(&state);
- setup_seat(&state);
- setup_surface(&state);
+ // set up globals
+ setup_registry_and_globals(&state);
+ wl_display_roundtrip(state.display);
+ // create non global objects
+ create_surface(&state);
+
+ // roundtrip to recieve the rest of the events
+ wl_display_roundtrip(state.display);
+
+ // set up graphics
if (!init_gl(&state)) {
fprintf(stderr, "Failed to Initalize EGL/OpenGL\n");
return 1;
}
+ // event loop
while (state.running) {
wl_display_dispatch_pending(state.display);
render_frame(&state);
diff --git a/pointer.c b/pointer.c
index 904323f..85eff0d 100644
--- a/pointer.c
+++ b/pointer.c
@@ -7,6 +7,7 @@ void setup_pointer(client_state* state) {
state->cursor_shape_device = wp_cursor_shape_manager_v1_get_pointer(
state->cursor_shape_manager, state->pointer);
wl_pointer_add_listener(state->pointer, &pointer_listener, state);
+ printf("setup pointer\n");
}
// listeners
diff --git a/registry.c b/registry.c
index 69f2370..72002e8 100644
--- a/registry.c
+++ b/registry.c
@@ -2,13 +2,13 @@
#include <string.h>
#include "./state.h"
+#include "wayland.h"
struct wl_registry_listener registry_listener;
-void setup_registry(client_state* state) {
+void setup_registry_and_globals(client_state* state) {
state->registry = wl_display_get_registry(state->display);
wl_registry_add_listener(state->registry, &registry_listener, state);
- wl_display_roundtrip(state->display);
}
// listeners
@@ -23,13 +23,13 @@ void global(void *data, struct wl_registry *wl_registry, uint32_t name, const ch
}
else if (!strcmp(interface, wl_seat_interface.name)) {
state->seat = wl_registry_bind(state->registry, name, &wl_seat_interface, 1);
+ setup_seat(state);
}
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);
}
else if (!strcmp(interface, wp_cursor_shape_manager_v1_interface.name)) {
- state->cursor_shape_manager = wl_registry_bind(
- wl_registry, name, &wp_cursor_shape_manager_v1_interface, version);
+ state->cursor_shape_manager = wl_registry_bind( wl_registry, name, &wp_cursor_shape_manager_v1_interface, version);
}
else {
}
diff --git a/seat.c b/seat.c
index a995066..528a007 100644
--- a/seat.c
+++ b/seat.c
@@ -6,7 +6,6 @@ struct wl_seat_listener seat_listener;
void setup_seat(client_state* state) {
wl_seat_add_listener(state->seat, &seat_listener, state);
- wl_display_roundtrip(state->display);
}
// listeners
@@ -14,6 +13,7 @@ void setup_seat(client_state* state) {
void capabilities(void *data, struct wl_seat *wl_seat, uint32_t capabilities) {
client_state* state = data;
+ printf("seat capablities\n");
if (capabilities & WL_SEAT_CAPABILITY_KEYBOARD && !state->keyboard) {
setup_keyboard(state);
}
diff --git a/wayland.h b/wayland.h
index e23f91f..b6c93a3 100644
--- a/wayland.h
+++ b/wayland.h
@@ -3,8 +3,8 @@
#include "state.h"
-void setup_registry(client_state* state);
-void setup_surface(client_state* state);
+void setup_registry_and_globals(client_state* state);
+void create_surface(client_state* state);
void setup_seat(client_state* state);
void setup_pointer(client_state* state);
void setup_keyboard(client_state* state);