[Libreoffice-commits] .: vcl/aqua vcl/inc

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Dec 21 05:35:48 PST 2012


 vcl/aqua/source/window/salframe.cxx    |   54 +++++++++++++++++++++++++++++++++
 vcl/aqua/source/window/salframeview.mm |   37 ++++++++++++++++++++++
 vcl/inc/aqua/salframeview.h            |    2 +
 3 files changed, 93 insertions(+)

New commits:
commit b2e5a39babba902707dab28d81b843d1aef055dc
Author: Tor Lillqvist <tml at iki.fi>
Date:   Fri Dec 21 15:26:36 2012 +0200

    fdo#39983: Support Mac OS X 10.7 full-screen mode
    
    Should be good enough for now, at least doesn't break any existing
    functionality if you don't use the system provided full-screen
    buttons. Should continue to compile against older SDKs but still work
    also on newer OSes.
    
    There are some known glitches. For instance if you choose View:Full
    Screen, the window does go into the system full-screen state, but if
    you then use the system unfullscreen button on the (now no longer
    disabled, but hidden) menubar, LO keeps displaying its own small
    floating unfullscreen dialog...
    
    I also occasionally managed to get some menus in the menubar borked
    with no text!? But as traditionally a full-screened LO has no menubar
    at all, technically that isn't a regression;)
    
    Partially based on my own old patch, partially on
    http://svn.apache.org/viewvc?view=revision&revision=1423520 ,
    http://svn.apache.org/viewvc?view=revision&revision=1423523 by Herbert
    Duerr <hdu at apache.org>.
    
    Change-Id: I546c58f7cee9f8cb6c746eb014d8d5a8af3619cb

diff --git a/vcl/aqua/source/window/salframe.cxx b/vcl/aqua/source/window/salframe.cxx
index 5aa6f0f..b836784 100644
--- a/vcl/aqua/source/window/salframe.cxx
+++ b/vcl/aqua/source/window/salframe.cxx
@@ -46,6 +46,18 @@
 #include <Carbon/Carbon.h>
 #include "postmac.h"
 
+#if !defined(MAC_OS_X_VERSION_10_7)
+
+enum {
+    NSFullScreenWindowMask = (1 << 14)
+};
+
+enum {
+    NSWindowCollectionBehaviorFullScreenPrimary = (1 << 7),
+    NSWindowCollectionBehaviorFullScreenAuxiliary = (1 << 8)
+};
+
+#endif
 
 using namespace std;
 
@@ -196,6 +208,31 @@ void AquaSalFrame::initWindowAndView()
         return;
     }
 
+    // On 10.7 and later, if the window is suitable and is
+    // resizable, we make it full-screenable.
+
+    bool bAllowFullScreen = (0 == (mnStyle & (SAL_FRAME_STYLE_DIALOG | SAL_FRAME_STYLE_TOOLTIP | SAL_FRAME_STYLE_SYSTEMCHILD | SAL_FRAME_STYLE_FLOAT | SAL_FRAME_STYLE_TOOLWINDOW | SAL_FRAME_STYLE_INTRO)));
+    bAllowFullScreen &= (0 == (~mnStyle & (SAL_FRAME_STYLE_SIZEABLE)));
+    bAllowFullScreen &= (mpParent == NULL);
+
+    if (GetSalData()->mnSystemVersion >= 0x1070 &&
+       ((mnStyleMask & NSTitledWindowMask) && (mnStyleMask & NSResizableWindowMask))) {
+
+        // Hmm. The docs say that one should use NSInvocation whenever
+        // the method does not return an object. collectionBehavior
+        // returns an NSWindowCollectionBehavior (NSUInteger). So
+        // should I? Or maybe I should just use the low-level
+        // objc_msgSend()?
+        NSWindowCollectionBehavior behavior = (NSWindowCollectionBehavior) [mpWindow performSelector: @selector(collectionBehavior)];
+
+        SAL_INFO("vcl.macosx", OSL_THIS_FUNC << ": bAllowFullScreen=" << bAllowFullScreen << ", behavior=" << hex << behavior);
+
+        [mpWindow performSelector: @selector(setCollectionBehavior:) withObject: (id) (behavior | (bAllowFullScreen ? NSWindowCollectionBehaviorFullScreenPrimary : NSWindowCollectionBehaviorFullScreenAuxiliary))];
+
+        behavior = (NSWindowCollectionBehavior) [mpWindow performSelector: @selector(collectionBehavior)];
+        SAL_INFO("vcl.macosx", OSL_THIS_FUNC << ": after setCollectionBehavior: behavior=" << hex << behavior);
+    }
+
     if( (mnStyle & SAL_FRAME_STYLE_TOOLTIP) )
         [mpWindow setIgnoresMouseEvents: YES];
     else
