From 942362063d19830544d5bd94a94a633bd929bb21 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Mon, 31 Dec 2018 10:45:44 -0800 Subject: [PATCH] Avoid blocking paint events from long-running mouse event handlers If a mouse event handler calls Refresh(), increase the likelyhood that a paint event can be issued before the next mouse event occurs, by requesting more mouse events from the the end of the handler rather than the start. See #18314 --- src/gtk/window.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 32340aaa62..8e15376cff 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1815,19 +1815,6 @@ gtk_window_motion_notify_callback( GtkWidget * WXUNUSED(widget), wxCOMMON_CALLBACK_PROLOGUE(gdk_event, win); - if (gdk_event->is_hint) - { - int x = 0; - int y = 0; -#ifdef __WXGTK3__ - gdk_window_get_device_position(gdk_event->window, gdk_event->device, &x, &y, NULL); -#else - gdk_window_get_pointer(gdk_event->window, &x, &y, NULL); -#endif - gdk_event->x = x; - gdk_event->y = y; - } - g_lastMouseEvent = (GdkEvent*) gdk_event; wxMouseEvent event( wxEVT_MOTION ); @@ -1875,6 +1862,20 @@ gtk_window_motion_notify_callback( GtkWidget * WXUNUSED(widget), g_lastMouseEvent = NULL; + // Request additional motion events. Done at the end to increase the + // chances that lower priority events requested by the handler above, such + // as painting, can be processed before the next motion event occurs. + // Otherwise a long-running handler can cause paint events to be entirely + // blocked while the mouse is moving. + if (gdk_event->is_hint) + { +#ifdef __WXGTK3__ + gdk_event_request_motions(gdk_event); +#else + gdk_window_get_pointer(gdk_event->window, NULL, NULL, NULL); +#endif + } + return ret; }