Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Mouse events now report the correct window id and window enter/leave …
Browse files Browse the repository at this point in the history
…events are now reported.
  • Loading branch information
pendletonrc committed Jun 11, 2009
1 parent 0f7d48b commit b01978f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/events/SDL_mouse.c
Expand Up @@ -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;
Expand Down
27 changes: 18 additions & 9 deletions src/video/x11/SDL_x11events.c
Expand Up @@ -83,19 +83,23 @@ 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)
printf("Mode: NotifyUngrab\n");
#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
}
}
Expand All @@ -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)
Expand All @@ -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
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/video/x11/SDL_x11mouse.c
Expand Up @@ -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;
Expand Down

0 comments on commit b01978f

Please sign in to comment.