summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2023-11-08 12:25:47 -0900
committerAndras Timar <andras.timar@collabora.com>2024-02-06 12:28:51 +0100
commitc23648abcf78eee2f6c2c3e0f1e9d842daba49b0 (patch)
tree7214898275cdba10d067c6466d7f05e6d5aa56f3
parent22345c29d126cc7d250ed0c8e35173d1722160f6 (diff)
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 <raykowj@gmail.com> (cherry picked from commit 1ac7350a7032a760be22cce845eab7efe435827d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162825 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--toolkit/source/awt/vclxmenu.cxx7
-rw-r--r--vcl/source/app/salvtables.cxx6
-rw-r--r--vcl/source/window/menu.cxx10
3 files changed, 15 insertions, 8 deletions
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 95beb907f6c0..50ecd194bdcd 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 82d630742ab5..a0a03be455cb 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2863,9 +2863,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;
@@ -2884,13 +2887,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 )