comparison src/video/win32/SDL_win32events.c @ 2974:d2f68ec8c1d0

The mouse position is relative to the client window. Fixed setting the mouse focus when the mouse enters/leaves the window.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 03 Jan 2009 06:03:56 +0000
parents bd518fc76f28
children 317b2f8e5e4f
comparison
equal deleted inserted replaced
2973:ab0c00f1b070 2974:d2f68ec8c1d0
219 int i; 219 int i;
220 int size = 0; 220 int size = 0;
221 const RAWMOUSE *raw_mouse = NULL; 221 const RAWMOUSE *raw_mouse = NULL;
222 POINT point; 222 POINT point;
223 USHORT flags; 223 USHORT flags;
224 int w, h;
224 225
225 /* we're collecting data from the mouse */ 226 /* we're collecting data from the mouse */
226 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size, 227 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size,
227 sizeof(RAWINPUTHEADER)); 228 sizeof(RAWINPUTHEADER));
228 lpb = SDL_stack_alloc(BYTE, size); 229 lpb = SDL_stack_alloc(BYTE, size);
239 break; 240 break;
240 } 241 }
241 } 242 }
242 /* FIXME: Doesn't this defeat the point of using raw input? */ 243 /* FIXME: Doesn't this defeat the point of using raw input? */
243 GetCursorPos(&point); 244 GetCursorPos(&point);
245 ScreenToClient(hwnd, &point);
246
247 SDL_GetWindowSize(data->windowID, &w, &h);
248 if (point.x >= 0 && point.y >= 0 && point.x < w && point.y < h) {
249 SDL_SetMouseFocus(index, data->windowID);
250 } else {
251 SDL_SetMouseFocus(index, 0);
252 /* FIXME: Should we be doing anything else here? */
253 break;
254 }
244 255
245 /* if the message was sent by a tablet we have to send also pressure */ 256 /* if the message was sent by a tablet we have to send also pressure */
246 if (index == tablet) { 257 if (index == tablet) {
247 SDL_SendMouseMotion(index, 0, point.x, point.y, pressure); 258 SDL_SendMouseMotion(index, 0, point.x, point.y, pressure);
248 } else { 259 } else {
284 } 295 }
285 return (0); 296 return (0);
286 297
287 case WM_MOUSELEAVE: 298 case WM_MOUSELEAVE:
288 { 299 {
289 int index; 300 int i;
290 SDL_Mouse *mouse; 301
291 302 for (i = 0; i < SDL_GetNumMice(); ++i) {
292 index = data->videodata->mouse; 303 SDL_Mouse *mouse = SDL_GetMouse(i);
293 mouse = SDL_GetMouse(index); 304
294 305 if (mouse->focus == data->windowID) {
295 if (mouse->focus == data->windowID) { 306 SDL_SetMouseFocus(i, 0);
296 SDL_SetMouseFocus(index, 0); 307 }
297 } 308 }
298 } 309 }
299 return (0); 310 return (0);
300 311
301 case WM_SYSKEYDOWN: 312 case WM_SYSKEYDOWN: