Revision: 15304
          http://sourceforge.net/p/skim-app/code/15304
Author:   hofman
Date:     2025-05-26 22:23:53 +0000 (Mon, 26 May 2025)
Log Message:
-----------
Use local variables for normal window during presentation switch and for static 
display window for fullscreen animation. Rename ivar.

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

Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h      2025-05-26 17:21:52 UTC (rev 15303)
+++ trunk/SKMainWindowController.h      2025-05-26 22:23:53 UTC (rev 15304)
@@ -127,7 +127,7 @@
     NSArray<NSString *>                 *tags;
     double                              rating;
     
-    NSWindow                            *savedWindow;
+    NSWindow                            *savedNormalWindow;
     SKSideWindow                        *sideWindow;
     
     SKInteractionMode                   interactionMode;

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2025-05-26 17:21:52 UTC (rev 15303)
+++ trunk/SKMainWindowController.m      2025-05-26 22:23:53 UTC (rev 15304)
@@ -564,7 +564,7 @@
             NSString *rectString = [setup objectForKey:MAINWINDOWFRAME_KEY];
             if (rectString) {
                 if ([self interactionMode] == SKPresentationMode)
-                    [savedWindow setFrame:NSRectFromString(rectString) 
display:NO];
+                    [savedNormalWindow setFrame:NSRectFromString(rectString) 
display:NO];
                 else
                     [[self window] setFrame:NSRectFromString(rectString) 
display:YES];
             }
@@ -604,7 +604,7 @@
     NSArray *cropBoxes = [self changedCropBoxes];
     
     if ([self interactionMode] == SKPresentationMode)
-        [setup setObject:NSStringFromRect([savedWindow frame]) 
forKey:MAINWINDOWFRAME_KEY];
+        [setup setObject:NSStringFromRect([savedNormalWindow frame]) 
forKey:MAINWINDOWFRAME_KEY];
     else
         [setup setObject:NSStringFromRect([[self window] frame]) 
forKey:MAINWINDOWFRAME_KEY];
     [setup setObject:[NSNumber numberWithDouble:[self leftSideWidth]] 
forKey:LEFTSIDEPANEWIDTH_KEY];
@@ -1638,7 +1638,7 @@
     
     [[SKImageToolTipWindow sharedToolTipWindow] orderOut:nil];
     
