mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 14:51:30 +11:00
fix headless build by ensuring NativeMonitorId enum is available internally even without the window feature; add Eq/PartialEq to NativeMonitorId
This commit is contained in:
parent
779f3ce888
commit
1b2fd6e6d0
|
@ -14,7 +14,7 @@ use std::collections::VecDeque;
|
||||||
use Api;
|
use Api;
|
||||||
use BuilderAttribs;
|
use BuilderAttribs;
|
||||||
use GlRequest;
|
use GlRequest;
|
||||||
use NativeMonitorID;
|
use native_monitor::NativeMonitorId;
|
||||||
|
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
display: ffi::egl::types::EGLDisplay,
|
display: ffi::egl::types::EGLDisplay,
|
||||||
|
@ -42,8 +42,8 @@ impl MonitorID {
|
||||||
Some("Primary".to_string())
|
Some("Primary".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_native_identifier(&self) -> NativeMonitorID {
|
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
||||||
NativeMonitorID::Unavailable
|
NativeMonitorId::Unavailable
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ use libc;
|
||||||
use Api;
|
use Api;
|
||||||
use BuilderAttribs;
|
use BuilderAttribs;
|
||||||
use GlRequest;
|
use GlRequest;
|
||||||
use NativeMonitorID;
|
use native_monitor::NativeMonitorId;
|
||||||
|
|
||||||
use cocoa::base::{Class, id, YES, NO, NSUInteger, nil, objc_allocateClassPair, class, objc_registerClassPair};
|
use cocoa::base::{Class, id, YES, NO, NSUInteger, nil, objc_allocateClassPair, class, objc_registerClassPair};
|
||||||
use cocoa::base::{selector, msg_send, msg_send_stret, class_addMethod, class_addIvar};
|
use cocoa::base::{selector, msg_send, msg_send_stret, class_addMethod, class_addIvar};
|
||||||
|
@ -409,7 +409,7 @@ impl Window {
|
||||||
unsafe {
|
unsafe {
|
||||||
let screen = monitor.map(|monitor_id| {
|
let screen = monitor.map(|monitor_id| {
|
||||||
let native_id = match monitor_id.get_native_identifier() {
|
let native_id = match monitor_id.get_native_identifier() {
|
||||||
NativeMonitorID::Numeric(num) => num,
|
NativeMonitorId::Numeric(num) => num,
|
||||||
_ => panic!("OS X monitors should always have a numeric native ID")
|
_ => panic!("OS X monitors should always have a numeric native ID")
|
||||||
};
|
};
|
||||||
let matching_screen = {
|
let matching_screen = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use core_graphics::display;
|
use core_graphics::display;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use window::NativeMonitorID;
|
use native_monitor::NativeMonitorId;
|
||||||
|
|
||||||
pub struct MonitorID(u32);
|
pub struct MonitorID(u32);
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ impl MonitorID {
|
||||||
Some(format!("Monitor #{}", screen_num))
|
Some(format!("Monitor #{}", screen_num))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_native_identifier(&self) -> NativeMonitorID {
|
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
||||||
let MonitorID(display_id) = *self;
|
let MonitorID(display_id) = *self;
|
||||||
NativeMonitorID::Numeric(display_id)
|
NativeMonitorId::Numeric(display_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
|
|
21
src/lib.rs
21
src/lib.rs
|
@ -50,7 +50,9 @@ pub use headless::{HeadlessRendererBuilder, HeadlessContext};
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
pub use window::{WindowBuilder, Window, WindowProxy, PollEventsIterator, WaitEventsIterator};
|
pub use window::{WindowBuilder, Window, WindowProxy, PollEventsIterator, WaitEventsIterator};
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
pub use window::{AvailableMonitorsIter, NativeMonitorID, MonitorID, get_available_monitors, get_primary_monitor};
|
pub use window::{AvailableMonitorsIter, MonitorID, get_available_monitors, get_primary_monitor};
|
||||||
|
#[cfg(feature = "window")]
|
||||||
|
pub use native_monitor::NativeMonitorId;
|
||||||
|
|
||||||
#[cfg(all(not(target_os = "windows"), not(target_os = "linux"), not(target_os = "macos"), not(target_os = "android")))]
|
#[cfg(all(not(target_os = "windows"), not(target_os = "linux"), not(target_os = "macos"), not(target_os = "android")))]
|
||||||
use this_platform_is_not_supported;
|
use this_platform_is_not_supported;
|
||||||
|
@ -322,3 +324,20 @@ impl<'a> BuilderAttribs<'a> {
|
||||||
.expect("Could not find compliant pixel format")
|
.expect("Could not find compliant pixel format")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod native_monitor {
|
||||||
|
/// Native platform identifier for a monitor. Different platforms use fundamentally different types
|
||||||
|
/// to represent a monitor ID.
|
||||||
|
#[derive(PartialEq, Eq)]
|
||||||
|
pub enum NativeMonitorId {
|
||||||
|
/// Cocoa and X11 use a numeric identifier to represent a monitor.
|
||||||
|
Numeric(u32),
|
||||||
|
|
||||||
|
/// Win32 uses a Unicode string to represent a monitor.
|
||||||
|
Name(String),
|
||||||
|
|
||||||
|
/// Other platforms (Android) don't support monitor identification.
|
||||||
|
Unavailable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use user32;
|
||||||
|
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
use NativeMonitorID;
|
use native_monitor::NativeMonitorId;
|
||||||
|
|
||||||
/// Win32 implementation of the main `MonitorID` object.
|
/// Win32 implementation of the main `MonitorID` object.
|
||||||
pub struct MonitorID {
|
pub struct MonitorID {
|
||||||
|
@ -116,8 +116,8 @@ impl MonitorID {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs of the crate root file.
|
/// See the docs of the crate root file.
|
||||||
pub fn get_native_identifier(&self) -> NativeMonitorID {
|
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
||||||
NativeMonitorID::Name(self.readable_name.clone())
|
NativeMonitorId::Name(self.readable_name.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs if the crate root file.
|
/// See the docs if the crate root file.
|
||||||
|
|
|
@ -7,6 +7,7 @@ use CreationError;
|
||||||
use Event;
|
use Event;
|
||||||
use GlRequest;
|
use GlRequest;
|
||||||
use MouseCursor;
|
use MouseCursor;
|
||||||
|
use native_monitor::NativeMonitorId;
|
||||||
|
|
||||||
use gl_common;
|
use gl_common;
|
||||||
use libc;
|
use libc;
|
||||||
|
@ -500,19 +501,6 @@ pub fn get_primary_monitor() -> MonitorID {
|
||||||
MonitorID(winimpl::get_primary_monitor())
|
MonitorID(winimpl::get_primary_monitor())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Native platform identifier for a monitor. Different platforms use fundamentally different types
|
|
||||||
/// to represent a monitor ID.
|
|
||||||
pub enum NativeMonitorID {
|
|
||||||
/// Cocoa and X11 use a numeric identifier to represent a monitor.
|
|
||||||
Numeric(u32),
|
|
||||||
|
|
||||||
/// Win32 uses a Unicode string to represent a monitor.
|
|
||||||
Name(String),
|
|
||||||
|
|
||||||
/// Other platforms (Android) don't support monitor identification.
|
|
||||||
Unavailable
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Identifier for a monitor.
|
/// Identifier for a monitor.
|
||||||
pub struct MonitorID(winimpl::MonitorID);
|
pub struct MonitorID(winimpl::MonitorID);
|
||||||
|
|
||||||
|
@ -524,7 +512,7 @@ impl MonitorID {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the native platform identifier for this monitor.
|
/// Returns the native platform identifier for this monitor.
|
||||||
pub fn get_native_identifier(&self) -> NativeMonitorID {
|
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
||||||
let &MonitorID(ref id) = self;
|
let &MonitorID(ref id) = self;
|
||||||
id.get_native_identifier()
|
id.get_native_identifier()
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::ptr;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use super::super::ffi;
|
use super::super::ffi;
|
||||||
use super::ensure_thread_init;
|
use super::ensure_thread_init;
|
||||||
use window::NativeMonitorID;
|
use native_monitor::NativeMonitorId;
|
||||||
|
|
||||||
pub struct MonitorID(pub u32);
|
pub struct MonitorID(pub u32);
|
||||||
|
|
||||||
|
@ -44,9 +44,9 @@ impl MonitorID {
|
||||||
Some(format!("Monitor #{}", screen_num))
|
Some(format!("Monitor #{}", screen_num))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_native_identifier(&self) -> NativeMonitorID {
|
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
||||||
let MonitorID(screen_num) = *self;
|
let MonitorID(screen_num) = *self;
|
||||||
NativeMonitorID::Numeric(screen_num)
|
NativeMonitorId::Numeric(screen_num)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
|
|
Loading…
Reference in a new issue