From 8628df80f7ef148e09eb1a86249e71c4a98dbe17 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Mon, 2 Nov 2026 22:24:07 +0000 Subject: [PATCH] Fix clicking notifications not focusing the window on GNOME + Wayland --- src/main/ipc.ts | 8 ++------ src/main/main.ts | 18 ++++++++++++++---- src/main/mainWindow.ts | 7 +++++++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 7e1daf98..d382a793 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -28,11 +28,10 @@ import { IpcEvents } from "../shared/IpcEvents"; import { setBadgeCount } from "./appBadge"; import { autoStart } from "./autoStart"; import { enableHardwareAcceleration } from "./main"; -import { mainWin } from "./mainWindow"; +import { focusMainWindow, mainWin } from "./mainWindow"; import { Settings, State } from "./settings"; import { handle, handleSync } from "./utils/ipcWrappers"; import { PopoutWindows } from "./utils/popout"; -import { showWindow } from "./utils/showWindow"; import { isDeckGameMode, showGamePage } from "./utils/steamOS"; import { isValidVencordInstall } from "./utils/vencordLoader"; import { VENCORD_FILES_DIR } from "./vencordFilesDir"; @@ -105,10 +104,7 @@ function getWindow(e: IpcMainInvokeEvent, key?: string) { return key ? PopoutWindows.get(key)! : (BrowserWindow.fromWebContents(e.sender) ?? mainWin); } -handle(IpcEvents.FOCUS, () => { - showWindow(mainWin); - mainWin.setSkipTaskbar(false); -}); +handle(IpcEvents.FOCUS, focusMainWindow); handle(IpcEvents.CLOSE, (e, key?: string) => { getWindow(e, key).close(); diff --git a/src/main/main.ts b/src/main/main.ts index 00edb879..d0261823 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -11,15 +11,15 @@ import "./rpc"; import "./userAssets"; import "./vesktopProtocol"; import { app, BrowserWindow, nativeTheme } from "electron"; +import { readFileSync } from "fs"; -import { DATA_DIR } from "./constants"; +import { DATA_DIR, IS_FLATPAK } from "./constants"; import { createFirstLaunchTour } from "./firstLaunch"; -import { createWindows, mainWin } from "./mainWindow"; +import { createWindows, focusMainWindow, mainWin } from "./mainWindow"; import { registerMediaPermissionsHandler } from "./mediaPermissions"; import { registerScreenShareHandler } from "./screenShare"; import { Settings, State } from "./settings"; import { setAsDefaultProtocolClient } from "./utils/setAsDefaultProtocolClient"; -import { showWindow } from "./utils/showWindow"; import { isDeckGameMode } from "./utils/steamOS"; console.log("Vesktop v" + app.getVersion()); @@ -72,6 +72,16 @@ function init() { // Supposed to be fixed already according to comments there, but it's just not lol, I can repro on Electron 43.0.0 // when moving the window from my main monitor (HDR - not sure if this is relevant lol) to second monitor (SDR) and back disabledFeatures.add("WaylandWpColorManagerV1"); + + // The Flatpak notification portal can't pass activation tokens, so clicking a notification can't focus the window on Wayland. + // Make libnotify talk to org.freedesktop.Notifications directly instead, but only if the sandbox allows it, + // otherwise notifications would be silently dropped + if ( + IS_FLATPAK && + /^org\.freedesktop\.Notifications=(talk|own)$/m.test(readFileSync("/.flatpak-info", "utf-8")) + ) { + process.env.NOTIFY_IGNORE_PORTAL = "1"; + } } disabledFeatures.forEach(feat => enabledFeatures.delete(feat)); @@ -94,7 +104,7 @@ function init() { app.on("second-instance", (_event, _cmdLine, _cwd, data: any) => { if (data.IS_DEV) app.quit(); - else if (mainWin) showWindow(mainWin); + else if (mainWin) focusMainWindow(); }); app.whenReady().then(async () => { diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 1ed870b6..b7d51f23 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -33,6 +33,7 @@ import { createSplashWindow, updateSplashMessage } from "./splash"; import { destroyTray, initTray } from "./tray"; import { clearData } from "./utils/clearData"; import { makeLinksOpenExternally } from "./utils/makeLinksOpenExternally"; +import { showWindow } from "./utils/showWindow"; import { applyDeckKeyboardFix, askToApplySteamLayout, isDeckGameMode } from "./utils/steamOS"; import { downloadVencordFiles, ensureVencordFiles } from "./utils/vencordLoader"; import { VENCORD_FILES_DIR } from "./vencordFilesDir"; @@ -47,6 +48,12 @@ app.on("before-quit", () => { export let mainWin: BrowserWindow; +export function focusMainWindow() { + showWindow(mainWin); + mainWin.setSkipTaskbar(false); + mainWin.focus(); +} + function makeSettingsListenerHelpers(o: SettingsStore) { const listeners = new Map<(data: any) => void, PropertyKey>();