mirror of https://github.com/encounter/SDL.git
Fix: Use WIN_ClientPointToSDL for converting additional mouse coordinates
This commit is contained in:
parent
08a331847b
commit
301912a5b9
|
@ -428,9 +428,13 @@ WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus)
|
||||||
|
|
||||||
/* In relative mode we are guaranteed to have mouse focus if we have keyboard focus */
|
/* In relative mode we are guaranteed to have mouse focus if we have keyboard focus */
|
||||||
if (!SDL_GetMouse()->relative_mode) {
|
if (!SDL_GetMouse()->relative_mode) {
|
||||||
|
SDL_Point point;
|
||||||
GetCursorPos(&cursorPos);
|
GetCursorPos(&cursorPos);
|
||||||
ScreenToClient(hwnd, &cursorPos);
|
ScreenToClient(hwnd, &cursorPos);
|
||||||
SDL_SendMouseMotion(window, 0, 0, cursorPos.x, cursorPos.y);
|
point.x = cursorPos.x;
|
||||||
|
point.y = cursorPos.y;
|
||||||
|
WIN_ClientPointToSDL(data->window, &point.x, &point.y);
|
||||||
|
SDL_SendMouseMotion(window, 0, 0, point.x, point.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
WIN_CheckAsyncMouseRelease(data);
|
WIN_CheckAsyncMouseRelease(data);
|
||||||
|
@ -909,17 +913,21 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
if (SDL_GetMouseFocus() == data->window && !SDL_GetMouse()->relative_mode && !IsIconic(hwnd)) {
|
if (SDL_GetMouseFocus() == data->window && !SDL_GetMouse()->relative_mode && !IsIconic(hwnd)) {
|
||||||
SDL_Mouse *mouse;
|
SDL_Mouse *mouse;
|
||||||
POINT cursorPos;
|
POINT cursorPos;
|
||||||
|
SDL_Point point;
|
||||||
GetCursorPos(&cursorPos);
|
GetCursorPos(&cursorPos);
|
||||||
ScreenToClient(hwnd, &cursorPos);
|
ScreenToClient(hwnd, &cursorPos);
|
||||||
|
point.x = cursorPos.x;
|
||||||
|
point.y = cursorPos.y;
|
||||||
|
WIN_ClientPointToSDL(data->window, &point.x, &point.y);
|
||||||
mouse = SDL_GetMouse();
|
mouse = SDL_GetMouse();
|
||||||
if (!mouse->was_touch_mouse_events) { /* we're not a touch handler causing a mouse leave? */
|
if (!mouse->was_touch_mouse_events) { /* we're not a touch handler causing a mouse leave? */
|
||||||
SDL_SendMouseMotion(data->window, 0, 0, cursorPos.x, cursorPos.y);
|
SDL_SendMouseMotion(data->window, 0, 0, point.x, point.y);
|
||||||
} else { /* touch handling? */
|
} else { /* touch handling? */
|
||||||
mouse->was_touch_mouse_events = SDL_FALSE; /* not anymore */
|
mouse->was_touch_mouse_events = SDL_FALSE; /* not anymore */
|
||||||
if (mouse->touch_mouse_events) { /* convert touch to mouse events */
|
if (mouse->touch_mouse_events) { /* convert touch to mouse events */
|
||||||
SDL_SendMouseMotion(data->window, SDL_TOUCH_MOUSEID, 0, cursorPos.x, cursorPos.y);
|
SDL_SendMouseMotion(data->window, SDL_TOUCH_MOUSEID, 0, point.x, point.y);
|
||||||
} else { /* normal handling */
|
} else { /* normal handling */
|
||||||
SDL_SendMouseMotion(data->window, 0, 0, cursorPos.x, cursorPos.y);
|
SDL_SendMouseMotion(data->window, 0, 0, point.x, point.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1679,13 +1687,17 @@ static void WIN_UpdateMouseCapture()
|
||||||
SDL_WindowData *data = (SDL_WindowData *) focusWindow->driverdata;
|
SDL_WindowData *data = (SDL_WindowData *) focusWindow->driverdata;
|
||||||
|
|
||||||
if (!data->mouse_tracked) {
|
if (!data->mouse_tracked) {
|
||||||
POINT pt;
|
POINT cursorPos;
|
||||||
|
|
||||||
if (GetCursorPos(&pt) && ScreenToClient(data->hwnd, &pt)) {
|
if (GetCursorPos(&cursorPos) && ScreenToClient(data->hwnd, &cursorPos)) {
|
||||||
SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
|
SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
|
||||||
SDL_MouseID mouseID = SDL_GetMouse()->mouseID;
|
SDL_MouseID mouseID = SDL_GetMouse()->mouseID;
|
||||||
|
SDL_Point point;
|
||||||
|
point.x = cursorPos.x;
|
||||||
|
point.y = cursorPos.y;
|
||||||
|
WIN_ClientPointToSDL(data->window, &point.x, &point.y);
|
||||||
|
|
||||||
SDL_SendMouseMotion(data->window, mouseID, 0, (int)pt.x, (int)pt.y);
|
SDL_SendMouseMotion(data->window, mouseID, 0, point.x, point.y);
|
||||||
SDL_SendMouseButton(data->window, mouseID, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, !swapButtons ? SDL_BUTTON_LEFT : SDL_BUTTON_RIGHT);
|
SDL_SendMouseButton(data->window, mouseID, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, !swapButtons ? SDL_BUTTON_LEFT : SDL_BUTTON_RIGHT);
|
||||||
SDL_SendMouseButton(data->window, mouseID, GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, !swapButtons ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT);
|
SDL_SendMouseButton(data->window, mouseID, GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, !swapButtons ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT);
|
||||||
SDL_SendMouseButton(data->window, mouseID, GetAsyncKeyState(VK_MBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_MIDDLE);
|
SDL_SendMouseButton(data->window, mouseID, GetAsyncKeyState(VK_MBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_MIDDLE);
|
||||||
|
|
Loading…
Reference in New Issue