Add name to bevy::window::Window#7650
Conversation
8569e8a to
80d04b6
Compare
crates/bevy_window/src/window.rs
Outdated
| fn default() -> Self { | ||
| Self { | ||
| title: "Bevy App".to_owned(), | ||
| app_id: "bevy.app".to_owned(), |
There was a problem hiding this comment.
is it an issue if several apps running at the same time have the same app_id? Would it be better as an option, and only set it when the user actually put a value?
There was a problem hiding this comment.
drive-by comment: It's not semantically invalid, but it's not useful to have a bunch of unrelated programs with the same app_id. So I'd say that it should be an Option.
There was a problem hiding this comment.
I made this an Option<String> type and None by default now.
| winit_window_builder = winit::platform::wayland::WindowBuilderExtWayland::with_name( | ||
| winit_window_builder, | ||
| window.app_id.clone(), | ||
| "", |
There was a problem hiding this comment.
this value should be explained
| winit_window_builder = winit::platform::x11::WindowBuilderExtX11::with_name( | ||
| winit_window_builder, | ||
| window.app_id.clone(), | ||
| "", |
There was a problem hiding this comment.
this value should be explained
There was a problem hiding this comment.
Should the docs on the field be already enough?
|
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 |
8e7f1e3 to
c7fc907
Compare
|
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 |
The equivalent of this on Windows is window class names, which |
|
@musjj Thanks! Didn't find this before. I will update this patch ASAP. |
Co-authored-by: François <mockersf@gmail.com>
Co-authored-by: François <mockersf@gmail.com>
app_id to bevy::window::Windowname to bevy::window::Window
mockersf
left a comment
There was a problem hiding this comment.
unable to test, but code looks good
| /// - **`macOS`**, **`iOS`**, **`Android`**, and **`Web`**: not applicable. | ||
| /// | ||
| /// Notes: Changing this field during runtime will have no effect for now. | ||
| pub name: Option<String>, |
There was a problem hiding this comment.
Could this be a &'static str instead? Given that it's not supposed to be changed?
There was a problem hiding this comment.
Sure! Done in the following commit.
There was a problem hiding this comment.
Oh it failed to build after turning the type of name into Option<&'static str>:
error: implementation of `cursor::_::_serde::Deserialize` is not general enough
--> crates/bevy_window/src/window.rs:121:35
|
121 | #[derive(Component, Debug, Clone, Reflect)]
| ^^^^^^^ implementation of `cursor::_::_serde::Deserialize` is not general enough
|
= note: `window::Window` must implement `cursor::_::_serde::Deserialize<'0>`, for any lifetime `'0`...
= note: ...but it actually implements `cursor::_::_serde::Deserialize<'static>`
= note: this error originates in the derive macro `Reflect` (in Nightly builds, run with -Z macro-backtrace for more info)
error: could not compile `bevy_window` (lib) due to previous errorHow to #[derive(Reflect)] a type with a component whose type is Option<&'static str>? 🤔
There was a problem hiding this comment.
bevy_reflect supports type with 'static lifetimes, but the situation here seems more complex. Reverted it because I'm not familiar with the mechanism of bevy_reflect. Maybe add this optimization later.
There was a problem hiding this comment.
oh I see, no worries. It seems like Reflect was implemented for &'static str in #11686 so it's a bit strange that it still won't work.
# 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 <mockersf@gmail.com>
# 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 <mockersf@gmail.com>
Objective
.with_class()inWindowDescriptorafter new winit release to allow setting window class on X11 and app_id on Wayland. #4188, make users could set application ID for bevy apps.Solution
namefield tobevy::window::Window. Specifying this field adds different properties to the window: application ID onWayland,WM_CLASSonX11, or window class name on Windows. It has no effect on other platforms.Changelog
Added
nametobevy::window::Window.Migration Guide
bevy_window::Window'snamefield when needed: