Remove api_transition macro (#279)
* Remove api_transition macro * Rename Window2 to Window * Try fix X11 code
This commit is contained in:
parent
0ada6c15ea
commit
342d5d8587
13 changed files with 97 additions and 247 deletions
|
|
@ -4,7 +4,7 @@ use cocoa::appkit::{NSApplication, NSEvent, NSView, NSWindow};
|
|||
use events::{self, ElementState, Event, MouseButton, TouchPhase, WindowEvent, DeviceEvent, ModifiersState, KeyboardInput};
|
||||
use std::collections::VecDeque;
|
||||
use std::sync::{Arc, Mutex, Weak};
|
||||
use super::window::Window;
|
||||
use super::window::Window2;
|
||||
use std;
|
||||
use super::DeviceId;
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ pub struct EventsLoop {
|
|||
|
||||
// State shared between the `EventsLoop` and its registered windows.
|
||||
pub struct Shared {
|
||||
pub windows: Mutex<Vec<Weak<Window>>>,
|
||||
pub windows: Mutex<Vec<Weak<Window2>>>,
|
||||
pub pending_events: Mutex<VecDeque<Event>>,
|
||||
// The user event callback given via either of the `poll_events` or `run_forever` methods.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
pub use self::events_loop::{EventsLoop, Proxy as EventsLoopProxy};
|
||||
pub use self::monitor::MonitorId;
|
||||
pub use self::window::{Id as WindowId, PlatformSpecificWindowBuilderAttributes, Window};
|
||||
pub use self::window::{Id as WindowId, PlatformSpecificWindowBuilderAttributes, Window2};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
|
@ -10,29 +10,29 @@ pub struct DeviceId;
|
|||
|
||||
use {CreationError};
|
||||
|
||||
pub struct Window2 {
|
||||
pub window: Arc<Window>,
|
||||
pub struct Window {
|
||||
pub window: Arc<Window2>,
|
||||
}
|
||||
|
||||
impl ::std::ops::Deref for Window2 {
|
||||
type Target = Window;
|
||||
impl ::std::ops::Deref for Window {
|
||||
type Target = Window2;
|
||||
#[inline]
|
||||
fn deref(&self) -> &Window {
|
||||
fn deref(&self) -> &Window2 {
|
||||
&*self.window
|
||||
}
|
||||
}
|
||||
|
||||
impl Window2 {
|
||||
impl Window {
|
||||
|
||||
pub fn new(events_loop: &EventsLoop,
|
||||
attributes: &::WindowAttributes,
|
||||
pl_attribs: &PlatformSpecificWindowBuilderAttributes) -> Result<Self, CreationError>
|
||||
{
|
||||
let weak_shared = Arc::downgrade(&events_loop.shared);
|
||||
let window = Arc::new(try!(Window::new(weak_shared, attributes, pl_attribs)));
|
||||
let window = Arc::new(try!(Window2::new(weak_shared, attributes, pl_attribs)));
|
||||
let weak_window = Arc::downgrade(&window);
|
||||
events_loop.shared.windows.lock().unwrap().push(weak_window);
|
||||
Ok(Window2 { window: window })
|
||||
Ok(Window { window: window })
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,16 +256,16 @@ pub struct PlatformSpecificWindowBuilderAttributes {
|
|||
pub activation_policy: ActivationPolicy,
|
||||
}
|
||||
|
||||
pub struct Window {
|
||||
pub struct Window2 {
|
||||
pub view: IdRef,
|
||||
pub window: IdRef,
|
||||
pub delegate: WindowDelegate,
|
||||
}
|
||||
|
||||
unsafe impl Send for Window {}
|
||||
unsafe impl Sync for Window {}
|
||||
unsafe impl Send for Window2 {}
|
||||
unsafe impl Sync for Window2 {}
|
||||
|
||||
impl Drop for Window {
|
||||
impl Drop for Window2 {
|
||||
fn drop(&mut self) {
|
||||
// Remove this window from the `EventLoop`s list of windows.
|
||||
let id = self.id();
|
||||
|
|
@ -283,7 +283,7 @@ impl Drop for Window {
|
|||
}
|
||||
}
|
||||
|
||||
impl WindowExt for Window {
|
||||
impl WindowExt for Window2 {
|
||||
#[inline]
|
||||
fn get_nswindow(&self) -> *mut c_void {
|
||||
*self.window as *mut c_void
|
||||
|
|
@ -295,11 +295,11 @@ impl WindowExt for Window {
|
|||
}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
impl Window2 {
|
||||
pub fn new(shared: Weak<Shared>,
|
||||
win_attribs: &WindowAttributes,
|
||||
pl_attribs: &PlatformSpecificWindowBuilderAttributes)
|
||||
-> Result<Window, CreationError>
|
||||
-> Result<Window2, CreationError>
|
||||
{
|
||||
unsafe {
|
||||
if !msg_send![cocoa::base::class("NSThread"), isMainThread] {
|
||||
|
|
@ -307,17 +307,17 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
let app = match Window::create_app(pl_attribs.activation_policy) {
|
||||
let app = match Window2::create_app(pl_attribs.activation_policy) {
|
||||
Some(app) => app,
|
||||
None => { return Err(OsError(format!("Couldn't create NSApplication"))); },
|
||||
};
|
||||
|
||||
let window = match Window::create_window(win_attribs)
|
||||
let window = match Window2::create_window(win_attribs)
|
||||
{
|
||||
Some(window) => window,
|
||||
None => { return Err(OsError(format!("Couldn't create NSWindow"))); },
|
||||
};
|
||||
let view = match Window::create_view(*window) {
|
||||
let view = match Window2::create_view(*window) {
|
||||
Some(view) => view,
|
||||
None => { return Err(OsError(format!("Couldn't create NSView"))); },
|
||||
};
|
||||
|
|
@ -355,7 +355,7 @@ impl Window {
|
|||
shared: shared,
|
||||
};
|
||||
|
||||
let window = Window {
|
||||
let window = Window2 {
|
||||
view: view,
|
||||
window: window,
|
||||
delegate: WindowDelegate::new(ds),
|
||||
|
|
@ -422,11 +422,11 @@ impl Window {
|
|||
appkit::NSBorderlessWindowMask | appkit::NSResizableWindowMask |
|
||||
appkit::NSTitledWindowMask
|
||||
} else if attrs.decorations {
|
||||
// Window with a titlebar
|
||||
// Window2 with a titlebar
|
||||
appkit::NSClosableWindowMask | appkit::NSMiniaturizableWindowMask |
|
||||
appkit::NSResizableWindowMask | appkit::NSTitledWindowMask
|
||||
} else {
|
||||
// Window without a titlebar
|
||||
// Window2 without a titlebar
|
||||
appkit::NSClosableWindowMask | appkit::NSMiniaturizableWindowMask |
|
||||
appkit::NSResizableWindowMask |
|
||||
appkit::NSFullSizeContentViewWindowMask
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue