From a44f79584517c180ba43e1d5d329693bb602aa3f Mon Sep 17 00:00:00 2001 From: Manpreet Singh Matharu Date: Fri, 12 Jul 2019 15:52:26 -0400 Subject: [PATCH 1/2] track and update cursor while scrolling --- components/compositing/compositor.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index bb8f4d8f2f0..af71c2dadbc 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -198,6 +198,9 @@ pub struct IOCompositor { /// Current mouse cursor. cursor: Cursor, + /// Current cursor position. + cursor_pos: DevicePoint, + output_file: Option, is_running_problem_test: bool, @@ -320,6 +323,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, @@ -361,6 +365,21 @@ impl IOCompositor { 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) { if self.shutdown_state == ShutdownState::NotShuttingDown { debug!("Shutting down the constellation for WindowEvent::Quit"); @@ -481,6 +500,7 @@ impl IOCompositor { (Msg::NewScrollFrameReady(recomposite_needed), ShutdownState::NotShuttingDown) => { self.waiting_for_results_of_scroll = false; + self.update_cursor(); if recomposite_needed { self.composition_request = CompositionRequest::CompositeNow( CompositingReason::NewWebRenderScrollFrame, From 83ebb85dbd33daf2fbd2d188cd3524ebf3154440 Mon Sep 17 00:00:00 2001 From: Manpreet Singh Matharu Date: Sat, 13 Jul 2019 11:33:14 -0400 Subject: [PATCH 2/2] use update_cursor() in dispatch_mouse_window_move_event_class() method --- components/compositing/compositor.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index af71c2dadbc..6714834005f 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -365,9 +365,8 @@ impl IOCompositor { 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() { + 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; @@ -500,7 +499,7 @@ impl IOCompositor { (Msg::NewScrollFrameReady(recomposite_needed), ShutdownState::NotShuttingDown) => { self.waiting_for_results_of_scroll = false; - self.update_cursor(); + self.update_cursor(self.hit_test_at_point(self.cursor_pos)); if recomposite_needed { self.composition_request = CompositionRequest::CompositeNow( CompositingReason::NewWebRenderScrollFrame, @@ -784,16 +783,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); } }