Kaydet (Commit) 011033cd authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

OSX cleanup some AquaSalFrame code

Don't send a SalEvent from AquaSalFrame::SetWindowState, if we
don't have a NSWindow and therefore can't actually move. Just
like most other function, we can return early in this case.

Also clean up duplicate code in AquaSalFrame::ShowFullScreen and
remove some duplicate mpNSWindow checks.

Change-Id: I90365ea64191682a7e867b80467c0a1bafdbc868
Reviewed-on: https://gerrit.libreoffice.org/64951
Tested-by: Jenkins
Reviewed-by: 's avatarJan-Marek Glogowski <glogow@fbihome.de>
üst d00513ab
...@@ -552,45 +552,45 @@ void AquaSalFrame::GetClientSize( long& rWidth, long& rHeight ) ...@@ -552,45 +552,45 @@ void AquaSalFrame::GetClientSize( long& rWidth, long& rHeight )
void AquaSalFrame::SetWindowState( const SalFrameState* pState ) void AquaSalFrame::SetWindowState( const SalFrameState* pState )
{ {
if (!mpNSWindow)
return;
OSX_SALDATA_RUNINMAIN( SetWindowState( pState ) ) OSX_SALDATA_RUNINMAIN( SetWindowState( pState ) )
if ( mpNSWindow ) // set normal state
NSRect aStateRect = [mpNSWindow frame];
aStateRect = [NSWindow contentRectForFrameRect: aStateRect styleMask: mnStyleMask];
CocoaToVCL(aStateRect);
if (pState->mnMask & WindowStateMask::X)
aStateRect.origin.x = float(pState->mnX);
if (pState->mnMask & WindowStateMask::Y)
aStateRect.origin.y = float(pState->mnY);
if (pState->mnMask & WindowStateMask::Width)
aStateRect.size.width = float(pState->mnWidth);
if (pState->mnMask & WindowStateMask::Height)
aStateRect.size.height = float(pState->mnHeight);
VCLToCocoa(aStateRect);
aStateRect = [NSWindow frameRectForContentRect: aStateRect styleMask: mnStyleMask];
[mpNSWindow setFrame: aStateRect display: NO];
if (pState->mnState == WindowStateState::Minimized)
[mpNSWindow miniaturize: NSApp];
else if ([mpNSWindow isMiniaturized])
[mpNSWindow deminiaturize: NSApp];
/* ZOOMED is not really maximized (actually it toggles between a user set size and
the program specified one), but comes closest since the default behavior is
"maximized" if the user did not intervene
*/
if (pState->mnState == WindowStateState::Maximized)
{ {
// set normal state if (![mpNSWindow isZoomed])
NSRect aStateRect = [mpNSWindow frame]; [mpNSWindow zoom: NSApp];
aStateRect = [NSWindow contentRectForFrameRect: aStateRect styleMask: mnStyleMask]; }
CocoaToVCL( aStateRect ); else
if( pState->mnMask & WindowStateMask::X ) {
aStateRect.origin.x = float(pState->mnX); if ([mpNSWindow isZoomed])
if( pState->mnMask & WindowStateMask::Y ) [mpNSWindow zoom: NSApp];
aStateRect.origin.y = float(pState->mnY);
if( pState->mnMask & WindowStateMask::Width )
aStateRect.size.width = float(pState->mnWidth);
if( pState->mnMask & WindowStateMask::Height )
aStateRect.size.height = float(pState->mnHeight);
VCLToCocoa( aStateRect );
aStateRect = [NSWindow frameRectForContentRect: aStateRect styleMask: mnStyleMask];
[mpNSWindow setFrame: aStateRect display: NO];
if( pState->mnState == WindowStateState::Minimized )
[mpNSWindow miniaturize: NSApp];
else if( [mpNSWindow isMiniaturized] )
[mpNSWindow deminiaturize: NSApp];
/* ZOOMED is not really maximized (actually it toggles between a user set size and
the program specified one), but comes closest since the default behavior is
"maximized" if the user did not intervene
*/
if( pState->mnState == WindowStateState::Maximized )
{
if(! [mpNSWindow isZoomed])
[mpNSWindow zoom: NSApp];
}
else
{
if( [mpNSWindow isZoomed] )
[mpNSWindow zoom: NSApp];
}
} }
// get new geometry // get new geometry
...@@ -602,7 +602,6 @@ void AquaSalFrame::SetWindowState( const SalFrameState* pState ) ...@@ -602,7 +602,6 @@ void AquaSalFrame::SetWindowState( const SalFrameState* pState )
mbPositioned = true; mbPositioned = true;
nEvent = SalEvent::Move; nEvent = SalEvent::Move;
} }
if( pState->mnMask & (WindowStateMask::Width | WindowStateMask::Height) ) if( pState->mnMask & (WindowStateMask::Width | WindowStateMask::Height) )
{ {
mbSized = true; mbSized = true;
...@@ -612,7 +611,7 @@ void AquaSalFrame::SetWindowState( const SalFrameState* pState ) ...@@ -612,7 +611,7 @@ void AquaSalFrame::SetWindowState( const SalFrameState* pState )
if( nEvent != SalEvent::NONE ) if( nEvent != SalEvent::NONE )
CallCallback( nEvent, nullptr ); CallCallback( nEvent, nullptr );
if( mbShown && mpNSWindow ) if (mbShown)
{ {
// trigger filling our backbuffer // trigger filling our backbuffer
SendPaintEvent(); SendPaintEvent();
...@@ -757,31 +756,25 @@ void AquaSalFrame::ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) ...@@ -757,31 +756,25 @@ void AquaSalFrame::ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay )
[NSMenu setMenuBarVisible:NO]; [NSMenu setMenuBarVisible:NO];
maFullScreenRect = [mpNSWindow frame]; maFullScreenRect = [mpNSWindow frame];
{
[mpNSWindow setFrame: [NSWindow frameRectForContentRect: aNewContentRect styleMask: mnStyleMask] display: mbShown ? YES : NO];
}
UpdateFrameGeometry(); [mpNSWindow setFrame: [NSWindow frameRectForContentRect: aNewContentRect styleMask: mnStyleMask] display: mbShown ? YES : NO];
if( mbShown )
CallCallback( SalEvent::MoveResize, nullptr );
} }
else else
{ {
{ [mpNSWindow setFrame: maFullScreenRect display: mbShown ? YES : NO];
[mpNSWindow setFrame: maFullScreenRect display: mbShown ? YES : NO];
}
UpdateFrameGeometry();
if( mbShown )
CallCallback( SalEvent::MoveResize, nullptr );
// show the dock and the menubar // show the dock and the menubar
[NSMenu setMenuBarVisible:YES]; [NSMenu setMenuBarVisible:YES];
} }
if( mbShown )
UpdateFrameGeometry();
if (mbShown)
{
CallCallback(SalEvent::MoveResize, nullptr);
// trigger filling our backbuffer // trigger filling our backbuffer
SendPaintEvent(); SendPaintEvent();
}
} }
void AquaSalFrame::StartPresentation( bool bStart ) void AquaSalFrame::StartPresentation( bool bStart )
...@@ -1661,11 +1654,8 @@ void AquaSalFrame::ResetClipRegion() ...@@ -1661,11 +1654,8 @@ void AquaSalFrame::ResetClipRegion()
if( mpNSView && mbShown ) if( mpNSView && mbShown )
[mpNSView setNeedsDisplay: YES]; [mpNSView setNeedsDisplay: YES];
if( mpNSWindow ) [mpNSWindow setOpaque: YES];
{ [mpNSWindow invalidateShadow];
[mpNSWindow setOpaque: YES];
[mpNSWindow invalidateShadow];
}
} }
void AquaSalFrame::BeginSetClipRegion( sal_uLong nRects ) void AquaSalFrame::BeginSetClipRegion( sal_uLong nRects )
...@@ -1718,12 +1708,9 @@ void AquaSalFrame::EndSetClipRegion() ...@@ -1718,12 +1708,9 @@ void AquaSalFrame::EndSetClipRegion()
} }
if( mpNSView && mbShown ) if( mpNSView && mbShown )
[mpNSView setNeedsDisplay: YES]; [mpNSView setNeedsDisplay: YES];
if( mpNSWindow ) [mpNSWindow setOpaque: (mrClippingPath != nullptr) ? NO : YES];
{ [mpNSWindow setBackgroundColor: [NSColor clearColor]];
[mpNSWindow setOpaque: (mrClippingPath != nullptr) ? NO : YES]; // shadow is invalidated when view gets drawn again
[mpNSWindow setBackgroundColor: [NSColor clearColor]];
// shadow is invalidated when view gets drawn again
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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