diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-05-18 16:33:57 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-06-24 13:42:28 +0200 |
commit | 0215d4b88ef3607d960362e1d491552771a176bc (patch) | |
tree | 00c66a1121e5ae475ecb45c30b09ff8b7e2f70e1 /vcl | |
parent | 8bd75c9d3320f042466218798f8eb9942ab76a7c (diff) |
tdf#141186 ensure child of collapsed expander is not mapped
If the expander is initially collapsed then when mapped all its children
are mapped too.
If they are mapped then the mnemonics of the children are taken into
account on shortcuts and non-visible children in a collapsed expander
can be triggered which is confusing.
If the expander is expanded and collapsed the child is unmapped
and the problem doesn't occur.
So to avoid the problem of an initially collapsed expander, listen to
the map event and if the expander is mapped but collapsed then unmap the
child of the expander.
Change-Id: Ib4c7a704295b338230357c4c4102a3692f8a9707
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134453
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/gtk3/gtkinst.cxx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 5ef64a01e4f0..e1833bc36a37 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -21982,6 +21982,7 @@ private: gulong m_nSignalId; #if !GTK_CHECK_VERSION(4, 0, 0) gulong m_nButtonPressEventSignalId; + gulong m_nMappedSignalId; #endif static void signalExpanded(GtkExpander* pExpander, GParamSpec*, gpointer widget) @@ -22029,6 +22030,31 @@ private: // doesn't work return true; } + + /* tdf#141186 if the expander is initially collapsed then when mapped all its + children are mapped too. If they are mapped then the mnemonics of the + children are taken into account on shortcuts and non-visible children in a + collapsed expander can be triggered which is confusing. + + If the expander is expanded and collapsed the child is unmapped and the + problem doesn't occur. + + So to avoid the problem of an initially collapsed expander, listen to + the map event and if the expander is mapped but collapsed then unmap the + child of the expander. + + This problem was seen in gtk3-3.24.33 and not with gtk4-4.6.4 so a gtk3 + fix only needed. + */ + static void signalMap(GtkWidget*, gpointer widget) + { + GtkInstanceExpander* pThis = static_cast<GtkInstanceExpander*>(widget); + if (!gtk_expander_get_expanded(pThis->m_pExpander)) + { + if (GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(pThis->m_pExpander))) + gtk_widget_unmap(pChild); + } + } #endif public: @@ -22038,6 +22064,7 @@ public: , m_nSignalId(g_signal_connect(m_pExpander, "notify::expanded", G_CALLBACK(signalExpanded), this)) #if !GTK_CHECK_VERSION(4, 0, 0) , m_nButtonPressEventSignalId(g_signal_connect_after(m_pExpander, "button-press-event", G_CALLBACK(signalButton), this)) + , m_nMappedSignalId(g_signal_connect_after(m_pExpander, "map", G_CALLBACK(signalMap), this)) #endif { } @@ -22065,6 +22092,7 @@ public: virtual ~GtkInstanceExpander() override { #if !GTK_CHECK_VERSION(4, 0, 0) + g_signal_handler_disconnect(m_pExpander, m_nMappedSignalId); g_signal_handler_disconnect(m_pExpander, m_nButtonPressEventSignalId); #endif g_signal_handler_disconnect(m_pExpander, m_nSignalId); |