From ba7b581b4d0645a693e6b19c558842174724e0f7 Mon Sep 17 00:00:00 2001 From: Rakarake Date: Sun, 22 Feb 2026 18:27:20 +0100 Subject: [PATCH] can now specify montor --- wayland.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/wayland.c b/wayland.c index 26a4a08..19d1432 100644 --- a/wayland.c +++ b/wayland.c @@ -36,6 +36,9 @@ struct surface_list { struct client_state { bool running; int output_type; + /// Names of enabled outputs, or NULL for every output. + char **output_list; + int output_list_len; /* Globals */ struct wl_display *wl_display; struct wl_registry *wl_registry; @@ -254,7 +257,15 @@ void layer_new(struct client_state *state, struct wl_output *wl_output) { static void wl_output_name(void *data, struct wl_output *wl_output, const char *name) { struct client_state *state = data; printf("output name: %s\n", name); - layer_new(state, wl_output); + if (state->output_list != NULL) { + for (int i = 0; i < state->output_list_len; i++) { + if (strcmp(state->output_list[i], name) == 0) { + layer_new(state, wl_output); + } + } + } else { + layer_new(state, wl_output); + } } static void wl_output_description(void *data, struct wl_output *wl_output, const char *description) { @@ -508,10 +519,14 @@ static const struct wl_registry_listener wl_registry_listener = { /// Initializes wayland and creates an opengl context struct client_state* wayland_init(int output_type, char *output_list[], int output_list_len) { - for (int i = 0; i < output_list_len; i++) { - printf("output name selected: %s\n", output_list[i]); + if (output_list != NULL) { + for (int i = 0; i < output_list_len; i++) { + printf("output name selected: %s\n", output_list[i]); + } } struct client_state *state = malloc(sizeof(struct client_state)); + state->output_list = output_list; + state->output_list_len = output_list_len; state->running = 1; state->output_type = output_type; state->wl_display = wl_display_connect(NULL);