Skip to content

Commit

Permalink
fix: hovering thumbnails would make alttab laggy (#1567)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed May 12, 2022
1 parent 296ced8 commit 7e66009
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/ui/generic-components/TrafficLightButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down
1 change: 0 additions & 1 deletion src/ui/main-window/ThumbnailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7e66009

Please sign in to comment.