From da8af409ded5921c71f26e1e6bad506b57dd2364 Mon Sep 17 00:00:00 2001 From: Felicitas Pojtinger Date: Tue, 22 Oct 2024 23:06:21 -0700 Subject: [PATCH] feat: Support lauching embedded Chromium instance from within Flatpak on Wayland Signed-off-by: Felicitas Pojtinger --- hydrapp/pkg/ui/browser_launcher.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/hydrapp/pkg/ui/browser_launcher.go b/hydrapp/pkg/ui/browser_launcher.go index 8de4bbae5..435c1c5fa 100644 --- a/hydrapp/pkg/ui/browser_launcher.go +++ b/hydrapp/pkg/ui/browser_launcher.go @@ -285,18 +285,26 @@ func LaunchBrowser( } userDataDir := filepath.Join(userConfigDir, appID) + execArgs := []string{ + "--name=" + appName, + "--class=" + appName, + "--user-data-dir=" + userDataDir, + "--no-first-run", + "--no-default-browser-check", + "--app=" + url, + } + + // If we are on Linux, in a Flatpak sandbox, are running a browser that itself is in the sandbox and + // are on Wayland, enable the Ozone platform abstraction layer for Chromium to support launching Chromium in Wayland + if runtime.GOOS == "linux" && runningInFlatpak && browserIsInSandbox && os.Getenv("XDG_SESSION_TYPE") == "wayland" { + execArgs = append(execArgs, "--ozone-platform-hint=auto") + } + // Create the browser instance execLine := append( browserBinary, append( - []string{ - "--name=" + appName, - "--class=" + appName, - "--user-data-dir=" + userDataDir, - "--no-first-run", - "--no-default-browser-check", - "--app=" + url, - }, + execArgs, os.Args[1:]..., )..., )