Skip to content

Commit 7e66009

Browse files
committed
fix: hovering thumbnails would make alttab laggy (#1567)
1 parent 296ced8 commit 7e66009

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

src/ui/generic-components/TrafficLightButton.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class TrafficLightButton: NSButton {
1212
target = self
1313
action = #selector(onClick)
1414
fit(size, size)
15+
addTrackingArea(NSTrackingArea(rect: bounds, options: [.mouseEnteredAndExited, .activeInKeyWindow], owner: self, userInfo: nil))
1516
}
1617

1718
required init?(coder: NSCoder) {
@@ -28,10 +29,6 @@ class TrafficLightButton: NSButton {
2829
}
2930
}
3031

31-
override func updateTrackingAreas() {
32-
addTrackingArea(NSTrackingArea(rect: bounds, options: [.activeInActiveApp, .mouseEnteredAndExited, .assumeInside, .inVisibleRect], owner: self, userInfo: nil))
33-
}
34-
3532
override func mouseEntered(with event: NSEvent) {
3633
isMouseOver = true
3734
setNeedsDisplay()
@@ -90,6 +87,7 @@ class TrafficLightButton: NSButton {
9087
}
9188

9289
private func drawDimming(_ disk: NSBezierPath) {
90+
disk.lineWidth = 1
9391
if (isHighlighted) {
9492
NSColor(calibratedRed: 0, green: 0, blue: 0, alpha: 0.5).setFill()
9593
disk.fill()
@@ -102,7 +100,7 @@ class TrafficLightButton: NSButton {
102100
private func drawDisk(_ backgroundGradient: NSGradient, _ strokeColor: NSColor) -> NSBezierPath {
103101
var disk = NSBezierPath()
104102
disk.appendOval(in: NSMakeRect(bounds.origin.x + 0.5, bounds.origin.y + 0.5, bounds.width - 1, bounds.height - 1))
105-
backgroundGradient.draw(in: disk, relativeCenterPosition: NSMakePoint(0, 0))
103+
backgroundGradient.draw(in: disk, relativeCenterPosition: .zero)
106104
strokeColor.setStroke()
107105
disk.lineWidth = 0.5
108106
disk.stroke()

src/ui/main-window/ThumbnailView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class ThumbnailView: NSStackView {
6868
}
6969

7070
func showOrHideWindowControls(_ shouldShowWindowControls: Bool) {
71-
self.shouldShowWindowControls = shouldShowWindowControls
7271
let shouldShow = shouldShowWindowControls && !Preferences.hideColoredCircles && !(window_?.isWindowlessApp ?? true) && !Preferences.hideThumbnails
7372
if isShowingWindowControls != shouldShow {
7473
isShowingWindowControls = shouldShow

0 commit comments

Comments
 (0)