aboutsummaryrefslogtreecommitdiffstats
path: root/src/win32/mod.rs
diff options
context:
space:
mode:
authorTomaka17 <pierre.krieger1708@gmail.com>2014-07-31 10:52:05 +0200
committerTomaka17 <pierre.krieger1708@gmail.com>2014-07-31 11:13:40 +0200
commitd9d293667a7b5934ba923f578ffbfd2c12d121be (patch)
tree6ac0c7ed6bb98b8eeda249141afac0928fdd0cec /src/win32/mod.rs
parentdb8955a9d85d7e44e63dd3fd7634230bc1aed635 (diff)
downloadglutin-d9d293667a7b5934ba923f578ffbfd2c12d121be.tar.gz
glutin-d9d293667a7b5934ba923f578ffbfd2c12d121be.zip
Add monitor support for win32
Diffstat (limited to 'src/win32/mod.rs')
-rw-r--r--src/win32/mod.rs28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/win32/mod.rs b/src/win32/mod.rs
index 232f0e5..0cb8ac9 100644
--- a/src/win32/mod.rs
+++ b/src/win32/mod.rs
@@ -4,8 +4,11 @@ use std::sync::atomics::AtomicBool;
use std::ptr;
use {Event, Hints};
+pub use self::monitor::{MonitorID, get_available_monitors, get_primary_monitor};
+
mod event;
mod ffi;
+mod monitor;
pub struct Window {
window: ffi::HWND,
@@ -17,16 +20,6 @@ pub struct Window {
nosend: NoSend,
}
-pub struct MonitorID(uint);
-
-pub fn get_available_monitors() -> Vec<MonitorID> {
- unimplemented!()
-}
-
-pub fn get_primary_monitor() -> MonitorID {
- unimplemented!()
-}
-
/// Stores the list of all the windows.
/// Only available on callback thread.
local_data_key!(pub WINDOWS_LIST: Mutex<Vec<(ffi::HWND, Sender<Event>)>>)
@@ -78,6 +71,18 @@ impl Window {
// switching to fullscreen
if monitor.is_some() {
+ let monitor = monitor.as_ref().unwrap();
+
+ // adjusting the rect
+ {
+ let pos = monitor.get_position();
+ rect.left += pos.val0() as ffi::LONG;
+ rect.right += pos.val0() as ffi::LONG;
+ rect.top += pos.val1() as ffi::LONG;
+ rect.bottom += pos.val1() as ffi::LONG;
+ }
+
+ // changing device settings
let mut screen_settings: ffi::DEVMODE = unsafe { mem::zeroed() };
screen_settings.dmSize = mem::size_of::<ffi::DEVMODE>() as ffi::WORD;
screen_settings.dmPelsWidth = 1024;
@@ -85,7 +90,8 @@ impl Window {
screen_settings.dmBitsPerPel = 32;
screen_settings.dmFields = ffi::DM_BITSPERPEL | ffi::DM_PELSWIDTH | ffi::DM_PELSHEIGHT;
- let result = unsafe { ffi::ChangeDisplaySettingsW(&mut screen_settings, ffi::CDS_FULLSCREEN) };
+ let result = unsafe { ffi::ChangeDisplaySettingsExW(monitor.get_system_name().as_ptr(),
+ &mut screen_settings, ptr::mut_null(), ffi::CDS_FULLSCREEN, ptr::mut_null()) };
if result != ffi::DISP_CHANGE_SUCCESSFUL {
return Err(format!("ChangeDisplaySettings failed: {}", result))
}