Skip to content

Commit 701256d

Browse files
author
Alan Jeffrey
committed
Pass the event loop waker into WebXR
1 parent c9dde3a commit 701256d

9 files changed

Lines changed: 17 additions & 19 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/embedder_traits/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ serde = "1.0"
2323
servo_url = {path = "../url"}
2424
style_traits = {path = "../style_traits", features = ["servo"]}
2525
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
26+
webxr-api = {git = "https://github.com/servo/webxr", features = ["ipc"]}

components/embedder_traits/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ use servo_url::ServoUrl;
2121
use std::fmt::{Debug, Error, Formatter};
2222
use webrender_api::units::{DeviceIntPoint, DeviceIntSize};
2323

24+
pub use webxr_api::MainThreadWaker as EventLoopWaker;
25+
2426
/// A cursor for the window. This is different from a CSS cursor (see
2527
/// `CursorKind`) in that it has no `Auto` value.
2628
#[repr(u8)]
@@ -63,12 +65,6 @@ pub enum Cursor {
6365
ZoomOut,
6466
}
6567

66-
/// Used to wake up the event loop, provided by the servo port/embedder.
67-
pub trait EventLoopWaker: 'static + Send {
68-
fn clone(&self) -> Box<dyn EventLoopWaker + Send>;
69-
fn wake(&self);
70-
}
71-
7268
/// Sends messages to the embedder.
7369
pub struct EmbedderProxy {
7470
pub sender: Sender<(Option<TopLevelBrowsingContextId>, EmbedderMsg)>,

components/net/tests/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn create_embedder_proxy() -> EmbedderProxy {
6767
}
6868
impl EventLoopWaker for DummyEventLoopWaker {
6969
fn wake(&self) {}
70-
fn clone(&self) -> Box<dyn EventLoopWaker + Send> {
70+
fn clone_box(&self) -> Box<dyn EventLoopWaker> {
7171
Box::new(DummyEventLoopWaker {})
7272
}
7373
}

components/servo/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,10 @@ where
289289
// the client window and the compositor. This channel is unique because
290290
// messages to client may need to pump a platform-specific event loop
291291
// to deliver the message.
292+
let event_loop_waker = embedder.create_event_loop_waker();
292293
let (compositor_proxy, compositor_receiver) =
293-
create_compositor_channel(embedder.create_event_loop_waker());
294-
let (embedder_proxy, embedder_receiver) =
295-
create_embedder_channel(embedder.create_event_loop_waker());
294+
create_compositor_channel(event_loop_waker.clone());
295+
let (embedder_proxy, embedder_receiver) = create_embedder_channel(event_loop_waker.clone());
296296
let time_profiler_chan = profile_time::Profiler::create(
297297
&opts.time_profiling,
298298
opts.time_profiler_trace_path.clone(),
@@ -368,8 +368,8 @@ where
368368

369369
// For the moment, we enable use both the webxr crate and the rust-webvr crate,
370370
// but we are migrating over to just using webxr.
371-
let mut webxr_main_thread =
372-
webxr_api::MainThreadRegistry::new().expect("Failed to create WebXR device registry");
371+
let mut webxr_main_thread = webxr_api::MainThreadRegistry::new(event_loop_waker)
372+
.expect("Failed to create WebXR device registry");
373373
if pref!(dom.webvr.enabled) || pref!(dom.webxr.enabled) {
374374
embedder.register_webxr(&mut webxr_main_thread);
375375
}

ports/glutin/events_loop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl EventLoopWaker for HeadedEventLoopWaker {
8787
warn!("Failed to wake up event loop ({}).", err);
8888
}
8989
}
90-
fn clone(&self) -> Box<dyn EventLoopWaker + Send> {
90+
fn clone_box(&self) -> Box<dyn EventLoopWaker> {
9191
Box::new(HeadedEventLoopWaker {
9292
proxy: self.proxy.clone(),
9393
})
@@ -97,5 +97,5 @@ impl EventLoopWaker for HeadedEventLoopWaker {
9797
struct HeadlessEventLoopWaker;
9898
impl EventLoopWaker for HeadlessEventLoopWaker {
9999
fn wake(&self) {}
100-
fn clone(&self) -> Box<dyn EventLoopWaker + Send> { Box::new(HeadlessEventLoopWaker) }
100+
fn clone_box(&self) -> Box<dyn EventLoopWaker> { Box::new(HeadlessEventLoopWaker) }
101101
}

ports/libmlservo/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ enum ScrollState {
403403
struct EventLoopWakerInstance;
404404

405405
impl EventLoopWaker for EventLoopWakerInstance {
406-
fn clone(&self) -> Box<dyn EventLoopWaker + Send> {
406+
fn clone_box(&self) -> Box<dyn EventLoopWaker> {
407407
Box::new(EventLoopWakerInstance)
408408
}
409409

ports/libsimpleservo/capi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl WakeupCallback {
373373
}
374374

375375
impl EventLoopWaker for WakeupCallback {
376-
fn clone(&self) -> Box<dyn EventLoopWaker + Send> {
376+
fn clone_box(&self) -> Box<dyn EventLoopWaker> {
377377
Box::new(WakeupCallback(self.0))
378378
}
379379
fn wake(&self) {

ports/libsimpleservo/jniapi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ impl WakeupCallback {
339339
}
340340

341341
impl EventLoopWaker for WakeupCallback {
342-
fn clone(&self) -> Box<dyn EventLoopWaker + Send> {
342+
fn clone_box(&self) -> Box<dyn EventLoopWaker> {
343343
Box::new(WakeupCallback {
344344
callback: self.callback.clone(),
345345
jvm: self.jvm.clone(),

0 commit comments

Comments
 (0)