Kaydet (Commit) 4c6f17f7 authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky

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/42937Reviewed-by: 's avatarMaxim Monastirsky <momonasmon@gmail.com>
Tested-by: 's avatarMaxim Monastirsky <momonasmon@gmail.com>
üst cb997040
......@@ -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);
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment