diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-12-09 17:28:00 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-12-09 21:24:21 +0100 |
commit | b6c2c72ceeab757fb33f2412afd291c3b21fe2ba (patch) | |
tree | e362ed5768cb741078cef3ada4b179784f5051ad /vcl | |
parent | ebc76496be42f1ca9141c94cc544a3fa922cad38 (diff) |
tdf#138778 add has_child_focus which considers a related popup a 'child'
Change-Id: Iab23e399f2650ece702fb1f62d1387acca472b42
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107480
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/salvtables.hxx | 2 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 7 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 33 |
3 files changed, 38 insertions, 4 deletions
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index f3f4a585cecf..0702cb103a5f 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -210,6 +210,8 @@ public: virtual bool is_active() const override; + virtual bool has_child_focus() const override; + virtual void set_has_default(bool has_default) override; virtual bool get_has_default() const override; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 03f68e381163..e8dd4acd4808 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -271,6 +271,8 @@ bool SalInstanceWidget::has_focus() const { return m_xWidget->HasFocus(); } bool SalInstanceWidget::is_active() const { return m_xWidget->IsActive(); } +bool SalInstanceWidget::has_child_focus() const { return m_xWidget->HasChildPathFocus(true); } + void SalInstanceWidget::set_has_default(bool has_default) { m_xWidget->set_property("has-default", OUString::boolean(has_default)); @@ -5776,10 +5778,7 @@ public: return m_xExpander->get_label_widget()->HasFocus() || SalInstanceContainer::has_focus(); } - virtual void grab_focus() override - { - return m_xExpander->get_label_widget()->GrabFocus(); - } + virtual void grab_focus() override { return m_xExpander->get_label_widget()->GrabFocus(); } virtual ~SalInstanceExpander() override { diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 5af961ed5aeb..c45a66e9edd4 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -2546,6 +2546,39 @@ public: return pTopLevel && gtk_window_is_active(pTopLevel) && has_focus(); } + // is the focus in a child of this widget, where a transient popup attached + // to a widget is considered a child of that widget + virtual bool has_child_focus() const override + { + bool bRet = false; + + GList* pList = gtk_window_list_toplevels(); + + for (GList* pEntry = pList; pEntry; pEntry = pEntry->next) + { + if (!gtk_window_has_toplevel_focus(GTK_WINDOW(pEntry->data))) + continue; + GtkWidget* pFocus = gtk_window_get_focus(GTK_WINDOW(pEntry->data)); + if (pFocus && gtk_widget_is_ancestor(pFocus, m_pWidget)) + { + bRet = true; + break; + } + GtkWidget* pAttachedTo = gtk_window_get_attached_to(GTK_WINDOW(pEntry->data)); + if (!pAttachedTo) + continue; + if (pAttachedTo == m_pWidget || gtk_widget_is_ancestor(pAttachedTo, m_pWidget)) + { + bRet = true; + break; + } + } + + g_list_free(pList); + + return bRet; + } + virtual void set_has_default(bool has_default) override { g_object_set(G_OBJECT(m_pWidget), "has-default", has_default, nullptr); |