mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Merge branch 'master' of http://github.com/tomaka/gl-init-rs
This commit is contained in:
commit
2e44edea60
10
Cargo.toml
10
Cargo.toml
|
@ -25,7 +25,13 @@ git = "https://github.com/DavidPartouche/rust-cocoa"
|
||||||
git = "https://github.com/DavidPartouche/rust-cocoa"
|
git = "https://github.com/DavidPartouche/rust-cocoa"
|
||||||
|
|
||||||
[target.i686-apple-darwin.dependencies.core_foundation]
|
[target.i686-apple-darwin.dependencies.core_foundation]
|
||||||
git = "https://github.com/servo/rust-core-foundation"
|
git = "https://github.com/DavidPartouche/rust-core-foundation"
|
||||||
|
|
||||||
[target.x86_64-apple-darwin.dependencies.core_foundation]
|
[target.x86_64-apple-darwin.dependencies.core_foundation]
|
||||||
git = "https://github.com/servo/rust-core-foundation"
|
git = "https://github.com/DavidPartouche/rust-core-foundation"
|
||||||
|
|
||||||
|
[target.i686-apple-darwin.dependencies.core_graphics]
|
||||||
|
git = "https://github.com/DavidPartouche/rust-core-graphics"
|
||||||
|
|
||||||
|
[target.x86_64-apple-darwin.dependencies.core_graphics]
|
||||||
|
git = "https://github.com/DavidPartouche/rust-core-graphics"
|
||||||
|
|
|
@ -125,6 +125,12 @@ impl Window {
|
||||||
pub fn set_title(&self, _: &str) {
|
pub fn set_title(&self, _: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn show(&self) {
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn hide(&self) {
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_position(&self) -> Option<(int, int)> {
|
pub fn get_position(&self) -> Option<(int, int)> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
32
src/lib.rs
32
src/lib.rs
|
@ -37,6 +37,8 @@ extern crate libc;
|
||||||
extern crate cocoa;
|
extern crate cocoa;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
extern crate core_foundation;
|
extern crate core_foundation;
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
extern crate core_graphics;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
extern crate sync;
|
extern crate sync;
|
||||||
|
|
||||||
|
@ -74,6 +76,7 @@ pub struct WindowBuilder {
|
||||||
monitor: Option<winimpl::MonitorID>,
|
monitor: Option<winimpl::MonitorID>,
|
||||||
gl_version: Option<(uint, uint)>,
|
gl_version: Option<(uint, uint)>,
|
||||||
vsync: bool,
|
vsync: bool,
|
||||||
|
visible: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
|
@ -86,6 +89,7 @@ impl WindowBuilder {
|
||||||
monitor: None,
|
monitor: None,
|
||||||
gl_version: None,
|
gl_version: None,
|
||||||
vsync: false,
|
vsync: false,
|
||||||
|
visible: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +131,12 @@ impl WindowBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets whether the window will be initially hidden or visible.
|
||||||
|
pub fn with_visibility(mut self, visible: bool) -> WindowBuilder {
|
||||||
|
self.visible = visible;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Builds the window.
|
/// Builds the window.
|
||||||
///
|
///
|
||||||
/// Error should be very rare and only occur in case of permission denied, incompatible system,
|
/// Error should be very rare and only occur in case of permission denied, incompatible system,
|
||||||
|
@ -252,6 +262,28 @@ impl Window {
|
||||||
self.window.set_title(title)
|
self.window.set_title(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Shows the window if it was hidden.
|
||||||
|
///
|
||||||
|
/// ## Platform-specific
|
||||||
|
///
|
||||||
|
/// - Has no effect on Android
|
||||||
|
///
|
||||||
|
#[inline]
|
||||||
|
pub fn show(&self) {
|
||||||
|
self.window.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Hides the window if it was visible.
|
||||||
|
///
|
||||||
|
/// ## Platform-specific
|
||||||
|
///
|
||||||
|
/// - Has no effect on Android
|
||||||
|
///
|
||||||
|
#[inline]
|
||||||
|
pub fn hide(&self) {
|
||||||
|
self.window.hide()
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the position of the top-left hand corner of the window relative to the
|
/// Returns the position of the top-left hand corner of the window relative to the
|
||||||
/// top-left hand corner of the desktop.
|
/// top-left hand corner of the desktop.
|
||||||
///
|
///
|
||||||
|
|
|
@ -22,6 +22,9 @@ use {MouseInput, Pressed, Released, LeftMouseButton, RightMouseButton, MouseMove
|
||||||
|
|
||||||
use events;
|
use events;
|
||||||
|
|
||||||
|
pub use self::monitor::{MonitorID, get_available_monitors, get_primary_monitor};
|
||||||
|
|
||||||
|
mod monitor;
|
||||||
mod event;
|
mod event;
|
||||||
|
|
||||||
static mut shift_pressed: bool = false;
|
static mut shift_pressed: bool = false;
|
||||||
|
@ -43,26 +46,6 @@ impl Deref<Window> for HeadlessContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct MonitorID;
|
|
||||||
|
|
||||||
pub fn get_available_monitors() -> Vec<MonitorID> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MonitorID {
|
|
||||||
pub fn get_name(&self) -> Option<String> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_dimensions(&self) -> (uint, uint) {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
impl Window {
|
impl Window {
|
||||||
pub fn new(builder: WindowBuilder) -> Result<Window, String> {
|
pub fn new(builder: WindowBuilder) -> Result<Window, String> {
|
||||||
|
@ -198,6 +181,12 @@ impl Window {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn show(&self) {
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn hide(&self) {
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_position(&self) -> Option<(int, int)> {
|
pub fn get_position(&self) -> Option<(int, int)> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
46
src/osx/monitor.rs
Normal file
46
src/osx/monitor.rs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
use core_graphics::display;
|
||||||
|
|
||||||
|
pub struct MonitorID(u32);
|
||||||
|
|
||||||
|
pub fn get_available_monitors() -> Vec<MonitorID> {
|
||||||
|
let mut monitors = Vec::new();
|
||||||
|
unsafe {
|
||||||
|
let max_displays = 10u32;
|
||||||
|
let mut active_displays = [0u32, ..10];
|
||||||
|
let mut display_count = 0;
|
||||||
|
display::CGGetActiveDisplayList(max_displays,
|
||||||
|
&mut active_displays[0],
|
||||||
|
&mut display_count);
|
||||||
|
for i in range(0u, display_count as uint) {
|
||||||
|
monitors.push(MonitorID(active_displays[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
monitors
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_primary_monitor() -> MonitorID {
|
||||||
|
let id = unsafe {
|
||||||
|
MonitorID(display::CGMainDisplayID())
|
||||||
|
};
|
||||||
|
id
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MonitorID {
|
||||||
|
pub fn get_name(&self) -> Option<String> {
|
||||||
|
let MonitorID(display_id) = *self;
|
||||||
|
let screen_num = unsafe {
|
||||||
|
display::CGDisplayModelNumber(display_id)
|
||||||
|
};
|
||||||
|
Some(format!("Monitor #{}", screen_num))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_dimensions(&self) -> (uint, uint) {
|
||||||
|
let MonitorID(display_id) = *self;
|
||||||
|
let dimension = unsafe {
|
||||||
|
let height = display::CGDisplayPixelsHigh(display_id);
|
||||||
|
let width = display::CGDisplayPixelsWide(display_id);
|
||||||
|
(width as uint, height as uint)
|
||||||
|
};
|
||||||
|
dimension
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,7 +17,7 @@ local_data_key!(WINDOW: (ffi::HWND, Sender<Event>))
|
||||||
pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: String,
|
pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: String,
|
||||||
builder_monitor: Option<super::MonitorID>,
|
builder_monitor: Option<super::MonitorID>,
|
||||||
builder_gl_version: Option<(uint, uint)>, builder_vsync: bool,
|
builder_gl_version: Option<(uint, uint)>, builder_vsync: bool,
|
||||||
builder_headless: bool) -> Result<Window, String>
|
builder_hidden: bool) -> Result<Window, String>
|
||||||
{
|
{
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::os;
|
use std::os;
|
||||||
|
@ -237,7 +237,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
||||||
(None, None)
|
(None, None)
|
||||||
};
|
};
|
||||||
|
|
||||||
let style = if builder_headless {
|
let style = if builder_hidden {
|
||||||
style
|
style
|
||||||
} else {
|
} else {
|
||||||
style | ffi::WS_VISIBLE
|
style | ffi::WS_VISIBLE
|
||||||
|
|
|
@ -68,8 +68,8 @@ pub struct Window {
|
||||||
impl Window {
|
impl Window {
|
||||||
/// See the docs in the crate root file.
|
/// See the docs in the crate root file.
|
||||||
pub fn new(builder: WindowBuilder) -> Result<Window, String> {
|
pub fn new(builder: WindowBuilder) -> Result<Window, String> {
|
||||||
let WindowBuilder { dimensions, title, monitor, gl_version, vsync } = builder;
|
let WindowBuilder { dimensions, title, monitor, gl_version, vsync, visible } = builder;
|
||||||
init::new_window(dimensions, title, monitor, gl_version, vsync, false)
|
init::new_window(dimensions, title, monitor, gl_version, vsync, !visible)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,6 +91,18 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn show(&self) {
|
||||||
|
unsafe {
|
||||||
|
ffi::ShowWindow(self.window, ffi::SW_SHOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn hide(&self) {
|
||||||
|
unsafe {
|
||||||
|
ffi::ShowWindow(self.window, ffi::SW_HIDE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// See the docs in the crate root file.
|
/// See the docs in the crate root file.
|
||||||
pub fn get_position(&self) -> Option<(int, int)> {
|
pub fn get_position(&self) -> Option<(int, int)> {
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
|
@ -295,6 +295,12 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn show(&self) {
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn hide(&self) {
|
||||||
|
}
|
||||||
|
|
||||||
fn get_geometry(&self) -> Option<(int, int, uint, uint)> {
|
fn get_geometry(&self) -> Option<(int, int, uint, uint)> {
|
||||||
unsafe {
|
unsafe {
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
Loading…
Reference in a new issue