Skip to content

Commit 9247fa1

Browse files
committed
refactor: self-recording and deployment target bump
- Auto-include self in app capture filter to enable dogfooding - Bump deployment target 15.0 → 15.2 - Mark unused sender param with underscore
1 parent 22ac3cf commit 9247fa1

3 files changed

Lines changed: 36 additions & 8 deletions

File tree

Sources/App/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
5656
}
5757
}
5858

59-
@objc func togglePopover(_ sender: AnyObject?) {
59+
@objc func togglePopover(_ _: AnyObject?) {
6060
if popover.isShown {
6161
closePopover()
6262
} else {

Sources/Core/RecordingEngine+Flow.swift

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ extension RecordingEngine {
6060
do {
6161
try await ensurePermissions()
6262

63+
let resolvedFilter = await augmentedFilterIfNeeded(from: filter)
6364
let directory = try await directoryProvider.recordingsDirectory()
6465
let outputURL = makeOutputURL(in: directory)
6566
currentOutputURL = outputURL
@@ -79,7 +80,7 @@ extension RecordingEngine {
7980
)
8081

8182
try await captureService.startRecording(
82-
filter: filter,
83+
filter: resolvedFilter,
8384
configuration: config,
8485
outputURL: outputURL,
8586
options: options,
@@ -93,6 +94,33 @@ extension RecordingEngine {
9394
}
9495
}
9596

97+
private func augmentedFilterIfNeeded(from filter: SCContentFilter) async -> SCContentFilter {
98+
guard captureSource == .application else { return filter }
99+
guard let bundleIdentifier = Bundle.main.bundleIdentifier else { return filter }
100+
101+
let currentApplications = filter.includedApplications
102+
if currentApplications.contains(where: { $0.bundleIdentifier == bundleIdentifier }) {
103+
return filter
104+
}
105+
106+
do {
107+
let content = try await SCShareableContent.current
108+
guard let captureApp = content.applications.first(where: { $0.bundleIdentifier == bundleIdentifier }) else {
109+
return filter
110+
}
111+
112+
guard let display = filter.includedDisplays.first ?? content.displays.first else {
113+
return filter
114+
}
115+
116+
var updatedApplications = currentApplications
117+
updatedApplications.append(captureApp)
118+
return SCContentFilter(display: display, including: updatedApplications, exceptingWindows: [])
119+
} catch {
120+
return filter
121+
}
122+
}
123+
96124
func stopRecording(discard: Bool) async {
97125
guard state.isRecording || state == .stopping else { return }
98126
setState(.stopping)

project.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: CaptureThis
22
options:
33
deploymentTarget:
4-
macOS: "15.0"
4+
macOS: "15.2"
55
bundleIdPrefix: com.capturethis
66

77
packages:
@@ -23,7 +23,7 @@ targets:
2323
CaptureThisCore:
2424
type: framework
2525
platform: macOS
26-
deploymentTarget: "15.0"
26+
deploymentTarget: "15.2"
2727
sources:
2828
- path: Sources/Core
2929
settings:
@@ -34,7 +34,7 @@ targets:
3434
CaptureThis:
3535
type: application
3636
platform: macOS
37-
deploymentTarget: "15.0"
37+
deploymentTarget: "15.2"
3838
sources:
3939
- path: Sources/App
4040
- path: Sources/Features
@@ -59,7 +59,7 @@ targets:
5959
CaptureThisCLI:
6060
type: tool
6161
platform: macOS
62-
deploymentTarget: "15.0"
62+
deploymentTarget: "15.2"
6363
sources:
6464
- path: Sources/CLI
6565
settings:
@@ -77,7 +77,7 @@ targets:
7777
CaptureThisTests:
7878
type: bundle.unit-test
7979
platform: macOS
80-
deploymentTarget: "15.0"
80+
deploymentTarget: "15.2"
8181
sources:
8282
- path: Tests/CaptureThisTests.swift
8383
dependencies:
@@ -90,7 +90,7 @@ targets:
9090
CaptureThisCoreTests:
9191
type: bundle.unit-test
9292
platform: macOS
93-
deploymentTarget: "15.0"
93+
deploymentTarget: "15.2"
9494
sources:
9595
- path: Tests/CoreTests
9696
dependencies:

0 commit comments

Comments
 (0)