Repository navigation
Fix HUD dragging and GPU on Linux X11 #1132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,15 +13,33 @@ function normalizeLinuxWindowSystem(value: string | undefined): "wayland" | "x11 | |
| return null; | ||
| } | ||
|
|
||
| function getForcedLinuxWindowSystem(env: NodeJS.ProcessEnv): "wayland" | "x11" | null { | ||
| function getOzoneSwitchValue(argv: readonly string[], name: string): string | undefined { | ||
| const prefix = `--${name}=`; | ||
| // Chromium uses the last occurrence of a repeated switch. | ||
| for (let i = argv.length - 1; i >= 0; i--) { | ||
| if (argv[i].startsWith(prefix)) { | ||
| return argv[i].slice(prefix.length); | ||
| } | ||
| } | ||
| return undefined; | ||
| } | ||
|
|
||
| function getForcedLinuxWindowSystem( | ||
| env: NodeJS.ProcessEnv, | ||
| argv: readonly string[], | ||
| ): "wayland" | "x11" | null { | ||
| // The --ozone-platform switch picks the backend Chromium actually uses, e.g. | ||
| // XWayland when launched with --ozone-platform=x11 from a Wayland session. | ||
| // ELECTRON_OZONE_PLATFORM_HINT is ignored by Electron 43, so it is not read. | ||
| return ( | ||
| normalizeLinuxWindowSystem(env.OZONE_PLATFORM) ?? | ||
| normalizeLinuxWindowSystem(env.ELECTRON_OZONE_PLATFORM_HINT) | ||
| normalizeLinuxWindowSystem(getOzoneSwitchValue(argv, "ozone-platform")) ?? | ||
| normalizeLinuxWindowSystem(getOzoneSwitchValue(argv, "ozone-platform-hint")) ?? | ||
| normalizeLinuxWindowSystem(env.OZONE_PLATFORM) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the Electron 43 does not use Suggested fix
|
||
| ); | ||
| } | ||
|
|
||
| export function shouldForceLinuxEgl(env: NodeJS.ProcessEnv): boolean { | ||
| const forcedWindowSystem = getForcedLinuxWindowSystem(env); | ||
| export function isLinuxX11Session(env: NodeJS.ProcessEnv, argv: readonly string[] = []): boolean { | ||
| const forcedWindowSystem = getForcedLinuxWindowSystem(env, argv); | ||
|
Comment on lines
+41
to
+42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if (forcedWindowSystem === "wayland") { | ||
| return false; | ||
| } | ||
|
|
@@ -42,7 +60,7 @@ export function shouldForceLinuxEgl(env: NodeJS.ProcessEnv): boolean { | |
|
|
||
| export function getGpuSwitches( | ||
| platform: NodeJS.Platform, | ||
| env: NodeJS.ProcessEnv = process.env, | ||
| _env: NodeJS.ProcessEnv = process.env, | ||
| ): GpuSwitches { | ||
| if (platform === "darwin") { | ||
| return { | ||
|
|
@@ -56,8 +74,9 @@ export function getGpuSwitches( | |
| } | ||
|
|
||
| if (platform === "linux") { | ||
| // Do not force --use-gl=egl on X11: Electron 43 only allows ANGLE, so the | ||
| // GPU process exits and WebGL/WebGPU become unavailable to the editor. | ||
| return { | ||
| useGl: shouldForceLinuxEgl(env) ? "egl" : undefined, | ||
| disableFeatures: ["VaapiVideoDecoder", "VaapiVideoEncoder"], | ||
| }; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore the removed Ozone hint when selecting HUD dragging.
On Electron 43,
--ozone-platform-hint=x11no longer selects X11. If a Wayland user retains that flag, this function reports X11.electron/windows.tsthen selects thesetBounds()drag path, which cannot move the Wayland HUD. Remove this lookup and update the hint test inelectron/gpuSwitches.test.ts. (github.com)