Improve external display handling and target selection performance #1512
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Greptile Summary
This PR improves external display handling and target selection performance through three key improvements:
Prewarmed Overlays for Faster Startup
PrewarmedOverlaysstate manager that creates hidden overlay windows on app startupCursor-Aware Display Positioning
Display::get_containing_cursor()logical_bounds()instead of physical coordinates for proper multi-monitor positioningTarget Mode Passthrough
target_modeparameter toShowCapWindow::TargetSelectOverlayand URL parametersRequestSetTargetModeevent allows direct navigation to display/window/area modesScreenshot Editor Improvements
.capdirectory structures and direct PNG filesThe changes are well-structured and follow existing patterns. The prewarming system properly handles cleanup of stale windows and prevents concurrent prewarming operations.
Confidence Score: 4/5
target_select_overlay.rsandwindows.rsfor multi-monitor positioning logicImportant Files Changed
open_target_pickerfunction with display detectionSequence Diagram
sequenceDiagram participant User participant Tray participant Main participant Lib as lib.rs participant TSO as target_select_overlay.rs participant Windows as windows.rs participant Frontend as target-select-overlay.tsx Note over Lib: App Startup Lib->>TSO: prewarm_target_select_overlays() TSO->>TSO: List all displays loop For each display TSO->>Windows: ShowCapWindow::TargetSelectOverlay Windows->>Frontend: Create hidden overlay window TSO->>TSO: Store in PrewarmedOverlays cache end Note over User,Frontend: User Initiates Target Selection User->>Tray: Click "Record Display" Tray->>Lib: open_target_picker(RecordingTargetMode::Display) Lib->>Lib: Display::get_containing_cursor() Lib->>Main: Hide main window Lib->>TSO: open_target_select_overlays(target_mode, display_id) alt Prewarmed overlay exists TSO->>TSO: Take from PrewarmedOverlays cache TSO->>Frontend: window.show() + set_focus() else No prewarmed overlay TSO->>Windows: ShowCapWindow::TargetSelectOverlay Windows->>Windows: Get display logical_bounds() Windows->>Frontend: Create overlay on cursor's display end TSO->>Frontend: Emit RequestSetTargetMode event Frontend->>Frontend: Set targetMode from URL param Frontend->>Frontend: Update UI for mode (display/window/area) Note over User,Frontend: User Makes Selection User->>Frontend: Click to select target Frontend->>Frontend: Update captureTarget in options Frontend->>TSO: closeTargetSelectOverlays() TSO->>Frontend: Close overlay windows Frontend->>Lib: startRecording() or take_screenshot()