Revision: 6648
          http://skim-app.svn.sourceforge.net/skim-app/?rev=6648&view=rev
Author:   hofman
Date:     2010-07-25 21:38:18 +0000 (Sun, 25 Jul 2010)

Log Message:
-----------
Get presentation options from the current main document. Update by observing 
main window change, need to still do it explicitly when switching between 
fullscreen and presentation

Modified Paths:
--------------
    trunk/NSDocument_SKExtensions.h
    trunk/NSDocument_SKExtensions.m
    trunk/SKApplication.h
    trunk/SKApplication.m
    trunk/SKApplicationController.m
    trunk/SKMainDocument.m
    trunk/SKMainWindowController.m

Modified: trunk/NSDocument_SKExtensions.h
===================================================================
--- trunk/NSDocument_SKExtensions.h     2010-07-25 19:23:44 UTC (rev 6647)
+++ trunk/NSDocument_SKExtensions.h     2010-07-25 21:38:18 UTC (rev 6648)
@@ -38,6 +38,7 @@
 
 #import <Cocoa/Cocoa.h>
 #import <Quartz/Quartz.h>
+#import <Carbon/Carbon.h>
 
 extern NSString *SKDocumentErrorDomain;
 
@@ -49,6 +50,8 @@
 
 @interface NSDocument (SKExtensions)
 
+- (void)getRequiredSystemUIMode:(SystemUIMode *)mode 
systemUIOptions:(SystemUIOptions *)options;
+
 #pragma mark Document Setup
 
 - (void)saveRecentDocumentInfo;

Modified: trunk/NSDocument_SKExtensions.m
===================================================================
--- trunk/NSDocument_SKExtensions.m     2010-07-25 19:23:44 UTC (rev 6647)
+++ trunk/NSDocument_SKExtensions.m     2010-07-25 21:38:18 UTC (rev 6648)
@@ -57,6 +57,11 @@
 
 @implementation NSDocument (SKExtensions)
 
+- (void)getRequiredSystemUIMode:(SystemUIMode *)mode 
systemUIOptions:(SystemUIOptions *)options {
+    if (mode) *mode = kUIModeNormal;
+    if (options) *options = 0;
+}
+
 #pragma mark Document Setup
 
 - (void)saveRecentDocumentInfo {}

Modified: trunk/SKApplication.h
===================================================================
--- trunk/SKApplication.h       2010-07-25 19:23:44 UTC (rev 6647)
+++ trunk/SKApplication.h       2010-07-25 21:38:18 UTC (rev 6648)
@@ -48,6 +48,8 @@
 
 @property (nonatomic, getter=isUserAttentionDisabled) BOOL 
userAttentionDisabled;
 
+- (void)updatePresentationOptions;
+
 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
 - (id <SKApplicationDelegate>)delegate;
 - (void)setDelegate:(id <SKApplicationDelegate>)newDelegate;

Modified: trunk/SKApplication.m
===================================================================
--- trunk/SKApplication.m       2010-07-25 19:23:44 UTC (rev 6647)
+++ trunk/SKApplication.m       2010-07-25 21:38:18 UTC (rev 6648)
@@ -39,6 +39,7 @@
 #import "SKApplication.h"
 #import "NSMenu_SKExtensions.h"
 #import "NSResponder_SKExtensions.h"
+#import "NSDocument_SKExtensions.h"
 
 NSString *SKApplicationStartsTerminatingNotification = 
@"SKApplicationStartsTerminatingNotification";
 
@@ -85,6 +86,16 @@
     [super terminate:sender];
 }
 
+- (void)updatePresentationOptions {
+    SystemUIMode currentMode, mode = kUIModeNormal;
+    SystemUIOptions currentOptions, options = 0;
+    GetSystemUIMode(&currentMode, &currentOptions);
+    NSDocument *doc = [[[self mainWindow] windowController] document];
+    [doc getRequiredSystemUIMode:&mode systemUIOptions:&options];
+    if (mode != currentMode || options != currentOptions)
+        SetSystemUIMode(mode, options);
+}
+
 - (void)reorganizeWindowsItem:(NSWindow *)aWindow {
     NSMenu *windowsMenu = [self windowsMenu];
     NSWindowController *windowController = [aWindow windowController];

Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m     2010-07-25 19:23:44 UTC (rev 6647)
+++ trunk/SKApplicationController.m     2010-07-25 21:38:18 UTC (rev 6648)
@@ -156,22 +156,7 @@
 }
 
 - (void)handleWindowDidBecomeMainNotification:(NSNotification *)aNotification {
-    SystemUIMode currentMode, mode = kUIModeNormal;
-    SystemUIOptions currentOptions, options = 0;
-    GetSystemUIMode(&currentMode, &currentOptions);
-    id doc = [[[aNotification object] windowController] document];
-    SKMainWindowController *mwc = [doc 
respondsToSelector:@selector(mainWindowController)] ? [doc 
mainWindowController] : nil;
-    if ([[[mwc window] screen] isEqual:[NSScreen primaryScreen]]) {
-        if ([mwc interactionMode] == SKPresentationMode) {
-            mode = kUIModeAllHidden;
-            options = kUIOptionDisableProcessSwitch;
-        } else if ([mwc interactionMode] == SKFullScreenMode) {
-            mode = kUIModeAllHidden;
-            options = kUIOptionAutoShowMenuBar;
-        }
-    }
-    if (mode != currentMode || options != currentOptions)
-        SetSystemUIMode(mode, options);
+    [NSApp updatePresentationOptions];
 }
 
 #pragma mark NSApplication delegate

Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m      2010-07-25 19:23:44 UTC (rev 6647)
+++ trunk/SKMainDocument.m      2010-07-25 21:38:18 UTC (rev 6648)
@@ -80,6 +80,7 @@
 #import "NSWindowController_SKExtensions.h"
 #import "NSInvocation_SKExtensions.h"
 #import "SKSyncPreferences.h"
