mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
* Create embedder event to send to constellation * Handle gamepad message in constellation, send to script thread * Handle GamepadEvent in script thread and dispatch event to document * Add missing Clones, fix event * Add gamepad task source * Adjust GamepadIndex type, remove unused imports * Add internal getter for gamepads list * Update gamepad new methods * Handle gamepad connect and disconnect events * Proto will be none, no need for HandleObject * Initialize buttons and axes to standard mapping * Adjust update type index types * Update GamepadButton update function * Adjust Gamepad mapping comments to match spec, add update logic * Amend comment * Update button and axis inputs on Updated event * Add GilRs as gamepad backend in servoshell * Add spec links, queue gamepad updates on task source * ./mach fmt * Fix comment length * Split out button init, update spec comments * Move gamepad event handling from document to global * Map and normalize axes/button values * Use std::time for gamepad timestamp * Adjust gamepad handling in event loop * Move button press/touch check into map+normalize function - Small change but is more in line with spec * ./mach fmt * Update comment spec links and warning messages * Doc comments -> regular comments * Add window event handlers for gamepad connect/disconnect * Adjust gamepad disconnect behavior * Add missing TODO's, adjust gamepad/gamepadbutton list methods and formatting * Update button handling from gilrs, add comments * Enable gamepad pref during WPT tests and update expectations * Update WPT expectations in meta-legacy-layout
126 lines
5.6 KiB
Rust
126 lines
5.6 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
use std::collections::HashMap;
|
|
use std::fmt;
|
|
use std::time::Duration;
|
|
|
|
use embedder_traits::Cursor;
|
|
use gfx_traits::Epoch;
|
|
use ipc_channel::ipc::IpcSender;
|
|
use keyboard_types::KeyboardEvent;
|
|
use msg::constellation_msg::{
|
|
BrowsingContextId, PipelineId, TopLevelBrowsingContextId, TraversalDirection,
|
|
};
|
|
use script_traits::{
|
|
AnimationTickType, CompositorEvent, GamepadEvent, LogEntry, MediaSessionActionType,
|
|
WebDriverCommandMsg, WindowSizeData, WindowSizeType,
|
|
};
|
|
use servo_url::ServoUrl;
|
|
|
|
/// Messages to the constellation.
|
|
pub enum ConstellationMsg {
|
|
/// Exit the constellation.
|
|
Exit,
|
|
/// Request that the constellation send the BrowsingContextId corresponding to the document
|
|
/// with the provided pipeline id
|
|
GetBrowsingContext(PipelineId, IpcSender<Option<BrowsingContextId>>),
|
|
/// Request that the constellation send the current pipeline id for the provided
|
|
/// browsing context id, over a provided channel.
|
|
GetPipeline(BrowsingContextId, IpcSender<Option<PipelineId>>),
|
|
/// Request that the constellation send the current focused top-level browsing context id,
|
|
/// over a provided channel.
|
|
GetFocusTopLevelBrowsingContext(IpcSender<Option<TopLevelBrowsingContextId>>),
|
|
/// Query the constellation to see if the current compositor output is stable
|
|
IsReadyToSaveImage(HashMap<PipelineId, Epoch>),
|
|
/// Inform the constellation of a key event.
|
|
Keyboard(KeyboardEvent),
|
|
/// Whether to allow script to navigate.
|
|
AllowNavigationResponse(PipelineId, bool),
|
|
/// Request to load a page.
|
|
LoadUrl(TopLevelBrowsingContextId, ServoUrl),
|
|
/// Clear the network cache.
|
|
ClearCache,
|
|
/// Request to traverse the joint session history of the provided browsing context.
|
|
TraverseHistory(TopLevelBrowsingContextId, TraversalDirection),
|
|
/// Inform the constellation of a window being resized.
|
|
WindowSize(TopLevelBrowsingContextId, WindowSizeData, WindowSizeType),
|
|
/// Requests that the constellation instruct layout to begin a new tick of the animation.
|
|
TickAnimation(PipelineId, AnimationTickType),
|
|
/// Dispatch a webdriver command
|
|
WebDriverCommand(WebDriverCommandMsg),
|
|
/// Reload a top-level browsing context.
|
|
Reload(TopLevelBrowsingContextId),
|
|
/// A log entry, with the top-level browsing context id and thread name
|
|
LogEntry(Option<TopLevelBrowsingContextId>, Option<String>, LogEntry),
|
|
/// Create a new top level browsing context.
|
|
NewWebView(ServoUrl, TopLevelBrowsingContextId),
|
|
/// Close a top level browsing context.
|
|
CloseWebView(TopLevelBrowsingContextId),
|
|
/// Panic a top level browsing context.
|
|
SendError(Option<TopLevelBrowsingContextId>, String),
|
|
/// Make a top-level browsing context focused.
|
|
FocusWebView(TopLevelBrowsingContextId),
|
|
/// Make none of the top-level browsing contexts focused.
|
|
BlurWebView,
|
|
/// Forward an event to the script task of the given pipeline.
|
|
ForwardEvent(PipelineId, CompositorEvent),
|
|
/// Requesting a change to the onscreen cursor.
|
|
SetCursor(Cursor),
|
|
/// Enable the sampling profiler, with a given sampling rate and max total sampling duration.
|
|
EnableProfiler(Duration, Duration),
|
|
/// Disable the sampling profiler.
|
|
DisableProfiler,
|
|
/// Request to exit from fullscreen mode
|
|
ExitFullScreen(TopLevelBrowsingContextId),
|
|
/// Media session action.
|
|
MediaSessionAction(MediaSessionActionType),
|
|
/// The visibility of the webview has changed.
|
|
WebViewVisibilityChanged(TopLevelBrowsingContextId, bool),
|
|
/// Virtual keyboard was dismissed
|
|
IMEDismissed,
|
|
/// Compositing done, but external code needs to present.
|
|
ReadyToPresent(TopLevelBrowsingContextId),
|
|
/// Gamepad state has changed
|
|
Gamepad(GamepadEvent),
|
|
}
|
|
|
|
impl fmt::Debug for ConstellationMsg {
|
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
|
use self::ConstellationMsg::*;
|
|
let variant = match *self {
|
|
Exit => "Exit",
|
|
GetBrowsingContext(..) => "GetBrowsingContext",
|
|
GetPipeline(..) => "GetPipeline",
|
|
GetFocusTopLevelBrowsingContext(..) => "GetFocusTopLevelBrowsingContext",
|
|
IsReadyToSaveImage(..) => "IsReadyToSaveImage",
|
|
Keyboard(..) => "Keyboard",
|
|
AllowNavigationResponse(..) => "AllowNavigationResponse",
|
|
LoadUrl(..) => "LoadUrl",
|
|
TraverseHistory(..) => "TraverseHistory",
|
|
WindowSize(..) => "WindowSize",
|
|
TickAnimation(..) => "TickAnimation",
|
|
WebDriverCommand(..) => "WebDriverCommand",
|
|
Reload(..) => "Reload",
|
|
LogEntry(..) => "LogEntry",
|
|
NewWebView(..) => "NewWebView",
|
|
CloseWebView(..) => "CloseWebView",
|
|
FocusWebView(..) => "FocusWebView",
|
|
BlurWebView => "BlurWebView",
|
|
SendError(..) => "SendError",
|
|
ForwardEvent(..) => "ForwardEvent",
|
|
SetCursor(..) => "SetCursor",
|
|
EnableProfiler(..) => "EnableProfiler",
|
|
DisableProfiler => "DisableProfiler",
|
|
ExitFullScreen(..) => "ExitFullScreen",
|
|
MediaSessionAction(..) => "MediaSessionAction",
|
|
WebViewVisibilityChanged(..) => "WebViewVisibilityChanged",
|
|
IMEDismissed => "IMEDismissed",
|
|
ClearCache => "ClearCache",
|
|
ReadyToPresent(..) => "ReadyToPresent",
|
|
Gamepad(..) => "Gamepad",
|
|
};
|
|
write!(formatter, "ConstellationMsg::{}", variant)
|
|
}
|
|
}
|