Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fixes for Android windowing code #3925

Merged
merged 1 commit into from Nov 8, 2014
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Build fixes for Android windowing code

This begins porting the Android event loop to work with the inverted flow
control from #3761.  Unfortunately, GLUT does not give us enough control over
the event loop to really make this work, so this will build but it may not run
properly.  Our current plan is to get rid of GLUT and switch to Glutin in the
near future.

r? @pcwalton
  • Loading branch information
mbrubeck committed Nov 7, 2014
commit b85adf8b3545524f1c8515cb3f93bd8737a987ee
@@ -56,8 +56,10 @@ pub extern "C" fn android_start(argc: int, argv: *const *const u8) -> int {
}

if opts::from_cmdline_args(args.as_slice()) {
let window = Some(create_window());
servo::run(window);
let window = create_window();
let mut browser = servo::Browser::new(Some(window.clone()));
while browser.handle_event(window.wait_events()) {}
browser.shutdown();
}
})
}
@@ -4,6 +4,7 @@

//! A windowing implementation using GLUT.

use compositing::compositor_task::{mod, CompositorProxy, CompositorReceiver};
use compositing::windowing::{WindowEvent, WindowMethods};
use compositing::windowing::{IdleWindowEvent, ResizeWindowEvent, LoadUrlWindowEvent, MouseWindowEventClass};
use compositing::windowing::{ScrollWindowEvent, ZoomWindowEvent, NavigationWindowEvent, FinishedWindowEvent};
@@ -129,6 +130,17 @@ impl Window {

wrapped_window
}

pub fn wait_events(&self) -> WindowEvent {
if !self.event_queue.borrow_mut().is_empty() {
return self.event_queue.borrow_mut().remove(0).unwrap();
}

// XXX: Need a function that blocks waiting for events, like glfwWaitEvents.
glut::check_loop();

self.event_queue.borrow_mut().remove(0).unwrap_or(IdleWindowEvent)
}
}

impl Drop for Window {
@@ -153,14 +165,13 @@ impl WindowMethods for Window {
glut::swap_buffers();
}

fn recv(&self) -> WindowEvent {
if !self.event_queue.borrow_mut().is_empty() {
return self.event_queue.borrow_mut().remove(0).unwrap();
}

glut::check_loop();

self.event_queue.borrow_mut().remove(0).unwrap_or(IdleWindowEvent)
fn create_compositor_channel(_: &Option<Rc<Window>>)
-> (Box<CompositorProxy+Send>, Box<CompositorReceiver>) {
let (sender, receiver) = channel();
(box GlutCompositorProxy {
sender: sender,
} as Box<CompositorProxy+Send>,
box receiver as Box<CompositorReceiver>)
}

/// Sets the ready state.
@@ -288,6 +299,24 @@ impl Window {
}
}

struct GlutCompositorProxy {
sender: Sender<compositor_task::Msg>,
}

impl CompositorProxy for GlutCompositorProxy {
fn send(&mut self, msg: compositor_task::Msg) {
// Send a message and kick the OS event loop awake.
self.sender.send(msg);
// XXX: Need a way to unblock wait_events, like glfwPostEmptyEvent
}
fn clone_compositor_proxy(&self) -> Box<CompositorProxy+Send> {
box GlutCompositorProxy {
sender: self.sender.clone(),
} as Box<CompositorProxy+Send>
}
}


local_data_key!(TLS_KEY: Rc<Window>)

fn install_local_window(window: Rc<Window>) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.