+#import "NSScreen_SKExtensions.h"
 
 #define BUNDLE_DATA_FILENAME @"data"
 #define PRESENTATION_OPTIONS_KEY 
@"net_sourceforge_skim-app_presentation_options"
@@ -272,6 +273,24 @@
        [self 
performSelector:@selector(undoableActionDoesntDirtyDocumentDeferred:) 
withObject:[NSNumber numberWithBool:[[self undoManager] isUndoing]] 
afterDelay:0.0];
 }
 
+
+- (void)getRequiredSystemUIMode:(SystemUIMode *)mode 
systemUIOptions:(SystemUIOptions *)options {
+    SystemUIMode aMode = kUIModeNormal;
+    SystemUIOptions anOptions = 0;
+    SKMainWindowController *mwc = [self mainWindowController];
+    if ([[[mwc window] screen] isEqual:[NSScreen primaryScreen]]) {
+        if ([mwc interactionMode] == SKPresentationMode) {
+            aMode = kUIModeAllHidden;
+            anOptions = kUIOptionDisableProcessSwitch;
+        } else if ([mwc interactionMode] == SKFullScreenMode) {
+            aMode = kUIModeAllHidden;
+            anOptions = kUIOptionAutoShowMenuBar;
+        }
+    }
+    if (mode) *mode = aMode;
+    if (options) *options = anOptions;
+}
+
 #pragma mark Writing
 
 - (NSArray *)writableTypesForSaveOperation:(NSSaveOperationType)saveOperation {

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2010-07-25 19:23:44 UTC (rev 6647)
+++ trunk/SKMainWindowController.m      2010-07-25 21:38:18 UTC (rev 6648)
@@ -1411,10 +1411,6 @@
     BOOL wasPresentation = [self interactionMode] == SKPresentationMode;
     
     NSScreen *screen = [[self window] screen] ?: [NSScreen mainScreen]; // @@ 
screen: or should we use the main screen?
-    if ([screen isEqual:[NSScreen primaryScreen]])
-        SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);
-    else if (wasPresentation)
-        SetSystemUIMode(kUIModeNormal, 0);
     
     interactionMode = SKFullScreenMode;
     
@@ -1423,6 +1419,7 @@
         [pdfView setFrame:[pdfContentView bounds]];
         [pdfContentView addSubview:pdfView];
         [(SKFullScreenWindow *)[self window] setMainView:pdfSplitView];
+        [NSApp updatePresentationOptions];
     } else {
         [self saveNormalSetup];
         [self goFullScreen];
@@ -1451,14 +1448,11 @@
     [self enterPresentationMode];
     
     NSScreen *screen = [[self window] screen] ?: [NSScreen mainScreen]; // @@ 
screen: or should we use the main screen?
-    if ([screen isEqual:[NSScreen primaryScreen]])
-        SetSystemUIMode(kUIModeAllHidden, kUIOptionDisableProcessSwitch);
-    else
-        SetSystemUIMode(kUIModeNormal, 0);
     
     interactionMode = SKPresentationMode;
     
     if (wasFullScreen) {
+        [NSApp updatePresentationOptions];
         [pdfSplitView setFrame:[centerContentView bounds]];
         [centerContentView addSubview:pdfSplitView];
         [(SKFullScreenWindow *)[self window] setMainView:pdfView];
@@ -1530,11 +1524,11 @@
     [mainWindow setLevel:NSNormalWindowLevel];
     [mainWindow setCollectionBehavior:NSWindowCollectionBehaviorDefault];
     [mainWindow display];
-    [fullScreenWindow fadeOut];
     [mainWindow makeFirstResponder:pdfView];
     [mainWindow recalculateKeyViewLoop];
     [mainWindow setDelegate:self];
     [mainWindow makeKeyWindow];
+    [fullScreenWindow fadeOut];
     // the page number may have changed
     [self synchronizeWindowTitleWithDocumentName];
     


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to