Revision: 16717
          http://sourceforge.net/p/skim-app/code/16717
Author:   hofman
Date:     2026-10-26 18:08:53 +0000 (Mon, 26 Oct 2026)
Log Message:
-----------
separate methods to show preview snapshot and getting page to preview for 
presentation notes

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

Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h      2026-10-26 17:41:43 UTC (rev 16716)
+++ trunk/SKMainWindowController.h      2026-10-26 18:08:53 UTC (rev 16717)
@@ -206,6 +206,7 @@
 
 - (void)showSnapshotAtPage:(PDFPage *)page forRect:(NSRect)rect 
scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits;
 - (void)showSnapshotsWithSetups:(NSArray<NSDictionary<NSString *, id> *> 
*)setups;
+- (void)showSnapshotAtPage:(PDFPage *)page previewOnScreen:(nullable NSScreen 
*)screen;
 - (void)showNote:(PDFAnnotation *)annotation;
 
 - (nullable NSWindowController *)windowControllerForNote:(PDFAnnotation 
*)annotation;

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2026-10-26 17:41:43 UTC (rev 16716)
+++ trunk/SKMainWindowController.m      2026-10-26 18:08:53 UTC (rev 16717)
@@ -2462,6 +2462,17 @@
     }];
 }
 
+- (void)showSnapshotAtPage:(PDFPage *)page previewOnScreen:(nullable NSScreen 
*)screen {
+    SKSnapshotWindowController *swc = [[SKSnapshotWindowController alloc] 
init];
+    
+    [swc setDelegate:self];
+    
+    [swc loadPdfDocument:[pdfView document]];
+    [swc previewPage:page displayOnScreen:screen];
+    
+    [[self document] addWindowController:swc];
+}
+
 - (void)snapshotController:(SKSnapshotWindowController *)controller 
didFinishSetup:(SKSnapshotOpenType)openType {
     if (openType == SKSnapshotOpenPreview)
         return;

Modified: trunk/SKMainWindowController_FullScreen.m
===================================================================
--- trunk/SKMainWindowController_FullScreen.m   2026-10-26 17:41:43 UTC (rev 
16716)
+++ trunk/SKMainWindowController_FullScreen.m   2026-10-26 18:08:53 UTC (rev 
16717)
@@ -181,32 +181,14 @@
     return mainScreen;
 }
 
-- (void)showNotesForPresentationOnScreen:(NSScreen *)screen {
+- (PDFPage *)pageForPresentationNotes {
     NSDocument *notesDocument = [self presentationNotesDocument];
     PDFDocument *pdfDoc = [notesDocument pdfDocument];
     NSInteger offset = [self presentationNotesOffset];
     PDFPage *page = [pdfView currentPage];
-    
     if (notesDocument != [self document] || offset != 0)
         page = [pdfDoc pageAtIndex:MAX(0, MIN((NSInteger)[pdfDoc pageCount] - 
1, (NSInteger)[page pageIndex] + offset))];
-    
-    if (presentationNotesAuxiliary == nil)
-        presentationNotesAuxiliary = [[SKPresentationNotesAuxiliary alloc] 
init];
-    
-    if (notesDocument == [self document]) {
-        SKSnapshotWindowController *preview = [[SKSnapshotWindowController 
alloc] init];
-        
-        [presentationNotesAuxiliary setPreviewController:preview];
-        
-        [preview setDelegate:self];
-        
-        [preview loadPdfDocument:pdfDoc];
-        [preview previewPage:page displayOnScreen:screen];
-    
-        [[self document] addWindowController:preview];
-    } else {
-        [notesDocument setCurrentPage:page];
-    }
+    return page;
 }
 
 - (void)handlePresentationViewPageChanged:(NSNotification *)notification {
@@ -219,13 +201,11 @@
             [pdfView goToPage:page];
         }
         if ([self presentationNotesDocument]) {
-            PDFDocument *pdfDoc = [[self presentationNotesDocument] 
pdfDocument];
-            NSInteger offset = [self presentationNotesOffset];
-            NSUInteger pageIndex = (NSUInteger)MAX(0, MIN((NSInteger)[pdfDoc 
pageCount] - 1, (NSInteger)[[pdfView currentPage] pageIndex] + offset));
+            PDFPage *page = [self pageForPresentationNotes];
             if ([self presentationNotesDocument] == [self document])
-                [[[presentationNotesAuxiliary previewController] pdfView] 
goAndScrollToPage:[pdfDoc pageAtIndex:pageIndex]];
+                [[[presentationNotesAuxiliary previewController] pdfView] 
goAndScrollToPage:page];
             else
-                [[self presentationNotesDocument] setCurrentPage:[pdfDoc 
pageAtIndex:pageIndex]];
+                [[self presentationNotesDocument] setCurrentPage:page];
         }
     }
 }
@@ -285,9 +265,11 @@
     interactionMode = SKPresentationMode;
     
     NSDocument *notesDocument = [self presentationNotesDocument];
-    NSScreen *notesScreen = (notesDocument && notesDocument != [self 
document]) ? [[notesDocument primaryWindow] screen] : nil;
+    NSScreen *screen = nil;
     BOOL preferExternal = [[NSUserDefaults standardUserDefaults] 
boolForKey:SKPreferExternalDisplayForPresentationKey];
-    NSScreen *screen = [self 
screenForPresentationWindowAvoidingScreen:notesScreen 
preferExternal:preferExternal];
+    if (notesDocument && notesDocument != [self document])
+        screen = [[notesDocument primaryWindow] screen];
+    screen = [self screenForPresentationWindowAvoidingScreen:screen 
preferExternal:preferExternal];
     
     NSWindow *presentationWindow = [[SKFullScreenWindow alloc] 
initWithContentRect:[screen frame]];
     [presentationWindow setAlphaValue:0.0];
@@ -305,9 +287,15 @@
     [presentationWindow orderFront:nil];
     
     if (notesDocument) {
-        if (notesScreen == nil)
-            notesScreen = [self 
screenForPresentationWindowAvoidingScreen:screen preferExternal:NO];
-        [self showNotesForPresentationOnScreen:notesScreen];
+        if (presentationNotesAuxiliary == nil)
+            presentationNotesAuxiliary = [[SKPresentationNotesAuxiliary alloc] 
init];
+        PDFPage *page = [self pageForPresentationNotes];
+        if (notesDocument == [self document]) {
+            screen = [self screenForPresentationWindowAvoidingScreen:screen 
preferExternal:NO];
+            [self showSnapshotAtPage:page previewOnScreen:screen];
+        } else {
+            [notesDocument setCurrentPage:page];
+        }
     }
     
     BOOL shouldFadeOut = NO;

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to