fix: add support for ELECTRON_OZONE_PLATFORM_HINT env var (#39792)
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
parent
6a8b70639b
commit
58fd8825d2
2 changed files with 18 additions and 2 deletions
|
@ -111,6 +111,16 @@ Options:
|
||||||
* `kioclient5`
|
* `kioclient5`
|
||||||
* `kioclient`
|
* `kioclient`
|
||||||
|
|
||||||
|
### `ELECTRON_OZONE_PLATFORM_HINT` _Linux_
|
||||||
|
|
||||||
|
Selects the preferred platform backend used on Linux. The default one is `x11`. `auto` selects Wayland if possible, X11 otherwise.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
* `auto`
|
||||||
|
* `wayland`
|
||||||
|
* `x11`
|
||||||
|
|
||||||
## Development Variables
|
## Development Variables
|
||||||
|
|
||||||
The following environment variables are intended primarily for development and
|
The following environment variables are intended primarily for development and
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
#include "shell/common/thread_restrictions.h"
|
#include "shell/common/thread_restrictions.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
constexpr base::StringPiece kElectronOzonePlatformHint(
|
||||||
|
"ELECTRON_OZONE_PLATFORM_HINT");
|
||||||
|
|
||||||
#if BUILDFLAG(OZONE_PLATFORM_WAYLAND)
|
#if BUILDFLAG(OZONE_PLATFORM_WAYLAND)
|
||||||
|
|
||||||
constexpr char kPlatformWayland[] = "wayland";
|
constexpr char kPlatformWayland[] = "wayland";
|
||||||
|
@ -115,17 +118,20 @@ std::string MaybeFixPlatformName(const std::string& ozone_platform_hint) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void ElectronBrowserMainParts::DetectOzonePlatform() {
|
void ElectronBrowserMainParts::DetectOzonePlatform() {
|
||||||
|
auto const env = base::Environment::Create();
|
||||||
auto* const command_line = base::CommandLine::ForCurrentProcess();
|
auto* const command_line = base::CommandLine::ForCurrentProcess();
|
||||||
if (!command_line->HasSwitch(switches::kOzonePlatform)) {
|
if (!command_line->HasSwitch(switches::kOzonePlatform)) {
|
||||||
const auto ozone_platform_hint =
|
auto ozone_platform_hint =
|
||||||
command_line->GetSwitchValueASCII(switches::kOzonePlatformHint);
|
command_line->GetSwitchValueASCII(switches::kOzonePlatformHint);
|
||||||
|
if (ozone_platform_hint.empty()) {
|
||||||
|
env->GetVar(kElectronOzonePlatformHint, &ozone_platform_hint);
|
||||||
|
}
|
||||||
if (!ozone_platform_hint.empty()) {
|
if (!ozone_platform_hint.empty()) {
|
||||||
command_line->AppendSwitchASCII(
|
command_line->AppendSwitchASCII(
|
||||||
switches::kOzonePlatform, MaybeFixPlatformName(ozone_platform_hint));
|
switches::kOzonePlatform, MaybeFixPlatformName(ozone_platform_hint));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto env = base::Environment::Create();
|
|
||||||
std::string desktop_startup_id;
|
std::string desktop_startup_id;
|
||||||
if (env->GetVar("DESKTOP_STARTUP_ID", &desktop_startup_id))
|
if (env->GetVar("DESKTOP_STARTUP_ID", &desktop_startup_id))
|
||||||
command_line->AppendSwitchASCII("desktop-startup-id", desktop_startup_id);
|
command_line->AppendSwitchASCII("desktop-startup-id", desktop_startup_id);
|
||||||
|
|
Loading…
Reference in a new issue