toolkit/source/awt/vclxmenu.cxx | 7 ++++++- vcl/source/app/salvtables.cxx | 6 ++++++ vcl/source/window/menu.cxx | 10 +++------- 3 files changed, 15 insertions(+), 8 deletions(-)
New commits: commit 1ac7350a7032a760be22cce845eab7efe435827d Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Wed Nov 8 12:25:47 2023 -0900 Commit: Jim Raykowski <rayk...@gmail.com> CommitDate: Thu Jan 25 09:10:40 2024 +0100 tdf#158101 Make non-gtk backends context popup menu item visibility behavior like gtk For context popup menus, gtk's native popup menu hides disabled menu items. This patch makes this the behavior for non-gtk backends while preserving the intent of commit a0955317900075371d6adb7f924af24c22f02d09 to make VCL PopupMenu respect the officecfg::Office::Common::View::Menu::DontHideDisabledEntry setting. Change-Id: Ice59f2b5ec20dac9d1b0891ccbd83dbbcd308078 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159192 Tested-by: Jenkins Reviewed-by: Jim Raykowski <rayk...@gmail.com> diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx index 37785849c551..20d3d5d2d18a 100644 --- a/toolkit/source/awt/vclxmenu.cxx +++ b/toolkit/source/awt/vclxmenu.cxx @@ -481,8 +481,13 @@ sal_Int16 VCLXMenu::execute( if ( !mpMenu || !IsPopupMenu() ) return 0; } + PopupMenu* pPopupMenu = static_cast<PopupMenu*>(pMenu.get()); + MenuFlags nMenuFlags = pPopupMenu->GetMenuFlags(); + // #102790# context menus shall never show disabled entries + nMenuFlags |= MenuFlags::HideDisabledEntries; + pPopupMenu->SetMenuFlags(nMenuFlags); // cannot call this with mutex locked because it will call back into us - return static_cast<PopupMenu*>(pMenu.get())->Execute( + return pPopupMenu->Execute( VCLUnoHelper::GetWindow( rxWindowPeer ), VCLRectangle( rPos ), static_cast<PopupMenuFlags>(nFlags) | PopupMenuFlags::NoMouseUpClose ); diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 7482a086b1be..2327b376b8ce 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1068,6 +1068,12 @@ void SalInstanceToolbar::set_menu_item_active(const OUString& rIdent, bool bActi { if (bActive) { + MenuFlags nMenuFlags = pPopup->GetMenuFlags(); + if (officecfg::Office::Common::View::Menu::DontHideDisabledEntry::get()) + nMenuFlags &= ~MenuFlags::HideDisabledEntries; + else + nMenuFlags |= MenuFlags::HideDisabledEntries; + pPopup->SetMenuFlags(nMenuFlags); tools::Rectangle aRect = m_xToolBox->GetItemRect(nItemId); pPopup->Execute(m_xToolBox, aRect, PopupMenuFlags::ExecuteDown); } diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 2dbba65ba245..387d74b0d1b3 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -2860,9 +2860,12 @@ bool PopupMenu::PrepareRun(const VclPtr<vcl::Window>& pParentWin, tools::Rectang if (bRealExecute) nPopupModeFlags |= FloatWinPopupFlags::NewLevel; + // MenuFlags get clobbered in the Activate function. Restore them after calling. + MenuFlags nMenuFlagsSaved = GetMenuFlags(); bInCallback = true; // set it here, if Activate overridden Activate(); bInCallback = false; + SetMenuFlags(nMenuFlagsSaved); if (pParentWin->isDisposed()) return false; @@ -2881,13 +2884,6 @@ bool PopupMenu::PrepareRun(const VclPtr<vcl::Window>& pParentWin, tools::Rectang else nMenuFlags &= ~MenuFlags::HideDisabledEntries; } - else - { - if (officecfg::Office::Common::View::Menu::DontHideDisabledEntry::get()) - nMenuFlags &= ~MenuFlags::HideDisabledEntries; - else - nMenuFlags |= MenuFlags::HideDisabledEntries; - } sal_uInt16 nVisibleEntries = ImplGetVisibleItemCount(); if ( !nVisibleEntries )