vcl/unx/gtk3/gtkinst.cxx | 5 +++++
1 file changed, 5 insertions(+)
New commits:
commit a1a0991282b4a4449dd200412ad5b49684a3363d
Author: Michael Weghorn <[email protected]>
AuthorDate: Mon Jun 2 15:22:44 2025 +0200
Commit: Michael Weghorn <[email protected]>
CommitDate: Tue Jun 3 11:35:37 2025 +0200
gtk3: Don't signal submenu activation
Ignore the GtkMenuItem::activate [1] signal for menu items
that have a submenu.
The corresponding MenuHelper::signal_item_activate overrides
that would be called would otherwise handle that activation
as if a (leaf) menu item was activated by the user to trigger an
action, while the signal already gets triggered simply
when a menu item that has a submenu becomes selected/active
and its submenu is shown.
This addresses/prevents the
warn:basctl.basicide:1948815:1948815:basctl/source/basicide/macrodlg.cxx:806:
Unknown context menu action: ___object_1___
warning seen when doing this in Writer:
* "Macros" -> "Organize Macros" -> "Basic"
* right-click on entry in the "Existing Macros In: <module>" treeview
* hover over the "Sorting" menu entry
* click somewhere outside the menu area to close/cancel/dismiss the menu
This was previously triggered because
GtkInstanceMenu::signal_item_activate called from
MenuHelper::signalActivate would set GtkInstanceMenu::m_sActivated
to the (auto-generated because not explicitly set) ID of the
corresponding menu entry and the call to Menu::popup_at_rect in
MacroChooser::ContextMenuHdl would then return that ID instead
of an empty string (which would indicate that the user did
not activate a menu item).
Ignoring the signal aligns this with the behavior of the VCL
implementation.
Originally discussed in [2] where the same issue can be seen
in a newly introduced use of the same menu elsewhere.
[1] https://docs.gtk.org/gtk3/signal.MenuItem.activate.html
[2]
https://gerrit.libreoffice.org/c/core/+/179627/comment/c3ff25b7_9e668e51/
Change-Id: Ieee476606410875d033d877e22e5c9606ff9a848
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186134
Reviewed-by: Caolán McNamara <[email protected]>
Tested-by: Jenkins
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index e88b41f16341..df4594db17ff 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -5231,6 +5231,11 @@ private:
static void signalActivate(GtkMenuItem* pItem, gpointer widget)
{
+ // ignore "activate" signal for non-leaf items resulting in the
submenu to be
+ // shown, contrary to a "normal" menu item getting activated to
trigger its action
+ if (gtk_menu_item_get_submenu(pItem))
+ return;
+
MenuHelper* pThis = static_cast<MenuHelper*>(widget);
SolarMutexGuard aGuard;
pThis->signal_item_activate(::get_buildable_id(GTK_BUILDABLE(pItem)));