perf: improve rendering performance by doing less work

This commit is contained in:
lwouis committed 2025-11-09 09:40:07 +01:00
1 parent 689adc0a30
commit ec55ae8b00
2 files changed
+5 -14

No files matched your search

+3
View File
@@ -315,6 +315,9 @@ class Windows {
// dispatch screenshot requests off the main-thread, then wait for completion // dispatch screenshot requests off the main-thread, then wait for completion
static func refreshThumbnailsAsync(_ windows: [Window], _ source: RefreshCausedBy) { static func refreshThumbnailsAsync(_ windows: [Window], _ source: RefreshCausedBy) {
guard !windows.isEmpty && SystemPermissions.screenRecordingPermission == .granted
&& !Preferences.onlyShowApplications()
&& (!Appearance.hideThumbnails || Preferences.previewFocusedWindow) else { return }
var eligibleWindows = [Window]() var eligibleWindows = [Window]()
for window in windows { for window in windows {
if !window.isWindowlessApp, let cgWindowId = window.cgWindowId, cgWindowId != CGWindowID(bitPattern: -1) { if !window.isWindowlessApp, let cgWindowId = window.cgWindowId, cgWindowId != CGWindowID(bitPattern: -1) {
+2 -14
View File
@@ -42,12 +42,6 @@ class App: AppCenterApplication {
fatalError("Class only supports programmatic initialization") fatalError("Class only supports programmatic initialization")
} }
/// pre-load some windows so they are faster on first display
private func preloadWindows() {
thumbnailsPanel.orderFront(nil)
thumbnailsPanel.orderOut(nil)
}
/// we put application code here which should be executed on init() and Preferences change /// we put application code here which should be executed on init() and Preferences change
func resetPreferencesDependentComponents() { func resetPreferencesDependentComponents() {
thumbnailsPanel.thumbnailsView.reset() thumbnailsPanel.thumbnailsView.reset()
@@ -203,12 +197,7 @@ class App: AppCenterApplication {
} }
func refreshOpenUi(_ windowsToScreenshot: [Window], _ source: RefreshCausedBy) { func refreshOpenUi(_ windowsToScreenshot: [Window], _ source: RefreshCausedBy) {
if !windowsToScreenshot.isEmpty && SystemPermissions.screenRecordingPermission == .granted Windows.refreshThumbnailsAsync(windowsToScreenshot, source)
&& !Preferences.onlyShowApplications()
&& (!Appearance.hideThumbnails || Preferences.previewFocusedWindow) {
Windows.refreshThumbnailsAsync(windowsToScreenshot, source)
if source == .refreshOnlyThumbnailsAfterShowUi { return }
}
guard appIsBeingUsed else { return } guard appIsBeingUsed else { return }
if source == .refreshUiAfterExternalEvent { if source == .refreshUiAfterExternalEvent {
if !Windows.updatesBeforeShowing() { hideUi(); return } if !Windows.updatesBeforeShowing() { hideUi(); return }
@@ -266,7 +255,7 @@ class App: AppCenterApplication {
guard appIsBeingUsed else { return } guard appIsBeingUsed else { return }
thumbnailsPanel.show() thumbnailsPanel.show()
KeyRepeatTimer.toggleRepeatingKeyNextWindow() KeyRepeatTimer.toggleRepeatingKeyNextWindow()
refreshOpenUi(Windows.list, .refreshOnlyThumbnailsAfterShowUi) Windows.refreshThumbnailsAsync(Windows.list, .refreshOnlyThumbnailsAfterShowUi)
} }
func checkIfShortcutsShouldBeDisabled(_ activeWindow: Window?, _ activeApp: NSRunningApplication?) { func checkIfShortcutsShouldBeDisabled(_ activeWindow: Window?, _ activeApp: NSRunningApplication?) {
@@ -323,7 +312,6 @@ extension App: NSApplicationDelegate {
MouseEvents.observe() MouseEvents.observe()
TrackpadEvents.observe() TrackpadEvents.observe()
CliEvents.observe() CliEvents.observe()
self.preloadWindows()
Logger.info("AltTab finished launching") Logger.info("AltTab finished launching")
#if DEBUG #if DEBUG
// self.showPreferencesWindow() // self.showPreferencesWindow()