unix: Refactor GTK bindings from SDL_tray to separate SDL_gtk module to allow shared usage

- SDL creates and requires usage of a specific glib context. This context is set as the global
  glib context with SDL_Gtk_EnterContext and the previous context is restored with
  SDL_Gtk_ExitContext.

- To avoid changing the behavior of SDL_tray, which is the only consumer of SDL_gtk currently,
  the SDL_UpdateTray function now unconditionally runs a single glib frame iteration and is
  responsible for dispatching glib events for all consumers in SDL_PumpEvents.

- Cleaned up some error handling in SDL_tray.
This commit is contained in:
Sam Lantinga
2025-07-31 08:49:31 -07:00
parent d8ac51859e
commit 3c369aa8b4
3 changed files with 165 additions and 233 deletions

View File

@@ -30,6 +30,10 @@
// this checks for HAVE_DBUS_DBUS_H internally.
#include "core/linux/SDL_dbus.h"
#ifdef SDL_PLATFORM_UNIX
#include "core/unix/SDL_gtk.h"
#endif
#ifdef SDL_PLATFORM_EMSCRIPTEN
#include <emscripten.h>
#endif
@@ -663,6 +667,10 @@ void SDL_Quit(void)
SDL_DBus_Quit();
#endif
#ifdef SDL_PLATFORM_UNIX
SDL_Gtk_Quit();
#endif
SDL_QuitTimers();
SDL_QuitAsyncIO();