[Libreoffice-commits] core.git: framework/source include/vcl vcl/inc vcl/osx vcl/source vcl/unx vcl/win
Caolán McNamara
caolanm at redhat.com
Wed Mar 16 09:28:04 UTC 2016
framework/source/layoutmanager/layoutmanager.cxx | 4 ++-
framework/source/uielement/menubarwrapper.cxx | 28 +++++++++++++----------
framework/source/uifactory/menubarfactory.cxx | 11 +++++++--
include/vcl/menu.hxx | 3 +-
vcl/inc/osx/salinst.h | 2 -
vcl/inc/salinst.hxx | 3 +-
vcl/inc/unx/gtk/gtkinst.hxx | 2 -
vcl/inc/unx/gtk/gtksalmenu.hxx | 2 -
vcl/inc/win/salinst.h | 2 -
vcl/osx/salmenu.cxx | 2 -
vcl/source/app/salvtables.cxx | 2 -
vcl/source/window/menu.cxx | 15 ++++++------
vcl/unx/gtk/gtkinst.cxx | 19 +++++++++++++--
vcl/unx/gtk/gtksalmenu.cxx | 28 +++++++++++------------
vcl/win/window/salmenu.cxx | 2 -
15 files changed, 78 insertions(+), 47 deletions(-)
New commits:
commit 86f504ee014d17172267f14742b8edd5789cbbc6
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Mar 15 20:44:50 2016 +0000
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 at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index 30de7cb..0651e0f 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 cc5820c..4cd6730 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 e9d9f79..13025ad 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 2778199..6fd25ac 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 972ad7b..fec12ec 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 6502679..6486ae6 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 6f1f999..5fec579 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 0e1cfd1..7435e37 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 b6408ea..35d3d40 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 00f0991..ad6ce39 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 c135cdf..116c772 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 810525b..373d946 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 a37102e..eacc457 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 2044155..0378b49 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 0b623e2..1f038be 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();
More information about the Libreoffice-commits
mailing list