Skip to content

Commit 3c369aa

Browse files
committed
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.
1 parent d8ac518 commit 3c369aa

File tree

3 files changed

+162
-230
lines changed

3 files changed

+162
-230
lines changed

src/SDL.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
// this checks for HAVE_DBUS_DBUS_H internally.
3131
#include "core/linux/SDL_dbus.h"
3232

33+
#ifdef SDL_PLATFORM_UNIX
34+
#include "core/unix/SDL_gtk.h"
35+
#endif
36+
3337
#ifdef SDL_PLATFORM_EMSCRIPTEN
3438
#include <emscripten.h>
3539
#endif
@@ -663,6 +667,10 @@ void SDL_Quit(void)
663667
SDL_DBus_Quit();
664668
#endif
665669

670+
#ifdef SDL_PLATFORM_UNIX
671+
SDL_Gtk_Quit();
672+
#endif
673+
666674
SDL_QuitTimers();
667675
SDL_QuitAsyncIO();
668676

src/events/SDL_events.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
#include "../video/android/SDL_androidevents.h"
4343
#endif
4444

45+
#ifdef SDL_PLATFORM_UNIX
46+
#include "../core/unix/SDL_gtk.h"
47+
#endif
48+
4549
// An arbitrary limit so we don't have unbounded growth
4650
#define SDL_MAX_QUEUED_EVENTS 65535
4751

@@ -1445,6 +1449,7 @@ void SDL_PumpEventMaintenance(void)
14451449
}
14461450
#endif
14471451

1452+
// SDL_UpdateTrays will also pump GTK events if needed
14481453
SDL_UpdateTrays();
14491454

14501455
SDL_SendPendingSignalEvents(); // in case we had a signal handler fire, etc.

0 commit comments

Comments
 (0)