diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-04-05 20:25:42 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-04-05 22:20:22 +0200 |
commit | c7cfd3323cf80d5953f5c3808c1afd6fec0c674b (patch) | |
tree | e67018cb23fdd4c4b7b027877528448cb02c041e /vcl | |
parent | 30507382e11e2340c7dee7adced1f5f37a2d9e7f (diff) |
tdf#141499 trigger container_focus_changed for toplevel window focus events
retaining the single callback of
commit 9ffd28c32a301141a26e41ddd0cf485a562c83bb
Date: Fri Mar 5 16:13:19 2021 +0000
use container_focus_changed instead of toplevel_focus_changed
for focus events affecting the container where for gen its all the same
thing, but restore the gtk code for toplevel window gaining/losing focus
which set-focus-child doesn't fire on
Change-Id: Ia254a447283d0b3dd1a76072820d85ff379865f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113616
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 95377fbe6594..377ac47461de 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -4075,6 +4075,7 @@ class GtkInstanceWindow : public GtkInstanceContainer, public virtual weld::Wind private: GtkWindow* m_pWindow; rtl::Reference<SalGtkXWindow> m_xWindow; //uno api + gulong m_nToplevelFocusChangedSignalId; static gboolean help_pressed(GtkAccelGroup*, GObject*, guint, GdkModifierType, gpointer widget) { @@ -4083,6 +4084,12 @@ private: return true; } + static void signalToplevelFocusChanged(GtkWindow*, GParamSpec*, gpointer widget) + { + GtkInstanceWindow* pThis = static_cast<GtkInstanceWindow*>(widget); + pThis->signal_container_focus_changed(); + } + bool isPositioningAllowed() const { bool bPositioningAllowed = true; @@ -4100,6 +4107,7 @@ public: GtkInstanceWindow(GtkWindow* pWindow, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) : GtkInstanceContainer(GTK_CONTAINER(pWindow), pBuilder, bTakeOwnership) , m_pWindow(pWindow) + , m_nToplevelFocusChangedSignalId(0) { const bool bIsFrameWeld = pBuilder == nullptr; if (!bIsFrameWeld) @@ -4259,6 +4267,27 @@ public: return aData.ToStr(); } + virtual void connect_container_focus_changed(const Link<Container&, void>& rLink) override + { + if (!m_nToplevelFocusChangedSignalId) + m_nToplevelFocusChangedSignalId = g_signal_connect(m_pWindow, "notify::has-toplevel-focus", G_CALLBACK(signalToplevelFocusChanged), this); + GtkInstanceContainer::connect_container_focus_changed(rLink); + } + + virtual void disable_notify_events() override + { + if (m_nToplevelFocusChangedSignalId) + g_signal_handler_block(m_pWidget, m_nToplevelFocusChangedSignalId); + GtkInstanceContainer::disable_notify_events(); + } + + virtual void enable_notify_events() override + { + GtkInstanceContainer::enable_notify_events(); + if (m_nToplevelFocusChangedSignalId) + g_signal_handler_unblock(m_pWidget, m_nToplevelFocusChangedSignalId); + } + virtual VclPtr<VirtualDevice> screenshot() override { // detect if we have to manually setup its size @@ -4312,6 +4341,8 @@ public: virtual ~GtkInstanceWindow() override { + if (m_nToplevelFocusChangedSignalId) + g_signal_handler_disconnect(m_pWindow, m_nToplevelFocusChangedSignalId); if (m_xWindow.is()) m_xWindow->clear(); } |