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

Expose .with_class() in WindowDescriptor after new winit release to allow setting window class on X11 and app_id on Wayland. #4188

Closed
heavyrain266 opened this issue Mar 11, 2022 · 6 comments · Fixed by #7650
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Feature A new feature, making something new possible O-Linux Specific to the Linux desktop operating system

Comments

@heavyrain266
Copy link

heavyrain266 commented Mar 11, 2022

What problem does this solve or what need does it fill?

Field .with_app_id() is used to set App's ID to be accessed by Compositor to e.g. set specific rules for given window or group of windows under same id, for example enabling/disabling server-side opacity, disabling CSD, hardcoding tag/workspace on startup, setting position etc.

What solution would you like?

use bevy::prelude::*;

fn main() {
    App::new()
        .insert_resource(
            WindowDescriptor {
                title: "Game Title".into(),
                // Value should be not have spaces, can be e.g. org.bevy.gameTitle (like in GTK) or anything else.
                app_id: "game_title".into(),
            
               ..Default::default()
            }
        )
        .run();
}

What alternative(s) have you considered?

None.

Additional context

For now, every bevy game have app_id exposed as <NULL>, there are programs like lswt or waylevel for querying info about connected clients and their app_id, programs like that may not work under KDE/GNOME if they don't implement protocols which allow clients to query such info from Compositor.

@heavyrain266 heavyrain266 added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Mar 11, 2022
@mockersf
Copy link
Member

relevant winit api: https://docs.rs/winit/latest/winit/window/struct.WindowBuilder.html#method.with_app_id. This should be feature gated on wayland

@alice-i-cecile alice-i-cecile added O-Linux Specific to the Linux desktop operating system O-Windows Specific to the Windows desktop operating system A-Windowing Platform-agnostic interface layer to run your app in and removed S-Needs-Triage This issue needs to be labelled O-Windows Specific to the Windows desktop operating system labels Mar 12, 2022
@bjorn3
Copy link
Contributor

bjorn3 commented Mar 12, 2022

Why should it be feature gated on wayland? It would be much easier to allow it on all platforms and just pass it to winit on unix. In addition while winit currently only uses it on wayland, other OSes do have a similar concept. For example macOS has the bundle id. And gtk has an application id that is used for wayland and for remote control using dbus. In addition things like the RegisterClient method of the org.Xfce.Session.Manager dbus interface also require an app id for session management.

@mockersf
Copy link
Member

mockersf commented Mar 12, 2022

Maybe, but the method is written as working only on wayland. Otherwise we should expose the canvas option on all platforms too I guess.

@heavyrain266
Copy link
Author

heavyrain266 commented Mar 12, 2022

Why should it be feature gated on wayland? It would be much easier to allow it on all platforms and just pass it to winit on unix. In addition while winit currently only uses it on wayland, other OSes do have a similar concept. For example macOS has the bundle id. And gtk has an application id that is used for wayland and for remote control using dbus. In addition things like the RegisterClient method of the org.Xfce.Session.Manager dbus interface also require an app id for session management.

I don't really know how other systems handle that kind of feature, I'm not really interested in GTK because it does everything in weird way just like GNOME itself, X11 doesn't even have any documentation other than XML file with general implementation, as well as Xorg's 400k lines of code.

@heavyrain266
Copy link
Author

Future winit release will include unified .with_class method which is used to set window class on X11 and app_id on Wayland. We should expose that one instead.

@heavyrain266 heavyrain266 changed the title Expose .with_app_id() from winit in WindowDescriptor for better Wayland integration on Linux target. Expose .with_class() in WindowDescriptor after new winit release to allow setting window class on X11 and app_id on Wayland. May 1, 2022
@kchibisov
Copy link

New winit will have unified call with_name on unix to set class/app_id.

github-merge-queue bot pushed a commit that referenced this issue Feb 5, 2024
# Objective
- Fixes  #4188, make users could set application ID for bevy apps.

## Solution

- Add `name` field to `bevy::window::Window`. Specifying this field adds
different properties to the window: application ID on `Wayland`,
`WM_CLASS` on `X11`, or window class name on Windows. It has no effect
on other platforms.
---

## Changelog

### Added
- Add `name` to `bevy::window::Window`.

## Migration Guide

- Set the `bevy_window::Window`'s `name` field when needed:
```rust
App::new()
        .add_plugins(DefaultPlugins.set(WindowPlugin {
            primary_window: Some(Window {
                title: "I am a window!".into(),
                name: Some("SpaceGameCompany.SpaceShooter".into()),
                ..default()
            }),
            ..default()
        }))
        .run();
```

---------

Co-authored-by: François <[email protected]>
lynn-lumen pushed a commit to lynn-lumen/bevy that referenced this issue Feb 5, 2024
# Objective
- Fixes  bevyengine#4188, make users could set application ID for bevy apps.

## Solution

- Add `name` field to `bevy::window::Window`. Specifying this field adds
different properties to the window: application ID on `Wayland`,
`WM_CLASS` on `X11`, or window class name on Windows. It has no effect
on other platforms.
---

## Changelog

### Added
- Add `name` to `bevy::window::Window`.

## Migration Guide

- Set the `bevy_window::Window`'s `name` field when needed:
```rust
App::new()
        .add_plugins(DefaultPlugins.set(WindowPlugin {
            primary_window: Some(Window {
                title: "I am a window!".into(),
                name: Some("SpaceGameCompany.SpaceShooter".into()),
                ..default()
            }),
            ..default()
        }))
        .run();
```

---------

Co-authored-by: François <[email protected]>
tjamaan pushed a commit to tjamaan/bevy that referenced this issue Feb 6, 2024
# Objective
- Fixes  bevyengine#4188, make users could set application ID for bevy apps.

## Solution

- Add `name` field to `bevy::window::Window`. Specifying this field adds
different properties to the window: application ID on `Wayland`,
`WM_CLASS` on `X11`, or window class name on Windows. It has no effect
on other platforms.
---

## Changelog

### Added
- Add `name` to `bevy::window::Window`.

## Migration Guide

- Set the `bevy_window::Window`'s `name` field when needed:
```rust
App::new()
        .add_plugins(DefaultPlugins.set(WindowPlugin {
            primary_window: Some(Window {
                title: "I am a window!".into(),
                name: Some("SpaceGameCompany.SpaceShooter".into()),
                ..default()
            }),
            ..default()
        }))
        .run();
```

---------

Co-authored-by: François <[email protected]>
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-Feature A new feature, making something new possible O-Linux Specific to the Linux desktop operating system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants