summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2016-02-07 17:53:40 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2016-02-15 12:08:07 +0000
commit2abdcfd641883f246fe78f2fbe38499c9382c059 (patch)
treeafbe57205258c7371f732389deb33c33cd49d639 /vcl/unx
parent7347248254595c082682180f7a1cfe768f5509a6 (diff)
tdf#97665 Let's hope that over activation isn't really needed
- MenuBarManager::Activate has a check for duplicate activation, which makes the second activation attempt fail. Removing this check or deactivating after each activation will likely affect performance even more, but on the other hand should solve lp#1296715, which was the main reason of the over activation in the first place. So let's activate only one menu at a time, and do full activation only on the initial update. - Unfortunately the HUD activation callback doesn't work, so we still have to keep active status listener for all menu items. (Which is BTW against the recommendation in XPopupMenuController::updatePopupMenu IDL doc. Fortunately the performance problem hardly noticeable on modern hw.) Change-Id: I96affa72412f3f38160fdca4b6efd20ca68d059f Reviewed-on: https://gerrit.libreoffice.org/22369 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/gtk/gloactiongroup.cxx2
-rw-r--r--vcl/unx/gtk/gtkdata.cxx18
-rw-r--r--vcl/unx/gtk/gtksalmenu.cxx62
3 files changed, 16 insertions, 66 deletions
diff --git a/vcl/unx/gtk/gloactiongroup.cxx b/vcl/unx/gtk/gloactiongroup.cxx
index 838538801ca7..e710809ca6cb 100644
--- a/vcl/unx/gtk/gloactiongroup.cxx
+++ b/vcl/unx/gtk/gloactiongroup.cxx
@@ -201,7 +201,7 @@ g_lo_action_group_perform_submenu_action (GLOActionGroup *group,
SAL_INFO("vcl.unity", "g_lo_action_group_perform_submenu_action on " << group << " to " << bState);
if (bState)
- pSalMenu->Activate();
+ pSalMenu->Activate (action_name);
else
pSalMenu->Deactivate (action_name);
}
diff --git a/vcl/unx/gtk/gtkdata.cxx b/vcl/unx/gtk/gtkdata.cxx
index e6121f7cba76..fa65259e8601 100644
--- a/vcl/unx/gtk/gtkdata.cxx
+++ b/vcl/unx/gtk/gtkdata.cxx
@@ -1027,22 +1027,4 @@ void GtkSalDisplay::deregisterFrame( SalFrame* pFrame )
SalGenericDisplay::deregisterFrame( pFrame );
}
-#if GTK_CHECK_VERSION(3,0,0)
-void GtkSalDisplay::RefreshMenusUnity()
-{
-#ifdef ENABLE_GMENU_INTEGRATION
- for(auto pSalFrame : m_aFrames) {
- auto pGtkSalFrame( static_cast<GtkSalFrame*>(pSalFrame));
- GtkSalMenu* pSalMenu = static_cast<GtkSalMenu*>(pGtkSalFrame->GetMenu());
- if(pSalMenu) {
- pSalMenu->Activate();
- pSalMenu->UpdateFull();
- }
- }
-#else
- (void) this;
-#endif
-}
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
index d8211eb5b865..7b9f7eda6cdd 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -372,54 +372,9 @@ void GtkSalMenu::SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsig
pItem->mpSubMenu = pGtkSubMenu;
}
-static bool bInvalidMenus = false;
-static gboolean RefreshMenusUnity(gpointer)
-{
- SolarMutexGuard g;
-#if GTK_CHECK_VERSION(3,0,0)
- GetGtkSalData()->GetGtkDisplay()->RefreshMenusUnity();
-#else
- SalDisplay* pSalDisplay = vcl_sal::getSalDisplay(GetGenericData());
- std::list< SalFrame* >::const_iterator pSalFrame = pSalDisplay->getFrames().begin();
- std::list< SalFrame* >::const_iterator pEndSalFrame = pSalDisplay->getFrames().end();
- for(; pSalFrame != pEndSalFrame; ++pSalFrame) {
- const GtkSalFrame* pGtkSalFrame = static_cast< const GtkSalFrame* >( *pSalFrame );
- GtkSalFrame* pFrameNonConst = const_cast<GtkSalFrame*>(pGtkSalFrame);
- GtkSalMenu* pSalMenu = static_cast<GtkSalMenu*>(pFrameNonConst->GetMenu());
- if(pSalMenu) {
- pSalMenu->Activate();
- pSalMenu->UpdateFull();
- }
- }
-#endif
- bInvalidMenus = false;
- return FALSE;
-}
-
-static void RefreshMenusUnity(void*, LinkParamNone*)
-{
- if(!bInvalidMenus) {
- g_timeout_add(10, &RefreshMenusUnity, nullptr);
- bInvalidMenus = true;
- }
-}
-
-static Link<LinkParamNone*,void>* getRefreshLinkInstance()
-{
- static Link<LinkParamNone*,void>* pLink = nullptr;
- if(!pLink) {
- pLink = new Link<LinkParamNone*,void>(nullptr, &RefreshMenusUnity);
- }
- return pLink;
-}
-
void GtkSalMenu::SetFrame( const SalFrame* pFrame )
{
SolarMutexGuard aGuard;
- {
- vcl::MenuInvalidator::AddMenuInvalidateListener(*getRefreshLinkInstance());
- }
-
assert(mbMenuBar);
SAL_INFO("vcl.unity", "GtkSalMenu set to frame");
mpFrame = static_cast< const GtkSalFrame* >( pFrame );
@@ -674,6 +629,7 @@ void GtkSalMenu::DispatchCommand( gint itemId, const gchar *aCommand )
void GtkSalMenu::ActivateAllSubmenus(MenuBar* pMenuBar)
{
pMenuBar->HandleMenuActivateEvent(mpVCLMenu);
+ pMenuBar->HandleMenuDeActivateEvent(mpVCLMenu);
for ( size_t nPos = 0; nPos < maItems.size(); nPos++ )
{
GtkSalMenuItem *pSalItem = maItems[ nPos ];
@@ -685,11 +641,23 @@ void GtkSalMenu::ActivateAllSubmenus(MenuBar* pMenuBar)
}
}
-void GtkSalMenu::Activate()
+void GtkSalMenu::Activate( const gchar* aMenuCommand )
{
if ( !mbMenuBar )
return;
- ActivateAllSubmenus(static_cast<MenuBar*>(mpVCLMenu));
+
+ if ( !aMenuCommand ) {
+ ActivateAllSubmenus( static_cast< MenuBar* >( mpVCLMenu ) );
+ return;
+ }
+
+ GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( const_cast<gchar*>(aMenuCommand), TRUE );
+
+ if ( pSalSubMenu != nullptr ) {
+ MenuBar* pMenuBar = static_cast< MenuBar* >( mpVCLMenu );
+ pMenuBar->HandleMenuActivateEvent( pSalSubMenu->mpVCLMenu );
+ pSalSubMenu->Update();
+ }
}
void GtkSalMenu::Deactivate( const gchar* aMenuCommand )