Skip to content

Commit 1e01747

Browse files
committed
refactor: improve naming
1 parent 95e51d1 commit 1e01747

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

src/api-wrappers/private-apis/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ However their full signature is a best-effort of retro-engineering
44
Very little information is available about private APIs. I tried to document them as much as possible here
55

66
Some links:
7+
78
* Webkit repo: https://github.com/WebKit/webkit/blob/master/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h
89
* Alt-tab-macos issue: https://github.com/lwouis/alt-tab-macos/pull/87#issuecomment-558624755
910
* Github repo with retro-engineered internals: https://github.com/NUIKit/CGSInternal

src/logic/SystemPermissions.swift

+18-18
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import Cocoa
22

33
// macOS has some privacy restrictions. The user needs to grant certain permissions, app by app, in System Preferences > Security & Privacy
44
class SystemPermissions {
5-
static var accessibilityIsGranted = PermissionStatus.notGranted
6-
static var screenRecordingIsGranted = PermissionStatus.notGranted
5+
static var accessibilityPermission = PermissionStatus.notGranted
6+
static var screenRecordingPermission = PermissionStatus.notGranted
77
static var preStartupPermissionsPassed = false
88
static var flakyCounter = 0
99
static var timerPermissionsToUpdatePermissionsWindow: Timer?
@@ -44,14 +44,14 @@ class SystemPermissions {
4444

4545
@discardableResult
4646
static func updateAccessibilityIsGranted() -> PermissionStatus {
47-
accessibilityIsGranted = detectAccessibilityIsGranted()
48-
return accessibilityIsGranted
47+
accessibilityPermission = detectAccessibilityIsGranted()
48+
return accessibilityPermission
4949
}
5050

5151
@discardableResult
5252
static func updateScreenRecordingIsGranted() -> PermissionStatus {
53-
screenRecordingIsGranted = detectScreenRecordingIsGranted()
54-
return screenRecordingIsGranted
53+
screenRecordingPermission = detectScreenRecordingIsGranted()
54+
return screenRecordingPermission
5555
}
5656

5757
private static func detectAccessibilityIsGranted() -> PermissionStatus {
@@ -72,12 +72,12 @@ class SystemPermissions {
7272
private static func checkPermissionsWhileAltTabIsRunning() {
7373
SystemPermissions.updateAccessibilityIsGranted()
7474
SystemPermissions.updateScreenRecordingIsGranted()
75-
Logger.debug(accessibilityIsGranted, screenRecordingIsGranted, preStartupPermissionsPassed)
76-
Menubar.togglePermissionCallout(screenRecordingIsGranted == .skipped)
77-
if accessibilityIsGranted == .notGranted {
75+
Logger.debug(accessibilityPermission, screenRecordingPermission, preStartupPermissionsPassed)
76+
Menubar.togglePermissionCallout(screenRecordingPermission == .skipped)
77+
if accessibilityPermission == .notGranted {
7878
App.app.restart()
7979
}
80-
if screenRecordingIsGranted == .notGranted {
80+
if screenRecordingPermission == .notGranted {
8181
// permission check may yield a false negative during wake-up
8282
// we restart after 2 negative checks
8383
if flakyCounter >= 2 {
@@ -93,22 +93,22 @@ class SystemPermissions {
9393
private static func checkPermissionsToUpdatePermissionsWindow(_ startupBlock: @escaping () -> Void) {
9494
updateAccessibilityIsGranted()
9595
updateScreenRecordingIsGranted()
96-
Logger.debug(accessibilityIsGranted, screenRecordingIsGranted, preStartupPermissionsPassed)
97-
Menubar.togglePermissionCallout(screenRecordingIsGranted == .skipped)
98-
if accessibilityIsGranted != App.app.permissionsWindow?.accessibilityView?.permissionStatus {
99-
App.app.permissionsWindow?.accessibilityView.updatePermissionStatus(accessibilityIsGranted)
96+
Logger.debug(accessibilityPermission, screenRecordingPermission, preStartupPermissionsPassed)
97+
Menubar.togglePermissionCallout(screenRecordingPermission == .skipped)
98+
if accessibilityPermission != App.app.permissionsWindow?.accessibilityView?.permissionStatus {
99+
App.app.permissionsWindow?.accessibilityView.updatePermissionStatus(accessibilityPermission)
100100
}
101-
if #available(macOS 10.15, *), screenRecordingIsGranted != App.app.permissionsWindow?.screenRecordingView?.permissionStatus {
102-
App.app.permissionsWindow?.screenRecordingView?.updatePermissionStatus(screenRecordingIsGranted)
101+
if #available(macOS 10.15, *), screenRecordingPermission != App.app.permissionsWindow?.screenRecordingView?.permissionStatus {
102+
App.app.permissionsWindow?.screenRecordingView?.updatePermissionStatus(screenRecordingPermission)
103103
}
104104
if !preStartupPermissionsPassed {
105-
if accessibilityIsGranted != .notGranted && screenRecordingIsGranted != .notGranted {
105+
if accessibilityPermission != .notGranted && screenRecordingPermission != .notGranted {
106106
preStartupPermissionsPassed = true
107107
App.app.permissionsWindow?.close()
108108
startupBlock()
109109
}
110110
} else {
111-
if accessibilityIsGranted == .notGranted || screenRecordingIsGranted == .notGranted {
111+
if accessibilityPermission == .notGranted || screenRecordingPermission == .notGranted {
112112
App.app.restart()
113113
}
114114
}

src/ui/App.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class App: AppCenterApplication {
198198
}
199199

200200
func refreshOpenUi(_ windowsToScreenshot: [Window], skipUpdatesBeforeShowing: Bool = false, onlyUpdateScreenshots: Bool = false) {
201-
if !Appearance.hideThumbnails && !windowsToScreenshot.isEmpty && SystemPermissions.screenRecordingIsGranted == .granted {
201+
if !Appearance.hideThumbnails && !windowsToScreenshot.isEmpty && SystemPermissions.screenRecordingPermission == .granted {
202202
Windows.refreshThumbnails(windowsToScreenshot, onlyUpdateScreenshots)
203203
return
204204
}

0 commit comments

Comments
 (0)