mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 15:13:13 -04:00
This is a follow up to the new API introduced in #20. This also fixes the issue where window resize events would not be emitted until the end of the resize. This PR fixese #39 by ensuring that the user callback given to either `EventsLoop::poll_events` or `EventsLoop::run_forever` can be called by each window delegate's resize callback directly.
38 lines
1.0 KiB
Rust
38 lines
1.0 KiB
Rust
#![cfg(target_os = "macos")]
|
|
|
|
pub use self::events_loop::EventsLoop;
|
|
pub use self::monitor::{MonitorId, get_available_monitors, get_primary_monitor};
|
|
pub use self::window::{Id as WindowId, PlatformSpecificWindowBuilderAttributes, Window};
|
|
|
|
use {CreationError};
|
|
|
|
pub struct Window2 {
|
|
pub window: ::std::sync::Arc<Window>,
|
|
}
|
|
|
|
impl ::std::ops::Deref for Window2 {
|
|
type Target = Window;
|
|
#[inline]
|
|
fn deref(&self) -> &Window {
|
|
&*self.window
|
|
}
|
|
}
|
|
|
|
impl Window2 {
|
|
|
|
pub fn new(events_loop: ::std::sync::Arc<EventsLoop>,
|
|
attributes: &::WindowAttributes,
|
|
pl_attribs: &PlatformSpecificWindowBuilderAttributes) -> Result<Self, CreationError>
|
|
{
|
|
let weak_events_loop = ::std::sync::Arc::downgrade(&events_loop);
|
|
let window = ::std::sync::Arc::new(try!(Window::new(weak_events_loop, attributes, pl_attribs)));
|
|
events_loop.windows.lock().unwrap().push(window.clone());
|
|
Ok(Window2 { window: window })
|
|
}
|
|
|
|
}
|
|
|
|
mod events_loop;
|
|
mod monitor;
|
|
mod window;
|