Skip to content
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

Feature: add optional Wayland support #471

Open
thatLeaflet opened this issue Nov 24, 2023 · 8 comments
Open

Feature: add optional Wayland support #471

thatLeaflet opened this issue Nov 24, 2023 · 8 comments

Comments

@thatLeaflet
Copy link

Currently, if I want to run VSCode in native Wayland mode, I need to either (1) launch from the terminal and pass ozone flags or (2) modify the desktop file and add those flags. Neither method is particularly good.

I propose that this this VSCode flatpak should follow in the steps of the Discord flatpak and add an optional native Wayland mode. With the Discord flatpak, it by default only comes with X11 access. But if you grant it Wayland access, it will automatically launch in native Wayland mode.

@ghost
Copy link

ghost commented Nov 25, 2023

you can use flatpak override --env=<variable> <app name> to do that

@thatLeaflet
Copy link
Author

I don't think there is any environmental variable to make chromium based stuff to use Wayland (unlike Firefox which has MOZ_ENABLE_WAYLAND=1).

As far as I'm aware, the only options for Chromium are inside the program (menu isn't available in VSCode), through a config file (which VSCode doesn't read without a patch), or from the command line.

@westurner
Copy link

This seems to fix the blurry fonts with Wayland instead of X:

flatpak --socket=wayland run com.visualstudio.code --enable-features=UseOzonePlatform --ozone-platform=wayland

@westurner
Copy link

Here's my .desktop file, which supersedes the system com.visualstudio.code.desktop; note the --enable-features=UseOzonePlatform --ozone-platform=wayland added to both Exec=s.

$ cat ~/.local/share/applications/com.visualstudio.code.desktop 
[Desktop Entry]
Name=Visual Studio Code
Comment=Code Editing. Redefined.
GenericName=Text Editor
Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=code --file-forwarding --socket=wayland com.visualstudio.code --enable-features=UseOzonePlatform --ozone-platform=wayland --reuse-window @@ %F @@
Icon=com.visualstudio.code
Type=Application
StartupNotify=true
StartupWMClass=Code
Categories=TextEditor;Development;IDE;
MimeType=text/plain;inode/directory;application/x-code-workspace;
Actions=new-empty-window;
Keywords=vscode;
X-Flatpak-Tags=proprietary;
X-Flatpak=com.visualstudio.code

[Desktop Action new-empty-window]
Name=New Empty Window
Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=code --file-forwarding --socket=wayland com.visualstudio.code --enable-features=UseOzonePlatform --ozone-platform=wayland --new-window @@ %F @@
Icon=com.visualstudio.code

@akvadrako
Copy link

You can set the environmental variable ELECTRON_OZONE_PLATFORM_HINT=auto and enable the wayland socket, and VSCode will use wayland.

@tazihad
Copy link

tazihad commented Jul 7, 2024

thanks. this worked for me.

flatpak override --user --socket=wayland --socket=fallback-x11  --env=ELECTRON_OZONE_PLATFORM_HINT=auto com.visualstudio.code

extra for kde: fix generic wayland icon in kde
Open vscode flatpak -> add new kwin rule with Alt+F3 -> More Actions -> Configure Special Application Settings -> Add Property -> Desktop file name -> There fill desktop file name without extension (com.visualstudio.code)

@chdalski
Copy link

I stumbled over that issue and was digging a little bit... From what I understood so far as of now it should be possible to natively support Wayland without any user interaction with the following changes:

Automatically set the platform hint on when launching from a Wayland session:

# Proposed change to 'code.sh'

WL_DISPLAY="${WAYLAND_DISPLAY:-"wayland-0"}"
if [[ -e "${XDG_RUNTIME_DIR}/${WL_DISPLAY}" || -e "/${WL_DISPLAY}" ]]; then
    echo "Debug: Enabling Wayland backend"
    EXTRA_ARGS+=(
        --ozone-platform-hint=auto
    )
fi

Change the yaml file according to the documention (search for work on both X11 and Wayland sessions)

# proposed change to 'com.visualstudio.code.yaml'

# replace line 14 '  - --socket=x11' with:
  - --socket=fallback-x11
  - --socket=wayland

That said I'm not into building flatpak nor electron apps and I currently use the following changes to manually enforce that behavior for all apps...
Flatpak change:
File ~/.local/share/flatpak/overrides/global (this overrides the flatpak settings for my apps... instead of global that file could be com.visualstudio.code)

[Context]
sockets=wayland;

Electron change:
File ~/.config/environment.d/envvars.conf (this configures the environment variables for systemd - which handles the wayland session)

ELECTRON_OZONE_PLATFORM_HINT=auto

This also allows to start the application the "Wayland way" if started from the console or the application menu.

I hope this helps somehow.

@francoism90
Copy link

francoism90 commented Oct 11, 2024

@chdalski This issue has been addressed for years, but the maintainers of this repo, don't want to merge them.

You can see the PRs that improve the Wayland situation are just sitting there doing nothing. It bugs me everytime, I need to manually overrule things, which could work fine for both X11 & Wayland users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants