On macOS, move automatic tabbing setting to ELWT

Those are global for the application, so it's better to keep them
on EventLoopWindowTarget.
This commit is contained in:
Kirill Chibisov 2023-07-13 15:55:51 +00:00 committed by GitHub
parent c5941d105f
commit 4d6dbea74c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 44 deletions

View file

@ -21,7 +21,7 @@ use objc2::rc::{autoreleasepool, Id, Shared};
use objc2::{msg_send_id, ClassType};
use raw_window_handle::{AppKitDisplayHandle, RawDisplayHandle};
use super::appkit::{NSApp, NSApplicationActivationPolicy, NSEvent};
use super::appkit::{NSApp, NSApplicationActivationPolicy, NSEvent, NSWindow};
use crate::{
event::Event,
event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootWindowTarget},
@ -101,6 +101,14 @@ impl<T> EventLoopWindowTarget<T> {
pub(crate) fn hide_other_applications(&self) {
NSApp().hideOtherApplications(None)
}
pub(crate) fn set_allows_automatic_window_tabbing(&self, enabled: bool) {
NSWindow::setAllowsAutomaticWindowTabbing(enabled)
}
pub(crate) fn allows_automatic_window_tabbing(&self) -> bool {
NSWindow::allowsAutomaticWindowTabbing()
}
}
pub struct EventLoop<T: 'static> {

View file

@ -83,7 +83,6 @@ pub struct PlatformSpecificWindowBuilderAttributes {
pub disallow_hidpi: bool,
pub has_shadow: bool,
pub accepts_first_mouse: bool,
pub allows_automatic_window_tabbing: bool,
pub tabbing_identifier: Option<String>,
pub option_as_alt: OptionAsAlt,
}
@ -101,7 +100,6 @@ impl Default for PlatformSpecificWindowBuilderAttributes {
disallow_hidpi: false,
has_shadow: true,
accepts_first_mouse: true,
allows_automatic_window_tabbing: true,
tabbing_identifier: None,
option_as_alt: Default::default(),
}
@ -366,8 +364,6 @@ impl WinitWindow {
this.setTabbingIdentifier(&NSString::from_str(&identifier));
}
NSWindow::setAllowsAutomaticWindowTabbing(pl_attrs.allows_automatic_window_tabbing);
if attrs.content_protected {
this.setSharingType(NSWindowSharingType::NSWindowSharingNone);
}
@ -1405,16 +1401,6 @@ impl WindowExtMacOS for WinitWindow {
self.setHasShadow(has_shadow)
}
#[inline]
fn set_allows_automatic_window_tabbing(&self, enabled: bool) {
NSWindow::setAllowsAutomaticWindowTabbing(enabled);
}
#[inline]
fn allows_automatic_window_tabbing(&self) -> bool {
NSWindow::allowsAutomaticWindowTabbing()
}
#[inline]
fn set_tabbing_identifier(&self, identifier: &str) {
self.setTabbingIdentifier(&NSString::from_str(identifier))