Auto merge of #24324 - paulrouget:glwindow_keyboard, r=asajeffrey

Make it possible to navigate with the keyboard in the webxr glwindow view

The glwindow is not interactive. With this PR we can use the arrow key to look up, down, right and left.

This will make debugging a lot easier.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24324)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-10-01 04:59:31 -04:00 committed by GitHub
commit ad1d003e25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 153 additions and 86 deletions

92
Cargo.lock generated
View file

@ -141,7 +141,7 @@ version = "0.36.1"
source = "git+https://github.com/servo/rust-azure#5996612af3139cc3c5eafb019d8218f8ca1634de"
dependencies = [
"cmake 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
"servo-freetype-sys 4.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"servo-skia 0.30000022.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -396,7 +396,7 @@ dependencies = [
"canvas_traits 0.0.1",
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"embedder_traits 0.0.1",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
"half 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -420,7 +420,7 @@ name = "canvas_traits"
version = "0.0.1"
dependencies = [
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"malloc_size_of 0.0.1",
@ -612,7 +612,7 @@ version = "0.0.1"
dependencies = [
"crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"embedder_traits 0.0.1",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_traits 0.0.1",
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.22.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -654,7 +654,7 @@ dependencies = [
"debugger 0.0.1",
"devtools_traits 0.0.1",
"embedder_traits 0.0.1",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gaol 0.2.0 (git+https://github.com/servo/gaol)",
"gfx 0.0.1",
"gfx_traits 0.0.1",
@ -1193,7 +1193,7 @@ dependencies = [
[[package]]
name = "euclid"
version = "0.20.0"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1258,7 +1258,7 @@ dependencies = [
"core-text 13.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"float-ord 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1387,7 +1387,7 @@ dependencies = [
"core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 13.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"fontsan 0.4.0 (git+https://github.com/servo/fontsan)",
"freetype 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2274,7 +2274,7 @@ dependencies = [
"canvas_traits 0.0.1",
"crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"embedder_traits 0.0.1",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx 0.0.1",
@ -2320,7 +2320,7 @@ dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx 0.0.1",
"gfx_traits 0.0.1",
@ -2350,7 +2350,7 @@ dependencies = [
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"embedder_traits 0.0.1",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx 0.0.1",
@ -2396,7 +2396,7 @@ dependencies = [
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"embedder_traits 0.0.1",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx 0.0.1",
@ -2439,7 +2439,7 @@ name = "layout_traits"
version = "0.0.1"
dependencies = [
"crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx 0.0.1",
"ipc-channel 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"metrics 0.0.1",
@ -2540,7 +2540,7 @@ dependencies = [
"devtools_traits 0.0.1",
"embedder_traits 0.0.1",
"env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gaol 0.2.0 (git+https://github.com/servo/gaol)",
"gfx 0.0.1",
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2633,7 +2633,7 @@ version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"arrayvec 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -2678,7 +2678,7 @@ dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"hashglobe 0.1.0",
"hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper_serde 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2741,7 +2741,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "media"
version = "0.0.1"
dependencies = [
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3187,7 +3187,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cgl 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3338,7 +3338,7 @@ name = "peek-poke"
version = "0.2.0"
source = "git+https://github.com/servo/webrender#4646982f69d90f0b39b6345be4e4dbd96ce5ac05"
dependencies = [
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"peek-poke-derive 0.2.0 (git+https://github.com/servo/webrender)",
]
@ -3411,7 +3411,7 @@ dependencies = [
name = "pixels"
version = "0.0.1"
dependencies = [
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"malloc_size_of 0.0.1",
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3428,7 +3428,7 @@ version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -3663,7 +3663,7 @@ name = "raqote"
version = "0.6.5-alpha.0"
source = "git+https://github.com/jrmuizel/raqote#c9d6d9c65ffac5fe91e2699f9854b3fbaa3c85c2"
dependencies = [
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"font-kit 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lyon_geom 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"png 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3780,7 +3780,7 @@ version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bindgen 0.51.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3885,7 +3885,7 @@ dependencies = [
"embedder_traits 0.0.1",
"encoding_rs 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)",
"enum-iterator 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"headers 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"html5ever 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3967,7 +3967,7 @@ dependencies = [
"canvas_traits 0.0.1",
"crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_traits 0.0.1",
"html5ever 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -4004,7 +4004,7 @@ dependencies = [
name = "script_tests"
version = "0.0.1"
dependencies = [
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"keyboard-types 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
"script 0.0.1",
"servo_url 0.0.1",
@ -4020,7 +4020,7 @@ dependencies = [
"crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"devtools_traits 0.0.1",
"embedder_traits 0.0.1",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_traits 0.0.1",
"http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)",
@ -4137,7 +4137,7 @@ dependencies = [
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
"clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.22.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -4214,7 +4214,7 @@ source = "git+https://github.com/servo/media#7776958f353b5881fa1d6ec97a236940f7a
dependencies = [
"boxfnonce 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
@ -4354,7 +4354,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cgl 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cmake 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"expat-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -4399,7 +4399,7 @@ dependencies = [
"dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"embedder_traits 0.0.1",
"env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -4428,7 +4428,7 @@ name = "servo_geometry"
version = "0.0.1"
dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"malloc_size_of 0.0.1",
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"style_traits 0.0.1",
@ -4712,7 +4712,7 @@ dependencies = [
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fallible 0.0.1",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"hashglobe 0.1.0",
@ -4778,7 +4778,7 @@ dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"html5ever 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.21.0",
@ -4800,7 +4800,7 @@ dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"malloc_size_of 0.0.1",
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -5510,7 +5510,7 @@ dependencies = [
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cookie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.22.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -5546,7 +5546,7 @@ dependencies = [
"core-text 13.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cstr 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
@ -5583,7 +5583,7 @@ dependencies = [
"core-foundation 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
"derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"peek-poke 0.2.0 (git+https://github.com/servo/webrender)",
@ -5606,7 +5606,7 @@ dependencies = [
name = "webrender_traits"
version = "0.0.1"
dependencies = [
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender 0.60.0 (git+https://github.com/servo/webrender)",
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)",
]
@ -5617,7 +5617,7 @@ version = "0.0.1"
dependencies = [
"canvas_traits 0.0.1",
"crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -5643,10 +5643,10 @@ dependencies = [
[[package]]
name = "webxr"
version = "0.0.1"
source = "git+https://github.com/servo/webxr#876424c9adbe4592518f76888452c0cdbb6adbed"
source = "git+https://github.com/servo/webxr#72d85b8254f8ce5d10f91d59ed35cd5969d15ed8"
dependencies = [
"bindgen 0.51.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -5661,9 +5661,9 @@ dependencies = [
[[package]]
name = "webxr-api"
version = "0.0.1"
source = "git+https://github.com/servo/webxr#876424c9adbe4592518f76888452c0cdbb6adbed"
source = "git+https://github.com/servo/webxr#72d85b8254f8ce5d10f91d59ed35cd5969d15ed8"
dependencies = [
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -5759,7 +5759,7 @@ version = "0.0.1"
source = "git+https://github.com/servo/webrender#4646982f69d90f0b39b6345be4e4dbd96ce5ac05"
dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -5961,7 +5961,7 @@ dependencies = [
"checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e"
"checksum erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3beee4bc16478a1b26f2e80ad819a52d24745e292f521a63c16eea5f74b7eb60"
"checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02"
"checksum euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4786521fec183792e755bf32cd0188e4e7628c6d0fcfd51426435b9081a106"
"checksum euclid 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89c879a4e57d6a2785d517b0771ea6857916173debef0102bf81142d36ca9254"
"checksum expat-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa"
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
"checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"

View file

@ -9,19 +9,24 @@ use crate::embedder::EmbedderCallbacks;
use crate::window_trait::WindowPortsMethods;
use crate::events_loop::EventsLoop;
use crate::{headed_window, headless_window};
use glutin::WindowId;
use servo::compositing::windowing::WindowEvent;
use servo::config::opts::{self, parse_url_or_filename};
use servo::servo_config::pref;
use servo::servo_url::ServoUrl;
use servo::{BrowserId, Servo};
use std::cell::{Cell, RefCell};
use std::collections::HashMap;
use std::env;
use std::mem;
use std::rc::Rc;
thread_local! {
pub static WINDOWS: RefCell<HashMap<WindowId, Rc<dyn WindowPortsMethods>>> = RefCell::new(HashMap::new());
}
pub struct App {
events_loop: Rc<RefCell<EventsLoop>>,
window: Rc<dyn WindowPortsMethods>,
servo: RefCell<Servo<dyn WindowPortsMethods>>,
browser: RefCell<Browser<dyn WindowPortsMethods>>,
event_queue: RefCell<Vec<WindowEvent>>,
@ -54,10 +59,11 @@ impl App {
servo.handle_events(vec![WindowEvent::NewBrowser(get_default_url(), browser_id)]);
servo.setup_logging();
register_window(window);
let app = App {
event_queue: RefCell::new(vec![]),
events_loop,
window: window,
browser: RefCell::new(browser),
servo: RefCell::new(servo),
suspended: Cell::new(false),
@ -89,18 +95,24 @@ impl App {
glutin::Event::WindowEvent {
window_id, event, ..
} => {
if Some(window_id) != self.window.id() {
warn!("Got an event from unknown window");
} else {
// Resize events need to be handled during run_forever
let cont = if let glutin::WindowEvent::Resized(_) = event {
glutin::ControlFlow::Continue
} else {
glutin::ControlFlow::Break
};
self.window.winit_event_to_servo_event(event);
return cont;
}
return WINDOWS.with(|windows| {
match windows.borrow().get(&window_id) {
None => {
warn!("Got an event from unknown window");
glutin::ControlFlow::Break
},
Some(window) => {
// Resize events need to be handled during run_forever
let cont = if let glutin::WindowEvent::Resized(_) = event {
glutin::ControlFlow::Continue
} else {
glutin::ControlFlow::Break
};
window.winit_event_to_servo_event(event);
return cont;
}
}
});
},
}
glutin::ControlFlow::Break
@ -108,7 +120,10 @@ impl App {
fn run_loop(self) {
loop {
if !self.window.is_animating() || self.suspended.get() {
let animating = WINDOWS.with(|windows| {
windows.borrow().iter().any(|(_, window)| window.is_animating())
});
if !animating || self.suspended.get() {
// If there's no animations running then we block on the window event loop.
self.events_loop.borrow_mut().run_forever(|e| {
let cont = self.winit_event_to_servo_event(e);
@ -141,18 +156,27 @@ impl App {
let mut browser = self.browser.borrow_mut();
let mut servo = self.servo.borrow_mut();
let win_events = self.window.get_events();
// FIXME:
// As of now, we support only one browser (self.browser)
// but have multiple windows (dom.webxr.glwindow). We forward
// the events of all the windows combined to that single
// browser instance. Pressing the "a" key on the glwindow
// will send a key event to the servo window.
let mut app_events = self.get_events();
WINDOWS.with(|windows| {
for (_win_id, window) in &*windows.borrow() {
app_events.extend(window.get_events());
}
});
// FIXME: this could be handled by Servo. We don't need
// a repaint_synchronously function exposed.
let need_resize = win_events.iter().any(|e| match *e {
let need_resize = app_events.iter().any(|e| match *e {
WindowEvent::Resize => true,
_ => false,
});
let mut app_events = self.get_events();
app_events.extend(win_events);
browser.handle_window_events(app_events);
let mut servo_events = servo.get_events();
@ -189,6 +213,12 @@ fn get_default_url() -> ServoUrl {
cmdline_url.or(pref_url).or(blank_url).unwrap()
}
pub fn register_window(window: Rc<dyn WindowPortsMethods>) {
WINDOWS.with(|w| {
w.borrow_mut().insert(window.id(), window);
});
}
pub fn gl_version() -> glutin::GlRequest {
if opts::get().angle {
glutin::GlRequest::Specific(glutin::Api::OpenGlEs, (3, 0))

View file

@ -9,7 +9,7 @@ use crate::context::GlContext;
use crate::events_loop::EventsLoop;
use crate::keyutils::keyboard_event_from_winit;
use crate::window_trait::{WindowPortsMethods, LINE_HEIGHT};
use euclid::{default::Size2D as UntypedSize2D, Point2D, Scale, Size2D, Vector2D};
use euclid::{Angle, default::Size2D as UntypedSize2D, Point2D, Rotation3D, Scale, Size2D, UnknownUnit, Vector2D};
use gleam::gl;
use glutin::dpi::{LogicalPosition, LogicalSize, PhysicalSize};
#[cfg(target_os = "macos")]
@ -17,7 +17,7 @@ use glutin::os::macos::{ActivationPolicy, WindowBuilderExt};
use glutin::Api;
#[cfg(any(target_os = "linux", target_os = "windows"))]
use glutin::Icon;
use glutin::{ElementState, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase};
use glutin::{ElementState, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode};
#[cfg(any(target_os = "linux", target_os = "windows"))]
use image;
use keyboard_types::{Key, KeyState, KeyboardEvent};
@ -68,6 +68,7 @@ pub struct Window {
animation_state: Cell<AnimationState>,
fullscreen: Cell<bool>,
gl: Rc<dyn gl::Gl>,
xr_rotation: Cell<Rotation3D<f32, UnknownUnit, UnknownUnit>>,
}
#[cfg(not(target_os = "windows"))]
@ -194,6 +195,7 @@ impl Window {
inner_size: Cell::new(inner_size),
primary_monitor,
screen_size,
xr_rotation: Cell::new(Rotation3D::identity()),
};
window.present();
@ -235,12 +237,36 @@ impl Window {
self.last_pressed.set(Some(event));
} else if event.key != Key::Unidentified {
self.last_pressed.set(None);
self.handle_xr_rotation(&input);
self.event_queue
.borrow_mut()
.push(WindowEvent::Keyboard(event));
}
}
fn handle_xr_rotation(&self, input: &KeyboardInput) {
if input.state != glutin::ElementState::Pressed {
return;
}
let mut x = 0.0;
let mut y = 0.0;
match input.virtual_keycode {
Some(VirtualKeyCode::Up) => x = 1.0,
Some(VirtualKeyCode::Down) => x = -1.0,
Some(VirtualKeyCode::Left) => y = 1.0,
Some(VirtualKeyCode::Right) => y = -1.0,
_ => return,
};
if input.modifiers.shift {
x = 10.0 * x;
y = 10.0 * y;
}
let x: Rotation3D<_, UnknownUnit, UnknownUnit> = Rotation3D::around_x(Angle::degrees(x));
let y: Rotation3D<_, UnknownUnit, UnknownUnit> = Rotation3D::around_y(Angle::degrees(y));
let rotation = self.xr_rotation.get().post_rotate(&x).post_rotate(&y);
self.xr_rotation.set(rotation);
}
/// Helper function to handle a click
fn handle_mouse(
&self,
@ -394,8 +420,8 @@ impl WindowPortsMethods for Window {
self.animation_state.get() == AnimationState::Animating
}
fn id(&self) -> Option<glutin::WindowId> {
Some(self.gl_context.borrow().window().id())
fn id(&self) -> glutin::WindowId {
self.gl_context.borrow().window().id()
}
fn winit_event_to_servo_event(&self, event: glutin::WindowEvent) {
@ -486,15 +512,15 @@ impl WindowPortsMethods for Window {
}
impl webxr::glwindow::GlWindow for Window {
fn make_current(&mut self) {
fn make_current(&self) {
debug!("Making window {:?} current", self.gl_context.borrow().window().id());
self.gl_context.get_mut().make_current();
self.gl_context.borrow_mut().make_current();
}
fn swap_buffers(&mut self) {
fn swap_buffers(&self) {
debug!("Swapping buffers on window {:?}", self.gl_context.borrow().window().id());
self.gl_context.get_mut().swap_buffers();
self.gl_context.get_mut().make_not_current();
self.gl_context.borrow().swap_buffers();
self.gl_context.borrow_mut().make_not_current();
}
fn size(&self) -> UntypedSize2D<gl::GLsizei> {
@ -508,12 +534,18 @@ impl webxr::glwindow::GlWindow for Window {
Size2D::new(width * dpr, height *dpr).to_i32()
}
fn new_window(&self) -> Result<Box<dyn webxr::glwindow::GlWindow>, ()> {
Ok(Box::new(Window::new(
fn get_rotation(&self) -> Rotation3D<f32, UnknownUnit, UnknownUnit> {
self.xr_rotation.get().clone()
}
fn new_window(&self) -> Result<Rc<dyn webxr::glwindow::GlWindow>, ()> {
let window = Rc::new(Window::new(
self.inner_size.get(),
Some(self),
self.events_loop.clone(),
)))
));
app::register_window(window.clone());
Ok(window)
}
}

View file

@ -6,7 +6,7 @@
use crate::window_trait::WindowPortsMethods;
use glutin;
use euclid::{default::Size2D as UntypedSize2D, Point2D, Scale, Size2D};
use euclid::{default::Size2D as UntypedSize2D, Point2D, Rotation3D, Scale, Size2D, UnknownUnit};
use gleam::gl;
use servo::compositing::windowing::{AnimationState, WindowEvent};
use servo::compositing::windowing::{EmbedderCoordinates, WindowMethods};
@ -132,8 +132,10 @@ impl WindowPortsMethods for Window {
false
}
fn id(&self) -> Option<glutin::WindowId> {
None
fn id(&self) -> glutin::WindowId {
unsafe {
glutin::WindowId::dummy()
}
}
fn page_height(&self) -> f32 {
@ -217,23 +219,26 @@ impl WindowMethods for Window {
}
impl webxr::glwindow::GlWindow for Window {
fn make_current(&mut self) {}
fn swap_buffers(&mut self) {}
fn make_current(&self) {}
fn swap_buffers(&self) {}
fn size(&self) -> UntypedSize2D<gl::GLsizei> {
let dpr = self.servo_hidpi_factor().get();
Size2D::new((self.context.width as f32 * dpr) as gl::GLsizei, (self.context.height as f32 * dpr) as gl::GLsizei)
}
fn new_window(&self) -> Result<Box<dyn webxr::glwindow::GlWindow>, ()> {
fn new_window(&self) -> Result<Rc<dyn webxr::glwindow::GlWindow>, ()> {
let width = self.context.width;
let height = self.context.height;
let share = Some(&self.context);
let context = HeadlessContext::new(width, height, share);
let gl = self.gl.clone();
Ok(Box::new(Window {
Ok(Rc::new(Window {
context,
gl,
animation_state: Cell::new(AnimationState::Idle),
fullscreen: Cell::new(false),
}))
}
fn get_rotation(&self) -> Rotation3D<f32, UnknownUnit, UnknownUnit> {
Rotation3D::identity()
}
}

View file

@ -15,7 +15,7 @@ pub const LINE_HEIGHT: f32 = 38.0;
pub trait WindowPortsMethods: WindowMethods + webxr::glwindow::GlWindow {
fn get_events(&self) -> Vec<WindowEvent>;
fn id(&self) -> Option<glutin::WindowId>;
fn id(&self) -> glutin::WindowId;
fn has_events(&self) -> bool;
fn page_height(&self) -> f32;
fn get_fullscreen(&self) -> bool;