bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Add `app_id` to `bevy::window::Window`

Open VitalyAnkh opened this issue 3 years ago • 2 comments

Objective

  • Fixes #4188, make users could set application ID for bevy apps.

Solution

  • Add app_id to bevy::window::Window, which will make bevy call winit::platform::wayland::WindowBuilderExtWayland::with_name() or winit::platform::x11::WindowBuilderExtX11::with_name() when building the window, then the window will have a desired "application ID" property.

Changelog

Added

  • Add app_id to bevy::window::Window.

Migration Guide

  • Set the bevy_window::Window's app_id:
App::new()
        .add_plugins(DefaultPlugins.set(WindowPlugin {
            primary_window: Some(Window {
                title: "I am a window!".into(),
                app_id: "SpaceShooter.SpaceGameCompany".into(),
                resolution: (500., 300.).into(),
                ..default()
            }),
            ..default()
        }))
        .run();

VitalyAnkh avatar Feb 13 '23 04:02 VitalyAnkh

is it an issue to have both x11 and wayland features enabled, and have both methods called?

mockersf avatar Feb 23 '23 16:02 mockersf

is it an issue to have both x11 and wayland features enabled, and have both methods called?

From looking at the winit code, no: both of them set platform_specific.name in the same way.

deifactor avatar Feb 25 '23 02:02 deifactor

I'm very sorry for such a long delay! After almost a year, I finally remembered this PR. I've rebased it onto the latest bevy and updated some documentation. The concept of application ID or wm_class is only applicable to UNIX platforms, and currently, winit does not provide a way to modify it after the app has started. This feature is quite for many window managers to manage windows. Please review the current code again, thank you very much!

VitalyAnkh avatar Jan 31 '24 11:01 VitalyAnkh

The concept of application ID or wm_class is only applicable to UNIX platforms

The equivalent of this on Windows is window class names, which winit also supports:

with_class_name

musjj avatar Jan 31 '24 12:01 musjj

@musjj Thanks! Didn't find this before. I will update this patch ASAP.

VitalyAnkh avatar Jan 31 '24 12:01 VitalyAnkh