summaryrefslogtreecommitdiff
path: root/vcl/source/window/syswin.cxx
diff options
context:
space:
mode:
authorPhilipp Lohmann [pl] <Philipp.Lohmann@Sun.COM>2010-05-04 18:15:36 +0200
committerPhilipp Lohmann [pl] <Philipp.Lohmann@Sun.COM>2010-05-04 18:15:36 +0200
commitc999e914a371d37ec37aab2db3c2d5f8a62ee192 (patch)
treea22b044cbc800b845fcd888b1446eb8814e82a73 /vcl/source/window/syswin.cxx
parent03efbb4e37d70ea1bd8f2616ce6c6e5a84e61378 (diff)
vcl111: #i42282# do not position dialogs outside the screen just because the screen existed in the last session
Diffstat (limited to 'vcl/source/window/syswin.cxx')
-rw-r--r--vcl/source/window/syswin.cxx61
1 files changed, 61 insertions, 0 deletions
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index 056b55dc3b61..f3624ef56f59 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -659,6 +659,63 @@ static void ImplWindowStateToStr( const WindowStateData& rData, ByteString& rStr
// -----------------------------------------------------------------------
+void SystemWindow::ImplMoveToScreen( long& io_rX, long& io_rY, long i_nWidth, long i_nHeight, Window* i_pConfigureWin )
+{
+ Rectangle aScreenRect;
+ if( Application::IsMultiDisplay() )
+ {
+ aScreenRect = Application::GetScreenPosSizePixel( GetScreenNumber() );
+ }
+ else
+ {
+ aScreenRect = Application::GetScreenPosSizePixel( 0 );
+ for( unsigned int i = 1; i < Application::GetScreenCount(); i++ )
+ aScreenRect.Union( Application::GetScreenPosSizePixel( i ) );
+ }
+ // unfortunately most of the time width and height are not really known
+ if( i_nWidth < 1 )
+ i_nWidth = 50;
+ if( i_nHeight < 1 )
+ i_nHeight = 50;
+
+ // check left border
+ bool bMove = false;
+ if( io_rX + i_nWidth < aScreenRect.Left() )
+ {
+ bMove = true;
+ io_rX = aScreenRect.Left();
+ }
+ // check right border
+ if( io_rX > aScreenRect.Right() - i_nWidth )
+ {
+ bMove = true;
+ io_rX = aScreenRect.Right() - i_nWidth;
+ }
+ // check top border
+ if( io_rY + i_nHeight < aScreenRect.Top() )
+ {
+ bMove = true;
+ io_rY = aScreenRect.Top();
+ }
+ // check bottom border
+ if( io_rY > aScreenRect.Bottom() - i_nHeight )
+ {
+ bMove = true;
+ io_rY = aScreenRect.Bottom() - i_nHeight;
+ }
+ Window* pParent = i_pConfigureWin->GetParent();
+ if( bMove && pParent )
+ {
+ // calculate absolute screen pos here, since that is what is contained in WindowState
+ Point aParentAbsPos( pParent->OutputToAbsoluteScreenPixel( Point(0,0) ) );
+ Size aParentSizePixel( pParent->GetOutputSizePixel() );
+ Point aPos( (aParentSizePixel.Width() - i_nWidth) / 2,
+ (aParentSizePixel.Height() - i_nHeight) / 2 );
+ io_rX = aParentAbsPos.X() + aPos.X();
+ io_rY = aParentAbsPos.Y() + aPos.Y();
+ }
+}
+
void SystemWindow::SetWindowStateData( const WindowStateData& rData )
{
ULONG nValidMask = rData.GetMask();
@@ -701,6 +758,10 @@ void SystemWindow::SetWindowStateData( const WindowStateData& rData )
//nState &= ~(WINDOWSTATE_STATE_MINIMIZED);
aState.mnState = nState & SAL_FRAMESTATE_SYSTEMMASK;
+ // normalize window positions onto screen
+ ImplMoveToScreen( aState.mnX, aState.mnY, aState.mnWidth, aState.mnHeight, pWindow );
+ ImplMoveToScreen( aState.mnMaximizedX, aState.mnMaximizedY, aState.mnMaximizedWidth, aState.mnMaximizedHeight, pWindow );
+
// #96568# avoid having multiple frames at the same screen location
// do the check only if not maximized
if( !((rData.GetMask() & WINDOWSTATE_MASK_STATE) && (nState & WINDOWSTATE_STATE_MAXIMIZED)) )