mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
compositing: Keep the event loop awake when scrolling.
This commit is contained in:
parent
9e3e361b84
commit
b4b3cbccf7
3 changed files with 24 additions and 6 deletions
|
@ -82,6 +82,8 @@ pub struct IOCompositor<Window: WindowMethods> {
|
||||||
/// The device pixel ratio for this window.
|
/// The device pixel ratio for this window.
|
||||||
hidpi_factor: ScaleFactor<ScreenPx, DevicePixel, f32>,
|
hidpi_factor: ScaleFactor<ScreenPx, DevicePixel, f32>,
|
||||||
|
|
||||||
|
channel_to_self: Box<CompositorProxy + Send>,
|
||||||
|
|
||||||
/// A handle to the scrolling timer.
|
/// A handle to the scrolling timer.
|
||||||
scrolling_timer: ScrollingTimerProxy,
|
scrolling_timer: ScrollingTimerProxy,
|
||||||
|
|
||||||
|
@ -206,6 +208,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}),
|
}),
|
||||||
window_size: window_size,
|
window_size: window_size,
|
||||||
hidpi_factor: hidpi_factor,
|
hidpi_factor: hidpi_factor,
|
||||||
|
channel_to_self: sender.clone_compositor_proxy(),
|
||||||
scrolling_timer: ScrollingTimerProxy::new(sender),
|
scrolling_timer: ScrollingTimerProxy::new(sender),
|
||||||
composition_request: CompositionRequest::NoCompositingNecessary,
|
composition_request: CompositionRequest::NoCompositingNecessary,
|
||||||
pending_scroll_events: Vec::new(),
|
pending_scroll_events: Vec::new(),
|
||||||
|
@ -360,6 +363,11 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(Msg::RecompositeAfterScroll, ShutdownState::NotShuttingDown) => {
|
||||||
|
self.composition_request =
|
||||||
|
CompositionRequest::CompositeNow(CompositingReason::ContinueScroll)
|
||||||
|
}
|
||||||
|
|
||||||
(Msg::KeyEvent(key, state, modified), ShutdownState::NotShuttingDown) => {
|
(Msg::KeyEvent(key, state, modified), ShutdownState::NotShuttingDown) => {
|
||||||
if state == KeyState::Pressed {
|
if state == KeyState::Pressed {
|
||||||
self.window.handle_key(key, modified);
|
self.window.handle_key(key, modified);
|
||||||
|
@ -755,11 +763,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
layer_id: LayerId,
|
layer_id: LayerId,
|
||||||
point: Point2D<f32>) {
|
point: Point2D<f32>) {
|
||||||
if self.move_layer(pipeline_id, layer_id, Point2D::from_untyped(&point)) {
|
if self.move_layer(pipeline_id, layer_id, Point2D::from_untyped(&point)) {
|
||||||
if self.send_buffer_requests_for_all_layers() {
|
self.perform_updates_after_scroll()
|
||||||
self.start_scrolling_timer_if_necessary();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
self.fragment_point = Some(point);
|
self.fragment_point = Some(point)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -899,8 +905,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
layer.handle_scroll_event(delta, cursor);
|
layer.handle_scroll_event(delta, cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.start_scrolling_timer_if_necessary();
|
self.perform_updates_after_scroll();
|
||||||
self.send_buffer_requests_for_all_layers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if had_scroll_events {
|
if had_scroll_events {
|
||||||
|
@ -908,6 +913,16 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Performs buffer requests and starts the scrolling timer or schedules a recomposite as
|
||||||
|
/// necessary.
|
||||||
|
fn perform_updates_after_scroll(&mut self) {
|
||||||
|
if self.send_buffer_requests_for_all_layers() {
|
||||||
|
self.start_scrolling_timer_if_necessary();
|
||||||
|
} else {
|
||||||
|
self.channel_to_self.send(Msg::RecompositeAfterScroll);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// If there are any animations running, dispatches appropriate messages to the constellation.
|
/// If there are any animations running, dispatches appropriate messages to the constellation.
|
||||||
fn process_animations(&mut self) {
|
fn process_animations(&mut self) {
|
||||||
for (pipeline_id, pipeline_details) in self.pipeline_details.iter() {
|
for (pipeline_id, pipeline_details) in self.pipeline_details.iter() {
|
||||||
|
|
|
@ -212,6 +212,7 @@ pub enum Msg {
|
||||||
/// Indicates that the scrolling timeout with the given starting timestamp has happened and a
|
/// Indicates that the scrolling timeout with the given starting timestamp has happened and a
|
||||||
/// composite should happen. (See the `scrolling` module.)
|
/// composite should happen. (See the `scrolling` module.)
|
||||||
ScrollTimeout(u64),
|
ScrollTimeout(u64),
|
||||||
|
RecompositeAfterScroll,
|
||||||
/// Sends an unconsumed key event back to the compositor.
|
/// Sends an unconsumed key event back to the compositor.
|
||||||
KeyEvent(Key, KeyState, KeyModifiers),
|
KeyEvent(Key, KeyState, KeyModifiers),
|
||||||
/// Changes the cursor.
|
/// Changes the cursor.
|
||||||
|
@ -240,6 +241,7 @@ impl Debug for Msg {
|
||||||
Msg::SetFrameTree(..) => write!(f, "SetFrameTree"),
|
Msg::SetFrameTree(..) => write!(f, "SetFrameTree"),
|
||||||
Msg::LoadComplete => write!(f, "LoadComplete"),
|
Msg::LoadComplete => write!(f, "LoadComplete"),
|
||||||
Msg::ScrollTimeout(..) => write!(f, "ScrollTimeout"),
|
Msg::ScrollTimeout(..) => write!(f, "ScrollTimeout"),
|
||||||
|
Msg::RecompositeAfterScroll => write!(f, "RecompositeAfterScroll"),
|
||||||
Msg::KeyEvent(..) => write!(f, "KeyEvent"),
|
Msg::KeyEvent(..) => write!(f, "KeyEvent"),
|
||||||
Msg::SetCursor(..) => write!(f, "SetCursor"),
|
Msg::SetCursor(..) => write!(f, "SetCursor"),
|
||||||
Msg::PaintTaskExited(..) => write!(f, "PaintTaskExited"),
|
Msg::PaintTaskExited(..) => write!(f, "PaintTaskExited"),
|
||||||
|
|
|
@ -103,6 +103,7 @@ impl CompositorEventListener for NullCompositor {
|
||||||
Msg::LoadComplete |
|
Msg::LoadComplete |
|
||||||
Msg::PaintMsgDiscarded(..) |
|
Msg::PaintMsgDiscarded(..) |
|
||||||
Msg::ScrollTimeout(..) |
|
Msg::ScrollTimeout(..) |
|
||||||
|
Msg::RecompositeAfterScroll |
|
||||||
Msg::ChangePageTitle(..) |
|
Msg::ChangePageTitle(..) |
|
||||||
Msg::ChangePageUrl(..) |
|
Msg::ChangePageUrl(..) |
|
||||||
Msg::KeyEvent(..) |
|
Msg::KeyEvent(..) |
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue