@@ -76,40 +76,37 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u
7676 }
7777}
7878
79- void ffdsConnectWayland (const FFinstance * instance , FFDisplayServerResult * result )
79+ bool detectWayland (const FFinstance * instance , FFDisplayServerResult * result )
8080{
81- if (getenv ("XDG_RUNTIME_DIR" ) == NULL )
82- return ;
83-
84- FF_LIBRARY_LOAD (wayland , instance -> config .libWayland , , "libwayland-client.so" , 1 )
81+ FF_LIBRARY_LOAD (wayland , instance -> config .libWayland , false, "libwayland-client.so" , 1 )
8582
86- FF_LIBRARY_LOAD_SYMBOL (wayland , wl_display_connect ,)
87- FF_LIBRARY_LOAD_SYMBOL (wayland , wl_display_dispatch ,)
88- FF_LIBRARY_LOAD_SYMBOL (wayland , wl_display_roundtrip ,)
89- FF_LIBRARY_LOAD_SYMBOL (wayland , wl_proxy_marshal_constructor ,)
90- FF_LIBRARY_LOAD_SYMBOL (wayland , wl_display_disconnect ,)
91- FF_LIBRARY_LOAD_SYMBOL (wayland , wl_registry_interface ,)
83+ FF_LIBRARY_LOAD_SYMBOL (wayland , wl_display_connect , false )
84+ FF_LIBRARY_LOAD_SYMBOL (wayland , wl_display_dispatch , false )
85+ FF_LIBRARY_LOAD_SYMBOL (wayland , wl_display_roundtrip , false )
86+ FF_LIBRARY_LOAD_SYMBOL (wayland , wl_proxy_marshal_constructor , false )
87+ FF_LIBRARY_LOAD_SYMBOL (wayland , wl_display_disconnect , false )
88+ FF_LIBRARY_LOAD_SYMBOL (wayland , wl_registry_interface , false )
9289
9390 WaylandData data ;
9491
95- FF_LIBRARY_LOAD_SYMBOL_ADRESS (wayland , data .ffwl_proxy_marshal_constructor_versioned , wl_proxy_marshal_constructor_versioned ,)
96- FF_LIBRARY_LOAD_SYMBOL_ADRESS (wayland , data .ffwl_proxy_add_listener , wl_proxy_add_listener ,)
97- FF_LIBRARY_LOAD_SYMBOL_ADRESS (wayland , data .ffwl_output_interface , wl_output_interface ,)
98- FF_LIBRARY_LOAD_SYMBOL_ADRESS (wayland , data .ffwl_proxy_destroy , wl_proxy_destroy ,)
92+ FF_LIBRARY_LOAD_SYMBOL_ADRESS (wayland , data .ffwl_proxy_marshal_constructor_versioned , wl_proxy_marshal_constructor_versioned , false )
93+ FF_LIBRARY_LOAD_SYMBOL_ADRESS (wayland , data .ffwl_proxy_add_listener , wl_proxy_add_listener , false )
94+ FF_LIBRARY_LOAD_SYMBOL_ADRESS (wayland , data .ffwl_output_interface , wl_output_interface , false )
95+ FF_LIBRARY_LOAD_SYMBOL_ADRESS (wayland , data .ffwl_proxy_destroy , wl_proxy_destroy , false )
9996
10097 struct wl_display * display = ffwl_display_connect (NULL );
10198 if (display == NULL )
10299 {
103100 dlclose (wayland );
104- return ;
101+ return false ;
105102 }
106103
107104 struct wl_registry * registry = (struct wl_registry * ) ffwl_proxy_marshal_constructor ((struct wl_proxy * ) display , WL_DISPLAY_GET_REGISTRY , ffwl_registry_interface , NULL );
108105 if (registry == NULL )
109106 {
110107 ffwl_display_disconnect (display );
111108 dlclose (wayland );
112- return ;
109+ return false ;
113110 }
114111
115112 data .instance = instance ;
@@ -136,20 +133,21 @@ void ffdsConnectWayland(const FFinstance* instance, FFDisplayServerResult* resul
136133 //So we can set set the session type to wayland.
137134 //This is used as an indicator that we are running wayland by the x11 backends.
138135 ffStrbufSetS (& result -> wmProtocolName , FF_DISPLAYSERVER_PROTOCOL_WAYLAND );
136+ return true;
139137}
140-
141- #else
138+ #endif
142139
143140void ffdsConnectWayland (const FFinstance * instance , FFDisplayServerResult * result )
144141{
145- FF_UNUSED (instance );
146-
147- //We try to detect wayland already here, so the x11 methods only to resolution detection.
148-
149142 //Wayland requires this to be set
150143 if (getenv ("XDG_RUNTIME_DIR" ) == NULL )
151144 return ;
152145
146+ #ifdef FF_HAVE_WAYLAND
147+ if (detectWayland (instance , result ))
148+ return ;
149+ #endif
150+
153151 const char * xdgSessionType = getenv ("XDG_SESSION_TYPE" );
154152
155153 //If XDG_SESSION_TYPE is set, and doesn't contain "wayland", we are probably not running in a wayland session.
@@ -161,9 +159,7 @@ void ffdsConnectWayland(const FFinstance* instance, FFDisplayServerResult* resul
161159 if (xdgSessionType == NULL && getenv ("WAYLAND_DISPLAY" ) == NULL && getenv ("WAYLAND_SOCKET" ) == NULL )
162160 return ;
163161
164- //We are probably running a wayland compositor at this point, but fastfetch was compiled without the required library.
165- //Set the protocol name and use DRM for resolution detection .
162+ //We are probably running a wayland compositor at this point,
163+ //but fastfetch was compiled without the required library, or loading the library failed .
166164 ffStrbufSetS (& result -> wmProtocolName , FF_DISPLAYSERVER_PROTOCOL_WAYLAND );
167165}
168-
169- #endif
0 commit comments