From 60fa68c194e46c3989914d17a9e0623ca8151864 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 10 Jan 2020 12:45:22 +0530 Subject: [PATCH] Update glutin --- Cargo.lock | 264 +++++++++++++++++++++++++++----- ports/glutin/Cargo.toml | 2 +- ports/glutin/app.rs | 33 ++-- ports/glutin/context.rs | 14 +- ports/glutin/embedder.rs | 6 +- ports/glutin/events_loop.rs | 22 +-- ports/glutin/headed_window.rs | 122 +++++++-------- ports/glutin/headless_window.rs | 6 +- ports/glutin/keyutils.rs | 6 +- ports/glutin/window_trait.rs | 4 +- 10 files changed, 336 insertions(+), 143 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 15991d2b9ffa..275ab84696d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -456,6 +456,17 @@ dependencies = [ "ppv-lite86", ] +[[package]] +name = "calloop" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aa2097be53a00de9e8fc349fea6d76221f398f5c4fa550d420669906962d160" +dependencies = [ + "mio", + "mio-extras", + "nix", +] + [[package]] name = "canvas" version = "0.0.1" @@ -862,6 +873,19 @@ dependencies = [ "libc", ] +[[package]] +name = "core-video-sys" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc065219542086f72d1e9f7aadbbab0989e980263695d129d502082d063a9d0" +dependencies = [ + "cfg-if", + "core-foundation-sys", + "core-graphics", + "libc", + "objc", +] + [[package]] name = "crc" version = "1.8.1" @@ -1177,6 +1201,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "dispatch" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04e93ca78226c51902d7aa8c12c988338aadd9e85ed9c6be8aaac39192ff3605" + [[package]] name = "display-link" version = "0.2.0" @@ -1654,7 +1684,7 @@ dependencies = [ "gfx-hal", "libloading", "log", - "parking_lot", + "parking_lot 0.9.0", "range-alloc", "raw-window-handle", "smallvec 0.6.10", @@ -1710,7 +1740,7 @@ dependencies = [ "log", "metal", "objc", - "parking_lot", + "parking_lot 0.9.0", "range-alloc", "raw-window-handle", "smallvec 0.6.10", @@ -1873,19 +1903,46 @@ dependencies = [ "libloading", "objc", "osmesa-sys", - "parking_lot", - "wayland-client", + "parking_lot 0.9.0", + "wayland-client 0.21.13", + "winapi", + "winit 0.19.3", +] + +[[package]] +name = "glutin" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e8c40ccddfa5fb8aaad6a152bfa6b17f157d6635928a832211534f87c9877e1" +dependencies = [ + "android_glue", + "cgl 0.3.2", + "cocoa 0.19.1", + "core-foundation", + "core-graphics", + "glutin_egl_sys", + "glutin_emscripten_sys", + "glutin_gles2_sys", + "glutin_glx_sys", + "glutin_wgl_sys", + "lazy_static", + "libloading", + "log", + "objc", + "osmesa-sys", + "parking_lot 0.9.0", + "wayland-client 0.23.6", "winapi", - "winit", + "winit 0.20.0", ] [[package]] name = "glutin_egl_sys" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23f48987ab6cb2b61ad903b59e54a2fd0c380a7baff68cffd6826b69a73dd326" +checksum = "772edef3b28b8ad41e4ea202748e65eefe8e5ffd1f4535f1219793dbb20b3d4c" dependencies = [ - "gl_generator 0.11.0", + "gl_generator 0.13.1", "winapi", ] @@ -2546,6 +2603,12 @@ dependencies = [ "url", ] +[[package]] +name = "instant" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c346c299e3fe8ef94dc10c2c0253d858a69aac1245157a3bf4125915d528caf" + [[package]] name = "io-surface" version = "0.12.1" @@ -2703,7 +2766,7 @@ dependencies = [ "msg", "net_traits", "num-traits", - "parking_lot", + "parking_lot 0.9.0", "profile_traits", "range", "rayon", @@ -2780,7 +2843,7 @@ dependencies = [ "metrics", "msg", "net_traits", - "parking_lot", + "parking_lot 0.9.0", "profile_traits", "range", "rayon", @@ -2890,9 +2953,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.62" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" +checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" [[package]] name = "libdbus-sys" @@ -3454,7 +3517,7 @@ dependencies = [ "lazy_static", "malloc_size_of", "malloc_size_of_derive", - "parking_lot", + "parking_lot 0.9.0", "serde", "servo_url", "size_of_test", @@ -3808,10 +3871,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" dependencies = [ "lock_api", - "parking_lot_core", + "parking_lot_core 0.6.2", "rustc_version", ] +[[package]] +name = "parking_lot" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" +dependencies = [ + "lock_api", + "parking_lot_core 0.7.0", +] + [[package]] name = "parking_lot_core" version = "0.6.2" @@ -3827,6 +3900,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "parking_lot_core" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" +dependencies = [ + "cfg-if", + "cloudabi", + "libc", + "redox_syscall", + "smallvec 1.0.0", + "winapi", +] + [[package]] name = "paste" version = "0.1.6" @@ -4361,7 +4448,7 @@ dependencies = [ "euclid", "gl_generator 0.13.1", "gleam 0.6.18", - "glutin", + "glutin 0.21.2", "gvr-sys", "libc", "libloading", @@ -4500,7 +4587,7 @@ dependencies = [ "msg", "net_traits", "num-traits", - "parking_lot", + "parking_lot 0.9.0", "percent-encoding", "phf", "phf_codegen", @@ -4737,7 +4824,7 @@ dependencies = [ "euclid", "getopts", "gleam 0.6.18", - "glutin", + "glutin 0.22.0", "image", "keyboard-types", "lazy_static", @@ -4985,7 +5072,7 @@ dependencies = [ "euclid", "expat-sys", "gleam 0.7.0", - "glutin", + "glutin 0.21.2", "glx", "io-surface", "libc", @@ -5253,9 +5340,25 @@ dependencies = [ "lazy_static", "memmap", "nix", - "wayland-client", - "wayland-commons", - "wayland-protocols", + "wayland-client 0.21.13", + "wayland-commons 0.21.13", + "wayland-protocols 0.21.4", +] + +[[package]] +name = "smithay-client-toolkit" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93960e8975909fcb14cc755de93af2149d8b8f4eb368315537d40cfd0f324054" +dependencies = [ + "andrew", + "bitflags", + "dlib", + "lazy_static", + "memmap", + "nix", + "wayland-client 0.23.6", + "wayland-protocols 0.23.6", ] [[package]] @@ -5391,7 +5494,7 @@ dependencies = [ "num_cpus", "ordered-float", "owning_ref", - "parking_lot", + "parking_lot 0.9.0", "precomputed-hash", "rayon", "regex", @@ -5495,7 +5598,7 @@ dependencies = [ "osmesa-sys", "wayland-sys 0.24.0", "winapi", - "winit", + "winit 0.19.3", "wio", "x11", ] @@ -5519,10 +5622,10 @@ dependencies = [ "log", "mach", "objc", - "parking_lot", + "parking_lot 0.9.0", "wayland-sys 0.24.0", "winapi", - "winit", + "winit 0.19.3", "wio", "x11", ] @@ -6221,11 +6324,28 @@ dependencies = [ "downcast-rs", "libc", "nix", - "wayland-commons", - "wayland-scanner", + "wayland-commons 0.21.13", + "wayland-scanner 0.21.13", "wayland-sys 0.21.13", ] +[[package]] +name = "wayland-client" +version = "0.23.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af1080ebe0efabcf12aef2132152f616038f2d7dcbbccf7b2d8c5270fe14bcda" +dependencies = [ + "bitflags", + "calloop", + "downcast-rs", + "libc", + "mio", + "nix", + "wayland-commons 0.23.6", + "wayland-scanner 0.23.6", + "wayland-sys 0.23.6", +] + [[package]] name = "wayland-commons" version = "0.21.13" @@ -6236,6 +6356,16 @@ dependencies = [ "wayland-sys 0.21.13", ] +[[package]] +name = "wayland-commons" +version = "0.23.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb66b0d1a27c39bbce712b6372131c6e25149f03ffb0cd017cf8f7de8d66dbdb" +dependencies = [ + "nix", + "wayland-sys 0.23.6", +] + [[package]] name = "wayland-protocols" version = "0.21.4" @@ -6243,12 +6373,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3f6cebb98963f028d397e9bad2acf9d3b2f6b76fae65aea191edd9e7c0df88c" dependencies = [ "bitflags", - "wayland-client", - "wayland-commons", - "wayland-scanner", + "wayland-client 0.21.13", + "wayland-commons 0.21.13", + "wayland-scanner 0.21.13", "wayland-sys 0.21.13", ] +[[package]] +name = "wayland-protocols" +version = "0.23.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cc286643656742777d55dc8e70d144fa4699e426ca8e9d4ef454f4bf15ffcf9" +dependencies = [ + "bitflags", + "wayland-client 0.23.6", + "wayland-commons 0.23.6", + "wayland-scanner 0.23.6", +] + [[package]] name = "wayland-scanner" version = "0.21.13" @@ -6260,6 +6402,17 @@ dependencies = [ "xml-rs", ] +[[package]] +name = "wayland-scanner" +version = "0.23.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93b02247366f395b9258054f964fe293ddd019c3237afba9be2ccbe9e1651c3d" +dependencies = [ + "proc-macro2 0.4.26", + "quote 0.6.12", + "xml-rs", +] + [[package]] name = "wayland-sys" version = "0.21.13" @@ -6270,6 +6423,16 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "wayland-sys" +version = "0.23.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d94e89a86e6d6d7c7c9b19ebf48a03afaac4af6bc22ae570e9a24124b75358f4" +dependencies = [ + "dlib", + "lazy_static", +] + [[package]] name = "wayland-sys" version = "0.24.0" @@ -6456,7 +6619,7 @@ dependencies = [ "euclid", "gl_generator 0.13.1", "gleam 0.6.18", - "glutin", + "glutin 0.21.2", "log", "openxr", "serde", @@ -6478,7 +6641,7 @@ dependencies = [ "log", "serde", "surfman-chains-api", - "winit", + "winit 0.19.3", ] [[package]] @@ -6497,7 +6660,7 @@ dependencies = [ "gfx-backend-vulkan", "gfx-hal", "log", - "parking_lot", + "parking_lot 0.9.0", "rendy-descriptor", "rendy-memory", "serde", @@ -6568,10 +6731,39 @@ dependencies = [ "libc", "log", "objc", - "parking_lot", + "parking_lot 0.9.0", + "percent-encoding", + "smithay-client-toolkit 0.4.6", + "wayland-client 0.21.13", + "winapi", + "x11-dl", +] + +[[package]] +name = "winit" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ba128780050481f453bec2a115b916dbc6ae79c303dee9bad8b9080bdccd4f5" +dependencies = [ + "android_glue", + "bitflags", + "cocoa 0.19.1", + "core-foundation", + "core-graphics", + "core-video-sys", + "dispatch", + "instant", + "lazy_static", + "libc", + "log", + "mio", + "mio-extras", + "objc", + "parking_lot 0.10.0", "percent-encoding", - "smithay-client-toolkit", - "wayland-client", + "raw-window-handle", + "smithay-client-toolkit 0.6.4", + "wayland-client 0.23.6", "winapi", "x11-dl", ] diff --git a/ports/glutin/Cargo.toml b/ports/glutin/Cargo.toml index 69c71acb5099..b05d56bde3c1 100644 --- a/ports/glutin/Cargo.toml +++ b/ports/glutin/Cargo.toml @@ -53,7 +53,7 @@ clipboard = "0.5" euclid = "0.20" getopts = "0.2.11" gleam = "0.6" -glutin = "0.21.0" +glutin = "0.22.0" keyboard-types = "0.4.3" lazy_static = "1" libservo = {path = "../../components/servo"} diff --git a/ports/glutin/app.rs b/ports/glutin/app.rs index 0b001969fa03..8837e042d484 100644 --- a/ports/glutin/app.rs +++ b/ports/glutin/app.rs @@ -9,7 +9,7 @@ use crate::embedder::EmbedderCallbacks; use crate::events_loop::EventsLoop; use crate::window_trait::WindowPortsMethods; use crate::{headed_window, headless_window}; -use glutin::WindowId; +use glutin::window::WindowId; use servo::compositing::windowing::WindowEvent; use servo::config::opts::{self, parse_url_or_filename}; use servo::servo_config::pref; @@ -93,36 +93,37 @@ impl App { } // This function decides whether the event should be handled during `run_forever`. - fn winit_event_to_servo_event(&self, event: glutin::Event) -> glutin::ControlFlow { + fn winit_event_to_servo_event(&self, event: glutin::event::Event<()>) -> glutin::event_loop::ControlFlow { match event { // App level events - glutin::Event::Suspended(suspended) => { - self.suspended.set(suspended); - if !suspended { - self.event_queue.borrow_mut().push(WindowEvent::Idle); - } + glutin::event::Event::Suspended => { + self.suspended.set(true); }, - glutin::Event::Awakened => { + glutin::event::Event::Resumed => { + self.suspended.set(false); self.event_queue.borrow_mut().push(WindowEvent::Idle); }, - glutin::Event::DeviceEvent { .. } => {}, + glutin::event::Event::Awakened => { + self.event_queue.borrow_mut().push(WindowEvent::Idle); + }, + glutin::event::Event::DeviceEvent { .. } => {}, // Window level events - glutin::Event::WindowEvent { + glutin::event::Event::WindowEvent { window_id, event, .. } => { return WINDOWS.with(|windows| { match windows.borrow().get(&window_id) { None => { warn!("Got an event from unknown window"); - glutin::ControlFlow::Break + glutin::event_loop::ControlFlow::Break }, Some(window) => { // Resize events need to be handled during run_forever - let cont = if let glutin::WindowEvent::Resized(_) = event { - glutin::ControlFlow::Continue + let cont = if let glutin::event::WindowEvent::Resized(_) = event { + glutin::event_loop::ControlFlow::Continue } else { - glutin::ControlFlow::Break + glutin::event_loop::ControlFlow::Break }; window.winit_event_to_servo_event(event); return cont; @@ -131,7 +132,7 @@ impl App { }); }, } - glutin::ControlFlow::Break + glutin::event_loop::ControlFlow::Break } fn run_loop(self) { @@ -146,7 +147,7 @@ impl App { // 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); - if cont == glutin::ControlFlow::Continue { + if cont == glutin::event_loop::ControlFlow::Continue { // Note we need to be careful to make sure that any events // that are handled during run_forever aren't re-entrant, // since we are handling them while holding onto a mutable borrow diff --git a/ports/glutin/context.rs b/ports/glutin/context.rs index 77dc4775bedc..ca352470af5f 100644 --- a/ports/glutin/context.rs +++ b/ports/glutin/context.rs @@ -2,8 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use glutin::os::ContextTraitExt; -use glutin::{ContextBuilder, CreationError, EventsLoop, NotCurrent, PossiblyCurrent, WindowedContext, WindowBuilder}; +use glutin::platform::ContextTraitExt; +use glutin::{ContextBuilder, CreationError, event_loop::EventLoop, NotCurrent, PossiblyCurrent, WindowedContext, window::WindowBuilder}; use servo_media::player::context::GlContext as RawContext; use std::os::raw; @@ -15,14 +15,14 @@ pub enum GlContext { } impl GlContext { - pub fn window(&self) -> &glutin::Window { + pub fn window(&self) -> &glutin::window::Window { match self { GlContext::Current(c) => c.window(), GlContext::NotCurrent(c) => c.window(), GlContext::None => unreachable!(), } } - pub fn resize(&mut self, size: glutin::dpi::PhysicalSize) { + pub fn resize(&mut self, size: glutin::dpi::PhysicalSize) { if let GlContext::NotCurrent(_) = self { self.make_current(); } @@ -87,7 +87,7 @@ impl GlContext { GlContext::Current(c) => { #[cfg(target_os = "linux")] { - use glutin::os::unix::RawHandle; + use glutin::platform::unix::RawHandle; let raw_handle = unsafe { c.raw_handle() }; return match raw_handle { @@ -98,7 +98,7 @@ impl GlContext { #[cfg(target_os = "windows")] { - use glutin::os::windows::RawHandle; + use glutin::platform::windows::RawHandle; let raw_handle = unsafe { c.raw_handle() }; return match raw_handle { @@ -132,7 +132,7 @@ impl GlContext { &self, cb: ContextBuilder, wb: WindowBuilder, - el: &EventsLoop + el: &EventLoop<()> ) -> Result, CreationError> where T: glutin::ContextCurrentState, diff --git a/ports/glutin/embedder.rs b/ports/glutin/embedder.rs index 44c925af3e43..9aebd542c78c 100644 --- a/ports/glutin/embedder.rs +++ b/ports/glutin/embedder.rs @@ -10,7 +10,7 @@ use crate::window_trait::WindowPortsMethods; use gleam::gl; use glutin; use glutin::dpi::LogicalSize; -use glutin::EventsLoopClosed; +use glutin::event_loop::EventLoopClosed; use rust_webvr::GlWindowVRService; use servo::compositing::windowing::EmbedderMethods; use servo::embedder_traits::EventLoopWaker; @@ -65,9 +65,9 @@ impl EmbedderMethods for EmbedderCallbacks { events_loop_clone .borrow_mut() .take() - .ok_or(EventsLoopClosed) + .ok_or(EventLoopClosed) }); - let window_builder = glutin::WindowBuilder::new() + let window_builder = glutin::window::WindowBuilder::new() .with_title(name.clone()) .with_dimensions(size) .with_visibility(false) diff --git a/ports/glutin/events_loop.rs b/ports/glutin/events_loop.rs index 749e526b48af..b3f00e81aa5b 100644 --- a/ports/glutin/events_loop.rs +++ b/ports/glutin/events_loop.rs @@ -15,7 +15,7 @@ use std::time; #[allow(dead_code)] enum EventLoop { /// A real Glutin windowing event loop. - Glutin(Option), + Glutin(Option>), /// A fake event loop which contains a signalling flag used to ensure /// that pending events get processed in a timely fashion, and a condition /// variable to allow waiting on that flag changing state. @@ -29,14 +29,14 @@ impl EventsLoop { // but on Linux, the event loop requires a X11 server. #[cfg(not(target_os = "linux"))] pub fn new(_headless: bool) -> Rc> { - Rc::new(RefCell::new(EventsLoop(EventLoop::Glutin(Some(glutin::EventsLoop::new()))))) + Rc::new(RefCell::new(EventsLoop(EventLoop::Glutin(Some(glutin::event_loop::EventLoop::new()))))) } #[cfg(target_os = "linux")] pub fn new(headless: bool) -> Rc> { let events_loop = if headless { EventLoop::Headless(Arc::new((Mutex::new(false), Condvar::new()))) } else { - EventLoop::Glutin(Some(glutin::EventsLoop::new())) + EventLoop::Glutin(Some(glutin::event_loop::EventLoop::new())) }; Rc::new(RefCell::new(EventsLoop(events_loop))) } @@ -55,20 +55,20 @@ impl EventsLoop { Box::new(HeadlessEventLoopWaker(data.clone())), } } - pub fn as_winit(&self) -> &glutin::EventsLoop { + pub fn as_winit(&self) -> &glutin::event_loop::EventLoop<()> { match self.0 { EventLoop::Glutin(Some(ref event_loop)) => event_loop, EventLoop::Glutin(None) | EventLoop::Headless(..) => panic!("Can't access winit event loop while using the fake headless event loop"), } } - pub fn take(&mut self) -> Option { + pub fn take(&mut self) -> Option> { match self.0 { EventLoop::Glutin(ref mut event_loop) => event_loop.take(), EventLoop::Headless(..) => None, } } - pub fn poll_events(&mut self, callback: F) where F: FnMut(glutin::Event) { + pub fn poll_events(&mut self, callback: F) where F: FnMut(glutin::event::Event<()>) { match self.0 { EventLoop::Glutin(Some(ref mut events_loop)) => events_loop.poll_events(callback), EventLoop::Glutin(None) => (), @@ -86,7 +86,7 @@ impl EventsLoop { } } } - pub fn run_forever(&mut self, mut callback: F) where F: FnMut(glutin::Event) -> glutin::ControlFlow { + pub fn run_forever(&mut self, mut callback: F) where F: FnMut(glutin::event::Event<()>) -> glutin::event_loop::ControlFlow { match self.0 { EventLoop::Glutin(ref mut events_loop) => { let events_loop = events_loop @@ -98,7 +98,7 @@ impl EventsLoop { let &(ref flag, ref condvar) = &**data; while { !*flag.lock().unwrap() } { self.sleep(flag, condvar); - if callback(glutin::Event::Awakened) == glutin::ControlFlow::Break { + if callback(glutin::event::Event::Awakened) == glutin::event_loop::ControlFlow::Break { break; } } @@ -121,11 +121,11 @@ impl EventsLoop { } struct HeadedEventLoopWaker { - proxy: Arc, + proxy: glutin::event_loop::EventLoopProxy<()>, } impl HeadedEventLoopWaker { - fn new(events_loop: &glutin::EventsLoop) -> HeadedEventLoopWaker { - let proxy = Arc::new(events_loop.create_proxy()); + fn new(events_loop: &glutin::event_loop::EventLoop<()>) -> HeadedEventLoopWaker { + let proxy = events_loop.create_proxy(); HeadedEventLoopWaker { proxy } } } diff --git a/ports/glutin/headed_window.rs b/ports/glutin/headed_window.rs index 36d3fc88d5f7..0f86d6b8ec1f 100644 --- a/ports/glutin/headed_window.rs +++ b/ports/glutin/headed_window.rs @@ -16,13 +16,13 @@ use euclid::{ use gleam::gl; use glutin::dpi::{LogicalPosition, LogicalSize, PhysicalSize}; #[cfg(target_os = "macos")] -use glutin::os::macos::{ActivationPolicy, WindowBuilderExt}; +use glutin::platform::macos::{ActivationPolicy, WindowBuilderExt}; #[cfg(target_os = "linux")] -use glutin::os::unix::WindowExt; +use glutin::platform::unix::WindowExtUnix; use glutin::Api; #[cfg(any(target_os = "linux", target_os = "windows"))] -use glutin::Icon; -use glutin::{ElementState, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode}; +use glutin::window::Icon; +use glutin::event::{ElementState, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode}; #[cfg(any(target_os = "linux", target_os = "windows"))] use image; use keyboard_types::{Key, KeyState, KeyboardEvent}; @@ -45,7 +45,7 @@ use winapi; const MULTISAMPLES: u16 = 16; #[cfg(target_os = "macos")] -fn builder_with_platform_options(mut builder: glutin::WindowBuilder) -> glutin::WindowBuilder { +fn builder_with_platform_options(mut builder: glutin::window::WindowBuilder) -> glutin::window::WindowBuilder { if opts::get().output_file.is_some() { // Prevent the window from showing in Dock.app, stealing focus, // when generating an output file. @@ -55,7 +55,7 @@ fn builder_with_platform_options(mut builder: glutin::WindowBuilder) -> glutin:: } #[cfg(not(target_os = "macos"))] -fn builder_with_platform_options(builder: glutin::WindowBuilder) -> glutin::WindowBuilder { +fn builder_with_platform_options(builder: glutin::window::WindowBuilder) -> glutin::window::WindowBuilder { builder } @@ -64,9 +64,9 @@ pub struct Window { events_loop: Rc>, screen_size: Size2D, inner_size: Cell>, - mouse_down_button: Cell>, + mouse_down_button: Cell>, mouse_down_point: Cell>, - primary_monitor: glutin::MonitorId, + primary_monitor: glutin::monitor::MonitorHandle, event_queue: RefCell>, mouse_pos: Cell>, last_pressed: Cell>, @@ -117,7 +117,7 @@ impl Window { let width = win_size.to_untyped().width; let height = win_size.to_untyped().height; - let mut window_builder = glutin::WindowBuilder::new() + let mut window_builder = glutin::window::WindowBuilder::new() .with_title("Servo".to_string()) .with_decorations(!no_native_titlebar) .with_transparency(no_native_titlebar) @@ -160,12 +160,12 @@ impl Window { context.make_current().expect("Couldn't make window current") }; - let primary_monitor = events_loop.borrow().as_winit().get_primary_monitor(); + let primary_monitor = events_loop.borrow().as_winit().primary_monitor(); let PhysicalSize { width: screen_width, height: screen_height, - } = primary_monitor.get_dimensions(); + } = primary_monitor.size(); let screen_size = Size2D::new(screen_width as u32, screen_height as u32); // TODO(ajeffrey): can this fail? let LogicalSize { width, height } = context @@ -293,7 +293,7 @@ impl Window { } fn handle_xr_rotation(&self, input: &KeyboardInput) { - if input.state != glutin::ElementState::Pressed { + if input.state != glutin::event::ElementState::Pressed { return; } let mut x = 0.0; @@ -318,8 +318,8 @@ impl Window { /// Helper function to handle a click fn handle_mouse( &self, - button: glutin::MouseButton, - action: glutin::ElementState, + button: glutin::event::MouseButton, + action: glutin::event::ElementState, coords: Point2D, ) { use servo::script_traits::MouseButton; @@ -422,44 +422,44 @@ impl WindowPortsMethods for Window { } fn set_cursor(&self, cursor: Cursor) { - use glutin::MouseCursor; + use glutin::window::CursorIcon; let winit_cursor = match cursor { - Cursor::Default => MouseCursor::Default, - Cursor::Pointer => MouseCursor::Hand, - Cursor::ContextMenu => MouseCursor::ContextMenu, - Cursor::Help => MouseCursor::Help, - Cursor::Progress => MouseCursor::Progress, - Cursor::Wait => MouseCursor::Wait, - Cursor::Cell => MouseCursor::Cell, - Cursor::Crosshair => MouseCursor::Crosshair, - Cursor::Text => MouseCursor::Text, - Cursor::VerticalText => MouseCursor::VerticalText, - Cursor::Alias => MouseCursor::Alias, - Cursor::Copy => MouseCursor::Copy, - Cursor::Move => MouseCursor::Move, - Cursor::NoDrop => MouseCursor::NoDrop, - Cursor::NotAllowed => MouseCursor::NotAllowed, - Cursor::Grab => MouseCursor::Grab, - Cursor::Grabbing => MouseCursor::Grabbing, - Cursor::EResize => MouseCursor::EResize, - Cursor::NResize => MouseCursor::NResize, - Cursor::NeResize => MouseCursor::NeResize, - Cursor::NwResize => MouseCursor::NwResize, - Cursor::SResize => MouseCursor::SResize, - Cursor::SeResize => MouseCursor::SeResize, - Cursor::SwResize => MouseCursor::SwResize, - Cursor::WResize => MouseCursor::WResize, - Cursor::EwResize => MouseCursor::EwResize, - Cursor::NsResize => MouseCursor::NsResize, - Cursor::NeswResize => MouseCursor::NeswResize, - Cursor::NwseResize => MouseCursor::NwseResize, - Cursor::ColResize => MouseCursor::ColResize, - Cursor::RowResize => MouseCursor::RowResize, - Cursor::AllScroll => MouseCursor::AllScroll, - Cursor::ZoomIn => MouseCursor::ZoomIn, - Cursor::ZoomOut => MouseCursor::ZoomOut, - _ => MouseCursor::Default, + Cursor::Default => CursorIcon::Default, + Cursor::Pointer => CursorIcon::Hand, + Cursor::ContextMenu => CursorIcon::ContextMenu, + Cursor::Help => CursorIcon::Help, + Cursor::Progress => CursorIcon::Progress, + Cursor::Wait => CursorIcon::Wait, + Cursor::Cell => CursorIcon::Cell, + Cursor::Crosshair => CursorIcon::Crosshair, + Cursor::Text => CursorIcon::Text, + Cursor::VerticalText => CursorIcon::VerticalText, + Cursor::Alias => CursorIcon::Alias, + Cursor::Copy => CursorIcon::Copy, + Cursor::Move => CursorIcon::Move, + Cursor::NoDrop => CursorIcon::NoDrop, + Cursor::NotAllowed => CursorIcon::NotAllowed, + Cursor::Grab => CursorIcon::Grab, + Cursor::Grabbing => CursorIcon::Grabbing, + Cursor::EResize => CursorIcon::EResize, + Cursor::NResize => CursorIcon::NResize, + Cursor::NeResize => CursorIcon::NeResize, + Cursor::NwResize => CursorIcon::NwResize, + Cursor::SResize => CursorIcon::SResize, + Cursor::SeResize => CursorIcon::SeResize, + Cursor::SwResize => CursorIcon::SwResize, + Cursor::WResize => CursorIcon::WResize, + Cursor::EwResize => CursorIcon::EwResize, + Cursor::NsResize => CursorIcon::NsResize, + Cursor::NeswResize => CursorIcon::NeswResize, + Cursor::NwseResize => CursorIcon::NwseResize, + Cursor::ColResize => CursorIcon::ColResize, + Cursor::RowResize => CursorIcon::RowResize, + Cursor::AllScroll => CursorIcon::AllScroll, + Cursor::ZoomIn => CursorIcon::ZoomIn, + Cursor::ZoomOut => CursorIcon::ZoomOut, + _ => CursorIcon::Default, }; self.gl_context.borrow_mut().window().set_cursor(winit_cursor); } @@ -468,20 +468,20 @@ impl WindowPortsMethods for Window { self.animation_state.get() == AnimationState::Animating } - fn id(&self) -> glutin::WindowId { + fn id(&self) -> glutin::window::WindowId { self.gl_context.borrow().window().id() } - fn winit_event_to_servo_event(&self, event: glutin::WindowEvent) { + fn winit_event_to_servo_event(&self, event: glutin::event::WindowEvent) { match event { - glutin::WindowEvent::ReceivedCharacter(ch) => self.handle_received_character(ch), - glutin::WindowEvent::KeyboardInput { input, .. } => self.handle_keyboard_input(input), - glutin::WindowEvent::MouseInput { state, button, .. } => { + glutin::event::WindowEvent::ReceivedCharacter(ch) => self.handle_received_character(ch), + glutin::event::WindowEvent::KeyboardInput { input, .. } => self.handle_keyboard_input(input), + glutin::event::WindowEvent::MouseInput { state, button, .. } => { if button == MouseButton::Left || button == MouseButton::Right { self.handle_mouse(button, state, self.mouse_pos.get()); } }, - glutin::WindowEvent::CursorMoved { position, .. } => { + glutin::event::WindowEvent::CursorMoved { position, .. } => { let pos = position.to_physical(self.device_hidpi_factor().get() as f64); let (x, y): (i32, i32) = pos.into(); self.mouse_pos.set(Point2D::new(x, y)); @@ -491,7 +491,7 @@ impl WindowPortsMethods for Window { x as f32, y as f32, ))); }, - glutin::WindowEvent::MouseWheel { delta, phase, .. } => { + glutin::event::WindowEvent::MouseWheel { delta, phase, .. } => { let (mut dx, mut dy, mode) = match delta { MouseScrollDelta::LineDelta(dx, dy) => (dx as f64, (dy * LINE_HEIGHT) as f64, WheelMode::DeltaLine), @@ -524,7 +524,7 @@ impl WindowPortsMethods for Window { self.event_queue.borrow_mut().push(wheel_event); self.event_queue.borrow_mut().push(scroll_event); }, - glutin::WindowEvent::Touch(touch) => { + glutin::event::WindowEvent::Touch(touch) => { use servo::script_traits::TouchId; let phase = winit_phase_to_touch_event_type(touch.phase); @@ -537,13 +537,13 @@ impl WindowPortsMethods for Window { .borrow_mut() .push(WindowEvent::Touch(phase, id, point)); }, - glutin::WindowEvent::Refresh => { + glutin::event::WindowEvent::Refresh => { self.event_queue.borrow_mut().push(WindowEvent::Refresh); }, - glutin::WindowEvent::CloseRequested => { + glutin::event::WindowEvent::CloseRequested => { self.event_queue.borrow_mut().push(WindowEvent::Quit); }, - glutin::WindowEvent::Resized(size) => { + glutin::event::WindowEvent::Resized(size) => { let physical_size = size.to_physical(self.device_hidpi_factor().get() as f64); self.gl_context.borrow_mut().resize(physical_size); // window.set_inner_size() takes DeviceIndependentPixel. diff --git a/ports/glutin/headless_window.rs b/ports/glutin/headless_window.rs index c24d142fda55..eef1875ee0a7 100644 --- a/ports/glutin/headless_window.rs +++ b/ports/glutin/headless_window.rs @@ -136,8 +136,8 @@ impl WindowPortsMethods for Window { false } - fn id(&self) -> glutin::WindowId { - unsafe { glutin::WindowId::dummy() } + fn id(&self) -> glutin::window::WindowId { + unsafe { glutin::window::WindowId::dummy() } } fn page_height(&self) -> f32 { @@ -157,7 +157,7 @@ impl WindowPortsMethods for Window { self.animation_state.get() == AnimationState::Animating } - fn winit_event_to_servo_event(&self, _event: glutin::WindowEvent) { + fn winit_event_to_servo_event(&self, _event: glutin::event::WindowEvent) { // Not expecting any winit events. } } diff --git a/ports/glutin/keyutils.rs b/ports/glutin/keyutils.rs index 7dd7fdf5ca5d..a4ea925d390a 100644 --- a/ports/glutin/keyutils.rs +++ b/ports/glutin/keyutils.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use glutin::{ElementState, KeyboardInput, ModifiersState, VirtualKeyCode}; +use glutin::event::{ElementState, KeyboardInput, ModifiersState, VirtualKeyCode}; use keyboard_types::{Code, Key, KeyState, KeyboardEvent, Location, Modifiers}; // Some shortcuts use Cmd on Mac and Control on other systems. @@ -18,7 +18,7 @@ pub const CMD_OR_ALT: Modifiers = Modifiers::META; pub const CMD_OR_ALT: Modifiers = Modifiers::ALT; fn get_servo_key_from_winit_key(key: Option) -> Key { - use glutin::VirtualKeyCode::*; + use glutin::event::VirtualKeyCode::*; // TODO: figure out how to map NavigateForward, NavigateBackward // TODO: map the remaining keys if possible let key = if let Some(key) = key { @@ -127,7 +127,7 @@ fn get_servo_key_from_winit_key(key: Option) -> Key { } fn get_servo_location_from_winit_key(key: Option) -> Location { - use glutin::VirtualKeyCode::*; + use glutin::event::VirtualKeyCode::*; // TODO: add more numpad keys let key = if let Some(key) = key { key diff --git a/ports/glutin/window_trait.rs b/ports/glutin/window_trait.rs index 6a1fd57f6313..03fcbce6ad4e 100644 --- a/ports/glutin/window_trait.rs +++ b/ports/glutin/window_trait.rs @@ -15,11 +15,11 @@ pub const LINE_HEIGHT: f32 = 38.0; pub trait WindowPortsMethods: WindowMethods + webxr::glwindow::GlWindow { fn get_events(&self) -> Vec; - fn id(&self) -> glutin::WindowId; + fn id(&self) -> glutin::window::WindowId; fn has_events(&self) -> bool; fn page_height(&self) -> f32; fn get_fullscreen(&self) -> bool; - fn winit_event_to_servo_event(&self, event: glutin::WindowEvent); + fn winit_event_to_servo_event(&self, event: glutin::event::WindowEvent); fn is_animating(&self) -> bool; fn set_title(&self, _title: &str) {} fn set_inner_size(&self, _size: DeviceIntSize) {}