Skip to content

Commit caac107

Browse files
author
bors-servo
authored
Auto merge of #23262 - paulrouget:cursor-update, r=jdm
Update SetCursor behavior We were initially sending a SetCursor message on every mouse move because of a winit bug, which is now fixed. Also, we had a layout SetCursor message that was never used. Fix #18599 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23262) <!-- Reviewable:end -->
2 parents e877dc2 + 7858ede commit caac107

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

components/compositing/compositor.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ pub struct IOCompositor<Window: WindowMethods> {
191191

192192
/// The coordinates of the native window, its view and the screen.
193193
embedder_coordinates: EmbedderCoordinates,
194+
195+
/// Current mouse cursor.
196+
cursor: Cursor,
194197
}
195198

196199
#[derive(Clone, Copy)]
@@ -291,6 +294,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
291294
webrender_api: state.webrender_api,
292295
webvr_heartbeats: state.webvr_heartbeats,
293296
pending_paint_metrics: HashMap::new(),
297+
cursor: Cursor::None,
294298
}
295299
}
296300

@@ -709,9 +713,12 @@ impl<Window: WindowMethods> IOCompositor<Window> {
709713
}
710714

711715
if let Some(cursor) = Cursor::from_u8(item.tag.1 as _) {
712-
let msg = ConstellationMsg::SetCursor(cursor);
713-
if let Err(e) = self.constellation_chan.send(msg) {
714-
warn!("Sending event to constellation failed ({:?}).", e);
716+
if cursor != self.cursor {
717+
self.cursor = cursor;
718+
let msg = ConstellationMsg::SetCursor(cursor);
719+
if let Err(e) = self.constellation_chan.send(msg) {
720+
warn!("Sending event to constellation failed ({:?}).", e);
721+
}
715722
}
716723
}
717724
}

components/constellation/constellation.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,6 @@ where
14691469
FromLayoutMsg::PendingPaintMetric(pipeline_id, epoch) => {
14701470
self.handle_pending_paint_metric(pipeline_id, epoch);
14711471
},
1472-
FromLayoutMsg::SetCursor(cursor) => self.handle_set_cursor_msg(cursor),
14731472
FromLayoutMsg::ViewportConstrained(pipeline_id, constraints) => {
14741473
self.handle_viewport_constrained_msg(pipeline_id, constraints);
14751474
},

components/script_traits/script_msg.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::WorkerGlobalScopeInit;
1414
use crate::WorkerScriptLoadOrigin;
1515
use canvas_traits::canvas::{CanvasId, CanvasMsg};
1616
use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
17-
use embedder_traits::{Cursor, EmbedderMsg};
17+
use embedder_traits::EmbedderMsg;
1818
use euclid::{Size2D, TypedSize2D};
1919
use gfx_traits::Epoch;
2020
use ipc_channel::ipc::{IpcReceiver, IpcSender};
@@ -58,8 +58,6 @@ pub enum LayoutMsg {
5858
/// Requests that the constellation inform the compositor that it needs to record
5959
/// the time when the frame with the given ID (epoch) is painted.
6060
PendingPaintMetric(PipelineId, Epoch),
61-
/// Requests that the constellation inform the compositor of the a cursor change.
62-
SetCursor(Cursor),
6361
/// Notifies the constellation that the viewport has been constrained in some manner
6462
ViewportConstrained(PipelineId, ViewportConstraints),
6563
}
@@ -71,7 +69,6 @@ impl fmt::Debug for LayoutMsg {
7169
ChangeRunningAnimationsState(..) => "ChangeRunningAnimationsState",
7270
IFrameSizes(..) => "IFrameSizes",
7371
PendingPaintMetric(..) => "PendingPaintMetric",
74-
SetCursor(..) => "SetCursor",
7572
ViewportConstrained(..) => "ViewportConstrained",
7673
};
7774
write!(formatter, "LayoutMsg::{}", variant)

0 commit comments

Comments
 (0)