Skip to content

Commit

Permalink
Update SetCursor behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrouget committed Apr 25, 2019
1 parent 07d1559 commit 7858ede
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
13 changes: 10 additions & 3 deletions components/compositing/compositor.rs
Expand Up @@ -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)]
Expand Down Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion components/constellation/constellation.rs
Expand Up @@ -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);
},
Expand Down
5 changes: 1 addition & 4 deletions components/script_traits/script_msg.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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),
}
Expand All @@ -71,7 +69,6 @@ impl fmt::Debug for LayoutMsg {
ChangeRunningAnimationsState(..) => "ChangeRunningAnimationsState",
IFrameSizes(..) => "IFrameSizes",
PendingPaintMetric(..) => "PendingPaintMetric",
SetCursor(..) => "SetCursor",
ViewportConstrained(..) => "ViewportConstrained",
};
write!(formatter, "LayoutMsg::{}", variant)
Expand Down

0 comments on commit 7858ede

Please sign in to comment.