The mouse position is relative to the client window.
Fixed setting the mouse focus when the mouse enters/leaves the window. --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403436
This commit is contained in:
parent
4a241fd21e
commit
dd23674bb7
3 changed files with 19 additions and 11 deletions
|
@ -221,6 +221,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
const RAWMOUSE *raw_mouse = NULL;
|
const RAWMOUSE *raw_mouse = NULL;
|
||||||
POINT point;
|
POINT point;
|
||||||
USHORT flags;
|
USHORT flags;
|
||||||
|
int w, h;
|
||||||
|
|
||||||
/* we're collecting data from the mouse */
|
/* we're collecting data from the mouse */
|
||||||
GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size,
|
GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size,
|
||||||
|
@ -241,6 +242,16 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
/* FIXME: Doesn't this defeat the point of using raw input? */
|
/* FIXME: Doesn't this defeat the point of using raw input? */
|
||||||
GetCursorPos(&point);
|
GetCursorPos(&point);
|
||||||
|
ScreenToClient(hwnd, &point);
|
||||||
|
|
||||||
|
SDL_GetWindowSize(data->windowID, &w, &h);
|
||||||
|
if (point.x >= 0 && point.y >= 0 && point.x < w && point.y < h) {
|
||||||
|
SDL_SetMouseFocus(index, data->windowID);
|
||||||
|
} else {
|
||||||
|
SDL_SetMouseFocus(index, 0);
|
||||||
|
/* FIXME: Should we be doing anything else here? */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* if the message was sent by a tablet we have to send also pressure */
|
/* if the message was sent by a tablet we have to send also pressure */
|
||||||
if (index == tablet) {
|
if (index == tablet) {
|
||||||
|
@ -286,14 +297,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
case WM_MOUSELEAVE:
|
case WM_MOUSELEAVE:
|
||||||
{
|
{
|
||||||
int index;
|
int i;
|
||||||
SDL_Mouse *mouse;
|
|
||||||
|
|
||||||
index = data->videodata->mouse;
|
for (i = 0; i < SDL_GetNumMice(); ++i) {
|
||||||
mouse = SDL_GetMouse(index);
|
SDL_Mouse *mouse = SDL_GetMouse(i);
|
||||||
|
|
||||||
if (mouse->focus == data->windowID) {
|
if (mouse->focus == data->windowID) {
|
||||||
SDL_SetMouseFocus(index, 0);
|
SDL_SetMouseFocus(i, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
@ -175,11 +175,9 @@ WIN_InitMouse(_THIS)
|
||||||
int cursors;
|
int cursors;
|
||||||
data->WTInfoA(WTI_DEVICES, DVC_NPRESSURE, &pressure);
|
data->WTInfoA(WTI_DEVICES, DVC_NPRESSURE, &pressure);
|
||||||
data->WTInfoA(WTI_DEVICES, DVC_NCSRTYPES, &cursors);
|
data->WTInfoA(WTI_DEVICES, DVC_NCSRTYPES, &cursors);
|
||||||
data->mouse =
|
SDL_AddMouse(&mouse, device_name, pressure.axMax, pressure.axMin, cursors);
|
||||||
SDL_AddMouse(&mouse, device_name, pressure.axMax,
|
|
||||||
pressure.axMin, cursors);
|
|
||||||
} else {
|
} else {
|
||||||
data->mouse = SDL_AddMouse(&mouse, device_name, 0, 0, 1);
|
SDL_AddMouse(&mouse, device_name, 0, 0, 1);
|
||||||
}
|
}
|
||||||
++index;
|
++index;
|
||||||
SDL_free(buffer);
|
SDL_free(buffer);
|
||||||
|
|
|
@ -75,7 +75,6 @@ typedef struct SDL_VideoData
|
||||||
BOOL (*WTClose) (HCTX);
|
BOOL (*WTClose) (HCTX);
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
int mouse;
|
|
||||||
int keyboard;
|
int keyboard;
|
||||||
SDL_scancode *key_layout;
|
SDL_scancode *key_layout;
|
||||||
} SDL_VideoData;
|
} SDL_VideoData;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue