diff --git a/src/core/unix/SDL_gtk.c b/src/core/unix/SDL_gtk.c index 2d10aa180c..5376cdf17d 100644 --- a/src/core/unix/SDL_gtk.c +++ b/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; } diff --git a/src/core/unix/SDL_gtk.h b/src/core/unix/SDL_gtk.h index 0287fe0b8f..7318ee31cf 100644 --- a/src/core/unix/SDL_gtk.h +++ b/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);