From 88102bca46cde51cdf8d8c51af70e86bf3f2c9e6 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Sun, 11 Oct 2020 21:44:46 -0400 Subject: [PATCH] Kick the refresh timer for GAL on Win32 with a terrible hack --- common/draw_panel_gal.cpp | 6 ++++++ libs/kiplatform/gtk/app.cpp | 5 +++++ libs/kiplatform/include/kiplatform/app.h | 11 +++++++++++ libs/kiplatform/msw/app.cpp | 8 ++++++++ libs/kiplatform/osx/app.mm | 5 +++++ 5 files changed, 35 insertions(+) diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index 09a40ba727..b4d40ba7b3 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -40,6 +40,8 @@ #include #include +#include + #include #include @@ -295,6 +297,10 @@ void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent ) void EDA_DRAW_PANEL_GAL::Refresh( bool aEraseBackground, const wxRect* aRect ) { + // Call to ensure the refresh timer eventually fires during rapid mouse moves + // Required for win32 + KIPLATFORM::APP::ForceTimerMessagesToBeCreatedIfNecessary(); + if( m_pendingRefresh ) return; diff --git a/libs/kiplatform/gtk/app.cpp b/libs/kiplatform/gtk/app.cpp index 87240c9af2..5d80a54862 100644 --- a/libs/kiplatform/gtk/app.cpp +++ b/libs/kiplatform/gtk/app.cpp @@ -50,4 +50,9 @@ void KIPLATFORM::APP::RemoveShutdownBlockReason( wxWindow* aWindow ) void KIPLATFORM::APP::SetShutdownBlockReason( wxWindow* aWindow, const wxString& aReason ) { +} + + +void KIPLATFORM::APP::ForceTimerMessagesToBeCreatedIfNecessary() +{ } \ No newline at end of file diff --git a/libs/kiplatform/include/kiplatform/app.h b/libs/kiplatform/include/kiplatform/app.h index ac66011f63..1aa303d4c2 100644 --- a/libs/kiplatform/include/kiplatform/app.h +++ b/libs/kiplatform/include/kiplatform/app.h @@ -64,6 +64,17 @@ namespace KIPLATFORM * @param aWindow that has a shutdown block reason set */ void RemoveShutdownBlockReason( wxWindow* aWindow ); + + /** + * Forces wxTimers to fire more promptly on Win32. + * + * wxTimers on win32 are not real timers + * They live in the message pump at the absolute lowest priority (only when no other events are pending) + * This functions "peeks" the message pump which causes them to get queued immediately + * + * Call as needed in an application to ensure timers are dispatched + */ + void ForceTimerMessagesToBeCreatedIfNecessary(); } } diff --git a/libs/kiplatform/msw/app.cpp b/libs/kiplatform/msw/app.cpp index ae6976a362..a487a8634f 100644 --- a/libs/kiplatform/msw/app.cpp +++ b/libs/kiplatform/msw/app.cpp @@ -71,4 +71,12 @@ void KIPLATFORM::APP::SetShutdownBlockReason( wxWindow* aWindow, const wxString& ShutdownBlockReasonDestroy( aWindow->GetHandle() ); // Destroys any existing or nonexisting reason ShutdownBlockReasonCreate( aWindow->GetHandle(), aReason.wc_str() ); +} + + +void KIPLATFORM::APP::ForceTimerMessagesToBeCreatedIfNecessary() +{ + // Taken from https://devblogs.microsoft.com/oldnewthing/20191108-00/?p=103080 + MSG msg; + PeekMessage( &msg, nullptr, WM_TIMER, WM_TIMER, PM_NOREMOVE ); } \ No newline at end of file diff --git a/libs/kiplatform/osx/app.mm b/libs/kiplatform/osx/app.mm index 87240c9af2..5d80a54862 100644 --- a/libs/kiplatform/osx/app.mm +++ b/libs/kiplatform/osx/app.mm @@ -50,4 +50,9 @@ void KIPLATFORM::APP::RemoveShutdownBlockReason( wxWindow* aWindow ) void KIPLATFORM::APP::SetShutdownBlockReason( wxWindow* aWindow, const wxString& aReason ) { +} + + +void KIPLATFORM::APP::ForceTimerMessagesToBeCreatedIfNecessary() +{ } \ No newline at end of file