From b01978f31e2a0825ec8ce70d99417495b24765bb Mon Sep 17 00:00:00 2001 From: Bob Pendleton Date: Thu, 11 Jun 2009 20:08:33 +0000 Subject: [PATCH] Mouse events now report the correct window id and window enter/leave events are now reported. --- src/events/SDL_mouse.c | 1 + src/video/x11/SDL_x11events.c | 27 ++++++++++++++++++--------- src/video/x11/SDL_x11mouse.c | 2 ++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 05fa358b2..1ef941763 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -97,6 +97,7 @@ SDL_AddMouse(const SDL_Mouse * mouse, char *name, int pressure_max, /* we're setting the mouse properties */ length = 0; length = SDL_strlen(name); + SDL_mice[index]->focus = 0; SDL_mice[index]->name = SDL_malloc((length + 2) * sizeof(char)); SDL_strlcpy(SDL_mice[index]->name, name, length + 1); SDL_mice[index]->pressure_max = pressure_max; diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index e4dc9998d..78f484272 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -83,8 +83,10 @@ X11_DispatchEvent(_THIS) /* Gaining mouse coverage? */ case EnterNotify:{ #ifdef DEBUG_XEVENTS - printf("EnterNotify! (%d,%d)\n", xevent.xcrossing.x, - xevent.xcrossing.y); + printf("EnterNotify! (%d,%d,%d)\n", + xevent.xcrossing.x, + xevent.xcrossing.y, + xevent.xcrossing.mode); if (xevent.xcrossing.mode == NotifyGrab) printf("Mode: NotifyGrab\n"); if (xevent.xcrossing.mode == NotifyUngrab) @@ -92,10 +94,12 @@ X11_DispatchEvent(_THIS) #endif if ((xevent.xcrossing.mode != NotifyGrab) && (xevent.xcrossing.mode != NotifyUngrab)) { +#if 1 /* FIXME: Should we reset data for all mice? */ -#if 0 - SDL_SetMouseFocus(0, data->windowID); - SDL_SendMouseMotion(0, 0, move->x, move->y, 0); + for (i = 0; i < SDL_GetNumMice(); ++i) { + SDL_Mouse *mouse = SDL_GetMouse(i); + SDL_SetMouseFocus(mouse->id, data->windowID); + } #endif } } @@ -104,8 +108,10 @@ X11_DispatchEvent(_THIS) /* Losing mouse coverage? */ case LeaveNotify:{ #ifdef DEBUG_XEVENTS - printf("LeaveNotify! (%d,%d)\n", xevent.xcrossing.x, - xevent.xcrossing.y); + printf("LeaveNotify! (%d,%d,%d)\n", + xevent.xcrossing.x, + xevent.xcrossing.y, + xevent.xcrossing.mode); if (xevent.xcrossing.mode == NotifyGrab) printf("Mode: NotifyGrab\n"); if (xevent.xcrossing.mode == NotifyUngrab) @@ -114,9 +120,12 @@ X11_DispatchEvent(_THIS) if ((xevent.xcrossing.mode != NotifyGrab) && (xevent.xcrossing.mode != NotifyUngrab) && (xevent.xcrossing.detail != NotifyInferior)) { +#if 1 /* FIXME: Should we reset data for all mice? */ -#if 0 - SDL_SetMouseFocus(0, 0); + for (i = 0; i < SDL_GetNumMice(); ++i) { + SDL_Mouse *mouse = SDL_GetMouse(i); + SDL_SetMouseFocus(mouse->id, 0); + } #endif } } diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 0ddc04bbb..8efaf75c9 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -52,6 +52,8 @@ X11_InitMouse(_THIS) #endif int num_mice = 0; + SDL_zero(mouse); + #if SDL_VIDEO_DRIVER_X11_XINPUT /* we're getting the list of input devices */ n = 0;