@@ -18,7 +18,6 @@ typedef struct WaylandData
1818 FF_LIBRARY_SYMBOL (wl_proxy_add_listener )
1919 FF_LIBRARY_SYMBOL (wl_proxy_destroy )
2020 const struct wl_interface * ffwl_output_interface ;
21- struct wl_output_listener output_listener ;
2221} WaylandData ;
2322
2423static void waylandDetectWM (int fd , FFDisplayServerResult * result )
@@ -68,7 +67,12 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u
6867 if (output == NULL )
6968 return ;
7069
71- wldata -> ffwl_proxy_add_listener (output , (void (* * )(void )) & wldata -> output_listener , data );
70+ //Needs to be static, because the scope of the function will already be lost when calling the listener
71+ static struct wl_output_listener outputListener = {
72+ .mode = waylandOutputModeListener
73+ };
74+
75+ wldata -> ffwl_proxy_add_listener (output , (void (* * )(void )) & outputListener , data );
7276 }
7377}
7478
@@ -114,10 +118,6 @@ bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result)
114118 .global = waylandGlobalAddListener
115119 };
116120
117- data .output_listener = (struct wl_output_listener ) {
118- .mode = waylandOutputModeListener
119- };
120-
121121 data .ffwl_proxy_add_listener (registry , (void (* * )(void )) & registry_listener , & data );
122122 ffwl_display_dispatch (display );
123123 ffwl_display_roundtrip (display );
0 commit comments