fix: hovering thumbnails would make alttab laggy (#1567)

This commit is contained in:
Louis Pontoise committed 2022-05-12 22:33:23 +09:00
1 parent 296ced8e9b
commit 7e660091e0
2 files changed
+3 -6

No files matched your search

@@ -12,6 +12,7 @@ class TrafficLightButton: NSButton {
target = self
action = #selector(onClick)
fit(size, size)
addTrackingArea(NSTrackingArea(rect: bounds, options: [.mouseEnteredAndExited, .activeInKeyWindow], owner: self, userInfo: nil))
}
required init?(coder: NSCoder) {
@@ -28,10 +29,6 @@ class TrafficLightButton: NSButton {
}
}
override func updateTrackingAreas() {
addTrackingArea(NSTrackingArea(rect: bounds, options: [.activeInActiveApp, .mouseEnteredAndExited, .assumeInside, .inVisibleRect], owner: self, userInfo: nil))
}
override func mouseEntered(with event: NSEvent) {
isMouseOver = true
setNeedsDisplay()
@@ -90,6 +87,7 @@ class TrafficLightButton: NSButton {
}
private func drawDimming(_ disk: NSBezierPath) {
disk.lineWidth = 1
if (isHighlighted) {
NSColor(calibratedRed: 0, green: 0, blue: 0, alpha: 0.5).setFill()
disk.fill()
@@ -102,7 +100,7 @@ class TrafficLightButton: NSButton {
private func drawDisk(_ backgroundGradient: NSGradient, _ strokeColor: NSColor) -> NSBezierPath {
var disk = NSBezierPath()
disk.appendOval(in: NSMakeRect(bounds.origin.x + 0.5, bounds.origin.y + 0.5, bounds.width - 1, bounds.height - 1))
backgroundGradient.draw(in: disk, relativeCenterPosition: NSMakePoint(0, 0))
backgroundGradient.draw(in: disk, relativeCenterPosition: .zero)
strokeColor.setStroke()
disk.lineWidth = 0.5
disk.stroke()
-1
View File
@@ -68,7 +68,6 @@ class ThumbnailView: NSStackView {
}
func showOrHideWindowControls(_ shouldShowWindowControls: Bool) {
self.shouldShowWindowControls = shouldShowWindowControls
let shouldShow = shouldShowWindowControls && !Preferences.hideColoredCircles && !(window_?.isWindowlessApp ?? true) && !Preferences.hideThumbnails
if isShowingWindowControls != shouldShow {
isShowingWindowControls = shouldShow