From 0586e48c707e3a306ce733ccf8ed37e108ddd796 Mon Sep 17 00:00:00 2001 From: Paul Delafosse Date: Fri, 6 Nov 2020 09:13:59 +0100 Subject: Add wayland app_id see: https://github.com/wayland-project/wayland-protocols/blob/4ed0cafeefd9f81b974465ca495cbd9118508cdb/stable/xdg-shell/xdg-shell.xml#L640 --- winit/src/settings.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 743f79bc..4a0e1fe1 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -103,6 +103,12 @@ impl Window { .with_max_inner_size(winit::dpi::LogicalSize { width, height }); } + #[cfg(target_os = "linux")] + { + use ::winit::platform::unix::WindowBuilderExtUnix; + window_builder = window_builder.with_app_id(title.to_string()); + } + #[cfg(target_os = "windows")] { use winit::platform::windows::WindowBuilderExtWindows; -- cgit From e3bc050aaeb0b7d5a5d463ed06911128e2d6753f Mon Sep 17 00:00:00 2001 From: Paul Delafosse Date: Tue, 10 Nov 2020 08:51:38 +0100 Subject: Match winit unix targets for wayland app_id --- winit/src/settings.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 4a0e1fe1..6051e5bc 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -103,7 +103,13 @@ impl Window { .with_max_inner_size(winit::dpi::LogicalSize { width, height }); } - #[cfg(target_os = "linux")] + #[cfg(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd" + ))] { use ::winit::platform::unix::WindowBuilderExtUnix; window_builder = window_builder.with_app_id(title.to_string()); -- cgit From 7337ab63bc9e167116f8adbfedb5a8e8203a4a5b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 11 Aug 2021 19:23:05 +0700 Subject: Introduce explicit `id` field to `Settings` ... and use it to set the application id of the window on Unix systems, instead of relying on the title of the application. --- glutin/src/application.rs | 1 + src/settings.rs | 13 +++++++++++-- winit/src/application.rs | 1 + winit/src/settings.rs | 13 ++++++++++++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/glutin/src/application.rs b/glutin/src/application.rs index 7ed6315d..4a5f4bd2 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -58,6 +58,7 @@ where &application.title(), application.mode(), event_loop.primary_monitor(), + settings.id, ) .with_menu(Some(conversion::menu(&application.menu()))); diff --git a/src/settings.rs b/src/settings.rs index 480bf813..d726dc4f 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -4,12 +4,18 @@ use crate::window; /// The settings of an application. #[derive(Debug, Clone)] pub struct Settings { + /// The identifier of the application. + /// + /// If provided, this identifier may be used to identify the application or + /// communicate with it through the windowing system. + pub id: Option, + /// The window settings. /// /// They will be ignored on the Web. pub window: window::Settings, - /// The data needed to initialize an [`Application`]. + /// The data needed to initialize the [`Application`]. /// /// [`Application`]: crate::Application pub flags: Flags, @@ -58,6 +64,7 @@ impl Settings { Self { flags, + id: default_settings.id, window: default_settings.window, default_font: default_settings.default_font, default_text_size: default_settings.default_text_size, @@ -74,8 +81,9 @@ where { fn default() -> Self { Self { - flags: Default::default(), + id: None, window: Default::default(), + flags: Default::default(), default_font: Default::default(), default_text_size: 20, text_multithreading: false, @@ -89,6 +97,7 @@ where impl From> for iced_winit::Settings { fn from(settings: Settings) -> iced_winit::Settings { iced_winit::Settings { + id: settings.id, window: settings.window.into(), flags: settings.flags, exit_on_close_request: settings.exit_on_close_request, diff --git a/winit/src/application.rs b/winit/src/application.rs index 1d32a5f3..c43eed11 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -152,6 +152,7 @@ where &application.title(), application.mode(), event_loop.primary_monitor(), + settings.id, ) .with_menu(Some(conversion::menu(&application.menu()))) .build(&event_loop) diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 6051e5bc..72a1a24a 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -16,6 +16,12 @@ use winit::window::WindowBuilder; /// The settings of an application. #[derive(Debug, Clone, Default)] pub struct Settings { + /// The identifier of the application. + /// + /// If provided, this identifier may be used to identify the application or + /// communicate with it through the windowing system. + pub id: Option, + /// The [`Window`] settings pub window: Window, @@ -70,6 +76,7 @@ impl Window { title: &str, mode: Mode, primary_monitor: Option, + _id: Option, ) -> WindowBuilder { let mut window_builder = WindowBuilder::new(); @@ -112,7 +119,10 @@ impl Window { ))] { use ::winit::platform::unix::WindowBuilderExtUnix; - window_builder = window_builder.with_app_id(title.to_string()); + + if let Some(id) = _id { + window_builder = window_builder.with_app_id(id); + } } #[cfg(target_os = "windows")] @@ -122,6 +132,7 @@ impl Window { if let Some(parent) = self.platform_specific.parent { window_builder = window_builder.with_parent_window(parent); } + window_builder = window_builder .with_drag_and_drop(self.platform_specific.drag_and_drop); } -- cgit