From 82d9bbe5598c8605a752641a477261de01340aed Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Mon, 24 Jun 2024 22:56:20 +0200 Subject: [PATCH] Remove EventLoopExtIOS::idiom and ios::Idiom (#2924) Introduced in 3a7350c with unclear motivation. Nowadays, this feature is incomplete and unsound, and the equivalent functionality can be trivially achieved outside of `winit` using `objc2-ui-kit`. --- FEATURES.md | 1 - src/changelog/unreleased.md | 4 +++ src/platform/ios.rs | 31 --------------------- src/platform_impl/apple/uikit/event_loop.rs | 17 +---------- 4 files changed, 5 insertions(+), 48 deletions(-) diff --git a/FEATURES.md b/FEATURES.md index 2ae94770ee..6f5aff3f4e 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -154,7 +154,6 @@ If your PR makes notable changes to Winit's features, please update this section * Home indicator visibility * Status bar visibility and style * Deferring system gestures -* Getting the device idiom * Getting the preferred video mode ### Web diff --git a/src/changelog/unreleased.md b/src/changelog/unreleased.md index 55fdec30a0..f5cd2a6b18 100644 --- a/src/changelog/unreleased.md +++ b/src/changelog/unreleased.md @@ -59,3 +59,7 @@ changelog entry. - Remove `EventLoopExtRunOnDemand::run_on_demand`. - Remove `EventLoopExtPumpEvents::pump_events`. - Remove `Event`. +- On iOS, remove `platform::ios::EventLoopExtIOS` and related `platform::ios::Idiom` type. + + This feature was incomplete, and the equivalent functionality can be trivially achieved outside + of `winit` using `objc2-ui-kit` and calling `UIDevice::currentDevice().userInterfaceIdiom()`. diff --git a/src/platform/ios.rs b/src/platform/ios.rs index 6a3cd38334..38243411ec 100644 --- a/src/platform/ios.rs +++ b/src/platform/ios.rs @@ -66,22 +66,9 @@ use std::os::raw::c_void; -use crate::event_loop::EventLoop; use crate::monitor::{MonitorHandle, VideoModeHandle}; use crate::window::{Window, WindowAttributes}; -/// Additional methods on [`EventLoop`] that are specific to iOS. -pub trait EventLoopExtIOS { - /// Returns the [`Idiom`] (phone/tablet/tv/etc) for the current device. - fn idiom(&self) -> Idiom; -} - -impl EventLoopExtIOS for EventLoop { - fn idiom(&self) -> Idiom { - self.event_loop.idiom() - } -} - /// Additional methods on [`Window`] that are specific to iOS. pub trait WindowExtIOS { /// Sets the [`contentScaleFactor`] of the underlying [`UIWindow`] to `scale_factor`. @@ -379,24 +366,6 @@ pub enum ValidOrientations { Portrait, } -/// The device [idiom]. -/// -/// [idiom]: https://developer.apple.com/documentation/uikit/uidevice/1620037-userinterfaceidiom?language=objc -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub enum Idiom { - Unspecified, - - /// iPhone and iPod touch. - Phone, - - /// iPad. - Pad, - - /// tvOS and Apple TV. - TV, - CarPlay, -} - bitflags::bitflags! { /// The [edges] of a screen. /// diff --git a/src/platform_impl/apple/uikit/event_loop.rs b/src/platform_impl/apple/uikit/event_loop.rs index 59e6fa83b2..f30bbbb823 100644 --- a/src/platform_impl/apple/uikit/event_loop.rs +++ b/src/platform_impl/apple/uikit/event_loop.rs @@ -15,14 +15,13 @@ use core_foundation::runloop::{ use objc2::rc::Retained; use objc2::{msg_send_id, ClassType}; use objc2_foundation::{MainThreadMarker, NSString}; -use objc2_ui_kit::{UIApplication, UIApplicationMain, UIDevice, UIScreen, UIUserInterfaceIdiom}; +use objc2_ui_kit::{UIApplication, UIApplicationMain, UIScreen}; use super::app_state::EventLoopHandler; use crate::application::ApplicationHandler; use crate::error::EventLoopError; use crate::event::Event; use crate::event_loop::{ActiveEventLoop as RootActiveEventLoop, ControlFlow, DeviceEvents}; -use crate::platform::ios::Idiom; use crate::window::{CustomCursor, CustomCursorSource}; use super::app_delegate::AppDelegate; @@ -222,20 +221,6 @@ impl EventLoop { } } -// EventLoopExtIOS -impl EventLoop { - pub fn idiom(&self) -> Idiom { - match UIDevice::currentDevice(self.mtm).userInterfaceIdiom() { - UIUserInterfaceIdiom::Unspecified => Idiom::Unspecified, - UIUserInterfaceIdiom::Phone => Idiom::Phone, - UIUserInterfaceIdiom::Pad => Idiom::Pad, - UIUserInterfaceIdiom::TV => Idiom::TV, - UIUserInterfaceIdiom::CarPlay => Idiom::CarPlay, - _ => Idiom::Unspecified, - } - } -} - pub struct EventLoopProxy { proxy_wake_up: Arc, source: CFRunLoopSourceRef,