Revision: 15357
          http://sourceforge.net/p/skim-app/code/15357
Author:   hofman
Date:     2025-06-03 14:36:04 +0000 (Tue, 03 Jun 2025)
Log Message:
-----------
convenience inline function to save toolbar offset

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

Modified: trunk/SKMainWindowController_FullScreen.m
===================================================================
--- trunk/SKMainWindowController_FullScreen.m   2025-06-03 14:23:31 UTC (rev 
15356)
+++ trunk/SKMainWindowController_FullScreen.m   2025-06-03 14:36:04 UTC (rev 
15357)
@@ -510,17 +510,6 @@
     return NO;
 }
 
-static inline CGFloat fullScreenOffset(NSWindow *window) {
-    if (hasUnifiedToolbar(window))
-        return 0.0;
-    else if (fullScreenToolbarOffset > 0.0)
-        return fullScreenToolbarOffset;
-    else if (@available(macOS 11.0, *))
-        return 16.0;
-    else
-        return 17.0;
-}
-
 static inline CGFloat toolbarViewOffset(NSWindow *window) {
     NSToolbar *toolbar = [window toolbar];
     NSView *view = nil;
@@ -535,6 +524,28 @@
     return view ? NSMaxY([view convertRectToScreen:[view frame]]) - 
NSMaxY([[view window] frame]) : 0.0;
 }
 
+static inline CGFloat fullScreenOffset(NSWindow *window) {
+    if (hasUnifiedToolbar(window))
+        return 0.0;
+    if (fullScreenToolbarOffset <= 0.0)
+        fullScreenToolbarOffset = toolbarViewOffset(window);
+    if (fullScreenToolbarOffset > 0.0)
+        return fullScreenToolbarOffset;
+    else if (@available(macOS 11.0, *))
+        return 16.0;
+    else
+        return 17.0;
+}
+
+static inline void saveFullScreenToolbarOffset(NSWindow *window) {
+    if (fullScreenToolbarOffset < 0.0 && showToolbarInFullScreen(window) && 
hasUnifiedToolbar(window) == NO) {
+        CGFloat toolbarItemOffset = toolbarViewOffset(window);
+        if (toolbarItemOffset < 0.0)
+            // save the offset for the next time, we may guess it wrong as it 
varies between OS versions
+            fullScreenToolbarOffset = toolbarItemOffset - 
fullScreenToolbarOffset;
+    }
+}
+
 - (void)windowWillEnterFullScreenStyle:(NSWindow *)window {
     if (interactionMode != SKFullScreenMode) {
         interactionMode = SKFullScreenMode;
@@ -596,8 +607,6 @@
     NSTitlebarAccessoryViewController *noteToolbar = nil;
     CALayer *blackLayer = nil;
     if (showToolbarInFullScreen(window)) {
-        if (fullScreenToolbarOffset <= 0.0 && hasUnifiedToolbar(window) == NO)
-            fullScreenToolbarOffset = toolbarViewOffset(window);
         CGFloat offset = fullScreenOffset(window);
         frame.size.height += offset;
         NSUInteger i = noteToolbarController ? [[window 
titlebarAccessoryViewControllers] indexOfObject:noteToolbarController] : 
NSNotFound;
@@ -636,12 +645,7 @@
 }
 
 - (void)windowDidEnterFullScreen:(NSNotification *)notification {
-    if (fullScreenToolbarOffset < 0.0 && showToolbarInFullScreen([self 
window]) && hasUnifiedToolbar([self window]) == NO) {
-        CGFloat toolbarItemOffset = toolbarViewOffset([self window]);
-        if (toolbarItemOffset < 0.0)
-            // save the offset for the next time, we may guess it wrong as it 
varies between OS versions
-            fullScreenToolbarOffset = toolbarItemOffset - 
fullScreenToolbarOffset;
-    }
+    saveFullScreenToolbarOffset([self window]);
     [touchBarController interactionModeChanged];
     mwcFlags.isSwitchingFullScreen = 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