Get the monitors attached to the display, and their resolution for X11
This commit is contained in:
parent
bd3b06e1a5
commit
ac74db979c
3 changed files with 63 additions and 23 deletions
|
|
@ -3,8 +3,11 @@ use libc;
|
|||
use std::{mem, ptr};
|
||||
use std::sync::atomics::AtomicBool;
|
||||
|
||||
pub use self::monitor::{MonitorID, get_available_monitors, get_primary_monitor};
|
||||
|
||||
mod events;
|
||||
mod ffi;
|
||||
mod monitor;
|
||||
|
||||
pub struct Window {
|
||||
display: *mut ffi::Display,
|
||||
|
|
@ -19,28 +22,6 @@ pub struct Window {
|
|||
is_fullscreen: bool,
|
||||
}
|
||||
|
||||
pub struct MonitorID(uint);
|
||||
|
||||
pub fn get_available_monitors() -> Vec<MonitorID> {
|
||||
vec![get_primary_monitor()]
|
||||
}
|
||||
|
||||
pub fn get_primary_monitor() -> MonitorID {
|
||||
MonitorID(0u)
|
||||
}
|
||||
|
||||
impl MonitorID {
|
||||
pub fn get_name(&self) -> Option<String> {
|
||||
Some("<Unknown>".to_string())
|
||||
}
|
||||
|
||||
pub fn get_dimensions(&self) -> (uint, uint) {
|
||||
//unimplemented!()
|
||||
// TODO: Get the real dimensions from the monitor
|
||||
(1024, 768)
|
||||
}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
pub fn new(builder: WindowBuilder) -> Result<Window, String> {
|
||||
let dimensions = builder.dimensions.unwrap_or((800, 600));
|
||||
|
|
@ -159,7 +140,7 @@ impl Window {
|
|||
|
||||
// finally creating the window
|
||||
let window = unsafe {
|
||||
let win = ffi::XCreateWindow(display, root, 50, 50, dimensions.val0() as libc::c_uint,
|
||||
let win = ffi::XCreateWindow(display, root, 0, 0, dimensions.val0() as libc::c_uint,
|
||||
dimensions.val1() as libc::c_uint, 0, visual_infos.depth, ffi::InputOutput,
|
||||
visual_infos.visual, window_attributes,
|
||||
&mut set_win_attr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue