mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 23:23:14 -04:00
Rename MonitorId to MonitorHandle
This commit is contained in:
@@ -41,7 +41,7 @@ use winapi::um::{winuser, winbase, ole2, processthreadsapi, commctrl, libloadera
|
||||
use winapi::um::winnt::{LONG, LPCSTR, SHORT};
|
||||
|
||||
use window::WindowId as RootWindowId;
|
||||
use monitor::MonitorId;
|
||||
use monitor::MonitorHandle;
|
||||
use event_loop::{ControlFlow, EventLoop as RootEventLoop, EventLoopClosed};
|
||||
use dpi::{LogicalPosition, LogicalSize, PhysicalSize};
|
||||
use event::{DeviceEvent, Touch, TouchPhase, StartCause, KeyboardInput, Event, WindowEvent};
|
||||
@@ -91,7 +91,7 @@ pub struct WindowState {
|
||||
// This is different from the value in `SavedWindowInfo`! That one represents the DPI saved upon entering
|
||||
// fullscreen. This will always be the most recent DPI for the window.
|
||||
pub dpi_factor: f64,
|
||||
pub fullscreen: Option<MonitorId>,
|
||||
pub fullscreen: Option<MonitorHandle>,
|
||||
pub window_icon: Option<WinIcon>,
|
||||
pub taskbar_icon: Option<WinIcon>,
|
||||
pub decorations: bool,
|
||||
|
||||
@@ -4,7 +4,7 @@ use winapi;
|
||||
use winapi::shared::windef::HWND;
|
||||
|
||||
pub use self::event_loop::{EventLoop, EventLoopProxy};
|
||||
pub use self::monitor::MonitorId;
|
||||
pub use self::monitor::MonitorHandle;
|
||||
pub use self::window::Window;
|
||||
|
||||
use window::Icon;
|
||||
|
||||
@@ -11,9 +11,9 @@ use dpi::{PhysicalPosition, PhysicalSize};
|
||||
use platform_impl::platform::dpi::{dpi_to_scale_factor, get_monitor_dpi};
|
||||
use platform_impl::platform::window::Window;
|
||||
|
||||
/// Win32 implementation of the main `MonitorId` object.
|
||||
/// Win32 implementation of the main `MonitorHandle` object.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct MonitorId {
|
||||
pub struct MonitorHandle {
|
||||
/// Monitor handle.
|
||||
hmonitor: HMonitor,
|
||||
/// The system name of the monitor.
|
||||
@@ -45,13 +45,13 @@ unsafe extern "system" fn monitor_enum_proc(
|
||||
_place: LPRECT,
|
||||
data: LPARAM,
|
||||
) -> BOOL {
|
||||
let monitors = data as *mut VecDeque<MonitorId>;
|
||||
(*monitors).push_back(MonitorId::from_hmonitor(hmonitor));
|
||||
let monitors = data as *mut VecDeque<MonitorHandle>;
|
||||
(*monitors).push_back(MonitorHandle::from_hmonitor(hmonitor));
|
||||
TRUE // continue enumeration
|
||||
}
|
||||
|
||||
pub fn get_available_monitors() -> VecDeque<MonitorId> {
|
||||
let mut monitors: VecDeque<MonitorId> = VecDeque::new();
|
||||
pub fn get_available_monitors() -> VecDeque<MonitorHandle> {
|
||||
let mut monitors: VecDeque<MonitorHandle> = VecDeque::new();
|
||||
unsafe {
|
||||
winuser::EnumDisplayMonitors(
|
||||
ptr::null_mut(),
|
||||
@@ -63,38 +63,38 @@ pub fn get_available_monitors() -> VecDeque<MonitorId> {
|
||||
monitors
|
||||
}
|
||||
|
||||
pub fn get_primary_monitor() -> MonitorId {
|
||||
pub fn get_primary_monitor() -> MonitorHandle {
|
||||
const ORIGIN: POINT = POINT { x: 0, y: 0 };
|
||||
let hmonitor = unsafe {
|
||||
winuser::MonitorFromPoint(ORIGIN, winuser::MONITOR_DEFAULTTOPRIMARY)
|
||||
};
|
||||
MonitorId::from_hmonitor(hmonitor)
|
||||
MonitorHandle::from_hmonitor(hmonitor)
|
||||
}
|
||||
|
||||
pub fn get_current_monitor(hwnd: HWND) -> MonitorId {
|
||||
pub fn get_current_monitor(hwnd: HWND) -> MonitorHandle {
|
||||
let hmonitor = unsafe {
|
||||
winuser::MonitorFromWindow(hwnd, winuser::MONITOR_DEFAULTTONEAREST)
|
||||
};
|
||||
MonitorId::from_hmonitor(hmonitor)
|
||||
MonitorHandle::from_hmonitor(hmonitor)
|
||||
}
|
||||
|
||||
impl<T> EventLoop<T> {
|
||||
// TODO: Investigate opportunities for caching
|
||||
pub fn get_available_monitors(&self) -> VecDeque<MonitorId> {
|
||||
pub fn get_available_monitors(&self) -> VecDeque<MonitorHandle> {
|
||||
get_available_monitors()
|
||||
}
|
||||
|
||||
pub fn get_primary_monitor(&self) -> MonitorId {
|
||||
pub fn get_primary_monitor(&self) -> MonitorHandle {
|
||||
get_primary_monitor()
|
||||
}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
pub fn get_available_monitors(&self) -> VecDeque<MonitorId> {
|
||||
pub fn get_available_monitors(&self) -> VecDeque<MonitorHandle> {
|
||||
get_available_monitors()
|
||||
}
|
||||
|
||||
pub fn get_primary_monitor(&self) -> MonitorId {
|
||||
pub fn get_primary_monitor(&self) -> MonitorHandle {
|
||||
get_primary_monitor()
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ fn get_monitor_info(hmonitor: HMONITOR) -> Result<winuser::MONITORINFOEXW, util:
|
||||
}
|
||||
}
|
||||
|
||||
impl MonitorId {
|
||||
impl MonitorHandle {
|
||||
pub(crate) fn from_hmonitor(hmonitor: HMONITOR) -> Self {
|
||||
let monitor_info = get_monitor_info(hmonitor).expect("`GetMonitorInfoW` failed");
|
||||
let place = monitor_info.rcMonitor;
|
||||
@@ -123,7 +123,7 @@ impl MonitorId {
|
||||
(place.right - place.left) as u32,
|
||||
(place.bottom - place.top) as u32,
|
||||
);
|
||||
MonitorId {
|
||||
MonitorHandle {
|
||||
hmonitor: HMonitor(hmonitor),
|
||||
monitor_name: util::wchar_ptr_to_string(monitor_info.szDevice.as_ptr()),
|
||||
primary: util::has_flag(monitor_info.dwFlags, winuser::MONITORINFOF_PRIMARY),
|
||||
|
||||
@@ -20,7 +20,7 @@ use winapi::um::winnt::{LONG, LPCWSTR};
|
||||
|
||||
use window::{CreationError, Icon, WindowAttributes, MouseCursor};
|
||||
use dpi::{LogicalPosition, LogicalSize, PhysicalSize};
|
||||
use monitor::MonitorId as RootMonitorId;
|
||||
use monitor::MonitorHandle as RootMonitorHandle;
|
||||
use platform_impl::platform::{Cursor, PlatformSpecificWindowBuilderAttributes, WindowId};
|
||||
use platform_impl::platform::dpi::{dpi_to_scale_factor, get_hwnd_dpi};
|
||||
use platform_impl::platform::event_loop::{self, EventLoop, DESTROY_MSG_ID, INITIAL_DPI_MSG_ID, REQUEST_REDRAW_NO_NEWEVENTS_MSG_ID};
|
||||
@@ -606,11 +606,11 @@ impl Window {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_fullscreen(&self, monitor: Option<RootMonitorId>) {
|
||||
pub fn set_fullscreen(&self, monitor: Option<RootMonitorHandle>) {
|
||||
let mut window_state_lock = self.window_state.lock();
|
||||
unsafe {
|
||||
let monitor_rect = monitor.as_ref()
|
||||
.map(|RootMonitorId{ ref inner }| {
|
||||
.map(|RootMonitorHandle{ ref inner }| {
|
||||
let (x, y): (i32, i32) = inner.get_position().into();
|
||||
let (width, height): (u32, u32) = inner.get_dimensions().into();
|
||||
(x, y, width, height)
|
||||
@@ -772,8 +772,8 @@ impl Window {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_current_monitor(&self) -> RootMonitorId {
|
||||
RootMonitorId {
|
||||
pub fn get_current_monitor(&self) -> RootMonitorHandle {
|
||||
RootMonitorHandle {
|
||||
inner: monitor::get_current_monitor(self.window.0),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user