Skip to content

Commit

Permalink
fix: thumbnails layout was wrong sometimes
Browse files Browse the repository at this point in the history
this is a regression introduced by 4eb9db0
  • Loading branch information
lwouis committed Apr 18, 2020
1 parent d17c9d5 commit 06c6f48
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/ui/main-window/ThumbnailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class ThumbnailView: NSStackView {

func updateRecycledCellWithNewContent(_ element: Window, _ mouseDownCallback: @escaping MouseDownCallback, _ mouseMovedCallback: @escaping MouseMovedCallback, _ newHeight: CGFloat, _ screen: NSScreen) {
window_ = element
// element.itemView = self
if thumbnail.image != element.thumbnail {
thumbnail.image = element.thumbnail
let (thumbnailWidth, thumbnailHeight) = ThumbnailView.thumbnailSize(element.thumbnail, screen)
Expand All @@ -38,12 +37,11 @@ class ThumbnailView: NSStackView {
appIcon.image?.size = appIconSize
appIcon.frame.size = appIconSize
}
if label.string != element.title {
let labelChanged = label.string != element.title
if labelChanged {
label.string = element.title
// workaround: setting string on NSTextView change the font (most likely a Cocoa bug)
label.font = Preferences.font
// force a display to avoid flickering; see https://github.com/lwouis/alt-tab-macos/issues/197
label.display()
}
assignIfDifferent(&hiddenIcon.isHidden, !window_!.isHidden)
assignIfDifferent(&minimizedIcon.isHidden, !window_!.isMinimized)
Expand All @@ -68,6 +66,11 @@ class ThumbnailView: NSStackView {
removeTrackingArea(trackingAreas[0])
addTrackingArea(NSTrackingArea(rect: bounds, options: [.mouseMoved, .activeAlways], owner: self, userInfo: nil))
}
// force a display to avoid flickering; see https://github.com/lwouis/alt-tab-macos/issues/197
// quirk: display() should be called last as it resets thumbnail.frame.size somehow
if labelChanged {
label.display()
}
}

private func observeDragAndDrop() {
Expand Down

0 comments on commit 06c6f48

Please sign in to comment.