Skip to content

Commit

Permalink
Remove EventLoopExtIOS::idiom and ios::Idiom (#2924)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
madsmtm authored Jun 24, 2024
1 parent 8bdd4d6 commit 82d9bbe
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 48 deletions.
1 change: 0 additions & 1 deletion FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/changelog/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.
31 changes: 0 additions & 31 deletions src/platform/ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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.
///
Expand Down
17 changes: 1 addition & 16 deletions src/platform_impl/apple/uikit/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<AtomicBool>,
source: CFRunLoopSourceRef,
Expand Down

0 comments on commit 82d9bbe

Please sign in to comment.