move SDL_HelperWindow outside of video
move to SDL_window.c to prevent relying on SDL_VIDEO
This commit is contained in:
committed by
Sam Lantinga
parent
5e787555e8
commit
a190e3b514
@@ -53,6 +53,78 @@ typedef enum RO_INIT_TYPE
|
|||||||
#define WC_ERR_INVALID_CHARS 0x00000080
|
#define WC_ERR_INVALID_CHARS 0x00000080
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Fake window to help with DirectInput events.
|
||||||
|
HWND SDL_HelperWindow = NULL;
|
||||||
|
static const TCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher");
|
||||||
|
static const TCHAR *SDL_HelperWindowName = TEXT("SDLHelperWindowInputMsgWindow");
|
||||||
|
static ATOM SDL_HelperWindowClass = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a HelperWindow used for DirectInput.
|
||||||
|
*/
|
||||||
|
bool SDL_HelperWindowCreate(void)
|
||||||
|
{
|
||||||
|
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||||
|
WNDCLASS wce;
|
||||||
|
|
||||||
|
// Make sure window isn't created twice.
|
||||||
|
if (SDL_HelperWindow != NULL) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the class.
|
||||||
|
SDL_zero(wce);
|
||||||
|
wce.lpfnWndProc = DefWindowProc;
|
||||||
|
wce.lpszClassName = SDL_HelperWindowClassName;
|
||||||
|
wce.hInstance = hInstance;
|
||||||
|
|
||||||
|
// Register the class.
|
||||||
|
SDL_HelperWindowClass = RegisterClass(&wce);
|
||||||
|
if (SDL_HelperWindowClass == 0 && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) {
|
||||||
|
return WIN_SetError("Unable to create Helper Window Class");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the window.
|
||||||
|
SDL_HelperWindow = CreateWindowEx(0, SDL_HelperWindowClassName,
|
||||||
|
SDL_HelperWindowName,
|
||||||
|
WS_OVERLAPPED, CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT, HWND_MESSAGE, NULL,
|
||||||
|
hInstance, NULL);
|
||||||
|
if (!SDL_HelperWindow) {
|
||||||
|
UnregisterClass(SDL_HelperWindowClassName, hInstance);
|
||||||
|
return WIN_SetError("Unable to create Helper Window");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Destroys the HelperWindow previously created with SDL_HelperWindowCreate.
|
||||||
|
*/
|
||||||
|
void SDL_HelperWindowDestroy(void)
|
||||||
|
{
|
||||||
|
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||||
|
|
||||||
|
// Destroy the window.
|
||||||
|
if (SDL_HelperWindow != NULL) {
|
||||||
|
if (DestroyWindow(SDL_HelperWindow) == 0) {
|
||||||
|
WIN_SetError("Unable to destroy Helper Window");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SDL_HelperWindow = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unregister the class.
|
||||||
|
if (SDL_HelperWindowClass != 0) {
|
||||||
|
if ((UnregisterClass(SDL_HelperWindowClassName, hInstance)) == 0) {
|
||||||
|
WIN_SetError("Unable to destroy Helper Window Class");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SDL_HelperWindowClass = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Sets an error message based on an HRESULT
|
// Sets an error message based on an HRESULT
|
||||||
bool WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
|
bool WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -96,12 +96,6 @@ typedef void (NTAPI *RtlGetVersion_t)(NT_OSVERSIONINFOW *);
|
|||||||
|
|
||||||
// #define HIGHDPI_DEBUG
|
// #define HIGHDPI_DEBUG
|
||||||
|
|
||||||
// Fake window to help with DirectInput events.
|
|
||||||
HWND SDL_HelperWindow = NULL;
|
|
||||||
static const TCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher");
|
|
||||||
static const TCHAR *SDL_HelperWindowName = TEXT("SDLHelperWindowInputMsgWindow");
|
|
||||||
static ATOM SDL_HelperWindowClass = 0;
|
|
||||||
|
|
||||||
/* For borderless Windows, still want the following flag:
|
/* For borderless Windows, still want the following flag:
|
||||||
- WS_MINIMIZEBOX: window will respond to Windows minimize commands sent to all windows, such as windows key + m, shaking title bar, etc.
|
- WS_MINIMIZEBOX: window will respond to Windows minimize commands sent to all windows, such as windows key + m, shaking title bar, etc.
|
||||||
Additionally, non-fullscreen windows can add:
|
Additionally, non-fullscreen windows can add:
|
||||||
@@ -1538,72 +1532,6 @@ void WIN_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
|||||||
CleanupWindowData(_this, window);
|
CleanupWindowData(_this, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Creates a HelperWindow used for DirectInput.
|
|
||||||
*/
|
|
||||||
bool SDL_HelperWindowCreate(void)
|
|
||||||
{
|
|
||||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
|
||||||
WNDCLASS wce;
|
|
||||||
|
|
||||||
// Make sure window isn't created twice.
|
|
||||||
if (SDL_HelperWindow != NULL) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the class.
|
|
||||||
SDL_zero(wce);
|
|
||||||
wce.lpfnWndProc = DefWindowProc;
|
|
||||||
wce.lpszClassName = SDL_HelperWindowClassName;
|
|
||||||
wce.hInstance = hInstance;
|
|
||||||
|
|
||||||
// Register the class.
|
|
||||||
SDL_HelperWindowClass = RegisterClass(&wce);
|
|
||||||
if (SDL_HelperWindowClass == 0 && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) {
|
|
||||||
return WIN_SetError("Unable to create Helper Window Class");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the window.
|
|
||||||
SDL_HelperWindow = CreateWindowEx(0, SDL_HelperWindowClassName,
|
|
||||||
SDL_HelperWindowName,
|
|
||||||
WS_OVERLAPPED, CW_USEDEFAULT,
|
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
||||||
CW_USEDEFAULT, HWND_MESSAGE, NULL,
|
|
||||||
hInstance, NULL);
|
|
||||||
if (!SDL_HelperWindow) {
|
|
||||||
UnregisterClass(SDL_HelperWindowClassName, hInstance);
|
|
||||||
return WIN_SetError("Unable to create Helper Window");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Destroys the HelperWindow previously created with SDL_HelperWindowCreate.
|
|
||||||
*/
|
|
||||||
void SDL_HelperWindowDestroy(void)
|
|
||||||
{
|
|
||||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
|
||||||
|
|
||||||
// Destroy the window.
|
|
||||||
if (SDL_HelperWindow != NULL) {
|
|
||||||
if (DestroyWindow(SDL_HelperWindow) == 0) {
|
|
||||||
WIN_SetError("Unable to destroy Helper Window");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SDL_HelperWindow = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unregister the class.
|
|
||||||
if (SDL_HelperWindowClass != 0) {
|
|
||||||
if ((UnregisterClass(SDL_HelperWindowClassName, hInstance)) == 0) {
|
|
||||||
WIN_SetError("Unable to destroy Helper Window Class");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SDL_HelperWindowClass = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
||||||
void WIN_OnWindowEnter(SDL_VideoDevice *_this, SDL_Window *window)
|
void WIN_OnWindowEnter(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user