Skip to content

Commit

Permalink
rebase, add docs, use the type Option<String> for app_id
Browse files Browse the repository at this point in the history
  • Loading branch information
VitalyAnkh committed Jan 31, 2024
1 parent b4285a2 commit c7fc907
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 37 deletions.
16 changes: 13 additions & 3 deletions crates/bevy_window/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,18 @@ pub struct Window {
pub resolution: WindowResolution,
/// Stores the title of the window.
pub title: String,
/// Stores the application ID of the window.
pub app_id: String,
/// Stores the application ID (on **`Wayland`**) or `wm_class` (on **`X11`**) of the window.
///
/// For details about application ID conventions, see the [Desktop Entry Spec](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#desktop-file-id).
///
/// ## Platform-specific
///
/// - **`Windows`**, **`iOS`**, **`Android`**, and **`Web`**: not applicable.
/// - **`X11`**: Can only be set while building the window, setting your App's `wm_class` property.
/// - **`Wayland`**: Can only be set while building the window, setting your App's application ID property.
///
/// Notes: Changing this field during runtime will have no effect for now.
pub app_id: Option<String>,
/// How the alpha channel of textures should be handled while compositing.
pub composite_alpha_mode: CompositeAlphaMode,
/// The limits of the window's logical size
Expand Down Expand Up @@ -244,7 +254,7 @@ impl Default for Window {
fn default() -> Self {
Self {
title: "Bevy App".to_owned(),
app_id: "bevy.app".to_owned(),
app_id: None,
cursor: Default::default(),
present_mode: Default::default(),
mode: Default::default(),
Expand Down
73 changes: 39 additions & 34 deletions crates/bevy_winit/src/winit_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,42 +98,47 @@ impl WinitWindows {
.with_transparent(window.transparent)
.with_visible(window.visible);

#[cfg(all(
feature = "wayland",
any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
)
))]
{
winit_window_builder = winit::platform::wayland::WindowBuilderExtWayland::with_name(
winit_window_builder,
window.app_id.clone(),
"",
);
}
match &window.app_id {
None => {}
Some(id) => {
#[cfg(all(
feature = "wayland",
any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
)
))]
{
winit_window_builder =
winit::platform::wayland::WindowBuilderExtWayland::with_name(
winit_window_builder,
id.clone(),
"",
);
}

#[cfg(all(
feature = "x11",
any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
)
))]
{
winit_window_builder = winit::platform::x11::WindowBuilderExtX11::with_name(
winit_window_builder,
window.app_id.clone(),
"",
);
#[cfg(all(
feature = "x11",
any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
)
))]
{
winit_window_builder = winit::platform::x11::WindowBuilderExtX11::with_name(
winit_window_builder,
id.clone(),
"",
);
}
}
}

let constraints = window.resize_constraints.check_constraints();
let min_inner_size = LogicalSize {
width: constraints.min_width,
Expand Down

0 comments on commit c7fc907

Please sign in to comment.