Skip to content

Commit

Permalink
Make the Port an option to allow for stealing
Browse files Browse the repository at this point in the history
  • Loading branch information
csherratt committed Mar 3, 2014
1 parent 9deae05 commit 974a748
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ impl WindowMode {
}

/// A group of key modifiers
#[deriving(Clone)]
pub struct Modifiers {
values: c_int,
}
Expand Down Expand Up @@ -693,6 +694,7 @@ impl fmt::Show for Modifiers {

pub type Scancode = c_int;

#[deriving(Clone)]
pub enum WindowEvent {
PosEvent(i32, i32),
SizeEvent(i32, i32),
Expand Down Expand Up @@ -735,7 +737,7 @@ impl<'a> Iterator<(f64, WindowEvent)> for FlushedWindowEvents<'a> {
/// A struct that wraps a `*GLFWwindow` handle.
pub struct Window {
ptr: *ffi::GLFWwindow,
event_port: Port<(f64, WindowEvent)>,
event_port: Option<Port<(f64, WindowEvent)>>,
is_shared: bool,
}

Expand Down Expand Up @@ -780,7 +782,7 @@ impl Window {
unsafe { ffi::glfwSetWindowUserPointer(ptr, cast::transmute(~chan)); }
Some(Window {
ptr: ptr,
event_port: port,
event_port: Some(port),
is_shared: share.is_none(),
})
}
Expand All @@ -791,11 +793,11 @@ impl Window {
}

pub fn events<'a>(&'a self) -> WindowEvents<'a> {
WindowEvents { event_port: &'a self.event_port }
WindowEvents { event_port: self.event_port.as_ref().unwrap() }
}

pub fn flush_events<'a>(&'a self) -> FlushedWindowEvents<'a> {
FlushedWindowEvents { event_port: &'a self.event_port }
FlushedWindowEvents { event_port: self.event_port.as_ref().unwrap() }
}

/// Wrapper for `glfwWindowShouldClose`.
Expand Down

0 comments on commit 974a748

Please sign in to comment.