mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
track and update cursor while scrolling
This commit is contained in:
parent
5fdc7c0d2c
commit
a44f795845
1 changed files with 20 additions and 0 deletions
|
@ -198,6 +198,9 @@ pub struct IOCompositor<Window: WindowMethods + ?Sized> {
|
||||||
/// Current mouse cursor.
|
/// Current mouse cursor.
|
||||||
cursor: Cursor,
|
cursor: Cursor,
|
||||||
|
|
||||||
|
/// Current cursor position.
|
||||||
|
cursor_pos: DevicePoint,
|
||||||
|
|
||||||
output_file: Option<String>,
|
output_file: Option<String>,
|
||||||
|
|
||||||
is_running_problem_test: bool,
|
is_running_problem_test: bool,
|
||||||
|
@ -320,6 +323,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
webxr_main_thread: state.webxr_main_thread,
|
webxr_main_thread: state.webxr_main_thread,
|
||||||
pending_paint_metrics: HashMap::new(),
|
pending_paint_metrics: HashMap::new(),
|
||||||
cursor: Cursor::None,
|
cursor: Cursor::None,
|
||||||
|
cursor_pos: DevicePoint::new(0.0, 0.0),
|
||||||
output_file,
|
output_file,
|
||||||
is_running_problem_test,
|
is_running_problem_test,
|
||||||
exit_after_load,
|
exit_after_load,
|
||||||
|
@ -361,6 +365,21 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
self.webrender.deinit();
|
self.webrender.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update_cursor(&mut self) {
|
||||||
|
let results = self.hit_test_at_point(self.cursor_pos);
|
||||||
|
if let Some(item) = results.items.first() {
|
||||||
|
if let Some(cursor) = Cursor::from_u8(item.tag.1 as _) {
|
||||||
|
if cursor != self.cursor {
|
||||||
|
self.cursor = cursor;
|
||||||
|
let msg = ConstellationMsg::SetCursor(cursor);
|
||||||
|
if let Err(e) = self.constellation_chan.send(msg) {
|
||||||
|
warn!("Sending event to constellation failed ({:?}).", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn maybe_start_shutting_down(&mut self) {
|
pub fn maybe_start_shutting_down(&mut self) {
|
||||||
if self.shutdown_state == ShutdownState::NotShuttingDown {
|
if self.shutdown_state == ShutdownState::NotShuttingDown {
|
||||||
debug!("Shutting down the constellation for WindowEvent::Quit");
|
debug!("Shutting down the constellation for WindowEvent::Quit");
|
||||||
|
@ -481,6 +500,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
|
|
||||||
(Msg::NewScrollFrameReady(recomposite_needed), ShutdownState::NotShuttingDown) => {
|
(Msg::NewScrollFrameReady(recomposite_needed), ShutdownState::NotShuttingDown) => {
|
||||||
self.waiting_for_results_of_scroll = false;
|
self.waiting_for_results_of_scroll = false;
|
||||||
|
self.update_cursor();
|
||||||
if recomposite_needed {
|
if recomposite_needed {
|
||||||
self.composition_request = CompositionRequest::CompositeNow(
|
self.composition_request = CompositionRequest::CompositeNow(
|
||||||
CompositingReason::NewWebRenderScrollFrame,
|
CompositingReason::NewWebRenderScrollFrame,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue