Skip to content

Edge-Drop is a clipboard shelf on the edge of your screen. Hover to open it. Drag files and images into any app, click to copy text and links. Free and open-source for Windows.

feat(display): cross-reboot display persistence with 4-tier fuzzy geometry matching and primary fallback

Deepender259e1be8cbbc83
diff --git a/README.md b/README.md
index 4f4ab39..24794cf 100644
--- a/README.md
+++ b/README.md
@@ -112,6 +112,7 @@ npm run build:store # outputs an MSIX .appx for Microsoft Store submission
- Configurable hot-zone height (25% / 40% / 60% of screen) and blade height (40% – 100%)
- **Vertical Position Presets:** Customize screen edge placement with **Top**, **Center** (default), or **Bottom** vertical alignment presets, featuring exact dynamic boundary clamping (zero clipping/out-of-bounds).
- **Multi-monitor support:** Pick exactly which display the panel sticks to, with options for Left or Right screen edges. Features a single source of truth multi-display engine (`getDisplayListOptions()`) with real-time physical resolution calculation (3840×2160, 2560×1440, 1920×1080) across all High-DPI Windows display scaling factors.
+- **Cross-Reboot Display Persistence:** Edge-Drop remembers your chosen monitor across device restarts. A 4-tier resolution pipeline (exact session ID → fuzzy workArea geometry match within 8px tolerance → nearest by position → primary fallback) silently re-identifies the correct physical monitor after Windows re-assigns numeric display IDs on reboot. If the monitor is genuinely unplugged, the panel seamlessly falls back to the Primary Display without any user action.
- **Fullscreen Protection (Game Mode):** Native Windows `SHQueryUserNotificationState` OS detection (`fullscreen.ts`) automatically suppresses edge hover when Direct3D games, fullscreen videos, or presentations are active.
- **Ultra-lightweight:** Optimized memory footprint (~60% reduced RAM) using custom `edgelocal://` streaming protocols and compressed WebM assets.
@@ -144,6 +145,7 @@ npm run build:store # outputs an MSIX .appx for Microsoft Store submission
- **macOS Segmented Control 5-Category Filter Suite**: Integrated 5-type filter bar (**`All`**, **`Text`**, **`Links`**, **`Images`**, **`Files`**) with a single persistent sliding spring indicator pill (`stiffness: 500`, `damping: 35`) and zero shape distortion.
- **Unified Image Entity Classification**: Native screenshots (`Win + Shift + S`) and copied image files (`.png`, `.jpg`, `.webp`, `.svg`) are unified under the **`Images`** filter tab with visual thumbnail cards.
- **HD Anti-Aliased Curved Edges**: GPU layer promotion (`transform: translateZ(0)`), `-webkit-background-clip: padding-box`, and smooth vector rasterization delivering 100% HD anti-aliased curved borders across all display scales.
+- **Cross-Reboot Display Persistence**: 4-tier display resolution pipeline persists `stickDisplayWorkArea` + `stickDisplayScaleFactor` to `settings.json`. On reboot, fuzzy geometry matching (8px tolerance) re-identifies the correct monitor even after Windows re-assigns numeric display IDs — with a safe primary display fallback if the monitor is genuinely disconnected.
- **Tactile Micro-Interactions & Spring Motion**: Card hover 2px lift with ambient backlight glow, micro radial copy ripple effect, and smooth Framer Motion `layoutId` spring list reflow (`stiffness: 500`, `damping: 32`).
- **Refined Obsidian Aesthetics & Multi-Layer Depth**: Dual-layer 3D glass hairline highlights (`inset 0 1px 0 rgba(255, 255, 255, 0.12)`) and dual typography hierarchy (monospaced *JetBrains Mono* metadata + *Inter/SF Pro* system title font stack).
- **Ergonomic Card Action Bar & Safety Guard**: Re-ordered card actions (`Pin`, `Expand`, `Copy`, `Open Link`, `Divider`, `Delete`) with a physical safety hairline divider and 100% layout consistency across normal hover and preview mode.
diff --git a/electron/main/geometry.ts b/electron/main/geometry.ts
index 141b04a..b66ef10 100644
--- a/electron/main/geometry.ts
+++ b/electron/main/geometry.ts
@@ -3,12 +3,20 @@ export type StickPosition = 'left' | 'right'
export interface DisplayInfo {
id: number
workArea: { x: number; y: number; width: number; height: number }
+ scaleFactor?: number
}
export interface StickBoundsParams {
position: StickPosition
displays: DisplayInfo[]
displayId?: number
+ /**
+ * Persisted workArea geometry from the previous session.
+ * Used as Tier-2 fuzzy match when the OS re-assigns numeric IDs on reboot.
+ */
+ savedWorkArea?: { x: number; y: number; width: number; height: number }
+ /** Persisted scale factor — secondary discriminator for identical-geometry monitors. */
+ savedScaleFactor?: number
windowWidth: number
windowHeight: number
currentBounds?: { x: number; y: number }
@@ -20,48 +28,96 @@ export interface StickBoundsResult {
width: number
height: number
displayId: number
+ /** The resolved display, exposed so callers can persist fresh geometry. */
+ resolvedDisplay: DisplayInfo
+}
+
+/**
+ * Tolerance (pixels) for workArea fuzzy-match.
+ *
+ * Windows sometimes shifts a display's workArea origin by a few pixels after
+ * a DWM restart, a driver update, or the taskbar repositioning — so exact
+ * equality would miss the right monitor. 8px is well within the margin of
+ * error while still being strict enough to disambiguate normal multi-monitor
+ * layouts (monitors are separated by at least their own width).
+ */
+const BOUNDS_TOLERANCE = 8
+
+function boundsMatch(
+ a: { x: number; y: number; width: number; height: number },
+ b: { x: number; y: number; width: number; height: number }
+): boolean {
+ return (
+ Math.abs(a.x - b.x) <= BOUNDS_TOLERANCE &&
+ Math.abs(a.y - b.y) <= BOUNDS_TOLERANCE &&
+ Math.abs(a.width - b.width) <= BOUNDS_TOLERANCE &&
+ Math.abs(a.height - b.height) <= BOUNDS_TOLERANCE
+ )
}
export function computeStickBounds(params: StickBoundsParams): StickBoundsResult {
- const { position, displays, displayId, windowWidth, currentBounds } = params
+ const { position, displays, displayId, savedWorkArea, savedScaleFactor, windowWidth, currentBounds } = params
let display: DisplayInfo | undefined
+ // ── Tier 1: exact session-local numeric ID match (fast path within same session) ──
if (displayId !== undefined) {
display = displays.find(d => d.id === displayId)
}
+ // ── Tier 2: cross-reboot fuzzy workArea match ──────────────────────────────────
+ // The OS re-assigns numeric display IDs on every Windows boot, so the saved ID
+ // will never match after a restart. Instead we match on the persisted workArea
+ // geometry (within BOUNDS_TOLERANCE) and optionally the DPI scale factor as a
+ // secondary discriminator when two monitors share the same resolution.
+ if (!display && savedWorkArea) {
+ const candidates = displays.filter(d => boundsMatch(d.workArea, savedWorkArea))
+ if (candidates.length === 1) {
+ // Only one display matches the stored geometry — unambiguous.
+ display = candidates[0]
+ } else if (candidates.length > 1 && savedScaleFactor !== undefined) {
+ // Multiple displays with the same geometry (e.g. dual same-res). Use
+ // scale factor as a tiebreaker.
+ const byScale = candidates.find(d => d.scaleFactor === savedScaleFactor)
+ display = byScale ?? candidates[0]
+ } else if (candidates.length > 1) {
+ // Tie with no scale discriminator — take the first candidate.
+ display = candidates[0]
+ }
+ // If candidates.length === 0 the saved display is genuinely gone; fall through.
+ }
+
+ // ── Tier 3: nearest-by-current-window-position (session continuity, no saved data) ──
if (!display && displayId === undefined && currentBounds) {
const nearest = findNearestDisplay(displays, currentBounds)
if (nearest) display = nearest
}
+ // ── Tier 4: primary display fallback ──────────────────────────────────────────
if (!display) {
- display = displays.find(d => (d as any).isPrimary) || displays[0]
+ display = displays.find(d => (d as any).isPrimary) ?? displays[0]
}
const wa = display.workArea
let x: number
let y: number
- let width = windowWidth
- let height: number
+ const width = windowWidth
+ // Use the resolved display's own height — NOT always the primary's.
+ const height = wa.height
switch (position) {
case 'left':
x = wa.x
y = wa.y
- height = wa.height
break
case 'right':
x = wa.x + wa.width - windowWidth
y = wa.y
- height = wa.height
break
-
}
- return { x, y, width, height, displayId: display.id }
+ return { x, y, width, height, displayId: display.id, resolvedDisplay: display }
}
function findNearestDisplay(displays: DisplayInfo[], point: { x: number; y: number }): DisplayInfo | undefined {
diff --git a/electron/main/ipc.ts b/electron/main/ipc.ts
index a424c4b..90f58fe 100644
--- a/electron/main/ipc.ts
+++ b/electron/main/ipc.ts
@@ -453,7 +453,22 @@ export function registerIpc(): void {
})
handle('settings:update', (patch) => {
- const next = saveSettings(patch)
+ // When the user explicitly picks a display, also persist its geometry so
+ // the next reboot can re-identify the monitor via fuzzy bounds matching
+ // even after Windows re-assigns numeric display IDs.
+ let enrichedPatch = { ...patch }
+ if (patch.stickDisplayId !== undefined) {
+ const displays = getDisplayListOptions()
+ const chosen = displays.find(d => d.id === patch.stickDisplayId)
+ if (chosen) {
+ enrichedPatch = {
+ ...enrichedPatch,
+ stickDisplayWorkArea: chosen.bounds,
+ stickDisplayScaleFactor: chosen.scaleFactor
+ }
+ }
+ }
+ const next = saveSettings(enrichedPatch)
if (patch.launchAtLogin !== undefined && app.isPackaged) {
try {
app.setLoginItemSettings({
diff --git a/electron/main/tray.ts b/electron/main/tray.ts
index 314bc59..0a9dfc1 100644
--- a/electron/main/tray.ts
+++ b/electron/main/tray.ts
@@ -64,7 +64,12 @@ export function createTray(): Tray {
type: 'radio' as const,
checked: d.isCurrent,
click: () => {
- const next = saveSettings({ stickDisplayId: d.id })
+ // Persist ID + geometry so the next reboot can fuzzy-match via workArea.
+ const next = saveSettings({
+ stickDisplayId: d.id,
+ stickDisplayWorkArea: d.bounds,
+ stickDisplayScaleFactor: d.scaleFactor
+ })
pushState.settings(next)
repositionWindow()
popUpAndRetract(1500)
diff --git a/electron/main/window.ts b/electron/main/window.ts
index eeb32e3..224d046 100644
--- a/electron/main/window.ts
+++ b/electron/main/window.ts
@@ -205,34 +205,79 @@ function getStickGeometry(): { x: number; y: number; width: number; height: numb
const allDisplays = screen.getAllDisplays().map(d => ({
id: d.id,
workArea: { ...d.workArea },
+ scaleFactor: d.scaleFactor,
isPrimary: d.id === primaryDisplay.id
}))
- // Auto-heal: If configured stickDisplayId is disconnected, immediately reset to undefined
- // so the panel instantly falls back to the Primary Display and stays fully usable.
- if (settings.stickDisplayId !== undefined && !allDisplays.some(d => d.id === settings.stickDisplayId)) {
- console.log(`[Main] Configured stickDisplayId (${settings.stickDisplayId}) disconnected. Falling back immediately to Primary Display (${primaryDisplay.id}).`)
- settings = saveSettings({ stickDisplayId: undefined })
- if (mainWindow && !mainWindow.isDestroyed() && !mainWindow.webContents.isDestroyed()) {
- mainWindow.webContents.send('state:settings', settings)
- }
- popUpAndRetract(1500)
- }
-
- const primaryHeight = primaryDisplay.workArea.height
- const windowHeight = primaryHeight
const currentWindowWidth = previewActive ? 820 : PANEL_WIDTH
const result = computeStickBounds({
position: settings.stickPosition,
displays: allDisplays,
displayId: settings.stickDisplayId,
+ savedWorkArea: settings.stickDisplayWorkArea,
+ savedScaleFactor: settings.stickDisplayScaleFactor,
windowWidth: currentWindowWidth,
- windowHeight,
+ windowHeight: primaryDisplay.workArea.height, // initial hint; result uses resolvedDisplay.workArea.height
currentBounds: getMainWindow()?.getBounds()
})
- currentStickDisplayId = result.displayId
+ const resolved = result.resolvedDisplay
+
+ // ── Self-heal: persist fresh geometry whenever the resolved display differs ──
+ // This covers two scenarios:
+ // A) Cross-reboot: OS re-assigned a new numeric ID to the same physical monitor.
+ // We matched via Tier-2 fuzzy bounds — now save the new ID so future same-
+ // session lookups hit Tier-1 instantly.
+ // B) Display disconnected: Tier-4 fell back to primary — clear stale persisted
+ // display so the app stays fully usable and the UI shows primary as active.
+ const idChanged = settings.stickDisplayId !== undefined && settings.stickDisplayId !== resolved.id
+ const idWasStale = settings.stickDisplayId !== undefined && !allDisplays.some(d => d.id === settings.stickDisplayId)
+
+ if (idWasStale) {
+ // The old ID no longer exists in this session (disconnected or reboot rename).
+ // Check whether we recovered via Tier-2 or fell all the way to primary.
+ const recoveredViaBounds = settings.stickDisplayWorkArea !== undefined && resolved.id !== primaryDisplay.id
+ if (recoveredViaBounds) {
+ console.log(`[Main] Display ${settings.stickDisplayId} re-matched via geometry to display ${resolved.id} — updating persisted ID.`)
+ } else {
+ console.log(`[Main] Display ${settings.stickDisplayId} disconnected or unrecognised. Falling back to display ${resolved.id}.`)
+ }
+ settings = saveSettings({
+ stickDisplayId: recoveredViaBounds ? resolved.id : undefined,
+ stickDisplayWorkArea: recoveredViaBounds ? resolved.workArea : undefined,
+ stickDisplayScaleFactor: recoveredViaBounds ? resolved.scaleFactor : undefined
+ })
+ if (mainWindow && !mainWindow.isDestroyed() && !mainWindow.webContents.isDestroyed()) {
+ mainWindow.webContents.send('state:settings', settings)
+ }
+ if (!recoveredViaBounds) {
+ // Genuinely fell back — briefly show panel on new location.
+ popUpAndRetract(1500)
+ }
+ } else if (idChanged) {
+ // Shouldn't happen if Tier-1 matched, but guard it anyway.
+ settings = saveSettings({
+ stickDisplayId: resolved.id,
+ stickDisplayWorkArea: resolved.workArea,
+ stickDisplayScaleFactor: resolved.scaleFactor
+ })
+ if (mainWindow && !mainWindow.isDestroyed() && !mainWindow.webContents.isDestroyed()) {
+ mainWindow.webContents.send('state:settings', settings)
+ }
+ } else if (settings.stickDisplayId !== undefined && (
+ settings.stickDisplayWorkArea === undefined ||
+ settings.stickDisplayScaleFactor === undefined
+ )) {
+ // Upgrade: user had a stickDisplayId saved before this feature was added;
+ // backfill geometry silently so the next reboot can fuzzy-match.
+ saveSettings({
+ stickDisplayWorkArea: resolved.workArea,
+ stickDisplayScaleFactor: resolved.scaleFactor
+ })
+ }
+
+ currentStickDisplayId = resolved.id
return { x: result.x, y: result.y, width: result.width, height: result.height }
}
@@ -365,18 +410,45 @@ export function registerWindowRepositionListener(fn: () => void): void {
export function getActiveDisplayId(allDisplays?: Electron.Display[]): number {
const displays = allDisplays ?? screen.getAllDisplays()
const settings = loadSettings()
+ const primary = screen.getPrimaryDisplay()
+
+ // Tier 1: exact session-local ID match.
if (settings.stickDisplayId !== undefined && displays.some(d => d.id === settings.stickDisplayId)) {
return settings.stickDisplayId
}
+
+ // Tier 2: fuzzy workArea match (cross-reboot).
+ if (settings.stickDisplayWorkArea !== undefined) {
+ const TOLERANCE = 8
+ const sa = settings.stickDisplayWorkArea
+ const candidates = displays.filter(d =>
+ Math.abs(d.workArea.x - sa.x) <= TOLERANCE &&
+ Math.abs(d.workArea.y - sa.y) <= TOLERANCE &&
+ Math.abs(d.workArea.width - sa.width) <= TOLERANCE &&
+ Math.abs(d.workArea.height - sa.height) <= TOLERANCE
+ )
+ if (candidates.length === 1) return candidates[0].id
+ if (candidates.length > 1 && settings.stickDisplayScaleFactor !== undefined) {
+ const byScale = candidates.find(d => d.scaleFactor === settings.stickDisplayScaleFactor)
+ if (byScale) return byScale.id
+ return candidates[0].id
+ }
+ if (candidates.length > 1) return candidates[0].id
+ }
+
+ // Tier 3: in-memory ID set this session by getStickGeometry.
if (currentStickDisplayId !== undefined && displays.some(d => d.id === currentStickDisplayId)) {
return currentStickDisplayId
}
- return screen.getPrimaryDisplay().id
+
+ // Tier 4: primary fallback.
+ return primary.id
}
export function getDisplayListOptions(): Array<{
id: number
bounds: { x: number; y: number; width: number; height: number }
+ scaleFactor: number
isPrimary: boolean
isCurrent: boolean
label: string
@@ -392,7 +464,7 @@ export function getDisplayListOptions(): Array<{
const rawName = (d as any).label || (d as any).name || ''
const fallbackName = isPrimary ? 'Primary Monitor' : `Display ${index + 1}`
const baseName = rawName.trim() ? rawName.trim() : fallbackName
- const name = isPrimary
+ const name = isPrimary
? (baseName.toLowerCase().includes('primary') ? baseName : `${baseName} (Primary)`)
: baseName
const scale = d.scaleFactor || 1
@@ -402,6 +474,7 @@ export function getDisplayListOptions(): Array<{
return {
id: d.id,
bounds: { x: d.bounds.x, y: d.bounds.y, width: d.bounds.width, height: d.bounds.height },
+ scaleFactor: scale,
isPrimary,
isCurrent: d.id === activeId,
label: `${name} ${resolution}`,
diff --git a/shared/types.ts b/shared/types.ts
index bdf1311..30941f2 100644
--- a/shared/types.ts
+++ b/shared/types.ts
@@ -125,6 +125,17 @@ export interface Settings {
tutorialCompleted: boolean
stickPosition: StickPosition
stickDisplayId?: number
+ /**
+ * Persisted workArea geometry of the display chosen by the user.
+ * Used as a cross-reboot fuzzy-match fingerprint when the OS re-assigns
+ * numeric display IDs after a restart (Windows behaviour).
+ */
+ stickDisplayWorkArea?: { x: number; y: number; width: number; height: number }
+ /**
+ * DPI scale factor of the chosen display — used as a secondary discriminator
+ * when two displays share identical workArea geometry (e.g. dual same-res).
+ */
+ stickDisplayScaleFactor?: number
/**
* When true, restores the bouncy overshoot panel-open animation.
* Off by default because it requires extra GPU compositing work.
@@ -159,6 +170,8 @@ export const DEFAULT_SETTINGS: Settings = {
tutorialCompleted: false,
stickPosition: 'left',
stickDisplayId: undefined,
+ stickDisplayWorkArea: undefined,
+ stickDisplayScaleFactor: undefined,
bounceAnimation: false,
suppressInFullscreen: true,
showCopyIndicator: true,