[Libreoffice-commits] core.git: vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Dec 15 16:18:19 UTC 2020
vcl/unx/gtk3/gtk3gtkinst.cxx | 60 +++++++++++++++++++++++--------------------
1 file changed, 33 insertions(+), 27 deletions(-)
New commits:
commit 943d1c0a0aff194300dd7d46a651c51dd05e2f3a
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Dec 15 12:53:52 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Dec 15 17:17:36 2020 +0100
split out get_focus_window for reuse
Change-Id: I16480130a4bcf491157b2a7dbcaef0ce01870025
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107765
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 06c7c75121eb..5a7c39ad8b06 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1902,6 +1902,27 @@ GdkDragAction VclToGdk(sal_Int8 dragOperation)
return eRet;
}
+GtkWindow* get_focus_window()
+{
+ GtkWindow* pFocus = nullptr;
+
+ GList* pList = gtk_window_list_toplevels();
+
+ for (GList* pEntry = pList; pEntry; pEntry = pEntry->next)
+ {
+ if (gtk_window_has_toplevel_focus(GTK_WINDOW(pEntry->data)))
+ {
+ pFocus = GTK_WINDOW(pEntry->data);
+ break;
+ }
+ }
+
+ g_list_free(pList);
+
+ return pFocus;
+}
+
+
class GtkInstanceWidget : public virtual weld::Widget
{
protected:
@@ -2553,33 +2574,18 @@ public:
// 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;
+ GtkWindow* pFocusWin = get_focus_window();
+ if (!pFocusWin)
+ return false;
+ GtkWidget* pFocus = gtk_window_get_focus(pFocusWin);
+ if (pFocus && gtk_widget_is_ancestor(pFocus, m_pWidget))
+ return true;
+ GtkWidget* pAttachedTo = gtk_window_get_attached_to(pFocusWin);
+ if (!pAttachedTo)
+ return false;
+ if (pAttachedTo == m_pWidget || gtk_widget_is_ancestor(pAttachedTo, m_pWidget))
+ return true;
+ return false;
}
virtual void set_has_default(bool has_default) override
More information about the Libreoffice-commits
mailing list