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(window): restore focusable: false default to prevent focus loss on paste

Deepender257af704a0cae1
diff --git a/electron/main/ipc.ts b/electron/main/ipc.ts
index 079c524..130489b 100644
--- a/electron/main/ipc.ts
+++ b/electron/main/ipc.ts
@@ -13,7 +13,7 @@ import { psHost, getSystemPowerShellPath } from './powershell'
import { filterValidPaths, isValidFilePath, isExistingFilePath } from './pathValidation'
import { type InvokeMap, type InvokeChannel, type SendMap, type SendChannel } from '../../shared/ipc'
import { getStore, loadSettings, saveSettings, pushState, addFiles, getWatcher } from './state'
-import { sendToMainWindow, setInteractive, setHeartbeatPaused, setHotZoneWidth, repositionWindow, getDisplayListOptions, popUpAndRetract, focusMainWindow } from './window'
+import { sendToMainWindow, setInteractive, setHeartbeatPaused, setHotZoneWidth, repositionWindow, getDisplayListOptions, popUpAndRetract, setWindowFocusable } from './window'
import { registerGlobalHotkey } from './index'
import { getOnboardingWindow } from './onboardingWindow'
import { rebuildTrayMenu } from './tray'
@@ -631,8 +631,8 @@ export function registerIpc(): void {
}
})
- handle('window:focus', () => {
- focusMainWindow()
+ handle('window:focus', (focusable) => {
+ setWindowFocusable(focusable ?? true)
})
handle('displays:list', () => {
diff --git a/electron/main/window.ts b/electron/main/window.ts
index 8b7637c..193f46e 100644
--- a/electron/main/window.ts
+++ b/electron/main/window.ts
@@ -454,7 +454,6 @@ export function createWindow(): BrowserWindow {
const { x, y, height } = getStickGeometry()
mainWindow = new BrowserWindow({
- type: 'toolbar',
icon: PATHS.icon(),
x,
y,
@@ -472,7 +471,7 @@ export function createWindow(): BrowserWindow {
hasShadow: false,
skipTaskbar: true,
alwaysOnTop: true,
- focusable: true,
+ focusable: false,
backgroundColor: '#00000000',
roundedCorners: false,
webPreferences: {
@@ -767,12 +766,21 @@ export function setVisible(visible: boolean): void {
}
}
-export function focusMainWindow(): void {
+export function setWindowFocusable(focusable: boolean): void {
if (mainWindow && !mainWindow.isDestroyed()) {
- mainWindow.focus()
+ try {
+ mainWindow.setFocusable(focusable)
+ if (focusable) {
+ mainWindow.focus()
+ }
+ } catch {}
}
}
+export function focusMainWindow(): void {
+ setWindowFocusable(true)
+}
+
/**
* Thin invisible detector window.
*
diff --git a/electron/preload/index.ts b/electron/preload/index.ts
index 5eba15d..9ca81e8 100644
--- a/electron/preload/index.ts
+++ b/electron/preload/index.ts
@@ -167,7 +167,7 @@ const api = {
pauseHotkey: (paused: boolean) => invoke('hotkey:pause', paused),
revealFile: (path: string) => invoke('file:reveal', path),
minimizeWindow: () => invoke('window:minimize'),
- focusWindow: () => invoke('window:focus'),
+ focusWindow: (focusable?: boolean) => invoke('window:focus', focusable),
setInternalDrag: (active: boolean) => { internalDrag = active },
broadcastTutorialStep: (step: number) => send('tutorial:set-step', step),
diff --git a/shared/bridge.ts b/shared/bridge.ts
index b2b0d1b..a08f3b3 100644
--- a/shared/bridge.ts
+++ b/shared/bridge.ts
@@ -40,7 +40,7 @@ export interface EdgeApi {
pauseHotkey: (paused: boolean) => Promise<void>
revealFile: (path: string) => Promise<boolean>
minimizeWindow: () => Promise<void>
- focusWindow: () => Promise<void>
+ focusWindow: (focusable?: boolean) => Promise<void>
getDisplays: () => Promise<import('./types').DisplayInfo[]>
getReleases: () => Promise<Array<{
version: string
diff --git a/shared/ipc.ts b/shared/ipc.ts
index 48b3000..632b051 100644
--- a/shared/ipc.ts
+++ b/shared/ipc.ts
@@ -78,7 +78,7 @@ export interface InvokeMap {
'window:minimize': { args: []; result: void }
/** Request explicit OS focus for the main window (e.g. for recording hotkeys). */
- 'window:focus': { args: []; result: void }
+ 'window:focus': { args: [focusable?: boolean]; result: void }
/** Trigger a download of the already-available update and quit-and-install. */
'app:install-update': { args: []; result: void }
diff --git a/src/components/HotkeyRecorder.tsx b/src/components/HotkeyRecorder.tsx
index ac2312f..b39ed4d 100644
--- a/src/components/HotkeyRecorder.tsx
+++ b/src/components/HotkeyRecorder.tsx
@@ -97,6 +97,11 @@ export function HotkeyRecorder({ hotkey, onChange }: HotkeyRecorderProps) {
const stopRecording = useCallback((canceled = false) => {
setIsRecording(false)
setPressedBadges([])
+ try {
+ edge.focusWindow(false).catch?.(() => {})
+ } catch {
+ /* ignore */
+ }
try {
edge.pauseHotkey(false).catch?.(() => {})
} catch {
@@ -114,7 +119,7 @@ export function HotkeyRecorder({ hotkey, onChange }: HotkeyRecorderProps) {
try {
window.focus()
- edge.focusWindow().catch?.(() => {})
+ edge.focusWindow(true).catch?.(() => {})
} catch {
/* ignore */
}
diff --git a/tests/taskbar.test.ts b/tests/taskbar.test.ts
index 164bb71..8313519 100644
--- a/tests/taskbar.test.ts
+++ b/tests/taskbar.test.ts
@@ -10,17 +10,16 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
describe('Taskbar & Explorer Recovery — Window Options', () => {
- it('specifies type: "toolbar" to assign WS_EX_TOOLWINDOW extended style on Windows', () => {
- // Win32 WS_EX_TOOLWINDOW excludes the window from taskbar and Alt+Tab switcher
+ it('configures skipTaskbar: true without type: "toolbar" to ensure OS focus returns cleanly to the target text box during paste', () => {
+ // Standard window with skipTaskbar: true preserves the Win32 foreground focus restoration chain,
+ // ensuring SendKeys('^v') pastes directly into the previous active text box when the panel closes.
const windowOptions = {
- type: 'toolbar' as const,
skipTaskbar: true,
alwaysOnTop: true,
frame: false,
transparent: true
}
- expect(windowOptions.type).toBe('toolbar')
expect(windowOptions.skipTaskbar).toBe(true)
expect(windowOptions.alwaysOnTop).toBe(true)
expect(windowOptions.frame).toBe(false)