mirror of
https://github.com/servo/servo.git
synced 2025-07-16 20:03:39 +01:00
break out cef app wakeup code into separate pub function
This commit is contained in:
parent
64ff2c4a54
commit
45116dca71
1 changed files with 37 additions and 36 deletions
|
@ -458,44 +458,9 @@ struct CefCompositorProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompositorProxy for 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) {
|
fn send(&mut self, msg: compositor_task::Msg) {
|
||||||
self.sender.send(msg).unwrap();
|
self.sender.send(msg).unwrap();
|
||||||
unsafe { if CEF_APP.is_null() { return; } }
|
app_wakeup();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone_compositor_proxy(&self) -> Box<CompositorProxy+Send> {
|
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")]
|
#[cfg(target_os="linux")]
|
||||||
pub fn init_window() {
|
pub fn init_window() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue