aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-04-25 12:28:08 -0400
committerGitHub <noreply@github.com>2019-04-25 12:28:08 -0400
commitcaac107ae8145ef2fd20365e2b8fadaf09c2eb3b (patch)
tree0ce392f3e8e9821013302e2c964b68361bfc4f2d
parente877dc2759fd6f46abb3a841c6aa6e21ba1b8142 (diff)
parent7858ede29f227f608245640f6d65c1dcfb560512 (diff)
downloadservo-caac107ae8145ef2fd20365e2b8fadaf09c2eb3b.tar.gz
servo-caac107ae8145ef2fd20365e2b8fadaf09c2eb3b.zip
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 -->
-rw-r--r--components/compositing/compositor.rs13
-rw-r--r--components/constellation/constellation.rs1
-rw-r--r--components/script_traits/script_msg.rs5
3 files changed, 11 insertions, 8 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index 7b203933fb8..6cbf1d35160 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -191,6 +191,9 @@ pub struct IOCompositor<Window: WindowMethods> {
/// The coordinates of the native window, its view and the screen.
embedder_coordinates: EmbedderCoordinates,
+
+ /// Current mouse cursor.
+ cursor: Cursor,
}
#[derive(Clone, Copy)]
@@ -291,6 +294,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
webrender_api: state.webrender_api,
webvr_heartbeats: state.webvr_heartbeats,
pending_paint_metrics: HashMap::new(),
+ cursor: Cursor::None,
}
}
@@ -709,9 +713,12 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}
if let Some(cursor) = Cursor::from_u8(item.tag.1 as _) {
- let msg = ConstellationMsg::SetCursor(cursor);
- if let Err(e) = self.constellation_chan.send(msg) {
- warn!("Sending event to constellation failed ({:?}).", e);
+ 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);
+ }
}
}
}
diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs
index 724891ab3f0..3f2430e7ce9 100644
--- a/components/constellation/constellation.rs
+++ b/components/constellation/constellation.rs
@@ -1469,7 +1469,6 @@ where
FromLayoutMsg::PendingPaintMetric(pipeline_id, epoch) => {
self.handle_pending_paint_metric(pipeline_id, epoch);
},
- FromLayoutMsg::SetCursor(cursor) => self.handle_set_cursor_msg(cursor),
FromLayoutMsg::ViewportConstrained(pipeline_id, constraints) => {
self.handle_viewport_constrained_msg(pipeline_id, constraints);
},
diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs
index f4691d4d218..bb7619aa1a7 100644
--- a/components/script_traits/script_msg.rs
+++ b/components/script_traits/script_msg.rs
@@ -14,7 +14,7 @@ use crate::WorkerGlobalScopeInit;
use crate::WorkerScriptLoadOrigin;
use canvas_traits::canvas::{CanvasId, CanvasMsg};
use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
-use embedder_traits::{Cursor, EmbedderMsg};
+use embedder_traits::EmbedderMsg;
use euclid::{Size2D, TypedSize2D};
use gfx_traits::Epoch;
use ipc_channel::ipc::{IpcReceiver, IpcSender};
@@ -58,8 +58,6 @@ pub enum LayoutMsg {
/// Requests that the constellation inform the compositor that it needs to record
/// the time when the frame with the given ID (epoch) is painted.
PendingPaintMetric(PipelineId, Epoch),
- /// Requests that the constellation inform the compositor of the a cursor change.
- SetCursor(Cursor),
/// Notifies the constellation that the viewport has been constrained in some manner
ViewportConstrained(PipelineId, ViewportConstraints),
}
@@ -71,7 +69,6 @@ impl fmt::Debug for LayoutMsg {
ChangeRunningAnimationsState(..) => "ChangeRunningAnimationsState",
IFrameSizes(..) => "IFrameSizes",
PendingPaintMetric(..) => "PendingPaintMetric",
- SetCursor(..) => "SetCursor",
ViewportConstrained(..) => "ViewportConstrained",
};
write!(formatter, "LayoutMsg::{}", variant)