Fix clicking notifications not focusing the window on GNOME + Wayland

This commit is contained in:
Nuckyz committed 2026-11-02 22:24:07 +00:00
1 parent 16e0c37441
commit 8628df80f7
3 files changed
+23 -10

No files matched your search

+2 -6
View File
@@ -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();
+14 -4
View File
@@ -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 () => {
+7
View File
@@ -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 extends object>(o: SettingsStore<O>) {
const listeners = new Map<(data: any) => void, PropertyKey>();