Skip to content

Commit deb7d37

Browse files
committed
Rename MonitorId to MonitorHandle
1 parent 8d8d9b7 commit deb7d37

File tree

26 files changed

+224
-220
lines changed

26 files changed

+224
-220
lines changed

src/dpi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
//! windows. This event is sent any time the DPI factor changes, either because the window moved to another monitor,
3434
//! or because the user changed the configuration of their screen.
3535
//! - You can also retrieve the DPI factor of a monitor by calling
36-
//! [`MonitorId::get_hidpi_factor`](../monitor/struct.MonitorId.html#method.get_hidpi_factor), or the
36+
//! [`MonitorHandle::get_hidpi_factor`](../monitor/struct.MonitorHandle.html#method.get_hidpi_factor), or the
3737
//! current DPI factor applied to a window by calling
3838
//! [`Window::get_hidpi_factor`](../window/struct.Window.html#method.get_hidpi_factor), which is roughly equivalent
3939
//! to `window.get_current_monitor().get_hidpi_factor()`.

src/event_loop.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::time::Instant;
1414

1515
use platform_impl;
1616
use event::Event;
17-
use monitor::{AvailableMonitorsIter, MonitorId};
17+
use monitor::{AvailableMonitorsIter, MonitorHandle};
1818

1919
/// Provides a way to retrieve events from the system and from the windows that were registered to
2020
/// the events loop.
@@ -101,8 +101,8 @@ impl<T> EventLoop<T> {
101101

102102
/// Returns the primary monitor of the system.
103103
#[inline]
104-
pub fn get_primary_monitor(&self) -> MonitorId {
105-
MonitorId { inner: self.event_loop.get_primary_monitor() }
104+
pub fn get_primary_monitor(&self) -> MonitorHandle {
105+
MonitorHandle { inner: self.event_loop.get_primary_monitor() }
106106
}
107107

108108
/// Hijacks the calling thread and initializes the `winit` event loop with the provided

src/monitor.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//! Types useful for interacting with a user's monitors.
22
//!
3-
//! If you want to get basic information about a monitor, you can use the [`MonitorId`][monitor_id]
3+
//! If you want to get basic information about a monitor, you can use the [`MonitorHandle`][monitor_id]
44
//! type. This is retreived from an [`AvailableMonitorsIter`][monitor_iter], which can be acquired
55
//! with:
66
//! - [`EventLoop::get_available_monitors`][loop_get]
77
//! - [`Window::get_available_monitors`][window_get].
88
//!
9-
//! [monitor_id]: ./struct.MonitorId.html
9+
//! [monitor_id]: ./struct.MonitorHandle.html
1010
//! [monitor_iter]: ./struct.AvailableMonitorsIter.html
1111
//! [loop_get]: ../event_loop/struct.EventLoop.html#method.get_available_monitors
1212
//! [window_get]: ../window/struct.Window.html#method.get_available_monitors
@@ -27,15 +27,15 @@ use dpi::{PhysicalPosition, PhysicalSize};
2727
// This may change in the future.
2828
#[derive(Debug)]
2929
pub struct AvailableMonitorsIter {
30-
pub(crate) data: VecDequeIter<platform_impl::MonitorId>,
30+
pub(crate) data: VecDequeIter<platform_impl::MonitorHandle>,
3131
}
3232

3333
impl Iterator for AvailableMonitorsIter {
34-
type Item = MonitorId;
34+
type Item = MonitorHandle;
3535

3636
#[inline]
37-
fn next(&mut self) -> Option<MonitorId> {
38-
self.data.next().map(|id| MonitorId { inner: id })
37+
fn next(&mut self) -> Option<MonitorHandle> {
38+
self.data.next().map(|id| MonitorHandle { inner: id })
3939
}
4040

4141
#[inline]
@@ -44,13 +44,17 @@ impl Iterator for AvailableMonitorsIter {
4444
}
4545
}
4646

47-
/// Identifier for a monitor.
47+
/// Handle to a monitor.
48+
///
49+
/// Allows you to retrieve information about a given monitor and can be used in [`Window`] creation.
50+
///
51+
/// [`Window`]: ../window/struct.Window.html
4852
#[derive(Debug, Clone)]
49-
pub struct MonitorId {
50-
pub(crate) inner: platform_impl::MonitorId
53+
pub struct MonitorHandle {
54+
pub(crate) inner: platform_impl::MonitorHandle
5155
}
5256

53-
impl MonitorId {
57+
impl MonitorHandle {
5458
/// Returns a human-readable name of the monitor.
5559
///
5660
/// Returns `None` if the monitor doesn't exist anymore.

src/platform/ios.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use std::os::raw::c_void;
44

5-
use {MonitorId, Window, WindowBuilder};
5+
use {MonitorHandle, Window, WindowBuilder};
66

77
/// Additional methods on `Window` that are specific to iOS.
88
pub trait WindowExtIOS {
@@ -45,13 +45,13 @@ impl WindowBuilderExtIOS for WindowBuilder {
4545
}
4646
}
4747

48-
/// Additional methods on `MonitorId` that are specific to iOS.
49-
pub trait MonitorIdExtIOS {
48+
/// Additional methods on `MonitorHandle` that are specific to iOS.
49+
pub trait MonitorHandleExtIOS {
5050
/// Returns a pointer to the `UIScreen` that is used by this monitor.
5151
fn get_uiscreen(&self) -> *mut c_void;
5252
}
5353

54-
impl MonitorIdExtIOS for MonitorId {
54+
impl MonitorHandleExtIOS for MonitorHandle {
5555
#[inline]
5656
fn get_uiscreen(&self) -> *mut c_void {
5757
self.inner.get_uiscreen() as _

src/platform/macos.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![cfg(target_os = "macos")]
22

33
use std::os::raw::c_void;
4-
use {LogicalSize, MonitorId, Window, WindowBuilder};
4+
use {LogicalSize, MonitorHandle, Window, WindowBuilder};
55

66
/// Additional methods on `Window` that are specific to MacOS.
77
pub trait WindowExtMacOS {
@@ -137,15 +137,15 @@ impl WindowBuilderExtMacOS for WindowBuilder {
137137
}
138138
}
139139

140-
/// Additional methods on `MonitorId` that are specific to MacOS.
141-
pub trait MonitorIdExtMacOS {
140+
/// Additional methods on `MonitorHandle` that are specific to MacOS.
141+
pub trait MonitorHandleExtMacOS {
142142
/// Returns the identifier of the monitor for Cocoa.
143143
fn native_id(&self) -> u32;
144144
/// Returns a pointer to the NSScreen representing this monitor.
145145
fn get_nsscreen(&self) -> Option<*mut c_void>;
146146
}
147147

148-
impl MonitorIdExtMacOS for MonitorId {
148+
impl MonitorHandleExtMacOS for MonitorHandle {
149149
#[inline]
150150
fn native_id(&self) -> u32 {
151151
self.inner.get_native_identifier()

src/platform/unix.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::sync::Arc;
77
use {
88
EventLoop,
99
LogicalSize,
10-
MonitorId,
10+
MonitorHandle,
1111
Window,
1212
WindowBuilder,
1313
};
@@ -279,13 +279,13 @@ impl WindowBuilderExtUnix for WindowBuilder {
279279
}
280280
}
281281

282-
/// Additional methods on `MonitorId` that are specific to Linux.
283-
pub trait MonitorIdExtUnix {
282+
/// Additional methods on `MonitorHandle` that are specific to Linux.
283+
pub trait MonitorHandleExtUnix {
284284
/// Returns the inner identifier of the monitor.
285285
fn native_id(&self) -> u32;
286286
}
287287

288-
impl MonitorIdExtUnix for MonitorId {
288+
impl MonitorHandleExtUnix for MonitorHandle {
289289
#[inline]
290290
fn native_id(&self) -> u32 {
291291
self.inner.get_native_identifier()

src/platform/windows.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use libc;
66
use winapi::shared::windef::HWND;
77

88
use event::DeviceId;
9-
use monitor::MonitorId;
9+
use monitor::MonitorHandle;
1010
use event_loop::EventLoop;
1111
use window::{Icon, Window, WindowBuilder};
1212
use platform_impl::EventLoop as WindowsEventLoop;
@@ -83,16 +83,16 @@ impl WindowBuilderExtWindows for WindowBuilder {
8383
}
8484
}
8585

86-
/// Additional methods on `MonitorId` that are specific to Windows.
87-
pub trait MonitorIdExtWindows {
86+
/// Additional methods on `MonitorHandle` that are specific to Windows.
87+
pub trait MonitorHandleExtWindows {
8888
/// Returns the name of the monitor adapter specific to the Win32 API.
8989
fn native_id(&self) -> String;
9090

9191
/// Returns the handle of the monitor - `HMONITOR`.
9292
fn hmonitor(&self) -> *mut c_void;
9393
}
9494

95-
impl MonitorIdExtWindows for MonitorId {
95+
impl MonitorHandleExtWindows for MonitorHandle {
9696
#[inline]
9797
fn native_id(&self) -> String {
9898
self.inner.get_native_identifier()

src/platform_impl/android/mod.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use {
2424
};
2525
use CreationError::OsError;
2626
use events::{Touch, TouchPhase};
27-
use window::MonitorId as RootMonitorId;
27+
use window::MonitorHandle as RootMonitorHandle;
2828

2929
pub struct EventLoop {
3030
event_rx: Receiver<android_glue::Event>,
@@ -45,15 +45,15 @@ impl EventLoop {
4545
}
4646

4747
#[inline]
48-
pub fn get_available_monitors(&self) -> VecDeque<MonitorId> {
48+
pub fn get_available_monitors(&self) -> VecDeque<MonitorHandle> {
4949
let mut rb = VecDeque::with_capacity(1);
50-
rb.push_back(MonitorId);
50+
rb.push_back(MonitorHandle);
5151
rb
5252
}
5353

5454
#[inline]
55-
pub fn get_primary_monitor(&self) -> MonitorId {
56-
MonitorId
55+
pub fn get_primary_monitor(&self) -> MonitorHandle {
56+
MonitorHandle
5757
}
5858

5959
pub fn poll_events<F>(&mut self, mut callback: F)
@@ -62,7 +62,7 @@ impl EventLoop {
6262
while let Ok(event) = self.event_rx.try_recv() {
6363
let e = match event{
6464
android_glue::Event::EventMotion(motion) => {
65-
let dpi_factor = MonitorId.get_hidpi_factor();
65+
let dpi_factor = MonitorHandle.get_hidpi_factor();
6666
let location = LogicalPosition::from_physical(
6767
(motion.x as f64, motion.y as f64),
6868
dpi_factor,
@@ -103,8 +103,8 @@ impl EventLoop {
103103
if native_window.is_null() {
104104
None
105105
} else {
106-
let dpi_factor = MonitorId.get_hidpi_factor();
107-
let physical_size = MonitorId.get_dimensions();
106+
let dpi_factor = MonitorHandle.get_hidpi_factor();
107+
let physical_size = MonitorHandle.get_dimensions();
108108
let size = LogicalSize::from_physical(physical_size, dpi_factor);
109109
Some(Event::WindowEvent {
110110
window_id: RootWindowId(WindowId),
@@ -178,19 +178,19 @@ pub struct Window {
178178
}
179179

180180
#[derive(Clone)]
181-
pub struct MonitorId;
181+
pub struct MonitorHandle;
182182

183-
impl fmt::Debug for MonitorId {
183+
impl fmt::Debug for MonitorHandle {
184184
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
185185
#[derive(Debug)]
186-
struct MonitorId {
186+
struct MonitorHandle {
187187
name: Option<String>,
188188
dimensions: PhysicalSize,
189189
position: PhysicalPosition,
190190
hidpi_factor: f64,
191191
}
192192

193-
let monitor_id_proxy = MonitorId {
193+
let monitor_id_proxy = MonitorHandle {
194194
name: self.get_name(),
195195
dimensions: self.get_dimensions(),
196196
position: self.get_position(),
@@ -201,7 +201,7 @@ impl fmt::Debug for MonitorId {
201201
}
202202
}
203203

204-
impl MonitorId {
204+
impl MonitorHandle {
205205
#[inline]
206206
pub fn get_name(&self) -> Option<String> {
207207
Some("Primary".to_string())
@@ -357,7 +357,7 @@ impl Window {
357357
}
358358

359359
#[inline]
360-
pub fn set_fullscreen(&self, _monitor: Option<RootMonitorId>) {
360+
pub fn set_fullscreen(&self, _monitor: Option<RootMonitorHandle>) {
361361
// N/A
362362
// Android has single screen maximized apps so nothing to do
363363
}
@@ -383,20 +383,20 @@ impl Window {
383383
}
384384

385385
#[inline]
386-
pub fn get_current_monitor(&self) -> RootMonitorId {
387-
RootMonitorId { inner: MonitorId }
386+
pub fn get_current_monitor(&self) -> RootMonitorHandle {
387+
RootMonitorHandle { inner: MonitorHandle }
388388
}
389389

390390
#[inline]
391-
pub fn get_available_monitors(&self) -> VecDeque<MonitorId> {
391+
pub fn get_available_monitors(&self) -> VecDeque<MonitorHandle> {
392392
let mut rb = VecDeque::with_capacity(1);
393-
rb.push_back(MonitorId);
393+
rb.push_back(MonitorHandle);
394394
rb
395395
}
396396

397397
#[inline]
398-
pub fn get_primary_monitor(&self) -> MonitorId {
399-
MonitorId
398+
pub fn get_primary_monitor(&self) -> MonitorHandle {
399+
MonitorHandle
400400
}
401401

402402
#[inline]

src/platform_impl/emscripten/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
1010
use std::sync::{Mutex, Arc};
1111

1212
use dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize};
13-
use window::MonitorId as RootMonitorId;
13+
use window::MonitorHandle as RootMonitorHandle;
1414

1515
const DOCUMENT_NAME: &'static str = "#document\0";
1616

@@ -31,9 +31,9 @@ pub struct DeviceId;
3131
pub struct PlatformSpecificHeadlessBuilderAttributes;
3232

3333
#[derive(Debug, Clone)]
34-
pub struct MonitorId;
34+
pub struct MonitorHandle;
3535

36-
impl MonitorId {
36+
impl MonitorHandle {
3737
#[inline]
3838
pub fn get_name(&self) -> Option<String> {
3939
Some("Canvas".to_owned())
@@ -107,15 +107,15 @@ impl EventLoop {
107107
}
108108

109109
#[inline]
110-
pub fn get_available_monitors(&self) -> VecDeque<MonitorId> {
110+
pub fn get_available_monitors(&self) -> VecDeque<MonitorHandle> {
111111
let mut list = VecDeque::with_capacity(1);
112-
list.push_back(MonitorId);
112+
list.push_back(MonitorHandle);
113113
list
114114
}
115115

116116
#[inline]
117-
pub fn get_primary_monitor(&self) -> MonitorId {
118-
MonitorId
117+
pub fn get_primary_monitor(&self) -> MonitorHandle {
118+
MonitorHandle
119119
}
120120

121121
pub fn poll_events<F>(&self, mut callback: F)
@@ -569,7 +569,7 @@ impl Window {
569569
}
570570

571571
#[inline]
572-
pub fn set_fullscreen(&self, _monitor: Option<::MonitorId>) {
572+
pub fn set_fullscreen(&self, _monitor: Option<::MonitorHandle>) {
573573
// iOS has single screen maximized apps so nothing to do
574574
}
575575

@@ -594,20 +594,20 @@ impl Window {
594594
}
595595

596596
#[inline]
597-
pub fn get_current_monitor(&self) -> RootMonitorId {
598-
RootMonitorId { inner: MonitorId }
597+
pub fn get_current_monitor(&self) -> RootMonitorHandle {
598+
RootMonitorHandle { inner: MonitorHandle }
599599
}
600600

601601
#[inline]
602-
pub fn get_available_monitors(&self) -> VecDeque<MonitorId> {
602+
pub fn get_available_monitors(&self) -> VecDeque<MonitorHandle> {
603603
let mut list = VecDeque::with_capacity(1);
604-
list.push_back(MonitorId);
604+
list.push_back(MonitorHandle);
605605
list
606606
}
607607

608608
#[inline]
609-
pub fn get_primary_monitor(&self) -> MonitorId {
610-
MonitorId
609+
pub fn get_primary_monitor(&self) -> MonitorHandle {
610+
MonitorHandle
611611
}
612612
}
613613

0 commit comments

Comments
 (0)