[LyX/master] Integrate some functions in GuiInputMethod class

Koji Yokota <[email protected]>
Newsgroups gmane.editors.lyx.cvs
Message-ID <[email protected]>
commit 5a626531d3a1674c333f4bbf3ebe9ac7127d78bd
Author: Koji Yokota <[email protected]>
Date:   Sun Apr 5 13:24:10 2026 +0900

    Integrate some functions in GuiInputMethod class
    
    Removing redundancy
---
 src/frontends/qt/GuiInputMethod.cpp | 29 ++++++-----------------------
 src/frontends/qt/GuiInputMethod.h   |  2 --
 2 files changed, 6 insertions(+), 25 deletions(-)

diff --git a/src/frontends/qt/GuiInputMethod.cpp b/src/frontends/qt/GuiInputMethod.cpp
index 7850876c73..c1fe0cba15 100644
--- a/src/frontends/qt/GuiInputMethod.cpp
+++ b/src/frontends/qt/GuiInputMethod.cpp
@@ -107,8 +107,6 @@ GuiInputMethod::GuiInputMethod(GuiWorkArea *parent)
 	        d->sys_im_, &QInputMethod::update);
 	connect(d->sys_im_, &QInputMethod::localeChanged,
 	        this, &GuiInputMethod::onLocaleChanged);
-	connect(this, &GuiInputMethod::cursorPositionChanged,
-	        this, &GuiInputMethod::onCursorPositionChanged);
 	connect(parent, &GuiWorkArea::bufferViewChanged,
 	        this, &GuiInputMethod::onBufferViewChanged);
 
@@ -292,7 +290,7 @@ void GuiInputMethod::processPreedit(QInputMethodEvent* ev)
 }
 
 
-void GuiInputMethod::onCursorPositionChanged()
+void GuiInputMethod::updatePosAndSurroundingText()
 {
 	if (d->cur_->atEnd()) {
 		// Slices are empty:
@@ -302,7 +300,10 @@ void GuiInputMethod::onCursorPositionChanged()
 		return;
 	}
 
-	d->cur_pos_ = d->cur_->top().pos();
+	if (d->cur_pos_ == d->cur_->top().pos())
+		return;
+	else
+		d->cur_pos_ = d->cur_->top().pos();
 
 	// We are only interested in the current paragraph
 	// (where cur_pos_ is) with the anchor_pos_.
@@ -1101,8 +1102,7 @@ pos_type GuiInputMethod::initializePositions(Cursor * cur)
 		return 0;
 
 	// position of the real cursor (also the start of the preedit)
-	if (cur->top().pos() != d->cur_pos_)
-		Q_EMIT cursorPositionChanged();
+	updatePosAndSurroundingText();
 
 	// Note that getRowIndex(., false) gives the row index *after* preedit
 	// strings since they are virtual, so it increases as preedit strings go
@@ -1368,23 +1368,6 @@ void GuiInputMethod::setSurroundingText(const Cursor & cur)
 	return;
 }
 
-void GuiInputMethod::updatePosAndSurroundingText()
-{
-	if (d->cur_->atEnd()) {
-		// Slices are empty:
-		// Reset pos caches and quit.
-		d->cur_pos_ = 0;
-		d->anchor_pos_ = 0;
-		return;
-	}
-	if (d->cur_->top().pos() == d->cur_pos_)
-		// Nothing to do
-		return;
-
-	Q_EMIT cursorPositionChanged();
-}
-
-
 docstring & GuiInputMethod::preeditString() const
 {
 	return d->preedit_str_;
diff --git a/src/frontends/qt/GuiInputMethod.h b/src/frontends/qt/GuiInputMethod.h
index d052e82ed3..88fd541392 100644
--- a/src/frontends/qt/GuiInputMethod.h
+++ b/src/frontends/qt/GuiInputMethod.h
@@ -118,7 +118,6 @@ Q_SIGNALS:
 	void preeditProcessed(QInputMethodEvent* ev);
 	void queryProcessed(QVariant response);
 	void inputMethodStateChanged(Qt::InputMethodQueries);
-	void cursorPositionChanged();
 
 public Q_SLOTS:
 	/// Process incoming preedit string
@@ -133,7 +132,6 @@ public Q_SLOTS:
 	void disableInputMethod() override;
 	/// Handles the localeChanged() signal the input method emits
 	void onLocaleChanged();
-	void onCursorPositionChanged();
 	void onBufferViewChanged();
 #ifdef Q_DEBUG
 	///
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.