mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Merge pull request #612 from tomaka/monitorid-to-monitorid
Rename MonitorID -> MonitorId
This commit is contained in:
commit
3e11e5ef69
|
@ -32,23 +32,23 @@ pub struct Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MonitorID;
|
pub struct MonitorId;
|
||||||
|
|
||||||
mod ffi;
|
mod ffi;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorId> {
|
||||||
let mut rb = VecDeque::new();
|
let mut rb = VecDeque::new();
|
||||||
rb.push_back(MonitorID);
|
rb.push_back(MonitorId);
|
||||||
rb
|
rb
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorId {
|
||||||
MonitorID
|
MonitorId
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorId {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
Some("Primary".to_string())
|
Some("Primary".to_string())
|
||||||
|
|
|
@ -39,18 +39,18 @@ impl WindowProxy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct MonitorID;
|
pub struct MonitorId;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorId> {
|
||||||
VecDeque::new()
|
VecDeque::new()
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorId {
|
||||||
MonitorID
|
MonitorId
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorId {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
|
|
|
@ -51,7 +51,7 @@ use events::ElementState::{Pressed, Released};
|
||||||
use events::MouseButton;
|
use events::MouseButton;
|
||||||
use events;
|
use events;
|
||||||
|
|
||||||
pub use self::monitor::{MonitorID, get_available_monitors, get_primary_monitor};
|
pub use self::monitor::{MonitorId, get_available_monitors, get_primary_monitor};
|
||||||
|
|
||||||
mod monitor;
|
mod monitor;
|
||||||
mod event;
|
mod event;
|
||||||
|
|
|
@ -3,9 +3,9 @@ use std::collections::VecDeque;
|
||||||
use native_monitor::NativeMonitorId;
|
use native_monitor::NativeMonitorId;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MonitorID(u32);
|
pub struct MonitorId(u32);
|
||||||
|
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorId> {
|
||||||
let mut monitors = VecDeque::new();
|
let mut monitors = VecDeque::new();
|
||||||
unsafe {
|
unsafe {
|
||||||
let max_displays = 10u32;
|
let max_displays = 10u32;
|
||||||
|
@ -15,23 +15,23 @@ pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
&mut active_displays[0],
|
&mut active_displays[0],
|
||||||
&mut display_count);
|
&mut display_count);
|
||||||
for i in 0..display_count as usize {
|
for i in 0..display_count as usize {
|
||||||
monitors.push_back(MonitorID(active_displays[i]));
|
monitors.push_back(MonitorId(active_displays[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
monitors
|
monitors
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorId {
|
||||||
let id = unsafe {
|
let id = unsafe {
|
||||||
MonitorID(display::CGMainDisplayID())
|
MonitorId(display::CGMainDisplayID())
|
||||||
};
|
};
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorId {
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
let MonitorID(display_id) = *self;
|
let MonitorId(display_id) = *self;
|
||||||
let screen_num = unsafe {
|
let screen_num = unsafe {
|
||||||
display::CGDisplayModelNumber(display_id)
|
display::CGDisplayModelNumber(display_id)
|
||||||
};
|
};
|
||||||
|
@ -40,12 +40,12 @@ impl MonitorID {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
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) {
|
||||||
let MonitorID(display_id) = *self;
|
let MonitorId(display_id) = *self;
|
||||||
let dimension = unsafe {
|
let dimension = unsafe {
|
||||||
let height = display::CGDisplayPixelsHigh(display_id);
|
let height = display::CGDisplayPixelsHigh(display_id);
|
||||||
let width = display::CGDisplayPixelsWide(display_id);
|
let width = display::CGDisplayPixelsWide(display_id);
|
||||||
|
|
|
@ -52,21 +52,21 @@ impl WindowProxy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct MonitorID;
|
pub struct MonitorId;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorId> {
|
||||||
let mut list = VecDeque::new();
|
let mut list = VecDeque::new();
|
||||||
list.push_back(MonitorID);
|
list.push_back(MonitorId);
|
||||||
list
|
list
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorId {
|
||||||
MonitorID
|
MonitorId
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorId {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
Some("Canvas".to_owned())
|
Some("Canvas".to_owned())
|
||||||
|
|
|
@ -105,7 +105,7 @@ use self::ffi::{
|
||||||
static mut jmpbuf: [libc::c_int;27] = [0;27];
|
static mut jmpbuf: [libc::c_int;27] = [0;27];
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MonitorID;
|
pub struct MonitorId;
|
||||||
|
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
eagl_context: id,
|
eagl_context: id,
|
||||||
|
@ -149,18 +149,18 @@ impl DelegateState {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorId> {
|
||||||
let mut rb = VecDeque::new();
|
let mut rb = VecDeque::new();
|
||||||
rb.push_back(MonitorID);
|
rb.push_back(MonitorId);
|
||||||
rb
|
rb
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorId {
|
||||||
MonitorID
|
MonitorId
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorId {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
Some("Primary".to_string())
|
Some("Primary".to_string())
|
||||||
|
|
|
@ -29,7 +29,7 @@ use std::ops::{Deref, DerefMut};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
|
|
||||||
use platform::MonitorID as PlatformMonitorID;
|
use platform::MonitorId as PlatformMonitorId;
|
||||||
|
|
||||||
use self::context::WaylandContext;
|
use self::context::WaylandContext;
|
||||||
|
|
||||||
|
@ -166,25 +166,25 @@ impl WindowProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MonitorID {
|
pub struct MonitorId {
|
||||||
output: Arc<Output>
|
output: Arc<Output>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorId> {
|
||||||
WAYLAND_CONTEXT.as_ref().unwrap().outputs.iter().map(|o| MonitorID::new(o.clone())).collect()
|
WAYLAND_CONTEXT.as_ref().unwrap().outputs.iter().map(|o| MonitorId::new(o.clone())).collect()
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorId {
|
||||||
match WAYLAND_CONTEXT.as_ref().unwrap().outputs.iter().next() {
|
match WAYLAND_CONTEXT.as_ref().unwrap().outputs.iter().next() {
|
||||||
Some(o) => MonitorID::new(o.clone()),
|
Some(o) => MonitorId::new(o.clone()),
|
||||||
None => panic!("No monitor is available.")
|
None => panic!("No monitor is available.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorId {
|
||||||
fn new(output: Arc<Output>) -> MonitorID {
|
fn new(output: Arc<Output>) -> MonitorId {
|
||||||
MonitorID {
|
MonitorId {
|
||||||
output: output
|
output: output
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ impl Window {
|
||||||
h as i32
|
h as i32
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut shell_window = if let Some(PlatformMonitorID::Wayland(ref monitor)) = window.monitor {
|
let mut shell_window = if let Some(PlatformMonitorId::Wayland(ref monitor)) = window.monitor {
|
||||||
let shell_surface = wayland_context.shell.get_shell_surface(surface);
|
let shell_surface = wayland_context.shell.get_shell_surface(surface);
|
||||||
shell_surface.set_fullscreen(ShellFullscreenMethod::Default, Some(&monitor.output));
|
shell_surface.set_fullscreen(ShellFullscreenMethod::Default, Some(&monitor.output));
|
||||||
ShellWindow::Plain(shell_surface)
|
ShellWindow::Plain(shell_surface)
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::thread;
|
||||||
|
|
||||||
use super::callback;
|
use super::callback;
|
||||||
use super::Window;
|
use super::Window;
|
||||||
use super::MonitorID;
|
use super::MonitorId;
|
||||||
use super::WindowWrapper;
|
use super::WindowWrapper;
|
||||||
use super::Context;
|
use super::Context;
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ unsafe fn register_window_class() -> Vec<u16> {
|
||||||
class_name
|
class_name
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn switch_to_fullscreen(rect: &mut winapi::RECT, monitor: &MonitorID)
|
unsafe fn switch_to_fullscreen(rect: &mut winapi::RECT, monitor: &MonitorId)
|
||||||
-> Result<(), CreationError>
|
-> Result<(), CreationError>
|
||||||
{
|
{
|
||||||
// adjusting the rect
|
// adjusting the rect
|
||||||
|
|
|
@ -21,7 +21,7 @@ use PixelFormat;
|
||||||
use PixelFormatRequirements;
|
use PixelFormatRequirements;
|
||||||
use WindowAttributes;
|
use WindowAttributes;
|
||||||
|
|
||||||
pub use self::monitor::{MonitorID, get_available_monitors, get_primary_monitor};
|
pub use self::monitor::{MonitorId, get_available_monitors, get_primary_monitor};
|
||||||
|
|
||||||
use winapi;
|
use winapi;
|
||||||
use user32;
|
use user32;
|
||||||
|
|
|
@ -6,9 +6,9 @@ use std::mem;
|
||||||
|
|
||||||
use native_monitor::NativeMonitorId;
|
use native_monitor::NativeMonitorId;
|
||||||
|
|
||||||
/// Win32 implementation of the main `MonitorID` object.
|
/// Win32 implementation of the main `MonitorId` object.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MonitorID {
|
pub struct MonitorId {
|
||||||
/// The system name of the adapter.
|
/// The system name of the adapter.
|
||||||
adapter_name: [winapi::WCHAR; 32],
|
adapter_name: [winapi::WCHAR; 32],
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ fn wchar_as_string(wchar: &[winapi::WCHAR]) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Win32 implementation of the main `get_available_monitors` function.
|
/// Win32 implementation of the main `get_available_monitors` function.
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorId> {
|
||||||
// return value
|
// return value
|
||||||
let mut result = VecDeque::new();
|
let mut result = VecDeque::new();
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
|
|
||||||
for (num, monitor) in DeviceEnumerator::monitors(adapter.DeviceName.as_ptr()).enumerate() {
|
for (num, monitor) in DeviceEnumerator::monitors(adapter.DeviceName.as_ptr()).enumerate() {
|
||||||
// adding to the resulting list
|
// adding to the resulting list
|
||||||
result.push_back(MonitorID {
|
result.push_back(MonitorId {
|
||||||
adapter_name: adapter.DeviceName,
|
adapter_name: adapter.DeviceName,
|
||||||
monitor_name: wchar_as_string(&monitor.DeviceName),
|
monitor_name: wchar_as_string(&monitor.DeviceName),
|
||||||
readable_name: wchar_as_string(&monitor.DeviceString),
|
readable_name: wchar_as_string(&monitor.DeviceString),
|
||||||
|
@ -136,7 +136,7 @@ pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Win32 implementation of the main `get_primary_monitor` function.
|
/// Win32 implementation of the main `get_primary_monitor` function.
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorId {
|
||||||
// we simply get all available monitors and return the one with the `PRIMARY_DEVICE` flag
|
// we simply get all available monitors and return the one with the `PRIMARY_DEVICE` flag
|
||||||
// TODO: it is possible to query the win32 API for the primary monitor, this should be done
|
// TODO: it is possible to query the win32 API for the primary monitor, this should be done
|
||||||
// instead
|
// instead
|
||||||
|
@ -149,7 +149,7 @@ pub fn get_primary_monitor() -> MonitorID {
|
||||||
panic!("Failed to find the primary monitor")
|
panic!("Failed to find the primary monitor")
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorId {
|
||||||
/// See the docs if the crate root file.
|
/// See the docs if the crate root file.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
|
@ -169,14 +169,14 @@ impl MonitorID {
|
||||||
self.dimensions
|
self.dimensions
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is a Win32-only function for `MonitorID` that returns the system name of the adapter
|
/// This is a Win32-only function for `MonitorId` that returns the system name of the adapter
|
||||||
/// device.
|
/// device.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_adapter_name(&self) -> &[winapi::WCHAR] {
|
pub fn get_adapter_name(&self) -> &[winapi::WCHAR] {
|
||||||
&self.adapter_name
|
&self.adapter_name
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is a Win32-only function for `MonitorID` that returns the position of the
|
/// This is a Win32-only function for `MonitorId` that returns the position of the
|
||||||
/// monitor on the desktop.
|
/// monitor on the desktop.
|
||||||
/// A window that is positionned at these coordinates will overlap the monitor.
|
/// A window that is positionned at these coordinates will overlap the monitor.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#![cfg(all(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"), feature = "window"))]
|
#![cfg(all(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"), feature = "window"))]
|
||||||
|
|
||||||
pub use self::monitor::{MonitorID, get_available_monitors, get_primary_monitor};
|
pub use self::monitor::{MonitorId, get_available_monitors, get_primary_monitor};
|
||||||
pub use self::window::{Window, XWindow, PollEventsIterator, WaitEventsIterator, Context, WindowProxy};
|
pub use self::window::{Window, XWindow, PollEventsIterator, WaitEventsIterator, Context, WindowProxy};
|
||||||
pub use self::xdisplay::{XConnection, XNotSupported};
|
pub use self::xdisplay::{XConnection, XNotSupported};
|
||||||
|
|
||||||
|
|
|
@ -5,25 +5,25 @@ use super::XConnection;
|
||||||
use native_monitor::NativeMonitorId;
|
use native_monitor::NativeMonitorId;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MonitorID(pub Arc<XConnection>, pub u32);
|
pub struct MonitorId(pub Arc<XConnection>, pub u32);
|
||||||
|
|
||||||
pub fn get_available_monitors(x: &Arc<XConnection>) -> VecDeque<MonitorID> {
|
pub fn get_available_monitors(x: &Arc<XConnection>) -> VecDeque<MonitorId> {
|
||||||
let nb_monitors = unsafe { (x.xlib.XScreenCount)(x.display) };
|
let nb_monitors = unsafe { (x.xlib.XScreenCount)(x.display) };
|
||||||
|
|
||||||
let mut monitors = VecDeque::new();
|
let mut monitors = VecDeque::new();
|
||||||
monitors.extend((0 .. nb_monitors).map(|i| MonitorID(x.clone(), i as u32)));
|
monitors.extend((0 .. nb_monitors).map(|i| MonitorId(x.clone(), i as u32)));
|
||||||
monitors
|
monitors
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_primary_monitor(x: &Arc<XConnection>) -> MonitorID {
|
pub fn get_primary_monitor(x: &Arc<XConnection>) -> MonitorId {
|
||||||
let primary_monitor = unsafe { (x.xlib.XDefaultScreen)(x.display) };
|
let primary_monitor = unsafe { (x.xlib.XDefaultScreen)(x.display) };
|
||||||
MonitorID(x.clone(), primary_monitor as u32)
|
MonitorId(x.clone(), primary_monitor as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorId {
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
let MonitorID(_, screen_num) = *self;
|
let MonitorId(_, screen_num) = *self;
|
||||||
Some(format!("Monitor #{}", screen_num))
|
Some(format!("Monitor #{}", screen_num))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,11 @@ use api::glx::Context as GlxContext;
|
||||||
use api::egl;
|
use api::egl;
|
||||||
use api::egl::Context as EglContext;
|
use api::egl::Context as EglContext;
|
||||||
|
|
||||||
use platform::MonitorID as PlatformMonitorID;
|
use platform::MonitorId as PlatformMonitorId;
|
||||||
|
|
||||||
use super::input::XInputEventHandler;
|
use super::input::XInputEventHandler;
|
||||||
use super::{ffi};
|
use super::{ffi};
|
||||||
use super::{MonitorID, XConnection};
|
use super::{MonitorId, XConnection};
|
||||||
|
|
||||||
// XOpenIM doesn't seem to be thread-safe
|
// XOpenIM doesn't seem to be thread-safe
|
||||||
lazy_static! { // TODO: use a static mutex when that's possible, and put me back in my function
|
lazy_static! { // TODO: use a static mutex when that's possible, and put me back in my function
|
||||||
|
@ -305,7 +305,7 @@ impl Window {
|
||||||
let dimensions = window_attrs.dimensions.unwrap_or((800, 600));
|
let dimensions = window_attrs.dimensions.unwrap_or((800, 600));
|
||||||
|
|
||||||
let screen_id = match window_attrs.monitor {
|
let screen_id = match window_attrs.monitor {
|
||||||
Some(PlatformMonitorID::X(MonitorID(_, monitor))) => monitor as i32,
|
Some(PlatformMonitorId::X(MonitorId(_, monitor))) => monitor as i32,
|
||||||
_ => unsafe { (display.xlib.XDefaultScreen)(display.display) },
|
_ => unsafe { (display.xlib.XDefaultScreen)(display.display) },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ 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, MonitorID, get_available_monitors, get_primary_monitor};
|
pub use window::{AvailableMonitorsIter, MonitorId, get_available_monitors, get_primary_monitor};
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
pub use native_monitor::NativeMonitorId;
|
pub use native_monitor::NativeMonitorId;
|
||||||
|
|
||||||
|
@ -504,7 +504,7 @@ pub struct WindowAttributes {
|
||||||
/// If `Some`, the window will be in fullscreen mode with the given monitor.
|
/// If `Some`, the window will be in fullscreen mode with the given monitor.
|
||||||
///
|
///
|
||||||
/// The default is `None`.
|
/// The default is `None`.
|
||||||
pub monitor: Option<platform::MonitorID>,
|
pub monitor: Option<platform::MonitorId>,
|
||||||
|
|
||||||
/// The title of the window in the title bar.
|
/// The title of the window in the title bar.
|
||||||
///
|
///
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use ContextError;
|
use ContextError;
|
||||||
use GlContext;
|
use GlContext;
|
||||||
|
|
||||||
pub use api::emscripten::{Window, WindowProxy, MonitorID, get_available_monitors};
|
pub use api::emscripten::{Window, WindowProxy, MonitorId, get_available_monitors};
|
||||||
pub use api::emscripten::{get_primary_monitor, WaitEventsIterator, PollEventsIterator};
|
pub use api::emscripten::{get_primary_monitor, WaitEventsIterator, PollEventsIterator};
|
||||||
|
|
||||||
pub struct HeadlessContext(Window);
|
pub struct HeadlessContext(Window);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*#[cfg(feature = "window")]
|
/*#[cfg(feature = "window")]
|
||||||
pub use api::x11::{Window, WindowProxy, MonitorID, get_available_monitors, get_primary_monitor};
|
pub use api::x11::{Window, WindowProxy, MonitorId, get_available_monitors, get_primary_monitor};
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
pub use api::x11::{WaitEventsIterator, PollEventsIterator};*/
|
pub use api::x11::{WaitEventsIterator, PollEventsIterator};*/
|
||||||
|
|
||||||
|
@ -69,64 +69,64 @@ impl WindowProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum MonitorID {
|
pub enum MonitorId {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
X(x11::MonitorID),
|
X(x11::MonitorId),
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
Wayland(wayland::MonitorID),
|
Wayland(wayland::MonitorId),
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorId> {
|
||||||
match *BACKEND {
|
match *BACKEND {
|
||||||
Backend::Wayland => wayland::get_available_monitors()
|
Backend::Wayland => wayland::get_available_monitors()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(MonitorID::Wayland)
|
.map(MonitorId::Wayland)
|
||||||
.collect(),
|
.collect(),
|
||||||
Backend::X(ref connec) => x11::get_available_monitors(connec)
|
Backend::X(ref connec) => x11::get_available_monitors(connec)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(MonitorID::X)
|
.map(MonitorId::X)
|
||||||
.collect(),
|
.collect(),
|
||||||
Backend::Error(_) => { let mut d = VecDeque::new(); d.push_back(MonitorID::None); d},
|
Backend::Error(_) => { let mut d = VecDeque::new(); d.push_back(MonitorId::None); d},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorId {
|
||||||
match *BACKEND {
|
match *BACKEND {
|
||||||
Backend::Wayland => MonitorID::Wayland(wayland::get_primary_monitor()),
|
Backend::Wayland => MonitorId::Wayland(wayland::get_primary_monitor()),
|
||||||
Backend::X(ref connec) => MonitorID::X(x11::get_primary_monitor(connec)),
|
Backend::X(ref connec) => MonitorId::X(x11::get_primary_monitor(connec)),
|
||||||
Backend::Error(_) => MonitorID::None,
|
Backend::Error(_) => MonitorId::None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorId {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
match self {
|
match self {
|
||||||
&MonitorID::X(ref m) => m.get_name(),
|
&MonitorId::X(ref m) => m.get_name(),
|
||||||
&MonitorID::Wayland(ref m) => m.get_name(),
|
&MonitorId::Wayland(ref m) => m.get_name(),
|
||||||
&MonitorID::None => None,
|
&MonitorId::None => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId {
|
pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId {
|
||||||
match self {
|
match self {
|
||||||
&MonitorID::X(ref m) => m.get_native_identifier(),
|
&MonitorId::X(ref m) => m.get_native_identifier(),
|
||||||
&MonitorID::Wayland(ref m) => m.get_native_identifier(),
|
&MonitorId::Wayland(ref m) => m.get_native_identifier(),
|
||||||
&MonitorID::None => unimplemented!() // FIXME:
|
&MonitorId::None => unimplemented!() // FIXME:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
match self {
|
match self {
|
||||||
&MonitorID::X(ref m) => m.get_dimensions(),
|
&MonitorId::X(ref m) => m.get_dimensions(),
|
||||||
&MonitorID::Wayland(ref m) => m.get_dimensions(),
|
&MonitorId::Wayland(ref m) => m.get_dimensions(),
|
||||||
&MonitorID::None => (800, 600), // FIXME:
|
&MonitorId::None => (800, 600), // FIXME:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use libc;
|
||||||
use api::osmesa::{self, OsMesaContext};
|
use api::osmesa::{self, OsMesaContext};
|
||||||
|
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
pub use self::api_dispatch::{Window, WindowProxy, MonitorID, get_available_monitors, get_primary_monitor};
|
pub use self::api_dispatch::{Window, WindowProxy, MonitorId, get_available_monitors, get_primary_monitor};
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
pub use self::api_dispatch::{WaitEventsIterator, PollEventsIterator};
|
pub use self::api_dispatch::{WaitEventsIterator, PollEventsIterator};
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
|
@ -21,7 +21,7 @@ mod api_dispatch;
|
||||||
#[cfg(not(feature = "window"))]
|
#[cfg(not(feature = "window"))]
|
||||||
pub type Window = (); // TODO: hack to make things work
|
pub type Window = (); // TODO: hack to make things work
|
||||||
#[cfg(not(feature = "window"))]
|
#[cfg(not(feature = "window"))]
|
||||||
pub type MonitorID = (); // TODO: hack to make things work
|
pub type MonitorId = (); // TODO: hack to make things work
|
||||||
|
|
||||||
pub struct HeadlessContext(OsMesaContext);
|
pub struct HeadlessContext(OsMesaContext);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#![cfg(target_os = "windows")]
|
#![cfg(target_os = "windows")]
|
||||||
|
|
||||||
pub use api::win32;
|
pub use api::win32;
|
||||||
pub use api::win32::{MonitorID, get_available_monitors, get_primary_monitor};
|
pub use api::win32::{MonitorId, get_available_monitors, get_primary_monitor};
|
||||||
pub use api::win32::{WindowProxy, PollEventsIterator, WaitEventsIterator};
|
pub use api::win32::{WindowProxy, PollEventsIterator, WaitEventsIterator};
|
||||||
|
|
||||||
use libc;
|
use libc;
|
||||||
|
|
|
@ -65,8 +65,8 @@ impl<'a> WindowBuilder<'a> {
|
||||||
///
|
///
|
||||||
/// If you don't specify dimensions for the window, it will match the monitor's.
|
/// If you don't specify dimensions for the window, it will match the monitor's.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with_fullscreen(mut self, monitor: MonitorID) -> WindowBuilder<'a> {
|
pub fn with_fullscreen(mut self, monitor: MonitorId) -> WindowBuilder<'a> {
|
||||||
let MonitorID(monitor) = monitor;
|
let MonitorId(monitor) = monitor;
|
||||||
self.window.monitor = Some(monitor);
|
self.window.monitor = Some(monitor);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -611,15 +611,15 @@ impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||||
// Implementation note: we retreive the list once, then serve each element by one by one.
|
// Implementation note: we retreive the list once, then serve each element by one by one.
|
||||||
// This may change in the future.
|
// This may change in the future.
|
||||||
pub struct AvailableMonitorsIter {
|
pub struct AvailableMonitorsIter {
|
||||||
data: VecDequeIter<platform::MonitorID>,
|
data: VecDequeIter<platform::MonitorId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Iterator for AvailableMonitorsIter {
|
impl Iterator for AvailableMonitorsIter {
|
||||||
type Item = MonitorID;
|
type Item = MonitorId;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn next(&mut self) -> Option<MonitorID> {
|
fn next(&mut self) -> Option<MonitorId> {
|
||||||
self.data.next().map(|id| MonitorID(id))
|
self.data.next().map(|id| MonitorId(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -637,32 +637,32 @@ pub fn get_available_monitors() -> AvailableMonitorsIter {
|
||||||
|
|
||||||
/// Returns the primary monitor of the system.
|
/// Returns the primary monitor of the system.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorId {
|
||||||
MonitorID(platform::get_primary_monitor())
|
MonitorId(platform::get_primary_monitor())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Identifier for a monitor.
|
/// Identifier for a monitor.
|
||||||
pub struct MonitorID(platform::MonitorID);
|
pub struct MonitorId(platform::MonitorId);
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorId {
|
||||||
/// Returns a human-readable name of the monitor.
|
/// Returns a human-readable name of the monitor.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
let &MonitorID(ref id) = self;
|
let &MonitorId(ref id) = self;
|
||||||
id.get_name()
|
id.get_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the native platform identifier for this monitor.
|
/// Returns the native platform identifier for this monitor.
|
||||||
#[inline]
|
#[inline]
|
||||||
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()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the number of pixels currently displayed on the monitor.
|
/// Returns the number of pixels currently displayed on the monitor.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
let &MonitorID(ref id) = self;
|
let &MonitorId(ref id) = self;
|
||||||
id.get_dimensions()
|
id.get_dimensions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue