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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Nov 20 20:08:17 UTC 2020


 vcl/unx/gtk3/gtk3gtkinst.cxx |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

New commits:
commit 94ea1c89e959069aa7c735317470712012df2362
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Nov 20 12:09:27 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Nov 20 21:07:30 2020 +0100

    If we grab focus to a GtkToolbar then focus a GtkToolbarItem child
    
    and consider focus in a GtkToolbar child as focus the GtkToolbar
    has focus
    
    Change-Id: Id3299dd9246da22b21b3e1a347faff8bc867c438
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106270
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 47da0859e962..2d10bc2d4647 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -8685,6 +8685,32 @@ public:
         return gtk_toolbar_get_drop_index(m_pToolbar, rPoint.X(), rPoint.Y());
     }
 
+    virtual bool has_focus() const override
+    {
+        if (gtk_widget_has_focus(m_pWidget))
+            return true;
+        GtkWidget* pTopLevel = gtk_widget_get_toplevel(m_pWidget);
+        if (!GTK_IS_WINDOW(pTopLevel))
+            return false;
+        GtkWidget* pFocus = gtk_window_get_focus(GTK_WINDOW(pTopLevel));
+        if (!pFocus)
+            return false;
+        return gtk_widget_is_ancestor(pFocus, m_pWidget);
+    }
+
+    virtual void grab_focus() override
+    {
+        disable_notify_events();
+        gtk_widget_grab_focus(m_pWidget);
+        if (!gtk_container_get_focus_child(GTK_CONTAINER(m_pWidget)))
+        {
+            GtkToolItem* pItem = gtk_toolbar_get_nth_item(m_pToolbar, 0);
+            gtk_container_set_focus_child(GTK_CONTAINER(m_pWidget), GTK_WIDGET(pItem));
+        }
+        gtk_widget_child_focus(gtk_container_get_focus_child(GTK_CONTAINER(m_pWidget)), GTK_DIR_TAB_FORWARD);
+        enable_notify_events();
+    }
+
     virtual ~GtkInstanceToolbar() override
     {
         for (auto& a : m_aMap)


More information about the Libreoffice-commits mailing list