early-access version 1780
This commit is contained in:
@@ -428,6 +428,23 @@ static SDL_MOUSE_EVENT_SOURCE GetMouseMessageSource()
|
||||
return SDL_MOUSE_EVENT_SOURCE_MOUSE;
|
||||
}
|
||||
|
||||
static SDL_WindowData *
|
||||
WIN_GetWindowDataFromHWND(HWND hwnd)
|
||||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
SDL_Window *window;
|
||||
|
||||
if (_this) {
|
||||
for (window = _this->windows; window; window = window->next) {
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
if (data && data->hwnd == hwnd) {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
@@ -510,7 +527,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
|
||||
/* Get the window data for the window */
|
||||
data = (SDL_WindowData *) GetProp(hwnd, TEXT("SDL_WindowData"));
|
||||
data = WIN_GetWindowDataFromHWND(hwnd);
|
||||
if (!data) {
|
||||
/* Fallback */
|
||||
data = (SDL_WindowData *) GetProp(hwnd, TEXT("SDL_WindowData"));
|
||||
}
|
||||
if (!data) {
|
||||
return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam);
|
||||
}
|
||||
@@ -693,8 +714,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
/* Mouse data (ignoring synthetic mouse events generated for touchscreens) */
|
||||
if (inp.header.dwType == RIM_TYPEMOUSE) {
|
||||
if (GetMouseMessageSource() == SDL_MOUSE_EVENT_SOURCE_TOUCH ||
|
||||
(GetMessageExtraInfo() & 0x82) == 0x82) {
|
||||
if (SDL_GetNumTouchDevices() > 0 &&
|
||||
(GetMouseMessageSource() == SDL_MOUSE_EVENT_SOURCE_TOUCH || (GetMessageExtraInfo() & 0x82) == 0x82)) {
|
||||
break;
|
||||
}
|
||||
if (isRelative) {
|
||||
@@ -1255,6 +1276,49 @@ void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata)
|
||||
g_WindowsMessageHookData = userdata;
|
||||
}
|
||||
|
||||
int
|
||||
WIN_WaitEventTimeout(_THIS, int timeout)
|
||||
{
|
||||
MSG msg;
|
||||
if (g_WindowsEnableMessageLoop) {
|
||||
BOOL message_result;
|
||||
UINT_PTR timer_id = 0;
|
||||
if (timeout > 0) {
|
||||
timer_id = SetTimer(NULL, 0, timeout, NULL);
|
||||
message_result = GetMessage(&msg, 0, 0, 0);
|
||||
KillTimer(NULL, timer_id);
|
||||
} else if (timeout == 0) {
|
||||
message_result = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
|
||||
} else {
|
||||
message_result = GetMessage(&msg, 0, 0, 0);
|
||||
}
|
||||
if (message_result) {
|
||||
if (msg.message == WM_TIMER && msg.hwnd == NULL && msg.wParam == timer_id) {
|
||||
return 0;
|
||||
}
|
||||
if (g_WindowsMessageHook) {
|
||||
g_WindowsMessageHook(g_WindowsMessageHookData, msg.hwnd, msg.message, msg.wParam, msg.lParam);
|
||||
}
|
||||
/* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
/* Fail the wait so the caller falls back to polling */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WIN_SendWakeupEvent(_THIS, SDL_Window *window)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
PostMessage(data->hwnd, data->videodata->_SDL_WAKEUP, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
WIN_PumpEvents(_THIS)
|
||||
{
|
||||
|
@@ -31,6 +31,8 @@ extern LRESULT CALLBACK WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lP
|
||||
extern LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
extern void WIN_PumpEvents(_THIS);
|
||||
extern void WIN_SendWakeupEvent(_THIS, SDL_Window *window);
|
||||
extern int WIN_WaitEventTimeout(_THIS, int timeout);
|
||||
|
||||
#endif /* SDL_windowsevents_h_ */
|
||||
|
||||
|
@@ -87,7 +87,9 @@ WIN_DeleteDevice(SDL_VideoDevice * device)
|
||||
if (data->shcoreDLL) {
|
||||
SDL_UnloadObject(data->shcoreDLL);
|
||||
}
|
||||
|
||||
if (device->wakeup_lock) {
|
||||
SDL_DestroyMutex(device->wakeup_lock);
|
||||
}
|
||||
SDL_free(device->driverdata);
|
||||
SDL_free(device);
|
||||
}
|
||||
@@ -113,6 +115,7 @@ WIN_CreateDevice(int devindex)
|
||||
return NULL;
|
||||
}
|
||||
device->driverdata = data;
|
||||
device->wakeup_lock = SDL_CreateMutex();
|
||||
|
||||
data->userDLL = SDL_LoadObject("USER32.DLL");
|
||||
if (data->userDLL) {
|
||||
@@ -139,6 +142,8 @@ WIN_CreateDevice(int devindex)
|
||||
device->GetDisplayModes = WIN_GetDisplayModes;
|
||||
device->SetDisplayMode = WIN_SetDisplayMode;
|
||||
device->PumpEvents = WIN_PumpEvents;
|
||||
device->WaitEventTimeout = WIN_WaitEventTimeout;
|
||||
device->SendWakeupEvent = WIN_SendWakeupEvent;
|
||||
device->SuspendScreenSaver = WIN_SuspendScreenSaver;
|
||||
|
||||
device->CreateSDLWindow = WIN_CreateWindow;
|
||||
@@ -171,6 +176,7 @@ WIN_CreateDevice(int devindex)
|
||||
device->OnWindowEnter = WIN_OnWindowEnter;
|
||||
device->SetWindowHitTest = WIN_SetWindowHitTest;
|
||||
device->AcceptDragAndDrop = WIN_AcceptDragAndDrop;
|
||||
device->FlashWindow = WIN_FlashWindow;
|
||||
|
||||
device->shape_driver.CreateShaper = Win32_CreateShaper;
|
||||
device->shape_driver.SetWindowShape = Win32_SetWindowShape;
|
||||
@@ -226,6 +232,8 @@ VideoBootStrap WINDOWS_bootstrap = {
|
||||
int
|
||||
WIN_VideoInit(_THIS)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (WIN_InitModes(_this) < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -236,6 +244,8 @@ WIN_VideoInit(_THIS)
|
||||
SDL_AddHintCallback(SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP, UpdateWindowsEnableMessageLoop, NULL);
|
||||
SDL_AddHintCallback(SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN, UpdateWindowFrameUsableWhileCursorHidden, NULL);
|
||||
|
||||
data->_SDL_WAKEUP = RegisterWindowMessageA("_SDL_WAKEUP");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -190,6 +190,7 @@ typedef struct SDL_VideoData
|
||||
TSFSink *ime_ippasink;
|
||||
|
||||
BYTE pre_hook_key_state[256];
|
||||
UINT _SDL_WAKEUP;
|
||||
} SDL_VideoData;
|
||||
|
||||
extern SDL_bool g_WindowsEnableMessageLoop;
|
||||
|
@@ -1084,6 +1084,24 @@ WIN_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept)
|
||||
DragAcceptFiles(data->hwnd, accept ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
int
|
||||
WIN_FlashWindow(_THIS, SDL_Window * window, Uint32 flash_count)
|
||||
{
|
||||
HWND hwnd;
|
||||
FLASHWINFO desc;
|
||||
|
||||
hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
desc.cbSize = sizeof(desc);
|
||||
desc.hwnd = hwnd;
|
||||
desc.dwFlags = FLASHW_TRAY;
|
||||
desc.uCount = flash_count; /* flash x times */
|
||||
desc.dwTimeout = 0;
|
||||
|
||||
FlashWindowEx(&desc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
@@ -86,6 +86,7 @@ extern void WIN_OnWindowEnter(_THIS, SDL_Window * window);
|
||||
extern void WIN_UpdateClipCursor(SDL_Window *window);
|
||||
extern int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
|
||||
extern void WIN_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept);
|
||||
extern int WIN_FlashWindow(_THIS, SDL_Window * window, Uint32 flash_count);
|
||||
|
||||
#endif /* SDL_windowswindow_h_ */
|
||||
|
||||
|
Reference in New Issue
Block a user