From ba253869db4f3db48a2c8dddd56f731bf661b900 Mon Sep 17 00:00:00 2001 From: Keith Simmons Date: Sat, 1 Feb 2020 08:36:12 -0800 Subject: [PATCH] update winit to hotfix --- Cargo.lock | 17 ++++++++--------- Cargo.toml | 2 +- src/window.rs | 11 +++++------ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa4e3d7..62ff262 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -544,9 +544,9 @@ dependencies = [ [[package]] name = "dispatch" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04e93ca78226c51902d7aa8c12c988338aadd9e85ed9c6be8aaac39192ff3605" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" [[package]] name = "dlib" @@ -2092,9 +2092,8 @@ dependencies = [ [[package]] name = "skulpin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6825386a1553c4e9da03bae6e6b044090c103bd3e94c5d099b98664c0eb3c23d" +version = "0.6.0" +source = "git+https://github.com/kethku/skulpin?branch=winit_20#2fda3cdc71903ddf756dc86f9c16bd42a7ef4959" dependencies = [ "ash", "cocoa", @@ -2477,13 +2476,11 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winit" -version = "0.20.0-alpha6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa4308ca09f50e2f4688c631c36879521bffc39b949238b288ffd932864acbc" +version = "0.20.0" +source = "git+https://github.com/filnet/winit?branch=fix-panic-at-redraw-event-in-non-redraw-phase#1ddd984bdbec45e5345632e0999851c47f2b372d" dependencies = [ "android_glue", "bitflags", - "calloop", "cocoa", "core-foundation", "core-graphics", @@ -2493,6 +2490,8 @@ dependencies = [ "lazy_static", "libc", "log", + "mio", + "mio-extras", "objc", "parking_lot", "percent-encoding", diff --git a/Cargo.toml b/Cargo.toml index 4055955..1350931 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ euclid = "0.20.7" font-kit = "0.4.0" skribo = { git = "https://github.com/linebender/skribo" } lru = "0.4.3" -skulpin = "0.5.2" +skulpin = { git = "https://github.com/kethku/skulpin", branch = "winit_20" } derive-new = "0.5" env_logger = "0.7.1" rmpv = "0.4.2" diff --git a/src/window.rs b/src/window.rs index cee7a1e..48993f3 100644 --- a/src/window.rs +++ b/src/window.rs @@ -19,10 +19,10 @@ use crate::INITIAL_DIMENSIONS; #[folder = "assets/"] struct Asset; -fn handle_new_grid_size(new_size: LogicalSize, renderer: &Renderer) { +fn handle_new_grid_size(new_size: LogicalSize, renderer: &Renderer) { if new_size.width > 0.0 && new_size.height > 0.0 { - let new_width = ((new_size.width + 1.0) as f32 / renderer.font_width) as u64; - let new_height = ((new_size.height + 1.0) as f32 / renderer.font_height) as u64; + let new_width = ((new_size.width + 1.0) / renderer.font_width) as i64; + let new_height = ((new_size.height + 1.0) / renderer.font_height) as i64; // Add 1 here to make sure resizing doesn't change the grid size on startup BRIDGE.queue_command(UiCommand::Resize { width: new_width as i64, height: new_height as i64 }); } @@ -86,7 +86,7 @@ pub fn ui_loop() { event: WindowEvent::Resized(new_size), .. } => { - handle_new_grid_size(new_size, &renderer) + handle_new_grid_size(new_size.to_logical(window.scale_factor()), &renderer) }, Event::WindowEvent { @@ -108,7 +108,6 @@ pub fn ui_loop() { }, .. } => { - let position: LogicalPosition = position; let grid_y = (position.x / renderer.font_width as f64) as i64; let grid_x = (position.y / renderer.font_height as f64) as i64; let (old_x, old_y) = mouse_pos; @@ -187,7 +186,7 @@ pub fn ui_loop() { if REDRAW_SCHEDULER.should_draw() { if let Err(_) = skulpin_renderer.draw(&window, |canvas, coordinate_system_helper| { if renderer.draw(canvas, coordinate_system_helper) { - handle_new_grid_size(window.inner_size(), &renderer) + handle_new_grid_size(window.inner_size().to_logical(window.scale_factor()), &renderer) } }) { println!("Render failed. Closing");