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.

fix(perf): reduce fullscreen retract delay to 800ms and tune edge poll/dwell latency for instant open

Deepender25dfbb2be7b185
diff --git a/electron/main/fullscreen.ts b/electron/main/fullscreen.ts
index 2617b25..711c63d 100644
--- a/electron/main/fullscreen.ts
+++ b/electron/main/fullscreen.ts
@@ -96,7 +96,7 @@ export function triggerFullscreenCheck(): void {
* still fires immediately whenever the OS focus changes, so the effective
* detection latency for Alt+Tab scenarios is still ~0ms.
*/
-const FULLSCREEN_CHECK_INTERVAL_MS = 5000
+const FULLSCREEN_CHECK_INTERVAL_MS = 800
export function startFullscreenMonitor(): void {
if (process.platform !== 'win32') return
diff --git a/electron/main/window.ts b/electron/main/window.ts
index d514add..849b20d 100644
--- a/electron/main/window.ts
+++ b/electron/main/window.ts
@@ -123,13 +123,13 @@ export function setPreviewMode(active: boolean): void {
*/
/** Proximity threshold for entering fast-poll mode (px from the edge). */
-const FAST_POLL_PROXIMITY_PX = 100
+const FAST_POLL_PROXIMITY_PX = 250
/** Full-speed poll when edge is near. */
const POLL_FAST_MS = 16
/** Battery-power slow poll (panel closed, cursor far). */
-const POLL_SLOW_BATTERY_MS = 150
+const POLL_SLOW_BATTERY_MS = 60
/** AC-power slow poll (panel closed, cursor far). */
-const POLL_SLOW_AC_MS = 80
+const POLL_SLOW_AC_MS = 35
/** After leaving proximity, stay in fast mode for this long before throttling. */
const SLOW_COOLDOWN_MS = 800
diff --git a/src/hooks/useEdgeHover.ts b/src/hooks/useEdgeHover.ts
index 4bd6c56..c058d97 100644
--- a/src/hooks/useEdgeHover.ts
+++ b/src/hooks/useEdgeHover.ts
@@ -25,7 +25,7 @@ import { edge } from '../lib/edge'
import { useStore } from '../store/appStore'
const TRIGGER_PX = 3 // leftmost px that count as "the edge"
-const DWELL_MS = 120 // cursor must linger this long to open
+const DWELL_MS = 40 // cursor must linger this long to open
const GRACE_MS = 250 // close delay after leaving
const PANEL_WIDE = 270 // blade is 270px (var(--panel-width))
/** Hysteresis thresholds for closing the panel.
diff --git a/tests/power.test.ts b/tests/power.test.ts
index 7afcba6..2f41fb4 100644
--- a/tests/power.test.ts
+++ b/tests/power.test.ts
@@ -1,4 +1,4 @@
-/**
+/**
* Power optimisation test suite.
*
* These tests verify the logic of each power fix without requiring an
@@ -20,10 +20,10 @@ function makeTick(clientX: number, clientY: number, displayWidth = 1920, stickPo
// ──────────────────────────────────────────────────────────────────────────────
describe('Fix 1 — adaptive poll rate constants', () => {
// The constants are embedded in window.ts but we can test the logic in isolation.
- const FAST_POLL_PROXIMITY_PX = 100
+ const FAST_POLL_PROXIMITY_PX = 250
const POLL_FAST_MS = 16
- const POLL_SLOW_BATTERY_MS = 150
- const POLL_SLOW_AC_MS = 80
+ const POLL_SLOW_BATTERY_MS = 60
+ const POLL_SLOW_AC_MS = 35
const SLOW_COOLDOWN_MS = 800
it('POLL_FAST_MS is exactly 16ms (one frame at 60Hz)', () => {
@@ -34,14 +34,14 @@ describe('Fix 1 — adaptive poll rate constants', () => {
expect(POLL_SLOW_BATTERY_MS).toBeGreaterThanOrEqual(POLL_SLOW_AC_MS)
})
- it('POLL_SLOW_BATTERY_MS falls within human reaction time (150–250ms)', () => {
- expect(POLL_SLOW_BATTERY_MS).toBeGreaterThanOrEqual(100)
- expect(POLL_SLOW_BATTERY_MS).toBeLessThanOrEqual(250)
+ it('POLL_SLOW_BATTERY_MS ensures low latency (30–100ms)', () => {
+ expect(POLL_SLOW_BATTERY_MS).toBeGreaterThanOrEqual(30)
+ expect(POLL_SLOW_BATTERY_MS).toBeLessThanOrEqual(100)
})
- it('FAST_POLL_PROXIMITY_PX is a meaningful approach distance (50–200px)', () => {
- expect(FAST_POLL_PROXIMITY_PX).toBeGreaterThanOrEqual(50)
- expect(FAST_POLL_PROXIMITY_PX).toBeLessThanOrEqual(200)
+ it('FAST_POLL_PROXIMITY_PX is a meaningful approach distance (100–400px)', () => {
+ expect(FAST_POLL_PROXIMITY_PX).toBeGreaterThanOrEqual(100)
+ expect(FAST_POLL_PROXIMITY_PX).toBeLessThanOrEqual(400)
})
it('cursor within PROXIMITY triggers fast mode (left panel)', () => {
@@ -72,9 +72,9 @@ describe('Fix 1 — adaptive poll rate constants', () => {
expect(SLOW_COOLDOWN_MS).toBeGreaterThanOrEqual(500)
})
- it('slow poll provides >= 5x improvement over fast poll', () => {
+ it('slow poll provides >= 3x improvement over fast poll', () => {
// Verify that the slow poll is meaningfully slower, not just slightly slower
- expect(POLL_SLOW_BATTERY_MS / POLL_FAST_MS).toBeGreaterThanOrEqual(5)
+ expect(POLL_SLOW_BATTERY_MS / POLL_FAST_MS).toBeGreaterThanOrEqual(3)
})
})