aboutsummaryrefslogtreecommitdiffstats
path: root/src/win32
diff options
context:
space:
mode:
Diffstat (limited to 'src/win32')
-rw-r--r--src/win32/init.rs8
-rw-r--r--src/win32/mod.rs8
-rw-r--r--src/win32/monitor.rs11
3 files changed, 21 insertions, 6 deletions
diff --git a/src/win32/init.rs b/src/win32/init.rs
index 743508e..5cdd6b8 100644
--- a/src/win32/init.rs
+++ b/src/win32/init.rs
@@ -203,16 +203,17 @@ unsafe fn init(title: Vec<u16>, builder: BuilderAttribs<'static>,
};
// calling SetPixelFormat
- {
+ let pixel_format = {
let formats = if extra_functions.GetPixelFormatAttribivARB.is_loaded() {
enumerate_arb_pixel_formats(&extra_functions, &real_window)
} else {
enumerate_native_pixel_formats(&real_window)
};
- let (id, _) = try!(builder.choose_pixel_format(formats.into_iter().map(|(a, b)| (b, a))));
+ let (id, f) = try!(builder.choose_pixel_format(formats.into_iter().map(|(a, b)| (b, a))));
try!(set_pixel_format(&real_window, id));
- }
+ f
+ };
// creating the OpenGL context
let context = try!(create_context(Some((&extra_functions, &builder)), &real_window,
@@ -263,6 +264,7 @@ unsafe fn init(title: Vec<u16>, builder: BuilderAttribs<'static>,
events_receiver: events_receiver,
is_closed: AtomicBool::new(false),
cursor_state: cursor_state,
+ pixel_format: pixel_format,
})
}
diff --git a/src/win32/mod.rs b/src/win32/mod.rs
index 1f5f3c0..4a9dcbf 100644
--- a/src/win32/mod.rs
+++ b/src/win32/mod.rs
@@ -13,6 +13,7 @@ use libc;
use {CreationError, Event, MouseCursor};
use CursorState;
+use PixelFormat;
use BuilderAttribs;
pub use self::headless::HeadlessContext;
@@ -53,6 +54,9 @@ pub struct Window {
/// The current cursor state.
cursor_state: Arc<Mutex<CursorState>>,
+
+ /// The pixel format that has been used to create this window.
+ pixel_format: PixelFormat,
}
unsafe impl Send for Window {}
@@ -258,6 +262,10 @@ impl Window {
::Api::OpenGl
}
+ pub fn get_pixel_format(&self) -> PixelFormat {
+ self.pixel_format.clone()
+ }
+
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
}
diff --git a/src/win32/monitor.rs b/src/win32/monitor.rs
index 886d0bf..4b592cb 100644
--- a/src/win32/monitor.rs
+++ b/src/win32/monitor.rs
@@ -21,6 +21,9 @@ pub struct MonitorID {
/// http://msdn.microsoft.com/en-us/library/dd183569(v=vs.85).aspx
flags: winapi::DWORD,
+ /// True if this is the primary monitor.
+ primary: bool,
+
/// The position of the monitor in pixels on the desktop.
///
/// A window that is positionned at these coordinates will overlap the monitor.
@@ -114,13 +117,15 @@ pub fn get_available_monitors() -> VecDeque<MonitorID> {
(position, dimensions)
};
- for monitor in DeviceEnumerator::monitors(adapter.DeviceName.as_ptr()) {
+ for (num, monitor) in DeviceEnumerator::monitors(adapter.DeviceName.as_ptr()).enumerate() {
// adding to the resulting list
result.push_back(MonitorID {
adapter_name: adapter.DeviceName,
monitor_name: wchar_as_string(&monitor.DeviceName),
readable_name: wchar_as_string(&monitor.DeviceString),
flags: monitor.StateFlags,
+ primary: (adapter.StateFlags & winapi::DISPLAY_DEVICE_PRIMARY_DEVICE) != 0 &&
+ num == 0,
position: position,
dimensions: dimensions,
});
@@ -135,8 +140,8 @@ pub fn get_primary_monitor() -> MonitorID {
// TODO: it is possible to query the win32 API for the primary monitor, this should be done
// instead
for monitor in get_available_monitors().into_iter() {
- if (monitor.flags & winapi::DISPLAY_DEVICE_PRIMARY_DEVICE) != 0 {
- return monitor
+ if monitor.primary {
+ return monitor;
}
}