From 5d93487607cc1f2946bd527225d25578cf4141ec Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Tue, 9 May 2023 20:30:15 -0400 Subject: [PATCH] Disable IME input on the gal canvas Fixes #9719 --- common/draw_panel_gal.cpp | 1 + libs/kiplatform/CMakeLists.txt | 1 + libs/kiplatform/gtk/ui.cpp | 5 +++++ libs/kiplatform/include/kiplatform/ui.h | 7 ++++++- libs/kiplatform/msw/ui.cpp | 21 +++++++++++++++++++++ libs/kiplatform/osx/ui.mm | 5 +++++ 6 files changed, 39 insertions(+), 1 deletion(-) diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index d6ef0ba53c..3881f33cbe 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -111,6 +111,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas KIPLATFORM::UI::SetOverlayScrolling( this, false ); // Prevent excessive repaint on GTK + KIPLATFORM::UI::ImmControl( this, false ); // Ensure our panel can't suck in IME events Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), nullptr, this ); Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), nullptr, diff --git a/libs/kiplatform/CMakeLists.txt b/libs/kiplatform/CMakeLists.txt index afeee3d118..e41c628e1e 100644 --- a/libs/kiplatform/CMakeLists.txt +++ b/libs/kiplatform/CMakeLists.txt @@ -33,6 +33,7 @@ elseif( WIN32 ) "Shlwapi" "winhttp" "wintrust" + "Imm32" ) elseif( UNIX ) set( PLATFORM_SRCS diff --git a/libs/kiplatform/gtk/ui.cpp b/libs/kiplatform/gtk/ui.cpp index b47e2acd4c..a2a4e87baa 100644 --- a/libs/kiplatform/gtk/ui.cpp +++ b/libs/kiplatform/gtk/ui.cpp @@ -216,3 +216,8 @@ void KIPLATFORM::UI::WarpPointer( wxWindow* aWindow, int aX, int aY ) gdk_window_set_cursor( win, cur_cursor ); } } + + +void KIPLATFORM::UI::ImmControl( wxWindow* aWindow, bool aEnable ) +{ +} \ No newline at end of file diff --git a/libs/kiplatform/include/kiplatform/ui.h b/libs/kiplatform/include/kiplatform/ui.h index 490e513787..c8c4942185 100644 --- a/libs/kiplatform/include/kiplatform/ui.h +++ b/libs/kiplatform/include/kiplatform/ui.h @@ -118,7 +118,7 @@ namespace KIPLATFORM double GetContentScaleFactor( const wxWindow* aWindow ); /** - * Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl, wxGrid) + * Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl, wxGrid) * that won't be obscured by scrollbars. * @param aWindow pointer to the scrollable widget to check * @return Viewport size that won't be obscured by scrollbars @@ -143,6 +143,11 @@ namespace KIPLATFORM * @param aY destination y position */ void WarpPointer( wxWindow* aWindow, int aX, int aY ); + + /** + * Configures the IME mode of a given control handle + */ + void ImmControl( wxWindow* aWindow, bool aEnable ); } } diff --git a/libs/kiplatform/msw/ui.cpp b/libs/kiplatform/msw/ui.cpp index 733c9fd7d4..b8e36f0446 100644 --- a/libs/kiplatform/msw/ui.cpp +++ b/libs/kiplatform/msw/ui.cpp @@ -156,3 +156,24 @@ void KIPLATFORM::UI::WarpPointer( wxWindow* aWindow, int aX, int aY ) { aWindow->WarpPointer( aX, aY ); } + + +void KIPLATFORM::UI::ImmControl( wxWindow* aWindow, bool aEnable ) +{ + static HIMC origHIMC = (HIMC) 0; + + if ( !aEnable ) + { + if( origHIMC == (HIMC) 0 ) + { + origHIMC = ImmGetContext( aWindow->GetHWND() ); + if( origHIMC ) + ImmAssociateContext( aWindow->GetHWND(), NULL ); + } + } + else if( origHIMC != (HIMC) 0 ) + { + ImmAssociateContext( aWindow->GetHWND(), origHIMC ); + origHIMC = (HIMC) 0; + } +} \ No newline at end of file diff --git a/libs/kiplatform/osx/ui.mm b/libs/kiplatform/osx/ui.mm index 807a0bb1be..58f3f853c6 100644 --- a/libs/kiplatform/osx/ui.mm +++ b/libs/kiplatform/osx/ui.mm @@ -157,3 +157,8 @@ void KIPLATFORM::UI::WarpPointer( wxWindow* aWindow, int aX, int aY ) { aWindow->WarpPointer( aX, aY ); } + + +void KIPLATFORM::UI::ImmControl( wxWindow* aWindow, bool aEnable ) +{ +} \ No newline at end of file