feat: new setting to not capture windows in background (closes #5337)

Also closes #5371
This commit is contained in:
lwouis
2026-03-21 19:51:19 +01:00
parent 630527e0b7
commit 5ed6c1d9ce
5 changed files with 19 additions and 4 deletions
+6
View File
@@ -136,6 +136,9 @@
/* No comment provided by engineer. */
"Cancel" = "Cancel";
/* No comment provided by engineer. */
"Capture windows in the background" = "Capture windows in the background";
/* No comment provided by engineer. */
"Center" = "Center";
@@ -590,6 +593,9 @@
/* No comment provided by engineer. */
"Visible Spaces" = "Visible Spaces";
/* No comment provided by engineer. */
"When disabled, avoids the macOS purple screen-recording indicator, and avoids flickers when playing DRM video. Thumbnails will be less up-to-date." = "When disabled, avoids the macOS purple screen-recording indicator, and avoids flickers when playing DRM video. Thumbnails will be less up-to-date.";
/* No comment provided by engineer. */
"When fullscreen" = "When fullscreen";
+2
View File
@@ -47,6 +47,7 @@ class Preferences {
"hideSpaceNumberLabels": "false",
"hideStatusIcons": "false",
"previewFocusedWindow": "false",
"captureWindowsInBackground": "true",
"screenRecordingPermissionSkipped": "false",
"trackpadHapticFeedbackEnabled": "true",
"settingsWindowShownOnFirstLaunch": "false",
@@ -115,6 +116,7 @@ class Preferences {
static var startAtLogin: Bool { CachedUserDefaults.bool("startAtLogin") }
static var exceptions: [ExceptionEntry] { CachedUserDefaults.json("exceptions", [ExceptionEntry].self) }
static var previewSelectedWindow: Bool { CachedUserDefaults.bool("previewFocusedWindow") }
static var captureWindowsInBackground: Bool { CachedUserDefaults.bool("captureWindowsInBackground") }
static var screenRecordingPermissionSkipped: Bool { CachedUserDefaults.bool("screenRecordingPermissionSkipped") }
static var settingsWindowShownOnFirstLaunch: Bool { CachedUserDefaults.bool("settingsWindowShownOnFirstLaunch") }
+2 -1
View File
@@ -129,7 +129,8 @@ class Windows {
static func refreshThumbnailsAsync(_ windows: [Window], _ source: RefreshCausedBy, windowRemoved: Bool = false) {
guard (!windows.isEmpty || windowRemoved) && ScreenRecordingPermission.status == .granted
&& !Preferences.onlyShowApplications()
&& (!Appearance.hideThumbnails || Preferences.previewSelectedWindow) else { return }
&& (!Appearance.hideThumbnails || Preferences.previewSelectedWindow)
&& (Preferences.captureWindowsInBackground || App.appIsBeingUsed) else { return }
var eligibleWindows = [Window]()
for window in windows {
if !window.isWindowlessApp, let cgWindowId = window.cgWindowId, cgWindowId != CGWindowID(bitPattern: -1) {
@@ -516,15 +516,17 @@ class TableGroupView: ClickHoverStackView {
}
rowView.addSubview(secondaryRow)
secondaryRow.translatesAutoresizingMaskIntoConstraints = false
secondaryRow.topAnchor.constraint(equalTo: mainRow.bottomAnchor, constant: TableGroupView.rowIntraSpacing).isActive = true
secondaryRow.topAnchor.constraint(equalTo: mainRow.bottomAnchor, constant: 2).isActive = true
secondaryRow.bottomAnchor.constraint(equalTo: rowView.bottomAnchor, constant: -TableGroupView.padding).isActive = true
// constrain trailing to the right views' leading so subtitle wraps before the toggle
let rightStackView = mainRow.arrangedSubviews[2]
switch alignment {
case .leading:
secondaryRow.leadingAnchor.constraint(equalTo: rowView.leadingAnchor, constant: TableGroupView.padding).isActive = true
secondaryRow.trailingAnchor.constraint(lessThanOrEqualTo: rowView.trailingAnchor, constant: -TableGroupView.padding).isActive = true
secondaryRow.trailingAnchor.constraint(lessThanOrEqualTo: rightStackView.leadingAnchor).isActive = true
case .centerX:
secondaryRow.leadingAnchor.constraint(equalTo: rowView.leadingAnchor, constant: TableGroupView.padding).isActive = true
secondaryRow.trailingAnchor.constraint(equalTo: rowView.trailingAnchor, constant: -TableGroupView.padding).isActive = true
secondaryRow.trailingAnchor.constraint(equalTo: rightStackView.leadingAnchor).isActive = true
case .right:
secondaryRow.leadingAnchor.constraint(lessThanOrEqualTo: rowView.leadingAnchor, constant: TableGroupView.padding).isActive = true
secondaryRow.trailingAnchor.constraint(equalTo: rowView.trailingAnchor, constant: -TableGroupView.padding).isActive = true
@@ -36,9 +36,13 @@ class GeneralTab {
cell.arrowPosition = .arrowAtBottom
cell.imagePosition = .imageOverlaps
enableDraggingOffMenubarIcon(menuIconShownToggle)
let captureWindowsInBackground = TableGroupView.Row(leftTitle: NSLocalizedString("Capture windows in the background", comment: ""),
subTitle: NSLocalizedString("When disabled, avoids the macOS purple screen-recording indicator, and avoids flickers when playing DRM video. Thumbnails will be less up-to-date.", comment: ""),
rightViews: [LabelAndControl.makeSwitch("captureWindowsInBackground")])
let table = TableGroupView(width: SettingsWindow.contentWidth)
table.addRow(startAtLogin)
table.addRow(menubarIcon)
table.addRow(captureWindowsInBackground)
table.addNewTable()
table.addRow(language)
table.addNewTable()