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.

add display picker in settings and tray

Khiem Nguyene6dc402daffb
diff --git a/electron/main/ipc.ts b/electron/main/ipc.ts
index 450fb8d..ee56dba 100644
--- a/electron/main/ipc.ts
+++ b/electron/main/ipc.ts
@@ -5,7 +5,7 @@
* renderer calls them through the typed preload bridge, so a signature mismatch
* is a compile-time error rather than a runtime one.
*/
-import { app, ipcMain, clipboard, nativeImage } from 'electron'
+import { app, ipcMain, clipboard, nativeImage, screen } from 'electron'
import { existsSync } from 'node:fs'
import { execFile } from 'node:child_process'
import { psHost } from './powershell'
@@ -437,7 +437,7 @@ export function registerIpc(): void {
if (patch.hotZoneWidth !== undefined) {
setHotZoneWidth(patch.hotZoneWidth)
}
- if (patch.stickPosition !== undefined) {
+ if (patch.stickPosition !== undefined || patch.stickDisplayId !== undefined) {
repositionWindow()
}
pushState.settings(next)
@@ -454,6 +454,21 @@ export function registerIpc(): void {
win.minimize()
}
})
+
+ handle('displays:list', () => {
+ const all = screen.getAllDisplays()
+ const primary = screen.getPrimaryDisplay()
+ return all.map((d) => {
+ const isLeft = d.bounds.x < 0
+ const positionLabel = d.id === primary.id ? 'Primary' : (isLeft ? 'Left' : 'Right')
+ return {
+ id: d.id,
+ bounds: { x: d.bounds.x, y: d.bounds.y, width: d.bounds.width, height: d.bounds.height },
+ isPrimary: d.id === primary.id,
+ label: `Display ${positionLabel} (${d.bounds.width}×${d.bounds.height})`
+ }
+ })
+ })
}
/**
diff --git a/electron/main/tray.ts b/electron/main/tray.ts
index d3a6da9..af38c59 100644
--- a/electron/main/tray.ts
+++ b/electron/main/tray.ts
@@ -6,7 +6,7 @@
* state (checkmarks) is rebuilt every time the menu opens so it always reflects
* current settings.
*/
-import { Menu, Tray, app, nativeImage, Notification } from 'electron'
+import { Menu, Tray, app, nativeImage, Notification, screen } from 'electron'
import { existsSync } from 'node:fs'
import { PATHS } from '../store/paths'
import { loadSettings, saveSettings } from '../store/settings'
@@ -57,6 +57,25 @@ export function createTray(): Tray {
} catch { /* ignore */ }
}
+ function buildDisplaySubmenu(currentId: number | undefined): Electron.MenuItemConstructorOptions[] {
+ const all = screen.getAllDisplays()
+ const primary = screen.getPrimaryDisplay()
+ return all.map((d) => {
+ const isLeft = d.bounds.x < 0
+ const posLabel = d.id === primary.id ? 'Primary' : (isLeft ? 'Left' : 'Right')
+ return {
+ label: `Display ${posLabel} (${d.bounds.width}×${d.bounds.height})`,
+ type: 'radio' as const,
+ checked: currentId === d.id,
+ click: () => {
+ const next = saveSettings({ stickDisplayId: d.id })
+ pushState.settings(next)
+ repositionWindow()
+ }
+ }
+ })
+ }
+
function buildStickSubmenu(current: StickPosition): Electron.MenuItemConstructorOptions[] {
return (['left', 'right', 'top'] as StickPosition[]).map((pos) => ({
label: pos.charAt(0).toUpperCase() + pos.slice(1),
@@ -107,6 +126,10 @@ export function createTray(): Tray {
label: 'Stick to',
submenu: buildStickSubmenu(settings.stickPosition)
},
+ {
+ label: 'Display',
+ submenu: buildDisplaySubmenu(settings.stickDisplayId)
+ },
{ type: 'separator' },
{
label: 'Quit Edge-Drop',
diff --git a/electron/preload/index.ts b/electron/preload/index.ts
index 5f3d40d..f354024 100644
--- a/electron/preload/index.ts
+++ b/electron/preload/index.ts
@@ -105,6 +105,7 @@ const api = {
removeSubitem: (req: import('../../shared/types').DragRequest) => invoke('item:remove-subitem', req),
mergeItems: (sourceId: string, targetId: string) => invoke('item:merge', sourceId, targetId),
splitItem: (req: import('../../shared/types').DragRequest) => invoke('item:split', req),
+ getDisplays: () => invoke('displays:list'),
updateSettings: (patch: Partial<InvokeResult<'settings:update'>>) =>
invoke('settings:update', patch),
setInteractive: (value: boolean) => invoke('window:set-interactive', value),
diff --git a/shared/bridge.ts b/shared/bridge.ts
index 97fbc5d..25802a2 100644
--- a/shared/bridge.ts
+++ b/shared/bridge.ts
@@ -31,6 +31,7 @@ export interface EdgeApi {
updateSettings: (patch: Partial<Settings>) => Promise<Settings>
setInteractive: (value: boolean) => Promise<void>
minimizeWindow: () => Promise<void>
+ getDisplays: () => Promise<import('./types').DisplayInfo[]>
setInternalDrag: (active: boolean) => void
broadcastTutorialStep: (step: number) => void
diff --git a/shared/ipc.ts b/shared/ipc.ts
index 1905181..c6de104 100644
--- a/shared/ipc.ts
+++ b/shared/ipc.ts
@@ -64,6 +64,9 @@ export interface InvokeMap {
/** Check for application updates on GitHub releases. */
'app:check-update': { args: []; result: { latestVersion: string; downloadUrl: string } | null }
+
+ /** Get the list of connected displays. */
+ 'displays:list': { args: []; result: import('./types').DisplayInfo[] }
}
/* ------------------------------------------------------------------ */
diff --git a/shared/types.ts b/shared/types.ts
index f37f548..93dad60 100644
--- a/shared/types.ts
+++ b/shared/types.ts
@@ -63,6 +63,13 @@ export type ItemSection = 'pinned' | 'shelf'
export type StickPosition = 'left' | 'right' | 'top'
+export interface DisplayInfo {
+ id: number
+ bounds: { x: number; y: number; width: number; height: number }
+ isPrimary: boolean
+ label: string
+}
+
/**
* Request to begin a native OS drag-out of one item.
*
diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx
index 93f6b6e..7ae595e 100644
--- a/src/components/Settings.tsx
+++ b/src/components/Settings.tsx
@@ -1,4 +1,6 @@
+import { useEffect, useState } from 'react'
import { useStore } from '../store/appStore'
+import type { DisplayInfo } from '../../shared/types'
import '../styles/settings.css'
export function Settings() {
@@ -7,6 +9,11 @@ export function Settings() {
const updateInfo = useStore((s) => s.updateInfo)
const currentVersion = useStore((s) => s.currentVersion)
+ const [displays, setDisplays] = useState<DisplayInfo[]>([])
+ useEffect(() => {
+ window.edge.getDisplays().then(setDisplays).catch(() => {})
+ }, [])
+
return (
<div className="settings-list">
{updateInfo?.hasUpdate && (
@@ -193,6 +200,28 @@ export function Settings() {
<div className="setting-divider" />
+ {/* Display picker */}
+ <div className="setting-row vertical">
+ <div className="setting-info">
+ <div className="setting-title">Display</div>
+ <div className="setting-desc">Monitor to stick the panel to</div>
+ </div>
+ <div className="setting-pills">
+ {displays.length === 0 && <div className="pill disabled">Loading...</div>}
+ {displays.map((d) => (
+ <button
+ key={d.id}
+ className={`pill ${settings.stickDisplayId === d.id ? 'active' : ''}`}
+ onClick={() => patch({ stickDisplayId: d.id })}
+ >
+ {d.label}
+ </button>
+ ))}
+ </div>
+ </div>
+
+ <div className="setting-divider" />
+
{/* Incognito mode */}
<div className="setting-row">
<div className="setting-info">