commit 008e4917ab20918a21a1346a9c56b2083727b737
Author: Koji Yokota <[email protected]>
Date:   Thu Aug 21 03:53:47 2025 +0900

    Get correct initial state of Qt::ImEnabled
---
 src/frontends/qt/GuiInputMethod.cpp | 11 ++++++++---
 src/frontends/qt/GuiInputMethod.h   |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/frontends/qt/GuiInputMethod.cpp 
b/src/frontends/qt/GuiInputMethod.cpp
index 8e91f1bdb9..b38ff618d6 100644
--- a/src/frontends/qt/GuiInputMethod.cpp
+++ b/src/frontends/qt/GuiInputMethod.cpp
@@ -111,6 +111,9 @@ GuiInputMethod::GuiInputMethod(GuiWorkArea *parent)
                this, &GuiInputMethod::onLocaleChanged);
        connect(this, &GuiInputMethod::cursorPositionChanged,
                this, &GuiInputMethod::onCursorPositionChanged);
+
+       // initialize locale status
+       onLocaleChanged();
 }
 
 GuiInputMethod::~GuiInputMethod()
@@ -128,12 +131,14 @@ void GuiInputMethod::toggleInputMethodAcceptance(){
                        d->cur_->getFont().language()->inputMethodOffInMath();
 
        // note that d->cur_->inset() is a cache so it lags from actual key 
moves
-       d->im_state_.enabled_=
+       bool enabled =
                !((d->im_off_in_math_
                   && d->cur_->inset().currentMode() == Inset::MATH_MODE)
                  || guiApp->isInCommandMode());
-
-       Q_EMIT inputMethodStateChanged(Qt::ImEnabled);
+       if (enabled != d->im_state_.enabled_) {
+               d->im_state_.enabled_= enabled;
+               Q_EMIT inputMethodStateChanged(Qt::ImEnabled);
+       }
 }
 
 
diff --git a/src/frontends/qt/GuiInputMethod.h 
b/src/frontends/qt/GuiInputMethod.h
index 637e8adf0a..b339de903e 100644
--- a/src/frontends/qt/GuiInputMethod.h
+++ b/src/frontends/qt/GuiInputMethod.h
@@ -127,6 +127,7 @@ public Q_SLOT:
        void processQuery(Qt::InputMethodQuery query);
        /// Turn off IM in math mode and command phase and turn it on otherwise
        void toggleInputMethodAcceptance() override;
+       /// Handles the localeChanged() signal the input method emits
        void onLocaleChanged();
        void onCursorPositionChanged();
 #ifdef Q_DEBUG
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to