[LyX/2.4.x] Fixup [152811a27d242/lyxgit]

Juergen Spitzmueller spitz at lyx.org
Wed Jul 3 07:56:50 UTC 2024


commit 2cc5ca27fdabbbcf34aec808a228f2f9bba2cb21
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Sun Jun 23 14:47:43 2024 +0200

    Fixup [152811a27d242/lyxgit]
    
    tabBarClicked() should really only reset focus if a click in a different
    TabBarGroup happened. And no need to issue workAreaChanged() again.
    
    This has lead to extra and erroneous focus changes (see #12954)
    
    (cherry picked from commit 026c4bd726f36623772dc152740f709ce9972415)
---
 src/frontends/qt/GuiView.cpp     |  6 ++++++
 src/frontends/qt/GuiView.h       |  2 ++
 src/frontends/qt/GuiWorkArea.cpp | 18 +++++++++++++++++-
 src/frontends/qt/GuiWorkArea.h   |  2 ++
 4 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index fc71a00842..c270a24190 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -1926,6 +1926,12 @@ GuiWorkArea const * GuiView::currentWorkArea() const
 }
 
 
+TabWorkArea * GuiView::currentTabWorkArea() const
+{
+	return d.currentTabWorkArea();
+}
+
+
 GuiWorkArea * GuiView::currentWorkArea()
 {
 	return d.current_work_area_;
diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h
index 18a5672239..b7726e0230 100644
--- a/src/frontends/qt/GuiView.h
+++ b/src/frontends/qt/GuiView.h
@@ -209,6 +209,8 @@ public:
 	void removeWorkArea(GuiWorkArea * work_area);
 	/// return true if \c wa is one of the visibles workareas of this view
 	bool hasVisibleWorkArea(GuiWorkArea * wa) const;
+	///
+	TabWorkArea * currentTabWorkArea() const;
 	/// return the current WorkArea (the one that has the focus).
 	GuiWorkArea const * currentWorkArea() const;
 	/// return the current WorkArea (the one that has the focus).
diff --git a/src/frontends/qt/GuiWorkArea.cpp b/src/frontends/qt/GuiWorkArea.cpp
index 6a13727602..30048e41fe 100644
--- a/src/frontends/qt/GuiWorkArea.cpp
+++ b/src/frontends/qt/GuiWorkArea.cpp
@@ -1648,7 +1648,7 @@ TabWorkArea::TabWorkArea(QWidget * parent)
 		this, SLOT(on_currentTabChanged(int)));
 	// Fix for #11835
 	QObject::connect(this, SIGNAL(tabBarClicked(int)),
-		this, SLOT(on_currentTabChanged(int)));
+		this, SLOT(on_tabBarClicked(int)));
 
 	closeBufferButton = new QToolButton(this);
 	closeBufferButton->setPalette(pal);
@@ -1928,6 +1928,22 @@ bool TabWorkArea::removeWorkArea(GuiWorkArea * work_area)
 }
 
 
+void TabWorkArea::on_tabBarClicked(int i)
+{
+	// returns e.g. on application destruction
+	if (i == -1)
+		return;
+
+	// if we click on a tab in a different TabWorkArea,
+	// focus needs to be set (#11835)
+	if (currentWorkArea() && currentWorkArea()->view().currentTabWorkArea() != this) {
+		GuiWorkArea * wa = workArea(i);
+		LASSERT(wa, return);
+		wa->setFocus();
+	}
+}
+
+
 void TabWorkArea::on_currentTabChanged(int i)
 {
 	// returns e.g. on application destruction
diff --git a/src/frontends/qt/GuiWorkArea.h b/src/frontends/qt/GuiWorkArea.h
index 8eeecadeb5..8846a4d6ef 100644
--- a/src/frontends/qt/GuiWorkArea.h
+++ b/src/frontends/qt/GuiWorkArea.h
@@ -265,6 +265,8 @@ private Q_SLOTS:
 	///
 	void on_currentTabChanged(int index);
 	///
+	void on_tabBarClicked(int index);
+	///
 	void showContextMenu(const QPoint & pos);
 	/// enable closing tab on middle-click
 	void mousePressEvent(QMouseEvent * me) override;


More information about the lyx-cvs mailing list