Revision: 15895
          http://sourceforge.net/p/skim-app/code/15895
Author:   hofman
Date:     2025-12-20 17:48:40 +0000 (Sat, 20 Dec 2025)
Log Message:
-----------
only send 2 pages when the page changes

Modified Paths:
--------------
    trunk/SKMainWindowController_UI.m
    trunk/SKPDFView.h
    trunk/SKPDFView.m

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2025-12-20 17:21:18 UTC (rev 15894)
+++ trunk/SKMainWindowController_UI.m   2025-12-20 17:48:40 UTC (rev 15895)
@@ -2114,12 +2114,12 @@
 
 - (void)handleReadingBarDidChangeNotification:(NSNotification *)notification {
     NSDictionary *userInfo = [notification userInfo];
+    PDFPage *page = [userInfo objectForKey:SKPDFViewPageKey];
     PDFPage *oldPage = [userInfo objectForKey:SKPDFViewOldPageKey];
-    PDFPage *newPage = [userInfo objectForKey:SKPDFViewNewPageKey];
+    if (page)
+        [self updateThumbnailAtPageIndex:[page pageIndex]];
     if (oldPage)
         [self updateThumbnailAtPageIndex:[oldPage pageIndex]];
-    if (newPage && [newPage isEqual:oldPage] == NO)
-        [self updateThumbnailAtPageIndex:[newPage pageIndex]];
 }
 
 - (void)handleWillRemoveDocumentNotification:(NSNotification *)notification {

Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h   2025-12-20 17:21:18 UTC (rev 15894)
+++ trunk/SKPDFView.h   2025-12-20 17:48:40 UTC (rev 15895)
@@ -61,7 +61,7 @@
 
 extern NSString * const SKPDFViewAnnotationKey;
 extern NSString * const SKPDFViewOldPageKey;
-extern NSString * const SKPDFViewNewPageKey;
+extern NSString * const SKPDFViewPageKey;
 
 typedef NS_ENUM(NSInteger, SKToolMode) {
     SKToolModeText,

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2025-12-20 17:21:18 UTC (rev 15894)
+++ trunk/SKPDFView.m   2025-12-20 17:48:40 UTC (rev 15895)
@@ -120,8 +120,8 @@
 NSNotificationName const SKPDFViewPacerStartedOrStoppedNotification = 
@"SKPDFViewPacerStartedOrStoppedNotification";
 
 NSString * const SKPDFViewAnnotationKey = @"annotation";
+NSString * const SKPDFViewPageKey = @"page";
 NSString * const SKPDFViewOldPageKey = @"oldPage";
-NSString * const SKPDFViewNewPageKey = @"newPage";
 
 #define SKMoveReadingBarModifiersKey @"SKMoveReadingBarModifiers"
 #define SKResizeReadingBarModifiersKey @"SKResizeReadingBarModifiers"
@@ -991,7 +991,7 @@
         page = [readingBar page];
         bounds = [readingBar currentBounds];
         [self setReadingBar:nil];
-        userInfo = [NSDictionary dictionaryWithObjectsAndKeys:page, 
SKPDFViewOldPageKey, nil];
+        userInfo = page ? @{SKPDFViewPageKey: page} : nil;
     } else {
         page = [self currentPage];
         NSInteger line = 0;
@@ -1012,7 +1012,7 @@
         rect = ([page lineDirectionAngle] % 180) ? NSInsetRect(rect, 0.0, 
-20.0) : NSInsetRect(rect, -20.0, 0.0);
         [self goToRect:rect onPage:page];
         [self setReadingBar:aReadingBar];
-        userInfo = [NSDictionary dictionaryWithObjectsAndKeys:page, 
SKPDFViewNewPageKey, nil];
+        userInfo = page ? @{SKPDFViewPageKey: page} : nil;
     }
     [self updatePacer];
     [self setNeedsDisplay:[[NSUserDefaults standardUserDefaults] 
boolForKey:SKReadingBarInvertKey] forReadingBarBounds:bounds onPage:page];
@@ -1060,7 +1060,7 @@
     if (newPage)
         [self setNeedsDisplay:NO forReadingBarBounds:newBounds onPage:newPage];
     
-    NSDictionary *userInfo = newPage ? [NSDictionary 
dictionaryWithObjectsAndKeys:newPage, SKPDFViewNewPageKey, oldPage, 
SKPDFViewOldPageKey, nil] : [NSDictionary dictionaryWithObjectsAndKeys:oldPage, 
SKPDFViewOldPageKey, nil];
+    NSDictionary *userInfo = (newPage && oldPage && newPage != oldPage) ? 
@{SKPDFViewPageKey: newPage, SKPDFViewOldPageKey: oldPage} : (newPage || 
oldPage) ? @{SKPDFViewPageKey: newPage ?: oldPage} : nil;
     [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewReadingBarDidChangeNotification object:self 
userInfo:userInfo];
 }
 
@@ -3001,8 +3001,8 @@
                 SKReadingBar *aReadingBar = [[SKReadingBar alloc] 
initWithPage:page line:line delegate:self];
                 [self setReadingBar:aReadingBar];
                 [self setNeedsDisplay:invert forReadingBarBounds:[readingBar 
currentBounds] onPage:[readingBar page]];
-                NSDictionary *userInfo = [NSDictionary 
dictionaryWithObjectsAndKeys:[readingBar page], SKPDFViewNewPageKey, nil];
-                [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewReadingBarDidChangeNotification object:self 
userInfo:userInfo];
+                page = [readingBar page];
+                [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewReadingBarDidChangeNotification object:self 
userInfo:page ? @{SKPDFViewPageKey: page} : nil];
             } else {
                 [readingBar goToLine:line onPage:page];
             }
@@ -3350,9 +3350,11 @@
     if (context == &SKPDFViewDefaultsObservationContext) {
         if (readingBar) {
             PDFPage *page = [readingBar page];
-            [self setNeedsDisplay:([keyPath 
isEqualToString:SKReadingBarInvertKey] || [[NSUserDefaults 
standardUserDefaults] boolForKey:SKReadingBarInvertKey]) 
forReadingBarBounds:[readingBar currentBounds] onPage:page];
-            [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewReadingBarDidChangeNotification
-                object:self userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:page, SKPDFViewOldPageKey, page, 
SKPDFViewNewPageKey, nil]];
+            if (page) {
+                [self setNeedsDisplay:([keyPath 
isEqualToString:SKReadingBarInvertKey] || [[NSUserDefaults 
standardUserDefaults] boolForKey:SKReadingBarInvertKey]) 
forReadingBarBounds:[readingBar currentBounds] onPage:page];
+                [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewReadingBarDidChangeNotification
+                                                                    
object:self userInfo:@{SKPDFViewPageKey: page}];
+            }
         }
     } else {
         [super observeValueForKeyPath:keyPath ofObject:object change:change 
context:context];

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