fix: permission callout could show even with permission granted

closes #3801
This commit is contained in:
lwouis committed 2024-11-14 14:07:11 +01:00
1 parent 2594427e75
commit 9585c92629
2 files changed
+14 -8

No files matched your search

+2 -6
View File
@@ -59,9 +59,7 @@ class SystemPermissions {
let accessibility = accessibilityIsGranted()
let screenRecording = screenRecordingIsGranted()
logger.d(accessibility, screenRecording, preStartupPermissionsPassed)
Menubar.permissionCalloutMenuItems?.forEach {
$0.isHidden = screenRecording != .skipped
}
Menubar.togglePermissionCallout(screenRecording == .skipped)
if accessibility == .notGranted {
App.app.restart()
}
@@ -82,9 +80,7 @@ class SystemPermissions {
let accessibility = accessibilityIsGranted()
let screenRecording = screenRecordingIsGranted()
logger.d(accessibility, screenRecording, preStartupPermissionsPassed)
Menubar.permissionCalloutMenuItems?.forEach {
$0.isHidden = screenRecording != .skipped
}
Menubar.togglePermissionCallout(screenRecording == .skipped)
if accessibility != App.app.permissionsWindow?.accessibilityView?.permissionStatus {
App.app.permissionsWindow?.accessibilityView.updatePermissionStatus(accessibility)
}
+12 -2
View File
@@ -12,8 +12,6 @@ class Menubar {
permissionCalloutMenuItem.view = PermissionCallout()
let calloutSeparator = NSMenuItem.separator()
permissionCalloutMenuItems = [permissionCalloutMenuItem, calloutSeparator]
menu.addItem(permissionCalloutMenuItem)
menu.addItem(calloutSeparator)
menu.addItem(
withTitle: String(format: NSLocalizedString("About %@", comment: "Menubar option. %@ is AltTab"), App.name),
action: #selector(App.app.showAboutTab),
@@ -55,6 +53,18 @@ class Menubar {
menubarIconCallback(nil)
}
// NSMenuItem.isHidden isn't reliable with custom views. We add/remove to hide/show these items
static func togglePermissionCallout(_ show: Bool) {
permissionCalloutMenuItems?.enumerated().forEach { offset, element in
if show && !menu.items.contains(element) {
menu.insertItem(element, at: offset)
}
if !show && menu.items.contains(element) {
menu.removeItem(element)
}
}
}
@objc static func statusItemOnClick() {
// NSApp.currentEvent == nil if the icon is "clicked" through VoiceOver
if let type = NSApp.currentEvent?.type, type != .leftMouseDown {