From 490cf2d256c4a8c51e5d45771e5d48f5e9a91d60 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 30 Jan 2023 18:39:16 +0100 Subject: [PATCH] Update to winit 0.28 Mac trackpads pinch gestures will now generate `egui::Event::Zoom` --- Cargo.lock | 226 ++++++++++++++++---- crates/eframe/Cargo.toml | 2 +- crates/eframe/src/native/epi_integration.rs | 19 +- crates/egui-wgpu/Cargo.toml | 2 +- crates/egui-winit/Cargo.toml | 2 +- crates/egui-winit/src/lib.rs | 25 ++- 6 files changed, 227 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 654b811b2a1a..012204b99f4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -94,7 +94,7 @@ dependencies = [ "accesskit_unix", "accesskit_windows", "parking_lot", - "winit", + "winit 0.27.5", ] [[package]] @@ -144,6 +144,30 @@ dependencies = [ "memchr", ] +[[package]] +name = "android-activity" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4165a1aef703232031b40a6e8908c2f9e314d495f11aa7f98db75d39a497cc6a" +dependencies = [ + "android-properties", + "bitflags", + "cc", + "jni-sys", + "libc", + "log", + "ndk 0.7.0", + "ndk-context", + "ndk-sys 0.4.1+23.1.7779620", + "num_enum", +] + +[[package]] +name = "android-properties" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -1388,7 +1412,7 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "wgpu", - "winit", + "winit 0.28.1", ] [[package]] @@ -1416,7 +1440,7 @@ dependencies = [ "tracing", "type-map", "wgpu", - "winit", + "winit 0.28.1", ] [[package]] @@ -1434,7 +1458,7 @@ dependencies = [ "tracing", "tts", "webbrowser", - "winit", + "winit 0.28.1", ] [[package]] @@ -2043,7 +2067,7 @@ dependencies = [ "wayland-client", "wayland-egl", "winapi", - "winit", + "winit 0.27.5", ] [[package]] @@ -2962,6 +2986,18 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +[[package]] +name = "orbclient" +version = "0.3.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba683f1641c11041c59d5d93689187abcab3c1349dc6d9d70c550c9f9360802f" +dependencies = [ + "cfg-if", + "redox_syscall 0.2.16", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "ordered-multimap" version = "0.4.3" @@ -3048,7 +3084,7 @@ checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", "windows-sys 0.42.0", ] @@ -3297,6 +3333,15 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_syscall" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb02a9aee8e8c7ad8d86890f1e16b49e0bbbffc9961ff3788c31d57c98bcbf03" +dependencies = [ + "bitflags", +] + [[package]] name = "redox_users" version = "0.4.3" @@ -3304,7 +3349,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", - "redox_syscall", + "redox_syscall 0.2.16", "thiserror", ] @@ -3574,6 +3619,19 @@ dependencies = [ "tiny-skia 0.7.0", ] +[[package]] +name = "sctk-adwaita" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc56402866c717f54e48b122eb93c69f709bc5a6359c403598992fd92f017931" +dependencies = [ + "ab_glyph", + "log", + "memmap2", + "smithay-client-toolkit", + "tiny-skia 0.8.2", +] + [[package]] name = "serde" version = "1.0.149" @@ -3818,6 +3876,12 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" +[[package]] +name = "strict-num" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9df65f20698aeed245efdde3628a6b559ea1239bbb871af1b6e3b58c413b2bd1" + [[package]] name = "strsim" version = "0.10.0" @@ -3913,7 +3977,7 @@ dependencies = [ "cfg-if", "fastrand", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "remove_dir_all", "winapi", ] @@ -4053,7 +4117,21 @@ dependencies = [ "cfg-if", "png", "safe_arch", - "tiny-skia-path", + "tiny-skia-path 0.7.0", +] + +[[package]] +name = "tiny-skia" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae12c22601b6853f4d93abb178e13bf0e1cc8e2454100c85d4d3a59ac71b3f7" +dependencies = [ + "arrayref", + "arrayvec 0.7.2", + "bytemuck", + "cfg-if", + "png", + "tiny-skia-path 0.8.2", ] [[package]] @@ -4066,6 +4144,17 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "tiny-skia-path" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd665853ce64402daabef6edda442dbb4f8ee93ea80957b66ba1af419f11a104" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + [[package]] name = "tinystr" version = "0.7.0" @@ -4849,12 +4938,12 @@ checksum = "0286ba339aa753e70765d521bb0242cc48e1194562bfa2a2ad7ac8a6de28f5d5" dependencies = [ "windows-implement", "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.0", + "windows_x86_64_msvc 0.42.1", ] [[package]] @@ -4864,12 +4953,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04662ed0e3e5630dfa9b26e4cb823b817f1a9addda855d973a9458c236556244" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.0", + "windows_x86_64_msvc 0.42.1", ] [[package]] @@ -4903,19 +4992,43 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.1", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.0", + "windows_x86_64_msvc 0.42.1", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" [[package]] name = "windows_aarch64_msvc" @@ -4931,9 +5044,9 @@ checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a" [[package]] name = "windows_aarch64_msvc" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" [[package]] name = "windows_i686_gnu" @@ -4949,9 +5062,9 @@ checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1" [[package]] name = "windows_i686_gnu" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" [[package]] name = "windows_i686_msvc" @@ -4967,9 +5080,9 @@ checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c" [[package]] name = "windows_i686_msvc" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" [[package]] name = "windows_x86_64_gnu" @@ -4985,15 +5098,15 @@ checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d" [[package]] name = "windows_x86_64_gnu" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" [[package]] name = "windows_x86_64_msvc" @@ -5009,9 +5122,9 @@ checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d" [[package]] name = "windows_x86_64_msvc" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" [[package]] name = "winit" @@ -5036,7 +5149,7 @@ dependencies = [ "percent-encoding", "raw-window-handle 0.4.3", "raw-window-handle 0.5.0", - "sctk-adwaita", + "sctk-adwaita 0.4.3", "smithay-client-toolkit", "wasm-bindgen", "wayland-client", @@ -5046,6 +5159,41 @@ dependencies = [ "x11-dl", ] +[[package]] +name = "winit" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4755d4ba0e3d30fc7beef2095e246b1e6a6fad0717608bcb87a2df4b003bcf" +dependencies = [ + "android-activity", + "bitflags", + "cfg_aliases", + "core-foundation", + "core-graphics", + "dispatch", + "instant", + "libc", + "log", + "mio", + "ndk 0.7.0", + "objc2", + "once_cell", + "orbclient", + "percent-encoding", + "raw-window-handle 0.5.0", + "redox_syscall 0.3.4", + "sctk-adwaita 0.5.3", + "smithay-client-toolkit", + "wasm-bindgen", + "wayland-client", + "wayland-commons", + "wayland-protocols", + "wayland-scanner", + "web-sys", + "windows-sys 0.45.0", + "x11-dl", +] + [[package]] name = "winreg" version = "0.10.1" diff --git a/crates/eframe/Cargo.toml b/crates/eframe/Cargo.toml index f26a5b1ce8ca..c87acad8e015 100644 --- a/crates/eframe/Cargo.toml +++ b/crates/eframe/Cargo.toml @@ -92,7 +92,7 @@ egui-winit = { version = "0.20.0", path = "../egui-winit", default-features = fa "links", ] } raw-window-handle = { version = "0.5.0" } -winit = "0.27.2" +winit = "0.28" # optional native: dark-light = { version = "1.0", optional = true } diff --git a/crates/eframe/src/native/epi_integration.rs b/crates/eframe/src/native/epi_integration.rs index 0e775acb54a3..4d27b24e1989 100644 --- a/crates/eframe/src/native/epi_integration.rs +++ b/crates/eframe/src/native/epi_integration.rs @@ -78,7 +78,6 @@ pub fn build_window( let mut window_builder = winit::window::WindowBuilder::new() .with_title(title) - .with_always_on_top(*always_on_top) .with_decorations(*decorated) .with_fullscreen(fullscreen.then(|| winit::window::Fullscreen::Borderless(None))) .with_maximized(*maximized) @@ -143,7 +142,16 @@ pub fn build_window( } } - window_builder.build(event_loop) + let window = window_builder.build(event_loop)?; + + use winit::window::WindowLevel; + window.set_window_level(if *always_on_top { + WindowLevel::AlwaysOnTop + } else { + WindowLevel::Normal + }); + + Ok(window) } fn largest_monitor_point_size(event_loop: &EventLoopWindowTarget) -> egui::Vec2 { @@ -235,7 +243,12 @@ pub fn handle_app_output( } if let Some(always_on_top) = always_on_top { - window.set_always_on_top(always_on_top); + use winit::window::WindowLevel; + window.set_window_level(if always_on_top { + WindowLevel::AlwaysOnTop + } else { + WindowLevel::Normal + }); } } diff --git a/crates/egui-wgpu/Cargo.toml b/crates/egui-wgpu/Cargo.toml index 1696941db2ef..7a0425cb16ad 100644 --- a/crates/egui-wgpu/Cargo.toml +++ b/crates/egui-wgpu/Cargo.toml @@ -49,7 +49,7 @@ wgpu = "0.15.0" ## Enable this when generating docs. document-features = { version = "0.2", optional = true } -winit = { version = "0.27.2", optional = true } +winit = { version = "0.28", optional = true } # Native: [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/crates/egui-winit/Cargo.toml b/crates/egui-winit/Cargo.toml index 64c9ec7d0b57..4ccf0170a368 100644 --- a/crates/egui-winit/Cargo.toml +++ b/crates/egui-winit/Cargo.toml @@ -54,7 +54,7 @@ instant = { version = "0.1", features = [ "wasm-bindgen", ] } # We use instant so we can (maybe) compile for web tracing = { version = "0.1", default-features = false, features = ["std"] } -winit = { version = "0.27.2", default-features = false } +winit = { version = "0.28", default-features = false } #! ### Optional dependencies diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 07c5766e2548..06f3e2887b74 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -380,8 +380,9 @@ impl State { consumed: false, } } - WindowEvent::AxisMotion { .. } - | WindowEvent::CloseRequested + + // Things that may require repaint: + WindowEvent::CloseRequested | WindowEvent::CursorEntered { .. } | WindowEvent::Destroyed | WindowEvent::Occluded(_) @@ -391,10 +392,26 @@ impl State { repaint: true, consumed: false, }, - WindowEvent::Moved(_) => EventResponse { - repaint: false, // moving a window doesn't warrant a repaint + + // Things we completely ignore: + WindowEvent::AxisMotion { .. } + | WindowEvent::Moved(_) + | WindowEvent::SmartMagnify { .. } + | WindowEvent::TouchpadRotate { .. } => EventResponse { + repaint: false, consumed: false, }, + + WindowEvent::TouchpadMagnify { delta, .. } => { + // Positive delta values indicate magnification (zooming in). + // Negative delta values indicate shrinking (zooming out). + let zoom_factor = (*delta as f32).exp(); + self.egui_input.events.push(egui::Event::Zoom(zoom_factor)); + EventResponse { + repaint: true, + consumed: egui_ctx.wants_pointer_input(), + } + } } }