fix(hud): resolve overlay snap to primary on multi-monitor#207
Conversation
- Add getHudOverlayDisplay() helper using getDisplayMatching() to detect which display the HUD is currently on - Replace getPrimaryDisplay() in getHudOverlayBounds(), set-hud-overlay-compact-width, set-hud-overlay-measured-height handlers, and createHudOverlayWindow() maxHeight constraint - Falls back to primary display when HUD window doesn't exist Tested on Windows 11 with dual-monitor setup. HUD stays on the external monitor through recording start/stop and expand/collapse cycles.
|
Warning
|
| Cohort / File(s) | Summary |
|---|---|
HUD Display Selection & Sizing electron/windows.ts |
Added getHudOverlayDisplay() function for intelligent display selection. Updated getHudOverlayBounds(), IPC handlers set-hud-overlay-compact-width and set-hud-overlay-measured-height, and createHudOverlayWindow() to use the selected display's bounds/workArea instead of always referencing the primary display. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
- Fix Linux HUD input handling #157: Modifies
createHudOverlayWindow()in the same file to adjust HUD mouse passthrough behavior, alongside the display selection changes in this PR.
Suggested labels
Checked
Poem
🐰 A HUD so smart, no longer tied,
To primary display's stubborn pride,
Now finds the screen where it should be,
Multi-monitor harmony! 🖥️✨
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title accurately summarizes the main change: fixing HUD overlay snapping to primary monitor on multi-monitor setups. |
| Description check | ✅ Passed | The PR description includes all key sections from the template: summary, motivation/context, detailed changes, comprehensive testing (including manual verification on dual-monitor setup), and risk assessment. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Summary
Fix the HUD overlay snapping to the primary monitor when recording
starts on a multi-monitor setup. The positioning logic now detects
which display the HUD is on using
screen.getDisplayMatching()instead of always defaulting to
getPrimaryDisplay().Context / Motivation
monitor (typically the screen being recorded)
for recording controls, firing the ResizeObserver
set-hud-overlay-compact-widthandset-hud-overlay-measured-heightIPC messages to the main processapplyHudOverlayBounds(), which computes x,yfrom the primary display's
workArea— always re-centering onprimary regardless of where the user placed the HUD
getDisplayMatching()pattern alreadyused by
getUpdateToastBounds()in this fileChanges
getHudOverlayDisplay()helper that usesgetDisplayMatching(hudWindow.getBounds())with fallback togetPrimaryDisplay()when the window doesn't exist yetgetPrimaryDisplay()ingetHudOverlayBounds()getPrimaryDisplay()inset-hud-overlay-compact-widthIPC handlergetPrimaryDisplay()inset-hud-overlay-measured-heightIPC handlergetPrimaryDisplay()increateHudOverlayWindow()maxHeight constraintTesting
start/stop cycle
Manual test — Windows 11 Pro (Build 26200):
npx vite build && npx electron-builder --win --dirgetDisplayMatching()returnedthe correct display throughout the entire cycle
Single monitor:
getDisplayMatching()with one displayalways returns that display — identical to
getPrimaryDisplay().No behavioral change.
Cross-platform:
screen.getDisplayMatching()is a core ElectronAPI on Windows, macOS, and Linux. No platform-specific code added.
Risks & Impact
getDisplayMatching()returns the display with largest overlap —same behavior as Electron's own transparent window positioning
Summary by CodeRabbit
Release Notes