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(fullscreen): automatic game & presentation edge hover suppression

Deepender25b95576e77c29
diff --git a/electron/main/fullscreen.ts b/electron/main/fullscreen.ts
new file mode 100644
index 0000000..403c51a
--- /dev/null
+++ b/electron/main/fullscreen.ts
@@ -0,0 +1,88 @@
+/**
+ * Fullscreen Game & Presentation Detection Module.
+ *
+ * Detects when a Direct3D fullscreen game, full-screen video, or presentation
+ * is active in the foreground using Windows API `SHQueryUserNotificationState`.
+ *
+ * Queries in the background every 2 seconds so edge hover polling (`startCursorPoll`)
+ * reads a cached boolean with 0ms performance overhead.
+ */
+import { execFile } from 'node:child_process'
+import { getSystemPowerShellPath } from './powershell'
+
+let isFullscreenActiveCache = false
+let checkTimer: ReturnType<typeof setInterval> | null = null
+let isChecking = false
+let onFullscreenDetectedFn: (() => void) | null = null
+
+export function registerFullscreenActiveListener(fn: () => void): void {
+ onFullscreenDetectedFn = fn
+}
+
+const psScript = `
+$code = @"
+using System;
+using System.Runtime.InteropServices;
+public class WinAPI {
+ [DllImport("shell32.dll")]
+ public static extern int SHQueryUserNotificationState(out int pstate);
+ public static int Check() {
+ int state = 5;
+ try { SHQueryUserNotificationState(out state); } catch {}
+ return state;
+ }
+}
+"@
+Add-Type -TypeDefinition $code -ErrorAction SilentlyContinue
+[WinAPI]::Check()
+`.trim()
+
+export function isFullscreenAppActive(): boolean {
+ return isFullscreenActiveCache
+}
+
+export function triggerFullscreenCheck(): void {
+ if (process.platform !== 'win32' || isChecking) return
+ isChecking = true
+ try {
+ execFile(
+ getSystemPowerShellPath(),
+ ['-NoProfile', '-NonInteractive', '-Command', psScript],
+ { windowsHide: true },
+ (error, stdout) => {
+ isChecking = false
+ if (!error && stdout) {
+ const state = parseInt(stdout.trim(), 10)
+ // Windows Notification States:
+ // 2 = QUNS_BUSY (Fullscreen app / presentation mode)
+ // 3 = QUNS_RUNNING_D3D_FULL_SCREEN (Direct3D Fullscreen Game)
+ // 4 = QUNS_PRESENTATION_MODE (PowerPoint / Keynote Presentation)
+ // 5 = QUNS_ACCEPTS_NOTIFICATIONS (Normal Desktop)
+ const isNowFullscreen = !isNaN(state) && state >= 2 && state <= 4
+ isFullscreenActiveCache = isNowFullscreen
+ if (isNowFullscreen) {
+ onFullscreenDetectedFn?.()
+ }
+ }
+ }
+ )
+ } catch {
+ isChecking = false
+ }
+}
+
+export function startFullscreenMonitor(): void {
+ if (process.platform !== 'win32') return
+ if (checkTimer !== null) return
+
+ triggerFullscreenCheck()
+ checkTimer = setInterval(triggerFullscreenCheck, 1000)
+}
+
+export function stopFullscreenMonitor(): void {
+ if (checkTimer !== null) {
+ clearInterval(checkTimer)
+ checkTimer = null
+ }
+ isFullscreenActiveCache = false
+}
diff --git a/electron/main/index.ts b/electron/main/index.ts
index e7e9b6c..42419c6 100644
--- a/electron/main/index.ts
+++ b/electron/main/index.ts
@@ -17,6 +17,7 @@ import { registerIpc, registerSendListeners } from './ipc'
import { prewarmDragIcons } from './drag'
import { initState, getWatcher, loadSettings, pushState, stopStateTimers } from './state'
import { createOnboardingWindow } from './onboardingWindow'
+import { startFullscreenMonitor, stopFullscreenMonitor, triggerFullscreenCheck } from './fullscreen'
import { join, resolve } from 'node:path'
import { existsSync, createReadStream } from 'node:fs'
import { createHash } from 'node:crypto'
@@ -40,6 +41,9 @@ if (!gotLock) {
setVisible(true)
getMainWindow()?.focus()
})
+ app.on('browser-window-blur', () => {
+ triggerFullscreenCheck()
+ })
}
// ---- before ready: register privileged protocol ----------------------------
@@ -58,6 +62,7 @@ app.on('before-quit', () => {
stopCursorPoll()
stopHeartbeat()
stopStateTimers()
+ stopFullscreenMonitor()
getWatcher().stop()
try {
const { globalShortcut } = require('electron')
@@ -81,6 +86,7 @@ app.whenReady().then(() => {
createWindow()
startCursorPoll()
+ startFullscreenMonitor()
createTray()
// Register Alt+C global shortcut to toggle panel
diff --git a/electron/main/window.ts b/electron/main/window.ts
index dd43d30..6885eb4 100644
--- a/electron/main/window.ts
+++ b/electron/main/window.ts
@@ -30,6 +30,7 @@ import { runtime } from './config'
import { PATHS } from '../store/paths'
import { computeStickBounds } from './geometry'
import { loadSettings, saveSettings } from '../store/settings'
+import { isFullscreenAppActive, registerFullscreenActiveListener } from './fullscreen'
export const PANEL_WIDTH = 384
/** Visual width of the blade when collapsed (only used by the renderer). */
@@ -136,6 +137,8 @@ export function startCursorPoll(): void {
if (runtime.quitting || !mainWindow || mainWindow.isDestroyed() || !mainWindow.isVisible()) return
const settings = loadSettings()
+ if (settings.suppressInFullscreen && isFullscreenAppActive()) return
+
const pt = screen.getCursorScreenPoint()
// Find the stick display (or fallback to primary)
@@ -269,6 +272,16 @@ export function createWindow(): BrowserWindow {
// Start click-through with no forwarding — edge detection is done via cursor poll.
mainWindow.setIgnoreMouseEvents(true, { forward: false })
+ registerFullscreenActiveListener(() => {
+ const settings = loadSettings()
+ if (settings.suppressInFullscreen) {
+ if (mainWindow && !mainWindow.isDestroyed() && !mainWindow.webContents.isDestroyed()) {
+ mainWindow.webContents.send('window:toggle', false)
+ }
+ setInteractive(false)
+ }
+ })
+
const handleDisplayChange = (triggerPopUp = false) => {
console.log('[Main] Display metrics/topology changed — validating bounds and repositioning window')
repositionWindow()
diff --git a/shared/types.ts b/shared/types.ts
index 3bb5fd4..3d9c1f4 100644
--- a/shared/types.ts
+++ b/shared/types.ts
@@ -133,6 +133,11 @@ export interface Settings {
* Off by default because filter: blur is resource-heavy.
*/
blurAnimation: boolean
+ /**
+ * When true, automatically suppresses edge hover when a fullscreen game or app is active.
+ * On by default to prevent accidental opening during PC gameplay.
+ */
+ suppressInFullscreen: boolean
}
export const DEFAULT_SETTINGS: Settings = {
@@ -150,7 +155,8 @@ export const DEFAULT_SETTINGS: Settings = {
stickPosition: 'left',
stickDisplayId: undefined,
bounceAnimation: false,
- blurAnimation: false
+ blurAnimation: false,
+ suppressInFullscreen: true
}
diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx
index 59b34c3..69e33a1 100644
--- a/src/components/Settings.tsx
+++ b/src/components/Settings.tsx
@@ -64,6 +64,19 @@ export function Settings() {
<div className="setting-divider" />
+ <div className="setting-row">
+ <div className="setting-info">
+ <div className="setting-title">Fullscreen Protection</div>
+ <div className="setting-desc">Automatically pause edge hover while playing games or watching fullscreen videos</div>
+ </div>
+ <Toggle
+ checked={settings.suppressInFullscreen}
+ onChange={(v) => patch({ suppressInFullscreen: v })}
+ />
+ </div>
+
+ <div className="setting-divider" />
+
<div className="setting-row">
<div className="setting-info">
<div className="setting-title">Clear unpinned on restart</div>