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.
This commit is contained in:
Adomas Venčkauskas 2025-02-18 10:53:08 +02:00
parent e765a4d3af
commit d231fb3b53

View file

@ -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();