From aef64e56b8a43cb6cf7a4faabd312739669030fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 25 Nov 2025 23:13:36 +0100 Subject: [PATCH] Add `allow_automatic_tabbing` task to `runtime::window` Co-authored-by: Karolis Ramanauskas --- runtime/src/window.rs | 24 +++++++++++++++++++----- winit/src/lib.rs | 16 ++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 2a05a96d..3b464d3f 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -178,6 +178,11 @@ pub enum Action { /// Get the logical dimensions of the monitor containing the window with the given [`Id`]. GetMonitorSize(Id, oneshot::Sender>), + /// Set whether the system can automatically organize windows into tabs. + /// + /// See https://developer.apple.com/documentation/appkit/nswindow/1646657-allowsautomaticwindowtabbing + SetAllowAutomaticTabbing(bool), + /// Redraw all the windows. RedrawAll, @@ -329,7 +334,7 @@ pub fn set_resize_increments(id: Id, increments: Option) -> Task { ))) } -/// Get the window's size in logical dimensions. +/// Gets the window size in logical dimensions. pub fn size(id: Id) -> Task { task::oneshot(move |channel| { crate::Action::Window(Action::GetSize(id, channel)) @@ -401,7 +406,7 @@ pub fn toggle_decorations(id: Id) -> Task { task::effect(crate::Action::Window(Action::ToggleDecorations(id))) } -/// Request user attention to the window. This has no effect if the application +/// Requests user attention to the window. This has no effect if the application /// is already focused. How requesting for user attention manifests is platform dependent, /// see [`UserAttention`] for details. /// @@ -432,7 +437,7 @@ pub fn set_level(id: Id, level: Level) -> Task { task::effect(crate::Action::Window(Action::SetLevel(id, level))) } -/// Show the [system menu] at cursor position. +/// Shows the [system menu] at cursor position. /// /// [system menu]: https://en.wikipedia.org/wiki/Common_menus_in_Microsoft_Windows#System_menu pub fn show_system_menu(id: Id) -> Task { @@ -487,7 +492,7 @@ pub fn enable_mouse_passthrough(id: Id) -> Task { task::effect(crate::Action::Window(Action::EnableMousePassthrough(id))) } -/// Disable mouse passthrough for the given window. +/// Disables mouse passthrough for the given window. /// /// This enables mouse events for the window and stops mouse events /// from being passed to whatever is underneath. @@ -495,9 +500,18 @@ pub fn disable_mouse_passthrough(id: Id) -> Task { task::effect(crate::Action::Window(Action::DisableMousePassthrough(id))) } -/// Get the logical dimensions of the monitor containing the window with the given [`Id`]. +/// Gets the logical dimensions of the monitor containing the window with the given [`Id`]. pub fn monitor_size(id: Id) -> Task> { task::oneshot(move |channel| { crate::Action::Window(Action::GetMonitorSize(id, channel)) }) } + +/// Sets whether the system can automatically organize windows into tabs. +/// +/// See https://developer.apple.com/documentation/appkit/nswindow/1646657-allowsautomaticwindowtabbing +pub fn allow_automatic_tabbing(enabled: bool) -> Task { + task::effect(crate::Action::Window(Action::SetAllowAutomaticTabbing( + enabled, + ))) +} diff --git a/winit/src/lib.rs b/winit/src/lib.rs index 1e6394e4..8b161aab 100644 --- a/winit/src/lib.rs +++ b/winit/src/lib.rs @@ -435,6 +435,16 @@ where self.error = Some(error); event_loop.exit(); } + Control::SetAutomaticWindowTabbing(_enabled) => { + #[cfg(target_os = "macos")] + { + use winit::platform::macos::ActiveEventLoopExtMacOS; + event_loop + .set_allows_automatic_window_tabbing( + _enabled, + ); + } + } }, _ => { break; @@ -492,6 +502,7 @@ enum Control { on_open: oneshot::Sender, scale_factor: f32, }, + SetAutomaticWindowTabbing(bool), } async fn run_instance

( @@ -1657,6 +1668,11 @@ fn run_action<'a, P, C>( let _ = channel.send(size); } } + window::Action::SetAllowAutomaticTabbing(enabled) => { + control_sender + .start_send(Control::SetAutomaticWindowTabbing(enabled)) + .expect("Send control action"); + } window::Action::RedrawAll => { for (_id, window) in window_manager.iter_mut() { window.raw.request_redraw();