mirror of https://github.com/encounter/SDL.git
Cleanup windows events after recent changes
Improves clarity without any functional changes
This commit is contained in:
parent
50f969c1b2
commit
06824b18fd
|
@ -381,7 +381,7 @@ WIN_UpdateFocus(SDL_Window *window)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetForegroundWindow() == hwnd) {
|
if (has_focus) {
|
||||||
POINT cursorPos;
|
POINT cursorPos;
|
||||||
|
|
||||||
SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
|
SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
|
||||||
|
@ -723,10 +723,9 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
HRAWINPUT hRawInput = (HRAWINPUT)lParam;
|
HRAWINPUT hRawInput = (HRAWINPUT)lParam;
|
||||||
RAWINPUT inp;
|
RAWINPUT inp;
|
||||||
UINT size = sizeof(inp);
|
UINT size = sizeof(inp);
|
||||||
const SDL_bool isRelative = mouse->relative_mode || mouse->relative_mode_warp;
|
|
||||||
|
|
||||||
/* Relative mouse motion is delivered to the window with keyboard focus */
|
/* Relative mouse motion is delivered to the window with keyboard focus */
|
||||||
if (!isRelative || data->window != SDL_GetKeyboardFocus()) {
|
if ((!mouse->relative_mode && !mouse->relative_mode_warp) || data->window != SDL_GetKeyboardFocus()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,17 +734,16 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
/* Mouse data (ignoring synthetic mouse events generated for touchscreens) */
|
/* Mouse data (ignoring synthetic mouse events generated for touchscreens) */
|
||||||
if (inp.header.dwType == RIM_TYPEMOUSE) {
|
if (inp.header.dwType == RIM_TYPEMOUSE) {
|
||||||
SDL_MouseID mouseID;
|
SDL_MouseID mouseID;
|
||||||
|
RAWMOUSE* rawmouse;
|
||||||
if (SDL_GetNumTouchDevices() > 0 &&
|
if (SDL_GetNumTouchDevices() > 0 &&
|
||||||
(GetMouseMessageSource() == SDL_MOUSE_EVENT_SOURCE_TOUCH || (GetMessageExtraInfo() & 0x82) == 0x82)) {
|
(GetMouseMessageSource() == SDL_MOUSE_EVENT_SOURCE_TOUCH || (GetMessageExtraInfo() & 0x82) == 0x82)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mouseID = (SDL_MouseID)(uintptr_t)inp.header.hDevice;
|
mouseID = (SDL_MouseID)(uintptr_t)inp.header.hDevice;
|
||||||
if (isRelative) {
|
rawmouse = &inp.data.mouse;
|
||||||
RAWMOUSE* rawmouse = &inp.data.mouse;
|
|
||||||
|
|
||||||
if ((rawmouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) {
|
if ((rawmouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) {
|
||||||
SDL_SendMouseMotion(data->window, mouseID, 1, (int)rawmouse->lLastX, (int)rawmouse->lLastY);
|
SDL_SendMouseMotion(data->window, mouseID, 1, (int)rawmouse->lLastX, (int)rawmouse->lLastY);
|
||||||
|
|
||||||
} else if (rawmouse->lLastX || rawmouse->lLastY) {
|
} else if (rawmouse->lLastX || rawmouse->lLastY) {
|
||||||
/* This is absolute motion, either using a tablet or mouse over RDP
|
/* This is absolute motion, either using a tablet or mouse over RDP
|
||||||
|
|
||||||
|
@ -819,10 +817,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
data->last_raw_mouse_position.y = y;
|
data->last_raw_mouse_position.y = y;
|
||||||
}
|
}
|
||||||
WIN_CheckRawMouseButtons(rawmouse->usButtonFlags, data, mouseID);
|
WIN_CheckRawMouseButtons(rawmouse->usButtonFlags, data, mouseID);
|
||||||
|
|
||||||
} else {
|
|
||||||
SDL_assert(0 && "Shouldn't happen");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -840,8 +834,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_MOUSELEAVE:
|
case WM_MOUSELEAVE:
|
||||||
if (SDL_GetMouseFocus() == data->window && !SDL_GetMouse()->relative_mode && !(data->window->flags & SDL_WINDOW_MOUSE_CAPTURE)) {
|
if (!(data->window->flags & SDL_WINDOW_MOUSE_CAPTURE)) {
|
||||||
if (!IsIconic(hwnd)) {
|
if (SDL_GetMouseFocus() == data->window && !SDL_GetMouse()->relative_mode && !IsIconic(hwnd)) {
|
||||||
SDL_Mouse *mouse;
|
SDL_Mouse *mouse;
|
||||||
POINT cursorPos;
|
POINT cursorPos;
|
||||||
GetCursorPos(&cursorPos);
|
GetCursorPos(&cursorPos);
|
||||||
|
@ -858,10 +852,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* When WM_MOUSELEAVE is fired we can be assured that the cursor has left the window */
|
/* When WM_MOUSELEAVE is fired we can be assured that the cursor has left the window */
|
||||||
if (!(data->window->flags & SDL_WINDOW_MOUSE_CAPTURE)) {
|
|
||||||
SDL_SetMouseFocus(NULL);
|
SDL_SetMouseFocus(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue