summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-09-10 12:28:58 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-09-10 18:57:17 +0200
commitfeae69bad70d637a92e6dbb7c18b756943858379 (patch)
tree37a4d5a7ec72980b3af644add6da62265281e127
parent94c9c991d1fd0991961ee7bb2fd88991fe55f2f1 (diff)
gtk4: complete child_grab_focus for gtk4
Change-Id: I35a19b4c95c1a57426a8fc51d4a15814ae443e6d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121897 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx23
1 files changed, 20 insertions, 3 deletions
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 5a4270857919..79d3835f69db 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -5547,22 +5547,39 @@ public:
virtual void child_grab_focus() override
{
gtk_widget_grab_focus(m_pWidget);
-#if !GTK_CHECK_VERSION(4, 0, 0)
+#if GTK_CHECK_VERSION(4, 0, 0)
+ bool bHasFocusChild = gtk_widget_get_focus_child(GTK_WIDGET(m_pContainer));
+#else
bool bHasFocusChild = gtk_container_get_focus_child(m_pContainer);
+#endif
if (!bHasFocusChild)
{
+#if GTK_CHECK_VERSION(4, 0, 0)
+ if (GtkWidget* pChild = gtk_widget_get_first_child(m_pContainer))
+ {
+ gtk_widget_set_focus_child(m_pContainer, pChild);
+ bHasFocusChild = true;
+ }
+#else
GList* pChildren = gtk_container_get_children(m_pContainer);
- for (GList* pChild = g_list_first(pChildren); pChild; pChild = g_list_next(pChild))
+ if (GList* pChild = g_list_first(pChildren))
{
gtk_container_set_focus_child(m_pContainer, static_cast<GtkWidget*>(pChild->data));
bHasFocusChild = true;
- break;
}
g_list_free(pChildren);
+#endif
}
+
if (bHasFocusChild)
+ {
+#if GTK_CHECK_VERSION(4, 0, 0)
+ gtk_widget_child_focus(gtk_widget_get_focus_child(m_pWidget), GTK_DIR_TAB_FORWARD);
+#else
gtk_widget_child_focus(gtk_container_get_focus_child(GTK_CONTAINER(m_pWidget)), GTK_DIR_TAB_FORWARD);
#endif
+ }
+
}
virtual void move(weld::Widget* pWidget, weld::Container* pNewParent) override