X11: Fix get_current_monitor (#515)

* X11: Fix get_current_monitor

Fixes #64

* impl Debug for MonitorId on all platforms
This commit is contained in:
Francesca Frangipane 2018-05-14 08:14:57 -04:00 committed by GitHub
parent 15a4fec3d9
commit d86f53a02c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 417 additions and 145 deletions

View file

@ -3,6 +3,7 @@ use cocoa::base::{id, nil};
use cocoa::foundation::{NSString, NSUInteger};
use core_graphics::display::{CGDirectDisplayID, CGDisplay};
use std::collections::VecDeque;
use std::fmt;
use super::EventsLoop;
use super::window::IdRef;
@ -32,6 +33,29 @@ impl EventsLoop {
}
}
impl fmt::Debug for MonitorId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
#[derive(Debug)]
struct MonitorId {
name: Option<String>,
native_identifier: u32,
dimensions: (u32, u32),
position: &'static str,
hidpi_factor: f32,
}
let monitor_id_proxy = MonitorId {
name: self.get_name(),
native_identifier: self.get_native_identifier(),
dimensions: self.get_dimensions(),
position: "WARNING: `MonitorId::get_position` is unimplemented on macOS!",
hidpi_factor: self.get_hidpi_factor(),
};
monitor_id_proxy.fmt(f)
}
}
impl MonitorId {
pub fn get_name(&self) -> Option<String> {
let MonitorId(display_id) = *self;