Skip to content
Permalink
Browse files

break out cef app wakeup code into separate pub function

  • Loading branch information
Mike Blumenkrantz
Mike Blumenkrantz committed May 27, 2015
1 parent 64ff2c4 commit 45116dca7130576b8ac9cdc75ad7715d9faa8c23
Showing with 37 additions and 36 deletions.
  1. +37 −36 ports/cef/window.rs
@@ -458,44 +458,9 @@ struct CefCompositorProxy {
}

impl CompositorProxy for CefCompositorProxy {
#[cfg(target_os="macos")]
fn send(&mut self, msg: compositor_task::Msg) {
use cocoa::appkit::{NSApp, NSApplication, NSApplicationDefined};
use cocoa::appkit::{NSEvent, NSEventModifierFlags, NSEventSubtype};
use cocoa::base::nil;
use cocoa::foundation::{NSAutoreleasePool, NSPoint};

// Send a message and kick the OS event loop awake.
self.sender.send(msg).unwrap();

unsafe {
let pool = NSAutoreleasePool::new(nil);
let event =
NSEvent::otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_(
nil,
NSApplicationDefined,
NSPoint::new(0.0, 0.0),
NSEventModifierFlags::empty(),
0.0,
0,
nil,
NSEventSubtype::NSWindowExposedEventType,
0,
0);
NSApp().postEvent_atStart_(event, 0);
pool.drain();
}
}

#[cfg(target_os="linux")]
fn send(&mut self, msg: compositor_task::Msg) {
self.sender.send(msg).unwrap();
unsafe { if CEF_APP.is_null() { return; } }
let capp = unsafe { CefApp::from_c_object_addref(CEF_APP) };
if unsafe { (*CEF_APP).get_browser_process_handler.is_some() } &&
check_ptr_exist!(capp.get_browser_process_handler(), on_work_available) {
capp.get_browser_process_handler().on_work_available();
}
app_wakeup();
}

fn clone_compositor_proxy(&self) -> Box<CompositorProxy+Send> {
@@ -520,6 +485,42 @@ fn on_load_start(window: &Window) {
}
}

#[cfg(target_os="macos")]
pub fn app_wakeup() {
use cocoa::appkit::{NSApp, NSApplication, NSApplicationDefined};
use cocoa::appkit::{NSEvent, NSEventModifierFlags, NSEventSubtype};
use cocoa::base::nil;
use cocoa::foundation::{NSAutoreleasePool, NSPoint};

unsafe {
let pool = NSAutoreleasePool::new(nil);
let event =
NSEvent::otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_(
nil,
NSApplicationDefined,
NSPoint::new(0.0, 0.0),
NSEventModifierFlags::empty(),
0.0,
0,
nil,
NSEventSubtype::NSWindowExposedEventType,
0,
0);
NSApp().postEvent_atStart_(event, 0);
pool.drain();
}
}

#[cfg(target_os="linux")]
pub fn app_wakeup() {
unsafe { if CEF_APP.is_null() { return; } }
let capp = unsafe { CefApp::from_c_object_addref(CEF_APP) };
if unsafe { (*CEF_APP).get_browser_process_handler.is_some() } &&
check_ptr_exist!(capp.get_browser_process_handler(), on_work_available) {
capp.get_browser_process_handler().on_work_available();
}
}

#[cfg(target_os="linux")]
pub fn init_window() {
unsafe {

0 comments on commit 45116dc

Please sign in to comment.
You can’t perform that action at this time.