[win32] Track mouse leave messages

Bug 1178 - No enter / leave events on actors when pointer leaves the
           stage window

This patch causes the Win32 backend to emit CLUTTER_LEAVE events when
a WM_MOUSELEAVE event is received in the same way that f505536 does
for the X11 backend.

Windows will only send WM_MOUSELEAVE events if they are previously
requested using TrackMouseEvent so this needs to be called whenever
the mouse enters the window. There is no WM_MOUSELEAVE event but we
can detect when the mouse enters because we get a WM_MOUSEMOVE event.
This commit is contained in:
Neil Roberts 2009-02-16 12:46:00 +00:00
parent 9e10dc402f
commit 1fcddb3b10
2 changed files with 26 additions and 0 deletions

View File

@ -502,6 +502,31 @@ message_translate (ClutterBackend *backend,
event->motion.x = GET_X_LPARAM (msg->lParam); event->motion.x = GET_X_LPARAM (msg->lParam);
event->motion.y = GET_Y_LPARAM (msg->lParam); event->motion.y = GET_Y_LPARAM (msg->lParam);
event->motion.modifier_state = get_modifier_state (msg->wParam); event->motion.modifier_state = get_modifier_state (msg->wParam);
/* We need to start tracking when the mouse leaves the stage if
we're not already */
if (!stage_win32->tracking_mouse)
{
TRACKMOUSEEVENT tmevent;
tmevent.cbSize = sizeof (tmevent);
tmevent.dwFlags = TME_LEAVE;
tmevent.hwndTrack = stage_win32->hwnd;
TrackMouseEvent (&tmevent);
stage_win32->tracking_mouse = TRUE;
}
break;
case WM_MOUSELEAVE:
event->crossing.type = CLUTTER_LEAVE;
event->crossing.time = msg->time;
event->crossing.x = msg->pt.x;
event->crossing.y = msg->pt.y;
/* When we get a leave message the mouse tracking is
automatically cancelled so we'll need to start it again when
the mouse next enters the window */
stage_win32->tracking_mouse = FALSE;
break; break;
case WM_KEYDOWN: case WM_KEYDOWN:

View File

@ -51,6 +51,7 @@ struct _ClutterStageWin32
gint scroll_pos; gint scroll_pos;
RECT fullscreen_rect; RECT fullscreen_rect;
gboolean is_foreign_win; gboolean is_foreign_win;
gboolean tracking_mouse;
ClutterBackendWin32 *backend; ClutterBackendWin32 *backend;
ClutterStageState state; ClutterStageState state;