diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 9f8736e619c..4f42867ae67 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -196,6 +196,9 @@ pub struct IOCompositor { /// Current mouse cursor. cursor: Cursor, + /// Current cursor position. + cursor_pos: DevicePoint, + output_file: Option, is_running_problem_test: bool, @@ -318,6 +321,7 @@ impl IOCompositor { webxr_main_thread: state.webxr_main_thread, pending_paint_metrics: HashMap::new(), cursor: Cursor::None, + cursor_pos: DevicePoint::new(0.0, 0.0), output_file, is_running_problem_test, exit_after_load, @@ -359,6 +363,20 @@ impl IOCompositor { self.webrender.deinit(); } + pub fn update_cursor(&mut self, hit_test_results: HitTestResult) { + if let Some(item) = hit_test_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) { if self.shutdown_state == ShutdownState::NotShuttingDown { debug!("Shutting down the constellation for WindowEvent::Quit"); @@ -479,6 +497,7 @@ impl IOCompositor { (Msg::NewScrollFrameReady(recomposite_needed), ShutdownState::NotShuttingDown) => { self.waiting_for_results_of_scroll = false; + self.update_cursor(self.hit_test_at_point(self.cursor_pos)); if recomposite_needed { self.composition_request = CompositionRequest::CompositeNow( CompositingReason::NewWebRenderScrollFrame, @@ -762,16 +781,7 @@ impl IOCompositor { if let Err(e) = self.constellation_chan.send(msg) { warn!("Sending event to constellation failed ({:?}).", e); } - - 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); - } - } - } + self.update_cursor(results); } }