mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-29 04:21:03 +08:00
Added GDK app constrained/unconstrained events (#9608)
This commit is contained in:
@@ -36,6 +36,7 @@ extern "C" {
|
|||||||
static XTaskQueueHandle GDK_GlobalTaskQueue;
|
static XTaskQueueHandle GDK_GlobalTaskQueue;
|
||||||
|
|
||||||
PAPPSTATE_REGISTRATION hPLM = {};
|
PAPPSTATE_REGISTRATION hPLM = {};
|
||||||
|
PAPPCONSTRAIN_REGISTRATION hCPLM = {};
|
||||||
HANDLE plmSuspendComplete = nullptr;
|
HANDLE plmSuspendComplete = nullptr;
|
||||||
|
|
||||||
extern "C" DECLSPEC int
|
extern "C" DECLSPEC int
|
||||||
@@ -177,6 +178,23 @@ SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved)
|
|||||||
return -1;
|
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");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Run the application main() code */
|
/* Run the application main() code */
|
||||||
result = mainFunction(argc, argv);
|
result = mainFunction(argc, argv);
|
||||||
|
|
||||||
@@ -184,6 +202,9 @@ SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved)
|
|||||||
UnregisterAppStateChangeNotification(hPLM);
|
UnregisterAppStateChangeNotification(hPLM);
|
||||||
CloseHandle(plmSuspendComplete);
|
CloseHandle(plmSuspendComplete);
|
||||||
|
|
||||||
|
/* Unregister constrain/unconstrain handling */
|
||||||
|
UnregisterAppConstrainedChangeNotification(hCPLM);
|
||||||
|
|
||||||
/* !!! FIXME: This follows the docs exactly, but for some reason still leaks handles on exit? */
|
/* !!! FIXME: This follows the docs exactly, but for some reason still leaks handles on exit? */
|
||||||
/* Terminate the task queue and dispatch any pending tasks */
|
/* Terminate the task queue and dispatch any pending tasks */
|
||||||
XTaskQueueTerminate(taskQueue, false, nullptr, nullptr);
|
XTaskQueueTerminate(taskQueue, false, nullptr, nullptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user