[Libreoffice-commits] core.git: vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Sun Jul 18 14:48:24 UTC 2021


 vcl/unx/gtk3/gtkinst.cxx |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

New commits:
commit f497a4e9da5d2375e428b03c423cc2d2e9995c4a
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Jul 16 15:49:33 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun Jul 18 16:47:50 2021 +0200

    Related: tdf#143357 restore focus to MenuButton when popover pops down
    
    which already happens for ComboBoxes but not always for MenuButtons with
    popovers with widgets in them
    
    Change-Id: If2ab1934f582b01327f910a578b80e9462d3daa0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119078
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index f82ab5d105cc..f79e3c35fbf0 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -9681,6 +9681,11 @@ private:
         bool bNewChecked = gtk_widget_get_state_flags(GTK_WIDGET(pToggleButton)) & GTK_STATE_FLAG_CHECKED;
         if (bOldChecked == bNewChecked)
             return;
+        if (bOldChecked && gtk_widget_get_focus_on_click(GTK_WIDGET(pToggleButton)))
+        {
+            // grab focus back to the toggle button if the menu was popped down
+            gtk_widget_grab_focus(GTK_WIDGET(pToggleButton));
+        }
         SolarMutexGuard aGuard;
         pThis->signal_toggled();
     }
@@ -9828,7 +9833,17 @@ public:
             return *m_xFont;
         return GtkInstanceWidget::get_font();
     }
-
+#else
+    virtual void set_active(bool bActive) override
+    {
+        bool bWasActive = get_active();
+        GtkInstanceToggleButton::set_active(bActive);
+        if (bWasActive && !bActive && gtk_widget_get_focus_on_click(GTK_WIDGET(m_pMenuButton)))
+        {
+            // grab focus back to the toggle button if the menu was popped down
+            gtk_widget_grab_focus(GTK_WIDGET(m_pMenuButton));
+        }
+    }
 #endif
 
     virtual void insert_item(int pos, const OUString& rId, const OUString& rStr,


More information about the Libreoffice-commits mailing list