Update to glutin 0.22.0 and winit 0.20.0 release (#268)
Thanks to @mwkroening (#317) and @martijnberger (#323) for helping fix this update. * Update to glutin 0.22.0 and winit 0.20.0 release, removing alpha pinning * scale_factor() replaces hidpi_factor() * Listen for ScaleFactorChanged, separate from Resized event * Fix getting physical size of window * Fix logical mouse event coordinates
This commit is contained in:
parent
a42d9a6761
commit
a6bff21de8
|
@ -667,7 +667,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "glutin"
|
||||
version = "0.22.0-alpha5"
|
||||
version = "0.22.0"
|
||||
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)",
|
||||
|
@ -688,7 +688,7 @@ dependencies = [
|
|||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-client 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winit 0.20.0-alpha6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winit 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2070,7 +2070,7 @@ dependencies = [
|
|||
"clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"collision 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"flate2 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"glutin 0.22.0-alpha5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"glutin 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"image 0.22.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2090,7 +2090,7 @@ dependencies = [
|
|||
"steven_shared 0.0.1",
|
||||
"structopt 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen 0.2.63 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winit 0.20.0-alpha6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winit 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"zip 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -2522,12 +2522,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "winit"
|
||||
version = "0.20.0-alpha6"
|
||||
version = "0.20.0"
|
||||
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)",
|
||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"calloop 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cocoa 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2537,6 +2536,8 @@ dependencies = [
|
|||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mio 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2697,7 +2698,7 @@ dependencies = [
|
|||
"checksum gif 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "471d90201b3b223f3451cd4ad53e34295f16a1df17b1edf3736d47761c3981af"
|
||||
"checksum gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ca98bbde17256e02d17336a6bdb5a50f7d0ccacee502e191d3e3d0ec2f96f84a"
|
||||
"checksum gl_generator 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"
|
||||
"checksum glutin 0.22.0-alpha5 (registry+https://github.com/rust-lang/crates.io-index)" = "4f29f0d8e02e304b15a4464118387dcad1f543695057a60276a196311cc93452"
|
||||
"checksum glutin 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e8c40ccddfa5fb8aaad6a152bfa6b17f157d6635928a832211534f87c9877e1"
|
||||
"checksum glutin_egl_sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "772edef3b28b8ad41e4ea202748e65eefe8e5ffd1f4535f1219793dbb20b3d4c"
|
||||
"checksum glutin_emscripten_sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80de4146df76e8a6c32b03007bc764ff3249dcaeb4f675d68a06caf1bac363f1"
|
||||
"checksum glutin_gles2_sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "07e853d96bebcb8e53e445225c3009758c6f5960d44f2543245f6f07b567dae0"
|
||||
|
@ -2894,7 +2895,7 @@ dependencies = [
|
|||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
"checksum winit 0.20.0-alpha6 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa4308ca09f50e2f4688c631c36879521bffc39b949238b288ffd932864acbc"
|
||||
"checksum winit 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ba128780050481f453bec2a115b916dbc6ae79c303dee9bad8b9080bdccd4f5"
|
||||
"checksum winreg 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69"
|
||||
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
|
||||
"checksum x11-clipboard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "89bd49c06c9eb5d98e6ba6536cf64ac9f7ee3a009b2f53996d405b3944f6bcea"
|
||||
|
|
|
@ -21,7 +21,7 @@ opt-level = 1
|
|||
cfg-if = "0.1.9"
|
||||
wasm-bindgen = "0.2.44"
|
||||
sha-1 = "0.8.2"
|
||||
glutin = "=0.22.0-alpha5"
|
||||
glutin = "0.22.0"
|
||||
byteorder = "1.3.4"
|
||||
serde = "1.0.104"
|
||||
serde_json = "1.0.55"
|
||||
|
@ -45,7 +45,7 @@ reqwest = { version = "0.10.6", features = [ "blocking" ]}
|
|||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
stdweb = "0.4.20"
|
||||
winit = { version = "=0.20.0-alpha6", features = [ "stdweb" ]}
|
||||
winit = { version = "0.20.0", features = [ "stdweb" ]}
|
||||
|
||||
[dependencies.steven_gl]
|
||||
path = "./gl"
|
||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -276,7 +276,7 @@ fn main2() {
|
|||
}
|
||||
|
||||
let textures = renderer.get_textures();
|
||||
let dpi_factor = window.window().current_monitor().hidpi_factor();
|
||||
let dpi_factor = window.window().current_monitor().scale_factor();
|
||||
let default_protocol_version = protocol::versions::protocol_name_to_protocol_version(
|
||||
opt.default_protocol_version.unwrap_or("".to_string()));
|
||||
let mut game = Game {
|
||||
|
@ -322,8 +322,9 @@ fn main2() {
|
|||
let diff = now.duration_since(last_frame);
|
||||
last_frame = now;
|
||||
let delta = (diff.subsec_nanos() as f64) / frame_time;
|
||||
let (width, height) = window.window().inner_size().into();
|
||||
let (physical_width, physical_height) = window.window().inner_size().to_physical(game.dpi_factor).into();
|
||||
let physical_size = window.window().inner_size();
|
||||
let (physical_width, physical_height) = physical_size.into();
|
||||
let (width, height) = physical_size.to_logical::<f64>(game.dpi_factor).into();
|
||||
|
||||
let version = {
|
||||
let try_res = game.resource_manager.try_write();
|
||||
|
@ -436,10 +437,12 @@ fn handle_window_event<T>(window: &mut glutin::WindowedContext<glutin::PossiblyC
|
|||
|
||||
Event::WindowEvent{event, ..} => match event {
|
||||
WindowEvent::CloseRequested => game.should_close = true,
|
||||
WindowEvent::Resized(logical_size) => {
|
||||
game.dpi_factor = window.window().hidpi_factor();
|
||||
window.resize(logical_size.to_physical(game.dpi_factor));
|
||||
WindowEvent::Resized(physical_size) => {
|
||||
window.resize(physical_size);
|
||||
},
|
||||
WindowEvent::ScaleFactorChanged{scale_factor, ..} => {
|
||||
game.dpi_factor = scale_factor;
|
||||
}
|
||||
|
||||
WindowEvent::ReceivedCharacter(codepoint) => {
|
||||
if !game.focused {
|
||||
|
@ -450,7 +453,7 @@ fn handle_window_event<T>(window: &mut glutin::WindowedContext<glutin::PossiblyC
|
|||
WindowEvent::MouseInput{state, button, ..} => {
|
||||
match (state, button) {
|
||||
(ElementState::Released, MouseButton::Left) => {
|
||||
let (width, height) = window.window().inner_size().into();
|
||||
let (width, height) = window.window().inner_size().to_logical::<f64>(game.dpi_factor).into();
|
||||
|
||||
if game.server.is_connected() && !game.focused && !game.screen_sys.is_current_closable() {
|
||||
game.focused = true;
|
||||
|
@ -478,7 +481,7 @@ fn handle_window_event<T>(window: &mut glutin::WindowedContext<glutin::PossiblyC
|
|||
game.last_mouse_y = y;
|
||||
|
||||
if !game.focused {
|
||||
let (width, height) = window.window().inner_size().into();
|
||||
let (width, height) = window.window().inner_size().to_logical::<f64>(game.dpi_factor).into();
|
||||
ui_container.hover_at(game, x, y, width, height);
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue