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

Bevy wayland window name is "Unknown" #3301

Closed
CrazyRoka opened this issue Dec 11, 2021 · 9 comments · Fixed by #8722
Closed

Bevy wayland window name is "Unknown" #3301

CrazyRoka opened this issue Dec 11, 2021 · 9 comments · Fixed by #8722
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior O-Linux Specific to the Linux desktop operating system

Comments

@CrazyRoka
Copy link
Contributor

Bevy version

Current main branch
25b62f9

Operating system & version

Fedora 35

What you did

cargo run --example 3d_scene --features bevy/wayland

What you expected to happen

Name should be the same as executable. It's correct with feature bevy/x11
image

What actually happened

Application name is "Unknown". Apart from that, title bar is not native and doesn't change after "Set title" is called.
image

Additional information

I updated the code of 3d_scene example to change the title. It's correct in x11, but not in wayland:

    let window = windows.get_primary_mut().expect("Window should be present");
    window.set_title("3D Scene".to_string());

image
image

Suggestion

Do we need to include more examples with set_title? I found only 1 usage in window_settings example.

@CrazyRoka CrazyRoka added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Dec 11, 2021
@DJMcNab
Copy link
Member

DJMcNab commented Dec 11, 2021

This seems like a winit issue, as we're not doing any native handling of this.

@mockersf mockersf added A-Windowing Platform-agnostic interface layer to run your app in O-Linux Specific to the Linux desktop operating system and removed S-Needs-Triage This issue needs to be labelled labels Dec 11, 2021
@heavyrain266
Copy link

Looks like winit doesn't handle window names properly. I believe that it doesn't have proper functionality to setup "appid", I think that this should be handled by bevy at this point. Someone from maintainers could look at anvil/src/winit.rs, and see how they handle window name for Compositor under winit backend.

@DJMcNab
Copy link
Member

DJMcNab commented Dec 11, 2021

I'd be very surprised if we decided it was our job to fix winit not handling a platform properly, although I might be missing some context here. I'd certainly be inclined to push back against any PR which added a fix which linked into platform specific code in this codebase.

Winit supports setting the window title - https://docs.rs/winit/0.26.0/winit/window/struct.Window.html#method.set_title, and doesn't list wayland as unsupported there.

I had a quick look at winit's issue tracker, and it doesn't seem like this is tracked, although @heavyrain266 it seems like you have more knowledge of how wayland works to report it.

@cart
Copy link
Member

cart commented Dec 11, 2021

This is almost certainly because Wayland requires CSDs (client side decorations). Winit literally chooses how / where to draw the window decorations, and probably doesn't have code written (or enabled) to render a title.

@cart
Copy link
Member

cart commented Dec 11, 2021

One solution is to depend on a library that can render the decorations (like GTK3) but I appreciate that winit doesn't depend on that. Maybe ultimately we should just draw our own 😄

@bjorn3
Copy link
Contributor

bjorn3 commented Dec 12, 2021

This is almost certainly because Wayland requires CSDs (client side decorations).

Wayland requires the client to support CSD. There is an extension for server side decorations implemented by (pretty much) everyone except gnome as they really want client side decorations only for some reason despite people complaining.

@heavyrain266
Copy link

heavyrain266 commented Dec 12, 2021

One solution is to depend on a library that can render the decorations (like GTK3) but I appreciate that winit doesn't depend on that. Maybe ultimately we should just draw our own 😄

For Wayland there is protocol for creating surfaces (there is native rust implementation), it's called xdg-shell which Compositors as renderers connected to headless Display Servers are using for compositing surfaces (images) into window. There is also second protocol called fullscreen-shell which handle fullscreen surfaces.

EDIT: Linked protocols and added info about handling fullscreen.

@heavyrain266
Copy link

This is almost certainly because Wayland requires CSDs (client side decorations).

Wayland requires the client to support CSD. There is an extension for server side decorations implemented by (pretty much) everyone except gnome as they really want client side decorations only for some reason despite people complaining.

GNOME is most problematic Wayland DE to support, they don't follow any existing standards used by almost every software/server author, many programs which are adding HUDs and Overlays for Wayland doesn't work in GNOME because they don't want to support popular Layershell protocol which adds z-index to renderer as "layers" where author choose layer to render his software i.e on top of everything or most bottom layer for wallpaper image/gif/shader.

@VitalyAnkh
Copy link
Contributor

Investigation

  1. Gnome forced Wayland apps to implement CSD, whether on their own or using some libraries like Gnome's official solution libdecor. Many Linux apps do this with libdecor, like blender, kitty... I think it's not comfortable for Bevy to fix this problem this way.
  2. Winit has support for CSD on wayland(https://github.com/rust-windowing/winit/blob/8bb004a1d9ec1b40cbb9831a6dea774d4b6d6d7b/Cargo.toml#L42), but Bevy disabled Winit's default features, thus no winit's wayland-csd-adwaita feature. And Bevy's wayland feature doesn't include winit's wayland-csd-adwaita feature so users can't get window decorations on Wayland even with Bevy's wayland feature enabled.
  3. Many rust UI toolkit, like iced, doesn't disable winit's wayland-csd-adwaita feature.

Conclusion and one Possible solution

Bevy disabled winit's default features in order to decrease package size. But I think it's acceptable to add winit's wayland-csd-adwaita feature to Bevy's wayland feature gate to fix this issue easily for this only add on crate: sctk-adwaita.

Subserial pushed a commit to Subserial/bevy_winit_hook that referenced this issue Jan 24, 2024
… (#8722)

# Objective

- Fix Wayland window client side decorations issue on Gnome Wayland,
fixes #3301.

## Solution

- One simple one line solution: Add winit's `wayland-csd-adwaita`
feature to Bevy's `wayland` feature.

Copied from
bevyengine/bevy#3301 (comment):
### Investigation
1. Gnome forced Wayland apps to implement CSD, whether on their own or
using some libraries like Gnome's official solution
[libdecor](https://gitlab.freedesktop.org/libdecor/libdecor). Many Linux
apps do this with libdecor, like blender, kitty... I think it's not
comfortable for Bevy to fix this problem this way.
2. Winit has support for CSD on
wayland(https://github.com/rust-windowing/winit/blob/8bb004a1d9ec1b40cbb9831a6dea774d4b6d6d7b/Cargo.toml#L42),
but Bevy disabled Winit's default features, thus no winit's
`wayland-csd-adwaita` feature. And Bevy's `wayland` feature doesn't
include winit's `wayland-csd-adwaita` feature so users can't get window
decorations on Wayland even with Bevy's `wayland` feature enabled.
3. Many rust UI toolkit, like iced, doesn't disable winit's
`wayland-csd-adwaita` feature.
### Conclusion and one Possible solution

Bevy disabled `winit`'s default features in order to decrease package
size. But I think it's acceptable to add `winit`'s `wayland-csd-adwaita`
feature to Bevy's `wayland` feature gate to fix this issue easily for
this only add on crate: sctk-adwaita.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior O-Linux Specific to the Linux desktop operating system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants