Explorar o código

unix: Factor out the check for GTK into an internal function

This will allow the same check to be done by the libdecor integration.

Helps: https://github.com/libsdl-org/sdl2-compat/issues/564
Signed-off-by: Simon McVittie <smcv@debian.org>
Simon McVittie hai 2 meses
pai
achega
9e0b31b297
Modificáronse 2 ficheiros con 11 adicións e 1 borrados
  1. 10 1
      src/core/unix/SDL_gtk.c
  2. 1 0
      src/core/unix/SDL_gtk.h

+ 10 - 1
src/core/unix/SDL_gtk.c

@@ -81,12 +81,21 @@ static bool IsGtkInit()
     return libgdk != NULL && libgtk != NULL;
 }
 
-static bool InitGtk(void)
+bool SDL_CanUseGtk(void)
 {
     if (!SDL_GetHintBoolean("SDL_ENABLE_GTK", true)) {
         return false;
     }
 
+    return true;
+}
+
+static bool InitGtk(void)
+{
+    if (!SDL_CanUseGtk()) {
+        return false;
+    }
+
     if (IsGtkInit()) {
         return true;
     }

+ 1 - 0
src/core/unix/SDL_gtk.h

@@ -116,6 +116,7 @@ typedef struct SDL_GtkContext
 	} gtk;
 } SDL_GtkContext;
 
+extern bool SDL_CanUseGtk(void);
 extern bool SDL_Gtk_Init(void);
 extern void SDL_Gtk_Quit(void);
 extern SDL_GtkContext *SDL_Gtk_EnterContext(void);