diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 2c6a1c4b90d..ebfd83260da 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -1548,9 +1548,10 @@ where fn handle_request_from_script(&mut self, message: (PipelineId, FromScriptMsg)) { let (source_pipeline_id, content) = message; - debug!( + trace!( "{}: Message from pipeline: {:?}", - source_pipeline_id, content, + source_pipeline_id, + content, ); let source_top_ctx_id = match self @@ -2904,15 +2905,23 @@ where self.pressed_mouse_buttons = 0; } - let msg = ConstellationControlMsg::SendEvent(destination_pipeline_id, event); - let result = match self.pipelines.get(&destination_pipeline_id) { + let pipeline = match self.pipelines.get(&destination_pipeline_id) { None => { debug!("{}: Got event after closure", destination_pipeline_id); return; }, - Some(pipeline) => pipeline.event_loop.send(msg), + Some(pipeline) => pipeline, }; - if let Err(e) = result { + + self.embedder_proxy.send(( + Some(pipeline.top_level_browsing_context_id), + EmbedderMsg::EventDelivered((&event).into()), + )); + + if let Err(e) = pipeline.event_loop.send(ConstellationControlMsg::SendEvent( + destination_pipeline_id, + event, + )) { self.handle_send_error(destination_pipeline_id, e); } } diff --git a/components/shared/embedder/lib.rs b/components/shared/embedder/lib.rs index ecaf57a14bb..d3e67bd9d24 100644 --- a/components/shared/embedder/lib.rs +++ b/components/shared/embedder/lib.rs @@ -208,6 +208,21 @@ pub enum EmbedderMsg { OnDevtoolsStarted(Result, String), /// Compositing done, but external code needs to present. ReadyToPresent, + /// The given event was delivered to a pipeline in the given browser. + EventDelivered(CompositorEventVariant), +} + +/// The variant of CompositorEvent that was delivered to a pipeline. +#[derive(Debug, Deserialize, Serialize)] +pub enum CompositorEventVariant { + ResizeEvent, + MouseButtonEvent, + MouseMoveEvent, + TouchEvent, + WheelEvent, + KeyboardEvent, + CompositionEvent, + IMEDismissedEvent, } impl Debug for EmbedderMsg { @@ -245,6 +260,7 @@ impl Debug for EmbedderMsg { EmbedderMsg::OnDevtoolsStarted(..) => write!(f, "OnDevtoolsStarted"), EmbedderMsg::ShowContextMenu(..) => write!(f, "ShowContextMenu"), EmbedderMsg::ReadyToPresent => write!(f, "ReadyToPresent"), + EmbedderMsg::EventDelivered(..) => write!(f, "HitTestedEvent"), } } } diff --git a/components/shared/script/lib.rs b/components/shared/script/lib.rs index 77782255a4c..fac68c03745 100644 --- a/components/shared/script/lib.rs +++ b/components/shared/script/lib.rs @@ -27,7 +27,7 @@ use canvas_traits::webgl::WebGLPipeline; use compositor::ScrollTreeNodeId; use crossbeam_channel::{Receiver, RecvTimeoutError, Sender}; use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId}; -use embedder_traits::Cursor; +use embedder_traits::{CompositorEventVariant, Cursor}; use euclid::default::Point2D; use euclid::{Length, Rect, Scale, Size2D, UnknownUnit, Vector2D}; use gfx_traits::Epoch; @@ -571,6 +571,21 @@ pub enum CompositorEvent { IMEDismissedEvent, } +impl From<&CompositorEvent> for CompositorEventVariant { + fn from(value: &CompositorEvent) -> Self { + match value { + CompositorEvent::ResizeEvent(..) => CompositorEventVariant::ResizeEvent, + CompositorEvent::MouseButtonEvent(..) => CompositorEventVariant::MouseButtonEvent, + CompositorEvent::MouseMoveEvent(..) => CompositorEventVariant::MouseMoveEvent, + CompositorEvent::TouchEvent(..) => CompositorEventVariant::TouchEvent, + CompositorEvent::WheelEvent(..) => CompositorEventVariant::WheelEvent, + CompositorEvent::KeyboardEvent(..) => CompositorEventVariant::KeyboardEvent, + CompositorEvent::CompositionEvent(..) => CompositorEventVariant::CompositionEvent, + CompositorEvent::IMEDismissedEvent => CompositorEventVariant::IMEDismissedEvent, + } + } +} + /// Requests a TimerEvent-Message be sent after the given duration. #[derive(Debug, Deserialize, Serialize)] pub struct TimerEventRequest( diff --git a/ports/libsimpleservo/api/src/lib.rs b/ports/libsimpleservo/api/src/lib.rs index bbb894faee1..cd9abc9b511 100644 --- a/ports/libsimpleservo/api/src/lib.rs +++ b/ports/libsimpleservo/api/src/lib.rs @@ -799,7 +799,8 @@ impl ServoGlue { EmbedderMsg::HeadParsed | EmbedderMsg::SetFullscreenState(..) | EmbedderMsg::ReadyToPresent | - EmbedderMsg::ReportProfile(..) => {}, + EmbedderMsg::ReportProfile(..) | + EmbedderMsg::EventDelivered(..) => {}, } } Ok(()) diff --git a/ports/servoshell/browser.rs b/ports/servoshell/browser.rs index 3978497491c..92e31f18c4e 100644 --- a/ports/servoshell/browser.rs +++ b/ports/servoshell/browser.rs @@ -14,8 +14,8 @@ use keyboard_types::{Key, KeyboardEvent, Modifiers, ShortcutMatcher}; use log::{debug, error, info, trace, warn}; use servo::compositing::windowing::{EmbedderEvent, WebRenderDebugOption}; use servo::embedder_traits::{ - ContextMenuResult, EmbedderMsg, FilterPattern, PermissionPrompt, PermissionRequest, - PromptDefinition, PromptOrigin, PromptResult, + CompositorEventVariant, ContextMenuResult, EmbedderMsg, FilterPattern, PermissionPrompt, + PermissionRequest, PromptDefinition, PromptOrigin, PromptResult, }; use servo::msg::constellation_msg::{TopLevelBrowsingContextId as BrowserId, TraversalDirection}; use servo::script_traits::TouchEventType; @@ -545,6 +545,13 @@ where EmbedderMsg::ReadyToPresent => { need_present = true; }, + EmbedderMsg::EventDelivered(event) => match (browser_id, event) { + (Some(browser_id), CompositorEventVariant::MouseButtonEvent) => { + // TODO Focus browser and/or raise to top if needed. + trace!("{}: Got a mouse button event", browser_id); + }, + (_, _) => {}, + }, } }