From d231fb3b53020c99f1a2fec52f09c370a69a2984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Tue, 18 Feb 2025 10:53:08 +0200 Subject: [PATCH] Do not attempt to activate windows on wayland using X11 libraries I don't know if something changed in my Ubuntu installation or in the Firefox runtime (probably the former), but that code crashes Zotero on wayland. Window activation (e.g. citation window) does not seem to be affected. --- chrome/content/zotero/xpcom/utilities_internal.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index 042bd14dbe..650c3c8f84 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -2606,6 +2606,14 @@ Zotero.Utilities.Internal.activate = new function () { } return function (win) { + let isWayland = true; + if (Zotero.isLinux) { + try { + let sessionType = Services.env.get('XDG_SESSION_TYPE'); + isWayland = sessionType === 'wayland'; + } + catch (e) {} + } if (Zotero.isMac) { if (win) { Components.utils.import("resource://gre/modules/ctypes.jsm"); @@ -2655,7 +2663,7 @@ Zotero.Utilities.Internal.activate = new function () { Zotero.Utilities.Internal.executeAppleScript(script); } } - else if (Zotero.isLinux && win) { + else if (Zotero.isLinux && !isWayland && win) { Components.utils.import("resource://gre/modules/ctypes.jsm"); if (_x11 === false) return; @@ -2867,7 +2875,7 @@ Zotero.Utilities.Internal.activate = new function () { }, 50); }, false); } - else if (Zotero.isWin && win) { + else if ((Zotero.isWin || Zotero.isLinux) && win) { // Try to focus the window. This is necessary as focusing a node inside // of the window may not necessarily activate the window. win.focus();