From f70956866adc52e5598bd7443e5c7a983a44acbf Mon Sep 17 00:00:00 2001 From: keith Date: Sun, 19 Apr 2020 17:22:20 -0700 Subject: [PATCH] fix mouse scaling --- Cargo.lock | 15 +++++---------- Cargo.toml | 2 +- src/window.rs | 3 ++- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 89c2235..7fec3f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1924,8 +1924,7 @@ dependencies = [ [[package]] name = "skulpin" version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dd4af3f78364d587c25990361d63d4e9707e7f4a40636c2875db39212b11786" +source = "git+https://github.com/kethku/skulpin?branch=windows-dpi-fix#24ce66e217980490e5891fa113ade2c9dbec02c6" dependencies = [ "log", "skulpin-app-winit", @@ -1937,8 +1936,7 @@ dependencies = [ [[package]] name = "skulpin-app-winit" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b94b802ebaa595692fdf7e68535a301e0dc21146839766d4fca6b4085e7efcad" +source = "git+https://github.com/kethku/skulpin?branch=windows-dpi-fix#24ce66e217980490e5891fa113ade2c9dbec02c6" dependencies = [ "log", "skulpin-renderer", @@ -1948,8 +1946,7 @@ dependencies = [ [[package]] name = "skulpin-renderer" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951abd350f1f0fd54acceb479e9af6329cda9e35498da5242c6f07255af4580c" +source = "git+https://github.com/kethku/skulpin?branch=windows-dpi-fix#24ce66e217980490e5891fa113ade2c9dbec02c6" dependencies = [ "ash", "log", @@ -1960,8 +1957,7 @@ dependencies = [ [[package]] name = "skulpin-renderer-sdl2" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "766028ec539df61ad43b8378467d08c2e866a1967141c292c34e5118cf22c592" +source = "git+https://github.com/kethku/skulpin?branch=windows-dpi-fix#24ce66e217980490e5891fa113ade2c9dbec02c6" dependencies = [ "log", "sdl2", @@ -1971,8 +1967,7 @@ dependencies = [ [[package]] name = "skulpin-renderer-winit" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e6adf5a21a5108143a6225835010aeee4ef0e83285716fd89e0e6ea3e0081c" +source = "git+https://github.com/kethku/skulpin?branch=windows-dpi-fix#24ce66e217980490e5891fa113ade2c9dbec02c6" dependencies = [ "cocoa", "log", diff --git a/Cargo.toml b/Cargo.toml index ed9e053..a26c47a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ euclid = "0.20.7" font-kit = "0.6.0" skribo = { git = "https://github.com/linebender/skribo" } lru = "0.4.3" -skulpin = { version = "0.9.0", features=["skulpin_sdl2"] } +skulpin = { git = "https://github.com/kethku/skulpin", branch = "windows-dpi-fix", features = ["skulpin_sdl2"] } derive-new = "0.5" rmpv = "0.4.4" rust-embed = { version = "5.2.0", features = ["debug-embed"] } diff --git a/src/window.rs b/src/window.rs index 2878b51..93ac65e 100644 --- a/src/window.rs +++ b/src/window.rs @@ -273,7 +273,8 @@ impl WindowWrapper { (y as f32 / self.renderer.font_height) as u32, ); - self.mouse_position = physical_size.to_logical(1.0); + let sdl_window_wrapper = Sdl2Window::new(&self.window); + self.mouse_position = physical_size.to_logical(sdl_window_wrapper.scale_factor()); if self.mouse_down && previous_position != self.mouse_position { BRIDGE.queue_command(UiCommand::Drag( self.mouse_position.width,