diff options
-rw-r--r-- | framework/source/layoutmanager/layoutmanager.cxx | 4 | ||||
-rw-r--r-- | framework/source/uielement/menubarwrapper.cxx | 28 | ||||
-rw-r--r-- | framework/source/uifactory/menubarfactory.cxx | 11 | ||||
-rw-r--r-- | include/vcl/menu.hxx | 3 | ||||
-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 |
15 files changed, 78 insertions, 47 deletions
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 30de7cbc30d1..0651e0f718a1 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -726,11 +726,13 @@ Reference< XUIElement > LayoutManager::implts_createElement( const OUString& aNa Reference< ui::XUIElement > xUIElement; SolarMutexGuard g; - Sequence< PropertyValue > aPropSeq( 2 ); + Sequence< PropertyValue > aPropSeq( 3 ); aPropSeq[0].Name = "Frame"; aPropSeq[0].Value <<= m_xFrame; aPropSeq[1].Name = "Persistent"; aPropSeq[1].Value <<= sal_True; + aPropSeq[2].Name = "Container"; + aPropSeq[2].Value <<= m_xContainerWindow; try { diff --git a/framework/source/uielement/menubarwrapper.cxx b/framework/source/uielement/menubarwrapper.cxx index cc5820c8d59a..4cd67300060f 100644 --- a/framework/source/uielement/menubarwrapper.cxx +++ b/framework/source/uielement/menubarwrapper.cxx @@ -34,6 +34,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> #include <vcl/svapp.hxx> +#include "../layoutmanager/helpers.hxx" using namespace com::sun::star; using namespace com::sun::star::uno; @@ -122,6 +123,20 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th OUString aModuleIdentifier; UIConfigElementWrapperBase::initialize( aArguments ); + bool bMenuOnly( false ); + Reference< XWindow > xContainerWindow; + for ( sal_Int32 n = 0; n < aArguments.getLength(); n++ ) + { + PropertyValue aPropValue; + if ( aArguments[n] >>= aPropValue ) + { + if ( aPropValue.Name == "MenuOnly" ) + aPropValue.Value >>= bMenuOnly; + else if ( aPropValue.Name == "Container" ) + aPropValue.Value >>= xContainerWindow; + } + } + Reference< XFrame > xFrame( m_xWeakFrame ); if ( xFrame.is() && m_xConfigSource.is() ) { @@ -130,7 +145,7 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th VCLXMenuBar* pAwtMenuBar = nullptr; { SolarMutexGuard aSolarMutexGuard; - pVCLMenuBar = new MenuBar(); + pVCLMenuBar = new MenuBar(getTopSystemWindow(xContainerWindow)); } Reference< XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext ); @@ -159,17 +174,6 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th { } - bool bMenuOnly( false ); - for ( sal_Int32 n = 0; n < aArguments.getLength(); n++ ) - { - PropertyValue aPropValue; - if ( aArguments[n] >>= aPropValue ) - { - if ( aPropValue.Name == "MenuOnly" ) - aPropValue.Value >>= bMenuOnly; - } - } - if ( !bMenuOnly ) { // Initialize menubar manager with our vcl menu bar. There are some situations where we only want to get the menu without any diff --git a/framework/source/uifactory/menubarfactory.cxx b/framework/source/uifactory/menubarfactory.cxx index e9d9f79ce5ab..13025adcfff7 100644 --- a/framework/source/uifactory/menubarfactory.cxx +++ b/framework/source/uifactory/menubarfactory.cxx @@ -34,6 +34,7 @@ #include <rtl/ustrbuf.hxx> using namespace com::sun::star::uno; +using namespace com::sun::star::awt; using namespace com::sun::star::lang; using namespace com::sun::star::frame; using namespace com::sun::star::beans; @@ -74,6 +75,7 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL Reference< XUIConfigurationManager > xCfgMgr; Reference< XUIConfigurationManager > xConfigSource; Reference< XFrame > xFrame; + Reference< XWindow > xContainerWindow; OUString aResourceURL( ResourceURL ); bool bPersistent( true ); bool bExtraMode( false ); @@ -84,6 +86,8 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL Args[n].Value >>= xConfigSource; else if ( Args[n].Name == "Frame" ) Args[n].Value >>= xFrame; + else if ( Args[n].Name == "Container" ) + Args[n].Value >>= xContainerWindow; else if ( Args[n].Name == "ResourceURL" ) Args[n].Value >>= aResourceURL; else if ( Args[n].Name == "Persistent" ) @@ -129,7 +133,7 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL } PropertyValue aPropValue; - Sequence< Any > aPropSeq( _pExtraMode ? 5 : 4); + Sequence< Any > aPropSeq( _pExtraMode ? 6 : 5); aPropValue.Name = "Frame"; aPropValue.Value <<= xFrame; aPropSeq[0] <<= aPropValue; @@ -142,11 +146,14 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL aPropValue.Name = "Persistent"; aPropValue.Value <<= bPersistent; aPropSeq[3] <<= aPropValue; + aPropValue.Name = "Container"; + aPropValue.Value <<= xContainerWindow; + aPropSeq[4] <<= aPropValue; if ( _pExtraMode ) { aPropValue.Name = OUString::createFromAscii(_pExtraMode); aPropValue.Value <<= bExtraMode; - aPropSeq[4] <<= aPropValue; + aPropSeq[5] <<= aPropValue; } SolarMutexGuard aGuard; diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx index 277819960347..6fd25acf169c 100644 --- a/include/vcl/menu.hxx +++ b/include/vcl/menu.hxx @@ -413,6 +413,7 @@ class VCL_DLLPUBLIC MenuBar : public Menu bool mbFloatBtnVisible : 1; bool mbHideBtnVisible : 1; bool mbDisplayable : 1; + SystemWindow* mpAssociatedSystemWindow; friend class Application; friend class Menu; @@ -431,7 +432,7 @@ protected: MenuBarWindow* getMenuBarWindow(); public: - MenuBar(); + MenuBar( SystemWindow* pAssociatedSystemWindow = nullptr ); MenuBar( const MenuBar& rMenu ); virtual ~MenuBar(); 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(); |