|
@@ -21,6 +21,7 @@
|
|
|
#include "SDL_internal.h"
|
|
|
|
|
|
extern "C" {
|
|
|
+#include "../../core/gdk/SDL_gdk.h"
|
|
|
#include "../../core/windows/SDL_windows.h"
|
|
|
#include "../../events/SDL_events_c.h"
|
|
|
}
|
|
@@ -105,58 +106,14 @@ int SDL_RunApp(int, char**, SDL_main_func mainFunction, void *reserved)
|
|
|
|
|
|
SDL_SetMainReady();
|
|
|
|
|
|
- /* Register suspend/resume handling */
|
|
|
- plmSuspendComplete = CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE);
|
|
|
- if (!plmSuspendComplete) {
|
|
|
- SDL_SetError("[GDK] Unable to create plmSuspendComplete event");
|
|
|
- return -1;
|
|
|
- }
|
|
|
- auto rascn = [](BOOLEAN quiesced, PVOID context) {
|
|
|
- SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppStateChangeNotification handler");
|
|
|
- if (quiesced) {
|
|
|
- ResetEvent(plmSuspendComplete);
|
|
|
- SDL_SendAppEvent(SDL_EVENT_DID_ENTER_BACKGROUND);
|
|
|
-
|
|
|
- // To defer suspension, we must wait to exit this callback.
|
|
|
- // IMPORTANT: The app must call SDL_GDKSuspendComplete() to release this lock.
|
|
|
- (void)WaitForSingleObject(plmSuspendComplete, INFINITE);
|
|
|
-
|
|
|
- SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppStateChangeNotification handler: plmSuspendComplete event signaled.");
|
|
|
- } else {
|
|
|
- SDL_SendAppEvent(SDL_EVENT_WILL_ENTER_FOREGROUND);
|
|
|
- }
|
|
|
- };
|
|
|
- if (RegisterAppStateChangeNotification(rascn, NULL, &hPLM)) {
|
|
|
- SDL_SetError("[GDK] Unable to call RegisterAppStateChangeNotification");
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- /* Register constrain/unconstrain handling */
|
|
|
- auto raccn = [](BOOLEAN constrained, PVOID context) {
|
|
|
- SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppConstrainedChangeNotification handler");
|
|
|
- SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
|
|
- if (_this) {
|
|
|
- if (constrained) {
|
|
|
- SDL_SetKeyboardFocus(NULL);
|
|
|
- } else {
|
|
|
- SDL_SetKeyboardFocus(_this->windows);
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- if (RegisterAppConstrainedChangeNotification(raccn, NULL, &hCPLM)) {
|
|
|
- SDL_SetError("[GDK] Unable to call RegisterAppConstrainedChangeNotification");
|
|
|
+ if (GDK_RegisterChangeNotifications() != 0) {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
/* Run the application main() code */
|
|
|
result = mainFunction(argc, argv);
|
|
|
|
|
|
- /* Unregister suspend/resume handling */
|
|
|
- UnregisterAppStateChangeNotification(hPLM);
|
|
|
- CloseHandle(plmSuspendComplete);
|
|
|
-
|
|
|
- /* Unregister constrain/unconstrain handling */
|
|
|
- UnregisterAppConstrainedChangeNotification(hCPLM);
|
|
|
+ GDK_UnregisterChangeNotifications();
|
|
|
|
|
|
/* !!! FIXME: This follows the docs exactly, but for some reason still leaks handles on exit? */
|
|
|
/* Terminate the task queue and dispatch any pending tasks */
|