Merge branch 'gdk-win32-fix-mouse-move-crossing-events' into 'main'
GdkWin32: Mouse events fixes Closes #4722 and #4813 See merge request GNOME/gtk!4620
This commit is contained in:
@@ -873,6 +873,7 @@ _gdk_win32_append_event (GdkEvent *event)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GList *link;
|
||||
gulong serial;
|
||||
|
||||
display = gdk_display_get_default ();
|
||||
|
||||
@@ -880,8 +881,9 @@ _gdk_win32_append_event (GdkEvent *event)
|
||||
#if 1
|
||||
link = _gdk_event_queue_append (display, event);
|
||||
GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
|
||||
serial = _gdk_display_get_next_serial (display);
|
||||
/* event morphing, the passed in may not be valid afterwards */
|
||||
_gdk_windowing_got_event (display, link, event, 0);
|
||||
_gdk_windowing_got_event (display, link, event, serial);
|
||||
#else
|
||||
_gdk_event_queue_append (display, event);
|
||||
GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
|
||||
@@ -2242,6 +2244,10 @@ gdk_event_translate (MSG *msg,
|
||||
button = 5;
|
||||
|
||||
buttonup0:
|
||||
{
|
||||
gboolean release_implicit_grab = FALSE;
|
||||
GdkSurface *prev_surface = NULL;
|
||||
|
||||
GDK_NOTE (EVENTS,
|
||||
g_print (" (%d,%d)",
|
||||
GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
|
||||
@@ -2251,41 +2257,18 @@ gdk_event_translate (MSG *msg,
|
||||
g_set_object (&window, find_window_for_mouse_event (window, msg));
|
||||
|
||||
if (pointer_grab != NULL && pointer_grab->implicit)
|
||||
{
|
||||
int state = build_pointer_event_state (msg);
|
||||
{
|
||||
int state = build_pointer_event_state (msg);
|
||||
|
||||
/* We keep the implicit grab until no buttons at all are held down */
|
||||
if ((state & GDK_ANY_BUTTON_MASK & ~(GDK_BUTTON1_MASK << (button - 1))) == 0)
|
||||
{
|
||||
ReleaseCapture ();
|
||||
/* We keep the implicit grab until no buttons at all are held down */
|
||||
if ((state & GDK_ANY_BUTTON_MASK & ~(GDK_BUTTON1_MASK << (button - 1))) == 0)
|
||||
{
|
||||
release_implicit_grab = TRUE;
|
||||
prev_surface = pointer_grab->surface;
|
||||
}
|
||||
}
|
||||
|
||||
new_window = NULL;
|
||||
hwnd = WindowFromPoint (msg->pt);
|
||||
if (hwnd != NULL)
|
||||
{
|
||||
POINT client_pt = msg->pt;
|
||||
|
||||
ScreenToClient (hwnd, &client_pt);
|
||||
GetClientRect (hwnd, &rect);
|
||||
if (PtInRect (&rect, client_pt))
|
||||
new_window = gdk_win32_handle_table_lookup (hwnd);
|
||||
}
|
||||
|
||||
synthesize_crossing_events (display,
|
||||
_gdk_device_manager->system_pointer,
|
||||
pointer_grab->surface, new_window,
|
||||
GDK_CROSSING_UNGRAB,
|
||||
&msg->pt,
|
||||
0, /* TODO: Set right mask */
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
FALSE);
|
||||
g_set_object (&mouse_window, new_window);
|
||||
mouse_window_ignored_leave = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
generate_button_event (GDK_BUTTON_RELEASE, button,
|
||||
window, msg);
|
||||
generate_button_event (GDK_BUTTON_RELEASE, button, window, msg);
|
||||
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
|
||||
@@ -2294,8 +2277,37 @@ gdk_event_translate (MSG *msg,
|
||||
impl->drag_move_resize_context.button == button)
|
||||
gdk_win32_surface_end_move_resize_drag (window);
|
||||
|
||||
if (release_implicit_grab)
|
||||
{
|
||||
ReleaseCapture ();
|
||||
|
||||
new_window = NULL;
|
||||
hwnd = WindowFromPoint (msg->pt);
|
||||
if (hwnd != NULL)
|
||||
{
|
||||
POINT client_pt = msg->pt;
|
||||
|
||||
ScreenToClient (hwnd, &client_pt);
|
||||
GetClientRect (hwnd, &rect);
|
||||
if (PtInRect (&rect, client_pt))
|
||||
new_window = gdk_win32_handle_table_lookup (hwnd);
|
||||
}
|
||||
|
||||
synthesize_crossing_events (display,
|
||||
_gdk_device_manager->system_pointer,
|
||||
prev_surface, new_window,
|
||||
GDK_CROSSING_UNGRAB,
|
||||
&msg->pt,
|
||||
0, /* TODO: Set right mask */
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
FALSE);
|
||||
g_set_object (&mouse_window, new_window);
|
||||
mouse_window_ignored_leave = NULL;
|
||||
}
|
||||
|
||||
return_val = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
GDK_NOTE (EVENTS,
|
||||
@@ -2320,60 +2332,35 @@ gdk_event_translate (MSG *msg,
|
||||
|
||||
pen_touch_input = FALSE;
|
||||
|
||||
new_window = window;
|
||||
g_set_object (&window, find_window_for_mouse_event (window, msg));
|
||||
|
||||
if (pointer_grab != NULL)
|
||||
{
|
||||
POINT pt;
|
||||
pt = msg->pt;
|
||||
|
||||
new_window = NULL;
|
||||
hwnd = WindowFromPoint (pt);
|
||||
if (hwnd != NULL)
|
||||
{
|
||||
POINT client_pt = pt;
|
||||
|
||||
ScreenToClient (hwnd, &client_pt);
|
||||
GetClientRect (hwnd, &rect);
|
||||
if (PtInRect (&rect, client_pt))
|
||||
new_window = gdk_win32_handle_table_lookup (hwnd);
|
||||
}
|
||||
|
||||
if (!pointer_grab->owner_events &&
|
||||
new_window != NULL &&
|
||||
new_window != pointer_grab->surface)
|
||||
new_window = NULL;
|
||||
}
|
||||
|
||||
if (mouse_window != new_window)
|
||||
if (mouse_window != window)
|
||||
{
|
||||
GDK_NOTE (EVENTS, g_print (" mouse_window %p -> %p",
|
||||
mouse_window ? GDK_SURFACE_HWND (mouse_window) : NULL,
|
||||
new_window ? GDK_SURFACE_HWND (new_window) : NULL));
|
||||
window ? GDK_SURFACE_HWND (window) : NULL));
|
||||
synthesize_crossing_events (display,
|
||||
_gdk_device_manager->system_pointer,
|
||||
mouse_window, new_window,
|
||||
mouse_window, window,
|
||||
GDK_CROSSING_NORMAL,
|
||||
&msg->pt,
|
||||
0, /* TODO: Set right mask */
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
FALSE);
|
||||
g_set_object (&mouse_window, new_window);
|
||||
g_set_object (&mouse_window, window);
|
||||
mouse_window_ignored_leave = NULL;
|
||||
if (new_window != NULL)
|
||||
track_mouse_event (TME_LEAVE, GDK_SURFACE_HWND (new_window));
|
||||
if (window != NULL)
|
||||
track_mouse_event (TME_LEAVE, GDK_SURFACE_HWND (window));
|
||||
}
|
||||
else if (new_window != NULL &&
|
||||
new_window == mouse_window_ignored_leave)
|
||||
else if (window != NULL && window == mouse_window_ignored_leave)
|
||||
{
|
||||
/* If we ignored a leave event for this window and we're now getting
|
||||
input again we need to re-arm the mouse tracking, as that was
|
||||
cancelled by the mouseleave. */
|
||||
mouse_window_ignored_leave = NULL;
|
||||
track_mouse_event (TME_LEAVE, GDK_SURFACE_HWND (new_window));
|
||||
track_mouse_event (TME_LEAVE, GDK_SURFACE_HWND (window));
|
||||
}
|
||||
|
||||
g_set_object (&window, find_window_for_mouse_event (window, msg));
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
|
||||
/* If we haven't moved, don't create any GDK event. Windows
|
||||
|
||||
Reference in New Issue
Block a user