@@ -741,10 +778,27 @@ void AquaSalFrame::ShowFullScreen( sal_Bool bFullScreen, sal_Int32 nDisplay )
     // #i113170# may not be the main thread if called from UNO API
     SalData::ensureThreadAutoreleasePool();
 
+    SAL_INFO("vcl.macosx", OSL_THIS_FUNC << ": mbFullScreen=" << mbFullScreen << ", bFullScreen=" << bFullScreen);
+
     if( mbFullScreen == bFullScreen )
         return;
 
     mbFullScreen = bFullScreen;
+
+    if (GetSalData()->mnSystemVersion >= 0x1070) {
+        // If the system full-screen state already is our desired, do nothing
+        if ((([mpWindow styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask) == mbFullScreen)
+            return;
+
+        SAL_INFO("vcl.macosx", OSL_THIS_FUNC << ": calling toggleFullScreen()");
+
+        // Otherwise toggle the system full-screen state
+        [mpWindow performSelector: @selector(toggleFullScreen:)];
+
+        // Nothing more to do?
+        return;
+    }
+
     if( bFullScreen )
     {
         // hide the dock and the menubar if we are on the menu screen
diff --git a/vcl/aqua/source/window/salframeview.mm b/vcl/aqua/source/window/salframeview.mm
index d6861a4..621b982 100644
--- a/vcl/aqua/source/window/salframeview.mm
+++ b/vcl/aqua/source/window/salframeview.mm
@@ -273,6 +273,43 @@ static AquaSalFrame* getMouseContainerFrame()
     }
 }
 
+-(void)windowDidEnterFullScreen: (NSNotification*)pNotification
+{
+    (void)pNotification;
+    YIELD_GUARD;
+
+    if( !mpFrame || !AquaSalFrame::isAlive( mpFrame))
+        return;
+
+    SAL_INFO("vcl.macosx", OSL_THIS_FUNC << ": mbFullScreen was " << mpFrame->mbFullScreen);
+
+    mpFrame->mbFullScreen = true;
+}
+
+-(void)windowDidExitFullScreen: (NSNotification*)pNotification
+{
+    (void)pNotification;
+    YIELD_GUARD;
+
+    if( !mpFrame || !AquaSalFrame::isAlive( mpFrame))
+        return;
+
+    SAL_INFO("vcl.macosx", OSL_THIS_FUNC << ": mbFullScreen was " << mpFrame->mbFullScreen);
+
+    mpFrame->mbFullScreen = false;
+
+    // Without this, if viewing the Start Centre in the system
+    // full-screen state, when going back using the system's
+    // unfulscreen menubar button, the Start Centre ends up
+    // garbled. For some reason the same doesn't happen in Writer,
+    // Calc etc.
+    if( mpFrame->mbShown )
+    {
+        mpFrame->CallCallback( SALEVENT_MOVERESIZE, NULL );
+        mpFrame->SendPaintEvent();
+    }
+}
+
 -(void)windowDidMiniaturize: (NSNotification*)pNotification
 {
     (void)pNotification;
diff --git a/vcl/inc/aqua/salframeview.h b/vcl/inc/aqua/salframeview.h
index 2387411..ece2672 100644
--- a/vcl/inc/aqua/salframeview.h
+++ b/vcl/inc/aqua/salframeview.h
@@ -35,6 +35,8 @@
 -(void)windowDidChangeScreen: (NSNotification*)pNotification;
 -(void)windowDidMove: (NSNotification*)pNotification;
 -(void)windowDidResize: (NSNotification*)pNotification;
+-(void)windowDidEnterFullScreen: (NSNotification*)pNotification;
+-(void)windowDidExitFullScreen: (NSNotification*)pNotification;
 -(void)windowDidMiniaturize: (NSNotification*)pNotification;
 -(void)windowDidDeminiaturize: (NSNotification*)pNotification;
 -(BOOL)windowShouldClose: (NSNotification*)pNotification;


More information about the Libreoffice-commits mailing list