Revision: 6616
          http://skim-app.svn.sourceforge.net/skim-app/?rev=6616&view=rev
Author:   hofman
Date:     2010-07-13 10:16:10 +0000 (Tue, 13 Jul 2010)

Log Message:
-----------
Use ivar to distinguish between main and non-main fullscreen windows. Fade out 
pdfview in temporary fullscreen window, so we can let the main fullscreen 
window remain main during the fadeout.

Modified Paths:
--------------
    trunk/SKFullScreenWindow.h
    trunk/SKFullScreenWindow.m
    trunk/SKMainWindowController.m

Modified: trunk/SKFullScreenWindow.h
===================================================================
--- trunk/SKFullScreenWindow.h  2010-07-13 09:37:54 UTC (rev 6615)
+++ trunk/SKFullScreenWindow.h  2010-07-13 10:16:10 UTC (rev 6616)
@@ -40,21 +40,17 @@
 #import "SKMainWindow.h"
 
 
-...@interface SKBlackingFullScreenWindow : SKMainWindow <NSAnimationDelegate> {
+...@interface SKFullScreenWindow : SKMainWindow <NSAnimationDelegate> {
     NSViewAnimation *animation;
+    BOOL canBecomeMain;
 }
 
+...@property (nonatomic, retain) NSView *mainView;
+
 - (id)initWithScreen:(NSScreen *)screen;
+- (id)initWithScreen:(NSScreen *)screen canBecomeMain:(BOOL)flag;
 
 - (void)fadeOutBlocking;
 - (void)fadeOut;
 
 @end
-
-#pragma mark -
-
-...@interface SKFullScreenWindow : SKBlackingFullScreenWindow
-
-...@property (nonatomic, retain) NSView *mainView;
-
-...@end

Modified: trunk/SKFullScreenWindow.m
===================================================================
--- trunk/SKFullScreenWindow.m  2010-07-13 09:37:54 UTC (rev 6615)
+++ trunk/SKFullScreenWindow.m  2010-07-13 10:16:10 UTC (rev 6616)
@@ -43,14 +43,25 @@
 #import "SKStringConstants.h"
 
 
-...@implementation SKBlackingFullScreenWindow
+...@implementation SKFullScreenWindow
 
+...@dynamic mainView;
+
 - (id)initWithScreen:(NSScreen *)screen {
+    return [self initWithScreen:screen canBecomeMain:YES];
+}
+
+- (id)initWithScreen:(NSScreen *)screen canBecomeMain:(BOOL)flag {
     if (screen == nil)
         screen = [NSScreen mainScreen];
     if (self = [self initWithContentRect:[screen frame] 
styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO 
screen:screen]) {
+        canBecomeMain = flag;
         [self setBackgroundColor:[NSColor blackColor]];
         [self 
setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
+        [self setReleasedWhenClosed:canBecomeMain == NO];
+        [self setDisplaysWhenScreenProfileChanges:canBecomeMain];
+        [self setAcceptsMouseMovedEvents:canBecomeMain];
+        [self setExcludedFromWindowsMenu:canBecomeMain == NO];
     }
     return self;
 }
@@ -65,10 +76,32 @@
     [super dealloc];
 }
 
-- (BOOL)canBecomeKeyWindow { return NO; }
+- (BOOL)canBecomeKeyWindow { return canBecomeMain; }
 
-- (BOOL)canBecomeMainWindow { return YES; }
+- (BOOL)canBecomeMainWindow { return canBecomeMain; }
 
+- (void)sendEvent:(NSEvent *)theEvent {
+    if (canBecomeMain && ([theEvent type] == NSLeftMouseDown || [theEvent 
type] == NSRightMouseDown)) {
+        SKMainWindowController *wc = (SKMainWindowController *)[self 
windowController];
+        if ([wc isPresentation] && ([theEvent type] == NSRightMouseDown || 
([theEvent modifierFlags] & NSControlKeyMask))) {
+            [wc doGoToPreviousPage:self];
+            return;
+        }
+    }
+    [super sendEvent:theEvent];
+}
+
+- (void)keyDown:(NSEvent *)theEvent {
+    unichar ch = [theEvent firstCharacter];
+       NSUInteger modifierFlags = [theEvent deviceIndependentModifierFlags];
+    
+    if (canBecomeMain && modifierFlags == 0 && ch == SKEscapeCharacter) {
+        [(SKMainWindowController *)[self windowController] 
exitFullScreen:self];
+        return;
+    }
+    [super keyDown:theEvent];
+}
+
 - (void)orderFront:(id)sender {
     [self stopAnimation];
     [self setAlphaValue:1.0];
@@ -124,55 +157,6 @@
     [self setAlphaValue:1.0];
 }
 
-...@end
-
-#pragma mark -
-
-...@implementation SKFullScreenWindow
-
-...@dynamic mainView;
-
-- (id)initWithScreen:(NSScreen *)screen {
-    if (self = [super initWithScreen:screen]) {
-        [self setReleasedWhenClosed:NO];
-        [self setDisplaysWhenScreenProfileChanges:YES];
-        [self setAcceptsMouseMovedEvents:YES];
-        [self setExcludedFromWindowsMenu:NO];
-    }
-    return self;
-}
-
-- (BOOL)canBecomeKeyWindow { return YES; }
-
-- (BOOL)canBecomeMainWindow { return YES; }
-
-- (void)sendEvent:(NSEvent *)theEvent {
-    if ([theEvent type] == NSLeftMouseDown || [theEvent type] == 
NSRightMouseDown) {
-        SKMainWindowController *wc = (SKMainWindowController *)[self 
windowController];
-        if ([wc isPresentation] && ([theEvent type] == NSRightMouseDown || 
([theEvent modifierFlags] & NSControlKeyMask))) {
-            [wc doGoToPreviousPage:self];
-            return;
-        }
-    }
-    [super sendEvent:theEvent];
-}
-
-- (void)keyDown:(NSEvent *)theEvent {
-    unichar ch = [theEvent firstCharacter];
-       NSUInteger modifierFlags = [theEvent deviceIndependentModifierFlags];
-    
-    if (modifierFlags == 0) {
-        SKMainWindowController *wc = (SKMainWindowController *)[self 
windowController];
-        if (ch == SKEscapeCharacter) {
-            [wc exitFullScreen:self];
-        } else {
-            [super keyDown:theEvent];
-        }
-    } else {
-        [super keyDown:theEvent];
-    }
-}
-
 - (NSView *)mainView {
     return [[[self contentView] subviews] lastObject];
 }

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2010-07-13 09:37:54 UTC (rev 6615)
+++ trunk/SKMainWindowController.m      2010-07-13 10:16:10 UTC (rev 6616)
@@ -1342,7 +1342,7 @@
         [blankingWindows removeAllObjects];
         for (NSScreen *screenToBlank in [NSScreen screens]) {
             if ([screenToBlank isEqual:screen] == NO) {
-                SKBlackingFullScreenWindow *window = 
[[SKBlackingFullScreenWindow alloc] initWithScreen:screenToBlank];
+                SKFullScreenWindow *window = [[SKFullScreenWindow alloc] 
initWithScreen:screenToBlank canBecomeMain:NO];
                 [window setBackgroundColor:backgroundColor];
                 [window setLevel:NSFloatingWindowLevel];
                 [window setFrame:[screenToBlank frame] display:YES];
@@ -1490,12 +1490,18 @@
     if ([[fullScreenWindow firstResponder] isDescendantOf:pdfView])
         [fullScreenWindow makeFirstResponder:nil];
     
-    SKBlackingFullScreenWindow *bgWindow = [[[SKBlackingFullScreenWindow 
alloc] initWithScreen:[fullScreenWindow screen]] autorelease];
-    [bgWindow setBackgroundColor:[fullScreenWindow backgroundColor]];
-    [bgWindow setLevel:[fullScreenWindow level]];
-    [bgWindow orderWindow:NSWindowBelow relativeTo:[fullScreenWindow 
windowNumber]];
+    // first fade out the pdfView so we can move the pdfView to the main 
window before it's revealed
+    // animating the view itself does no work as PDFView does not work nicely 
with CoreAnimation, so we use a temporary window
+    SKFullScreenWindow *fadeWindow = [[SKFullScreenWindow alloc] 
initWithScreen:[fullScreenWindow screen] canBecomeMain:NO];
+    [fadeWindow setBackgroundColor:[fullScreenWindow backgroundColor]];
+    [fadeWindow setLevel:[fullScreenWindow level]];
+    [fadeWindow setMainView:[fullScreenWindow mainView]];
+    [fadeWindow orderWindow:NSWindowAbove relativeTo:[fullScreenWindow 
windowNumber]];
+    [fadeWindow display];
+    [fullScreenWindow display];
     [fullScreenWindow setDelegate:nil];
-    [fullScreenWindow fadeOutBlocking];
+    [fadeWindow fadeOutBlocking];
+    [fadeWindow release];
     
     [pdfView setInteractionMode:SKNormalMode screen:[[self window] screen]];
     // this should be done before exitPresentationMode to get a smooth 
transition
@@ -1515,19 +1521,19 @@
     else
         [self applyPDFSettings:savedNormalSetup];
     
-    [bgWindow setLevel:NSPopUpMenuWindowLevel];
-    
-    SetSystemUIMode(kUIModeNormal, 0);
-    
     for (NSWindowController *wc in [[self document] windowControllers]) {
         if ([wc isNoteWindowController] || [wc isSnapshotWindowController])
             [(id)wc setForceOnTop:NO];
     }
     
+    [fullScreenWindow setLevel:NSPopUpMenuWindowLevel];
+    
+    SetSystemUIMode(kUIModeNormal, 0);
+    
     [self setWindow:mainWindow];
-    [mainWindow orderWindow:NSWindowBelow relativeTo:[bgWindow windowNumber]];
+    [mainWindow orderWindow:NSWindowBelow relativeTo:[fullScreenWindow 
windowNumber]];
     [mainWindow display];
-    [bgWindow fadeOut];
+    [fullScreenWindow fadeOut];
     [mainWindow makeFirstResponder:pdfView];
     [mainWindow recalculateKeyViewLoop];
     [mainWindow setDelegate:self];


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