Revision: 16180
          http://sourceforge.net/p/skim-app/code/16180
Author:   hofman
Date:     2026-04-06 09:01:49 +0000 (Mon, 06 Apr 2026)
Log Message:
-----------
completion handler block for hiding overview in separate method

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

Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h      2026-04-06 08:46:08 UTC (rev 16179)
+++ trunk/SKMainWindowController.h      2026-04-06 09:01:49 UTC (rev 16180)
@@ -267,7 +267,7 @@
 
 - (void)showOverviewAnimating:(BOOL)animate;
 - (void)hideOverviewAnimating:(BOOL)animate;
-- (void)hideOverviewAnimating:(BOOL)animate completionHandler:(nullable void 
(^)(void))handler;
+- (void)hideOverviewWithCompletionHandler:(void (^)(void))completionHandler;
 
 - (void)showFindBar;
 

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2026-04-06 08:46:08 UTC (rev 16179)
+++ trunk/SKMainWindowController.m      2026-04-06 09:01:49 UTC (rev 16180)
@@ -1722,13 +1722,10 @@
     [[NSNotificationCenter defaultCenter] 
postNotificationName:SKMainWindowControllerDidShowOrHideOverviewNotification 
object:self];
 }
 
-- (void)hideOverviewAnimating:(BOOL)animate completionHandler:(void 
(^)(void))handler {
+- (void)hideOverviewAnimating:(BOOL)animate {
     NSWindow *window = [overviewContentView window];
-    if (window == nil) {
-        if (handler)
-            handler();
+    if (window == nil)
         return;
-    }
     
     if ([NSView shouldShowFadeAnimation] == NO)
         animate = NO;
@@ -1737,10 +1734,6 @@
     BOOL isPresentation = (window == [presentationView window]);
     
     if (animate) {
-        if (handler) {
-            [CATransaction begin];
-            [CATransaction setCompletionBlock:handler];
-        }
         CAAnimation *animation = [CATransition animation];
         [animation setDuration:OVERVIEW_DURATION];
         [animation setTimingFunction:[CAMediaTimingFunction 
functionWithName:kCAMediaTimingFunctionDefault]];
@@ -1753,18 +1746,18 @@
     [window recalculateKeyViewLoop];
     
     [[NSNotificationCenter defaultCenter] 
postNotificationName:SKMainWindowControllerDidShowOrHideOverviewNotification 
object:self];
-    
-    if (handler) {
-        if (animate)
-            [CATransaction commit];
-        else
-            handler();
-    }
 }
 
-    
-- (void)hideOverviewAnimating:(BOOL)animate {
-    [self hideOverviewAnimating:(BOOL)animate completionHandler:NULL];
+- (void)hideOverviewWithCompletionHandler:(void (^)(void))completionHandler {
+    if ([NSView shouldShowFadeAnimation]) {
+        [CATransaction begin];
+        [CATransaction setCompletionBlock:completionHandler];
+        [self hideOverviewAnimating:YES];
+        [CATransaction commit];
+    } else {
+        [self hideOverviewAnimating:NO];
+        completionHandler();
+    }
 }
 
 - (NSInteger)collectionView:(NSCollectionView *)collectionView
@@ -1812,7 +1805,7 @@
     }
     
     if ([self hasOverview]) {
-        [self hideOverviewAnimating:YES completionHandler:^{
+        [self hideOverviewWithCompletionHandler:^{
             [self findString:string forward:forward];
         }];
         return YES;

Modified: trunk/SKMainWindowController_Actions.m
===================================================================
--- trunk/SKMainWindowController_Actions.m      2026-04-06 08:46:08 UTC (rev 
16179)
+++ trunk/SKMainWindowController_Actions.m      2026-04-06 09:01:49 UTC (rev 
16180)
@@ -785,7 +785,7 @@
 
 - (void)selectSearchFieldForSideViewController:(SKSideViewController 
*)sideViewController {
     if ([self hasOverview]) {
-        [self hideOverviewAnimating:YES completionHandler:^{ [self 
selectSearchFieldForSideViewController:sideViewController]; }];
+        [self hideOverviewWithCompletionHandler:^{ [self 
selectSearchFieldForSideViewController:sideViewController]; }];
     } else {
         NSSplitViewItem *item = [splitViewController 
splitViewItemForViewController:sideViewController];
         if ([item isCollapsed] == NO) {
@@ -1032,7 +1032,7 @@
         else
             [self showSideWindow];
     } else if ([self hasOverview]) {
-        [self hideOverviewAnimating:YES completionHandler:^{ [self 
toggleLeftSidePane:sender]; }];
+        [self hideOverviewWithCompletionHandler:^{ [self 
toggleLeftSidePane:sender]; }];
     } else {
         NSSplitViewItem *item = [[splitViewController splitViewItems] 
firstObject];
         BOOL collapse = [item isCollapsed] == NO;
@@ -1046,7 +1046,7 @@
 - (IBAction)toggleRightSidePane:(id)sender {
     if ([self interactionMode] == SKPresentationMode) {
     } else if ([self hasOverview]) {
-        [self hideOverviewAnimating:YES completionHandler:^{ [self 
toggleRightSidePane:sender]; }];
+        [self hideOverviewWithCompletionHandler:^{ [self 
toggleRightSidePane:sender]; }];
     } else {
         NSSplitViewItem *item = [[splitViewController splitViewItems] 
lastObject];
         BOOL collapse = [item isCollapsed] == NO;
@@ -1078,7 +1078,7 @@
 
 - (IBAction)toggleSplitPDF:(id)sender {
     if ([self hasOverview]) {
-        [self hideOverviewAnimating:YES completionHandler:^{ [self 
toggleSplitPDF:sender]; }];
+        [self hideOverviewWithCompletionHandler:^{ [self 
toggleSplitPDF:sender]; }];
         return;
     }
     
@@ -1243,7 +1243,7 @@
     }
     
     if ([self hasOverview]) {
-        [self hideOverviewAnimating:YES completionHandler:^{ [self 
performFindPanelAction:sender]; }];
+        [self hideOverviewWithCompletionHandler:^{ [self 
performFindPanelAction:sender]; }];
         return;
     }
        
@@ -1296,7 +1296,7 @@
     }
     
     if ([self hasOverview]) {
-        [self hideOverviewAnimating:YES completionHandler:^{ [self 
centerSelectionInVisibleArea:sender]; }];
+        [self hideOverviewWithCompletionHandler:^{ [self 
centerSelectionInVisibleArea:sender]; }];
         return;
     }
     

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