diff --git a/src/logic/Window.swift b/src/logic/Window.swift index 443fde8f..54a20942 100644 --- a/src/logic/Window.swift +++ b/src/logic/Window.swift @@ -4,6 +4,7 @@ class Window { var cgWindowId: CGWindowID var title: String! var thumbnail: NSImage? + var thumbnailFullSize: NSSize? var icon: NSImage? { get { application.icon } } var shouldShowTheUser = true var isTabbed: Bool = false @@ -66,6 +67,7 @@ class Window { func refreshThumbnail() { guard let cgImage = cgWindowId.screenshot() else { return } thumbnail = NSImage(cgImage: cgImage, size: NSSize(width: cgImage.width, height: cgImage.height)) + thumbnailFullSize = thumbnail!.size } func refreshIsTabbed(_ currentWindows: [AXUIElement]) { diff --git a/src/logic/Windows.swift b/src/logic/Windows.swift index d083d71c..a7921db2 100644 --- a/src/logic/Windows.swift +++ b/src/logic/Windows.swift @@ -102,11 +102,10 @@ class Windows { DispatchQueue.main.async { let view = ThumbnailsView.recycledViews[currentIndex] if view.thumbnail.image != window.thumbnail { + let oldSize = view.thumbnail.frame.size view.thumbnail.image = window.thumbnail - let (thumbnailWidth, thumbnailHeight) = ThumbnailView.thumbnailSize(window.thumbnail, screen) - let thumbnailSize = NSSize(width: thumbnailWidth.rounded(), height: thumbnailHeight.rounded()) - view.thumbnail.image?.size = thumbnailSize - view.thumbnail.frame.size = thumbnailSize + view.thumbnail.image?.size = oldSize + view.thumbnail.frame.size = oldSize } } } diff --git a/src/ui/main-window/ThumbnailView.swift b/src/ui/main-window/ThumbnailView.swift index 0601d0b8..bb22ce94 100644 --- a/src/ui/main-window/ThumbnailView.swift +++ b/src/ui/main-window/ThumbnailView.swift @@ -99,13 +99,14 @@ class ThumbnailView: NSStackView { func updateRecycledCellWithNewContent(_ element: Window, _ index: Int, _ newHeight: CGFloat, _ screen: NSScreen) { window_ = element - if thumbnail.image != element.thumbnail { - thumbnail.image = element.thumbnail - let (thumbnailWidth, thumbnailHeight) = ThumbnailView.thumbnailSize(element.thumbnail, screen) - let thumbnailSize = NSSize(width: thumbnailWidth.rounded(), height: thumbnailHeight.rounded()) - thumbnail.image?.size = thumbnailSize - thumbnail.frame.size = thumbnailSize + thumbnail.image = element.thumbnail + if let image = thumbnail.image { + image.size = element.thumbnailFullSize! } + let (thumbnailWidth, thumbnailHeight) = ThumbnailView.thumbnailSize(element.thumbnail, screen) + let thumbnailSize = NSSize(width: thumbnailWidth.rounded(), height: thumbnailHeight.rounded()) + thumbnail.image?.size = thumbnailSize + thumbnail.frame.size = thumbnailSize if appIcon.image != element.icon { appIcon.image = element.icon let appIconSize = NSSize(width: Preferences.iconSize, height: Preferences.iconSize)