diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-05-18 14:28:39 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-06-05 11:10:57 +0200 |
commit | eda624641b34a7d4315388c8ec1aebe44f63982e (patch) | |
tree | e5392764efad425741cba297c367fd2bb5eec4e8 /vcl | |
parent | b24739c98f3b5025e3dd5d86fadeae9983ccd5bc (diff) |
lp#1296715: refresh invalidated menus
- so we need to be a StatusListener in framework after all
- we ware updating all menus for now, instead of just one
- this would have a hugh performance hit when there is much change to the menu
- thus we just invalidate the menu and update with all changes after 100ms once
Change-Id: I48cda968cf0ae1eae0421b3424bb3e5830817e84
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/menu.cxx | 17 | ||||
-rw-r--r-- | vcl/unx/gtk/window/gtksalmenu.cxx | 43 |
2 files changed, 60 insertions, 0 deletions
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 9a7e73b6d27b..73e566803b5e 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -6130,4 +6130,21 @@ ImplMenuDelData::~ImplMenuDelData() const_cast< Menu* >( mpMenu )->ImplRemoveDel( *this ); } +namespace vcl +{ + MenuInvalidator::MenuInvalidator() {}; + + static VclEventListeners2* pMenuInvalidateListeners = NULL; + VclEventListeners2* MenuInvalidator::GetMenuInvalidateListeners() + { + if(!pMenuInvalidateListeners) + pMenuInvalidateListeners = new VclEventListeners2(); + return pMenuInvalidateListeners; + } + void MenuInvalidator::Invalidated() + { + VclSimpleEvent aEvent(0); + GetMenuInvalidateListeners()->callListeners(&aEvent); + }; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx index 6143e6c72101..dcbcd78425c6 100644 --- a/vcl/unx/gtk/window/gtksalmenu.cxx +++ b/vcl/unx/gtk/window/gtksalmenu.cxx @@ -11,6 +11,8 @@ #ifdef ENABLE_GMENU_INTEGRATION +#include <generic/gendata.hxx> +#include <unx/saldisp.hxx> #include <unx/gtk/glomenu.h> #include <unx/gtk/gloactiongroup.h> #include <vcl/menu.hxx> @@ -448,9 +450,50 @@ void GtkSalMenu::SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsig pItem->mpSubMenu = pGtkSubMenu; } +static bool bInvalidMenus = false; +static gboolean RefreshMenusUnity(gpointer) +{ + SalDisplay* pSalDisplay = GetGenericData()->GetSalDisplay(); + 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(); + } + } + bInvalidMenus = false; + return FALSE; +} + +static long RefreshMenusUnity(void*, void*) +{ + if(!bInvalidMenus) { + g_timeout_add(10, &RefreshMenusUnity, NULL); + bInvalidMenus = true; + } + return 0; +} + +static Link* getRefreshLinkInstance() +{ + static Link* pLink = NULL; + if(!pLink) { + pLink = new Link(NULL, &RefreshMenusUnity); + } + return pLink; +} + void GtkSalMenu::SetFrame( const SalFrame* pFrame ) { SolarMutexGuard aGuard; + { + vcl::MenuInvalidator aInvalidator; + aInvalidator.GetMenuInvalidateListeners()->addListener(*getRefreshLinkInstance()); + } assert(mbMenuBar); SAL_INFO("vcl.unity", "GtkSalMenu set to frame"); |