perf: prevent appkit work
This commit is contained in:
1 parent
41e0e7c688
commit
fefc491ce5
2 files changed
+12
No files matched your search
@@ -40,9 +40,12 @@ class ThumbnailsPanel: NSPanel {
|
|||||||
guard App.app.appIsBeingUsed else { return }
|
guard App.app.appIsBeingUsed else { return }
|
||||||
NSScreen.preferred.repositionPanel(self)
|
NSScreen.preferred.repositionPanel(self)
|
||||||
}
|
}
|
||||||
|
// prevent further AppKit work
|
||||||
|
thumbnailsView.clearNeedsLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func orderOut(_ sender: Any?) {
|
override func orderOut(_ sender: Any?) {
|
||||||
|
thumbnailsView.clearNeedsLayout()
|
||||||
if Preferences.fadeOutAnimation {
|
if Preferences.fadeOutAnimation {
|
||||||
NSAnimationContext.runAnimationGroup(
|
NSAnimationContext.runAnimationGroup(
|
||||||
{ _ in animator().alphaValue = 0 },
|
{ _ in animator().alphaValue = 0 },
|
||||||
|
|||||||
@@ -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 {
|
struct LayoutCache {
|
||||||
var labelHeight = CGFloat(0)
|
var labelHeight = CGFloat(0)
|
||||||
var iconWidth = CGFloat(0)
|
var iconWidth = CGFloat(0)
|
||||||
|
|||||||
Reference in new issue
Block a user