зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #19895 - unfork glutin (from paulrouget:unfork); r=paulrouget
I'm taking over #19120. Fix #18918. Beside the change in the API, I had to rewrite main loop. At this point, we should have a very similar behavior as servo-glutin. Source-Repo: https://github.com/servo/servo Source-Revision: c9f60c5a6778fe47cae85fcd88cb38257a220bb1 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : e3ef5fbc5962e96c48a1340e589054aa2086bb92
This commit is contained in:
Родитель
9e399147af
Коммит
4955984079
|
@ -18,12 +18,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "android_glue"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "android_injected_glue"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
@ -97,7 +97,7 @@ dependencies = [
|
|||
"euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo-freetype-sys 4.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo-skia 0.30000013.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo-skia 0.30000013.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -730,6 +730,14 @@ dependencies = [
|
|||
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dlib"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libloading 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dom_struct"
|
||||
version = "0.0.1"
|
||||
|
@ -755,15 +763,6 @@ dependencies = [
|
|||
"dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dwmapi-sys"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dwrote"
|
||||
version = "0.4.2"
|
||||
|
@ -1084,6 +1083,28 @@ name = "glob"
|
|||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "glutin"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cgl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cocoa 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"shared_library 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-client 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winit 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"x11-dl 2.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glx"
|
||||
version = "0.2.3"
|
||||
|
@ -1663,6 +1684,15 @@ dependencies = [
|
|||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memmap"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.2.1"
|
||||
|
@ -2341,7 +2371,7 @@ name = "rust-webvr-api"
|
|||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"android_injected_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"android_injected_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2624,13 +2654,14 @@ dependencies = [
|
|||
name = "servo"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"android_injected_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"android_injected_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"compositing 0.0.1",
|
||||
"euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"glutin 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libservo 0.0.1",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
|
@ -2639,7 +2670,6 @@ dependencies = [
|
|||
"osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script_traits 0.0.1",
|
||||
"servo-egl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo-glutin 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo_config 0.0.1",
|
||||
"servo_geometry 0.0.1",
|
||||
"servo_url 0.0.1",
|
||||
|
@ -2688,35 +2718,9 @@ dependencies = [
|
|||
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "servo-glutin"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"android_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cgl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cocoa 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwmapi-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"image 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"shared_library 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"x11-dl 2.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "servo-skia"
|
||||
version = "0.30000013.0"
|
||||
version = "0.30000013.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cgl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2724,13 +2728,13 @@ dependencies = [
|
|||
"euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"expat-sys 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"glutin 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"glx 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"io-surface 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo-egl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo-fontconfig-sys 4.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo-freetype-sys 4.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo-glutin 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"x11 2.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -2780,7 +2784,7 @@ dependencies = [
|
|||
name = "servo_config"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"android_injected_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"android_injected_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2851,15 +2855,6 @@ dependencies = [
|
|||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shell32-sys"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sig"
|
||||
version = "0.1.1"
|
||||
|
@ -3117,6 +3112,18 @@ dependencies = [
|
|||
"gcc 0.3.47 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tendril"
|
||||
version = "0.4.0"
|
||||
|
@ -3193,6 +3200,11 @@ dependencies = [
|
|||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "token_store"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.2.1"
|
||||
|
@ -3355,6 +3367,69 @@ dependencies = [
|
|||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wayland-client"
|
||||
version = "0.12.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"token_store 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-scanner 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-sys 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wayland-kbd"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dlib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-client 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wayland-protocols"
|
||||
version = "0.12.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-client 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-scanner 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-sys 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wayland-scanner"
|
||||
version = "0.12.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wayland-sys"
|
||||
version = "0.12.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"dlib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wayland-window"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-client 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-protocols 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webdriver"
|
||||
version = "0.33.0"
|
||||
|
@ -3501,6 +3576,27 @@ name = "winapi-x86_64-pc-windows-gnu"
|
|||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winit"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cocoa 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-client 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-kbd 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-protocols 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-window 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"x11-dl 2.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ws"
|
||||
version = "0.6.0"
|
||||
|
@ -3545,10 +3641,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "x11-dl"
|
||||
version = "2.14.0"
|
||||
version = "2.17.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -3595,8 +3691,8 @@ dependencies = [
|
|||
"checksum adler32 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ff33fe13a08dbce05bcefa2c68eea4844941437e33d6f808240b54d7157b9cd"
|
||||
"checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699"
|
||||
"checksum alloc-no-stdlib 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b21f6ad9c9957eb5d70c3dee16d31c092b3cab339628f821766b05e6833d72b8"
|
||||
"checksum android_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d8289e9637439939cc92b1995b0972117905be88bc28116c86b64d6e589bcd38"
|
||||
"checksum android_injected_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ec08bc5e100186b5223a24dcfe5655d1488aed9eafeb44fb9a0f67a4f53d0fc"
|
||||
"checksum android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407"
|
||||
"checksum android_injected_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "80b9e34fcbf29c0563547cb2ecce9b49504597cad6166769b1e4efb45c6c2951"
|
||||
"checksum angle 0.5.0 (git+https://github.com/servo/angle?branch=servo)" = "<none>"
|
||||
"checksum ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b3568b48b7cefa6b8ce125f9bb4989e52fbcc29ebea88df04cc7c5f12f70455"
|
||||
"checksum antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5"
|
||||
|
@ -3657,9 +3753,9 @@ dependencies = [
|
|||
"checksum debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a032eac705ca39214d169f83e3d3da290af06d8d1d344d1baad2fd002dca4b3"
|
||||
"checksum deflate 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ebb02aaf4b775afc96684b8402510a338086974e38570a1f65bea8c202eb77a7"
|
||||
"checksum device 0.0.1 (git+https://github.com/servo/devices)" = "<none>"
|
||||
"checksum dlib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "95518d8f88d556e62c9b3014629f21bdad97a9fdfee85c68a185e3980af29e7c"
|
||||
"checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90"
|
||||
"checksum dtoa-short 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe6f727b406462fd57c95fed84d1b0dbfb5f0136fcac005adba9ea0367c05cc8"
|
||||
"checksum dwmapi-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b44b6442aeab12e609aee505bd1066bdfd36b79c3fe5aad604aae91537623e76"
|
||||
"checksum dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b26e30aaa6bf31ec830db15fec14ed04f0f2ecfcc486ecfce88c55d3389b237f"
|
||||
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
|
||||
"checksum encoding_rs 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f5215aabf22b83153be3ee44dfe3f940214541b2ce13d419c55e7a115c8c51a9"
|
||||
|
@ -3689,6 +3785,7 @@ dependencies = [
|
|||
"checksum gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a795170cbd85b5a7baa58d6d7525cae6a03e486859860c220f7ebbbdd379d0a"
|
||||
"checksum gleam 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a7f5351837630a7dd0cd6d7976de547929f9fabd381b9d5ac35f82e90be2"
|
||||
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
|
||||
"checksum glutin 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90de8e0391e57098acfbfe693b23065e9186255d370ebae12c933b7d77df8424"
|
||||
"checksum glx 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "63a6e7c2846e12626455f45ebaff9d92161436dd0fa703d9d198012e528ca7b9"
|
||||
"checksum gvr-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1334b94d8ce67319ddc44663daef53d8c1538629a11562530c981dbd9085b9a"
|
||||
"checksum half 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63d68db75012a85555434ee079e7e6337931f87a087ab2988becbadf64673a7f"
|
||||
|
@ -3734,6 +3831,7 @@ dependencies = [
|
|||
"checksum markup5ever 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c220b3a3d75543b76e5c1fcab6635a8430ab5f9bfa011d003c3787ae0abf4ffa"
|
||||
"checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1"
|
||||
"checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4"
|
||||
"checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff"
|
||||
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
|
||||
"checksum mime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9d69889cdc6336ed56b174514ce876c4c3dc564cc23dd872e7bca589bb2a36c8"
|
||||
"checksum mime_guess 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76da6df85047af8c0edfa53f48eb1073012ce1cc95c8fedc0a374f659a89dd65"
|
||||
|
@ -3811,12 +3909,10 @@ dependencies = [
|
|||
"checksum servo-fontconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "93f799b649b4a2bf362398910eca35240704c7e765e780349b2bb1070d892262"
|
||||
"checksum servo-fontconfig-sys 4.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "38b494f03009ee81914b0e7d387ad7c145cafcd69747c2ec89b0e17bb94f303a"
|
||||
"checksum servo-freetype-sys 4.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9232032c2e85118c0282c6562c84cab12316e655491ba0a5d1905b2320060d1b"
|
||||
"checksum servo-glutin 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a36b9398e9cade5b1e3011d841d9d98d4e86a538a1b639db62100d86134c10f6"
|
||||
"checksum servo-skia 0.30000013.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1be5e09cb97ea135d1223fa226f8880f124aed2fa887bf5acf10ef16ad94e072"
|
||||
"checksum servo-skia 0.30000013.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3fb707c7dc3d8a053b8c9d48ed9eb7f2a0c0751616dfbe3598f526948408bc33"
|
||||
"checksum servo-websocket 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efde78dfcf2178d5a11e1e2268e0d8df0627dfe2724546db8585d6678e1af150"
|
||||
"checksum sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc30b1e1e8c40c121ca33b86c23308a090d19974ef001b4bf6e61fd1a0fb095c"
|
||||
"checksum shared_library 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fb04126b6fcfd2710fb5b6d18f4207b6c535f2850a7e1a43bcd526d44f30a79a"
|
||||
"checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c"
|
||||
"checksum sig 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c6649e43c1a1e68d29ed56d0dc3b5b6cf3b901da77cf107c4066b9e3da036df5"
|
||||
"checksum signpost 0.1.0 (git+https://github.com/pcwalton/signpost.git)" = "<none>"
|
||||
"checksum simd 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a94d14a2ae1f1f110937de5fb69e494372560181c7e1739a097fcc2cee37ba0"
|
||||
|
@ -3834,6 +3930,7 @@ dependencies = [
|
|||
"checksum syn 0.12.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9e1c669ed757c0ebd04337f6a5bb972d05e0c08fe2540dd3ee3dd9e4daf1604c"
|
||||
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
|
||||
"checksum synstructure 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "010366096045d8250555904c58da03377289e7f4b2ce7a5b1027e2b532f41000"
|
||||
"checksum tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11ce2fe9db64b842314052e2421ac61a73ce41b898dc8e3750398b219c5fc1e0"
|
||||
"checksum tendril 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9de21546595a0873061940d994bbbc5c35f024ae4fd61ec5c5b159115684f508"
|
||||
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
|
||||
"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693"
|
||||
|
@ -3843,6 +3940,7 @@ dependencies = [
|
|||
"checksum threadpool 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "59f6d3eff89920113dac9db44dde461d71d01e88a5b57b258a0466c32b5d7fe1"
|
||||
"checksum time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "ffd7ccbf969a892bf83f1e441126968a07a3941c24ff522a26af9f9f4585d1a3"
|
||||
"checksum tinyfiledialogs 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d92a5f7395a9e2895a2361c3121d4a0be0f8dac3be7d91841a5c1c5291b1c6dc"
|
||||
"checksum token_store 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a686838375fc11103b9c1529c6508320b7bd5e2401cd62831ca51b3e82e61849"
|
||||
"checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4"
|
||||
"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
|
||||
"checksum truetype 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)" = "acec30350633d6dac9dc1a625786b6cbe9150664be941aac2c35ad7199eab877"
|
||||
|
@ -3867,6 +3965,12 @@ dependencies = [
|
|||
"checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c"
|
||||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
"checksum walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bb08f9e670fab86099470b97cd2b252d6527f0b3cc1401acdb595ffc9dd288ff"
|
||||
"checksum wayland-client 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2b90adf943117ee4930d7944fe103dcb6f36ba05421f46521cb5adbf6bf0fbc8"
|
||||
"checksum wayland-kbd 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4fe0fb1c9917da9529d781659e456d84a693d74fe873d1658109758444616f76"
|
||||
"checksum wayland-protocols 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fb5942dd2fc79d934db437c9ea3aabffceb49b546046ea453bcba531005e5537"
|
||||
"checksum wayland-scanner 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dcffa55a621e6f2c3d436de64d840fc325e1d0a467b92ee5e7292e17552e08ad"
|
||||
"checksum wayland-sys 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)" = "377a2f83063c463e801ca10ae8cb9666e6e597eecac0049ac36cc7b9a83b0db3"
|
||||
"checksum wayland-window 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2d94d3c23f8f2e0a09d82c6ca765da3c1efe65ef0280f750d74a6c6c6bb4ca8f"
|
||||
"checksum webdriver 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6577005cf83a9df4ba39910f8baf3b835b5e4a0a5e9a0d71f3eceae6214ebf28"
|
||||
"checksum webrender 0.57.0 (git+https://github.com/servo/webrender)" = "<none>"
|
||||
"checksum webrender_api 0.57.0 (git+https://github.com/servo/webrender)" = "<none>"
|
||||
|
@ -3876,11 +3980,12 @@ dependencies = [
|
|||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ec6667f60c23eca65c561e63a13d81b44234c2e38a6b6c959025ee907ec614cc"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "98f12c52b2630cd05d2c3ffd8e008f7f48252c042b4871c72aed9dc733b96668"
|
||||
"checksum winit 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "396f0350e661940359e3c8c7d58ff847f67997943e2c80ecac374c5aa8287f63"
|
||||
"checksum ws 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "04614a58714f3fd4a8b1da4bcae9f031c532d35988c3d39627619248113f8be8"
|
||||
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
|
||||
"checksum x11 2.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e5c4ac579b5d324dc4add02312b5d0e3e0218521e2d5779d526ac39ee4bb171"
|
||||
"checksum x11-clipboard 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "78a35cd979d17b95e0706ab1f3425ecc98565d3873902bd5944b9f5f388327d1"
|
||||
"checksum x11-dl 2.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "326c500cdc166fd7c70dd8c8a829cd5c0ce7be5a5d98c25817de2b9bdc67faf8"
|
||||
"checksum x11-dl 2.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "29e78a65a3239e5511ffe2c832edb9224982ebf67bcaabc218ef1b07d8494b3e"
|
||||
"checksum xcb 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "400cebeaedeca931825f11606874080f18aa51370dd3d7e11bc08d5aac8b3142"
|
||||
"checksum xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a66b7c2281ebde13cf4391d70d4c7e5946c3c25e72a7b859ca8f677dcd0b0c61"
|
||||
"checksum xi-unicode 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "12ea8eda4b1eb72f02d148402e23832d56a33f55d8c1b2d5bcdde91d79d47cb1"
|
||||
|
|
|
@ -646,10 +646,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
device_pixel_ratio: dppx,
|
||||
initial_viewport: initial_viewport,
|
||||
};
|
||||
let top_level_browsing_context_id = match self.root_pipeline {
|
||||
Some(ref pipeline) => pipeline.top_level_browsing_context_id,
|
||||
None => return warn!("Window resize without root pipeline."),
|
||||
};
|
||||
let top_level_browsing_context_id = self.root_pipeline.as_ref().map(|pipeline| {
|
||||
pipeline.top_level_browsing_context_id
|
||||
});
|
||||
let msg = ConstellationMsg::WindowSize(top_level_browsing_context_id, data, size_type);
|
||||
|
||||
if let Err(e) = self.constellation_chan.send(msg) {
|
||||
|
|
|
@ -2551,14 +2551,16 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
|||
|
||||
/// Called when the window is resized.
|
||||
fn handle_window_size_msg(&mut self,
|
||||
top_level_browsing_context_id: TopLevelBrowsingContextId,
|
||||
top_level_browsing_context_id: Option<TopLevelBrowsingContextId>,
|
||||
new_size: WindowSizeData,
|
||||
size_type: WindowSizeType)
|
||||
{
|
||||
debug!("handle_window_size_msg: {:?}", new_size.initial_viewport.to_untyped());
|
||||
|
||||
let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id);
|
||||
self.resize_browsing_context(new_size, size_type, browsing_context_id);
|
||||
if let Some(top_level_browsing_context_id) = top_level_browsing_context_id {
|
||||
let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id);
|
||||
self.resize_browsing_context(new_size, size_type, browsing_context_id);
|
||||
}
|
||||
|
||||
if let Some(resize_channel) = self.webdriver.resize_channel.take() {
|
||||
let _ = resize_channel.send(new_size);
|
||||
|
|
|
@ -678,7 +678,7 @@ pub enum ConstellationMsg {
|
|||
/// 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),
|
||||
WindowSize(Option<TopLevelBrowsingContextId>, WindowSizeData, WindowSizeType),
|
||||
/// Requests that the constellation instruct layout to begin a new tick of the animation.
|
||||
TickAnimation(PipelineId, AnimationTickType),
|
||||
/// Dispatch a webdriver command
|
||||
|
|
|
@ -30,12 +30,12 @@ bitflags = "1.0"
|
|||
compositing = {path = "../../components/compositing"}
|
||||
euclid = "0.17"
|
||||
gleam = "0.4"
|
||||
glutin = "0.13"
|
||||
libservo = {path = "../../components/servo"}
|
||||
log = "0.3.5"
|
||||
msg = {path = "../../components/msg"}
|
||||
net_traits = {path = "../../components/net_traits"}
|
||||
script_traits = {path = "../../components/script_traits"}
|
||||
servo-glutin = "0.15"
|
||||
servo_geometry = {path = "../../components/geometry"}
|
||||
servo_config = {path = "../../components/config"}
|
||||
servo_url = {path = "../../components/url"}
|
||||
|
|
|
@ -6,14 +6,9 @@
|
|||
|
||||
pub mod window;
|
||||
|
||||
use compositing::windowing::WindowEvent;
|
||||
use servo_config::opts;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub trait NestedEventLoopListener {
|
||||
fn handle_event_from_nested_event_loop(&mut self, event: WindowEvent) -> bool;
|
||||
}
|
||||
|
||||
pub fn create_window() -> Rc<window::Window> {
|
||||
// Read command-line options.
|
||||
let opts = opts::get();
|
||||
|
|
|
@ -5,16 +5,14 @@
|
|||
//! A windowing implementation using glutin.
|
||||
|
||||
use compositing::compositor_thread::EventLoopWaker;
|
||||
use compositing::windowing::{AnimationState, MouseWindowEvent};
|
||||
use compositing::windowing::{WebRenderDebugOption, WindowEvent, WindowMethods};
|
||||
use compositing::windowing::{AnimationState, MouseWindowEvent, WindowEvent};
|
||||
use compositing::windowing::{WebRenderDebugOption, WindowMethods};
|
||||
use euclid::{Point2D, Size2D, TypedPoint2D, TypedVector2D, TypedScale, TypedSize2D};
|
||||
#[cfg(target_os = "windows")]
|
||||
use gdi32;
|
||||
use gleam::gl;
|
||||
use glutin;
|
||||
use glutin::{Api, ElementState, Event, GlRequest, MouseButton, MouseScrollDelta, VirtualKeyCode};
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
use glutin::ScanCode;
|
||||
use glutin::{Api, ElementState, Event, GlContext, GlRequest, MouseButton, MouseScrollDelta, VirtualKeyCode};
|
||||
use glutin::TouchPhase;
|
||||
#[cfg(target_os = "macos")]
|
||||
use glutin::os::macos::{ActivationPolicy, WindowBuilderExt};
|
||||
|
@ -28,22 +26,20 @@ use script_traits::{LoadData, TouchEventType};
|
|||
use servo::ipc_channel::ipc::IpcSender;
|
||||
use servo_config::opts;
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::resource_files;
|
||||
use servo_geometry::DeviceIndependentPixel;
|
||||
use servo_url::ServoUrl;
|
||||
use std::cell::{Cell, RefCell};
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
use std::ffi::CString;
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
use std::mem;
|
||||
use std::os::raw::c_void;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use std::time;
|
||||
use style_traits::DevicePixel;
|
||||
use style_traits::cursor::CursorKind;
|
||||
use super::NestedEventLoopListener;
|
||||
use tinyfiledialogs;
|
||||
#[cfg(target_os = "windows")]
|
||||
use user32;
|
||||
|
@ -51,8 +47,6 @@ use webrender_api::{DeviceUintRect, DeviceUintSize, ScrollLocation};
|
|||
#[cfg(target_os = "windows")]
|
||||
use winapi;
|
||||
|
||||
static mut G_NESTED_EVENT_LOOP_LISTENER: Option<*mut (NestedEventLoopListener + 'static)> = None;
|
||||
|
||||
bitflags! {
|
||||
struct GlutinKeyModifiers: u8 {
|
||||
const LEFT_CONTROL = 1;
|
||||
|
@ -91,7 +85,7 @@ fn builder_with_platform_options(mut builder: glutin::WindowBuilder) -> glutin::
|
|||
// output file.
|
||||
builder = builder.with_activation_policy(ActivationPolicy::Prohibited)
|
||||
}
|
||||
builder.with_app_name(String::from("Servo"))
|
||||
builder
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
|
@ -174,13 +168,15 @@ impl HeadlessContext {
|
|||
}
|
||||
|
||||
enum WindowKind {
|
||||
Window(glutin::Window),
|
||||
Window(glutin::GlWindow, RefCell<glutin::EventsLoop>),
|
||||
Headless(HeadlessContext),
|
||||
}
|
||||
|
||||
/// The type of a window.
|
||||
pub struct Window {
|
||||
kind: WindowKind,
|
||||
screen_size: Size2D<u32>,
|
||||
inner_size: Cell<TypedSize2D<u32, DeviceIndependentPixel>>,
|
||||
|
||||
mouse_down_button: Cell<Option<glutin::MouseButton>>,
|
||||
mouse_down_point: Cell<Point2D<i32>>,
|
||||
|
@ -194,21 +190,14 @@ pub struct Window {
|
|||
key_modifiers: Cell<GlutinKeyModifiers>,
|
||||
current_url: RefCell<Option<ServoUrl>>,
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
/// The contents of the last ReceivedCharacter event for use in a subsequent KeyEvent.
|
||||
pending_key_event_char: Cell<Option<char>>,
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
last_pressed_key: Cell<Option<constellation_msg::Key>>,
|
||||
|
||||
/// The list of keys that have been pressed but not yet released, to allow providing
|
||||
/// the equivalent ReceivedCharacter data as was received for the press event.
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
pressed_key_map: RefCell<Vec<(ScanCode, char)>>,
|
||||
|
||||
animation_state: Cell<AnimationState>,
|
||||
|
||||
fullscreen: Cell<bool>,
|
||||
|
||||
gl: Rc<gl::Gl>,
|
||||
suspended: Cell<bool>,
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
|
@ -243,44 +232,52 @@ impl Window {
|
|||
// #9996.
|
||||
let visible = is_foreground && !opts::get().no_native_titlebar;
|
||||
|
||||
let screen_size;
|
||||
let inner_size;
|
||||
let window_kind = if opts::get().headless {
|
||||
screen_size = Size2D::new(width, height);
|
||||
inner_size = TypedSize2D::new(width, height);
|
||||
WindowKind::Headless(HeadlessContext::new(width, height))
|
||||
} else {
|
||||
let mut builder =
|
||||
glutin::WindowBuilder::new().with_title("Servo".to_string())
|
||||
.with_decorations(!opts::get().no_native_titlebar)
|
||||
.with_transparency(opts::get().no_native_titlebar)
|
||||
.with_dimensions(width, height)
|
||||
.with_gl(Window::gl_version())
|
||||
.with_visibility(visible)
|
||||
.with_multitouch();
|
||||
let events_loop = glutin::EventsLoop::new();
|
||||
let mut window_builder = glutin::WindowBuilder::new()
|
||||
.with_title("Servo".to_string())
|
||||
.with_decorations(!opts::get().no_native_titlebar)
|
||||
.with_transparency(opts::get().no_native_titlebar)
|
||||
.with_dimensions(width, height)
|
||||
.with_visibility(visible)
|
||||
.with_multitouch();
|
||||
|
||||
if let Ok(mut icon_path) = resource_files::resources_dir_path() {
|
||||
icon_path.push("servo.png");
|
||||
builder = builder.with_icon(icon_path);
|
||||
}
|
||||
window_builder = builder_with_platform_options(window_builder);
|
||||
|
||||
if opts::get().enable_vsync {
|
||||
builder = builder.with_vsync();
|
||||
}
|
||||
let mut context_builder = glutin::ContextBuilder::new()
|
||||
.with_gl(Window::gl_version())
|
||||
.with_vsync(opts::get().enable_vsync);
|
||||
|
||||
if opts::get().use_msaa {
|
||||
builder = builder.with_multisampling(MULTISAMPLES)
|
||||
context_builder = context_builder.with_multisampling(MULTISAMPLES)
|
||||
}
|
||||
|
||||
builder = builder_with_platform_options(builder);
|
||||
let glutin_window = glutin::GlWindow::new(window_builder, context_builder, &events_loop)
|
||||
.expect("Failed to create window.");
|
||||
|
||||
let mut glutin_window = builder.build().expect("Failed to create window.");
|
||||
unsafe {
|
||||
glutin_window.context().make_current().expect("Couldn't make window current");
|
||||
}
|
||||
|
||||
unsafe { glutin_window.make_current().expect("Failed to make context current!") }
|
||||
let (screen_width, screen_height) = events_loop.get_primary_monitor().get_dimensions();
|
||||
screen_size = Size2D::new(screen_width, screen_height);
|
||||
// TODO(ajeffrey): can this fail?
|
||||
let (width, height) = glutin_window.get_inner_size().expect("Failed to get window inner size.");
|
||||
inner_size = TypedSize2D::new(width, height);
|
||||
|
||||
glutin_window.set_window_resize_callback(Some(Window::nested_window_resize as fn(u32, u32)));
|
||||
glutin_window.show();
|
||||
|
||||
WindowKind::Window(glutin_window)
|
||||
WindowKind::Window(glutin_window, RefCell::new(events_loop))
|
||||
};
|
||||
|
||||
let gl = match window_kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
WindowKind::Window(ref window, ..) => {
|
||||
match gl::GlType::default() {
|
||||
gl::GlType::Gl => {
|
||||
unsafe {
|
||||
|
@ -325,14 +322,13 @@ impl Window {
|
|||
key_modifiers: Cell::new(GlutinKeyModifiers::empty()),
|
||||
current_url: RefCell::new(None),
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
pending_key_event_char: Cell::new(None),
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
pressed_key_map: RefCell::new(vec![]),
|
||||
#[cfg(target_os = "windows")]
|
||||
last_pressed_key: Cell::new(None),
|
||||
gl: gl.clone(),
|
||||
animation_state: Cell::new(AnimationState::Idle),
|
||||
fullscreen: Cell::new(false),
|
||||
inner_size: Cell::new(inner_size),
|
||||
screen_size,
|
||||
suspended: Cell::new(false),
|
||||
};
|
||||
|
||||
window.present();
|
||||
|
@ -340,14 +336,6 @@ impl Window {
|
|||
Rc::new(window)
|
||||
}
|
||||
|
||||
fn nested_window_resize(_width: u32, _height: u32) {
|
||||
unsafe {
|
||||
if let Some(listener) = G_NESTED_EVENT_LOOP_LISTENER {
|
||||
(*listener).handle_event_from_nested_event_loop(WindowEvent::Resize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))]
|
||||
fn gl_version() -> GlRequest {
|
||||
return GlRequest::Specific(Api::OpenGl, (3, 2));
|
||||
|
@ -358,14 +346,6 @@ impl Window {
|
|||
GlRequest::Specific(Api::OpenGlEs, (3, 0))
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn handle_received_character(&self, ch: char) {
|
||||
if !ch.is_control() {
|
||||
self.pending_key_event_char.set(Some(ch));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn handle_received_character(&self, ch: char) {
|
||||
let modifiers = Window::glutin_mods_to_script_mods(self.key_modifiers.get());
|
||||
if let Some(last_pressed_key) = self.last_pressed_key.get() {
|
||||
|
@ -403,48 +383,7 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn handle_keyboard_input(&self, element_state: ElementState, _scan_code: u8, virtual_key_code: VirtualKeyCode) {
|
||||
self.toggle_keyboard_modifiers(virtual_key_code);
|
||||
|
||||
let ch = match element_state {
|
||||
ElementState::Pressed => {
|
||||
// Retrieve any previously stored ReceivedCharacter value.
|
||||
// Store the association between the scan code and the actual
|
||||
// character value, if there is one.
|
||||
let ch = self.pending_key_event_char
|
||||
.get()
|
||||
.and_then(|ch| filter_nonprintable(ch, virtual_key_code));
|
||||
self.pending_key_event_char.set(None);
|
||||
if let Some(ch) = ch {
|
||||
self.pressed_key_map.borrow_mut().push((_scan_code, ch));
|
||||
}
|
||||
ch
|
||||
}
|
||||
|
||||
ElementState::Released => {
|
||||
// Retrieve the associated character value for this release key,
|
||||
// if one was previously stored.
|
||||
let idx = self.pressed_key_map
|
||||
.borrow()
|
||||
.iter()
|
||||
.position(|&(code, _)| code == _scan_code);
|
||||
idx.map(|idx| self.pressed_key_map.borrow_mut().swap_remove(idx).1)
|
||||
}
|
||||
};
|
||||
|
||||
if let Ok(key) = Window::glutin_key_to_script_key(virtual_key_code) {
|
||||
let state = match element_state {
|
||||
ElementState::Pressed => KeyState::Pressed,
|
||||
ElementState::Released => KeyState::Released,
|
||||
};
|
||||
let modifiers = Window::glutin_mods_to_script_mods(self.key_modifiers.get());
|
||||
self.event_queue.borrow_mut().push(WindowEvent::KeyEvent(ch, key, state, modifiers));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn handle_keyboard_input(&self, element_state: ElementState, _scan_code: u8, virtual_key_code: VirtualKeyCode) {
|
||||
fn handle_keyboard_input(&self, element_state: ElementState, virtual_key_code: VirtualKeyCode) {
|
||||
self.toggle_keyboard_modifiers(virtual_key_code);
|
||||
|
||||
if let Ok(key) = Window::glutin_key_to_script_key(virtual_key_code) {
|
||||
|
@ -462,57 +401,56 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_window_event(&self, event: glutin::Event) -> bool {
|
||||
fn handle_window_event(&self, event: glutin::Event) {
|
||||
match event {
|
||||
Event::ReceivedCharacter(ch) => {
|
||||
self.handle_received_character(ch)
|
||||
}
|
||||
Event::KeyboardInput(element_state, _scan_code, Some(virtual_key_code)) => {
|
||||
self.handle_keyboard_input(element_state, _scan_code, virtual_key_code);
|
||||
}
|
||||
Event::KeyboardInput(_, _, None) => {
|
||||
debug!("Keyboard input without virtual key.");
|
||||
}
|
||||
Event::Resized(..) => {
|
||||
self.event_queue.borrow_mut().push(WindowEvent::Resize);
|
||||
}
|
||||
Event::MouseInput(element_state, mouse_button, pos) => {
|
||||
if mouse_button == MouseButton::Left ||
|
||||
mouse_button == MouseButton::Right {
|
||||
match pos {
|
||||
Some((x, y)) => {
|
||||
self.mouse_pos.set(Point2D::new(x, y));
|
||||
self.event_queue.borrow_mut().push(
|
||||
WindowEvent::MouseWindowMoveEventClass(TypedPoint2D::new(x as f32, y as f32)));
|
||||
self.handle_mouse(mouse_button, element_state, x, y);
|
||||
}
|
||||
None => {
|
||||
let mouse_pos = self.mouse_pos.get();
|
||||
self.handle_mouse(mouse_button, element_state, mouse_pos.x, mouse_pos.y);
|
||||
}
|
||||
}
|
||||
Event::WindowEvent {
|
||||
event: glutin::WindowEvent::ReceivedCharacter(ch),
|
||||
..
|
||||
} => self.handle_received_character(ch),
|
||||
Event::WindowEvent {
|
||||
event: glutin::WindowEvent::KeyboardInput {
|
||||
input: glutin::KeyboardInput {
|
||||
state, virtual_keycode: Some(virtual_keycode), ..
|
||||
}, ..
|
||||
}, ..
|
||||
} => self.handle_keyboard_input(state, virtual_keycode),
|
||||
Event::WindowEvent {
|
||||
event: glutin::WindowEvent::MouseInput {
|
||||
state, button, ..
|
||||
}, ..
|
||||
} => {
|
||||
if button == MouseButton::Left || button == MouseButton::Right {
|
||||
let mouse_pos = self.mouse_pos.get();
|
||||
self.handle_mouse(button, state, mouse_pos.x, mouse_pos.y);
|
||||
}
|
||||
}
|
||||
Event::MouseMoved(x, y) => {
|
||||
self.mouse_pos.set(Point2D::new(x, y));
|
||||
},
|
||||
Event::WindowEvent {
|
||||
event: glutin::WindowEvent::CursorMoved {
|
||||
position: (x, y),
|
||||
..
|
||||
},
|
||||
..
|
||||
} => {
|
||||
self.mouse_pos.set(Point2D::new(x as i32, y as i32));
|
||||
self.event_queue.borrow_mut().push(
|
||||
WindowEvent::MouseWindowMoveEventClass(TypedPoint2D::new(x as f32, y as f32)));
|
||||
}
|
||||
Event::MouseWheel(delta, phase, pos) => {
|
||||
Event::WindowEvent {
|
||||
event: glutin::WindowEvent::MouseWheel { delta, phase, .. },
|
||||
..
|
||||
} => {
|
||||
let (dx, dy) = match delta {
|
||||
MouseScrollDelta::LineDelta(dx, dy) => (dx, dy * LINE_HEIGHT),
|
||||
MouseScrollDelta::PixelDelta(dx, dy) => (dx, dy),
|
||||
};
|
||||
let scroll_location = ScrollLocation::Delta(TypedVector2D::new(dx, dy));
|
||||
if let Some((x, y)) = pos {
|
||||
self.mouse_pos.set(Point2D::new(x, y));
|
||||
self.event_queue.borrow_mut().push(
|
||||
WindowEvent::MouseWindowMoveEventClass(TypedPoint2D::new(x as f32, y as f32)));
|
||||
};
|
||||
let phase = glutin_phase_to_touch_event_type(phase);
|
||||
self.scroll_window(scroll_location, phase);
|
||||
},
|
||||
Event::Touch(touch) => {
|
||||
Event::WindowEvent {
|
||||
event: glutin::WindowEvent::Touch(touch),
|
||||
..
|
||||
} => {
|
||||
use script_traits::TouchId;
|
||||
|
||||
let phase = glutin_phase_to_touch_event_type(touch.phase);
|
||||
|
@ -520,16 +458,44 @@ impl Window {
|
|||
let point = TypedPoint2D::new(touch.location.0 as f32, touch.location.1 as f32);
|
||||
self.event_queue.borrow_mut().push(WindowEvent::Touch(phase, id, point));
|
||||
}
|
||||
Event::Refresh => {
|
||||
self.event_queue.borrow_mut().push(WindowEvent::Refresh);
|
||||
Event::WindowEvent {
|
||||
event: glutin::WindowEvent::Refresh,
|
||||
..
|
||||
} => self.event_queue.borrow_mut().push(WindowEvent::Refresh),
|
||||
Event::WindowEvent {
|
||||
event: glutin::WindowEvent::Closed,
|
||||
..
|
||||
} => {
|
||||
self.event_queue.borrow_mut().push(WindowEvent::Quit);
|
||||
}
|
||||
Event::Closed => {
|
||||
return true
|
||||
Event::WindowEvent {
|
||||
event: glutin::WindowEvent::Resized(width, height),
|
||||
..
|
||||
} => {
|
||||
// width and height are DevicePixel.
|
||||
// window.resize() takes DevicePixel.
|
||||
if let WindowKind::Window(ref window, _) = self.kind {
|
||||
window.resize(width, height);
|
||||
}
|
||||
// window.set_inner_size() takes DeviceIndependentPixel.
|
||||
let new_size = TypedSize2D::new(width as f32, height as f32);
|
||||
let new_size = (new_size / self.hidpi_factor()).cast().expect("Window size should fit in u32");
|
||||
if self.inner_size.get() != new_size {
|
||||
self.inner_size.set(new_size);
|
||||
self.event_queue.borrow_mut().push(WindowEvent::Resize);
|
||||
}
|
||||
}
|
||||
Event::Suspended(suspended) => {
|
||||
self.suspended.set(suspended);
|
||||
if !suspended {
|
||||
self.event_queue.borrow_mut().push(WindowEvent::Idle);
|
||||
}
|
||||
}
|
||||
Event::Awakened => {
|
||||
self.event_queue.borrow_mut().push(WindowEvent::Idle);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
fn toggle_modifier(&self, modifier: GlutinKeyModifiers) {
|
||||
|
@ -592,113 +558,62 @@ impl Window {
|
|||
self.event_queue.borrow_mut().push(WindowEvent::MouseWindowEventClass(event));
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||
fn handle_next_event(&self) -> bool {
|
||||
match self.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
let event = match window.wait_events().next() {
|
||||
None => {
|
||||
warn!("Window event stream closed.");
|
||||
return true;
|
||||
},
|
||||
Some(event) => event,
|
||||
};
|
||||
let mut close = self.handle_window_event(event);
|
||||
if !close {
|
||||
while let Some(event) = window.poll_events().next() {
|
||||
if self.handle_window_event(event) {
|
||||
close = true;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
close
|
||||
}
|
||||
WindowKind::Headless(..) => {
|
||||
false
|
||||
}
|
||||
}
|
||||
pub fn get_events(&self) -> Vec<WindowEvent> {
|
||||
mem::replace(&mut *self.event_queue.borrow_mut(), Vec::new())
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn handle_next_event(&self) -> bool {
|
||||
match self.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
let event = match window.wait_events().next() {
|
||||
None => {
|
||||
warn!("Window event stream closed.");
|
||||
return true;
|
||||
},
|
||||
Some(event) => event,
|
||||
};
|
||||
let mut close = self.handle_window_event(event);
|
||||
if !close {
|
||||
while let Some(event) = window.poll_events().next() {
|
||||
if self.handle_window_event(event) {
|
||||
close = true;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
close
|
||||
}
|
||||
WindowKind::Headless(..) => {
|
||||
false
|
||||
}
|
||||
}
|
||||
fn is_animating(&self) -> bool {
|
||||
self.animation_state.get() == AnimationState::Animating && !self.suspended.get()
|
||||
}
|
||||
|
||||
pub fn wait_events(&self) -> Vec<WindowEvent> {
|
||||
use std::mem;
|
||||
|
||||
let mut events = mem::replace(&mut *self.event_queue.borrow_mut(), Vec::new());
|
||||
let mut close_event = false;
|
||||
|
||||
let poll = self.animation_state.get() == AnimationState::Animating ||
|
||||
opts::get().output_file.is_some() ||
|
||||
opts::get().exit_after_load ||
|
||||
opts::get().headless;
|
||||
// When writing to a file then exiting, use event
|
||||
// polling so that we don't block on a GUI event
|
||||
// such as mouse click.
|
||||
if poll {
|
||||
match self.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
while let Some(event) = window.poll_events().next() {
|
||||
close_event = self.handle_window_event(event) || close_event;
|
||||
pub fn run<T>(&self, mut servo_callback: T) where T: FnMut() -> bool {
|
||||
match self.kind {
|
||||
WindowKind::Window(_, ref events_loop) => {
|
||||
let mut stop = false;
|
||||
loop {
|
||||
if self.is_animating() {
|
||||
// We block on compositing (servo_callback ends up calling swap_buffers)
|
||||
events_loop.borrow_mut().poll_events(|e| {
|
||||
self.handle_window_event(e);
|
||||
});
|
||||
stop = servo_callback();
|
||||
} else {
|
||||
// We block on glutin's event loop (window events)
|
||||
events_loop.borrow_mut().run_forever(|e| {
|
||||
self.handle_window_event(e);
|
||||
if !self.event_queue.borrow().is_empty() {
|
||||
if !self.suspended.get() {
|
||||
stop = servo_callback();
|
||||
}
|
||||
}
|
||||
if stop || self.is_animating() {
|
||||
glutin::ControlFlow::Break
|
||||
} else {
|
||||
glutin::ControlFlow::Continue
|
||||
}
|
||||
});
|
||||
}
|
||||
if stop {
|
||||
break;
|
||||
}
|
||||
}
|
||||
WindowKind::Headless(..) => {
|
||||
}
|
||||
WindowKind::Headless(..) => {
|
||||
loop {
|
||||
// Sleep the main thread to avoid using 100% CPU
|
||||
// This can be done better, see comments in #18777
|
||||
if events.is_empty() {
|
||||
if self.event_queue.borrow().is_empty() {
|
||||
thread::sleep(time::Duration::from_millis(5));
|
||||
}
|
||||
let stop = servo_callback();
|
||||
if stop {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
close_event = self.handle_next_event();
|
||||
}
|
||||
|
||||
if close_event {
|
||||
events.push(WindowEvent::Quit)
|
||||
}
|
||||
|
||||
events.extend(mem::replace(&mut *self.event_queue.borrow_mut(), Vec::new()).into_iter());
|
||||
events
|
||||
}
|
||||
|
||||
pub unsafe fn set_nested_event_loop_listener(
|
||||
&self,
|
||||
listener: *mut (NestedEventLoopListener + 'static)) {
|
||||
G_NESTED_EVENT_LOOP_LISTENER = Some(listener)
|
||||
}
|
||||
|
||||
pub unsafe fn remove_nested_event_loop_listener(&self) {
|
||||
G_NESTED_EVENT_LOOP_LISTENER = None
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn char_to_script_key(c: char) -> Option<constellation_msg::Key> {
|
||||
match c {
|
||||
' ' => Some(Key::Space),
|
||||
|
@ -948,34 +863,13 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
fn create_window_proxy(window: &Window) -> Option<glutin::WindowProxy> {
|
||||
match window.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
Some(window.create_window_proxy())
|
||||
}
|
||||
WindowKind::Headless(..) => {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WindowMethods for Window {
|
||||
fn gl(&self) -> Rc<gl::Gl> {
|
||||
self.gl.clone()
|
||||
}
|
||||
|
||||
fn framebuffer_size(&self) -> DeviceUintSize {
|
||||
match self.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
let scale_factor = window.hidpi_factor() as u32;
|
||||
// TODO(ajeffrey): can this fail?
|
||||
let (width, height) = window.get_inner_size().expect("Failed to get window inner size.");
|
||||
DeviceUintSize::new(width, height) * scale_factor
|
||||
}
|
||||
WindowKind::Headless(ref context) => {
|
||||
DeviceUintSize::new(context.width, context.height)
|
||||
}
|
||||
}
|
||||
(self.inner_size.get().to_f32() * self.hidpi_factor()).to_usize().cast().expect("Window size should fit in u32")
|
||||
}
|
||||
|
||||
fn window_rect(&self) -> DeviceUintRect {
|
||||
|
@ -985,21 +879,12 @@ impl WindowMethods for Window {
|
|||
}
|
||||
|
||||
fn size(&self) -> TypedSize2D<f32, DeviceIndependentPixel> {
|
||||
match self.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
// TODO(ajeffrey): can this fail?
|
||||
let (width, height) = window.get_inner_size().expect("Failed to get window inner size.");
|
||||
TypedSize2D::new(width as f32, height as f32)
|
||||
}
|
||||
WindowKind::Headless(ref context) => {
|
||||
TypedSize2D::new(context.width as f32, context.height as f32)
|
||||
}
|
||||
}
|
||||
self.inner_size.get().to_f32()
|
||||
}
|
||||
|
||||
fn client_window(&self, _: BrowserId) -> (Size2D<u32>, Point2D<i32>) {
|
||||
match self.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
WindowKind::Window(ref window, ..) => {
|
||||
// TODO(ajeffrey): can this fail?
|
||||
let (width, height) = window.get_outer_size().expect("Failed to get window outer size.");
|
||||
let size = Size2D::new(width, height);
|
||||
|
@ -1017,28 +902,12 @@ impl WindowMethods for Window {
|
|||
}
|
||||
|
||||
fn screen_size(&self, _: BrowserId) -> Size2D<u32> {
|
||||
match self.kind {
|
||||
WindowKind::Window(_) => {
|
||||
let (width, height) = glutin::get_primary_monitor().get_dimensions();
|
||||
Size2D::new(width, height)
|
||||
}
|
||||
WindowKind::Headless(ref context) => {
|
||||
Size2D::new(context.width, context.height)
|
||||
}
|
||||
}
|
||||
self.screen_size
|
||||
}
|
||||
|
||||
fn screen_avail_size(&self, _: BrowserId) -> Size2D<u32> {
|
||||
fn screen_avail_size(&self, browser_id: BrowserId) -> Size2D<u32> {
|
||||
// FIXME: Glutin doesn't have API for available size. Fallback to screen size
|
||||
match self.kind {
|
||||
WindowKind::Window(_) => {
|
||||
let (width, height) = glutin::get_primary_monitor().get_dimensions();
|
||||
Size2D::new(width, height)
|
||||
}
|
||||
WindowKind::Headless(ref context) => {
|
||||
Size2D::new(context.width, context.height)
|
||||
}
|
||||
}
|
||||
self.screen_size(browser_id)
|
||||
}
|
||||
|
||||
fn set_animation_state(&self, state: AnimationState) {
|
||||
|
@ -1047,7 +916,7 @@ impl WindowMethods for Window {
|
|||
|
||||
fn set_inner_size(&self, _: BrowserId, size: Size2D<u32>) {
|
||||
match self.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
WindowKind::Window(ref window, ..) => {
|
||||
window.set_inner_size(size.width as u32, size.height as u32)
|
||||
}
|
||||
WindowKind::Headless(..) => {}
|
||||
|
@ -1056,25 +925,28 @@ impl WindowMethods for Window {
|
|||
|
||||
fn set_position(&self, _: BrowserId, point: Point2D<i32>) {
|
||||
match self.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
WindowKind::Window(ref window, ..) => {
|
||||
window.set_position(point.x, point.y)
|
||||
}
|
||||
WindowKind::Headless(..) => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_fullscreen_state(&self, _: BrowserId, _state: bool) {
|
||||
fn set_fullscreen_state(&self, _: BrowserId, state: bool) {
|
||||
match self.kind {
|
||||
WindowKind::Window(..) => {
|
||||
warn!("Fullscreen is not implemented!")
|
||||
WindowKind::Window(ref window, ..) => {
|
||||
if self.fullscreen.get() != state {
|
||||
window.set_fullscreen(None);
|
||||
}
|
||||
},
|
||||
WindowKind::Headless(..) => {}
|
||||
}
|
||||
self.fullscreen.set(state);
|
||||
}
|
||||
|
||||
fn present(&self) {
|
||||
match self.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
WindowKind::Window(ref window, ..) => {
|
||||
if let Err(err) = window.swap_buffers() {
|
||||
warn!("Failed to swap window buffers ({}).", err);
|
||||
}
|
||||
|
@ -1085,31 +957,44 @@ impl WindowMethods for Window {
|
|||
|
||||
fn create_event_loop_waker(&self) -> Box<EventLoopWaker> {
|
||||
struct GlutinEventLoopWaker {
|
||||
window_proxy: Option<glutin::WindowProxy>,
|
||||
proxy: Option<Arc<glutin::EventsLoopProxy>>,
|
||||
}
|
||||
impl GlutinEventLoopWaker {
|
||||
fn new(window: &Window) -> GlutinEventLoopWaker {
|
||||
let proxy = match window.kind {
|
||||
WindowKind::Window(_, ref events_loop) => {
|
||||
Some(Arc::new(events_loop.borrow().create_proxy()))
|
||||
},
|
||||
WindowKind::Headless(..) => {
|
||||
None
|
||||
}
|
||||
};
|
||||
GlutinEventLoopWaker { proxy }
|
||||
}
|
||||
}
|
||||
impl EventLoopWaker for GlutinEventLoopWaker {
|
||||
fn wake(&self) {
|
||||
// kick the OS event loop awake.
|
||||
if let Some(ref window_proxy) = self.window_proxy {
|
||||
window_proxy.wakeup_event_loop()
|
||||
if let Some(ref proxy) = self.proxy {
|
||||
if let Err(err) = proxy.wakeup() {
|
||||
warn!("Failed to wake up event loop ({}).", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
fn clone(&self) -> Box<EventLoopWaker + Send> {
|
||||
Box::new(GlutinEventLoopWaker {
|
||||
window_proxy: self.window_proxy.clone(),
|
||||
proxy: self.proxy.clone(),
|
||||
})
|
||||
}
|
||||
}
|
||||
let window_proxy = create_window_proxy(self);
|
||||
Box::new(GlutinEventLoopWaker {
|
||||
window_proxy: window_proxy,
|
||||
})
|
||||
|
||||
Box::new(GlutinEventLoopWaker::new(&self))
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||
match self.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
WindowKind::Window(ref window, ..) => {
|
||||
TypedScale::new(window.hidpi_factor())
|
||||
}
|
||||
WindowKind::Headless(..) => {
|
||||
|
@ -1127,7 +1012,7 @@ impl WindowMethods for Window {
|
|||
|
||||
fn set_page_title(&self, _: BrowserId, title: Option<String>) {
|
||||
match self.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
WindowKind::Window(ref window, ..) => {
|
||||
let fallback_title: String = if let Some(ref current_url) = *self.current_url.borrow() {
|
||||
current_url.to_string()
|
||||
} else {
|
||||
|
@ -1154,7 +1039,7 @@ impl WindowMethods for Window {
|
|||
fn load_end(&self, _: BrowserId) {
|
||||
if opts::get().no_native_titlebar {
|
||||
match self.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
WindowKind::Window(ref window, ..) => {
|
||||
window.show();
|
||||
}
|
||||
WindowKind::Headless(..) => {}
|
||||
|
@ -1175,7 +1060,7 @@ impl WindowMethods for Window {
|
|||
/// Has no effect on Android.
|
||||
fn set_cursor(&self, cursor: CursorKind) {
|
||||
match self.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
WindowKind::Window(ref window, ..) => {
|
||||
use glutin::MouseCursor;
|
||||
|
||||
let glutin_cursor = match cursor {
|
||||
|
@ -1457,15 +1342,6 @@ fn is_printable(key_code: VirtualKeyCode) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn filter_nonprintable(ch: char, key_code: VirtualKeyCode) -> Option<char> {
|
||||
if is_printable(key_code) {
|
||||
Some(ch)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn sanitize_url(request: &str) -> Option<ServoUrl> {
|
||||
let request = request.trim();
|
||||
ServoUrl::parse(&request).ok()
|
||||
|
|
|
@ -60,7 +60,6 @@ use servo::servo_url::ServoUrl;
|
|||
use std::env;
|
||||
use std::panic;
|
||||
use std::process;
|
||||
use std::rc::Rc;
|
||||
use std::thread;
|
||||
|
||||
pub mod platform {
|
||||
|
@ -173,70 +172,34 @@ fn main() {
|
|||
|
||||
let target_url = cmdline_url.or(pref_url).or(blank_url).unwrap();
|
||||
|
||||
// Our wrapper around `ServoWrapper` that also implements some
|
||||
// callbacks required by the glutin window implementation.
|
||||
let mut servo_wrapper = ServoWrapper {
|
||||
servo: Servo::new(window.clone())
|
||||
};
|
||||
let mut servo = Servo::new(window.clone());
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
servo_wrapper.servo.handle_events(vec![WindowEvent::NewBrowser(target_url, sender)]);
|
||||
servo.handle_events(vec![WindowEvent::NewBrowser(target_url, sender)]);
|
||||
let browser_id = receiver.recv().unwrap();
|
||||
window.set_browser_id(browser_id);
|
||||
servo_wrapper.servo.handle_events(vec![WindowEvent::SelectBrowser(browser_id)]);
|
||||
servo.handle_events(vec![WindowEvent::SelectBrowser(browser_id)]);
|
||||
|
||||
servo_wrapper.servo.setup_logging();
|
||||
servo.setup_logging();
|
||||
|
||||
register_glutin_resize_handler(&window, &mut servo_wrapper);
|
||||
|
||||
// Feed events from the window to the browser until the browser
|
||||
// says to stop.
|
||||
loop {
|
||||
let should_continue = servo_wrapper.servo.handle_events(window.wait_events());
|
||||
if !should_continue {
|
||||
break;
|
||||
window.run(|| {
|
||||
let events = window.get_events();
|
||||
let need_resize = events.iter().any(|e| match *e {
|
||||
WindowEvent::Resize => true,
|
||||
_ => false
|
||||
});
|
||||
let stop = !servo.handle_events(events);
|
||||
if need_resize {
|
||||
servo.repaint_synchronously();
|
||||
}
|
||||
}
|
||||
stop
|
||||
});
|
||||
|
||||
unregister_glutin_resize_handler(&window);
|
||||
|
||||
servo_wrapper.servo.deinit();
|
||||
servo.deinit();
|
||||
|
||||
platform::deinit()
|
||||
}
|
||||
|
||||
fn register_glutin_resize_handler(window: &Rc<glutin_app::window::Window>, browser: &mut ServoWrapper) {
|
||||
unsafe {
|
||||
window.set_nested_event_loop_listener(browser);
|
||||
}
|
||||
}
|
||||
|
||||
fn unregister_glutin_resize_handler(window: &Rc<glutin_app::window::Window>) {
|
||||
unsafe {
|
||||
window.remove_nested_event_loop_listener();
|
||||
}
|
||||
}
|
||||
|
||||
struct ServoWrapper {
|
||||
servo: Servo<glutin_app::window::Window>,
|
||||
}
|
||||
|
||||
impl glutin_app::NestedEventLoopListener for ServoWrapper {
|
||||
fn handle_event_from_nested_event_loop(&mut self, event: WindowEvent) -> bool {
|
||||
let is_resize = match event {
|
||||
WindowEvent::Resize => true,
|
||||
_ => false,
|
||||
};
|
||||
if !self.servo.handle_events(vec![event]) {
|
||||
return false;
|
||||
}
|
||||
if is_resize {
|
||||
self.servo.repaint_synchronously()
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
fn setup_logging() {
|
||||
// Piping logs from stdout/stderr to logcat happens in android_injected_glue.
|
||||
|
|
Загрузка…
Ссылка в новой задаче