From 41b024d3b1bec0780f56f6bf527b25ec685b5808 Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Wed, 29 Jun 2022 11:08:42 +0200 Subject: [PATCH] Refactor wayland code the third --- src/detection/displayserver/wayland.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/detection/displayserver/wayland.c b/src/detection/displayserver/wayland.c index dd2c17ac9..a3998bd2d 100644 --- a/src/detection/displayserver/wayland.c +++ b/src/detection/displayserver/wayland.c @@ -18,7 +18,6 @@ typedef struct WaylandData FF_LIBRARY_SYMBOL(wl_proxy_add_listener) FF_LIBRARY_SYMBOL(wl_proxy_destroy) const struct wl_interface* ffwl_output_interface; - struct wl_output_listener output_listener; } WaylandData; static void waylandDetectWM(int fd, FFDisplayServerResult* result) @@ -68,7 +67,12 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u if(output == NULL) return; - wldata->ffwl_proxy_add_listener(output, (void(**)(void)) &wldata->output_listener, data); + //Needs to be static, because the scope of the function will already be lost when calling the listener + static struct wl_output_listener outputListener = { + .mode = waylandOutputModeListener + }; + + wldata->ffwl_proxy_add_listener(output, (void(**)(void)) &outputListener, data); } } @@ -114,10 +118,6 @@ bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result) .global = waylandGlobalAddListener }; - data.output_listener = (struct wl_output_listener) { - .mode = waylandOutputModeListener - }; - data.ffwl_proxy_add_listener(registry, (void(**)(void)) ®istry_listener, &data); ffwl_display_dispatch(display); ffwl_display_roundtrip(display);