Hackfix some cases the IME on windows locks up

Asking the IME to cancel when the canvas takes focus fixes the case where:

- Windows input lang set to Chinese
- Input mode set to english instead of chinese
- You spam the M key while launching a sch/pcb from the kicad.exe until the editor opens
- The windows would then normally be frozen
This commit is contained in:
Marek Roszko 2024-05-25 13:25:10 -04:00
parent 3065ae1f01
commit 7dee29f70a
5 changed files with 24 additions and 0 deletions

View File

@ -186,6 +186,7 @@ EDA_DRAW_PANEL_GAL::~EDA_DRAW_PANEL_GAL()
void EDA_DRAW_PANEL_GAL::SetFocus()
{
KIPLATFORM::UI::ImeNotifyCancelComposition( this );
wxScrolledCanvas::SetFocus();
m_lostFocus = false;
}

View File

@ -321,6 +321,11 @@ void KIPLATFORM::UI::ImmControl( wxWindow* aWindow, bool aEnable )
}
void KIPLATFORM::UI::ImeNotifyCancelComposition( wxWindow* aWindow )
{
}
void KIPLATFORM::UI::SetFloatLevel( wxWindow* aWindow )
{
}

View File

@ -158,6 +158,11 @@ namespace KIPLATFORM
*/
void ImmControl( wxWindow* aWindow, bool aEnable );
/**
* Asks the IME to cancel
*/
void ImeNotifyCancelComposition( wxWindow* aWindow );
/**
* On Wayland, restricts the pointer movement to a rectangle slightly bigger than the given `wxWindow`.
* This way, the cursor doesn't exit the (bigger) application window and we retain control on it.

View File

@ -184,6 +184,14 @@ void KIPLATFORM::UI::ImmControl( wxWindow* aWindow, bool aEnable )
}
void KIPLATFORM::UI::ImeNotifyCancelComposition( wxWindow* aWindow )
{
const HIMC himc = ImmGetContext( aWindow->GetHWND() );
ImmNotifyIME( himc, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
ImmReleaseContext( aWindow->GetHWND(), himc );
}
bool KIPLATFORM::UI::InfiniteDragPrepareWindow( wxWindow* aWindow )
{
return true;

View File

@ -184,6 +184,11 @@ void KIPLATFORM::UI::ImmControl( wxWindow* aWindow, bool aEnable )
}
void KIPLATFORM::UI::ImeNotifyCancelComposition( wxWindow* aWindow )
{
}
bool KIPLATFORM::UI::InfiniteDragPrepareWindow( wxWindow* aWindow )
{
return true;