Add app_name to WindowAttributes

This commit is contained in:
Roland Fredenhagen 2023-11-11 01:29:24 +01:00
parent 043bfe2c78
commit bcbbb7810e
No known key found for this signature in database
GPG key ID: 094AF99241035EB6
2 changed files with 25 additions and 0 deletions

View file

@ -272,6 +272,23 @@ impl<Message> Windows<Message> {
.with_window_icon(attrs.window_icon)
.with_theme(attrs.preferred_theme);
#[cfg(any(target_os = "linux", target_os = "windows"))]
if let Some(app_name) = &attrs.app_name {
#[cfg(target_os = "linux")]
{
builder = winit::platform::wayland::WindowBuilderExtWayland::with_name(
builder, app_name, "",
);
builder =
winit::platform::x11::WindowBuilderExtX11::with_name(builder, app_name, "");
}
#[cfg(target_os = "windows")]
{
builder =
platform::windows::WindowBuilderExtWindows::with_name(builder, app_name, "");
}
}
if let Some(inner_size) = attrs.inner_size {
builder = builder.with_inner_size(inner_size);
}

View file

@ -137,6 +137,13 @@ pub struct WindowAttributes<ParentWindowEvent> {
pub parent_window: Option<Window<ParentWindowEvent>>,
/// Whether the window is active or not.
pub active: bool,
/// Name of the application
///
/// - `WM_CLASS` on X11
/// - application ID on wayland
/// - class name on windows
#[doc(alias("app_id", "class", "class_name"))]
pub app_name: Option<String>,
}
impl<User> Default for WindowAttributes<User> {
@ -162,6 +169,7 @@ impl<User> Default for WindowAttributes<User> {
window_level: defaults.window_level,
active: defaults.active,
parent_window: None,
app_name: None,
}
}
}