diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-01-18 18:27:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-17 12:56:51 +0200 |
commit | 9090dc1f3b27195f5defd35586ac79357992be21 (patch) | |
tree | d39f4b624ae337d5c9ce76eba8521b76e53afa05 /toolkit/source | |
parent | c8cf2e0e088b74afa52564945a9c005b3b86bf7e (diff) |
split OutputDevice from Window
as part of a longer-term goal of doing our
widget rendering only inside a top-level render-
context.
I moved all of the OutputDevice-related code that existed in vcl::Window
into a new subclass of OutputDevice called WindowOutputDevice.
Notes for further work
(*) not sure why we are getting an 1x1 surface in
SvpSalGraphics::releaseCairoContext, but to fix it I clamp
the size there
(*) might have to dump VCLXDevice, and move it's code down into VCLXWindow and VCLXVirtualDevice
(*) can we remove use of VCLXDevice in other places, in favour of just talking to the VCL code?
Change-Id: I105946377f5322677d6f7d0c1c23847178a720b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113204
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'toolkit/source')
-rw-r--r-- | toolkit/source/awt/vclxcontainer.cxx | 10 | ||||
-rw-r--r-- | toolkit/source/awt/vclxwindow.cxx | 23 | ||||
-rw-r--r-- | toolkit/source/awt/vclxwindows.cxx | 8 | ||||
-rw-r--r-- | toolkit/source/controls/unocontrol.cxx | 4 | ||||
-rw-r--r-- | toolkit/source/helper/btndlg.cxx | 2 |
5 files changed, 20 insertions, 27 deletions
diff --git a/toolkit/source/awt/vclxcontainer.cxx b/toolkit/source/awt/vclxcontainer.cxx index e070c3239ab7..082cdacaa786 100644 --- a/toolkit/source/awt/vclxcontainer.cxx +++ b/toolkit/source/awt/vclxcontainer.cxx @@ -254,15 +254,7 @@ void SAL_CALL VCLXContainer::setProperty( TabPage* pScrollTabPage = dynamic_cast< TabPage* >( pWindow.get() ); if ( pWindow && (pScrollable || pScrollTabPage) ) { - OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); - if ( !pDev ) - pDev = pWindow->GetParent(); - // shouldn't happen but it appears pDev can be NULL - // #FIXME ( find out how/why ) - if ( !pDev ) - break; - - aSize = pDev->LogicToPixel( aSize, aMode ); + aSize = pWindow->LogicToPixel( aSize, aMode ); switch ( nPropType ) { case BASEPROPERTY_SCROLLHEIGHT: diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index 2a90325ef9a3..215fdbaf2d88 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -351,7 +351,7 @@ void VCLXWindow::SetWindow( const VclPtr<vcl::Window> &pWindow ) // GetWindow()->DbgAssertNoEventListeners(); } - SetOutputDevice( pWindow ); + SetOutputDevice( pWindow ? pWindow->GetOutDev() : nullptr ); if ( GetWindow() ) { @@ -910,15 +910,14 @@ void VCLXWindow::dispose( ) mpImpl->disposing(); - if ( auto pWindow = GetWindow() ) + if ( VclPtr<vcl::Window> pWindow = GetWindow() ) { pWindow->RemoveEventListener( LINK( this, VCLXWindow, WindowEventListener ) ); pWindow->SetWindowPeer( nullptr, nullptr ); pWindow->SetAccessible( nullptr ); - VclPtr<OutputDevice> pOutDev = GetOutputDevice(); SetOutputDevice( nullptr ); - pOutDev.disposeAndClear(); + pWindow.disposeAndClear(); } // #i14103# dispose the accessible context after the window has been destroyed, @@ -1674,22 +1673,22 @@ void VCLXWindow::setProperty( const OUString& PropertyName, const css::uno::Any& break; case BASEPROPERTY_FILLCOLOR: if ( bVoid ) - pWindow->SetFillColor(); + pWindow->GetOutDev()->SetFillColor(); else { Color nColor; if ( Value >>= nColor ) - pWindow->SetFillColor( nColor ); + pWindow->GetOutDev()->SetFillColor( nColor ); } break; case BASEPROPERTY_LINECOLOR: if ( bVoid ) - pWindow->SetLineColor(); + pWindow->GetOutDev()->SetLineColor(); else { Color nColor; if ( Value >>= nColor ) - pWindow->SetLineColor( nColor ); + pWindow->GetOutDev()->SetLineColor( nColor ); } break; case BASEPROPERTY_BORDER: @@ -2012,10 +2011,10 @@ css::uno::Any VCLXWindow::getProperty( const OUString& PropertyName ) aProp <<= GetWindow()->GetTextLineColor(); break; case BASEPROPERTY_FILLCOLOR: - aProp <<= GetWindow()->GetFillColor(); + aProp <<= GetWindow()->GetOutDev()->GetFillColor(); break; case BASEPROPERTY_LINECOLOR: - aProp <<= GetWindow()->GetLineColor(); + aProp <<= GetWindow()->GetOutDev()->GetLineColor(); break; case BASEPROPERTY_BORDER: { @@ -2227,7 +2226,7 @@ void VCLXWindow::draw( sal_Int32 nX, sal_Int32 nY ) OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( mpImpl->mxViewGraphics ); if (!pDev) - pDev = pWindow->GetParent(); + pDev = pWindow->GetParent()->GetOutDev(); TabPage* pTabPage = dynamic_cast< TabPage* >( pWindow.get() ); if ( pTabPage ) { @@ -2239,7 +2238,7 @@ void VCLXWindow::draw( sal_Int32 nX, sal_Int32 nY ) Point aPos( nX, nY ); - if ( pWindow->GetParent() && !pWindow->IsSystemWindow() && ( pWindow->GetParent() == pDev ) ) + if ( pWindow->GetParent() && !pWindow->IsSystemWindow() && ( pWindow->GetParent()->GetOutDev() == pDev ) ) { // #i40647# don't draw here if this is a recursive call // sometimes this is called recursively, because the Update call on the parent diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index e53f334de303..ce81e68fdd2e 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -2387,7 +2387,7 @@ void SAL_CALL VCLXDialog::draw( sal_Int32 nX, sal_Int32 nY ) { OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); if ( !pDev ) - pDev = pWindow->GetParent(); + pDev = pWindow->GetParent()->GetOutDev(); Point aPos = pDev->PixelToLogic( Point( nX, nY ) ); pWindow->Draw( pDev, aPos, DrawFlags::NoControls ); @@ -2508,7 +2508,7 @@ void SAL_CALL VCLXMultiPage::draw( sal_Int32 nX, sal_Int32 nY ) { OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); if ( !pDev ) - pDev = pWindow->GetParent(); + pDev = pWindow->GetParent()->GetOutDev(); Point aPos = pDev->PixelToLogic( Point( nX, nY ) ); pWindow->Draw( pDev, aPos, DrawFlags::NoControls ); @@ -2753,7 +2753,7 @@ void SAL_CALL VCLXTabPage::draw( sal_Int32 nX, sal_Int32 nY ) { OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); if ( !pDev ) - pDev = pWindow->GetParent(); + pDev = pWindow->GetParent()->GetOutDev(); Point aPos = pDev->PixelToLogic( Point( nX, nY ) ); pWindow->Draw( pDev, aPos, DrawFlags::NoControls ); @@ -6241,7 +6241,7 @@ void SAL_CALL VCLXFrame::draw( sal_Int32 nX, sal_Int32 nY ) { OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); if ( !pDev ) - pDev = pWindow->GetParent(); + pDev = pWindow->GetParent()->GetOutDev(); Point aPos = pDev->PixelToLogic( Point( nX, nY ) ); pWindow->Draw( pDev, aPos, DrawFlags::NoControls ); diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx index a97cb2229942..e669e7e9889e 100644 --- a/toolkit/source/controls/unocontrol.cxx +++ b/toolkit/source/controls/unocontrol.cxx @@ -183,7 +183,9 @@ Reference< XWindowPeer > UnoControl::ImplGetCompatiblePeer() vcl::Window* pParentWindow( nullptr ); { SolarMutexGuard aGuard; - pParentWindow = dynamic_cast< vcl::Window* >( Application::GetDefaultDevice() ); + auto pDefaultDevice = Application::GetDefaultDevice(); + if (pDefaultDevice) + pParentWindow = pDefaultDevice->GetOwnerWindow(); ENSURE_OR_THROW( pParentWindow != nullptr, "could obtain a default parent window!" ); } try diff --git a/toolkit/source/helper/btndlg.cxx b/toolkit/source/helper/btndlg.cxx index 64124928babc..a2471c3f92cd 100644 --- a/toolkit/source/helper/btndlg.cxx +++ b/toolkit/source/helper/btndlg.cxx @@ -100,7 +100,7 @@ tools::Long ButtonDialog::ImplGetButtonSize() { nSepSize += nLastSepSize; - tools::Long nTxtWidth = it->mpPushButton->GetCtrlTextWidth(it->mpPushButton->GetText()); + tools::Long nTxtWidth = it->mpPushButton->GetOutDev()->GetCtrlTextWidth(it->mpPushButton->GetText()); nTxtWidth += IMPL_EXTRA_BUTTON_WIDTH; if ( nTxtWidth > maCtrlSize.Width() ) |