Skip to content

Commit 62a15ff

Browse files
committed
Prevent window alpha value from being set too often
1 parent 541cd81 commit 62a15ff

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

Core/Sources/SuggestionWidget/SuggestionWidgetController.swift

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,15 @@ extension SuggestionWidgetController {
403403
/// element.
404404
private func updateWindowLocation(animated: Bool = false) {
405405
func hide() {
406-
panelWindow.alphaValue = 0
407-
widgetWindow.alphaValue = 0
408-
tabWindow.alphaValue = 0
406+
if panelWindow.alphaValue != 0 {
407+
panelWindow.alphaValue = 0
408+
}
409+
if widgetWindow.alphaValue != 0 {
410+
widgetWindow.alphaValue = 0
411+
}
412+
if tabWindow.alphaValue != 0 {
413+
tabWindow.alphaValue = 0
414+
}
409415
}
410416

411417
guard UserDefaults.shared.value(for: \.suggestionPresentationMode) == .floatingWidget
@@ -448,9 +454,15 @@ extension SuggestionWidgetController {
448454
suggestionPanelViewModel.alignTopToAnchor = result.alignPanelTopToAnchor
449455
}
450456

451-
panelWindow.alphaValue = 1
452-
widgetWindow.alphaValue = 1
453-
tabWindow.alphaValue = 1
457+
if panelWindow.alphaValue != 1 {
458+
panelWindow.alphaValue = 1
459+
}
460+
if widgetWindow.alphaValue != 1 {
461+
widgetWindow.alphaValue = 1
462+
}
463+
if tabWindow.alphaValue != 1 {
464+
tabWindow.alphaValue = 1
465+
}
454466
return
455467
}
456468
}

0 commit comments

Comments
 (0)