]> git.lyx.org Git - lyx.git/commitdiff
Fixup [152811a27d242/lyxgit]
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 23 Jun 2024 12:47:43 +0000 (14:47 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 3 Jul 2024 07:49:54 +0000 (09:49 +0200)
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
src/frontends/qt/GuiView.h
src/frontends/qt/GuiWorkArea.cpp
src/frontends/qt/GuiWorkArea.h

index fc71a00842c8adbc9a66ff30af758aaf510ed5b6..c270a2419090c08a2f7af9dd652b047d08f12f23 100644 (file)
@@ -1926,6 +1926,12 @@ GuiWorkArea const * GuiView::currentWorkArea() const
 }
 
 
+TabWorkArea * GuiView::currentTabWorkArea() const
+{
+       return d.currentTabWorkArea();
+}
+
+
 GuiWorkArea * GuiView::currentWorkArea()
 {
        return d.current_work_area_;
index 18a5672239db36e3d0cab268383cebca2437e9e6..b7726e02305bd78c3bace4a3fb5a02bc012c9a47 100644 (file)
@@ -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).
index 6a13727602c211baf1fab751641a1fbf05fe8692..30048e41fe6c0f8835cd9bea4ee8f675b286968c 100644 (file)
@@ -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
index 8eeecadeb5780e6f6a579c86011231c9993aabde..8846a4d6ef3368928daa5f9b3abb03d5a9bf5311 100644 (file)
@@ -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;