From fefc491ce53c6872cf9d35c0e22f412fc8a6899f Mon Sep 17 00:00:00 2001 From: lwouis Date: Sun, 8 Feb 2026 18:08:01 +0100 Subject: [PATCH] perf: prevent appkit work --- src/ui/main-window/ThumbnailsPanel.swift | 3 +++ src/ui/main-window/ThumbnailsView.swift | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/ui/main-window/ThumbnailsPanel.swift b/src/ui/main-window/ThumbnailsPanel.swift index 1b7e35f5..29f8255a 100644 --- a/src/ui/main-window/ThumbnailsPanel.swift +++ b/src/ui/main-window/ThumbnailsPanel.swift @@ -40,9 +40,12 @@ class ThumbnailsPanel: NSPanel { guard App.app.appIsBeingUsed else { return } NSScreen.preferred.repositionPanel(self) } + // prevent further AppKit work + thumbnailsView.clearNeedsLayout() } override func orderOut(_ sender: Any?) { + thumbnailsView.clearNeedsLayout() if Preferences.fadeOutAnimation { NSAnimationContext.runAnimationGroup( { _ in animator().alphaValue = 0 }, diff --git a/src/ui/main-window/ThumbnailsView.swift b/src/ui/main-window/ThumbnailsView.swift index 57a800b4..4b90722e 100644 --- a/src/ui/main-window/ThumbnailsView.swift +++ b/src/ui/main-window/ThumbnailsView.swift @@ -261,6 +261,15 @@ class ThumbnailsView { } } + func clearNeedsLayout() { + let views = [contentView, scrollView, scrollView.contentView, scrollView.documentView].compactMap { $0 } + for view in views { + view.needsLayout = false + view.needsDisplay = false + view.needsUpdateConstraints = false + } + } + struct LayoutCache { var labelHeight = CGFloat(0) var iconWidth = CGFloat(0)