diff options
| -rw-r--r-- | layer_surface.c | 3 | ||||
| -rw-r--r-- | main.c | 14 | ||||
| -rw-r--r-- | pointer.c | 1 | ||||
| -rw-r--r-- | registry.c | 8 | ||||
| -rw-r--r-- | seat.c | 2 | ||||
| -rw-r--r-- | wayland.h | 4 |
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 @@ -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); @@ -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 @@ -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, ®istry_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 { } @@ -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); } @@ -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); |