-    if (isPresentation && mwcFlags.thumbnailsUpdatedDuringPresentaton == 0 && 
fabs([[self window] backingScaleFactor] - [savedWindow backingScaleFactor]) > 
0.0) {
+    if (isPresentation && mwcFlags.thumbnailsUpdatedDuringPresentaton == 0 && 
fabs([[self window] backingScaleFactor] - [savedNormalWindow 
backingScaleFactor]) > 0.0) {
         [self allThumbnailsNeedUpdate];
         mwcFlags.thumbnailsUpdatedDuringPresentaton = 1;
     }
@@ -2912,7 +2912,7 @@
     CGFloat scale = [[self window] backingScaleFactor];
     dispatch_queue_t queue = [thumbnail isPlaceholder] ? [[self class] 
thumbnailQueue] : [[self class] utilityThumbnailQueue];
     
-    if ([self interactionMode] == SKPresentationMode && 
mwcFlags.thumbnailsNeedUpdateAfterPresentaton == 0 && fabs([savedWindow 
backingScaleFactor] - scale) > 0.0)
+    if ([self interactionMode] == SKPresentationMode && 
mwcFlags.thumbnailsNeedUpdateAfterPresentaton == 0 && fabs([savedNormalWindow 
backingScaleFactor] - scale) > 0.0)
         mwcFlags.thumbnailsNeedUpdateAfterPresentaton = 1;
     
     dispatch_async(queue, ^{

Modified: trunk/SKMainWindowController_FullScreen.m
===================================================================
--- trunk/SKMainWindowController_FullScreen.m   2025-05-26 17:21:52 UTC (rev 
15303)
+++ trunk/SKMainWindowController_FullScreen.m   2025-05-26 22:23:53 UTC (rev 
15304)
@@ -109,7 +109,7 @@
         [leftSideController.topBar setDrawsBackground:NO];
     }
 
-    if (mwcFlags.thumbnailsUpdatedDuringPresentaton == 0 && fabs([[self 
window] backingScaleFactor] - [savedWindow backingScaleFactor]) > 0.0) {
+    if (mwcFlags.thumbnailsUpdatedDuringPresentaton == 0 && fabs([[self 
window] backingScaleFactor] - [savedNormalWindow backingScaleFactor]) > 0.0) {
         [self allThumbnailsNeedUpdate];
         mwcFlags.thumbnailsUpdatedDuringPresentaton = 1;
     }
@@ -239,11 +239,12 @@
     // remember normal setup to return to, we must do this before changing the 
interactionMode
     [savedNormalSetup setDictionary:[self currentPDFSettings]];
     
+    NSWindow *normalWindow = [self window];
+    savedNormalWindow = normalWindow;
+    
     interactionMode = SKPresentationMode;
     
-    savedWindow = [self window];
-    
-    NSScreen *screen = [savedWindow screen];
+    NSScreen *screen = [normalWindow screen];
     if ([self presentationNotesDocument] && [self presentationNotesDocument] 
!= [self document]) {
         NSArray *screens = [[[[self presentationNotesDocument] mainWindow] 
screen] alternateScreens];
         if ([screens count] > 0 && [screens containsObject:[screen 
primaryScreen]] == NO)
@@ -269,15 +270,15 @@
         [self showNotesForPresentationWindow:presentationWindow];
     
     BOOL shouldFadeOut = NO;
-    if ([[savedWindow tabbedWindows] count] > 1) {
-        NSUInteger tabIndex = [[savedWindow tabbedWindows] 
indexOfObject:savedWindow];
-        [savedNormalSetup setObject:[savedWindow tabGroup] 
forKey:TABGROUP_KEY];
+    if ([[normalWindow tabbedWindows] count] > 1) {
+        NSUInteger tabIndex = [[normalWindow tabbedWindows] 
indexOfObject:normalWindow];
+        [savedNormalSetup setObject:[normalWindow tabGroup] 
forKey:TABGROUP_KEY];
         [savedNormalSetup setObject:[NSNumber 
numberWithUnsignedInteger:tabIndex] forKey:TABINDEX_KEY];
-    } else if (NSContainsRect([presentationWindow frame], [savedWindow frame]) 
== NO) {
+    } else if (NSContainsRect([presentationWindow frame], [normalWindow 
frame]) == NO) {
         shouldFadeOut = YES;
     }
     
-    [savedWindow setDelegate:nil];
+    [normalWindow setDelegate:nil];
     
     [self setWindow:presentationWindow];
     
@@ -292,7 +293,7 @@
             [context setTimingFunction:[CAMediaTimingFunction 
functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
             [[presentationWindow animator] setAlphaValue:1.0];
             if (shouldFadeOut)
-                [[savedWindow animator] setAlphaValue:0.0];
+                [[normalWindow animator] setAlphaValue:0.0];
             [[[presentationPreview window] animator] setAlphaValue:1.0];
         }
         completionHandler:^{
@@ -300,8 +301,8 @@
             if ([NSScreen screenForWindowHasMenuBar:presentationWindow])
                 [NSApp 
setPresentationOptions:NSApplicationPresentationHideDock | 
NSApplicationPresentationHideMenuBar];
             
-            [savedWindow orderOutWithoutAnimation];
-            [savedWindow setAlphaValue:1.0];
+            [normalWindow orderOutWithoutAnimation];
+            [normalWindow setAlphaValue:1.0];
             if ([self hasOverview])
                 [self hideOverviewAnimating:NO];
             
@@ -368,8 +369,11 @@
     if (mode != [pdfView extendedDisplayMode])
         [pdfView setExtendedDisplayModeAndRewind:mode];
     
-    [self setWindow:savedWindow];
+    NSWindow *normalWindow = savedNormalWindow;
+    savedNormalWindow = nil;
     
+    [self setWindow:normalWindow];
+    
     if (mwcFlags.thumbnailsNeedUpdateAfterPresentaton) {
         mwcFlags.thumbnailsNeedUpdateAfterPresentaton = 0;
         [self allThumbnailsNeedUpdate];
@@ -379,20 +383,20 @@
     NSWindowTabGroup *tabGroup = [savedNormalSetup objectForKey:TABGROUP_KEY];
     BOOL moveToTab = [[tabGroup windows] count] > 0;
     
-    [savedWindow setAlphaValue:0.0];
-    if (NSPointInRect(SKCenterPoint([savedWindow frame]), [[presentationWindow 
screen] frame]) && moveToTab == NO) {
-        NSWindowCollectionBehavior collectionBehavior = [savedWindow 
collectionBehavior];
+    [normalWindow setAlphaValue:0.0];
+    if (NSPointInRect(SKCenterPoint([normalWindow frame]), 
[[presentationWindow screen] frame]) && moveToTab == NO) {
+        NSWindowCollectionBehavior collectionBehavior = [normalWindow 
collectionBehavior];
         // trick to make sure the main window shows up in the same space as 
the fullscreen window
-        [savedWindow setCollectionBehavior:collectionBehavior | 
NSWindowCollectionBehaviorMoveToActiveSpace];
-        [savedWindow orderFrontWithoutAnimation];
-        dispatch_async(dispatch_get_main_queue(), ^{ [savedWindow 
setCollectionBehavior:collectionBehavior]; });
+        [normalWindow setCollectionBehavior:collectionBehavior | 
NSWindowCollectionBehaviorMoveToActiveSpace];
+        [normalWindow orderFrontWithoutAnimation];
+        dispatch_async(dispatch_get_main_queue(), ^{ [normalWindow 
setCollectionBehavior:collectionBehavior]; });
     } else {
-        [savedWindow orderFrontWithoutAnimation];
+        [normalWindow orderFrontWithoutAnimation];
     }
-    if ([pdfView window] == savedWindow)
-        [savedWindow makeFirstResponder:pdfView];
-    [savedWindow setDelegate:self];
-    [savedWindow makeKeyWindow];
+    if ([pdfView window] == normalWindow)
+        [normalWindow makeFirstResponder:pdfView];
+    [normalWindow setDelegate:self];
+    [normalWindow makeKeyWindow];
     
     [NSApp removeWindowsItem:presentationWindow];
     [presentationWindow setLevel:NSPopUpMenuWindowLevel];
@@ -401,10 +405,10 @@
     
     if (moveToTab) {
         NSUInteger tabIndex = [[savedNormalSetup objectForKey:TABINDEX_KEY] 
unsignedIntegerValue];
-        [savedWindow setAlphaValue:1.0];
-        [tabGroup insertWindow:savedWindow atIndex:MIN(tabIndex, [[tabGroup 
windows] count])];
-    } else if (NSContainsRect([presentationWindow frame], [savedWindow 
frame])) {
-        [savedWindow setAlphaValue:1.0];
+        [normalWindow setAlphaValue:1.0];
+        [tabGroup insertWindow:normalWindow atIndex:MIN(tabIndex, [[tabGroup 
windows] count])];
+    } else if (NSContainsRect([presentationWindow frame], [normalWindow 
frame])) {
+        [normalWindow setAlphaValue:1.0];
     }
     
     [savedNormalSetup removeAllObjects];
@@ -417,8 +421,8 @@
     [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
             [context setDuration:PRESENTATION_DURATION];
             [context setTimingFunction:[CAMediaTimingFunction 
functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
-            if ([savedWindow alphaValue] < 1.0)
-                [[savedWindow animator] setAlphaValue:1.0];
+            if ([normalWindow alphaValue] < 1.0)
+                [[normalWindow animator] setAlphaValue:1.0];
             [[presentationWindow animator] setAlphaValue:0.0];
             [[[presentationPreview window] animator] setAlphaValue:0.0];
         }
@@ -429,8 +433,6 @@
             [presentationView setPage:nil];
             [presentationView setAutoScales:NO];
             
-            savedWindow = nil;
-            
             if (presentationPreview) {
                 [[presentationPreview window] 
setAnimationBehavior:NSWindowAnimationBehaviorNone];
                 [presentationPreview close];
@@ -470,7 +472,7 @@
     }
 }
 
-- (void)displayStaticContentForWindow:(NSWindow *)window {
+- (void)displayStaticContentForWindow:(NSWindow *)window inWindow:(NSWindow 
*)displayWindow {
     NSRect frame = [window frame];
     CGImageRef cgImage = CGWindowListCreateImage(CGRectNull, 
kCGWindowListOptionIncludingWindow, (CGWindowID)[window windowNumber], 
kCGWindowImageBoundsIgnoreFraming | kCGWindowImageBestResolution);
     if (([window styleMask] & NSWindowStyleMaskFullScreen) != 0 && 
autoHideToolbarInFullScreen() == NO && [[window toolbar] isVisible]) {
@@ -494,14 +496,11 @@
     }
     NSImage *image = [[NSImage alloc] initWithCGImage:cgImage size:frame.size];
     CGImageRelease(cgImage);
-    if (savedWindow == nil)
-        savedWindow = [[SKAnimatedBorderlessWindow alloc] 
initWithContentRect:frame];
-    else
-        [savedWindow setFrame:frame display:NO];
-    [savedWindow addImageViewWithImage:image];
-    [savedWindow setHasShadow:[window hasShadow]];
-    [savedWindow setLevel:[window level]];
-    [savedWindow orderWindow:NSWindowAbove relativeTo:window];
+    [displayWindow setFrame:frame display:NO];
+    [displayWindow addImageViewWithImage:image];
+    [displayWindow setHasShadow:[window hasShadow]];
+    [displayWindow setLevel:[window level]];
+    [displayWindow orderWindow:NSWindowAbove relativeTo:window];
     [window setAlphaValue:0.0];
 }
 
@@ -588,8 +587,8 @@
     if ([windows count] == 1)
         return nil;
     if ([[NSWorkspace sharedWorkspace] 
accessibilityDisplayShouldReduceMotion]) {
-        savedWindow = [[SKAnimatedBorderlessWindow alloc] 
initWithContentRect:[window frame]];
-        windows = [windows arrayByAddingObject:savedWindow];
+        savedNormalWindow = [[SKAnimatedBorderlessWindow alloc] 
initWithContentRect:[window frame]];
+        windows = [windows arrayByAddingObject:savedNormalWindow];
     }
     return windows;
 }
@@ -600,11 +599,11 @@
     NSRect frame = SKShrinkRect([[window screen] frame], 
-fullScreenOffset(window), NSMaxYEdge);
     if ([[NSUserDefaults standardUserDefaults] 
boolForKey:AppleMenuBarVisibleInFullscreenKey])
         frame.size.height -= [[NSApp mainMenu] menuBarHeight] ?: 24.0;
-    if (savedWindow != nil) {
-        [self displayStaticContentForWindow:window];
+    if (savedNormalWindow != nil) {
+        [self displayStaticContentForWindow:window inWindow:savedNormalWindow];
         [(SKMainWindow *)window setDisableConstrainedFrame:YES];
         [window setFrame:frame display:YES];
-        [window orderWindow:NSWindowAbove relativeTo:savedWindow];
+        [window orderWindow:NSWindowAbove relativeTo:savedNormalWindow];
         setAlphaValueOfTitleBarControls(window, 0.0, NO);
         [(SKMainWindow *)window setDisableConstrainedFrame:NO];
         [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
@@ -613,8 +612,8 @@
                 [[window animator] setAlphaValue:1.0];
             }
             completionHandler:^{
-                [savedWindow orderOut:nil];
-                savedWindow = nil;
+                [savedNormalWindow orderOut:nil];
+                savedNormalWindow = nil;
             }];
     } else {
         [(SKMainWindow *)window setDisableConstrainedFrame:YES];
@@ -656,7 +655,7 @@
     }
     if ([[pdfView document] isLocked] == NO || [savedNormalSetup count] == 1)
         [savedNormalSetup removeAllObjects];
-    savedWindow = nil;
+    savedNormalWindow = nil;
     interactionMode = SKNormalMode;
     mwcFlags.isSwitchingFullScreen = 0;
 }
@@ -681,8 +680,8 @@
     if ([windows count] == 1)
         return nil;
     if ([[NSWorkspace sharedWorkspace] 
accessibilityDisplayShouldReduceMotion]) {
-        savedWindow = [[SKAnimatedBorderlessWindow alloc] 
initWithContentRect:[window frame]];
-        windows = [windows arrayByAddingObject:savedWindow];
+        savedNormalWindow = [[SKAnimatedBorderlessWindow alloc] 
initWithContentRect:[window frame]];
+        windows = [windows arrayByAddingObject:savedNormalWindow];
     }
     return windows;
 }
@@ -689,13 +688,13 @@
 
 - (void)window:(NSWindow *)window 
startCustomAnimationToExitFullScreenWithDuration:(NSTimeInterval)duration {
     NSRect frame = NSRectFromString([savedNormalSetup 
objectForKey:MAINWINDOWFRAME_KEY]);
-    if (savedWindow != nil) {
-        [self displayStaticContentForWindow:window];
+    if (savedNormalWindow != nil) {
+        [self displayStaticContentForWindow:window inWindow:savedNormalWindow];
         [window setStyleMask:[window styleMask] & 
~NSWindowStyleMaskFullScreen];
         setAlphaValueOfTitleBarControls(window, 1.0, NO);
         [window setFrame:frame display:YES];
         [window setLevel:NSNormalWindowLevel];
-        BOOL covered = NSContainsRect([savedWindow frame], [window frame]);
+        BOOL covered = NSContainsRect([savedNormalWindow frame], [window 
frame]);
         if (covered)
             [window setAlphaValue:1.0];
         [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
@@ -703,11 +702,11 @@
                 [context setTimingFunction:[CAMediaTimingFunction 
functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
                 if (covered == NO)
                     [[window animator] setAlphaValue:1.0];
-                [[savedWindow animator] setAlphaValue:0.0];
+                [[savedNormalWindow animator] setAlphaValue:0.0];
             }
             completionHandler:^{
-                [savedWindow orderOut:nil];
-                savedWindow = nil;
+                [savedNormalWindow orderOut:nil];
+                savedNormalWindow = nil;
             }];
     } else {
         NSRect startFrame = [window frame];
@@ -756,7 +755,7 @@
             [self applyPDFSettings:fullScreenSetup rewind:YES];
         [self forceSubwindowsOnTop:YES];
     }
-    savedWindow = nil;
+    savedNormalWindow = nil;
     mwcFlags.isSwitchingFullScreen = 0;
     mwcFlags.wantsPresentationOrFullScreen = 0;
 }

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



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to