diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2017-09-29 10:54:48 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2017-10-01 01:21:03 +0200 |
commit | 4c6f17f730929e630ec2412785e2f4a8964940c7 (patch) | |
tree | 6018c68d591bbd8f037c2a52bf81f6af00bee6be /framework | |
parent | cb9970400d0bbd73e508f25a67e1ad2c7dd28eb6 (diff) |
Wayland: Make the shapes popup work in the overflow toolbar
Was failing to show, with this warning:
Gdk-WARNING **: Tried to map a popup with a non-top most parent
To make it work, needed to implement a way to pass as extra
"ParentWindow" property to the ui element. It's documented in the
XUIElementFactory idl, but was not used by the framework impl.
Change-Id: Ifea24fc333709478634f70230699963e952e9157
Reviewed-on: https://gerrit.libreoffice.org/42937
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Tested-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/uifactory/menubarfactory.hxx | 1 | ||||
-rw-r--r-- | framework/source/uielement/subtoolbarcontroller.cxx | 2 | ||||
-rw-r--r-- | framework/source/uielement/toolbarwrapper.cxx | 10 | ||||
-rw-r--r-- | framework/source/uifactory/menubarfactory.cxx | 69 | ||||
-rw-r--r-- | framework/source/uifactory/statusbarfactory.cxx | 2 | ||||
-rw-r--r-- | framework/source/uifactory/toolbarfactory.cxx | 2 |
6 files changed, 47 insertions, 39 deletions
diff --git a/framework/inc/uifactory/menubarfactory.hxx b/framework/inc/uifactory/menubarfactory.hxx index c5a7003a2787..78e154813193 100644 --- a/framework/inc/uifactory/menubarfactory.hxx +++ b/framework/inc/uifactory/menubarfactory.hxx @@ -63,7 +63,6 @@ typedef ::cppu::WeakImplHelper< static void CreateUIElement(const OUString& ResourceURL ,const css::uno::Sequence< css::beans::PropertyValue >& Args - ,const char* _pExtraMode ,const OUString& ResourceType ,const css::uno::Reference< css::ui::XUIElement >& _xMenuBar ,const css::uno::Reference< css::uno::XComponentContext >& _rxContext); diff --git a/framework/source/uielement/subtoolbarcontroller.cxx b/framework/source/uielement/subtoolbarcontroller.cxx index 0ef2c4ab8af6..e712dd3801a5 100644 --- a/framework/source/uielement/subtoolbarcontroller.cxx +++ b/framework/source/uielement/subtoolbarcontroller.cxx @@ -208,6 +208,7 @@ css::uno::Reference< css::awt::XWindow > SubToolBarController::createPopupWindow auto aPropSeq( comphelper::InitPropertySequence( { { "Frame", css::uno::makeAny( xFrame ) }, + { "ParentWindow", css::uno::makeAny( m_xParentWindow ) }, { "Persistent", css::uno::makeAny( false ) }, { "PopupMode", css::uno::makeAny( true ) } } ) ); @@ -239,7 +240,6 @@ css::uno::Reference< css::awt::XWindow > SubToolBarController::createPopupWindow if ( pTbxWindow && pTbxWindow->GetType() == WindowType::TOOLBOX ) { ToolBox* pToolBar = static_cast< ToolBox* >( pTbxWindow.get() ); - pToolBar->SetParent( pToolBox ); // calc and set size for popup mode Size aSize = pToolBar->CalcPopupWindowSizePixel(); pToolBar->SetSizePixel( aSize ); diff --git a/framework/source/uielement/toolbarwrapper.cxx b/framework/source/uielement/toolbarwrapper.cxx index 1f090b60760d..b5b56f0ab070 100644 --- a/framework/source/uielement/toolbarwrapper.cxx +++ b/framework/source/uielement/toolbarwrapper.cxx @@ -124,16 +124,16 @@ void SAL_CALL ToolBarWrapper::initialize( const Sequence< Any >& aArguments ) UIConfigElementWrapperBase::initialize( aArguments ); bool bPopupMode( false ); + Reference< XWindow > xParentWindow; for ( sal_Int32 i = 0; i < aArguments.getLength(); i++ ) { PropertyValue aPropValue; if ( aArguments[i] >>= aPropValue ) { if ( aPropValue.Name == "PopupMode" ) - { aPropValue.Value >>= bPopupMode; - break; - } + else if ( aPropValue.Name == "ParentWindow" ) + xParentWindow.set( aPropValue.Value, UNO_QUERY ); } } @@ -145,7 +145,9 @@ void SAL_CALL ToolBarWrapper::initialize( const Sequence< Any >& aArguments ) ToolBarManager* pToolBarManager = nullptr; { SolarMutexGuard aSolarMutexGuard; - VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); + if ( !xParentWindow.is() ) + xParentWindow.set( xFrame->getContainerWindow() ); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xParentWindow ); if ( pWindow ) { sal_uLong nStyles = WB_LINESPACING | WB_BORDER | WB_SCROLL | WB_MOVEABLE | WB_3DLOOK | WB_DOCKABLE | WB_SIZEABLE | WB_CLOSEABLE; diff --git a/framework/source/uifactory/menubarfactory.cxx b/framework/source/uifactory/menubarfactory.cxx index 05709675997a..4612f53bc81d 100644 --- a/framework/source/uifactory/menubarfactory.cxx +++ b/framework/source/uifactory/menubarfactory.cxx @@ -59,42 +59,42 @@ Reference< XUIElement > SAL_CALL MenuBarFactory::createUIElement( { Reference< css::ui::XUIElement > xMenuBar( static_cast<OWeakObject *>(new MenuBarWrapper(m_xContext)), UNO_QUERY); - CreateUIElement(ResourceURL, Args, "MenuOnly", "private:resource/menubar/", xMenuBar, m_xContext); + CreateUIElement(ResourceURL, Args, "private:resource/menubar/", xMenuBar, m_xContext); return xMenuBar; } void MenuBarFactory::CreateUIElement(const OUString& ResourceURL ,const Sequence< PropertyValue >& Args - ,const char* _pExtraMode ,const OUString& ResourceType ,const Reference< css::ui::XUIElement >& _xMenuBar ,const css::uno::Reference< css::uno::XComponentContext >& _rxContext) { + sal_Int32 nConfigPropertyIndex( Args.getLength() ); + sal_Int32 nURLPropertyIndex( Args.getLength() ); Reference< XUIConfigurationManager > xCfgMgr; - Reference< XUIConfigurationManager > xConfigSource; Reference< XFrame > xFrame; OUString aResourceURL( ResourceURL ); - bool bPersistent( true ); - bool bExtraMode( false ); for ( sal_Int32 n = 0; n < Args.getLength(); n++ ) { if ( Args[n].Name == "ConfigurationSource" ) - Args[n].Value >>= xConfigSource; - else if ( Args[n].Name == "Frame" ) - Args[n].Value >>= xFrame; + { + nConfigPropertyIndex = n; + Args[n].Value >>= xCfgMgr; + } else if ( Args[n].Name == "ResourceURL" ) + { + nURLPropertyIndex = n; Args[n].Value >>= aResourceURL; - else if ( Args[n].Name == "Persistent" ) - Args[n].Value >>= bPersistent; - else if ( _pExtraMode && Args[n].Name.equalsAscii( _pExtraMode )) - Args[n].Value >>= bExtraMode; + } + else if ( Args[n].Name == "Frame" ) + Args[n].Value >>= xFrame; } if (!aResourceURL.startsWith(ResourceType)) throw IllegalArgumentException(); // Identify frame and determine document based ui configuration manager/module ui configuration manager - if ( xFrame.is() && !xConfigSource.is() ) + if ( xFrame.is() && !xCfgMgr.is() ) { bool bHasSettings( false ); Reference< XModel > xModel; @@ -127,25 +127,32 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL } } - PropertyValue aPropValue; - Sequence< Any > aPropSeq( _pExtraMode ? 5 : 4); - aPropValue.Name = "Frame"; - aPropValue.Value <<= xFrame; - aPropSeq[0] <<= aPropValue; - aPropValue.Name = "ConfigurationSource"; - aPropValue.Value <<= xCfgMgr; - aPropSeq[1] <<= aPropValue; - aPropValue.Name = "ResourceURL"; - aPropValue.Value <<= aResourceURL; - aPropSeq[2] <<= aPropValue; - aPropValue.Name = "Persistent"; - aPropValue.Value <<= bPersistent; - aPropSeq[3] <<= aPropValue; - if ( _pExtraMode ) + sal_Int32 nSeqLength( Args.getLength() ); + if ( Args.getLength() == nConfigPropertyIndex ) + nSeqLength++; + if ( Args.getLength() == nURLPropertyIndex ) + nSeqLength++; + if ( nConfigPropertyIndex == nURLPropertyIndex ) + nURLPropertyIndex++; + + Sequence< Any > aPropSeq( nSeqLength ); + for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ ) { - aPropValue.Name = OUString::createFromAscii(_pExtraMode); - aPropValue.Value <<= bExtraMode; - aPropSeq[4] <<= aPropValue; + PropertyValue aPropValue; + if ( n == nURLPropertyIndex ) + { + aPropValue.Name = "ResourceURL"; + aPropValue.Value <<= aResourceURL; + } + else if ( n == nConfigPropertyIndex ) + { + aPropValue.Name = "ConfigurationSource"; + aPropValue.Value <<= xCfgMgr; + } + else + aPropValue = Args[n]; + + aPropSeq[n] <<= aPropValue; } SolarMutexGuard aGuard; diff --git a/framework/source/uifactory/statusbarfactory.cxx b/framework/source/uifactory/statusbarfactory.cxx index bf04d9a127c1..1644e8447d73 100644 --- a/framework/source/uifactory/statusbarfactory.cxx +++ b/framework/source/uifactory/statusbarfactory.cxx @@ -70,7 +70,7 @@ Reference< XUIElement > SAL_CALL StatusBarFactory::createUIElement( { Reference< css::ui::XUIElement > xStatusBar( static_cast<OWeakObject *>(new StatusBarWrapper(m_xContext)), UNO_QUERY); - MenuBarFactory::CreateUIElement(ResourceURL, Args, nullptr, "private:resource/statusbar/", xStatusBar, m_xContext); + MenuBarFactory::CreateUIElement(ResourceURL, Args, "private:resource/statusbar/", xStatusBar, m_xContext); return xStatusBar; } diff --git a/framework/source/uifactory/toolbarfactory.cxx b/framework/source/uifactory/toolbarfactory.cxx index 1b3b99a5c565..6e6391ec994e 100644 --- a/framework/source/uifactory/toolbarfactory.cxx +++ b/framework/source/uifactory/toolbarfactory.cxx @@ -69,7 +69,7 @@ Reference< XUIElement > SAL_CALL ToolBarFactory::createUIElement( { Reference< css::ui::XUIElement > xToolBar( static_cast<OWeakObject *>(new ToolBarWrapper(m_xContext)), UNO_QUERY); - CreateUIElement(ResourceURL, Args, "PopupMode", "private:resource/toolbar/", xToolBar, m_xContext); + CreateUIElement(ResourceURL, Args, "private:resource/toolbar/", xToolBar, m_xContext); return xToolBar; } |