diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-03-15 20:44:50 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-03-16 09:27:36 +0000 |
commit | 86f504ee014d17172267f14742b8edd5789cbbc6 (patch) | |
tree | 6b6c78ac513e2169e9bceb7ffa99a16753a2eea5 /vcl | |
parent | 84aee1ae9d4e03054dfcf5f8a9f10ecd2b0496b8 (diff) |
Related: tdf#98637 make this a tractable problem
This is just too hard, it would all be much easier if the ActionGroup existed
right from the start of the entire process. So smuggle in to the ctor the
toplevel frame that the menubar will be inserted into so we can use its
ActionGroup from the start.
That would suggest that we could then just keep the hierarchy in sync as it is
created rather than finding opportune moments to update /generate it.
Change-Id: I550f94a994210423ab9cea1986e643056cb5bd29
Reviewed-on: https://gerrit.libreoffice.org/23287
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/osx/salinst.h | 2 | ||||
-rw-r--r-- | vcl/inc/salinst.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkinst.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtksalmenu.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/win/salinst.h | 2 | ||||
-rw-r--r-- | vcl/osx/salmenu.cxx | 2 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/menu.cxx | 15 | ||||
-rw-r--r-- | vcl/unx/gtk/gtkinst.cxx | 19 | ||||
-rw-r--r-- | vcl/unx/gtk/gtksalmenu.cxx | 28 | ||||
-rw-r--r-- | vcl/win/window/salmenu.cxx | 2 |
11 files changed, 48 insertions, 31 deletions
diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h index 972ad7be8cbe..fec12ecea07f 100644 --- a/vcl/inc/osx/salinst.h +++ b/vcl/inc/osx/salinst.h @@ -111,7 +111,7 @@ public: virtual SalYieldResult DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong nReleased) override; virtual bool AnyInput( VclInputFlags nType ) override; - virtual SalMenu* CreateMenu( bool bMenuBar, Menu* pVCLMenu ) override; + virtual SalMenu* CreateMenu( bool bMenuBar, Menu* pVCLMenu, SystemWindow* pAssociatedSystemWindow ) override; virtual void DestroyMenu( SalMenu* ) override; virtual SalMenuItem* CreateMenuItem( const SalItemParams* pItemData ) override; virtual void DestroyMenuItem( SalMenuItem* ) override; diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx index 6502679d426a..6486ae67e04f 100644 --- a/vcl/inc/salinst.hxx +++ b/vcl/inc/salinst.hxx @@ -53,6 +53,7 @@ struct SalItemParams; class SalSession; struct SystemGraphicsData; struct SystemWindowData; +class SystemWindow; class Menu; enum class VclInputFlags; enum class SalFrameStyleFlags; @@ -137,7 +138,7 @@ public: virtual bool AnyInput( VclInputFlags nType ) = 0; // menus - virtual SalMenu* CreateMenu( bool bMenuBar, Menu* pMenu ); + virtual SalMenu* CreateMenu( bool bMenuBar, Menu* pMenu, SystemWindow* pAssociatedSystemWindow ); virtual void DestroyMenu( SalMenu* pMenu); virtual SalMenuItem* CreateMenuItem( const SalItemParams* pItemData ); virtual void DestroyMenuItem( SalMenuItem* pItem ); diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx index 6f1f9999bc9b..5fec57974483 100644 --- a/vcl/inc/unx/gtk/gtkinst.hxx +++ b/vcl/inc/unx/gtk/gtkinst.hxx @@ -199,7 +199,7 @@ public: virtual SalSystem* CreateSalSystem() override; virtual SalInfoPrinter* CreateInfoPrinter(SalPrinterQueueInfo* pPrinterQueueInfo, ImplJobSetup* pJobSetup) override; virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter ) override; - virtual SalMenu* CreateMenu( bool, Menu* ) override; + virtual SalMenu* CreateMenu( bool, Menu*, SystemWindow* ) override; virtual void DestroyMenu( SalMenu* pMenu ) override; virtual SalMenuItem* CreateMenuItem( const SalItemParams* ) override; virtual void DestroyMenuItem( SalMenuItem* pItem ) override; diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx index 0e1cfd1a5167..7435e375baf1 100644 --- a/vcl/inc/unx/gtk/gtksalmenu.hxx +++ b/vcl/inc/unx/gtk/gtksalmenu.hxx @@ -59,7 +59,7 @@ private: void ActivateAllSubmenus(Menu* pMenuBar); public: - GtkSalMenu( bool bMenuBar ); + GtkSalMenu(bool bMenuBar, GActionGroup* pActionGroup); virtual ~GtkSalMenu(); virtual bool VisibleMenuBar() override; // must return TRUE to actually DISPLAY native menu bars diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h index b6408ea4f322..35d3d408fbd2 100644 --- a/vcl/inc/win/salinst.h +++ b/vcl/inc/win/salinst.h @@ -74,7 +74,7 @@ public: virtual SalYieldResult DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong nReleased) override; virtual bool AnyInput( VclInputFlags nType ) override; - virtual SalMenu* CreateMenu( bool bMenuBar, Menu* ) override; + virtual SalMenu* CreateMenu( bool bMenuBar, Menu*, SystemWindow* ) override; virtual void DestroyMenu( SalMenu* ) override; virtual SalMenuItem* CreateMenuItem( const SalItemParams* pItemData ) override; virtual void DestroyMenuItem( SalMenuItem* ) override; diff --git a/vcl/osx/salmenu.cxx b/vcl/osx/salmenu.cxx index 00f099105818..ad6ce395a2dc 100644 --- a/vcl/osx/salmenu.cxx +++ b/vcl/osx/salmenu.cxx @@ -220,7 +220,7 @@ static void initAppMenu() } } -SalMenu* AquaSalInstance::CreateMenu( bool bMenuBar, Menu* pVCLMenu ) +SalMenu* AquaSalInstance::CreateMenu( bool bMenuBar, Menu* pVCLMenu, SystemWindow* /*pAssociatedSystemWindow*/ ) { initAppMenu(); diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index c135cdf42294..116c772c3324 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -65,7 +65,7 @@ SalInstance::~SalInstance() { } -SalMenu* SalInstance::CreateMenu( bool, Menu* ) +SalMenu* SalInstance::CreateMenu( bool, Menu*, SystemWindow* ) { // default: no native menus return nullptr; diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 810525ba1234..373d94686887 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -2488,14 +2488,15 @@ MenuBarWindow* MenuBar::getMenuBarWindow() return pWin; } -MenuBar::MenuBar() +MenuBar::MenuBar(SystemWindow* pAssociatedSystemWindow) : Menu(), mbCloseBtnVisible(false), mbFloatBtnVisible(false), mbHideBtnVisible(false), - mbDisplayable(true) + mbDisplayable(true), + mpAssociatedSystemWindow(pAssociatedSystemWindow) { - mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(true, this); + mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(true, this, mpAssociatedSystemWindow); } MenuBar::MenuBar( const MenuBar& rMenu ) @@ -2505,7 +2506,7 @@ MenuBar::MenuBar( const MenuBar& rMenu ) mbHideBtnVisible(false), mbDisplayable(true) { - mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(true, this); + mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(true, this, mpAssociatedSystemWindow); *this = rMenu; } @@ -2779,13 +2780,13 @@ MenuFloatingWindow * PopupMenu::ImplGetFloatingWindow() const { PopupMenu::PopupMenu() : pRefAutoSubMenu(nullptr) { - mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this); + mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this, nullptr); } PopupMenu::PopupMenu( const ResId& rResId ) : pRefAutoSubMenu(nullptr) { - mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this); + mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this, nullptr); ResMgr* pMgr = rResId.GetResMgr(); if( ! pMgr ) @@ -2819,7 +2820,7 @@ PopupMenu::PopupMenu( const PopupMenu& rMenu ) : Menu(), pRefAutoSubMenu(nullptr) { - mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this); + mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this, nullptr); *this = rMenu; } diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx index a37102e0f30f..eacc457b1350 100644 --- a/vcl/unx/gtk/gtkinst.cxx +++ b/vcl/unx/gtk/gtkinst.cxx @@ -32,6 +32,7 @@ #include <headless/svpvd.hxx> #include <headless/svpbmp.hxx> #include <vcl/inputtypes.hxx> +#include <vcl/syswin.hxx> #include <unx/genpspgraphics.h> #include <rtl/strbuf.hxx> #include <rtl/uri.hxx> @@ -347,10 +348,24 @@ SalBitmap* GtkInstance::CreateSalBitmap() #ifdef ENABLE_GMENU_INTEGRATION -SalMenu* GtkInstance::CreateMenu( bool bMenuBar, Menu* pVCLMenu ) +SalMenu* GtkInstance::CreateMenu( bool bMenuBar, Menu* pVCLMenu, SystemWindow* pAssociatedSystemWindow ) { EnsureInit(); - GtkSalMenu* pSalMenu = new GtkSalMenu( bMenuBar ); + + GtkSalFrame *pFrame = pAssociatedSystemWindow ? dynamic_cast<GtkSalFrame*>(pAssociatedSystemWindow->ImplGetFrame()) + : nullptr; + + GActionGroup* pActionGroup; + if (pFrame) + { + GtkWidget* pWidget = pFrame->getWindow(); + GdkWindow* gdkWindow = gtk_widget_get_window( pWidget ); + pActionGroup = G_ACTION_GROUP( g_object_get_data( G_OBJECT( gdkWindow ), "g-lo-action-group" ) ); + } + else + pActionGroup = nullptr; + + GtkSalMenu* pSalMenu = new GtkSalMenu(bMenuBar, pActionGroup); pSalMenu->SetMenu( pVCLMenu ); return pSalMenu; } diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx index 204415564b96..0378b49f45e0 100644 --- a/vcl/unx/gtk/gtksalmenu.cxx +++ b/vcl/unx/gtk/gtksalmenu.cxx @@ -456,16 +456,26 @@ bool GtkSalMenu::ShowNativePopupMenu(FloatingWindow* pWin, const Rectangle& rRec * GtkSalMenu */ -GtkSalMenu::GtkSalMenu( bool bMenuBar ) : +GtkSalMenu::GtkSalMenu( bool bMenuBar, GActionGroup *pActionGroup ) : mbMenuBar( bMenuBar ), mpMenuBarWidget( nullptr ), mpCloseButton( nullptr ), mpVCLMenu( nullptr ), mpParentSalMenu( nullptr ), mpFrame( nullptr ), - mpMenuModel( nullptr ), - mpActionGroup( nullptr ) + mpActionGroup(pActionGroup) { + if (bMenuBar) + mpMenuModel = G_MENU_MODEL(g_lo_menu_new()); + else + mpMenuModel = nullptr; + + GLOActionGroup* pLOActionGroup = G_LO_ACTION_GROUP( mpActionGroup ); + if (pLOActionGroup) + { + g_lo_action_group_clear(pLOActionGroup); + g_lo_action_group_set_top_menu(pLOActionGroup, static_cast<gpointer>(this)); + } } void GtkSalMenu::SetMenuModel(GMenuModel* pMenuModel) @@ -664,22 +674,12 @@ void GtkSalMenu::SetFrame(const SalFrame* pFrame) GdkWindow* gdkWindow = gtk_widget_get_window( pWidget ); GLOMenu* pMenuModel = G_LO_MENU( g_object_get_data( G_OBJECT( gdkWindow ), "g-lo-menubar" ) ); - GLOActionGroup* pActionGroup = G_LO_ACTION_GROUP( g_object_get_data( G_OBJECT( gdkWindow ), "g-lo-action-group" ) ); - SAL_INFO("vcl.unity", "Found menu model: " << pMenuModel << " and action group: " << pActionGroup); + SAL_INFO("vcl.unity", "Found menu model: " << pMenuModel); if ( pMenuModel ) { if ( g_menu_model_get_n_items( G_MENU_MODEL( pMenuModel ) ) > 0 ) g_lo_menu_remove( pMenuModel, 0 ); - - mpMenuModel = G_MENU_MODEL( g_lo_menu_new() ); - } - - if ( pActionGroup ) - { - g_lo_action_group_clear( pActionGroup ); - g_lo_action_group_set_top_menu(pActionGroup, static_cast<gpointer>(this)); - mpActionGroup = G_ACTION_GROUP( pActionGroup ); } // Generate the main menu structure. diff --git a/vcl/win/window/salmenu.cxx b/vcl/win/window/salmenu.cxx index 0b623e25b1b4..1f038bedbe3f 100644 --- a/vcl/win/window/salmenu.cxx +++ b/vcl/win/window/salmenu.cxx @@ -43,7 +43,7 @@ bool SalData::IsKnownMenuHandle( HMENU hMenu ) // WinSalInst factory methods -SalMenu* WinSalInstance::CreateMenu( bool bMenuBar, Menu* ) +SalMenu* WinSalInstance::CreateMenu( bool bMenuBar, Menu*, SystemWindow* /*pAssociatedSystemWindow*/ ) { WinSalMenu *pSalMenu = new WinSalMenu(); |