[Libreoffice-commits] core.git: vcl/osx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Dec 11 14:16:39 UTC 2018


 vcl/osx/salframe.cxx |  115 ++++++++++++++++++++++-----------------------------
 1 file changed, 51 insertions(+), 64 deletions(-)

New commits:
commit 011033cd847d037e4c6a696d3f8a99277b71a503
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Fri Nov 23 13:43:15 2018 +0100
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Tue Dec 11 15:16:12 2018 +0100

    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: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index 3a6cabbc41d2..d09fcf0cb43c 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -552,45 +552,45 @@ void AquaSalFrame::GetClientSize( long& rWidth, long& rHeight )
 
 void AquaSalFrame::SetWindowState( const SalFrameState* pState )
 {
+    if (!mpNSWindow)
+        return;
+
     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
-        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 )
-        {
-            if(! [mpNSWindow isZoomed])
-                [mpNSWindow zoom: NSApp];
-        }
-        else
-        {
-            if( [mpNSWindow isZoomed] )
-                [mpNSWindow zoom: NSApp];
-        }
+        if (![mpNSWindow isZoomed])
+            [mpNSWindow zoom: NSApp];
+    }
+    else
+    {
+        if ([mpNSWindow isZoomed])
+            [mpNSWindow zoom: NSApp];
     }
 
     // get new geometry
@@ -602,7 +602,6 @@ void AquaSalFrame::SetWindowState( const SalFrameState* pState )
         mbPositioned = true;
         nEvent = SalEvent::Move;
     }
-
     if( pState->mnMask & (WindowStateMask::Width | WindowStateMask::Height) )
     {
         mbSized = true;
@@ -612,7 +611,7 @@ void AquaSalFrame::SetWindowState( const SalFrameState* pState )
     if( nEvent != SalEvent::NONE )
         CallCallback( nEvent, nullptr );
 
-    if( mbShown && mpNSWindow )
+    if (mbShown)
     {
         // trigger filling our backbuffer
         SendPaintEvent();
@@ -757,31 +756,25 @@ void AquaSalFrame::ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay )
             [NSMenu setMenuBarVisible:NO];
 
         maFullScreenRect = [mpNSWindow frame];
-        {
-            [mpNSWindow setFrame: [NSWindow frameRectForContentRect: aNewContentRect styleMask: mnStyleMask] display: mbShown ? YES : NO];
-        }
 
-        UpdateFrameGeometry();
-
-        if( mbShown )
-            CallCallback( SalEvent::MoveResize, nullptr );
+        [mpNSWindow setFrame: [NSWindow frameRectForContentRect: aNewContentRect styleMask: mnStyleMask] display: mbShown ? YES : NO];
     }
     else
     {
-        {
-            [mpNSWindow setFrame: maFullScreenRect display: mbShown ? YES : NO];
-        }
-        UpdateFrameGeometry();
-
-        if( mbShown )
-            CallCallback( SalEvent::MoveResize, nullptr );
+        [mpNSWindow setFrame: maFullScreenRect display: mbShown ? YES : NO];
 
         // show the dock and the menubar
         [NSMenu setMenuBarVisible:YES];
     }
-    if( mbShown )
+
+    UpdateFrameGeometry();
+    if (mbShown)
+    {
+        CallCallback(SalEvent::MoveResize, nullptr);
+
         // trigger filling our backbuffer
         SendPaintEvent();
+    }
 }
 
 void AquaSalFrame::StartPresentation( bool bStart )
@@ -1661,11 +1654,8 @@ void AquaSalFrame::ResetClipRegion()
 
     if( mpNSView && mbShown )
         [mpNSView setNeedsDisplay: YES];
-    if( mpNSWindow )
-    {
-        [mpNSWindow setOpaque: YES];
-        [mpNSWindow invalidateShadow];
-    }
+    [mpNSWindow setOpaque: YES];
+    [mpNSWindow invalidateShadow];
 }
 
 void AquaSalFrame::BeginSetClipRegion( sal_uLong nRects )
@@ -1718,12 +1708,9 @@ void AquaSalFrame::EndSetClipRegion()
     }
     if( mpNSView && mbShown )
         [mpNSView setNeedsDisplay: YES];
-    if( mpNSWindow )
-    {
-        [mpNSWindow setOpaque: (mrClippingPath != nullptr) ? NO : YES];
-        [mpNSWindow setBackgroundColor: [NSColor clearColor]];
-        // shadow is invalidated when view gets drawn again
-    }
+    [mpNSWindow setOpaque: (mrClippingPath != nullptr) ? NO : YES];
+    [mpNSWindow setBackgroundColor: [NSColor clearColor]];
+    // shadow is invalidated when view gets drawn again
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list