fix: position window titlebar buttons correctly in Ubuntu on Wayland (#48602)

fix: position window titlebar buttons correctly in Ubuntu on Wayland (#48490)

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Mitchell Cohen <mitch.cohen@me.com>
This commit is contained in:
trop[bot] 2025-10-21 15:26:57 +02:00 committed by GitHub
commit 5e29e21a60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 43 deletions

View file

@ -186,14 +186,3 @@ the one downloaded by `npm install`. Usage:
```sh
export ELECTRON_OVERRIDE_DIST_PATH=/Users/username/projects/electron/out/Testing
```
## Set By Electron
Electron sets some variables in your environment at runtime.
### `ORIGINAL_XDG_CURRENT_DESKTOP`
This variable is set to the value of `XDG_CURRENT_DESKTOP` that your application
originally launched with. Electron sometimes modifies the value of `XDG_CURRENT_DESKTOP`
to affect other logic within Chromium so if you want access to the _original_ value
you should look up this environment variable instead.

View file

@ -16,9 +16,15 @@ This document uses the following convention to categorize breaking changes:
### Removed: `ELECTRON_OZONE_PLATFORM_HINT` environment variable
The default value of the `--ozone-plaftform` flag [changed to `auto`](https://chromium-review.googlesource.com/c/chromium/src/+/6775426).
The default value of the `--ozone-platform` flag [changed to `auto`](https://chromium-review.googlesource.com/c/chromium/src/+/6775426).
You should use the `XDG_SESSION_TYPE=wayland` environment variable instead to use Wayland.
Electron now defaults to running as a native Wayland app when launched in a Wayland session (when `XDG_SESSION_TYPE=wayland`).
Users can force XWayland by passing `--ozone-platform=x11`.
### Removed: `ORIGINAL_XDG_CURRENT_DESKTOP` environment variable
Previously, Electron changed the value of `XDG_CURRENT_DESKTOP` internally to `Unity`, and stored the original name of the desktop session
in a separate variable. `XDG_CURRENT_DESKTOP` is no longer overriden and now reflects the actual desktop environment.
### Removed: macOS 11 support

View file

@ -162,27 +162,6 @@ require('@electron/internal/browser/api/web-contents-view');
// Set main startup script of the app.
const mainStartupScript = packageJson.main || 'index.js';
const KNOWN_XDG_DESKTOP_VALUES = new Set(['Pantheon', 'Unity:Unity7', 'pop:GNOME']);
function currentPlatformSupportsAppIndicator () {
if (process.platform !== 'linux') return false;
const currentDesktop = process.env.XDG_CURRENT_DESKTOP;
if (!currentDesktop) return false;
if (KNOWN_XDG_DESKTOP_VALUES.has(currentDesktop)) return true;
// ubuntu based or derived session (default ubuntu one, communitheme…) supports
// indicator too.
if (/ubuntu/ig.test(currentDesktop)) return true;
return false;
}
// Workaround for electron/electron#5050 and electron/electron#9046
process.env.ORIGINAL_XDG_CURRENT_DESKTOP = process.env.XDG_CURRENT_DESKTOP;
if (currentPlatformSupportsAppIndicator()) {
process.env.XDG_CURRENT_DESKTOP = 'Unity';
}
// Quit when all windows are closed and no other one is listening to this.
app.on('window-all-closed', () => {
if (app.listenerCount('window-all-closed') === 1) {

View file

@ -15,7 +15,6 @@
#include "base/cancelable_callback.h"
#include "base/containers/contains.h"
#include "base/containers/map_util.h"
#include "base/environment.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
@ -59,8 +58,6 @@ const char kFreedesktopPortalName[] = "org.freedesktop.portal.Desktop";
const char kFreedesktopPortalPath[] = "/org/freedesktop/portal/desktop";
const char kFreedesktopPortalOpenURI[] = "org.freedesktop.portal.OpenURI";
const char kOriginalXdgCurrentDesktopEnvVar[] = "ORIGINAL_XDG_CURRENT_DESKTOP";
const char kMethodOpenDirectory[] = "OpenDirectory";
class ShowItemHelper {
@ -279,12 +276,6 @@ bool XDGUtil(const std::vector<std::string>& argv,
base::nix::CreateLaunchOptionsWithXdgActivation(base::BindOnce(
[](base::RepeatingClosure quit_loop, base::LaunchOptions* options_out,
base::LaunchOptions options) {
// Correct the XDG_CURRENT_DESKTOP environment variable before calling
// XDG, in case it was changed for compatibility.
if (const auto* orig = base::FindOrNull(
options.environment, kOriginalXdgCurrentDesktopEnvVar))
options.environment.emplace(base::nix::kXdgCurrentDesktopEnvVar,
*orig);
*options_out = std::move(options);
std::move(quit_loop).Run();
},