Skip to content

Commit ec55ae8

Browse files
committed
perf: improve rendering performance by doing less work
1 parent 689adc0 commit ec55ae8

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

src/logic/Windows.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ class Windows {
315315

316316
// dispatch screenshot requests off the main-thread, then wait for completion
317317
static func refreshThumbnailsAsync(_ windows: [Window], _ source: RefreshCausedBy) {
318+
guard !windows.isEmpty && SystemPermissions.screenRecordingPermission == .granted
319+
&& !Preferences.onlyShowApplications()
320+
&& (!Appearance.hideThumbnails || Preferences.previewFocusedWindow) else { return }
318321
var eligibleWindows = [Window]()
319322
for window in windows {
320323
if !window.isWindowlessApp, let cgWindowId = window.cgWindowId, cgWindowId != CGWindowID(bitPattern: -1) {

src/ui/App.swift

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ class App: AppCenterApplication {
4242
fatalError("Class only supports programmatic initialization")
4343
}
4444

45-
/// pre-load some windows so they are faster on first display
46-
private func preloadWindows() {
47-
thumbnailsPanel.orderFront(nil)
48-
thumbnailsPanel.orderOut(nil)
49-
}
50-
5145
/// we put application code here which should be executed on init() and Preferences change
5246
func resetPreferencesDependentComponents() {
5347
thumbnailsPanel.thumbnailsView.reset()
@@ -203,12 +197,7 @@ class App: AppCenterApplication {
203197
}
204198

205199
func refreshOpenUi(_ windowsToScreenshot: [Window], _ source: RefreshCausedBy) {
206-
if !windowsToScreenshot.isEmpty && SystemPermissions.screenRecordingPermission == .granted
207-
&& !Preferences.onlyShowApplications()
208-
&& (!Appearance.hideThumbnails || Preferences.previewFocusedWindow) {
209-
Windows.refreshThumbnailsAsync(windowsToScreenshot, source)
210-
if source == .refreshOnlyThumbnailsAfterShowUi { return }
211-
}
200+
Windows.refreshThumbnailsAsync(windowsToScreenshot, source)
212201
guard appIsBeingUsed else { return }
213202
if source == .refreshUiAfterExternalEvent {
214203
if !Windows.updatesBeforeShowing() { hideUi(); return }
@@ -266,7 +255,7 @@ class App: AppCenterApplication {
266255
guard appIsBeingUsed else { return }
267256
thumbnailsPanel.show()
268257
KeyRepeatTimer.toggleRepeatingKeyNextWindow()
269-
refreshOpenUi(Windows.list, .refreshOnlyThumbnailsAfterShowUi)
258+
Windows.refreshThumbnailsAsync(Windows.list, .refreshOnlyThumbnailsAfterShowUi)
270259
}
271260

272261
func checkIfShortcutsShouldBeDisabled(_ activeWindow: Window?, _ activeApp: NSRunningApplication?) {
@@ -323,7 +312,6 @@ extension App: NSApplicationDelegate {
323312
MouseEvents.observe()
324313
TrackpadEvents.observe()
325314
CliEvents.observe()
326-
self.preloadWindows()
327315
Logger.info("AltTab finished launching")
328316
#if DEBUG
329317
// self.showPreferencesWindow()

0 commit comments

Comments
 (0)