mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
compositing: Support multiple events per frame.
Improves scrolling performance on Mac.
This commit is contained in:
parent
e52197d126
commit
0098d9e9e8
12 changed files with 67 additions and 59 deletions
|
@ -75,9 +75,9 @@ pub struct Browser {
|
|||
/// application Servo is embedded in. Clients then create an event
|
||||
/// loop to pump messages between the embedding application and
|
||||
/// various browser components.
|
||||
impl Browser {
|
||||
impl Browser {
|
||||
pub fn new<Window>(window: Option<Rc<Window>>) -> Browser
|
||||
where Window: WindowMethods + 'static {
|
||||
where Window: WindowMethods + 'static {
|
||||
// Global configuration options, parsed from the command line.
|
||||
let opts = opts::get();
|
||||
|
||||
|
@ -124,8 +124,8 @@ impl Browser {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn handle_event(&mut self, event: WindowEvent) -> bool {
|
||||
self.compositor.handle_event(event)
|
||||
pub fn handle_events(&mut self, events: Vec<WindowEvent>) -> bool {
|
||||
self.compositor.handle_events(events)
|
||||
}
|
||||
|
||||
pub fn repaint_synchronously(&mut self) {
|
||||
|
|
|
@ -64,17 +64,14 @@ fn main() {
|
|||
|
||||
maybe_register_glutin_resize_handler(&window, &mut browser);
|
||||
|
||||
browser.browser.handle_event(WindowEvent::InitializeCompositing);
|
||||
browser.browser.handle_events(vec![WindowEvent::InitializeCompositing]);
|
||||
|
||||
// Feed events from the window to the browser until the browser
|
||||
// says to stop.
|
||||
loop {
|
||||
let should_continue = match window {
|
||||
None => browser.browser.handle_event(WindowEvent::Idle),
|
||||
Some(ref window) => {
|
||||
let event = window.wait_events();
|
||||
browser.browser.handle_event(event)
|
||||
}
|
||||
None => browser.browser.handle_events(Vec::new()),
|
||||
Some(ref window) => browser.browser.handle_events(window.wait_events()),
|
||||
};
|
||||
if !should_continue {
|
||||
break
|
||||
|
@ -123,7 +120,7 @@ impl app::NestedEventLoopListener for BrowserWrapper {
|
|||
WindowEvent::Resize(..) => true,
|
||||
_ => false,
|
||||
};
|
||||
if !self.browser.handle_event(event) {
|
||||
if !self.browser.handle_events(vec![event]) {
|
||||
return false
|
||||
}
|
||||
if is_resize {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue