Skip to content

feat(wallpaper): let Windows users pick the managed wallpaper display - #311

Open
sanketpatel32 wants to merge 3 commits into
Code-Amadeus:mainfrom
sanketpatel32:issue-190-wallpaper-target-display
Open

sanketpatel32 wants to merge 3 commits into
Code-Amadeus:mainfrom
sanketpatel32:issue-190-wallpaper-target-display

Conversation

@sanketpatel32

Copy link
Copy Markdown
Contributor

Summary

Closes #190 — a bounded implementation of the proposed monitor choice: one explicit monitor identity shared by the Lively helper and the Electron surfaces, primary display unchanged by default.

  • Identity: the GDI device name (\.\DISPLAY2) is the single identity across Win32 / the helper journal / Electron. Electron correlates displays to helper rects via screen.dipToScreenRect (physical px), so the physical-pixel vs DIP boundary is handled explicitly; Display.id never crosses it.
  • Helper (windows-wallpaper/helper.py): EnumDisplayMonitors + GetMonitorInfoExW enumeration under per-monitor-V2 DPI awareness (physical rects + device names + primary flag); LivelyHost.resolve_monitor(target) — None keeps PrimaryMonitor(), explicit targets resolve to exactly one monitor or fail (disconnected/ambiguous); resolved target stored in the Snapshot, so existing serialization/journal/restoration cover it unchanged.
  • Electron: wallpaperTarget.ts resolves a persisted AMADEUS_WALLPAPER_MONITOR setting to exactly one Electron Display; index.ts pins wallpaperSessionDisplayId and all interactive surfaces (slice/canvas/work overlay) mount on it; a display-change re-binds, display loss ends the session through the existing host-exit path — never a silent takeover of another monitor.
  • Settings: a ComboCard lists live monitors with "Primary display (default)"; macOS/Linux and external wallpaper hosts untouched; no OS display-configuration changes, no new dependencies.

Test plan

  • Python helper: 109 tests pass (8 new target-resolution cases)
  • Electron: 717 tests pass incl. new wallpaperTarget specs, target dedupe/remount/arg propagation, display-loss session end
  • tsc clean; npm run check:config, extension-sdk and pi checks pass; full vite build
  • Physical two-monitor acceptance still required (per the issue): select the secondary display; verify wallpaper/character/composer land there, primary stays primary, the other wallpaper is untouched, disconnect fails visibly, and journal restore is correct after stop/crash
  • Sanitized before/after screenshots need a two-monitor run

Generated with Devin

Refs Code-Amadeus#190.

Adds a persisted AMADEUS_WALLPAPER_MONITOR desktop setting (default:
primary display, unchanged behavior). The persisted value is a Windows
GDI device name such as \\.\DISPLAY2, the identity Lively's screen
list, Win32 MONITORINFOEX enumeration, and the session journal already
speak; Electron's volatile Display.id never crosses the boundary.

- The Python helper enumerates monitors under per-monitor-V2 DPI
  awareness (physical pixels), gains a read-only screens command,
  accepts run <url> [target], resolves the target exactly, and stores
  it in the existing Snapshot/journal. A missing or ambiguous target
  fails before any display is taken over.
- Electron resolves the same identity at session open: the helper's
  physical-pixel rectangles are correlated with each display's
  dipToScreenRect output. The resolved display is pinned for the
  session and used for the slice, canvas, and work surfaces.
- Changing the target restores the previous session before mounting on
  the new display; an unresolved target reports the problem without
  taking over another monitor.
- macOS/Linux and external wallpaper hosts are unchanged; no OS display
  configuration is modified.

Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@sanketpatel32
sanketpatel32 force-pushed the issue-190-wallpaper-target-display branch from 970dc9e to d99d7fe Compare November 22, 2026 23:56

@Lucas1479 Lucas1479 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @sanketpatel32 for picking up #190. The default path stays on the primary display, and a target that is disconnected or ambiguous fails closed instead of silently taking over another monitor. Both match what the issue asked for.

There is one blocking problem, and the acceptance run the issue requires is still missing:

  1. An explicit target can never resolve against a real Lively host. The PR persists the GDI device name (\\.\DISPLAY2) and compares it with LivelyHost.get_screens().

    • get_screens() reads field 1 of Lively's ScreenData. Field 1 is device_id, the device-interface path (\\?\DISPLAY#…#{…}); device_name is field 2 (display.proto, DisplayManager.cs).
    • SetWallpaper also looks the display up by DeviceId (WinDesktopCoreServer.cs).
    • So resolve_monitor("\\.\DISPLAY2") matches nothing, and every explicit choice ends with "is not connected". The new helper tests pass only because they stub get_screens with GDI names.

    Suggested direction: make Lively's DeviceId the persisted identity. The screens command can get it the same way Lively does (EnumDisplayDevicesW(..., EDD_GET_DEVICE_INTERFACE_NAME), DisplayManager.cs) and report it next to the physical rectangle. Electron can keep matching displays by rectangle. A DeviceId is also more stable than \\.\DISPLAYn, which can be renumbered when displays or GPUs are hot-plugged. Please add a test whose fake screens use device IDs shaped like real ones.

  2. Physical two-monitor acceptance, as #190 requires. Please cover:

    • selecting the secondary display, and where the wallpaper, character and composer land;
    • the primary display and the other monitor's wallpaper staying unchanged;
    • a visible failure when the target is disconnected;
    • journal restore after a stop and after a crash.

    Please include sanitized screenshots.

I haven't reviewed the Electron re-pinning paths in index.ts in depth yet (slice recreation and display changes). I'll look at them again after the identity fix.

The previous commit persisted the GDI device name (\\.\DISPLAY2), but
LivelyHost.get_screens() reads ScreenData field 1 — the device-interface
path (\\?\DISPLAY#…#{…}) — and SetWallpaper resolves displays by that
same DeviceId, so an explicit target could never match a real host.

- Windows.monitors() now queries EnumDisplayDevicesW(szDevice, 0,
  EDD_GET_DEVICE_INTERFACE_NAME), the same call Lively's DisplayManager
  makes, and MonitorGeometry reports DeviceId next to the physical rect
  and the GDI name (labels only; it can be renumbered on hot-plug).
- The screens command emits DeviceId; AMADEUS_WALLPAPER_MONITOR persists
  it, so helper resolve_monitor matches the identity SetWallpaper gets.
- Electron still correlates displays by physical rectangle; resolution
  and options now key on deviceId while labels keep the GDI name.
- Tests use fake screens with real-shaped device-interface paths, and a
  GDI name is asserted to be an unresolvable target.
devin-ai-integration Bot pushed a commit to sanketpatel32/Amadeus that referenced this pull request Nov 23, 2026
The full-display Slice surface saved positions in localStorage, but it loads
from http://127.0.0.1:<assetPort> and AssetServer picks a free port each run,
so the origin — and the saved positions — reset every restart.

- sliceControlPositions.ts: normalized {status,card} positions (window
  coordinates, [-1,1]) stored at userData/wallpaper-control-positions.json
  with the same durable write pattern as desktop settings.
- Preload exposes get/setControlPositions on window.amadeus; the renderer
  loads positions once over IPC and writes on drop/reset. Only the slice and
  canvas renderers may call the IPC.
- electronSliceDisplay(): both full-display bounds helpers now resolve the
  target display in one place — AMADEUS_WALLPAPER_MONITOR matches an Electron
  label/id until Code-Amadeus#311's DeviceId resolver lands, primary stays the fallback,
  so the surface follows the chosen wallpaper display.
@sanketpatel32

Copy link
Copy Markdown
Contributor Author

Requested changes addressed in f2d337d:

  • DeviceId persistence. get_screens() now emits each monitor's DeviceId (the \\?\DISPLAY#…#{…} device-interface path, via EnumDisplayDevicesW + EDD_GET_DEVICE_INTERFACE_NAME — the same call Lively's DisplayManager makes). parseWallpaperMonitors requires a non-empty DeviceId, resolveWallpaperTargetDisplay filters on it, and wallpaperMonitorOptions returns the DeviceId as the persisted value; the GDI \\.\DISPLAYn name is labels-only and can never resolve as a target (test: a GDI device name is never a resolvable target). A lookup that fails EnumDisplayDevicesW fails closed with an empty DeviceId.
  • Real-shaped fixtures. Tests use \\?\DISPLAY#SAM0A8F#… / GSM5BC7 / DELA1B2 device-interface paths across the helper, launch-target, and Electron-side tests.

Outstanding: the physical two-monitor acceptance pass + sanitized screenshots need a Windows host — flagging that as the remaining evidence rather than simulating it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows managed wallpaper: choose a target display without changing the OS primary screen

2 participants