mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
constellation: notify embedder when events are hit-tested to browsers (#30841)
* constellation: notify embedder when events are hit-tested to browsers * fix compile error in libsimpleservo * impl From<&CompositorEvent> for CompositorEventVariant * remove msg temporaries in Constellation::forward_event * use single wildcard arm in EventDelivered case in handle_servo_events
This commit is contained in:
parent
676c170b07
commit
8a226fdb19
5 changed files with 58 additions and 10 deletions
|
@ -1548,9 +1548,10 @@ where
|
||||||
|
|
||||||
fn handle_request_from_script(&mut self, message: (PipelineId, FromScriptMsg)) {
|
fn handle_request_from_script(&mut self, message: (PipelineId, FromScriptMsg)) {
|
||||||
let (source_pipeline_id, content) = message;
|
let (source_pipeline_id, content) = message;
|
||||||
debug!(
|
trace!(
|
||||||
"{}: Message from pipeline: {:?}",
|
"{}: Message from pipeline: {:?}",
|
||||||
source_pipeline_id, content,
|
source_pipeline_id,
|
||||||
|
content,
|
||||||
);
|
);
|
||||||
|
|
||||||
let source_top_ctx_id = match self
|
let source_top_ctx_id = match self
|
||||||
|
@ -2904,15 +2905,23 @@ where
|
||||||
self.pressed_mouse_buttons = 0;
|
self.pressed_mouse_buttons = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let msg = ConstellationControlMsg::SendEvent(destination_pipeline_id, event);
|
let pipeline = match self.pipelines.get(&destination_pipeline_id) {
|
||||||
let result = match self.pipelines.get(&destination_pipeline_id) {
|
|
||||||
None => {
|
None => {
|
||||||
debug!("{}: Got event after closure", destination_pipeline_id);
|
debug!("{}: Got event after closure", destination_pipeline_id);
|
||||||
return;
|
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);
|
self.handle_send_error(destination_pipeline_id, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,6 +208,21 @@ pub enum EmbedderMsg {
|
||||||
OnDevtoolsStarted(Result<u16, ()>, String),
|
OnDevtoolsStarted(Result<u16, ()>, String),
|
||||||
/// Compositing done, but external code needs to present.
|
/// Compositing done, but external code needs to present.
|
||||||
ReadyToPresent,
|
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 {
|
impl Debug for EmbedderMsg {
|
||||||
|
@ -245,6 +260,7 @@ impl Debug for EmbedderMsg {
|
||||||
EmbedderMsg::OnDevtoolsStarted(..) => write!(f, "OnDevtoolsStarted"),
|
EmbedderMsg::OnDevtoolsStarted(..) => write!(f, "OnDevtoolsStarted"),
|
||||||
EmbedderMsg::ShowContextMenu(..) => write!(f, "ShowContextMenu"),
|
EmbedderMsg::ShowContextMenu(..) => write!(f, "ShowContextMenu"),
|
||||||
EmbedderMsg::ReadyToPresent => write!(f, "ReadyToPresent"),
|
EmbedderMsg::ReadyToPresent => write!(f, "ReadyToPresent"),
|
||||||
|
EmbedderMsg::EventDelivered(..) => write!(f, "HitTestedEvent"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ use canvas_traits::webgl::WebGLPipeline;
|
||||||
use compositor::ScrollTreeNodeId;
|
use compositor::ScrollTreeNodeId;
|
||||||
use crossbeam_channel::{Receiver, RecvTimeoutError, Sender};
|
use crossbeam_channel::{Receiver, RecvTimeoutError, Sender};
|
||||||
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId};
|
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId};
|
||||||
use embedder_traits::Cursor;
|
use embedder_traits::{CompositorEventVariant, Cursor};
|
||||||
use euclid::default::Point2D;
|
use euclid::default::Point2D;
|
||||||
use euclid::{Length, Rect, Scale, Size2D, UnknownUnit, Vector2D};
|
use euclid::{Length, Rect, Scale, Size2D, UnknownUnit, Vector2D};
|
||||||
use gfx_traits::Epoch;
|
use gfx_traits::Epoch;
|
||||||
|
@ -571,6 +571,21 @@ pub enum CompositorEvent {
|
||||||
IMEDismissedEvent,
|
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.
|
/// Requests a TimerEvent-Message be sent after the given duration.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct TimerEventRequest(
|
pub struct TimerEventRequest(
|
||||||
|
|
|
@ -799,7 +799,8 @@ impl ServoGlue {
|
||||||
EmbedderMsg::HeadParsed |
|
EmbedderMsg::HeadParsed |
|
||||||
EmbedderMsg::SetFullscreenState(..) |
|
EmbedderMsg::SetFullscreenState(..) |
|
||||||
EmbedderMsg::ReadyToPresent |
|
EmbedderMsg::ReadyToPresent |
|
||||||
EmbedderMsg::ReportProfile(..) => {},
|
EmbedderMsg::ReportProfile(..) |
|
||||||
|
EmbedderMsg::EventDelivered(..) => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -14,8 +14,8 @@ use keyboard_types::{Key, KeyboardEvent, Modifiers, ShortcutMatcher};
|
||||||
use log::{debug, error, info, trace, warn};
|
use log::{debug, error, info, trace, warn};
|
||||||
use servo::compositing::windowing::{EmbedderEvent, WebRenderDebugOption};
|
use servo::compositing::windowing::{EmbedderEvent, WebRenderDebugOption};
|
||||||
use servo::embedder_traits::{
|
use servo::embedder_traits::{
|
||||||
ContextMenuResult, EmbedderMsg, FilterPattern, PermissionPrompt, PermissionRequest,
|
CompositorEventVariant, ContextMenuResult, EmbedderMsg, FilterPattern, PermissionPrompt,
|
||||||
PromptDefinition, PromptOrigin, PromptResult,
|
PermissionRequest, PromptDefinition, PromptOrigin, PromptResult,
|
||||||
};
|
};
|
||||||
use servo::msg::constellation_msg::{TopLevelBrowsingContextId as BrowserId, TraversalDirection};
|
use servo::msg::constellation_msg::{TopLevelBrowsingContextId as BrowserId, TraversalDirection};
|
||||||
use servo::script_traits::TouchEventType;
|
use servo::script_traits::TouchEventType;
|
||||||
|
@ -545,6 +545,13 @@ where
|
||||||
EmbedderMsg::ReadyToPresent => {
|
EmbedderMsg::ReadyToPresent => {
|
||||||
need_present = true;
|
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);
|
||||||
|
},
|
||||||
|
(_, _) => {},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue