diff --git a/Cargo.lock b/Cargo.lock index 6a0cc54a..65ee6a62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,7 +66,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", - "getrandom 0.3.4", "once_cell", "version_check", "zerocopy", @@ -872,6 +871,17 @@ dependencies = [ "objc2", ] +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + [[package]] name = "dlib" version = "0.5.3" @@ -1067,6 +1077,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + [[package]] name = "futures-channel" version = "0.3.33" @@ -1587,6 +1606,109 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "icu_collections" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" + +[[package]] +name = "icu_properties" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" + +[[package]] +name = "icu_provider" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + [[package]] name = "indexmap" version = "2.14.0" @@ -1910,7 +2032,7 @@ dependencies = [ "bitflags", "libc", "plain", - "redox_syscall 0.9.1", + "redox_syscall", ] [[package]] @@ -1988,6 +2110,12 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + [[package]] name = "log" version = "0.4.33" @@ -2396,11 +2524,10 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "orbclient" -version = "0.3.55" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5df339f526ea9a60e371768d50efc2f2508c7203290731565d1f7a6f71d21747" +checksum = "01f140a738f180203d7912dfd369936fff2fb0ad6f426c0aa007ed3e2b443e6b" dependencies = [ - "libc", "libredox", ] @@ -2667,6 +2794,15 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d20d5497ef88037a52ff98267d066e7f11fcc5e99bbfbd58a42336193aacec3" +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + [[package]] name = "ppv-lite86" version = "0.2.21" @@ -2896,12 +3032,13 @@ dependencies = [ ] [[package]] -name = "redox_syscall" -version = "0.5.18" +name = "redox_event" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +checksum = "c5018d583d6d2f5499352aea8d177e9067d1eb03ab17c78169d5ba7a30001b15" dependencies = [ "bitflags", + "libredox", ] [[package]] @@ -3270,7 +3407,7 @@ checksum = "e8e2fb0f499abb4d162f2bedad68f5ef91a1682b5a03596ddb67efd37768d100" [[package]] name = "smithay" version = "0.7.0" -source = "git+https://github.com/Smithay/smithay.git?rev=4cf0b62028039661477d482ec4758b687d8f4392#4cf0b62028039661477d482ec4758b687d8f4392" +source = "git+https://github.com/Smithay/smithay.git?rev=0ff00983b6007257a7a161a4fe8b14a778e2ac8f#0ff00983b6007257a7a161a4fe8b14a778e2ac8f" dependencies = [ "aliasable", "appendlist", @@ -3321,20 +3458,18 @@ dependencies = [ [[package]] name = "smithay-client-toolkit" -version = "0.20.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0512da38f5e2b31201a93524adb8d3136276fa4fe4aafab4e1f727a82b534cc0" +checksum = "74dc9ee14b0fdcb535f9556141bacac070c994a977d2240ee455d7438a617f00" dependencies = [ "bitflags", "calloop", "calloop-wayland-source", "cursor-icon", - "libc", "log", "memmap2", "rustix 1.1.4", "thiserror 2.0.20", - "wayland-backend", "wayland-client", "wayland-csd-frame", "wayland-cursor", @@ -3349,7 +3484,7 @@ dependencies = [ [[package]] name = "smithay-drm-extras" version = "0.1.0" -source = "git+https://github.com/Smithay/smithay.git?rev=4cf0b62028039661477d482ec4758b687d8f4392#4cf0b62028039661477d482ec4758b687d8f4392" +source = "git+https://github.com/Smithay/smithay.git?rev=0ff00983b6007257a7a161a4fe8b14a778e2ac8f#0ff00983b6007257a7a161a4fe8b14a778e2ac8f" dependencies = [ "drm", "libdisplay-info", @@ -3365,6 +3500,12 @@ dependencies = [ "serde", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + [[package]] name = "static_assertions" version = "1.1.0" @@ -3438,6 +3579,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "system-deps" version = "7.0.8" @@ -3540,6 +3692,16 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "tinystr" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "toml" version = "1.1.4+spec-1.1.0" @@ -3748,6 +3910,24 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -3945,9 +4125,9 @@ dependencies = [ [[package]] name = "wayland-protocols-experimental" -version = "20250721.0.1" +version = "20251230.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a1f863128dcaaec790d7b4b396cc9b9a7a079e878e18c47e6c2d2c5a8dcbb1" +checksum = "91c6c3e7178e553d093d46999032bc79aafea9dedd71dd702c8ace7bbc25cf13" dependencies = [ "bitflags", "wayland-backend", @@ -4251,9 +4431,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winit" -version = "0.31.0-beta.2" +version = "0.31.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2879d2854d1a43e48f67322d4bd097afcb6eb8f8f775c8de0260a71aea1df1aa" +checksum = "f431156a3e4f0f1b35eaaf37674e55838e3652908c8088f570466274d1902e2b" dependencies = [ "bitflags", "cfg_aliases", @@ -4278,9 +4458,9 @@ dependencies = [ [[package]] name = "winit-android" -version = "0.31.0-beta.2" +version = "0.31.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d9c0d2cd93efec3a9f9ad819cfaf0834782403af7c0d248c784ec0c61761df" +checksum = "d5d60d944a564986b9311e325334cc22e7e4cf726dd0ff7475fd925404215af4" dependencies = [ "android-activity", "bitflags", @@ -4294,9 +4474,9 @@ dependencies = [ [[package]] name = "winit-appkit" -version = "0.31.0-beta.2" +version = "0.31.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21310ca07851a49c348e0c2cc768e36b52ca65afda2c2354d78ed4b90074d8aa" +checksum = "23343ec0ea7ac6aa72f38009a6ff66fb63bcf6395e0622fba72794d2a762ab42" dependencies = [ "bitflags", "block2", @@ -4317,13 +4497,16 @@ dependencies = [ [[package]] name = "winit-common" -version = "0.31.0-beta.2" +version = "0.31.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45375fbac4cbb77260d83a30b1f9d8105880dbac99a9ae97f56656694680ff69" +checksum = "e90422ff1c04502aaaac1dad1d099791c2bbb3fbb3f823019e0ce5cdeee04025" dependencies = [ + "block2", + "dpi", "memmap2", "objc2", "objc2-core-foundation", + "objc2-foundation", "smol_str", "tracing", "winit-core", @@ -4333,9 +4516,9 @@ dependencies = [ [[package]] name = "winit-core" -version = "0.31.0-beta.2" +version = "0.31.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4f0ccd7abb43740e2c6124ac7cae7d865ecec74eec63783e8922577ac232583" +checksum = "b8af6307236c51847199950c15cf80e0481a250bb96ce9132f5026df4ad3d0f9" dependencies = [ "bitflags", "cursor-icon", @@ -4343,20 +4526,22 @@ dependencies = [ "keyboard-types", "raw-window-handle", "smol_str", + "url", "web-time", ] [[package]] name = "winit-orbital" -version = "0.31.0-beta.2" +version = "0.31.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ea1fb262e7209f265f12bd0cc792c399b14355675e65531e9c8a87db287d46" +checksum = "278a8ae837902a3bc95dd2fd696d680da33f32130eecc29905358c9089cf6c50" dependencies = [ "bitflags", "dpi", + "libredox", "orbclient", "raw-window-handle", - "redox_syscall 0.5.18", + "redox_event", "smol_str", "tracing", "winit-core", @@ -4364,9 +4549,9 @@ dependencies = [ [[package]] name = "winit-uikit" -version = "0.31.0-beta.2" +version = "0.31.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "680a356e798837d8eb274d4556e83bceaf81698194e31aafc5cfb8a9f2fab643" +checksum = "83315a3ea1739c8466cf23d35e3b0a2cb20c9515d8857666b633afef484740b5" dependencies = [ "bitflags", "block2", @@ -4385,17 +4570,18 @@ dependencies = [ [[package]] name = "winit-wayland" -version = "0.31.0-beta.2" +version = "0.31.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce5afb2ba07da603f84b722c95f9f9396d2cedae3944fb6c0cda4a6f88de545" +checksum = "8b64ceed06de0c45886eef05102106abe1413e703384e337bc57c7e95b71f803" dependencies = [ - "ahash", "bitflags", "calloop", "cursor-icon", "dpi", + "foldhash", "libc", "memmap2", + "percent-encoding", "raw-window-handle", "rustix 1.1.4", "smithay-client-toolkit", @@ -4411,9 +4597,9 @@ dependencies = [ [[package]] name = "winit-web" -version = "0.31.0-beta.2" +version = "0.31.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2490a953fb776fbbd5e295d54f1c3847f4f15b6c3929ec53c09acda6487a92" +checksum = "f539be45f95cc297bdfb80569aef38d925d64aec4133852a4d3fc5cb3660f1c9" dependencies = [ "atomic-waker", "bitflags", @@ -4434,9 +4620,9 @@ dependencies = [ [[package]] name = "winit-win32" -version = "0.31.0-beta.2" +version = "0.31.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644ea78af0e858aa3b092e5d1c67c41995a98220c81813f1353b28bc8bb91eaa" +checksum = "25fb480c41df01d351f656cbf3ad74013f8a9d22bb5b2dcab59f9167e7a0b6ec" dependencies = [ "bitflags", "cursor-icon", @@ -4445,15 +4631,17 @@ dependencies = [ "smol_str", "tracing", "unicode-segmentation", - "windows-sys 0.59.0", + "url", + "windows-sys 0.61.2", + "winit-common", "winit-core", ] [[package]] name = "winit-x11" -version = "0.31.0-beta.2" +version = "0.31.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa5b600756534c7041aa93cd0d244d44b09fca1b89e202bd1cd80dd9f3636c46" +checksum = "bb5746cd907e514b7895491a1c6f7d0cb70077f9e16928cd74ae6f987ffd96aa" dependencies = [ "bitflags", "bytemuck", @@ -4488,6 +4676,12 @@ version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + [[package]] name = "x11-dl" version = "2.21.0" @@ -4584,6 +4778,29 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" +[[package]] +name = "yoke" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "synstructure", +] + [[package]] name = "zbus" version = "5.18.0" @@ -4701,6 +4918,60 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + [[package]] name = "zmij" version = "1.0.23" diff --git a/Cargo.toml b/Cargo.toml index 670d8002..7890fa42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,13 +28,13 @@ tracy-client = { version = "0.18.4", default-features = false } [workspace.dependencies.smithay] # version = "0.4.1" git = "https://github.com/Smithay/smithay.git" -rev = "4cf0b62028039661477d482ec4758b687d8f4392" +rev = "0ff00983b6007257a7a161a4fe8b14a778e2ac8f" default-features = false [workspace.dependencies.smithay-drm-extras] # version = "0.1.0" git = "https://github.com/Smithay/smithay.git" -rev = "4cf0b62028039661477d482ec4758b687d8f4392" +rev = "0ff00983b6007257a7a161a4fe8b14a778e2ac8f" # path = "../smithay/smithay-drm-extras" [package] diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index bd2d9a2e..cd7eb708 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -39,7 +39,7 @@ use smithay::wayland::keyboard_shortcuts_inhibit::{ }; use smithay::wayland::output::OutputHandler; use smithay::wayland::pointer_constraints::{ - with_pointer_constraint, PointerConstraint, PointerConstraintsHandler, + with_pointer_constraint, ConstraintRemove, PointerConstraintsHandler, }; use smithay::wayland::security_context::{ SecurityContext, SecurityContextHandler, SecurityContextListenerSource, @@ -206,7 +206,7 @@ impl PointerConstraintsHandler for State { &mut self, _surface: &WlSurface, pointer: &PointerHandle, - _constraint: Option<&PointerConstraint>, + reason: ConstraintRemove, ) { // Since a pointer constraint is broken when a surface loses pointer focus, and one surface // can only have a single pointer constraint at once, assume there can be only one @@ -219,11 +219,7 @@ impl PointerConstraintsHandler for State { // If the constraint was broken by the pointer forcibly leaving the surface (e.g. the user // opened the overview), then it doesn't make much sense to warp it. - // - // Furthermore, when the constraint is removed as part of the pointer leaving the surface, - // this call happens with locked pointer data, and calling set_location() will try to lock - // it again and deadlock. - if pointer.last_enter().is_none() { + if matches!(reason, ConstraintRemove::PointerLeave(_)) { return; } diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index b0525d24..a266b6ca 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -2,6 +2,7 @@ use std::cell::Cell; use calloop::Interest; use niri_config::PresetSize; +use smithay::backend::input::InputTime; use smithay::desktop::{ find_popup_root_surface, get_popup_toplevel_coords, layer_map_for_output, utils, LayerSurface, PopupKeyboardGrab, PopupKind, PopupManager, PopupPointerGrab, PopupUngrabStrategy, Window, @@ -113,33 +114,32 @@ impl XdgShellHandler for State { // See if this comes from a tablet tool grab. let mut tablet_tool = None; - self.niri.seat.tablet_seat().with_tools(|tools| { - for tool in tools.values() { - let found = tool.with_grab(|grab_serial, grab| { - if grab_serial == serial { - let start_data = grab.start_data(); - if let Some((focus, _)) = &start_data.focus { - if focus.id().same_client_as(&wl_surface.id()) { - // Deny move requests from DnD grabs to work around - // https://gitlab.gnome.org/GNOME/gtk/-/issues/7113 - let is_dnd_grab = Self::is_dnd_grab(grab.as_any()); - - if !is_dnd_grab { - grab_start_data = - Some(AnyStartData::TabletTool(start_data.clone())); - tablet_tool = Some(tool.clone()); - return true; - } + let tools = self.niri.seat.tablet_seat().get_tools(); + for tool in tools.values() { + let found = tool.with_grab(|grab_serial, grab| { + if grab_serial == serial { + let start_data = grab.start_data(); + if let Some((focus, _)) = &start_data.focus { + if focus.id().same_client_as(&wl_surface.id()) { + // Deny move requests from DnD grabs to work around + // https://gitlab.gnome.org/GNOME/gtk/-/issues/7113 + let is_dnd_grab = Self::is_dnd_grab(grab.as_any()); + + if !is_dnd_grab { + grab_start_data = + Some(AnyStartData::TabletTool(start_data.clone())); + tablet_tool = Some(tool.clone()); + return true; } } } - false - }); - if found == Some(true) { - break; } + false + }); + if found == Some(true) { + break; } - }); + } let Some(start_data) = grab_start_data else { return; @@ -170,7 +170,7 @@ impl XdgShellHandler for State { } AnyStartData::TabletTool(_) => { if let Some(grab) = MoveGrab::new(self, start_data, window.clone(), true, None) { - let time = get_monotonic_time().as_millis() as u32; + let time = InputTime::now(); tablet_tool .unwrap() .set_grab(self, grab, time, serial, Focus::Clear); @@ -219,21 +219,20 @@ impl XdgShellHandler for State { // See if this comes from a tablet tool grab. let mut tablet_tool = None; - self.niri.seat.tablet_seat().with_tools(|tools| { - 'outer: for tool in tools.values() { - if tool.has_grab(serial) { - if let Some(start_data) = tool.grab_start_data() { - if let Some((focus, _)) = &start_data.focus { - if focus.id().same_client_as(&wl_surface.id()) { - grab_start_data = Some(AnyStartData::TabletTool(start_data)); - tablet_tool = Some(tool.clone()); - break 'outer; - } + let tools = self.niri.seat.tablet_seat().get_tools(); + 'outer: for tool in tools.values() { + if tool.has_grab(serial) { + if let Some(start_data) = tool.grab_start_data() { + if let Some((focus, _)) = &start_data.focus { + if focus.id().same_client_as(&wl_surface.id()) { + grab_start_data = Some(AnyStartData::TabletTool(start_data)); + tablet_tool = Some(tool.clone()); + break 'outer; } } } } - }); + } let Some(start_data) = grab_start_data else { return; @@ -301,7 +300,7 @@ impl XdgShellHandler for State { } AnyStartData::TabletTool(_) => { let grab = ResizeGrab::new(start_data, window); - let time = get_monotonic_time().as_millis() as u32; + let time = InputTime::now(); tablet_tool .unwrap() .set_grab(self, grab, time, serial, Focus::Clear); diff --git a/src/input/mod.rs b/src/input/mod.rs index 50db88fc..13081875 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -417,7 +417,7 @@ impl State { let mod_key = self.backend.mod_key(&self.niri.config.borrow()); let serial = SERIAL_COUNTER.next_serial(); - let time = Event::time_msec(&event); + let time = Event::time(&event); let pressed = event.state() == KeyState::Pressed; // Stop bind key repeat on any release. This won't work 100% correctly in cases like: @@ -447,7 +447,7 @@ impl State { #[cfg(feature = "dbus")] let block = { let block = self.a11y_process_key( - Duration::from_millis(u64::from(time)), + Duration::from_micros(time.micros()), event.key_code(), event.state(), ); @@ -2496,7 +2496,7 @@ impl State { &RelativeMotionEvent { delta: event.delta(), delta_unaccel: event.delta_unaccel(), - utime: event.time(), + time: event.time(), }, ); @@ -2607,7 +2607,7 @@ impl State { &RelativeMotionEvent { delta: event.delta(), delta_unaccel: event.delta_unaccel(), - utime: event.time(), + time: event.time(), }, ); @@ -2627,7 +2627,7 @@ impl State { &MotionEvent { location: new_pos, serial, - time: event.time_msec(), + time: event.time(), }, ); @@ -2637,7 +2637,7 @@ impl State { &RelativeMotionEvent { delta: event.delta(), delta_unaccel: event.delta_unaccel(), - utime: event.time(), + time: event.time(), }, ); @@ -2728,7 +2728,7 @@ impl State { &MotionEvent { location: pos, serial, - time: event.time_msec(), + time: event.time(), }, ); @@ -3094,7 +3094,7 @@ impl State { button: button_code, state: button_state, serial, - time: event.time_msec(), + time: event.time(), }, ); pointer.frame(self); @@ -3113,7 +3113,7 @@ impl State { self.niri.pointer_visibility = PointerVisibility::Visible; self.niri.tablet_cursor_location = None; - let timestamp = Duration::from_micros(event.time()); + let timestamp = Duration::from_micros(event.time().micros()); let horizontal_amount_v120 = event.amount_v120(Axis::Horizontal); let vertical_amount_v120 = event.amount_v120(Axis::Vertical); @@ -3550,7 +3550,7 @@ impl State { let horizontal_amount_v120 = horizontal_amount_v120.map(|x| x * horizontal_factor); let vertical_amount_v120 = vertical_amount_v120.map(|x| x * vertical_factor); - let mut frame = AxisFrame::new(event.time_msec()).source(source); + let mut frame = AxisFrame::new(event.time()).source(source); if horizontal_amount != 0.0 { frame = frame .relative_direction(Axis::Horizontal, event.relative_direction(Axis::Horizontal)); @@ -3611,7 +3611,7 @@ impl State { let tablet_seat = self.niri.seat.tablet_seat(); let tool = tablet_seat.get_tool(&event.tool()); if let Some(tool) = tool { - let time = event.time_msec(); + let time = event.time(); let frame = tablet::tool::AxisFrame { pressure: event.pressure_has_changed().then(|| event.pressure()), @@ -3655,7 +3655,7 @@ impl State { let tip_state = event.tip_state(); let serial = SERIAL_COUNTER.next_serial(); - let time = event.time_msec(); + let time = event.time(); match tip_state { TabletToolTipState::Down => { @@ -3728,7 +3728,7 @@ impl State { location: pos, }; let start_data = AnyStartData::TabletTool(start_data); - let start_timestamp = Duration::from_micros(event.time()); + let start_timestamp = Duration::from_micros(event.time().micros()); let grab = TouchOverviewGrab::new( start_data, start_timestamp, @@ -3810,7 +3810,7 @@ impl State { let tablet = tablet_seat.get_tablet(&TabletDescriptor::from(&event.device())); if let Some(tablet) = tablet { let serial = SERIAL_COUNTER.next_serial(); - let time = event.time_msec(); + let time = event.time(); match event.state() { ProximityState::In => { @@ -3913,7 +3913,7 @@ impl State { } } - let time = event.time_msec(); + let time = event.time(); tool.button( self, @@ -3959,7 +3959,7 @@ impl State { self, &GestureSwipeBeginEvent { serial, - time: event.time_msec(), + time: event.time(), fingers: event.fingers(), }, ); @@ -4030,7 +4030,7 @@ impl State { } } - let timestamp = Duration::from_micros(event.time()); + let timestamp = Duration::from_micros(event.time().micros()); let mut handled = false; let res = self @@ -4080,7 +4080,7 @@ impl State { pointer.gesture_swipe_update( self, &GestureSwipeUpdateEvent { - time: event.time_msec(), + time: event.time(), delta: event.delta(), }, ); @@ -4124,7 +4124,7 @@ impl State { self, &GestureSwipeEndEvent { serial, - time: event.time_msec(), + time: event.time(), cancelled: event.cancelled(), }, ); @@ -4142,7 +4142,7 @@ impl State { self, &GesturePinchBeginEvent { serial, - time: event.time_msec(), + time: event.time(), fingers: event.fingers(), }, ); @@ -4158,7 +4158,7 @@ impl State { pointer.gesture_pinch_update( self, &GesturePinchUpdateEvent { - time: event.time_msec(), + time: event.time(), delta: event.delta(), scale: event.scale(), rotation: event.rotation(), @@ -4178,7 +4178,7 @@ impl State { self, &GesturePinchEndEvent { serial, - time: event.time_msec(), + time: event.time(), cancelled: event.cancelled(), }, ); @@ -4196,7 +4196,7 @@ impl State { self, &GestureHoldBeginEvent { serial, - time: event.time_msec(), + time: event.time(), fingers: event.fingers(), }, ); @@ -4214,7 +4214,7 @@ impl State { self, &GestureHoldEndEvent { serial, - time: event.time_msec(), + time: event.time(), cancelled: event.cancelled(), }, ); @@ -4326,7 +4326,7 @@ impl State { location: pos, }; let start_data = AnyStartData::Touch(start_data); - let start_timestamp = Duration::from_micros(evt.time()); + let start_timestamp = Duration::from_micros(evt.time().micros()); let grab = TouchOverviewGrab::new( start_data, start_timestamp, @@ -4372,7 +4372,7 @@ impl State { slot, location: pos, serial, - time: evt.time_msec(), + time: evt.time(), }, ); @@ -4399,7 +4399,7 @@ impl State { &UpEvent { slot, serial, - time: evt.time_msec(), + time: evt.time(), }, ) } @@ -4429,7 +4429,7 @@ impl State { &TouchMotionEvent { slot, location: pos, - time: evt.time_msec(), + time: evt.time(), }, ); diff --git a/src/input/move_grab.rs b/src/input/move_grab.rs index a206bd98..b10db89b 100644 --- a/src/input/move_grab.rs +++ b/src/input/move_grab.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use smithay::backend::input::ButtonState; +use smithay::backend::input::{ButtonState, InputTime}; use smithay::desktop::Window; use smithay::input::pointer::{ AxisFrame, ButtonEvent, CursorIcon, CursorImageStatus, GestureHoldBeginEvent, @@ -20,7 +20,6 @@ use smithay::utils::{IsAlive, Logical, Point, SERIAL_COUNTER}; use crate::input::AnyStartData; use crate::niri::State; -use crate::utils::get_monotonic_time; pub struct MoveGrab { start_data: AnyStartData, @@ -311,7 +310,7 @@ impl PointerGrab for MoveGrab { // Relative motion takes precedence over normal motion. if self.relative_delta.is_none() { - self.event_timestamp = Some(Duration::from_millis(u64::from(event.time))); + self.event_timestamp = Some(Duration::from_micros(event.time.micros())); } } @@ -326,7 +325,7 @@ impl PointerGrab for MoveGrab { handle.relative_motion(data, None, event); *self.relative_delta.get_or_insert_default() += event.delta; - self.event_timestamp = Some(Duration::from_micros(event.utime)); + self.event_timestamp = Some(Duration::from_micros(event.time.micros())); } fn button( @@ -378,7 +377,7 @@ impl PointerGrab for MoveGrab { self, data, SERIAL_COUNTER.next_serial(), - get_monotonic_time().as_millis() as u32, + InputTime::now(), true, ); } @@ -511,7 +510,7 @@ impl TouchGrab for MoveGrab { } self.new_location = event.location; - self.event_timestamp = Some(Duration::from_millis(u64::from(event.time))); + self.event_timestamp = Some(Duration::from_micros(event.time.micros())); } fn frame(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>) { @@ -580,7 +579,7 @@ impl TabletToolGrab for MoveGrab { handle.motion(data, None, event); self.new_location = event.location; - self.event_timestamp = Some(Duration::from_millis(u64::from(event.time))); + self.event_timestamp = Some(Duration::from_micros(event.time.micros())); } fn down( @@ -624,7 +623,7 @@ impl TabletToolGrab for MoveGrab { &mut self, data: &mut State, handle: &mut TabletToolInnerHandle<'_, State>, - time: u32, + time: InputTime, ) { handle.frame(data, time); @@ -634,7 +633,7 @@ impl TabletToolGrab for MoveGrab { self, data, SERIAL_COUNTER.next_serial(), - get_monotonic_time().as_millis() as u32, + InputTime::now(), true, ); } diff --git a/src/input/resize_grab.rs b/src/input/resize_grab.rs index 941957e8..17158e40 100644 --- a/src/input/resize_grab.rs +++ b/src/input/resize_grab.rs @@ -1,3 +1,4 @@ +use smithay::backend::input::InputTime; use smithay::desktop::Window; use smithay::input::pointer::{ AxisFrame, ButtonEvent, CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent, @@ -15,7 +16,6 @@ use smithay::utils::{IsAlive, Logical, Point, SERIAL_COUNTER}; use crate::input::AnyStartData; use crate::niri::State; -use crate::utils::get_monotonic_time; pub struct ResizeGrab { start_data: AnyStartData, @@ -116,7 +116,7 @@ impl PointerGrab for ResizeGrab { self, data, SERIAL_COUNTER.next_serial(), - get_monotonic_time().as_millis() as u32, + InputTime::now(), true, ); } @@ -354,7 +354,7 @@ impl TabletToolGrab for ResizeGrab { &mut self, data: &mut State, handle: &mut TabletToolInnerHandle<'_, State>, - time: u32, + time: InputTime, ) { handle.frame(data, time); @@ -364,7 +364,7 @@ impl TabletToolGrab for ResizeGrab { self, data, SERIAL_COUNTER.next_serial(), - get_monotonic_time().as_millis() as u32, + InputTime::now(), true, ); } diff --git a/src/input/spatial_movement_grab.rs b/src/input/spatial_movement_grab.rs index 546929a0..627050a7 100644 --- a/src/input/spatial_movement_grab.rs +++ b/src/input/spatial_movement_grab.rs @@ -1,5 +1,6 @@ use std::time::Duration; +use smithay::backend::input::InputTime; use smithay::input::pointer::{ AxisFrame, ButtonEvent, CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, @@ -12,7 +13,6 @@ use smithay::utils::{Logical, Point, SERIAL_COUNTER}; use crate::layout::workspace::WorkspaceId; use crate::niri::State; -use crate::utils::get_monotonic_time; pub struct SpatialMovementGrab { start_data: PointerGrabStartData, @@ -159,7 +159,7 @@ impl PointerGrab for SpatialMovementGrab { // Relative motion takes precedence over normal motion. if self.relative_delta.is_none() { - self.event_timestamp = Some(Duration::from_millis(u64::from(event.time))); + self.event_timestamp = Some(Duration::from_micros(event.time.micros())); } } @@ -174,7 +174,7 @@ impl PointerGrab for SpatialMovementGrab { handle.relative_motion(data, None, event); *self.relative_delta.get_or_insert_default() += event.delta; - self.event_timestamp = Some(Duration::from_micros(event.utime)); + self.event_timestamp = Some(Duration::from_micros(event.time.micros())); } fn button( @@ -209,7 +209,7 @@ impl PointerGrab for SpatialMovementGrab { self, data, SERIAL_COUNTER.next_serial(), - get_monotonic_time().as_millis() as u32, + InputTime::now(), true, ); } diff --git a/src/input/touch_overview_grab.rs b/src/input/touch_overview_grab.rs index c5c4ef88..82b307de 100644 --- a/src/input/touch_overview_grab.rs +++ b/src/input/touch_overview_grab.rs @@ -1,5 +1,6 @@ use std::time::Duration; +use smithay::backend::input::InputTime; use smithay::desktop::Window; use smithay::input::pointer::{CursorIcon, CursorImageStatus}; use smithay::input::tablet::tool::{TabletToolGrab, TabletToolInnerHandle}; @@ -15,7 +16,6 @@ use smithay::utils::{IsAlive, Logical, Point, SERIAL_COUNTER}; use crate::input::AnyStartData; use crate::layout::workspace::{Workspace, WorkspaceId}; use crate::niri::State; -use crate::utils::get_monotonic_time; use crate::window::Mapped; // When the touch is stationary for this much time, it becomes an interactive move. @@ -282,7 +282,7 @@ impl TouchGrab for TouchOverviewGrab { } self.new_location = event.location; - self.event_timestamp = Some(Duration::from_millis(u64::from(event.time))); + self.event_timestamp = Some(Duration::from_micros(event.time.micros())); } fn frame(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>) { @@ -351,7 +351,7 @@ impl TabletToolGrab for TouchOverviewGrab { handle.motion(data, None, event); self.new_location = event.location; - self.event_timestamp = Some(Duration::from_millis(u64::from(event.time))); + self.event_timestamp = Some(Duration::from_micros(event.time.micros())); } fn down( @@ -395,7 +395,7 @@ impl TabletToolGrab for TouchOverviewGrab { &mut self, data: &mut State, handle: &mut TabletToolInnerHandle<'_, State>, - time: u32, + time: InputTime, ) { handle.frame(data, time); @@ -405,7 +405,7 @@ impl TabletToolGrab for TouchOverviewGrab { self, data, SERIAL_COUNTER.next_serial(), - get_monotonic_time().as_millis() as u32, + InputTime::now(), true, ); } diff --git a/src/niri.rs b/src/niri.rs index fa44b5cb..552f41d7 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -20,7 +20,7 @@ use niri_config::{ WorkspaceReference, Xkb, }; use smithay::backend::allocator::Fourcc; -use smithay::backend::input::Keycode; +use smithay::backend::input::{InputTime, Keycode}; use smithay::backend::renderer::damage::OutputDamageTracker; use smithay::backend::renderer::element::memory::MemoryRenderBufferRenderElement; use smithay::backend::renderer::element::surface::WaylandSurfaceRenderElement; @@ -875,7 +875,7 @@ impl State { &MotionEvent { location, serial: SERIAL_COUNTER.next_serial(), - time: get_monotonic_time().as_millis() as u32, + time: InputTime::now(), }, ); pointer.frame(self); @@ -1106,7 +1106,7 @@ impl State { &MotionEvent { location, serial: SERIAL_COUNTER.next_serial(), - time: get_monotonic_time().as_millis() as u32, + time: InputTime::now(), }, ); @@ -1336,7 +1336,7 @@ impl State { self.niri.seat.get_pointer().unwrap().unset_grab( self, SERIAL_COUNTER.next_serial(), - get_monotonic_time().as_millis() as u32, + InputTime::now(), ); self.niri.popup_grab = None; } @@ -1999,7 +1999,7 @@ impl State { }; // Now that we captured the screenshots, clear grabs like drag-and-drop, etc. - let time = get_monotonic_time().as_millis() as u32; + let time = InputTime::now(); self.niri .seat .get_pointer() @@ -2009,12 +2009,7 @@ impl State { touch.unset_grab(self); } - // Can't unset_grab() from with_tools(), will deadlock on tablet seat mutex... - let mut tools = Vec::new(); - self.niri.seat.tablet_seat().with_tools(|map| { - tools = Vec::from_iter(map.values().cloned()); - }); - for tool in tools { + for tool in self.niri.seat.tablet_seat().get_tools().into_values() { tool.unset_grab(self, SERIAL_COUNTER.next_serial(), time); } diff --git a/src/protocols/virtual_pointer.rs b/src/protocols/virtual_pointer.rs index c2b01e1c..0d1a6f6f 100644 --- a/src/protocols/virtual_pointer.rs +++ b/src/protocols/virtual_pointer.rs @@ -3,7 +3,7 @@ use std::sync::Mutex; use smithay::backend::input::{ AbsolutePositionEvent, Axis, AxisRelativeDirection, AxisSource, ButtonState, Device, - DeviceCapability, Event, InputBackend, PointerAxisEvent, PointerButtonEvent, + DeviceCapability, Event, InputBackend, InputTime, PointerAxisEvent, PointerButtonEvent, PointerMotionAbsoluteEvent, PointerMotionEvent, UnusedEvent, }; use smithay::input::pointer::AxisFrame; @@ -69,7 +69,9 @@ impl VirtualPointer { fn mutate_axis_frame(&self, time: Option, f: impl FnOnce(AxisFrame) -> AxisFrame) { let mut frame = self.data().axis_frame.lock().unwrap(); - *frame = frame.or(time.map(AxisFrame::new)).map(f); + *frame = frame + .or(time.map(InputTime::from_millis).map(AxisFrame::new)) + .map(f); } } @@ -103,8 +105,8 @@ pub struct VirtualPointerMotionEvent { } impl Event for VirtualPointerMotionEvent { - fn time(&self) -> u64 { - self.time as u64 * 1000 // millis to micros + fn time(&self) -> InputTime { + InputTime::from_millis(self.time) } fn device(&self) -> VirtualPointer { @@ -140,8 +142,8 @@ pub struct VirtualPointerMotionAbsoluteEvent { } impl Event for VirtualPointerMotionAbsoluteEvent { - fn time(&self) -> u64 { - self.time as u64 * 1000 // millis to micros + fn time(&self) -> InputTime { + InputTime::from_millis(self.time) } fn device(&self) -> VirtualPointer { @@ -175,8 +177,8 @@ pub struct VirtualPointerButtonEvent { } impl Event for VirtualPointerButtonEvent { - fn time(&self) -> u64 { - self.time as u64 * 1000 // millis to micros + fn time(&self) -> InputTime { + InputTime::from_millis(self.time) } fn device(&self) -> VirtualPointer { @@ -200,8 +202,8 @@ pub struct VirtualPointerAxisEvent { } impl Event for VirtualPointerAxisEvent { - fn time(&self) -> u64 { - self.frame.time as u64 * 1000 // millis to micros + fn time(&self) -> InputTime { + self.frame.time } fn device(&self) -> VirtualPointer {