diff --git a/Cargo.lock b/Cargo.lock index c27ed2cb..007567b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,7 +21,7 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" [[package]] name = "accesskit" version = "0.22.0" -source = "git+https://github.com/wash2/accesskit?rev=6c20249#6c20249d3b9fd45e7002efad9f6b6171a9257912" +source = "git+https://github.com/wash2/accesskit?tag=cosmic-0.14#f0599eed5f18111228266fe3f28991cc48b5964f" dependencies = [ "uuid", ] @@ -29,7 +29,7 @@ dependencies = [ [[package]] name = "accesskit_consumer" version = "0.32.0" -source = "git+https://github.com/wash2/accesskit?rev=6c20249#6c20249d3b9fd45e7002efad9f6b6171a9257912" +source = "git+https://github.com/wash2/accesskit?tag=cosmic-0.14#f0599eed5f18111228266fe3f28991cc48b5964f" dependencies = [ "accesskit", "hashbrown 0.16.1", @@ -38,7 +38,7 @@ dependencies = [ [[package]] name = "accesskit_macos" version = "0.23.0" -source = "git+https://github.com/wash2/accesskit?rev=6c20249#6c20249d3b9fd45e7002efad9f6b6171a9257912" +source = "git+https://github.com/wash2/accesskit?tag=cosmic-0.14#f0599eed5f18111228266fe3f28991cc48b5964f" dependencies = [ "accesskit", "accesskit_consumer", @@ -51,7 +51,7 @@ dependencies = [ [[package]] name = "accesskit_windows" version = "0.30.0" -source = "git+https://github.com/wash2/accesskit?rev=6c20249#6c20249d3b9fd45e7002efad9f6b6171a9257912" +source = "git+https://github.com/wash2/accesskit?tag=cosmic-0.14#f0599eed5f18111228266fe3f28991cc48b5964f" dependencies = [ "accesskit", "accesskit_consumer", @@ -64,7 +64,7 @@ dependencies = [ [[package]] name = "accesskit_winit" version = "0.30.0" -source = "git+https://github.com/wash2/accesskit?rev=6c20249#6c20249d3b9fd45e7002efad9f6b6171a9257912" +source = "git+https://github.com/wash2/accesskit?tag=cosmic-0.14#f0599eed5f18111228266fe3f28991cc48b5964f" dependencies = [ "accesskit", "accesskit_macos", @@ -135,7 +135,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef6978589202a00cd7e118380c448a08b6ed394c3a8df3a430d0898e3a42d046" dependencies = [ "android-properties", - "bitflags 2.13.2", + "bitflags 2.13.1", "cc", "cesu8", "jni", @@ -182,6 +182,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f47b57fc4521e3cae26a4d45b5227f8fadee4c345be0fefd8d5d1711afb8aeb9" +[[package]] +name = "approx" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f2a05fd1bd10b2527e20a2cd32d8873d115b8b39fe219ee25f42a8aca6ba278" +dependencies = [ + "num-traits", +] + [[package]] name = "approx" version = "0.5.1" @@ -236,7 +245,7 @@ dependencies = [ "enumflags2", "futures-channel", "futures-util", - "rand 0.9.5", + "rand 0.9.2", "serde", "serde_repr", "url", @@ -470,9 +479,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.13.2" +version = "2.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" +checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" dependencies = [ "serde_core", ] @@ -610,7 +619,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dbf9978365bac10f54d1d4b04f7ce4427e51f71d61f2fe15e3fed5166474df7" dependencies = [ "async-task", - "bitflags 2.13.2", + "bitflags 2.13.1", "futures-core", "polling", "rustix 1.1.4", @@ -670,6 +679,16 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "cgmath" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a98d30140e3296250832bbaaff83b27dcd6fa3cc70fb6f1f3e5c9c0023b5317" +dependencies = [ + "approx 0.4.0", + "num-traits", +] + [[package]] name = "chacha20" version = "0.10.0" @@ -854,7 +873,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "core-foundation 0.10.1", "libc", ] @@ -872,7 +891,7 @@ dependencies = [ name = "cosmic-client-toolkit" version = "0.2.0" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "cosmic-protocols", "libc", "smithay-client-toolkit", @@ -885,7 +904,7 @@ name = "cosmic-comp" version = "1.0.0" dependencies = [ "anyhow", - "bitflags 2.13.2", + "bitflags 2.13.1", "calloop", "clap_lex", "cosmic-comp-config", @@ -1001,7 +1020,7 @@ dependencies = [ name = "cosmic-protocols" version = "0.2.0" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "wayland-backend", "wayland-client", "wayland-protocols", @@ -1021,7 +1040,7 @@ dependencies = [ [[package]] name = "cosmic-settings-config" -version = "1.9.0" +version = "0.1.0" dependencies = [ "cosmic-config", "ron 0.11.0", @@ -1040,7 +1059,7 @@ dependencies = [ [[package]] name = "cosmic-settings-daemon-config" -version = "1.9.0" +version = "0.1.0" dependencies = [ "cosmic-config", "cosmic-theme", @@ -1051,7 +1070,7 @@ dependencies = [ name = "cosmic-text" version = "0.19.0" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "fontdb", "harfrust", "linebender_resource_handle", @@ -1289,7 +1308,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "objc2 0.6.4", ] @@ -1317,7 +1336,7 @@ dependencies = [ name = "dnd" version = "0.1.0" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "mime 0.1.0", "raw-window-handle", "smithay-client-toolkit", @@ -1355,7 +1374,7 @@ version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80bc8c5c6c2941f70a55c15f8d9f00f9710ebda3ffda98075f996a0e6c92756f" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "bytemuck", "drm-ffi", "drm-fourcc", @@ -1412,7 +1431,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25dd34cec49ab55d85ebf70139cb1ccd29c977ef6b6ba4fe85489d6877ee9ef3" dependencies = [ "ahash", - "bitflags 2.13.2", + "bitflags 2.13.1", "emath", "epaint", "nohash-hasher", @@ -1936,7 +1955,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce852e998d3ca5e4a97014fb31c940dc5ef344ec7d364984525fd11e8a547e6a" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "drm", "drm-fourcc", "gbm-sys", @@ -2104,7 +2123,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b89c83349105e3732062a895becfc71a8f921bb71ecbbdd8ff99263e3b53a0ca" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "gpu-descriptor-types", "hashbrown 0.15.5", ] @@ -2115,7 +2134,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", ] [[package]] @@ -2152,7 +2171,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f9f40651a03bc0f7316bd75267ff5767e93017ef3cfffe76c6aa7252cc5a31c" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "bytemuck", "core_maths", "read-fonts 0.37.0", @@ -2374,7 +2393,7 @@ dependencies = [ name = "iced_core" version = "0.14.0" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "build_helpers", "bytes", "cosmic-client-toolkit", @@ -2420,7 +2439,7 @@ dependencies = [ name = "iced_graphics" version = "0.14.0" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "bytemuck", "cosmic-text", "half", @@ -2490,7 +2509,7 @@ dependencies = [ name = "iced_wgpu" version = "0.14.0" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "build_helpers", "bytemuck", "cosmic-client-toolkit", @@ -2752,7 +2771,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "inotify-sys", "libc", ] @@ -2772,7 +2791,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9793345a65d71317763a33066b5d8351f8760dde8d4930fe9e39b5f14a7959d" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "input-sys", "libc", "log", @@ -2930,7 +2949,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fbe853b403ae61a04233030ae8a79d94975281ed9770a1f9e246732b534b28d" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "serde", ] @@ -3034,9 +3053,9 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" [[package]] name = "libc" -version = "0.2.182" +version = "0.2.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" [[package]] name = "libcosmic-yoda" @@ -3072,7 +3091,6 @@ dependencies = [ "log", "palette", "phf 0.13.1", - "roxmltree 0.20.0", "rust-embed", "serde", "slotmap", @@ -3090,7 +3108,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59fd96dbb2381ff31f314f07accbdf8550febdcc5cd8761ecaf7c1763361c359" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "libc", "libdisplay-info-derive", "libdisplay-info-sys", @@ -3136,14 +3154,14 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libredox" -version = "0.1.25" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d" +checksum = "28d0a00925a9f930d679b6789b721e3a7f9ed110f41b86d2497caa780c3a070a" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "libc", "plain", - "redox_syscall 0.9.4", + "redox_syscall 0.9.2", ] [[package]] @@ -3402,7 +3420,7 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7047791b5bc903b8cd963014b355f71dc9864a9a0b727057676c1dcae5cbc15" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "block", "core-graphics-types 0.2.0", "foreign-types", @@ -3464,9 +3482,9 @@ checksum = "e53debba6bda7a793e5f99b8dacf19e626084f525f7829104ba9898f367d85ff" [[package]] name = "mio" -version = "1.1.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +checksum = "30d65c71f1ce40ab09135ce117d742b9f8a19ff91a41a8b57ed50bc2de59c427" dependencies = [ "libc", "log", @@ -3498,7 +3516,7 @@ checksum = "618f667225063219ddfc61251087db8a9aec3c3f0950c916b614e403486f1135" dependencies = [ "arrayvec", "bit-set", - "bitflags 2.13.2", + "bitflags 2.13.1", "cfg-if", "cfg_aliases", "codespan-reporting", @@ -3522,7 +3540,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "jni-sys", "log", "ndk-sys", @@ -3552,7 +3570,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "cfg-if", "cfg_aliases", "libc", @@ -3580,7 +3598,7 @@ version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d3d07927151ff8575b7087f245456e549fea62edf0ec4e565a5ee50c8402bc3" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "fsevent-sys", "inotify", "kqueue", @@ -3598,7 +3616,7 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42b8cfee0e339a0337359f3c88165702ac6e600dc01c0cc9579a92d62b08477a" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", ] [[package]] @@ -3763,7 +3781,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "block2 0.5.1", "libc", "objc2 0.5.2", @@ -3779,7 +3797,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "objc2 0.6.4", "objc2-core-foundation", "objc2-foundation 0.3.2", @@ -3791,7 +3809,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -3803,7 +3821,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "block2 0.6.2", "dispatch2", "objc2 0.6.4", @@ -3815,7 +3833,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "libc", "objc2-core-foundation", ] @@ -3838,7 +3856,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "objc2-core-foundation", "objc2-core-graphics", ] @@ -3855,7 +3873,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "block2 0.5.1", "libc", "objc2 0.5.2", @@ -3867,7 +3885,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "block2 0.6.2", "objc2 0.6.4", "objc2-core-foundation", @@ -3879,7 +3897,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -3891,7 +3909,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -3904,7 +3922,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "objc2 0.6.4", "objc2-core-foundation", "objc2-foundation 0.3.2", @@ -4008,7 +4026,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cbf71184cc5ecc2e4e1baccdb21026c20e5fc3dcf63028a086131b3ab00b6e6" dependencies = [ - "approx", + "approx 0.5.1", "fast-srgb8", "palette_derive", "phf 0.11.3", @@ -4255,7 +4273,7 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "crc32fast", "fdeflate", "flate2", @@ -4456,9 +4474,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.9.5" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.5", @@ -4570,7 +4588,7 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5018d583d6d2f5499352aea8d177e9067d1eb03ab17c78169d5ba7a30001b15" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "libredox", ] @@ -4580,16 +4598,16 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", ] [[package]] name = "redox_syscall" -version = "0.9.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "737970939a87c6fa31e7acad13307bccbb017a073b695b6089a2c484f929e20e" +checksum = "f1c93da5bb2c5d4e6c0ef7abeead62c89169a0a4882bfb83ac892f2423aea2fe" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", ] [[package]] @@ -4717,7 +4735,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db09040cc89e461f1a265139777a2bde7f8d8c67c4936f700c63ce3e2904d468" dependencies = [ "base64 0.22.1", - "bitflags 2.13.2", + "bitflags 2.13.1", "serde", "serde_derive", "unicode-ident", @@ -4729,7 +4747,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd490c5b18261893f14449cbd28cb9c0b637aebf161cd77900bfdedaff21ec32" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "once_cell", "serde", "serde_derive", @@ -4807,7 +4825,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "errno", "libc", "linux-raw-sys 0.4.15", @@ -4820,7 +4838,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "errno", "libc", "linux-raw-sys 0.12.1", @@ -4839,7 +4857,7 @@ version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd3c7c96f8a08ee34eff8857b11b49b07d71d1c3f4e88f8a88d4c9e9f90b1702" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "bytemuck", "core_maths", "log", @@ -5132,12 +5150,12 @@ checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" [[package]] name = "smithay" version = "0.7.0" -source = "git+https://github.com/smithay/smithay.git?rev=e3d461a#e3d461a057ba244d213a8498ec372b0799cca103" +source = "git+https://github.com/smithay/smithay.git?rev=5fb12b8#5fb12b87407b3680135c45d94214c5f1b1d0fbea" dependencies = [ "aliasable", "appendlist", "ash", - "bitflags 2.13.2", + "bitflags 2.13.1", "calloop", "cc", "cursor-icon", @@ -5161,7 +5179,7 @@ dependencies = [ "pkg-config", "portable-atomic", "profiling", - "rand 0.10.0", + "rand 0.9.2", "reis", "rustix 1.1.4", "scopeguard", @@ -5190,7 +5208,7 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0512da38f5e2b31201a93524adb8d3136276fa4fe4aafab4e1f727a82b534cc0" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "bytemuck", "calloop", "calloop-wayland-source", @@ -5227,13 +5245,16 @@ dependencies = [ [[package]] name = "smithay-egui" version = "0.2.0" -source = "git+https://github.com/Smithay/smithay-egui.git?rev=6511552#65115521c756f356a7bcac8f1eeb715817a4666f" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6794c95b83518f9f91ae8c2faee52302d521c0d541d016b4ed632374041d9c42" dependencies = [ + "cgmath", "egui", "egui_extras", "egui_glow", "image", "log", + "memoffset", "smithay", "xkbcommon 0.8.0", ] @@ -5288,7 +5309,7 @@ version = "0.3.0+sdk-1.3.268.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", ] [[package]] @@ -6168,7 +6189,7 @@ version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "hashbrown 0.15.5", "indexmap 2.13.0", "semver", @@ -6208,7 +6229,7 @@ version = "0.31.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "645c7c96bb74690c3189b5c9cb4ca1627062bb23693a4fad9d8c3de958260144" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "rustix 1.1.4", "wayland-backend", "wayland-scanner", @@ -6220,7 +6241,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "cursor-icon", "wayland-backend", ] @@ -6252,7 +6273,7 @@ version = "0.32.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "wayland-backend", "wayland-client", "wayland-scanner", @@ -6265,7 +6286,7 @@ version = "20250721.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40a1f863128dcaaec790d7b4b396cc9b9a7a079e878e18c47e6c2d2c5a8dcbb1" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "wayland-backend", "wayland-client", "wayland-protocols", @@ -6278,7 +6299,7 @@ version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e9567599ef23e09b8dad6e429e5738d4509dfc46b3b21f32841a304d16b29c8" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "wayland-backend", "wayland-client", "wayland-protocols", @@ -6292,7 +6313,7 @@ version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa98634619300a535a9a97f338aed9a5ff1e01a461943e8346ff4ae26007306b" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "wayland-backend", "wayland-client", "wayland-protocols", @@ -6305,7 +6326,7 @@ version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "wayland-backend", "wayland-client", "wayland-protocols", @@ -6330,7 +6351,7 @@ version = "0.31.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc1846eb04c49182e04f4a099e2a830a2b745610bbc1d61246e206f29c7000a0" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "downcast-rs", "rustix 1.1.4", "wayland-backend", @@ -6382,7 +6403,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9cb534d5ffd109c7d1135f34cdae29e60eab94855a625dcfe1705f8bc7ad79f" dependencies = [ "arrayvec", - "bitflags 2.13.2", + "bitflags 2.13.1", "bytemuck", "cfg-if", "cfg_aliases", @@ -6414,7 +6435,7 @@ dependencies = [ "arrayvec", "bit-set", "bit-vec", - "bitflags 2.13.2", + "bitflags 2.13.1", "bytemuck", "cfg_aliases", "document-features", @@ -6474,7 +6495,7 @@ dependencies = [ "arrayvec", "ash", "bit-set", - "bitflags 2.13.2", + "bitflags 2.13.1", "block", "bytemuck", "cfg-if", @@ -6518,7 +6539,7 @@ version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e18308757e594ed2cd27dddbb16a139c42a683819d32a2e0b1b0167552f5840c" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "bytemuck", "js-sys", "log", @@ -7069,7 +7090,7 @@ checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" name = "winit" version = "0.31.0-beta.2" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "cfg_aliases", "cursor-icon", "dpi 0.1.2", @@ -7095,7 +7116,7 @@ version = "0.31.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2879d2854d1a43e48f67322d4bd097afcb6eb8f8f775c8de0260a71aea1df1aa" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "cfg_aliases", "cursor-icon", "dpi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7121,7 +7142,7 @@ name = "winit-android" version = "0.31.0-beta.2" dependencies = [ "android-activity", - "bitflags 2.13.2", + "bitflags 2.13.1", "dpi 0.1.2", "ndk", "raw-window-handle", @@ -7137,7 +7158,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d9c0d2cd93efec3a9f9ad819cfaf0834782403af7c0d248c784ec0c61761df" dependencies = [ "android-activity", - "bitflags 2.13.2", + "bitflags 2.13.1", "dpi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "ndk", "raw-window-handle", @@ -7150,7 +7171,7 @@ dependencies = [ name = "winit-appkit" version = "0.31.0-beta.2" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "block2 0.6.2", "dispatch2", "dpi 0.1.2", @@ -7173,7 +7194,7 @@ version = "0.31.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21310ca07851a49c348e0c2cc768e36b52ca65afda2c2354d78ed4b90074d8aa" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "block2 0.6.2", "dispatch2", "dpi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7223,7 +7244,7 @@ dependencies = [ name = "winit-core" version = "0.31.0-beta.2" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "cursor-icon", "dpi 0.1.2", "keyboard-types", @@ -7238,7 +7259,7 @@ version = "0.31.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4f0ccd7abb43740e2c6124ac7cae7d865ecec74eec63783e8922577ac232583" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "cursor-icon", "dpi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keyboard-types", @@ -7251,7 +7272,7 @@ dependencies = [ name = "winit-orbital" version = "0.31.0-beta.2" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "dpi 0.1.2", "libredox", "orbclient", @@ -7268,7 +7289,7 @@ version = "0.31.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51ea1fb262e7209f265f12bd0cc792c399b14355675e65531e9c8a87db287d46" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "dpi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "orbclient", "raw-window-handle", @@ -7282,7 +7303,7 @@ dependencies = [ name = "winit-uikit" version = "0.31.0-beta.2" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "block2 0.6.2", "dispatch2", "dpi 0.1.2", @@ -7303,7 +7324,7 @@ version = "0.31.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "680a356e798837d8eb274d4556e83bceaf81698194e31aafc5cfb8a9f2fab643" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "block2 0.6.2", "dispatch2", "dpi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7323,7 +7344,7 @@ name = "winit-wayland" version = "0.31.0-beta.2" dependencies = [ "ahash", - "bitflags 2.13.2", + "bitflags 2.13.1", "calloop", "cursor-icon", "dpi 0.1.2", @@ -7350,7 +7371,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce5afb2ba07da603f84b722c95f9f9396d2cedae3944fb6c0cda4a6f88de545" dependencies = [ "ahash", - "bitflags 2.13.2", + "bitflags 2.13.1", "calloop", "cursor-icon", "dpi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7374,7 +7395,7 @@ name = "winit-web" version = "0.31.0-beta.2" dependencies = [ "atomic-waker", - "bitflags 2.13.2", + "bitflags 2.13.1", "concurrent-queue", "cursor-icon", "dpi 0.1.2", @@ -7397,7 +7418,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c2490a953fb776fbbd5e295d54f1c3847f4f15b6c3929ec53c09acda6487a92" dependencies = [ "atomic-waker", - "bitflags 2.13.2", + "bitflags 2.13.1", "concurrent-queue", "cursor-icon", "dpi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7417,7 +7438,7 @@ dependencies = [ name = "winit-win32" version = "0.31.0-beta.2" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "cursor-icon", "dpi 0.1.2", "raw-window-handle", @@ -7434,7 +7455,7 @@ version = "0.31.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "644ea78af0e858aa3b092e5d1c67c41995a98220c81813f1353b28bc8bb91eaa" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "cursor-icon", "dpi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "raw-window-handle", @@ -7451,7 +7472,7 @@ version = "0.31.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa5b600756534c7041aa93cd0d244d44b09fca1b89e202bd1cd80dd9f3636c46" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "bytemuck", "calloop", "cursor-icon", @@ -7554,7 +7575,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" dependencies = [ "anyhow", - "bitflags 2.13.2", + "bitflags 2.13.1", "indexmap 2.13.0", "log", "serde", @@ -7684,7 +7705,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" dependencies = [ - "bitflags 2.13.2", + "bitflags 2.13.1", "dlib", "log", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 11001e83..145f1248 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -177,5 +177,4 @@ dnd = { path = "../window_clipboard/dnd" } mime = { path = "../window_clipboard/mime" } [patch.crates-io] -smithay = { git = "https://github.com/smithay/smithay.git", rev = "e3d461a" } -smithay-egui = { git = "https://github.com/Smithay/smithay-egui.git", rev = "6511552" } +smithay = { git = "https://github.com/smithay/smithay.git", rev = "5fb12b8" } diff --git a/cosmic-comp-config/src/lib.rs b/cosmic-comp-config/src/lib.rs index 510927f9..853ba447 100644 --- a/cosmic-comp-config/src/lib.rs +++ b/cosmic-comp-config/src/lib.rs @@ -66,13 +66,6 @@ impl Default for AppearanceConfig { } } -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] -pub enum DecorationPreference { - #[default] - ClientSide, - ServerSide, -} - #[derive(Clone, Debug, PartialEq, CosmicConfigEntry)] #[version = 1] pub struct CosmicCompConfig { @@ -111,7 +104,6 @@ pub struct CosmicCompConfig { /// Briefly magnify the cursor when the pointer is shaken, to help locate it pub cursor_shake_to_find: bool, pub activation_policy: ActivationPolicy, - pub decoration_preference: DecorationPreference, } impl Default for CosmicCompConfig { @@ -151,7 +143,6 @@ impl Default for CosmicCompConfig { cursor_hide_timeout: None, cursor_shake_to_find: true, activation_policy: ActivationPolicy::default(), - decoration_preference: DecorationPreference::default(), } } } diff --git a/resources/i18n/fil/cosmic_comp.ftl b/resources/i18n/fil/cosmic_comp.ftl deleted file mode 100644 index e69de29b..00000000 diff --git a/resources/i18n/oc/cosmic_comp.ftl b/resources/i18n/oc/cosmic_comp.ftl index a1238332..e69de29b 100644 --- a/resources/i18n/oc/cosmic_comp.ftl +++ b/resources/i18n/oc/cosmic_comp.ftl @@ -1,20 +0,0 @@ -a11y-zoom-move-continuously = La vista bolega de contunh amb lo ponchador -a11y-zoom-move-onedge = La lista bolega quand lo ponchador atenh un caire -a11y-zoom-move-centered = La vista bolega per gardar lo ponchador al centre -a11y-zoom-settings = Paramètres de la lópia... -unknown-keybinding = -window-menu-tiled = Fenèstras bandejanta -window-menu-screenshot = Prendre una captura d’ecran -window-menu-resize = Redimensionar -window-menu-move-prev-workspace = Desplaçar a l’espaci de trabalh precedent -window-menu-move-next-workspace = Desplaçar a l'espaci de trabalh seguent -window-menu-stack = Crear una pila de fenèstras -window-menu-unstack-all = Desapilar totas las fenèstras -window-menu-unstack = Desapilar la fenèstra -window-menu-sticky = Fenèstra adesiva -window-menu-close = Tampar -window-menu-close-all = Tampar totas las fenèstras -window-menu-resize-edge-top = Amont -window-menu-resize-edge-left = Esquèrra -window-menu-resize-edge-right = Drecha -window-menu-resize-edge-bottom = Aval diff --git a/src/backend/kms/device.rs b/src/backend/kms/device.rs index c58450bc..418a16f3 100644 --- a/src/backend/kms/device.rs +++ b/src/backend/kms/device.rs @@ -693,7 +693,7 @@ impl Device { ) .with_context(|| { format!( - "Failed to obtain file descriptor for drm device: {}", + "Failed to optain file descriptor for drm device: {}", path.display() ) })?, diff --git a/src/backend/kms/mod.rs b/src/backend/kms/mod.rs index 36c6407c..6da04aac 100644 --- a/src/backend/kms/mod.rs +++ b/src/backend/kms/mod.rs @@ -32,11 +32,7 @@ use smithay::{ calloop::{Dispatcher, EventLoop, LoopHandle}, drm::{ Device as _, - control::{ - Device as _, - connector::{Interface, State as ConnectorState}, - crtc, - }, + control::{Device as _, connector::Interface, crtc}, }, input::{self, Libinput}, wayland_protocols::wp::linux_dmabuf::zv1::server::zwp_linux_dmabuf_feedback_v1::TrancheFlags, @@ -254,18 +250,13 @@ fn determine_primary_gpu( // try to find builtin display for dev in drm_devices.values() { - let drm = dev.drm.device(); - let res_handles = drm.resource_handles()?; - let connectors = res_handles.connectors(); - if connectors.iter().any(|conn| { - let Ok(conn_info) = drm.get_connector(*conn, false) else { - return false; - }; - let i = conn_info.interface(); - conn_info.state() == ConnectorState::Connected - && (i == Interface::EmbeddedDisplayPort - || i == Interface::LVDS - || i == Interface::DSI) + if dev.inner.surfaces.values().any(|s| { + if let Ok(conn_info) = dev.drm.device().get_connector(s.connector, false) { + let i = conn_info.interface(); + i == Interface::EmbeddedDisplayPort || i == Interface::LVDS || i == Interface::DSI + } else { + false + } }) { return Ok(Some(dev.inner.render_node)); } diff --git a/src/backend/render/mod.rs b/src/backend/render/mod.rs index 9ad61588..b348640f 100644 --- a/src/backend/render/mod.rs +++ b/src/backend/render/mod.rs @@ -286,10 +286,10 @@ impl IndicatorShader { Uniform::new( "radius", [ - outer_radius[0] as f32, - outer_radius[1] as f32, - outer_radius[2] as f32, outer_radius[3] as f32, + outer_radius[1] as f32, + outer_radius[0] as f32, + outer_radius[2] as f32, ], ), Uniform::new("scale", scale as f32), @@ -899,7 +899,8 @@ where let geometry = geometry.to_local(output).as_logical(); let padded = with_states(layer.wl_surface(), |states| { - surface_padding(states).and_then(|padding| pad_rect(geometry, &padding)) + surface_padding(states, geometry.size) + .and_then(|padding| pad_rect(geometry, &padding)) }) .unwrap_or(geometry); let radii = with_states(layer.wl_surface(), |states| { diff --git a/src/backend/render/shadow.rs b/src/backend/render/shadow.rs index 87fdd2e3..37b1fdec 100644 --- a/src/backend/render/shadow.rs +++ b/src/backend/render/shadow.rs @@ -86,6 +86,12 @@ impl ShadowShader { let offset = [0., 5.]; let color = [0., 0., 0., if dark_mode { 0.45 } else { 0.35 }]; let radius = radius.map(|r| ceil(r as f64)); + let radius = [ + radius[3], // top_left + radius[1], // top_right + radius[0], // bottom_right + radius[2], // bottom_left + ]; let width = softness; let sigma = width / 2.; diff --git a/src/backend/render/wayland/blur_effect.rs b/src/backend/render/wayland/blur_effect.rs index b8a7935a..c4d27fac 100644 --- a/src/backend/render/wayland/blur_effect.rs +++ b/src/backend/render/wayland/blur_effect.rs @@ -247,10 +247,10 @@ impl BlurElement { Uniform::new( "corner_radius", [ - radii[0] as f32, - radii[1] as f32, - radii[2] as f32, radii[3] as f32, + radii[1] as f32, + radii[0] as f32, + radii[2] as f32, ], ), Uniform::new( diff --git a/src/backend/render/wayland/clipped_surface.rs b/src/backend/render/wayland/clipped_surface.rs index 52535269..8322079e 100644 --- a/src/backend/render/wayland/clipped_surface.rs +++ b/src/backend/render/wayland/clipped_surface.rs @@ -99,10 +99,10 @@ where Uniform::new( "corner_radius", [ - radius[0] as f32, - radius[1] as f32, - radius[2] as f32, radius[3] as f32, + radius[1] as f32, + radius[0] as f32, + radius[2] as f32, ], ), Uniform::new( @@ -145,10 +145,10 @@ where geo: Rectangle, radius: [u8; 4], ) -> [Rectangle; 4] { - let top_left = radius[0] as f64; + let top_left = radius[3] as f64; let top_right = radius[1] as f64; - let bottom_right = radius[2] as f64; - let bottom_left = radius[3] as f64; + let bottom_right = radius[0] as f64; + let bottom_left = radius[2] as f64; [ Rectangle::new(geo.loc, Size::from((top_left, top_left))), diff --git a/src/config/mod.rs b/src/config/mod.rs index f8a51585..93b53374 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -14,11 +14,8 @@ use cosmic_config::{ConfigGet, CosmicConfigEntry}; use cosmic_settings_config::window_rules::ApplicationException; use cosmic_settings_config::{Shortcuts, shortcuts, window_rules}; use serde::{Deserialize, Serialize}; +use smithay::utils::{Clock, Monotonic}; use smithay::wayland::xdg_activation::XdgActivationState; -use smithay::{ - backend::input::InputTime, - utils::{Clock, Monotonic}, -}; pub use smithay::{ backend::input::{self as smithay_input, KeyState}, input::keyboard::{Keysym, ModifiersState, keysyms as KeySyms}, @@ -49,8 +46,8 @@ mod types; use cosmic::config::CosmicTk; pub use cosmic_comp_config::EdidProduct; use cosmic_comp_config::{ - ActivationPolicy, AppearanceConfig, CosmicCompConfig, DecorationPreference, KeyboardConfig, - TileBehavior, XkbConfig, XwaylandDescaling, XwaylandEavesdropping, ZoomConfig, + ActivationPolicy, AppearanceConfig, CosmicCompConfig, KeyboardConfig, TileBehavior, XkbConfig, + XwaylandDescaling, XwaylandEavesdropping, ZoomConfig, input::{DeviceState as InputDeviceState, InputConfig, TouchpadOverride}, output::comp::{ OutputConfig, OutputInfo, OutputState, OutputsConfig, TransformDef, load_outputs, @@ -172,7 +169,7 @@ pub enum ColorFilter { } impl Config { - pub fn load(loop_handle: &LoopHandle<'_, State>, kiosk_mode: bool) -> Config { + pub fn load(loop_handle: &LoopHandle<'_, State>) -> Config { let config = cosmic_config::Config::new("com.system76.CosmicComp", 1).unwrap(); let source = cosmic_config::calloop::ConfigWatchSource::new(&config).unwrap(); loop_handle @@ -248,48 +245,40 @@ impl Config { // Source key bindings from com.system76.CosmicSettings.Shortcuts let settings_context = shortcuts::context().expect("Failed to load shortcuts config"); - let mut system_actions = Default::default(); - let mut shortcuts = Default::default(); - // Kiosk mode disables shortcuts - if !kiosk_mode { - system_actions = shortcuts::system_actions(&settings_context); - shortcuts = shortcuts::shortcuts(&settings_context); + let system_actions = shortcuts::system_actions(&settings_context); + let shortcuts = shortcuts::shortcuts(&settings_context); - // Listen for updates to the keybindings config. - match cosmic_config::calloop::ConfigWatchSource::new(&settings_context) { - Ok(source) => { - if let Err(err) = - loop_handle.insert_source(source, |(config, keys), (), state| { - for key in keys { - match key.as_str() { - // Reload the keyboard shortcuts config. - "custom" | "defaults" => { - state.common.config.shortcuts = - shortcuts::shortcuts(&config); - } - - "system_actions" => { - state.common.config.system_actions = - shortcuts::system_actions(&config); - } - - _ => (), - } + // Listen for updates to the keybindings config. + match cosmic_config::calloop::ConfigWatchSource::new(&settings_context) { + Ok(source) => { + if let Err(err) = loop_handle.insert_source(source, |(config, keys), (), state| { + for key in keys { + match key.as_str() { + // Reload the keyboard shortcuts config. + "custom" | "defaults" => { + state.common.config.shortcuts = shortcuts::shortcuts(&config); } - }) - { - warn!( - ?err, - "Failed to watch com.system76.CosmicSettings.Shortcuts config" - ); + + "system_actions" => { + state.common.config.system_actions = + shortcuts::system_actions(&config); + } + + _ => (), + } } + }) { + warn!( + ?err, + "Failed to watch com.system76.CosmicSettings.Shortcuts config" + ); } - Err(err) => warn!( - ?err, - "failed to create config watch source for com.system76.CosmicSettings.Shortcuts" - ), - }; - } + } + Err(err) => warn!( + ?err, + "failed to create config watch source for com.system76.CosmicSettings.Shortcuts" + ), + }; let window_rules_context = window_rules::context().expect("Failed to load window rules config"); @@ -549,13 +538,7 @@ impl Config { primary.config_mut().xwayland_primary = true; } } - // sort by connector name for a deterministic layout independent of hotplug order - let mut sorted_outputs = outputs - .iter() - .filter(|o| o.mirroring().is_none()) - .collect::>(); - sorted_outputs.sort_by_key(|o| o.name()); - for output in sorted_outputs { + for output in outputs.iter().filter(|o| o.mirroring().is_none()) { { let mut config = output.config_mut(); config.position = (w, 0); @@ -787,12 +770,13 @@ pub fn change_modifier_state( const X11_KEYCODE_OFFSET: u32 = 8; let mut input = |key_state, scan_code| { + let time = state.common.clock.now().as_millis(); let _ = keyboard.input( state, smithay_input::Keycode::new(scan_code + X11_KEYCODE_OFFSET), key_state, SERIAL_COUNTER.next_serial(), - InputTime::now(), + time, |_, _, _| smithay::input::keyboard::FilterResult::<()>::Forward, ); }; @@ -856,9 +840,7 @@ fn config_changed(config: cosmic_config::Config, keys: Vec, state: &mut } if !state.common.ei_seats.is_empty() { let seat = state.common.shell.read().seats.last_active().clone(); - if let Some(keyboard) = seat.get_keyboard() { - state.broadcast_ei_keyboard_modifiers(&keyboard); - } + state.broadcast_ei_keyboard_modifiers(&seat); } state.common.config.cosmic_conf.xkb_config = value; } @@ -1016,13 +998,6 @@ fn config_changed(config: cosmic_config::Config, keys: Vec, state: &mut state.common.config.cosmic_conf.activation_policy = new; } } - "decoration_preference" => { - let new = get_config::(&config, "decoration_preference"); - if new != state.common.config.cosmic_conf.decoration_preference { - state.common.config.cosmic_conf.decoration_preference = new; - state.update_decorations(); - } - } _ => {} } } diff --git a/src/input/actions.rs b/src/input/actions.rs index 8639ba62..8a5ef84c 100644 --- a/src/input/actions.rs +++ b/src/input/actions.rs @@ -18,7 +18,6 @@ use cosmic_config::ConfigSet; use cosmic_settings_config::shortcuts; use cosmic_settings_config::shortcuts::action::{Direction, FocusDirection}; use smithay::{ - backend::input::InputTime, input::{Seat, pointer::MotionEvent}, utils::{Point, Serial}, }; @@ -46,7 +45,7 @@ impl State { backend_id: &InputBackendId, seat: &Seat, serial: Serial, - time: InputTime, + time: u32, pattern: shortcuts::Binding, direction: Option, ) { @@ -151,7 +150,7 @@ impl State { backend_id: &InputBackendId, seat: &Seat, serial: Serial, - time: InputTime, + time: u32, pattern: shortcuts::Binding, direction: Option, propagate: bool, diff --git a/src/input/mod.rs b/src/input/mod.rs index af160ae2..0e307079 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -9,17 +9,14 @@ use crate::{ cosmic_modifiers_from_smithay, }, }, - input::{ - gestures::{GestureState, SwipeAction}, - tablet_emu::PointerEmulationGrab, - }, + input::gestures::{GestureState, SwipeAction}, shell::{ SeatExt, Trigger, focus::{ Stage, render_input_order, target::{KeyboardFocusTarget, PointerFocusTarget}, }, - grabs::{MenuGrab, MoveGrab, ReleaseMode, ResizeEdge, ResizeGrab}, + grabs::{ReleaseMode, ResizeEdge}, layout::{ floating::ResizeGrabMarker, tiling::{NodeDesc, SwapWindowGrab, TilingLayout}, @@ -45,21 +42,19 @@ use smithay::{ backend::input::{ AbsolutePositionEvent, Axis, AxisRelativeDirection, AxisSource, Device, DeviceCapability, GestureBeginEvent, GestureEndEvent, GesturePinchUpdateEvent as _, - GestureSwipeUpdateEvent as _, InputBackend, InputEvent, InputTime, KeyState, - PointerAxisEvent, ProximityState, TabletToolButtonEvent, TabletToolEvent, - TabletToolProximityEvent, TabletToolTipEvent, TabletToolTipState, TouchEvent, + GestureSwipeUpdateEvent as _, InputBackend, InputEvent, KeyState, PointerAxisEvent, + ProximityState, TabletToolButtonEvent, TabletToolEvent, TabletToolProximityEvent, + TabletToolTipEvent, TabletToolTipState, TouchEvent, }, - desktop::{WindowSurfaceType, utils::under_from_surface_tree}, + desktop::{PopupKeyboardGrab, WindowSurfaceType, utils::under_from_surface_tree}, input::{ Seat, - keyboard::KeyboardHandle, keyboard::{FilterResult, KeyboardSource, KeysymHandle, ModifiersState}, pointer::{ - AxisFrame, ButtonEvent as PointerButtonEvent, Focus, GestureHoldBeginEvent, - GestureHoldEndEvent, GesturePinchBeginEvent, GesturePinchEndEvent, - GesturePinchUpdateEvent, GestureSwipeBeginEvent, GestureSwipeEndEvent, - GestureSwipeUpdateEvent, MotionEvent as PointerMotionEvent, PointerGrab, PointerHandle, - RelativeMotionEvent, + AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent, + GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, + GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent, + PointerGrab, PointerHandle, RelativeMotionEvent, }, tablet::{TabletDescriptor, TabletSeatTrait, tool}, touch::{DownEvent, MotionEvent as TouchMotionEvent, UpEvent}, @@ -92,7 +87,6 @@ use std::{ pub mod actions; pub mod gestures; -pub mod tablet_emu; /// Identifies the input backend instance an event came from, used to disambiguate device ids /// (which are only unique within a single backend instance, see @@ -277,7 +271,7 @@ impl State { trace!(?keycode, ?state, "key"); let serial = SERIAL_COUNTER.next_serial(); - let time = Event::time(&event); + let time = Event::time_msec(&event); let keyboard = seat.get_keyboard().unwrap(); let previous_modifiers = keyboard.modifier_state(); if let Some((action, pattern)) = keyboard @@ -331,7 +325,7 @@ impl State { } InputEvent::PointerMotion { event, .. } => { - use smithay::backend::input::PointerMotionEvent as _; + use smithay::backend::input::PointerMotionEvent; let shell = self.common.shell.write(); if let Some(seat) = shell @@ -344,9 +338,6 @@ impl State { let current_output = seat.active_output(); if self.common.config.cosmic_conf.cursor_shake_to_find - && seat - .get_pointer() - .is_some_and(|pointer| !pointer.is_grabbed()) && let Some(cursor_state) = seat.user_data() .get::() @@ -406,7 +397,7 @@ impl State { &RelativeMotionEvent { delta: event.delta(), delta_unaccel: event.delta_unaccel(), - time: event.time(), + utime: event.time(), }, ); @@ -644,10 +635,10 @@ impl State { ptr.motion( self, under, - &PointerMotionEvent { + &MotionEvent { location: position.as_logical(), serial, - time: event.time(), + time: event.time_msec(), }, ); ptr.frame(self); @@ -759,33 +750,23 @@ impl State { ptr.motion( self, under, - &PointerMotionEvent { + &MotionEvent { location: position.as_logical(), serial, - time: event.time(), + time: event.time_msec(), }, ); ptr.frame(self); - let mut shell = self.common.shell.write(); // Keep the seat's active output following the pointer. Click-to- // focus (PointerButton) resolves its target via // `seat.active_output()` let previous_output = seat.active_output(); if previous_output != output { - for session in cursor_sessions_for_output(&shell, &previous_output) { - session.set_cursor_pos(None); - } seat.set_active_output(&output); } - shell.update_pointer_position(position.to_local(&output), &output); - shell.update_focal_point( - &seat, - position, - self.common.config.cosmic_conf.accessibility_zoom.view_moves, - ); - + let shell = self.common.shell.read(); update_output_image_copy_cursor_position( &shell, &self.common.clock, @@ -796,8 +777,9 @@ impl State { } } InputEvent::PointerButton { event, .. } => { - use smithay::backend::input::{ButtonState, PointerButtonEvent as _}; + use smithay::backend::input::{ButtonState, PointerButtonEvent}; + // let Some(seat) = self .common .shell @@ -871,7 +853,7 @@ impl State { && !shortcuts_inhibited { let seat_clone = seat.clone(); - let mouse_button = event.button(); + let mouse_button = PointerButtonEvent::button(&event); let mut supress_button = || { // If the logo is held then the pointer event is @@ -1023,7 +1005,7 @@ impl State { button, event.state(), serial, - event.time(), + event.time_msec(), ); } @@ -1031,16 +1013,16 @@ impl State { if pass_event { ptr.button( self, - &PointerButtonEvent { + &ButtonEvent { button, state: event.state(), serial, - time: event.time(), + time: event.time_msec(), }, ); ptr.frame(self); } else if event.state() == ButtonState::Released { - ptr.unset_grab(self, serial, event.time()) + ptr.unset_grab(self, serial, event.time_msec()) } } InputEvent::PointerAxis { event, .. } => { @@ -1091,7 +1073,7 @@ impl State { self.update_zoom(&seat, change, event.source() == AxisSource::Wheel); } } else { - let mut frame = AxisFrame::new(event.time()).source(event.source()); + let mut frame = AxisFrame::new(event.time_msec()).source(event.source()); let horizontal_amount = event .amount(Axis::Horizontal) .or_else(|| Some(event.amount_v120(Axis::Horizontal)? * 15.0 / 120.)); @@ -1160,7 +1142,7 @@ impl State { self, &GestureSwipeBeginEvent { serial, - time: event.time(), + time: event.time_msec(), fingers: event.fingers(), }, ); @@ -1181,7 +1163,7 @@ impl State { if let Some(ref mut gesture_state) = self.common.gesture_state { let first_update = gesture_state.update( event.delta(), - Duration::from_millis(event.time().millis() as u64), + Duration::from_millis(event.time_msec() as u64), ); // Decide on action if first update if first_update { @@ -1257,7 +1239,7 @@ impl State { pointer.gesture_swipe_update( self, &GestureSwipeUpdateEvent { - time: event.time(), + time: event.time_msec(), delta: event.delta(), }, ); @@ -1306,7 +1288,7 @@ impl State { self, &GestureSwipeEndEvent { serial, - time: event.time(), + time: event.time_msec(), cancelled: event.cancelled(), }, ); @@ -1329,7 +1311,7 @@ impl State { self, &GesturePinchBeginEvent { serial, - time: event.time(), + time: event.time_msec(), fingers: event.fingers(), }, ); @@ -1349,7 +1331,7 @@ impl State { pointer.gesture_pinch_update( self, &GesturePinchUpdateEvent { - time: event.time(), + time: event.time_msec(), delta: event.delta(), scale: event.scale(), rotation: event.rotation(), @@ -1373,7 +1355,7 @@ impl State { self, &GesturePinchEndEvent { serial, - time: event.time(), + time: event.time_msec(), cancelled: event.cancelled(), }, ); @@ -1395,7 +1377,7 @@ impl State { self, &GestureHoldBeginEvent { serial, - time: event.time(), + time: event.time_msec(), fingers: event.fingers(), }, ); @@ -1417,7 +1399,7 @@ impl State { self, &GestureHoldEndEvent { serial, - time: event.time(), + time: event.time_msec(), cancelled: event.cancelled(), }, ); @@ -1474,7 +1456,7 @@ impl State { slot: event.slot(), location: position.as_logical(), serial, - time: event.time(), + time: event.time_msec(), }, ); } @@ -1523,7 +1505,7 @@ impl State { &TouchMotionEvent { slot: event.slot(), location: position.as_logical(), - time: event.time(), + time: event.time_msec(), }, ); } @@ -1549,7 +1531,7 @@ impl State { self, &UpEvent { slot: event.slot(), - time: event.time(), + time: event.time_msec(), serial, }, ); @@ -1600,7 +1582,6 @@ impl State { return; }; - let current_output = seat.active_output(); let position = transform_output_mapped_position(&output, &event, shell.zoom_state()); let under = State::surface_under(position, &output, &shell) @@ -1609,33 +1590,21 @@ impl State { std::mem::drop(shell); let pointer = seat.get_pointer().unwrap(); - pointer.set_location(position.as_logical()); + pointer.motion( + self, + under.clone(), + &MotionEvent { + location: position.as_logical(), + serial: SERIAL_COUNTER.next_serial(), + time: self.common.clock.now().as_millis(), + }, + ); let tablet_seat = seat.tablet_seat(); let tool = tablet_seat.get_tool(&event.tool()); if let Some(tool) = tool { - let serial = SERIAL_COUNTER.next_serial(); - if !tool.is_grabbed() - && under - .as_ref() - .is_some_and(|(target, _)| !target.supports_tool(&tool)) - { - let start_data = tool::GrabStartData { - focus: under.clone(), - trigger: tool::GrabTrigger::Proximity, - location: position.as_logical(), - }; - tool.set_grab( - self, - PointerEmulationGrab::new(start_data, seat.clone()), - event.time(), - serial, - Focus::Keep, - ); - } - let frame = tool::AxisFrame { pressure: event.pressure_has_changed().then(|| event.pressure()), distance: event.distance_has_changed().then(|| event.distance()), @@ -1653,39 +1622,17 @@ impl State { tool.motion( self, - under, + under + .and_then(|(f, loc)| f.wl_surface().map(|s| (s.into_owned(), loc))), &tool::MotionEvent { location: position.as_logical(), - serial, - time: event.time(), + serial: SERIAL_COUNTER.next_serial(), + time: event.time_msec(), }, ); - tool.frame(self, event.time()); + tool.frame(self, event.time_msec()); } - - let mut shell = self.common.shell.write(); - shell.update_pointer_position(position.to_local(&output), &output); - shell.update_focal_point( - &seat, - position, - self.common.config.cosmic_conf.accessibility_zoom.view_moves, - ); - - if output != current_output { - for session in cursor_sessions_for_output(&shell, ¤t_output) { - session.set_cursor_pos(None); - } - seat.set_active_output(&output); - } - - update_output_image_copy_cursor_position( - &shell, - &self.common.clock, - &output, - &seat, - position, - ); } } InputEvent::TabletToolProximity { event, .. } => { @@ -1704,7 +1651,6 @@ impl State { return; }; - let current_output = seat.active_output(); let position = transform_output_mapped_position(&output, &event, shell.zoom_state()); let under = State::surface_under(position, &output, &shell) @@ -1713,7 +1659,15 @@ impl State { std::mem::drop(shell); let pointer = seat.get_pointer().unwrap(); - pointer.set_location(position.as_logical()); + pointer.motion( + self, + under.clone(), + &MotionEvent { + location: position.as_logical(), + serial: SERIAL_COUNTER.next_serial(), + time: self.common.clock.now().as_millis(), + }, + ); let tablet_seat = seat.tablet_seat(); @@ -1726,25 +1680,6 @@ impl State { if let Some(tablet) = tablet { let serial = SERIAL_COUNTER.next_serial(); - if !tool.is_grabbed() - && under - .as_ref() - .is_some_and(|(target, _)| !target.supports_tool(&tool)) - { - let start_data = tool::GrabStartData { - focus: under.clone(), - trigger: tool::GrabTrigger::Proximity, - location: position.as_logical(), - }; - tool.set_grab( - self, - PointerEmulationGrab::new(start_data, seat.clone()), - event.time(), - serial, - Focus::Keep, - ); - } - let frame = tool::AxisFrame { pressure: event.pressure_has_changed().then(|| event.pressure()), distance: event.distance_has_changed().then(|| event.distance()), @@ -1760,6 +1695,9 @@ impl State { match event.state() { ProximityState::In => { + let under = under.and_then(|(f, loc)| { + f.wl_surface().map(|s| (s.into_owned(), loc)) + }); tool.proximity_in( self, under, @@ -1767,75 +1705,25 @@ impl State { &tool::ProximityInEvent { location: position.as_logical(), axis: Some(frame), - serial, - time: event.time(), + serial: SERIAL_COUNTER.next_serial(), + time: event.time_msec(), }, - ); - } - ProximityState::Out => { - tool.proximity_out( - self, - &tool::ProximityOutEvent { - serial, - time: event.time(), - }, - ); - if let Some(pointer) = seat.get_pointer() { - pointer.motion( - self, - None, - &PointerMotionEvent { - location: position.as_logical(), - serial, - time: event.time(), - }, - ); - } + ) } + ProximityState::Out => tool.proximity_out( + self, + &tool::ProximityOutEvent { + serial, + time: event.time_msec(), + }, + ), } - tool.frame(self, event.time()); - } - - if event.state() == ProximityState::In { - let mut shell = self.common.shell.write(); - shell.update_pointer_position(position.to_local(&output), &output); - shell.update_focal_point( - &seat, - position, - self.common.config.cosmic_conf.accessibility_zoom.view_moves, - ); - - if output != current_output { - for session in cursor_sessions_for_output(&shell, ¤t_output) { - session.set_cursor_pos(None); - } - seat.set_active_output(&output); - } - - update_output_image_copy_cursor_position( - &shell, - &self.common.clock, - &output, - &seat, - position, - ); + tool.frame(self, event.time_msec()); } } } InputEvent::TabletToolTip { event, .. } => { - { - let mut shell = self.common.shell.write(); - if let Some(Trigger::Tool(desc, trigger)) = - shell.overview_mode().0.active_trigger() - && event.tool() == *desc - && matches!(*trigger, tool::GrabTrigger::Tip) - && event.tip_state() == TabletToolTipState::Up - { - shell.set_overview_mode(None, self.common.event_loop_handle.clone()); - } - } - let maybe_seat = self .common .shell @@ -1846,21 +1734,6 @@ impl State { if let Some(seat) = maybe_seat { self.common.idle_notifier_state.notify_activity(&seat); notify_cursor_activity(self, &seat); - - let serial = SERIAL_COUNTER.next_serial(); - let output = seat.active_output(); - let shell = self.common.shell.write(); - let position = - transform_output_mapped_position(&output, &event, shell.zoom_state()); - let under = State::element_under(position, &output, &shell, &seat); - drop(shell); - - if event.tip_state() == TabletToolTipState::Down - && let Some(target) = under.as_ref() - { - Shell::set_focus(self, Some(target), &seat, Some(serial), false); - } - if let Some(tool) = seat.tablet_seat().get_tool(&event.tool()) { let serial = SERIAL_COUNTER.next_serial(); match event.tip_state() { @@ -1869,7 +1742,7 @@ impl State { self, &tool::DownEvent { serial, - time: event.time(), + time: event.time_msec(), }, ); } @@ -1878,13 +1751,13 @@ impl State { self, &tool::UpEvent { serial, - time: event.time(), + time: event.time_msec(), }, ); } } - tool.frame(self, event.time()); + tool.frame(self, event.time_msec()); } } } @@ -1906,11 +1779,11 @@ impl State { button: event.button(), state: event.button_state(), serial: SERIAL_COUNTER.next_serial(), - time: event.time(), + time: event.time_msec(), }, ); - tool.frame(self, event.time()); + tool.frame(self, event.time_msec()); } } } @@ -2013,7 +1886,7 @@ impl State { let Some(pointer) = seat.get_pointer() else { return; }; - let time = InputTime::now(); + let time = self.common.clock.now().as_millis(); for button in buttons { let serial = SERIAL_COUNTER.next_serial(); pointer.button( @@ -2031,7 +1904,13 @@ impl State { /// Mirror the seat's current modifier state to every libei sender with a keyboard via /// `ei_keyboard.modifiers` - pub(crate) fn broadcast_ei_keyboard_modifiers(&self, keyboard: &KeyboardHandle) { + pub(crate) fn broadcast_ei_keyboard_modifiers(&self, seat: &Seat) { + if self.common.ei_seats.is_empty() { + return; + } + let Some(keyboard) = seat.get_keyboard() else { + return; + }; let s = keyboard.modifier_state().serialized; for ei_seat in self.common.ei_seats.values() { ei_seat.keyboard_modifiers(s.depressed, s.locked, s.latched, s.layout_effective); @@ -2069,14 +1948,14 @@ impl State { modifiers: &ModifiersState, handle: KeysymHandle<'_>, serial: Serial, - time: InputTime, + time: u32, keycode: Keycode, key_state: KeyState, previous_modifiers: ModifiersState, ) -> FilterResult> { if previous_modifiers != *modifiers { seat.set_last_modifier_change(backend_id, serial); - self.broadcast_ei_keyboard_modifiers(&seat.get_keyboard().unwrap()); + self.broadcast_ei_keyboard_modifiers(seat); } let current_focus = seat.get_keyboard().unwrap().current_focus(); @@ -2096,21 +1975,6 @@ impl State { backend_id, seat, modifiers, handle, serial, keycode, key_state, time, ); - // A modifier-only binding fires on the modifier's release, but its press was already - // forwarded. Forward the release too. - if key_state == KeyState::Released - && matches!(&result, FilterResult::Intercept(Some((_, binding))) if binding.key.is_none()) - { - seat.get_keyboard().unwrap().input_forward( - self, - keycode, - key_state, - serial, - time, - previous_modifiers != *modifiers, - ); - } - if (matches!(result, FilterResult::Forward) && !seat.get_keyboard().unwrap().is_grabbed() && !shortcuts_inhibited @@ -2144,7 +2008,7 @@ impl State { return; }; let serial = SERIAL_COUNTER.next_serial(); - let time = InputTime::now(); + let time = self.common.clock.now().as_millis(); let previous_modifiers = keyboard.modifier_state(); let result = keyboard .input_from_source( @@ -2293,7 +2157,7 @@ impl State { serial: Serial, keycode: Keycode, key_state: KeyState, - time: InputTime, + time: u32, ) -> FilterResult> { // Pre-compute for layout-agnostic shortcut matching let raw_syms = handle.raw_syms(); @@ -2306,15 +2170,17 @@ impl State { let keyboard = seat.get_keyboard().unwrap(); let pointer = seat.get_pointer().unwrap(); - // Escape only cancels grabs the compositor started for its own interactions - // For keyboard: SwapWindowGrab - // For pointer: MoveGrab, ResizeGrab, and MenuGrab - let keyboard_grabbed = - keyboard.with_grab(|_serial, grab| grab.is::()) == Some(true); - let pointer_grabbed = pointer.with_grab(|_serial, grab| { - grab.is::() || grab.is::() || grab.is::() + // We're only interested in filtering keyboard grabs if we initiated them. + // The easiest way to check that is to check the type of the grab. + let keyboard_grabbed = keyboard.with_grab(|_serial, grab| { + grab.is::() || grab.is::>() }) == Some(true); - let is_grabbed = keyboard_grabbed || pointer_grabbed; + // A virtual-keyboard key can arrive while the seat's pointer is grabbed by that + // same on-screen keyboard's own button press (the implicit grab from clicking an OSK + // key). That pointer grab must not capture the injected key, otherwise e.g. + // pressing esc on a virtual keyboard gets swallowed here + let from_vk = matches!(backend_id, InputBackendId::VirtualKeyboard); + let is_grabbed = keyboard_grabbed || (pointer.is_grabbed() && !from_vk); let current_focus = keyboard.current_focus(); //this should fall back to active output since there may not be a focused output @@ -2456,9 +2322,7 @@ impl State { &backend_id_clone, &seat_clone, serial, - InputTime::from_millis( - time.millis().overflowing_add(duration as u32).0, - ), + time.overflowing_add(duration as u32).0, key_pattern_clone.clone(), None, ); @@ -2510,7 +2374,7 @@ impl State { self.common.event_loop_handle.insert_idle(move |state| { if let Some(keyboard) = seat.get_keyboard() { let serial = SERIAL_COUNTER.next_serial(); - let time = InputTime::now(); + let time = state.common.clock.now().as_millis(); keyboard.input( state, key_code, @@ -3036,7 +2900,6 @@ impl State { surface: &WlSurface, pointer: &PointerHandle, mut location: Point, - constraint: Option<&PointerConstraint>, ) { let Some(client) = surface.client() else { return; @@ -3061,13 +2924,15 @@ impl State { return false; } - if let Some(constraint) = constraint - && let Some(region) = constraint.region() - { - let point_in_surface = (p - surface_offset.to_f64()).to_i32_floor(); - return region.contains(point_in_surface); - } - true + with_pointer_constraint(surface, pointer, |constraint| { + if let Some(constraint) = constraint + && let Some(region) = constraint.region() + { + let point_in_surface = (p - surface_offset.to_f64()).to_i32_floor(); + return region.contains(point_in_surface); + } + true + }) }; let workspace_origin = output.geometry().loc.to_f64(); @@ -3091,23 +2956,23 @@ impl State { let serial = SERIAL_COUNTER.next_serial(); let under = State::surface_under(point, &output, &self.common.shell.write()) .map(|(target, pos)| (target, pos.as_logical())); - let time = InputTime::now(); + let time = self.common.clock.now(); pointer.relative_motion( self, under.clone(), &RelativeMotionEvent { delta: (0., 0.).into(), delta_unaccel: (0., 0.).into(), - time, + utime: time.as_micros(), }, ); pointer.motion( self, under, - &PointerMotionEvent { + &MotionEvent { location: point.as_logical(), serial, - time, + time: time.as_millis(), }, ); pointer.frame(self); diff --git a/src/input/tablet_emu.rs b/src/input/tablet_emu.rs deleted file mode 100644 index 6ab17924..00000000 --- a/src/input/tablet_emu.rs +++ /dev/null @@ -1,256 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-only - -//! Pointer Emulating TabletTool grab. - -use crate::{shell::focus::target::PointerFocusTarget, state::State}; -use smithay::{ - backend::input::{ButtonState, InputTime, MouseButton}, - input::{ - Seat, pointer, - tablet::{ - self, - tool::{ - AxisFrame, ButtonEvent, DownEvent, GrabStartData, ProximityInEvent, - ProximityOutEvent, TabletToolGrab, TabletToolInnerHandle, UpEvent, - }, - }, - }, - utils::{Logical, Point, SERIAL_COUNTER}, -}; - -// from https://gitlab.freedesktop.org/libinput/libinput/-/blob/main/include/linux/linux/input-event-codes.h -const BTN_STYLUS: u32 = 0x14b; -const BTN_STYLUS_2: u32 = 0x14c; -const BTN_LEFT: u32 = 0x110; -const BTN_RIGHT: u32 = 0x111; -const BTN_MIDDLE: u32 = 0x112; -const BTN_FORWARD: u32 = 0x115; -const BTN_BACK: u32 = 0x116; - -pub struct PointerEmulationGrab { - start_data: GrabStartData, - seat: Seat, - - above_source: bool, - tip_down: bool, - button_down: Vec, -} - -impl PointerEmulationGrab { - pub fn new(start_data: GrabStartData, seat: Seat) -> Self { - Self { - start_data, - seat, - - above_source: true, - tip_down: false, - button_down: Vec::new(), - } - } - - fn button_to_mouse(&self, button: u32) -> Option { - // FIXME: This should be configurable. - if button == BTN_STYLUS { - Some(MouseButton::Right) - } else if button == BTN_STYLUS_2 { - Some(MouseButton::Middle) - } else { - None - } - } - - fn pointer_button(&self, data: &mut State, button: MouseButton, state: ButtonState) { - if let Some(pointer) = self.seat.get_pointer() { - let button = match button { - MouseButton::Left => BTN_LEFT, - MouseButton::Right => BTN_RIGHT, - MouseButton::Middle => BTN_MIDDLE, - MouseButton::Back => BTN_BACK, - MouseButton::Forward => BTN_FORWARD, - _ => return, - }; - - pointer.button( - data, - &pointer::ButtonEvent { - serial: SERIAL_COUNTER.next_serial(), - button, - state, - time: InputTime::now(), - }, - ); - - pointer.frame(data); - } - } -} - -type Type = tablet::tool::MotionEvent; - -impl TabletToolGrab for PointerEmulationGrab { - fn proximity_in( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - focus: Option<(PointerFocusTarget, Point)>, - event: &ProximityInEvent, - ) { - handle.proximity_in(data, focus.clone(), event); - - if !self.above_source && !self.tip_down && self.button_down.is_empty() { - handle.unset_grab( - self, - data, - SERIAL_COUNTER.next_serial(), - InputTime::now(), - true, - ); - } else if let Some(pointer) = self.seat.get_pointer() { - pointer.motion( - data, - focus, - &pointer::MotionEvent { - location: event.location, - serial: SERIAL_COUNTER.next_serial(), - time: InputTime::now(), - }, - ); - pointer.frame(data); - } - } - - fn proximity_out( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &ProximityOutEvent, - ) { - handle.proximity_out(data, event); - - handle.unset_grab(self, data, event.serial, event.time, true); - } - - fn down( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &DownEvent, - ) { - handle.down(data, event); - self.tip_down = true; - - self.pointer_button(data, MouseButton::Left, ButtonState::Pressed); - } - - fn up( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &UpEvent, - ) { - handle.up(data, event); - - self.pointer_button(data, MouseButton::Left, ButtonState::Released); - self.tip_down = false; - - if !self.above_source && !self.tip_down && self.button_down.is_empty() { - handle.unset_grab(self, data, event.serial, event.time, true); - } - } - - fn motion( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - focus: Option<(PointerFocusTarget, Point)>, - event: &Type, - ) { - self.above_source = focus.as_ref().map(|(target, _)| target) - == self.start_data.focus.as_ref().map(|(target, _)| target); - handle.motion(data, self.start_data.focus.clone(), event); - - if !self.above_source && !self.tip_down && self.button_down.is_empty() { - handle.unset_grab( - self, - data, - SERIAL_COUNTER.next_serial(), - InputTime::now(), - true, - ); - } else if let Some(pointer) = self.seat.get_pointer() { - pointer.motion( - data, - focus, - &pointer::MotionEvent { - location: event.location, - serial: SERIAL_COUNTER.next_serial(), - time: InputTime::now(), - }, - ); - pointer.frame(data); - } - } - - fn button( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &ButtonEvent, - ) { - handle.button(data, event); - - self.button_down.retain(|b| b != &event.button); - if matches!(event.state, ButtonState::Pressed) { - self.button_down.push(event.button); - } - - if let Some(button) = self.button_to_mouse(event.button) { - self.pointer_button(data, button, event.state); - } - - if !self.above_source && !self.tip_down && self.button_down.is_empty() { - handle.unset_grab( - self, - data, - SERIAL_COUNTER.next_serial(), - InputTime::now(), - true, - ); - } - } - - fn axis( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - frame: AxisFrame, - ) { - handle.axis(data, frame); - } - - fn frame( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - time: InputTime, - ) { - handle.frame(data, time); - } - - fn unset(&mut self, data: &mut State) { - if self.tip_down { - self.pointer_button(data, MouseButton::Left, ButtonState::Released); - } - - let buttons = std::mem::take(&mut self.button_down); - for button in buttons.into_iter() { - if let Some(button) = self.button_to_mouse(button) { - self.pointer_button(data, button, ButtonState::Released); - } - } - } - - fn start_data(&self) -> &GrabStartData { - &self.start_data - } -} diff --git a/src/lib.rs b/src/lib.rs index 98bfa2a3..aa31a464 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -289,7 +289,7 @@ Project home page: https://github.com/pop-os/cosmic-comp Options: -h, --help Show this message --no-xwayland Run without Xwayland - -V, --version Show the version of cosmic-comp"# + -v, --version Show the version of cosmic-comp"# ); } diff --git a/src/libei.rs b/src/libei.rs index 487f0387..ad3a674d 100644 --- a/src/libei.rs +++ b/src/libei.rs @@ -124,9 +124,7 @@ pub fn setup_ei( data.update_ei_input_method(); // Notify the remaining libei clients of the now-cleared modifier state let seat = data.common.shell.read().seats.last_active().clone(); - if let Some(keyboard) = seat.get_keyboard() { - data.broadcast_ei_keyboard_modifiers(&keyboard); - } + data.broadcast_ei_keyboard_modifiers(&seat); } EiInputEvent::Event(event) => { use smithay::backend::input::{InputEvent, KeyboardKeyEvent}; diff --git a/src/shell/element/mod.rs b/src/shell/element/mod.rs index d4743b7f..14736719 100644 --- a/src/shell/element/mod.rs +++ b/src/shell/element/mod.rs @@ -12,7 +12,7 @@ use id_tree::NodeId; use smithay::{ backend::{ drm::DrmNode, - input::{InputTime, KeyState}, + input::KeyState, renderer::{ element::{ Element, Kind, RenderElement, UnderlyingStorage, @@ -1012,7 +1012,7 @@ impl KeyboardTarget for CosmicMapped { key: KeysymHandle<'_>, state: KeyState, serial: Serial, - time: InputTime, + time: u32, ) { match &self.element { CosmicMappedInternal::Stack(s) => { diff --git a/src/shell/element/stack.rs b/src/shell/element/stack.rs index 7f7f6317..7ce26204 100644 --- a/src/shell/element/stack.rs +++ b/src/shell/element/stack.rs @@ -11,7 +11,7 @@ use crate::{ shell::{ element::{CosmicMappedKey, CosmicMappedKeyInner}, focus::target::PointerFocusTarget, - grabs::{GrabType, ReleaseMode, ResizeEdge}, + grabs::{ReleaseMode, ResizeEdge}, layout::tiling::NodeDesc, }, state::State, @@ -38,7 +38,7 @@ use shortcuts::action::{Direction, FocusDirection}; use smithay::{ backend::{ drm::DrmNode, - input::{InputTime, KeyState, TabletToolDescriptor}, + input::KeyState, renderer::{ ImportAll, ImportMem, Renderer, element::{Element, Id as RendererId, Kind, RenderElement, UnderlyingStorage}, @@ -52,23 +52,14 @@ use smithay::{ Seat, keyboard::{KeyboardTarget, KeysymHandle, ModifiersState}, pointer::{ - AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, CursorImageStatus, - GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, - GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, - GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent as PointerMotionEvent, + AxisFrame, ButtonEvent, CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent, + GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, + GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent, PointerTarget, RelativeMotionEvent, }, - tablet::{ - Tablet, TabletSeatTrait, - tool::{ - AxisFrame as ToolAxisFrame, ButtonEvent as ToolButtonEvent, - DownEvent as ToolDownEvent, MotionEvent as ToolMotionEvent, TabletToolTarget, - UpEvent as ToolUpEvent, - }, - }, touch::{ - DownEvent as TouchDownEvent, FrameMarker, MotionEvent as TouchMotionEvent, - OrientationEvent, ShapeEvent, TouchTarget, UpEvent as TouchUpEvent, + DownEvent, FrameMarker, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, + TouchTarget, UpEvent, }, }, output::Output, @@ -121,7 +112,6 @@ pub struct CosmicStackInternal { previous_keyboard: AtomicUsize, pointer_entered: AtomicU8, touch_serial: AtomicU32, - tablet_serial: AtomicU32, reenter: AtomicBool, potential_drag: Mutex>, override_alive: AtomicBool, @@ -181,7 +171,6 @@ impl CosmicStack { previous_keyboard: AtomicUsize::new(0), pointer_entered: AtomicU8::new(0), touch_serial: AtomicU32::new(0), - tablet_serial: AtomicU32::new(0), reenter: AtomicBool::new(false), potential_drag: Mutex::new(None), override_alive: AtomicBool::new(true), @@ -842,7 +831,7 @@ impl CosmicStack { ))); }; - let radii = radii.map(|[_, _, c, d]| [0, 0, c, d]); + let radii = radii.map(|[a, _, c, _]| [a, 0, c, 0]); windows[active].push_render_elements( renderer, window_loc, @@ -920,19 +909,12 @@ impl CosmicStack { false, ); if let Some((grab, focus)) = res { - match grab.grab_type() { - GrabType::Touch => { - seat.get_touch().unwrap().set_grab(state, grab, serial) - } - GrabType::Pointer => seat - .get_pointer() + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab(state, grab, serial); + } else { + seat.get_pointer() .unwrap() - .set_grab(state, grab, serial, focus), - GrabType::TabletTool => seat - .tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab(state, grab, InputTime::now(), serial, focus), + .set_grab(state, grab, serial, focus); } } }); @@ -1015,17 +997,17 @@ impl CosmicStack { .corner_radius(geometry_size) .unwrap_or([default_radius; 4]); - corners[0] = 0; corners[1] = 0; + corners[3] = 0; corners } else { let mut corners = active_window.corner_radius(geometry_size).unwrap_or(radii); - corners[0] = radii[0]; + corners[0] = radii[0].max(corners[0]); corners[1] = radii[1]; corners[2] = radii[2].max(corners[2]); - corners[3] = radii[3].max(corners[3]); + corners[3] = radii[3]; corners } @@ -1107,19 +1089,12 @@ impl Program for CosmicStackInternal { false, ); if let Some((grab, focus)) = res { - match grab.grab_type() { - GrabType::Touch => { - seat.get_touch().unwrap().set_grab(state, grab, serial) - } - GrabType::Pointer => seat - .get_pointer() + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab(state, grab, serial); + } else { + seat.get_pointer() .unwrap() - .set_grab(state, grab, serial, focus), - GrabType::TabletTool => seat - .tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab(state, grab, InputTime::now(), serial, focus), + .set_grab(state, grab, serial, focus); } } }); @@ -1572,7 +1547,7 @@ impl KeyboardTarget for CosmicStack { key: KeysymHandle<'_>, state: KeyState, serial: Serial, - time: InputTime, + time: u32, ) { let active = self.keyboard_leave_if_previous(seat, data, serial); self.0.with_program(|p| { @@ -1612,7 +1587,7 @@ impl KeyboardTarget for CosmicStack { } impl PointerTarget for CosmicStack { - fn enter(&self, seat: &Seat, data: &mut State, event: &PointerMotionEvent) { + fn enter(&self, seat: &Seat, data: &mut State, event: &MotionEvent) { let mut event = event.clone(); self.0.with_program(|p| { let active_window = &p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)]; @@ -1640,7 +1615,7 @@ impl PointerTarget for CosmicStack { PointerTarget::enter(&self.0, seat, data, &event) } - fn motion(&self, seat: &Seat, data: &mut State, event: &PointerMotionEvent) { + fn motion(&self, seat: &Seat, data: &mut State, event: &MotionEvent) { let mut event = event.clone(); self.0.with_program(|p| { let active = p.active.load(Ordering::SeqCst); @@ -1683,7 +1658,7 @@ impl PointerTarget for CosmicStack { ) { } - fn button(&self, seat: &Seat, data: &mut State, event: &PointerButtonEvent) { + fn button(&self, seat: &Seat, data: &mut State, event: &ButtonEvent) { match self.0.with_program(|p| p.current_focus()) { Some(Focus::Header) => PointerTarget::button(&self.0, seat, data, event), Some(x) => { @@ -1714,12 +1689,14 @@ impl PointerTarget for CosmicStack { state.common.config.cosmic_conf.edge_snap_threshold, false, ); - if let Some((grab, focus)) = res - && let GrabType::Pointer = grab.grab_type() - { - seat.get_pointer() - .unwrap() - .set_grab(state, grab, serial, focus); + if let Some((grab, focus)) = res { + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab(state, grab, serial); + } else { + seat.get_pointer() + .unwrap() + .set_grab(state, grab, serial, focus); + } } }); } @@ -1727,7 +1704,7 @@ impl PointerTarget for CosmicStack { } } - fn axis(&self, seat: &Seat, data: &mut State, frame: PointerAxisFrame) { + fn axis(&self, seat: &Seat, data: &mut State, frame: AxisFrame) { if let Some(Focus::Header) = self.0.with_program(|p| p.current_focus()) { PointerTarget::axis(&self.0, seat, data, frame) } @@ -1739,7 +1716,7 @@ impl PointerTarget for CosmicStack { } } - fn leave(&self, seat: &Seat, data: &mut State, serial: Serial, time: InputTime) { + fn leave(&self, seat: &Seat, data: &mut State, serial: Serial, time: u32) { self.0.with_program(|p| { let mut cursor_state = seat .user_data() @@ -1775,12 +1752,14 @@ impl PointerTarget for CosmicStack { &state.common.event_loop_handle, false, ); - if let Some((grab, focus)) = res - && let GrabType::Pointer = grab.grab_type() - { - seat.get_pointer() - .unwrap() - .set_grab(state, grab, serial, focus); + if let Some((grab, focus)) = res { + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab(state, grab, serial); + } else { + seat.get_pointer() + .unwrap() + .set_grab(state, grab, serial, focus); + } } }); } @@ -1853,7 +1832,7 @@ impl PointerTarget for CosmicStack { } impl TouchTarget for CosmicStack { - fn down(&self, seat: &Seat, data: &mut State, event: &TouchDownEvent) { + fn down(&self, seat: &Seat, data: &mut State, event: &DownEvent) { let mut event = event.clone(); let active_window_geo = self.0.with_program(|p| { p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)].geometry() @@ -1864,7 +1843,7 @@ impl TouchTarget for CosmicStack { TouchTarget::down(&self.0, seat, data, &event) } - fn up(&self, seat: &Seat, data: &mut State, event: &TouchUpEvent) { + fn up(&self, seat: &Seat, data: &mut State, event: &UpEvent) { TouchTarget::up(&self.0, seat, data, event) } @@ -1912,185 +1891,6 @@ impl TouchTarget for CosmicStack { } } -impl TabletToolTarget for CosmicStack { - fn proximity_in( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - tablet: &Tablet, - serial: Serial, - ) { - TabletToolTarget::proximity_in(&self.0, seat, data, tool_descriptor, tablet, serial) - } - - fn proximity_out( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - ) { - self.0.with_program(|p| { - let mut cursor_state = seat - .user_data() - .get::() - .unwrap() - .lock() - .unwrap(); - cursor_state.unset_shape(); - let _previous = p.swap_focus(None); - }); - TabletToolTarget::proximity_out(&self.0, seat, data, tool_descriptor); - } - - fn down( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &ToolDownEvent, - ) { - self.0.with_program(|p| { - p.tablet_serial - .store(event.serial.into(), Ordering::Release) - }); - match self.0.with_program(|p| p.current_focus()) { - Some(Focus::Header) => { - TabletToolTarget::down(&self.0, seat, data, tool_descriptor, event) - } - Some(x) => { - let serial = self - .0 - .with_program(|p| p.tablet_serial.load(Ordering::Acquire)) - .into(); - let seat = seat.clone(); - let Some(surface) = self.0.with_program(|p| { - let window = &p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)]; - window.wl_surface().map(Cow::into_owned) - }) else { - return; - }; - self.0.loop_handle().insert_idle(move |state| { - let res = state.common.shell.write().resize_request( - &surface, - &seat, - serial, - match x { - Focus::ResizeTop => ResizeEdge::TOP, - Focus::ResizeTopLeft => ResizeEdge::TOP_LEFT, - Focus::ResizeTopRight => ResizeEdge::TOP_RIGHT, - Focus::ResizeBottom => ResizeEdge::BOTTOM, - Focus::ResizeBottomLeft => ResizeEdge::BOTTOM_LEFT, - Focus::ResizeBottomRight => ResizeEdge::BOTTOM_RIGHT, - Focus::ResizeLeft => ResizeEdge::LEFT, - Focus::ResizeRight => ResizeEdge::RIGHT, - Focus::Header => unreachable!(), - }, - state.common.config.cosmic_conf.edge_snap_threshold, - false, - ); - if let Some((grab, focus)) = res - && let GrabType::TabletTool = grab.grab_type() - { - seat.tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab(state, grab, InputTime::now(), serial, focus); - } - }); - } - None => {} - } - } - - fn up( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &ToolUpEvent, - ) { - TabletToolTarget::up(&self.0, seat, data, tool_descriptor, event) - } - - fn motion( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &ToolMotionEvent, - ) { - let mut event = event.clone(); - self.0.with_program(|p| { - let active = p.active.load(Ordering::SeqCst); - let active_window = &p.windows.lock().unwrap()[active]; - let Some(next) = Focus::under(active_window, TAB_HEIGHT, event.location) else { - return; - }; - let _previous = p.swap_focus(Some(next)); - - let mut cursor_state = seat - .user_data() - .get::() - .unwrap() - .lock() - .unwrap(); - cursor_state.set_shape(next.cursor_shape()); - seat.set_cursor_image_status(CursorImageStatus::default_named()); - }); - - let active_window_geo = self.0.with_program(|p| { - p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)].geometry() - }); - event.location -= active_window_geo.loc.to_f64(); - - TabletToolTarget::motion(&self.0, seat, data, tool_descriptor, &event); - if event.location.y < 0.0 - || event.location.y > TAB_HEIGHT as f64 - || event.location.x < 64.0 - || event.location.x > (active_window_geo.size.w as f64 - 64.0) - { - self.start_drag( - data, - seat, - self.0 - .with_program(|p| p.tablet_serial.load(Ordering::Acquire)) - .into(), - ); - } - } - - fn axis( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - frame: ToolAxisFrame, - ) { - TabletToolTarget::axis(&self.0, seat, data, tool_descriptor, frame) - } - - fn button( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &ToolButtonEvent, - ) { - TabletToolTarget::button(&self.0, seat, data, tool_descriptor, event) - } - - fn frame( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - time: InputTime, - ) { - TabletToolTarget::frame(&self.0, seat, data, tool_descriptor, time) - } -} - pub enum CosmicStackRenderElement { Header(IcedRenderElement), Shadow(PixelShaderElement), diff --git a/src/shell/element/stack/tab.rs b/src/shell/element/stack/tab.rs index 5613f76e..1a311dfc 100644 --- a/src/shell/element/stack/tab.rs +++ b/src/shell/element/stack/tab.rs @@ -8,7 +8,6 @@ use cosmic::{ layout::{Layout, Limits, Node}, mouse, overlay, renderer, text::{Ellipsize, EllipsizeHeightLimit, Shaping, Wrapping}, - touch, widget::{Id, Widget, operation::Operation, tree::Tree}, }, widget::{self, container::draw_background, rule::FillMode, scrollable::AbsoluteOffset}, @@ -371,7 +370,6 @@ where if matches!( event, event::Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) - | event::Event::Touch(touch::Event::FingerPressed { .. }) ) && let Some(message) = self.press_message.clone() { shell.publish(message); @@ -390,7 +388,6 @@ where if matches!( event, event::Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) - | event::Event::Touch(touch::Event::FingerLifted { .. }) ) { shell.publish(Message::activate(self.idx)); shell.capture_event(); diff --git a/src/shell/element/stack/tabs.rs b/src/shell/element/stack/tabs.rs index 9dd5ef81..86218db6 100644 --- a/src/shell/element/stack/tabs.rs +++ b/src/shell/element/stack/tabs.rs @@ -31,7 +31,7 @@ use keyframe::{ functions::{EaseInOutCubic, EaseOutCubic}, }; use std::{ - collections::{HashMap, VecDeque}, + collections::{HashMap, HashSet, VecDeque}, time::{Duration, Instant}, }; @@ -757,10 +757,12 @@ where state.last_state = Some(current_state.clone()); } let last_state = state.last_state.as_mut().unwrap(); - let unknown_keys = current_state.len() != last_state.len() - || current_state - .keys() - .any(|key| !last_state.contains_key(key)); + let unknown_keys = current_state + .keys() + .collect::>() + .symmetric_difference(&last_state.keys().collect::>()) + .next() + .is_some(); enum Difference { NewOrRemoved, diff --git a/src/shell/element/surface.rs b/src/shell/element/surface.rs index a7fd922d..99bb2f78 100644 --- a/src/shell/element/surface.rs +++ b/src/shell/element/surface.rs @@ -21,7 +21,6 @@ use std::{ use smithay::{ backend::{ drm::DrmNode, - input::InputTime, renderer::{ ImportAll, Renderer, buffer_has_alpha, element::{Kind, RenderElementStates, surface::KindEvaluation}, @@ -1085,7 +1084,7 @@ impl KeyboardTarget for CosmicSurface { key: KeysymHandle<'_>, state: smithay::backend::input::KeyState, serial: smithay::utils::Serial, - time: InputTime, + time: u32, ) { match self.0.underlying_surface() { WindowSurface::Wayland(toplevel) => { diff --git a/src/shell/element/window.rs b/src/shell/element/window.rs index c06609fe..838efd24 100644 --- a/src/shell/element/window.rs +++ b/src/shell/element/window.rs @@ -7,7 +7,7 @@ use crate::{ shell::{ element::{CosmicMappedKey, CosmicMappedKeyInner}, focus::target::PointerFocusTarget, - grabs::{GrabType, ReleaseMode, ResizeEdge}, + grabs::{ReleaseMode, ResizeEdge}, }, state::State, utils::{ @@ -21,7 +21,7 @@ use cosmic_comp_config::AppearanceConfig; use smithay::{ backend::{ drm::DrmNode, - input::{InputTime, KeyState, TabletToolDescriptor}, + input::KeyState, renderer::{ ImportAll, ImportMem, Renderer, element::{Element, Id as RendererId, Kind, RenderElement, UnderlyingStorage}, @@ -35,23 +35,14 @@ use smithay::{ Seat, keyboard::{KeyboardTarget, KeysymHandle, ModifiersState}, pointer::{ - AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, CursorIcon, - CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, - GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, - GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent as PointerMotionEvent, - PointerTarget, RelativeMotionEvent, - }, - tablet::{ - Tablet, TabletSeatTrait, - tool::{ - AxisFrame as ToolAxisFrame, ButtonEvent as ToolButtonEvent, - DownEvent as ToolDownEvent, MotionEvent as ToolMotionEvent, TabletToolTarget, - UpEvent as ToolUpEvent, - }, + AxisFrame, ButtonEvent, CursorIcon, CursorImageStatus, GestureHoldBeginEvent, + GestureHoldEndEvent, GesturePinchBeginEvent, GesturePinchEndEvent, + GesturePinchUpdateEvent, GestureSwipeBeginEvent, GestureSwipeEndEvent, + GestureSwipeUpdateEvent, MotionEvent, PointerTarget, RelativeMotionEvent, }, touch::{ - DownEvent as TouchDownEvent, FrameMarker, MotionEvent as TouchMotionEvent, - OrientationEvent, ShapeEvent, TouchTarget, UpEvent as TouchUpEvent, + DownEvent, FrameMarker, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, + TouchTarget, UpEvent, }, }, output::Output, @@ -438,12 +429,12 @@ impl CosmicWindow { .map(|x| (x * scale as f32).round() as u8); if has_ssd && !clip { // bottom corners + radii[0] = 0; radii[2] = 0; - radii[3] = 0; if is_tiled { // top corners - radii[0] = 0; radii[1] = 0; + radii[3] = 0; } } @@ -510,12 +501,12 @@ impl CosmicWindow { && !is_maximized; if has_ssd && !clip { // bottom corners + radii[0] = 0; radii[2] = 0; - radii[3] = 0; if is_tiled { // top corners - radii[0] = 0; radii[1] = 0; + radii[3] = 0; } } @@ -560,8 +551,8 @@ impl CosmicWindow { self.0.with_program(|p| { let mut radii = radii; if has_ssd { - radii[0] = 0; radii[1] = 0; + radii[3] = 0; } let theme = p.theme.lock().unwrap(); let frosted = if theme.cosmic().frosted_windows { @@ -585,8 +576,8 @@ impl CosmicWindow { }); if has_ssd { + radii[0] = 0; radii[2] = 0; - radii[3] = 0; let ssd_loc = location + self .0 @@ -691,26 +682,26 @@ impl CosmicWindow { (has_ssd, true) => { let mut corners = p.window.corner_radius(geometry_size).unwrap_or(radii); - corners[0] = if has_ssd { - radii[0] - } else { - radii[0].max(corners[0]) - }; + corners[0] = radii[0].max(corners[0]); corners[1] = if has_ssd { radii[1] } else { radii[1].max(corners[1]) }; corners[2] = radii[2].max(corners[2]); - corners[3] = radii[3].max(corners[3]); + corners[3] = if has_ssd { + radii[3] + } else { + radii[3].max(corners[3]) + }; corners } (true, false) => p .window .corner_radius(geometry_size) - .map(|[_, _, c, d]| [radii[0], radii[1], c, d]) - .unwrap_or([radii[0], radii[1], default_radius, default_radius]), + .map(|[a, _, c, _]| [a, radii[1], c, radii[3]]) + .unwrap_or([default_radius, radii[1], default_radius, radii[3]]), (false, false) => p .window .corner_radius(geometry_size) @@ -755,19 +746,12 @@ impl Program for CosmicWindowInternal { false, ); if let Some((grab, focus)) = res { - match grab.grab_type() { - GrabType::Touch => { - seat.get_touch().unwrap().set_grab(state, grab, serial) - } - GrabType::Pointer => seat - .get_pointer() + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab(state, grab, serial); + } else { + seat.get_pointer() .unwrap() - .set_grab(state, grab, serial, focus), - GrabType::TabletTool => seat - .tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab(state, grab, InputTime::now(), serial, focus), + .set_grab(state, grab, serial, focus); } } }); @@ -997,7 +981,7 @@ impl KeyboardTarget for CosmicWindow { key: KeysymHandle<'_>, state: KeyState, serial: Serial, - time: InputTime, + time: u32, ) { self.0 .with_program(|p| KeyboardTarget::key(&p.window, seat, data, key, state, serial, time)) @@ -1015,7 +999,7 @@ impl KeyboardTarget for CosmicWindow { } impl PointerTarget for CosmicWindow { - fn enter(&self, seat: &Seat, data: &mut State, event: &PointerMotionEvent) { + fn enter(&self, seat: &Seat, data: &mut State, event: &MotionEvent) { let mut event = event.clone(); self.0.with_program(|p| { let has_ssd = p.has_ssd(false); @@ -1028,7 +1012,8 @@ impl PointerTarget for CosmicWindow { return; }; - let _ = p.swap_focus(Some(next)); + let old_focus = p.swap_focus(Some(next)); + assert_eq!(old_focus, None); let cursor_state = seat.user_data().get::().unwrap(); cursor_state.lock().unwrap().set_shape(next.cursor_shape()); @@ -1040,7 +1025,7 @@ impl PointerTarget for CosmicWindow { PointerTarget::enter(&self.0, seat, data, &event) } - fn motion(&self, seat: &Seat, data: &mut State, event: &PointerMotionEvent) { + fn motion(&self, seat: &Seat, data: &mut State, event: &MotionEvent) { let mut event = event.clone(); self.0.with_program(|p| { let has_ssd = p.has_ssd(false); @@ -1072,7 +1057,7 @@ impl PointerTarget for CosmicWindow { ) { } - fn button(&self, seat: &Seat, data: &mut State, event: &PointerButtonEvent) { + fn button(&self, seat: &Seat, data: &mut State, event: &ButtonEvent) { match self.0.with_program(|p| p.current_focus()) { Some(Focus::Header) => PointerTarget::button(&self.0, seat, data, event), Some(x) => { @@ -1108,12 +1093,14 @@ impl PointerTarget for CosmicWindow { false, ); - if let Some((grab, focus)) = res - && let GrabType::Pointer = grab.grab_type() - { - seat.get_pointer() - .unwrap() - .set_grab(state, grab, serial, focus) + if let Some((grab, focus)) = res { + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab(state, grab, serial); + } else { + seat.get_pointer() + .unwrap() + .set_grab(state, grab, serial, focus); + } } }); } @@ -1121,7 +1108,7 @@ impl PointerTarget for CosmicWindow { } } - fn axis(&self, seat: &Seat, data: &mut State, frame: PointerAxisFrame) { + fn axis(&self, seat: &Seat, data: &mut State, frame: AxisFrame) { if let Some(Focus::Header) = self.0.with_program(|p| p.current_focus()) { PointerTarget::axis(&self.0, seat, data, frame) } @@ -1133,7 +1120,7 @@ impl PointerTarget for CosmicWindow { } } - fn leave(&self, seat: &Seat, data: &mut State, serial: Serial, time: InputTime) { + fn leave(&self, seat: &Seat, data: &mut State, serial: Serial, time: u32) { self.0.with_program(|p| { let cursor_state = seat.user_data().get::().unwrap(); cursor_state.lock().unwrap().unset_shape(); @@ -1208,7 +1195,7 @@ impl PointerTarget for CosmicWindow { } impl TouchTarget for CosmicWindow { - fn down(&self, seat: &Seat, data: &mut State, event: &TouchDownEvent) { + fn down(&self, seat: &Seat, data: &mut State, event: &DownEvent) { let mut event = event.clone(); self.0.with_program(|p| { event.location -= p.window.geometry().loc.to_f64(); @@ -1216,7 +1203,7 @@ impl TouchTarget for CosmicWindow { TouchTarget::down(&self.0, seat, data, &event) } - fn up(&self, seat: &Seat, data: &mut State, event: &TouchUpEvent) { + fn up(&self, seat: &Seat, data: &mut State, event: &UpEvent) { TouchTarget::up(&self.0, seat, data, event) } @@ -1247,155 +1234,6 @@ impl TouchTarget for CosmicWindow { } } -impl TabletToolTarget for CosmicWindow { - fn proximity_in( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - tablet: &Tablet, - serial: Serial, - ) { - TabletToolTarget::proximity_in(&self.0, seat, data, tool_descriptor, tablet, serial) - } - - fn proximity_out( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - ) { - self.0.with_program(|p| { - let cursor_state = seat.user_data().get::().unwrap(); - cursor_state.lock().unwrap().unset_shape(); - let _previous = p.swap_focus(None); - }); - TabletToolTarget::proximity_out(&self.0, seat, data, tool_descriptor) - } - - fn down( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &ToolDownEvent, - ) { - match self.0.with_program(|p| p.current_focus()) { - Some(Focus::Header) => { - TabletToolTarget::down(&self.0, seat, data, tool_descriptor, event) - } - Some(x) => { - let serial = event.serial; - let seat = seat.clone(); - let Some(surface) = self.wl_surface().map(Cow::into_owned) else { - return; - }; - - self.0.loop_handle().insert_idle(move |state| { - let res = state.common.shell.write().resize_request( - &surface, - &seat, - serial, - match x { - Focus::ResizeTop => ResizeEdge::TOP, - Focus::ResizeTopLeft => ResizeEdge::TOP_LEFT, - Focus::ResizeTopRight => ResizeEdge::TOP_RIGHT, - Focus::ResizeBottom => ResizeEdge::BOTTOM, - Focus::ResizeBottomLeft => ResizeEdge::BOTTOM_LEFT, - Focus::ResizeBottomRight => ResizeEdge::BOTTOM_RIGHT, - Focus::ResizeLeft => ResizeEdge::LEFT, - Focus::ResizeRight => ResizeEdge::RIGHT, - Focus::Header => unreachable!(), - }, - state.common.config.cosmic_conf.edge_snap_threshold, - false, - ); - - if let Some((grab, focus)) = res - && let GrabType::TabletTool = grab.grab_type() - { - seat.tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab(state, grab, InputTime::now(), serial, focus) - } - }); - } - None => {} - } - } - - fn up( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &ToolUpEvent, - ) { - TabletToolTarget::up(&self.0, seat, data, tool_descriptor, event) - } - - fn motion( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &ToolMotionEvent, - ) { - let mut event = event.clone(); - self.0.with_program(|p| { - let has_ssd = p.has_ssd(false); - if has_ssd || p.has_tiled_state() { - let Some(next) = Focus::under( - &p.window, - if has_ssd { SSD_HEIGHT } else { 0 }, - event.location, - ) else { - return; - }; - let _previous = p.swap_focus(Some(next)); - - let cursor_state = seat.user_data().get::().unwrap(); - cursor_state.lock().unwrap().set_shape(next.cursor_shape()); - seat.set_cursor_image_status(CursorImageStatus::default_named()); - } - }); - - event.location -= self.0.with_program(|p| p.window.geometry().loc.to_f64()); - TabletToolTarget::motion(&self.0, seat, data, tool_descriptor, &event) - } - - fn axis( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - frame: ToolAxisFrame, - ) { - TabletToolTarget::axis(&self.0, seat, data, tool_descriptor, frame) - } - - fn button( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &ToolButtonEvent, - ) { - TabletToolTarget::button(&self.0, seat, data, tool_descriptor, event) - } - - fn frame( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - time: InputTime, - ) { - TabletToolTarget::frame(&self.0, seat, data, tool_descriptor, time) - } -} - impl WaylandFocus for CosmicWindow { fn wl_surface(&self) -> Option> { self.0.with_program(|p| { diff --git a/src/shell/focus/mod.rs b/src/shell/focus/mod.rs index dcfd55de..cab37a85 100644 --- a/src/shell/focus/mod.rs +++ b/src/shell/focus/mod.rs @@ -2,18 +2,11 @@ use crate::{ shell::{CosmicSurface, MinimizedWindow, Shell, Trigger, element::CosmicMapped}, state::{Common, State}, utils::prelude::*, - wayland::{ - handlers::{xdg_shell::PopupGrabData, xwayland_keyboard_grab::XWaylandGrabSeatData}, - protocols::session_lock_layer::layer_show_on_lock, - }, + wayland::handlers::{xdg_shell::PopupGrabData, xwayland_keyboard_grab::XWaylandGrabSeatData}, }; use indexmap::IndexSet; use smithay::{ - backend::input::InputTime, - desktop::{ - LayerSurface, PopupUngrabStrategy, WindowSurfaceType, find_popup_root_surface, - layer_map_for_output, - }, + desktop::{PopupUngrabStrategy, layer_map_for_output}, input::{Seat, pointer::MotionEvent}, output::Output, reexports::wayland_server::{Resource, protocol::wl_surface::WlSurface}, @@ -426,7 +419,7 @@ fn update_focus_state( &MotionEvent { location: new_pos.as_logical(), serial: SERIAL_COUNTER.next_serial(), - time: InputTime::now(), + time: 0, }, ); } @@ -633,42 +626,19 @@ fn focus_target_is_valid( output: &Output, target: KeyboardFocusTarget, ) -> bool { - // If a session lock is active, only lock surfaces and lock layers can be focused + // If a session lock is active, only lock surfaces can be focused if shell.session_lock.is_some() { - if let KeyboardFocusTarget::LayerSurface(layer) = &target { - return layer_show_on_lock(layer.wl_surface()); - } else if let KeyboardFocusTarget::Popup(popup) = &target - && let Ok(root) = find_popup_root_surface(popup) - { - return layer_show_on_lock(&root); - } return matches!(target, KeyboardFocusTarget::LockSurface(_)); } // If an exclusive layer shell surface exists (on any output), only exclusive // shell surfaces can have focus, on the highest layer with exclusive surfaces. - // Popups are judged by their root surface, so an exclusive surface can - // still open grabbing popups (menus, dropdowns, context menus). if let Some(layer) = exclusive_layer_surface_layer(shell) { - let is_exclusive_on_layer = |layer_surface: &LayerSurface| { + return if let KeyboardFocusTarget::LayerSurface(layer_surface) = target { let data = layer_surface.cached_state(); (data.keyboard_interactivity, data.layer) == (KeyboardInteractivity::Exclusive, layer) - }; - return match target { - KeyboardFocusTarget::LayerSurface(layer_surface) => { - is_exclusive_on_layer(&layer_surface) - } - KeyboardFocusTarget::Popup(popup) => find_popup_root_surface(&popup) - .ok() - .and_then(|root| { - shell.outputs().find_map(|o| { - layer_map_for_output(o) - .layer_for_surface(&root, WindowSurfaceType::ALL) - .map(&is_exclusive_on_layer) - }) - }) - .unwrap_or(false), - _ => false, + } else { + false }; } @@ -798,7 +768,7 @@ fn update_pointer_focus(state: &mut State, seat: &Seat) { &MotionEvent { location: pointer.current_location(), serial: SERIAL_COUNTER.next_serial(), - time: InputTime::now(), + time: state.common.clock.now().as_millis(), }, ); } diff --git a/src/shell/focus/order.rs b/src/shell/focus/order.rs index 937fa311..fb904c01 100644 --- a/src/shell/focus/order.rs +++ b/src/shell/focus/order.rs @@ -22,7 +22,7 @@ use crate::{ prelude::OutputExt, quirks::{WORKSPACE_OVERVIEW_NAMESPACE, workspace_overview_is_open}, }, - wayland::protocols::{session_lock_layer::layer_show_on_lock, workspace::WorkspaceHandle}, + wayland::protocols::workspace::WorkspaceHandle, }; pub enum Stage<'a> { @@ -77,8 +77,6 @@ fn render_input_order_internal( element_filter: ElementFilter, mut callback: impl FnMut(Stage) -> ControlFlow, ()>, ) -> ControlFlow, ()> { - // NOTE: Keep in sync with other surface iteration functions - if shell .zoom_state .as_ref() @@ -89,92 +87,7 @@ fn render_input_order_internal( // Session Lock if let Some(session_lock) = &shell.session_lock { - for (layer, popup, location) in layer_popups(output, Layer::Overlay, element_filter) { - if !layer_show_on_lock(layer.wl_surface()) { - continue; - } - callback(Stage::LayerPopup { - layer, - popup: &popup, - location, - workspace_idx: current.1, - })?; - } - for (layer, location) in layer_surfaces(output, Layer::Overlay, element_filter) { - if !layer_show_on_lock(layer.wl_surface()) { - continue; - } - callback(Stage::LayerSurface { - layer, - location, - workspace_idx: current.1, - })?; - } - for (layer, popup, location) in layer_popups(output, Layer::Top, element_filter) { - if !layer_show_on_lock(layer.wl_surface()) { - continue; - } - callback(Stage::LayerPopup { - layer, - popup: &popup, - location, - workspace_idx: current.1, - })?; - } - for (layer, location) in layer_surfaces(output, Layer::Top, element_filter) { - if !layer_show_on_lock(layer.wl_surface()) { - continue; - } - callback(Stage::LayerSurface { - layer, - location, - workspace_idx: current.1, - })?; - } - callback(Stage::SessionLock(session_lock.surfaces.get(output)))?; - for (layer, popup, location) in layer_popups(output, Layer::Bottom, element_filter) { - if !layer_show_on_lock(layer.wl_surface()) { - continue; - } - callback(Stage::LayerPopup { - layer, - popup: &popup, - location, - workspace_idx: current.1, - })?; - } - for (layer, popup, location) in layer_popups(output, Layer::Background, element_filter) { - if !layer_show_on_lock(layer.wl_surface()) { - continue; - } - callback(Stage::LayerPopup { - layer, - popup: &popup, - location, - workspace_idx: current.1, - })?; - } - for (layer, location) in layer_surfaces(output, Layer::Bottom, element_filter) { - if !layer_show_on_lock(layer.wl_surface()) { - continue; - } - callback(Stage::LayerSurface { - layer, - location, - workspace_idx: current.1, - })?; - } - for (layer, location) in layer_surfaces(output, Layer::Background, element_filter) { - if !layer_show_on_lock(layer.wl_surface()) { - continue; - } - callback(Stage::LayerSurface { - layer, - location, - workspace_idx: current.1, - })?; - } - return ControlFlow::Continue(()); + return callback(Stage::SessionLock(session_lock.surfaces.get(output))); } // Overlay-level layer shell diff --git a/src/shell/focus/target.rs b/src/shell/focus/target.rs index c914e0fa..80b1a34f 100644 --- a/src/shell/focus/target.rs +++ b/src/shell/focus/target.rs @@ -16,30 +16,21 @@ use crate::{ }; use id_tree::NodeId; use smithay::{ - backend::input::{InputTime, KeyState, TabletToolDescriptor}, + backend::input::KeyState, desktop::{LayerSurface, PopupKind, WindowSurface, WindowSurfaceType, space::SpaceElement}, input::{ Seat, dnd::{DndFocus, OfferData, Source}, keyboard::{KeyboardTarget, KeysymHandle, ModifiersState}, pointer::{ - AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, - GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, - GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, - GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent as PointerMotionEvent, - PointerTarget, RelativeMotionEvent, - }, - tablet::{ - Tablet, - tool::{ - AxisFrame as ToolAxisFrame, ButtonEvent as ToolButtonEvent, - DownEvent as ToolDownEvent, MotionEvent as ToolMotionEvent, TabletToolHandle, - TabletToolTarget, UpEvent as ToolUpEvent, - }, + AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent, + GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, + GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, + MotionEvent as PointerMotionEvent, PointerTarget, RelativeMotionEvent, }, touch::{ - DownEvent as TouchDownEvent, FrameMarker, MotionEvent as TouchMotionEvent, - OrientationEvent, ShapeEvent, TouchTarget, UpEvent as TouchUpEvent, + DownEvent, FrameMarker, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, + TouchTarget, UpEvent, }, }, reexports::wayland_server::{ @@ -173,17 +164,6 @@ impl PointerFocusTarget { } } - fn inner_tablet_tool_target(&self) -> &dyn TabletToolTarget { - match self { - PointerFocusTarget::WlSurface { surface, .. } => surface, - PointerFocusTarget::X11Surface { surface, .. } => surface, - PointerFocusTarget::StackUI(u) => u, - PointerFocusTarget::WindowUI(u) => u, - PointerFocusTarget::ResizeFork(f) => f, - PointerFocusTarget::ZoomUI(e) => e, - } - } - pub fn under_surface>>( surface: &CosmicSurface, point: P, @@ -292,10 +272,9 @@ impl PointerFocusTarget { None }; - let cursor_hotspot = if let Some(CursorGeometry { hotspot, .. }) = seat.cursor_geometry( - (0.0, 0.0), - Duration::from_millis(event.time.millis() as u64).into(), - ) { + let cursor_hotspot = if let Some(CursorGeometry { hotspot, .. }) = + seat.cursor_geometry((0.0, 0.0), Duration::from_millis(event.time as u64).into()) + { hotspot } else { Point::from((0, 0)) @@ -306,16 +285,6 @@ impl PointerFocusTarget { session.set_cursor_hotspot(cursor_hotspot); } } - - pub fn supports_tool(&self, tool_handle: &TabletToolHandle) -> bool { - match self { - Self::WlSurface { surface, .. } if surface.client().is_some() => tool_handle - .client_tools(&surface.client().unwrap()) - .next() - .is_some(), - _ => true, - } - } } impl KeyboardFocusTarget { @@ -439,16 +408,16 @@ impl PointerTarget for PointerFocusTarget { self.inner_pointer_target() .relative_motion(seat, data, event); } - fn button(&self, seat: &Seat, data: &mut State, event: &PointerButtonEvent) { + fn button(&self, seat: &Seat, data: &mut State, event: &ButtonEvent) { self.inner_pointer_target().button(seat, data, event); } - fn axis(&self, seat: &Seat, data: &mut State, frame: PointerAxisFrame) { + fn axis(&self, seat: &Seat, data: &mut State, frame: AxisFrame) { self.inner_pointer_target().axis(seat, data, frame); } fn frame(&self, seat: &Seat, data: &mut State) { self.inner_pointer_target().frame(seat, data); } - fn leave(&self, seat: &Seat, data: &mut State, serial: Serial, time: InputTime) { + fn leave(&self, seat: &Seat, data: &mut State, serial: Serial, time: u32) { let toplevel = self.toplevel(&data.common.shell.read()); if let Some(element) = toplevel { for session in element.cursor_sessions() { @@ -528,102 +497,12 @@ impl PointerTarget for PointerFocusTarget { } } -impl TabletToolTarget for PointerFocusTarget { - fn proximity_in( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - tablet: &Tablet, - serial: Serial, - ) { - self.inner_tablet_tool_target() - .proximity_in(seat, data, tool_descriptor, tablet, serial); - } - - fn proximity_out( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - ) { - self.inner_tablet_tool_target() - .proximity_out(seat, data, tool_descriptor); - } - - fn down( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &ToolDownEvent, - ) { - self.inner_tablet_tool_target() - .down(seat, data, tool_descriptor, event); - } - - fn up( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &ToolUpEvent, - ) { - self.inner_tablet_tool_target() - .up(seat, data, tool_descriptor, event); - } - - fn motion( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &ToolMotionEvent, - ) { - self.inner_tablet_tool_target() - .motion(seat, data, tool_descriptor, event); - } - - fn axis( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - frame: ToolAxisFrame, - ) { - self.inner_tablet_tool_target() - .axis(seat, data, tool_descriptor, frame); - } - - fn button( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &ToolButtonEvent, - ) { - self.inner_tablet_tool_target() - .button(seat, data, tool_descriptor, event); - } - - fn frame( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - time: InputTime, - ) { - self.inner_tablet_tool_target() - .frame(seat, data, tool_descriptor, time); - } -} - impl TouchTarget for PointerFocusTarget { - fn down(&self, seat: &Seat, data: &mut State, event: &TouchDownEvent) { + fn down(&self, seat: &Seat, data: &mut State, event: &DownEvent) { self.inner_touch_target().down(seat, data, event); } - fn up(&self, seat: &Seat, data: &mut State, event: &TouchUpEvent) { + fn up(&self, seat: &Seat, data: &mut State, event: &UpEvent) { self.inner_touch_target().up(seat, data, event); } @@ -714,7 +593,7 @@ impl DndFocus for PointerFocusTarget { offer: Option<&mut CosmicOfferData>, seat: &Seat, location: Point, - time: InputTime, + time: u32, ) { match self { PointerFocusTarget::WlSurface { surface, .. } => { @@ -816,7 +695,7 @@ impl KeyboardTarget for KeyboardFocusTarget { key: KeysymHandle<'_>, state: KeyState, serial: Serial, - time: InputTime, + time: u32, ) { if let Some(inner) = self.inner_keyboard_target() { inner.key(seat, data, key, state, serial, time); diff --git a/src/shell/grabs/delay.rs b/src/shell/grabs/delay.rs index ca19e4cb..96d33dc6 100644 --- a/src/shell/grabs/delay.rs +++ b/src/shell/grabs/delay.rs @@ -1,34 +1,22 @@ use smithay::{ - backend::input::{InputTime, TabletToolDescriptor}, input::{ Seat, SeatHandler, pointer::{ - AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, Focus, - GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, - GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, - GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData, - MotionEvent as PointerMotionEvent, PointerGrab, PointerInnerHandle, - RelativeMotionEvent, - }, - tablet::{ - TabletSeatHandler, TabletSeatTrait, - tool::{ - AxisFrame as TabletAxisFrame, ButtonEvent as TabletButtonEvent, - DownEvent as TabletDownEvent, GrabStartData as TabletGrabStartData, - MotionEvent as TabletMotionEvent, ProximityInEvent, ProximityOutEvent, - TabletToolGrab, TabletToolInnerHandle, UpEvent as TabletUpEvent, - }, + AxisFrame, ButtonEvent, Focus, GestureHoldBeginEvent, GestureHoldEndEvent, + GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, + GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, + GrabStartData as PointerGrabStartData, MotionEvent as PointerMotionEvent, PointerGrab, + PointerInnerHandle, RelativeMotionEvent, }, touch::{ - DownEvent as TouchDownEvent, GrabStartData as TouchGrabStartData, - MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchGrab, - TouchInnerHandle, UpEvent as TouchUpEvent, + DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent, + OrientationEvent, ShapeEvent, TouchGrab, TouchInnerHandle, UpEvent, }, }, utils::{Logical, Point, SERIAL_COUNTER, Serial}, }; -use crate::{shell::grabs::GrabType, state::State}; +use crate::state::State; use super::GrabStartData; @@ -56,15 +44,10 @@ impl DelayGrab { } } - pub fn grab_type(&self) -> GrabType { - self.start_data.type_() - } - - pub fn tool(&self) -> Option<&TabletToolDescriptor> { - if let GrabStartData::TabletTool { tool, .. } = &self.start_data { - Some(tool) - } else { - None + pub fn is_touch_grab(&self) -> bool { + match self.start_data { + GrabStartData::Touch(_) => true, + GrabStartData::Pointer(_) => false, } } } @@ -109,7 +92,7 @@ impl> PointerGrab for DelayGrab { &mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>, - event: &PointerButtonEvent, + event: &ButtonEvent, ) { handle.button(data, event); if handle.current_pressed().is_empty() { @@ -121,7 +104,7 @@ impl> PointerGrab for DelayGrab { &mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>, - details: PointerAxisFrame, + details: AxisFrame, ) { handle.axis(data, details); } @@ -218,17 +201,12 @@ impl> TouchGrab for DelayGrab { data: &mut State, handle: &mut TouchInnerHandle<'_, State>, focus: Option<(::TouchFocus, Point)>, - event: &TouchDownEvent, + event: &DownEvent, ) { handle.down(data, focus, event); } - fn up( - &mut self, - data: &mut State, - handle: &mut TouchInnerHandle<'_, State>, - event: &TouchUpEvent, - ) { + fn up(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, event: &UpEvent) { handle.up(data, event); if event.slot == TouchGrab::start_data(self).slot { @@ -295,110 +273,3 @@ impl> TouchGrab for DelayGrab { fn unset(&mut self, _data: &mut State) {} } - -impl> TabletToolGrab for DelayGrab { - fn start_data(&self) -> &TabletGrabStartData { - match &self.start_data { - GrabStartData::TabletTool { data, .. } => data, - _ => unreachable!(), - } - } - - fn proximity_out( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &ProximityOutEvent, - ) { - handle.proximity_out(data, event); - } - - fn motion( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - focus: Option<(::ToolFocus, Point)>, - event: &TabletMotionEvent, - ) { - handle.motion(data, focus, event); - - let distance = self.start_data.distance(event.location); - if distance >= 1. - && let Some(factory) = self.grab_factory.take() - { - let seat = self.seat.clone(); - let serial = self.serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial()); - let time = InputTime::now(); - let Some(tool) = self.tool().cloned() else { - handle.unset_grab(self, data, serial, time, true); - return; - }; - data.common.event_loop_handle.insert_idle(move |data| { - if let Some((grab, focus)) = factory(data) { - seat.tablet_seat() - .get_tool(&tool) - .unwrap() - .set_grab(data, grab, time, serial, focus); - } - }); - } - } - - fn down( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletDownEvent, - ) { - handle.down(data, event) - } - - fn up( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletUpEvent, - ) { - handle.up(data, event); - handle.unset_grab(self, data, event.serial, event.time, false); - } - - fn button( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletButtonEvent, - ) { - handle.button(data, event); - } - - fn axis( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - frame: TabletAxisFrame, - ) { - handle.axis(data, frame) - } - - fn frame( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - time: InputTime, - ) { - handle.frame(data, time) - } - - fn unset(&mut self, _data: &mut State) {} - - fn proximity_in( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - focus: Option<(::ToolFocus, Point)>, - event: &ProximityInEvent, - ) { - handle.proximity_in(data, focus, event); - } -} diff --git a/src/shell/grabs/menu/default.rs b/src/shell/grabs/menu/default.rs index 26cca2f5..c7418b6d 100644 --- a/src/shell/grabs/menu/default.rs +++ b/src/shell/grabs/menu/default.rs @@ -1,10 +1,7 @@ use cosmic_settings_config::shortcuts::Action; use smithay::{ - backend::input::InputTime, - input::{pointer::MotionEvent, tablet::TabletSeatTrait}, - reexports::wayland_server::protocol::wl_surface::WlSurface, - utils::SERIAL_COUNTER, - wayland::seat::WaylandFocus, + input::pointer::MotionEvent, reexports::wayland_server::protocol::wl_surface::WlSurface, + utils::SERIAL_COUNTER, wayland::seat::WaylandFocus, }; use crate::{ @@ -13,7 +10,7 @@ use crate::{ shell::{ CosmicSurface, PointGlobalExt, Shell, element::{CosmicMapped, CosmicWindow}, - grabs::{GrabType, ReleaseMode}, + grabs::ReleaseMode, }, state::State, utils::{prelude::SeatExt, screenshot::screenshot_window}, @@ -355,20 +352,19 @@ pub fn window_items( std::mem::drop(shell); if let Some((grab, focus)) = res { - let serial = SERIAL_COUNTER.next_serial(); - match grab.grab_type() { - GrabType::Touch => { - seat.get_touch().unwrap().set_grab(state, grab, serial) - } - GrabType::Pointer => seat - .get_pointer() - .unwrap() - .set_grab(state, grab, serial, focus), - GrabType::TabletTool => seat - .tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab(state, grab, InputTime::now(), serial, focus), + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab( + state, + grab, + SERIAL_COUNTER.next_serial(), + ) + } else { + seat.get_pointer().unwrap().set_grab( + state, + grab, + SERIAL_COUNTER.next_serial(), + focus, + ); } } } @@ -392,29 +388,21 @@ pub fn window_items( std::mem::drop(shell); if let Some(((target, loc), (grab, focus))) = res { let serial = SERIAL_COUNTER.next_serial(); - match grab.grab_type() { - GrabType::Touch => { - seat.get_touch().unwrap().set_grab(state, grab, serial) - } - GrabType::TabletTool => seat - .tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab(state, grab, InputTime::now(), serial, focus), - GrabType::Pointer => { - let pointer = seat.get_pointer().unwrap(); - pointer.motion( - state, - target, - &MotionEvent { - location: loc.as_logical().to_f64(), - serial, - time: InputTime::now(), - }, - ); - pointer.frame(state); - pointer.set_grab(state, grab, serial, focus); - } + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab(state, grab, serial); + } else { + let pointer = seat.get_pointer().unwrap(); + pointer.motion( + state, + target, + &MotionEvent { + location: loc.as_logical().to_f64(), + serial, + time: state.common.clock.now().as_millis(), + }, + ); + pointer.frame(state); + pointer.set_grab(state, grab, serial, focus); } } }); @@ -435,30 +423,21 @@ pub fn window_items( std::mem::drop(shell); if let Some(((target, loc), (grab, focus))) = res { let serial = SERIAL_COUNTER.next_serial(); - match grab.grab_type() { - GrabType::Touch => { - seat.get_touch().unwrap().set_grab(state, grab, serial) - } - GrabType::Pointer => { - let pointer = seat.get_pointer().unwrap(); - pointer.motion( - state, - target, - &MotionEvent { - location: loc.as_logical().to_f64(), - serial, - time: InputTime::now(), - }, - ); - pointer.frame(state); - pointer.set_grab(state, grab, serial, focus); - } - GrabType::TabletTool => { - seat.tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab(state, grab, InputTime::now(), serial, focus); - } + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab(state, grab, serial); + } else { + let pointer = seat.get_pointer().unwrap(); + pointer.motion( + state, + target, + &MotionEvent { + location: loc.as_logical().to_f64(), + serial, + time: state.common.clock.now().as_millis(), + }, + ); + pointer.frame(state); + pointer.set_grab(state, grab, serial, focus); } } }); @@ -479,30 +458,21 @@ pub fn window_items( std::mem::drop(shell); if let Some(((target, loc), (grab, focus))) = res { let serial = SERIAL_COUNTER.next_serial(); - match grab.grab_type() { - GrabType::Touch => { - seat.get_touch().unwrap().set_grab(state, grab, serial) - } - GrabType::Pointer => { - let pointer = seat.get_pointer().unwrap(); - pointer.motion( - state, - target, - &MotionEvent { - location: loc.as_logical().to_f64(), - serial, - time: InputTime::now(), - }, - ); - pointer.frame(state); - pointer.set_grab(state, grab, serial, focus); - } - GrabType::TabletTool => { - seat.tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab(state, grab, InputTime::now(), serial, focus); - } + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab(state, grab, serial); + } else { + let pointer = seat.get_pointer().unwrap(); + pointer.motion( + state, + target, + &MotionEvent { + location: loc.as_logical().to_f64(), + serial, + time: state.common.clock.now().as_millis(), + }, + ); + pointer.frame(state); + pointer.set_grab(state, grab, serial, focus); } } }); @@ -523,29 +493,21 @@ pub fn window_items( std::mem::drop(shell); if let Some(((target, loc), (grab, focus))) = res { let serial = SERIAL_COUNTER.next_serial(); - match grab.grab_type() { - GrabType::Touch => { - seat.get_touch().unwrap().set_grab(state, grab, serial) - } - GrabType::Pointer => { - let pointer = seat.get_pointer().unwrap(); - pointer.motion( - state, - target, - &MotionEvent { - location: loc.as_logical().to_f64(), - serial, - time: InputTime::now(), - }, - ); - pointer.frame(state); - pointer.set_grab(state, grab, serial, focus); - } - GrabType::TabletTool => seat - .tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab(state, grab, InputTime::now(), serial, focus), + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab(state, grab, serial); + } else { + let pointer = seat.get_pointer().unwrap(); + pointer.motion( + state, + target, + &MotionEvent { + location: loc.as_logical().to_f64(), + serial, + time: state.common.clock.now().as_millis(), + }, + ); + pointer.frame(state); + pointer.set_grab(state, grab, serial, focus); } } }); @@ -665,20 +627,19 @@ pub fn fullscreen_items(window: &CosmicSurface, config: &Config) -> impl Iterato std::mem::drop(shell); if let Some((grab, focus)) = res { - let serial = SERIAL_COUNTER.next_serial(); - match grab.grab_type() { - GrabType::Touch => { - seat.get_touch().unwrap().set_grab(state, grab, serial) - } - GrabType::Pointer => seat - .get_pointer() - .unwrap() - .set_grab(state, grab, serial, focus), - GrabType::TabletTool => seat - .tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab(state, grab, InputTime::now(), serial, focus), + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab( + state, + grab, + SERIAL_COUNTER.next_serial(), + ) + } else { + seat.get_pointer().unwrap().set_grab( + state, + grab, + SERIAL_COUNTER.next_serial(), + focus, + ); } } } diff --git a/src/shell/grabs/menu/mod.rs b/src/shell/grabs/menu/mod.rs index 9ea37a31..1eb571f1 100644 --- a/src/shell/grabs/menu/mod.rs +++ b/src/shell/grabs/menu/mod.rs @@ -19,33 +19,22 @@ use cosmic::{ }; use smithay::{ backend::{ - input::{ButtonState, InputTime, TabletToolDescriptor, TouchSlot}, + input::{ButtonState, TouchSlot}, renderer::ImportMem, }, desktop::space::SpaceElement, input::{ Seat, pointer::{ - AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, - GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, - GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, - GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData, - MotionEvent as PointerMotionEvent, PointerGrab, PointerInnerHandle, PointerTarget, - RelativeMotionEvent, - }, - tablet::{ - TabletSeatHandler, - tool::{ - AxisFrame as TabletAxisFrame, ButtonEvent as TabletButtonEvent, - DownEvent as TabletDownEvent, GrabStartData as TabletGrabStartData, - MotionEvent as TabletMotionEvent, ProximityInEvent, ProximityOutEvent, - TabletToolGrab, TabletToolInnerHandle, TabletToolTarget, UpEvent as TabletUpEvent, - }, + AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent, + GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, + GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, + GrabStartData as PointerGrabStartData, MotionEvent as PointerMotionEvent, PointerGrab, + PointerInnerHandle, PointerTarget, RelativeMotionEvent, }, touch::{ - DownEvent as TouchDownEvent, GrabStartData as TouchGrabStartData, - MotionEvent as TouchMotionEvent, TouchGrab, TouchInnerHandle, TouchTarget, - UpEvent as TouchUpEvent, + DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent, + TouchGrab, TouchInnerHandle, TouchTarget, UpEvent, }, }, output::Output, @@ -54,7 +43,7 @@ use smithay::{ use crate::{ backend::render::element::AsGlowRenderer, - shell::{SeatExt, focus::target::PointerFocusTarget, grabs::GrabType}, + shell::{SeatExt, focus::target::PointerFocusTarget}, state::State, utils::{ iced::{IcedElement, IcedRenderElement, Program}, @@ -361,7 +350,6 @@ impl Program for ContextMenu { position, pointer_entered: false, touch_entered: None, - tablet_entered: None, }) } }); @@ -521,7 +509,6 @@ pub struct Element { position: Point, pointer_entered: bool, touch_entered: Option, - tablet_entered: Option, } pub struct MenuGrab { @@ -530,7 +517,6 @@ pub struct MenuGrab { seat: Seat, screen_space_relative: Option, scale: Arc>, - last_tablet_idx: Option, } impl PointerGrab for MenuGrab { @@ -613,7 +599,7 @@ impl PointerGrab for MenuGrab { &mut self, state: &mut State, handle: &mut PointerInnerHandle<'_, State>, - event: &PointerButtonEvent, + event: &ButtonEvent, ) { let any_entered = self .elements @@ -647,7 +633,7 @@ impl PointerGrab for MenuGrab { &mut self, state: &mut State, handle: &mut PointerInnerHandle<'_, State>, - details: PointerAxisFrame, + details: AxisFrame, ) { handle.axis(state, details); } @@ -744,7 +730,7 @@ impl TouchGrab for MenuGrab { data: &mut State, handle: &mut TouchInnerHandle<'_, State>, _focus: Option<(PointerFocusTarget, Point)>, - event: &TouchDownEvent, + event: &DownEvent, ) { { let mut guard = self.elements.lock().unwrap(); @@ -772,7 +758,7 @@ impl TouchGrab for MenuGrab { }) { let element = &mut elements[i]; - let new_event = TouchDownEvent { + let new_event = DownEvent { slot: event.slot, location: event_location - element.position.as_logical().to_f64(), serial: event.serial, @@ -787,12 +773,7 @@ impl TouchGrab for MenuGrab { handle.down(data, None, event); } - fn up( - &mut self, - data: &mut State, - handle: &mut TouchInnerHandle<'_, State>, - event: &TouchUpEvent, - ) { + fn up(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, event: &UpEvent) { { let elements = self.elements.lock().unwrap(); for element in elements.iter().filter(|elem| { @@ -868,248 +849,6 @@ impl TouchGrab for MenuGrab { fn unset(&mut self, _data: &mut State) {} } -impl TabletToolGrab for MenuGrab { - fn start_data(&self) -> &TabletGrabStartData { - match &self.start_data { - GrabStartData::TabletTool { data, .. } => data, - _ => unreachable!(), - } - } - - fn proximity_in( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - _focus: Option<(::ToolFocus, Point)>, - event: &ProximityInEvent, - ) { - { - let location = if let Some(output) = self.screen_space_relative.as_ref() { - if data.common.shell.read().zoom_state().is_some() { - event - .location - .as_global() - .to_zoomed(output) - .to_global(output) - .as_logical() - } else { - event.location - } - } else { - event.location - }; - - let mut elements = self.elements.lock().unwrap(); - if let Some(i) = elements.iter().position(|elem| { - let mut bbox = elem.iced.bbox(); - bbox.loc = elem.position.as_logical(); - - bbox.contains(location.to_i32_floor()) - }) { - let element = &mut elements[i]; - - let new_event = TabletMotionEvent { - location: location - element.position.as_logical().to_f64(), - serial: event.serial, - time: event.time, - }; - - TabletToolTarget::proximity_in( - &element.iced, - &self.seat, - data, - handle.descriptor(), - &handle.current_tablet(), - event.serial, - ); - element.tablet_entered = Some(handle.descriptor().clone()); - TabletToolTarget::motion( - &element.iced, - &self.seat, - data, - handle.descriptor(), - &new_event, - ); - self.last_tablet_idx = Some(i); - } - } - handle.proximity_in(data, None, event); - } - - fn proximity_out( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &ProximityOutEvent, - ) { - { - let mut elements = self.elements.lock().unwrap(); - for element in elements.iter_mut().filter(|elem| { - elem.tablet_entered - .as_ref() - .is_some_and(|tool| tool == handle.descriptor()) - }) { - TabletToolTarget::proximity_out( - &element.iced, - &self.seat, - data, - handle.descriptor(), - ); - element.tablet_entered.take(); - } - self.last_tablet_idx.take(); - } - handle.unset_grab(self, data, event.serial, event.time, true); - } - - fn motion( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - _focus: Option<(::ToolFocus, Point)>, - event: &TabletMotionEvent, - ) { - { - let location = if let Some(output) = self.screen_space_relative.as_ref() { - if data.common.shell.read().zoom_state().is_some() { - event - .location - .as_global() - .to_zoomed(output) - .to_global(output) - .as_logical() - } else { - event.location - } - } else { - event.location - }; - - let mut elements = self.elements.lock().unwrap(); - if let Some(i) = elements.iter().position(|elem| { - let mut bbox = elem.iced.bbox(); - bbox.loc = elem.position.as_logical(); - - bbox.contains(location.to_i32_floor()) - }) { - let element = &mut elements[i]; - - let new_event = TabletMotionEvent { - location: location - element.position.as_logical().to_f64(), - serial: event.serial, - time: event.time, - }; - - if element.tablet_entered.is_none() { - TabletToolTarget::proximity_in( - &element.iced, - &self.seat, - data, - handle.descriptor(), - &handle.current_tablet(), - event.serial, - ); - element.tablet_entered = Some(handle.descriptor().clone()); - } - TabletToolTarget::motion( - &element.iced, - &self.seat, - data, - handle.descriptor(), - &new_event, - ); - self.last_tablet_idx = Some(i); - } else { - elements - .iter_mut() - .filter(|element| element.tablet_entered.is_some()) - .skip(1) - .for_each(|element| { - TabletToolTarget::proximity_out( - &element.iced, - &self.seat, - data, - handle.descriptor(), - ); - }); - self.last_tablet_idx.take(); - } - } - handle.motion(data, None, event); - } - - fn down( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletDownEvent, - ) { - let mut guard = self.elements.lock().unwrap(); - let elements = &mut *guard; - - if let Some(elem) = self.last_tablet_idx.and_then(|i| elements.get_mut(i)) - && elem - .tablet_entered - .as_ref() - .is_some_and(|desc| desc == handle.descriptor()) - { - TabletToolTarget::down(&elem.iced, &self.seat, data, handle.descriptor(), event); - } else { - handle.down(data, event); - } - } - - fn up( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletUpEvent, - ) { - let mut guard = self.elements.lock().unwrap(); - let elements = &mut *guard; - - if let Some(elem) = self.last_tablet_idx.and_then(|i| elements.get_mut(i)) - && elem - .tablet_entered - .as_ref() - .is_some_and(|desc| desc == handle.descriptor()) - { - TabletToolTarget::up(&elem.iced, &self.seat, data, handle.descriptor(), event); - } else { - handle.up(data, event); - } - } - - fn button( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletButtonEvent, - ) { - handle.button(data, event); - } - - fn axis( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - frame: TabletAxisFrame, - ) { - handle.axis(data, frame); - } - - fn frame( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - time: InputTime, - ) { - handle.frame(data, time); - } - - fn unset(&mut self, _data: &mut State) {} -} - #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct MenuAlignment { pub x: AxisAlignment, @@ -1313,7 +1052,6 @@ impl MenuGrab { position, pointer_entered: false, touch_entered: None, - tablet_entered: None, }])); let scale = Arc::new(Mutex::new(screen_space_relative.unwrap_or(1.))); @@ -1338,7 +1076,6 @@ impl MenuGrab { seat: seat.clone(), screen_space_relative, scale, - last_tablet_idx: None, } } @@ -1349,15 +1086,10 @@ impl MenuGrab { } } - pub fn grab_type(&self) -> GrabType { - self.start_data.type_() - } - - pub fn tool(&self) -> Option<&TabletToolDescriptor> { - if let GrabStartData::TabletTool { tool, .. } = &self.start_data { - Some(tool) - } else { - None + pub fn is_touch_grab(&self) -> bool { + match self.start_data { + GrabStartData::Touch(_) => true, + GrabStartData::Pointer(_) => false, } } } diff --git a/src/shell/grabs/mod.rs b/src/shell/grabs/mod.rs index 9524f425..515916fd 100644 --- a/src/shell/grabs/mod.rs +++ b/src/shell/grabs/mod.rs @@ -1,26 +1,18 @@ use calloop::LoopHandle; use cosmic_settings_config::shortcuts; use smithay::{ - backend::input::{InputTime, TabletToolDescriptor}, input::{ Seat, pointer::{ - AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, - GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, - GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, - GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData, - MotionEvent, PointerGrab, PointerInnerHandle, RelativeMotionEvent, - }, - tablet::tool::{ - AxisFrame as TabletAxisFrame, ButtonEvent as TabletButtonEvent, - DownEvent as TabletDownEvent, GrabStartData as TabletGrabStartData, - MotionEvent as TabletMotionEvent, ProximityOutEvent, TabletToolGrab, - TabletToolInnerHandle, UpEvent as TabletUpEvent, + AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent, + GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, + GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, + GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle, + RelativeMotionEvent, }, touch::{ - DownEvent as TouchDownEvent, GrabStartData as TouchGrabStartData, - MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchGrab, - TouchInnerHandle, UpEvent as TouchUpEvent, + DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent, + OrientationEvent, ShapeEvent, TouchGrab, TouchInnerHandle, UpEvent, }, }, output::Output, @@ -47,17 +39,6 @@ use super::{ pub enum GrabStartData { Touch(TouchGrabStartData), Pointer(PointerGrabStartData), - TabletTool { - tool: TabletToolDescriptor, - data: TabletGrabStartData, - }, -} - -#[derive(Debug, Clone)] -pub enum GrabType { - Touch, - Pointer, - TabletTool, } impl GrabStartData { @@ -65,7 +46,6 @@ impl GrabStartData { match self { Self::Touch(touch) => touch.focus.as_ref(), Self::Pointer(pointer) => pointer.focus.as_ref(), - Self::TabletTool { data, .. } => data.focus.as_ref(), } } @@ -73,7 +53,6 @@ impl GrabStartData { match self { Self::Touch(touch) => touch.focus = focus, Self::Pointer(pointer) => pointer.focus = focus, - Self::TabletTool { data, .. } => data.focus = focus, } } @@ -81,7 +60,6 @@ impl GrabStartData { match self { Self::Touch(touch) => touch.location, Self::Pointer(pointer) => pointer.location, - Self::TabletTool { data, .. } => data.location, } } @@ -89,7 +67,6 @@ impl GrabStartData { match self { Self::Touch(touch) => touch.location = location, Self::Pointer(pointer) => pointer.location = location, - Self::TabletTool { data, .. } => data.location = location, } } @@ -99,14 +76,6 @@ impl GrabStartData { ((new.x - old.x).powi(2) + (new.y - old.y).powi(2)).sqrt() } - - pub fn type_(&self) -> GrabType { - match self { - Self::Pointer(_) => GrabType::Pointer, - Self::Touch(_) => GrabType::Touch, - Self::TabletTool { .. } => GrabType::TabletTool, - } - } } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -234,17 +203,10 @@ impl From for ResizeGrab { } impl ResizeGrab { - pub fn grab_type(&self) -> GrabType { + pub fn is_touch_grab(&self) -> bool { match self { - ResizeGrab::Floating(grab) => grab.grab_type(), - ResizeGrab::Tiling(grab) => grab.grab_type(), - } - } - - pub fn tool(&self) -> Option<&TabletToolDescriptor> { - match self { - ResizeGrab::Floating(grab) => grab.tool(), - ResizeGrab::Tiling(grab) => grab.tool(), + ResizeGrab::Floating(grab) => grab.is_touch_grab(), + ResizeGrab::Tiling(grab) => grab.is_touch_grab(), } } } @@ -280,11 +242,11 @@ impl PointerGrab for ResizeGrab { &mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>, - event: &PointerButtonEvent, + event: &ButtonEvent, ) { match self { - ResizeGrab::Floating(grab) => PointerGrab::button(grab, data, handle, event), - ResizeGrab::Tiling(grab) => PointerGrab::button(grab, data, handle, event), + ResizeGrab::Floating(grab) => grab.button(data, handle, event), + ResizeGrab::Tiling(grab) => grab.button(data, handle, event), } } @@ -292,11 +254,11 @@ impl PointerGrab for ResizeGrab { &mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>, - details: PointerAxisFrame, + details: AxisFrame, ) { match self { - ResizeGrab::Floating(grab) => PointerGrab::axis(grab, data, handle, details), - ResizeGrab::Tiling(grab) => PointerGrab::axis(grab, data, handle, details), + ResizeGrab::Floating(grab) => grab.axis(data, handle, details), + ResizeGrab::Tiling(grab) => grab.axis(data, handle, details), } } @@ -424,7 +386,7 @@ impl TouchGrab for ResizeGrab { data: &mut State, handle: &mut TouchInnerHandle<'_, State>, focus: Option<(PointerFocusTarget, Point)>, - event: &TouchDownEvent, + event: &DownEvent, ) { match self { ResizeGrab::Floating(grab) => TouchGrab::down(grab, data, handle, focus, event), @@ -432,12 +394,7 @@ impl TouchGrab for ResizeGrab { } } - fn up( - &mut self, - data: &mut State, - handle: &mut TouchInnerHandle<'_, State>, - event: &TouchUpEvent, - ) { + fn up(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, event: &UpEvent) { match self { ResizeGrab::Floating(grab) => TouchGrab::up(grab, data, handle, event), ResizeGrab::Tiling(grab) => TouchGrab::up(grab, data, handle, event), @@ -510,107 +467,6 @@ impl TouchGrab for ResizeGrab { } } -impl TabletToolGrab for ResizeGrab { - fn down( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletDownEvent, - ) { - match self { - ResizeGrab::Floating(grab) => TabletToolGrab::down(grab, data, handle, event), - ResizeGrab::Tiling(grab) => TabletToolGrab::down(grab, data, handle, event), - } - } - - fn up( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletUpEvent, - ) { - match self { - ResizeGrab::Floating(grab) => TabletToolGrab::up(grab, data, handle, event), - ResizeGrab::Tiling(grab) => TabletToolGrab::up(grab, data, handle, event), - } - } - - fn motion( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - focus: Option<(PointerFocusTarget, Point)>, - event: &TabletMotionEvent, - ) { - match self { - ResizeGrab::Floating(grab) => TabletToolGrab::motion(grab, data, handle, focus, event), - ResizeGrab::Tiling(grab) => TabletToolGrab::motion(grab, data, handle, focus, event), - } - } - - fn frame( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - serial: InputTime, - ) { - match self { - ResizeGrab::Floating(grab) => TabletToolGrab::frame(grab, data, handle, serial), - ResizeGrab::Tiling(grab) => TabletToolGrab::frame(grab, data, handle, serial), - } - } - - fn button( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletButtonEvent, - ) { - match self { - ResizeGrab::Floating(grab) => TabletToolGrab::button(grab, data, handle, event), - ResizeGrab::Tiling(grab) => TabletToolGrab::button(grab, data, handle, event), - } - } - - fn axis( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - details: TabletAxisFrame, - ) { - match self { - ResizeGrab::Floating(grab) => TabletToolGrab::axis(grab, data, handle, details), - ResizeGrab::Tiling(grab) => TabletToolGrab::axis(grab, data, handle, details), - } - } - - fn proximity_out( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &ProximityOutEvent, - ) { - match self { - ResizeGrab::Floating(grab) => TabletToolGrab::proximity_out(grab, data, handle, event), - ResizeGrab::Tiling(grab) => TabletToolGrab::proximity_out(grab, data, handle, event), - } - } - - fn start_data(&self) -> &TabletGrabStartData { - match self { - ResizeGrab::Floating(grab) => TabletToolGrab::start_data(grab), - ResizeGrab::Tiling(grab) => TabletToolGrab::start_data(grab), - } - } - - fn unset(&mut self, data: &mut State) { - match self { - ResizeGrab::Floating(grab) => TabletToolGrab::unset(grab, data), - ResizeGrab::Tiling(grab) => TabletToolGrab::unset(grab, data), - } - } -} - pub enum MoveGrab { Move(moving::MoveGrab), Delayed(delay::DelayGrab), @@ -680,17 +536,10 @@ impl MoveGrab { } } - pub fn grab_type(&self) -> GrabType { + pub fn is_touch_grab(&self) -> bool { match self { - MoveGrab::Move(m) => m.grab_type(), - MoveGrab::Delayed(d) => d.grab_type(), - } - } - - pub fn tool(&self) -> Option<&TabletToolDescriptor> { - match self { - MoveGrab::Move(m) => m.tool(), - MoveGrab::Delayed(d) => d.tool(), + MoveGrab::Move(m) => m.is_touch_grab(), + MoveGrab::Delayed(d) => d.is_touch_grab(), } } } @@ -725,11 +574,11 @@ impl PointerGrab for MoveGrab { &mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>, - event: &PointerButtonEvent, + event: &ButtonEvent, ) { match self { - MoveGrab::Move(grab) => PointerGrab::button(grab, data, handle, event), - MoveGrab::Delayed(grab) => PointerGrab::button(grab, data, handle, event), + MoveGrab::Move(grab) => grab.button(data, handle, event), + MoveGrab::Delayed(grab) => grab.button(data, handle, event), } } @@ -737,11 +586,11 @@ impl PointerGrab for MoveGrab { &mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>, - details: PointerAxisFrame, + details: AxisFrame, ) { match self { - MoveGrab::Move(grab) => PointerGrab::axis(grab, data, handle, details), - MoveGrab::Delayed(grab) => PointerGrab::axis(grab, data, handle, details), + MoveGrab::Move(grab) => grab.axis(data, handle, details), + MoveGrab::Delayed(grab) => grab.axis(data, handle, details), } } @@ -869,7 +718,7 @@ impl TouchGrab for MoveGrab { data: &mut State, handle: &mut TouchInnerHandle<'_, State>, focus: Option<(PointerFocusTarget, Point)>, - event: &TouchDownEvent, + event: &DownEvent, ) { match self { MoveGrab::Move(grab) => TouchGrab::down(grab, data, handle, focus, event), @@ -877,12 +726,7 @@ impl TouchGrab for MoveGrab { } } - fn up( - &mut self, - data: &mut State, - handle: &mut TouchInnerHandle<'_, State>, - event: &TouchUpEvent, - ) { + fn up(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, event: &UpEvent) { match self { MoveGrab::Move(grab) => TouchGrab::up(grab, data, handle, event), MoveGrab::Delayed(grab) => TouchGrab::up(grab, data, handle, event), @@ -954,104 +798,3 @@ impl TouchGrab for MoveGrab { } } } - -impl TabletToolGrab for MoveGrab { - fn down( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletDownEvent, - ) { - match self { - MoveGrab::Move(grab) => TabletToolGrab::down(grab, data, handle, event), - MoveGrab::Delayed(grab) => TabletToolGrab::down(grab, data, handle, event), - } - } - - fn up( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletUpEvent, - ) { - match self { - MoveGrab::Move(grab) => TabletToolGrab::up(grab, data, handle, event), - MoveGrab::Delayed(grab) => TabletToolGrab::up(grab, data, handle, event), - } - } - - fn motion( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - focus: Option<(PointerFocusTarget, Point)>, - event: &TabletMotionEvent, - ) { - match self { - MoveGrab::Move(grab) => TabletToolGrab::motion(grab, data, handle, focus, event), - MoveGrab::Delayed(grab) => TabletToolGrab::motion(grab, data, handle, focus, event), - } - } - - fn frame( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - serial: InputTime, - ) { - match self { - MoveGrab::Move(grab) => TabletToolGrab::frame(grab, data, handle, serial), - MoveGrab::Delayed(grab) => TabletToolGrab::frame(grab, data, handle, serial), - } - } - - fn button( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletButtonEvent, - ) { - match self { - MoveGrab::Move(grab) => TabletToolGrab::button(grab, data, handle, event), - MoveGrab::Delayed(grab) => TabletToolGrab::button(grab, data, handle, event), - } - } - - fn axis( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - details: TabletAxisFrame, - ) { - match self { - MoveGrab::Move(grab) => TabletToolGrab::axis(grab, data, handle, details), - MoveGrab::Delayed(grab) => TabletToolGrab::axis(grab, data, handle, details), - } - } - - fn proximity_out( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &ProximityOutEvent, - ) { - match self { - MoveGrab::Move(grab) => TabletToolGrab::proximity_out(grab, data, handle, event), - MoveGrab::Delayed(grab) => TabletToolGrab::proximity_out(grab, data, handle, event), - } - } - - fn start_data(&self) -> &TabletGrabStartData { - match self { - MoveGrab::Move(grab) => TabletToolGrab::start_data(grab), - MoveGrab::Delayed(grab) => TabletToolGrab::start_data(grab), - } - } - - fn unset(&mut self, data: &mut State) { - match self { - MoveGrab::Move(grab) => TabletToolGrab::unset(grab, data), - MoveGrab::Delayed(grab) => TabletToolGrab::unset(grab, data), - } - } -} diff --git a/src/shell/grabs/moving.rs b/src/shell/grabs/moving.rs index f1fbfa8a..d8714830 100644 --- a/src/shell/grabs/moving.rs +++ b/src/shell/grabs/moving.rs @@ -8,7 +8,6 @@ use crate::{ CosmicMapped, CosmicSurface, Direction, ManagedLayer, element::{CosmicMappedRenderElement, stack_hover::StackHover}, focus::target::{KeyboardFocusTarget, PointerFocusTarget}, - grabs::GrabType, layout::floating::TiledCorners, }, utils::prelude::*, @@ -21,7 +20,7 @@ use smallvec::SmallVec; use smithay::{ backend::{ drm::DrmNode, - input::{ButtonState, InputTime, TabletToolDescriptor}, + input::ButtonState, renderer::{ ImportAll, ImportMem, element::{RenderElement, utils::RescaleRenderElement}, @@ -31,27 +30,13 @@ use smithay::{ input::{ Seat, pointer::{ - AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, CursorIcon, - GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, - GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, - GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData, - MotionEvent as PointerMotionEvent, PointerGrab, PointerInnerHandle, + AxisFrame, ButtonEvent, CursorIcon, GestureHoldBeginEvent, GestureHoldEndEvent, + GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, + GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, + GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle, RelativeMotionEvent, }, - tablet::{ - TabletSeatHandler, - tool::{ - AxisFrame as TabletAxisFrame, ButtonEvent as TabletButtonEvent, - DownEvent as TabletDownEvent, GrabStartData as TabletGrabStartData, - MotionEvent as TabletMotionEvent, ProximityInEvent, ProximityOutEvent, - TabletToolGrab, TabletToolInnerHandle, UpEvent as TabletUpEvent, - }, - }, - touch::{ - DownEvent as TouchDownEvent, GrabStartData as TouchGrabStartData, - MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchGrab, - TouchInnerHandle, UpEvent as TouchUpEvent, - }, + touch::{self, GrabStartData as TouchGrabStartData, TouchGrab, TouchInnerHandle}, }, output::Output, utils::{IsAlive, Logical, Point, Rectangle, SERIAL_COUNTER, Scale}, @@ -518,7 +503,7 @@ impl PointerGrab for MoveGrab { state: &mut State, handle: &mut PointerInnerHandle<'_, State>, _focus: Option<(PointerFocusTarget, Point)>, - event: &PointerMotionEvent, + event: &MotionEvent, ) { self.update_location(state, event.location); @@ -544,7 +529,7 @@ impl PointerGrab for MoveGrab { &mut self, state: &mut State, handle: &mut PointerInnerHandle<'_, State>, - event: &PointerButtonEvent, + event: &ButtonEvent, ) { handle.button(state, event); match self.release { @@ -565,7 +550,7 @@ impl PointerGrab for MoveGrab { &mut self, state: &mut State, handle: &mut PointerInnerHandle<'_, State>, - details: PointerAxisFrame, + details: AxisFrame, ) { handle.axis(state, details); } @@ -662,7 +647,7 @@ impl TouchGrab for MoveGrab { data: &mut State, handle: &mut TouchInnerHandle<'_, State>, _focus: Option<(PointerFocusTarget, Point)>, - event: &TouchDownEvent, + event: &touch::DownEvent, ) { handle.down(data, None, event) } @@ -671,7 +656,7 @@ impl TouchGrab for MoveGrab { &mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, - event: &TouchUpEvent, + event: &touch::UpEvent, ) { if event.slot == >::start_data(self).slot { handle.unset_grab(self, data); @@ -685,7 +670,7 @@ impl TouchGrab for MoveGrab { data: &mut State, handle: &mut TouchInnerHandle<'_, State>, _focus: Option<(PointerFocusTarget, Point)>, - event: &TouchMotionEvent, + event: &touch::MotionEvent, ) { if event.slot == >::start_data(self).slot { self.update_location(data, event.location); @@ -706,7 +691,7 @@ impl TouchGrab for MoveGrab { &mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, - event: &ShapeEvent, + event: &touch::ShapeEvent, ) { handle.shape(data, event) } @@ -715,7 +700,7 @@ impl TouchGrab for MoveGrab { &mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, - event: &OrientationEvent, + event: &touch::OrientationEvent, ) { handle.orientation(data, event) } @@ -730,98 +715,6 @@ impl TouchGrab for MoveGrab { fn unset(&mut self, _data: &mut State) {} } -impl TabletToolGrab for MoveGrab { - fn start_data(&self) -> &TabletGrabStartData { - match &self.start_data { - GrabStartData::TabletTool { data, .. } => data, - _ => unreachable!(), - } - } - - fn proximity_out( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &ProximityOutEvent, - ) { - handle.proximity_out(data, event); - handle.unset_grab(self, data, event.serial, event.time, false); - } - - fn motion( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - _focus: Option<(::ToolFocus, Point)>, - event: &TabletMotionEvent, - ) { - handle.motion(data, None, event); - - self.update_location(data, event.location); - if !self.window.alive() { - handle.unset_grab(self, data, event.serial, event.time, true); - } - } - - fn down( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletDownEvent, - ) { - handle.down(data, event) - } - - fn up( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletUpEvent, - ) { - handle.up(data, event); - handle.unset_grab(self, data, event.serial, event.time, false); - } - - fn button( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletButtonEvent, - ) { - handle.button(data, event) - } - - fn axis( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - frame: TabletAxisFrame, - ) { - handle.axis(data, frame) - } - - fn frame( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - time: InputTime, - ) { - handle.frame(data, time) - } - - fn proximity_in( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - focus: Option<(::ToolFocus, Point)>, - event: &ProximityInEvent, - ) { - handle.proximity_in(data, focus, event); - } - - fn unset(&mut self, _data: &mut State) {} -} - impl MoveGrab { pub fn new( start_data: GrabStartData, @@ -885,15 +778,10 @@ impl MoveGrab { self.previous == ManagedLayer::Tiling } - pub fn grab_type(&self) -> GrabType { - self.start_data.type_() - } - - pub fn tool(&self) -> Option<&TabletToolDescriptor> { - if let GrabStartData::TabletTool { tool, .. } = &self.start_data { - Some(tool) - } else { - None + pub fn is_touch_grab(&self) -> bool { + match self.start_data { + GrabStartData::Touch(_) => true, + GrabStartData::Pointer(_) => false, } } } @@ -905,7 +793,7 @@ impl Drop for MoveGrab { let seat = self.seat.clone(); // false-positive: `Output`s hash is based on it's inner ptr #[allow(clippy::mutable_key_type)] - let window_outputs = std::mem::take(&mut self.window_outputs); + let window_outputs = self.window_outputs.drain().collect::>(); let previous = self.previous; let window = self.window.clone(); let is_touch_grab = matches!(self.start_data, GrabStartData::Touch(_)); @@ -1065,10 +953,10 @@ impl Drop for MoveGrab { position.as_logical().to_f64() - window.geometry().loc.to_f64() + offset, )), - &PointerMotionEvent { + &MotionEvent { location: pointer.current_location(), serial, - time: InputTime::now(), + time: state.common.clock.now().as_millis(), }, ); } diff --git a/src/shell/layout/floating/grabs/resize.rs b/src/shell/layout/floating/grabs/resize.rs index 9d767671..f9e5cbfd 100644 --- a/src/shell/layout/floating/grabs/resize.rs +++ b/src/shell/layout/floating/grabs/resize.rs @@ -7,36 +7,25 @@ use crate::{ shell::{ element::CosmicMapped, focus::target::PointerFocusTarget, - grabs::{GrabStartData, GrabType, ReleaseMode, ResizeEdge}, + grabs::{GrabStartData, ReleaseMode, ResizeEdge}, }, utils::prelude::*, }; use smithay::{ - backend::input::{ButtonState, InputTime, TabletToolDescriptor}, + backend::input::ButtonState, desktop::{WindowSurface, space::SpaceElement}, input::{ Seat, pointer::{ - AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, CursorIcon, - GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, - GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, - GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData, - MotionEvent as PointerMotionEvent, PointerGrab, PointerInnerHandle, + AxisFrame, ButtonEvent, CursorIcon, GestureHoldBeginEvent, GestureHoldEndEvent, + GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, + GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, + GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle, RelativeMotionEvent, }, - tablet::{ - TabletSeatHandler, - tool::{ - AxisFrame as TabletAxisFrame, ButtonEvent as TabletButtonEvent, - DownEvent as TabletDownEvent, GrabStartData as TabletGrabStartData, - MotionEvent as TabletMotionEvent, ProximityInEvent, ProximityOutEvent, - TabletToolGrab, TabletToolInnerHandle, UpEvent as TabletUpEvent, - }, - }, touch::{ - DownEvent as TouchDownEvent, GrabStartData as TouchGrabStartData, - MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchGrab, - TouchInnerHandle, UpEvent as TouchUpEvent, + DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent, + OrientationEvent, ShapeEvent, TouchGrab, TouchInnerHandle, UpEvent, }, }, output::Output, @@ -181,19 +170,10 @@ impl ResizeSurfaceGrab { false } - pub fn grab_type(&self) -> GrabType { + pub fn is_touch_grab(&self) -> bool { match self.start_data { - GrabStartData::Pointer(_) => GrabType::Pointer, - GrabStartData::Touch(_) => GrabType::Touch, - GrabStartData::TabletTool { .. } => GrabType::TabletTool, - } - } - - pub fn tool(&self) -> Option<&TabletToolDescriptor> { - if let GrabStartData::TabletTool { tool, .. } = &self.start_data { - Some(tool) - } else { - None + GrabStartData::Touch(_) => true, + GrabStartData::Pointer(_) => false, } } } @@ -204,7 +184,7 @@ impl PointerGrab for ResizeSurfaceGrab { data: &mut State, handle: &mut PointerInnerHandle<'_, State>, _focus: Option<(PointerFocusTarget, Point)>, - event: &PointerMotionEvent, + event: &MotionEvent, ) { // While the grab is active, no client has pointer focus handle.motion(data, None, event); @@ -229,7 +209,7 @@ impl PointerGrab for ResizeSurfaceGrab { &mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>, - event: &PointerButtonEvent, + event: &ButtonEvent, ) { handle.button(data, event); match self.release { @@ -250,7 +230,7 @@ impl PointerGrab for ResizeSurfaceGrab { &mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>, - details: PointerAxisFrame, + details: AxisFrame, ) { handle.axis(data, details) } @@ -349,17 +329,12 @@ impl TouchGrab for ResizeSurfaceGrab { data: &mut State, handle: &mut TouchInnerHandle<'_, State>, _focus: Option<(PointerFocusTarget, Point)>, - event: &TouchDownEvent, + event: &DownEvent, ) { handle.down(data, None, event) } - fn up( - &mut self, - data: &mut State, - handle: &mut TouchInnerHandle<'_, State>, - event: &TouchUpEvent, - ) { + fn up(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, event: &UpEvent) { if event.slot == >::start_data(self).slot { handle.unset_grab(self, data); } @@ -421,99 +396,6 @@ impl TouchGrab for ResizeSurfaceGrab { } } -impl TabletToolGrab for ResizeSurfaceGrab { - fn start_data(&self) -> &TabletGrabStartData { - match &self.start_data { - GrabStartData::TabletTool { data, .. } => data, - _ => unreachable!(), - } - } - - fn proximity_out( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &ProximityOutEvent, - ) { - handle.unset_grab(self, data, event.serial, event.time, true); - handle.proximity_out(data, event); - } - - fn motion( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - _focus: Option<(::ToolFocus, Point)>, - event: &TabletMotionEvent, - ) { - if self.update_location(event.location.as_global()) { - handle.unset_grab(self, data, event.serial, event.time, true); - } - - handle.motion(data, None, event); - } - - fn down( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletDownEvent, - ) { - handle.down(data, event) - } - - fn up( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletUpEvent, - ) { - handle.unset_grab(self, data, event.serial, event.time, true); - handle.up(data, event); - } - - fn button( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletButtonEvent, - ) { - handle.button(data, event) - } - - fn axis( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - frame: TabletAxisFrame, - ) { - handle.axis(data, frame) - } - - fn frame( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - time: InputTime, - ) { - handle.frame(data, time) - } - - fn unset(&mut self, _data: &mut State) { - self.ungrab() - } - - fn proximity_in( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - _focus: Option<(::ToolFocus, Point)>, - event: &ProximityInEvent, - ) { - handle.proximity_in(data, None, event); - } -} - pub struct ResizeGrabMarker(AtomicBool); impl ResizeGrabMarker { diff --git a/src/shell/layout/tiling/grabs/resize.rs b/src/shell/layout/tiling/grabs/resize.rs index c6f202cf..9b135119 100644 --- a/src/shell/layout/tiling/grabs/resize.rs +++ b/src/shell/layout/tiling/grabs/resize.rs @@ -4,42 +4,31 @@ use crate::{ backend::render::cursor::CursorState, shell::{ focus::target::PointerFocusTarget, - grabs::{GrabStartData, GrabType, ReleaseMode}, + grabs::{GrabStartData, ReleaseMode}, layout::Orientation, }, utils::prelude::*, }; use id_tree::{NodeId, Tree}; use smithay::{ - backend::input::{ButtonState, InputTime, TabletToolDescriptor}, + backend::input::ButtonState, input::{ Seat, pointer::{ - AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, CursorIcon, Focus, - GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, - GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, - GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData, - MotionEvent as PointerMotionEvent, PointerGrab, PointerInnerHandle, PointerTarget, - RelativeMotionEvent, - }, - tablet::{ - Tablet, TabletSeatHandler, TabletSeatTrait, - tool::{ - AxisFrame as TabletAxisFrame, ButtonEvent as TabletButtonEvent, - DownEvent as TabletDownEvent, GrabStartData as TabletToolGrabStartData, - GrabTrigger as TabletToolGrabTrigger, MotionEvent as TabletMotionEvent, - ProximityInEvent, ProximityOutEvent, TabletToolGrab, TabletToolInnerHandle, - TabletToolTarget, UpEvent as TabletUpEvent, - }, + AxisFrame, ButtonEvent, CursorIcon, Focus, GestureHoldBeginEvent, GestureHoldEndEvent, + GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, + GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, + GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle, + PointerTarget, RelativeMotionEvent, }, touch::{ - DownEvent as TouchDownEvent, FrameMarker, GrabStartData as TouchGrabStartData, + DownEvent, FrameMarker, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchGrab, - TouchInnerHandle, TouchTarget, UpEvent as TouchUpEvent, + TouchInnerHandle, TouchTarget, UpEvent, }, }, output::WeakOutput, - utils::{IsAlive, Logical, Point, Serial}, + utils::{IsAlive, Logical, Point}, }; use super::super::{Data, TilingLayout}; @@ -59,7 +48,7 @@ impl IsAlive for ResizeForkTarget { } impl PointerTarget for ResizeForkTarget { - fn enter(&self, seat: &Seat, _data: &mut State, _event: &PointerMotionEvent) { + fn enter(&self, seat: &Seat, _data: &mut State, _event: &MotionEvent) { let user_data = seat.user_data(); let cursor_state = user_data.get::().unwrap(); cursor_state @@ -71,13 +60,19 @@ impl PointerTarget for ResizeForkTarget { }); } - fn leave(&self, seat: &Seat, _data: &mut State, _serial: Serial, _time: InputTime) { + fn leave( + &self, + seat: &Seat, + _data: &mut State, + _serial: smithay::utils::Serial, + _time: u32, + ) { let user_data = seat.user_data(); let cursor_state = user_data.get::().unwrap(); cursor_state.lock().unwrap().unset_shape(); } - fn button(&self, seat: &Seat, data: &mut State, event: &PointerButtonEvent) { + fn button(&self, seat: &Seat, data: &mut State, event: &ButtonEvent) { if event.button == 0x110 && event.state == ButtonState::Pressed { let seat = seat.clone(); let node = self.node.clone(); @@ -111,7 +106,7 @@ impl PointerTarget for ResizeForkTarget { } } - fn motion(&self, _seat: &Seat, _data: &mut State, _event: &PointerMotionEvent) {} + fn motion(&self, _seat: &Seat, _data: &mut State, _event: &MotionEvent) {} fn relative_motion( &self, _seat: &Seat, @@ -119,7 +114,7 @@ impl PointerTarget for ResizeForkTarget { _event: &RelativeMotionEvent, ) { } - fn axis(&self, _seat: &Seat, _data: &mut State, _frame: PointerAxisFrame) {} + fn axis(&self, _seat: &Seat, _data: &mut State, _frame: AxisFrame) {} fn frame(&self, _seat: &Seat, _data: &mut State) {} fn gesture_swipe_begin(&self, _: &Seat, _: &mut State, _: &GestureSwipeBeginEvent) {} fn gesture_swipe_update(&self, _: &Seat, _: &mut State, _: &GestureSwipeUpdateEvent) {} @@ -132,7 +127,7 @@ impl PointerTarget for ResizeForkTarget { } impl TouchTarget for ResizeForkTarget { - fn down(&self, seat: &Seat, data: &mut State, event: &TouchDownEvent) { + fn down(&self, seat: &Seat, data: &mut State, event: &DownEvent) { let seat = seat.clone(); let node = self.node.clone(); let output = self.output.clone(); @@ -163,7 +158,7 @@ impl TouchTarget for ResizeForkTarget { }); } - fn up(&self, _seat: &Seat, _data: &mut State, _event: &TouchUpEvent) {} + fn up(&self, _seat: &Seat, _data: &mut State, _event: &UpEvent) {} fn motion(&self, _seat: &Seat, _data: &mut State, _event: &TouchMotionEvent) {} fn frame(&self, _seat: &Seat, _data: &mut State, _frame: FrameMarker) {} fn cancel(&self, _seat: &Seat, _data: &mut State, _frame: FrameMarker) {} @@ -174,121 +169,6 @@ impl TouchTarget for ResizeForkTarget { } } -impl TabletToolTarget for ResizeForkTarget { - fn down( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &TabletDownEvent, - ) { - let seat = seat.clone(); - let node = self.node.clone(); - let output = self.output.clone(); - let left_up_idx = self.left_up_idx; - let orientation = self.orientation; - let serial = event.serial; - let time = event.time; - let tool = tool_descriptor.clone(); - data.common.event_loop_handle.insert_idle(move |state| { - let pointer = seat.get_pointer().unwrap(); - let location = pointer.current_location(); - let tablet = seat.tablet_seat().get_tool(&tool).unwrap(); - tablet.set_grab( - state, - ResizeForkGrab::new( - GrabStartData::TabletTool { - tool, - data: TabletToolGrabStartData { - focus: None, - location, - trigger: TabletToolGrabTrigger::Tip, - }, - }, - location.as_global(), - node, - left_up_idx, - orientation, - output, - ReleaseMode::NoMouseButtons, - ), - time, - serial, - Focus::Keep, - ) - }); - } - fn motion( - &self, - _seat: &Seat, - _data: &mut State, - _tool_descriptor: &TabletToolDescriptor, - _event: &TabletMotionEvent, - ) { - } - fn proximity_out( - &self, - seat: &Seat, - _data: &mut State, - _tool_descriptor: &TabletToolDescriptor, - ) { - let user_data = seat.user_data(); - let cursor_state = user_data.get::().unwrap(); - cursor_state.lock().unwrap().unset_shape(); - } - - fn proximity_in( - &self, - seat: &Seat, - _data: &mut State, - _tool_descriptor: &TabletToolDescriptor, - _tablet: &Tablet, - _serial: Serial, - ) { - let user_data = seat.user_data(); - let cursor_state = user_data.get::().unwrap(); - cursor_state - .lock() - .unwrap() - .set_shape(match self.orientation { - Orientation::Horizontal => CursorIcon::RowResize, - Orientation::Vertical => CursorIcon::ColResize, - }); - } - fn up( - &self, - _seat: &Seat, - _data: &mut State, - _tool_descriptor: &TabletToolDescriptor, - _event: &TabletUpEvent, - ) { - } - fn axis( - &self, - _seat: &Seat, - _data: &mut State, - _tool_descriptor: &TabletToolDescriptor, - _frame: TabletAxisFrame, - ) { - } - fn button( - &self, - _seat: &Seat, - _data: &mut State, - _tool_descriptor: &TabletToolDescriptor, - _event: &TabletButtonEvent, - ) { - } - fn frame( - &self, - _seat: &Seat, - _data: &mut State, - _tool_descriptor: &TabletToolDescriptor, - _time: InputTime, - ) { - } -} - pub struct ResizeForkGrab { start_data: GrabStartData, last_loc: Point, @@ -458,19 +338,10 @@ impl ResizeForkGrab { false } - pub fn grab_type(&self) -> GrabType { + pub fn is_touch_grab(&self) -> bool { match self.start_data { - GrabStartData::Pointer(_) => GrabType::Pointer, - GrabStartData::Touch(_) => GrabType::Touch, - GrabStartData::TabletTool { .. } => GrabType::TabletTool, - } - } - - pub fn tool(&self) -> Option<&TabletToolDescriptor> { - if let GrabStartData::TabletTool { tool, .. } = &self.start_data { - Some(tool) - } else { - None + GrabStartData::Touch(_) => true, + GrabStartData::Pointer(_) => false, } } } @@ -481,7 +352,7 @@ impl PointerGrab for ResizeForkGrab { data: &mut State, handle: &mut PointerInnerHandle<'_, State>, _focus: Option<(PointerFocusTarget, Point)>, - event: &PointerMotionEvent, + event: &MotionEvent, ) { // While the grab is active, no client has pointer focus handle.motion(data, None, event); @@ -506,7 +377,7 @@ impl PointerGrab for ResizeForkGrab { &mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>, - event: &PointerButtonEvent, + event: &ButtonEvent, ) { handle.button(data, event); match self.release { @@ -527,7 +398,7 @@ impl PointerGrab for ResizeForkGrab { &mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>, - details: PointerAxisFrame, + details: AxisFrame, ) { handle.axis(data, details) } @@ -626,17 +497,12 @@ impl TouchGrab for ResizeForkGrab { data: &mut State, handle: &mut TouchInnerHandle<'_, State>, _focus: Option<(PointerFocusTarget, Point)>, - event: &TouchDownEvent, + event: &DownEvent, ) { handle.down(data, None, event) } - fn up( - &mut self, - data: &mut State, - handle: &mut TouchInnerHandle<'_, State>, - event: &TouchUpEvent, - ) { + fn up(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, event: &UpEvent) { if event.slot == >::start_data(self).slot { handle.unset_grab(self, data); } @@ -697,96 +563,3 @@ impl TouchGrab for ResizeForkGrab { self.update_location(data, self.last_loc.as_logical(), true); } } - -impl TabletToolGrab for ResizeForkGrab { - fn start_data(&self) -> &TabletToolGrabStartData { - match &self.start_data { - GrabStartData::TabletTool { data, .. } => data, - _ => unreachable!(), - } - } - - fn proximity_out( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &ProximityOutEvent, - ) { - handle.proximity_out(data, event); - handle.unset_grab(self, data, event.serial, event.time, true); - } - - fn motion( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - _focus: Option<(::ToolFocus, Point)>, - event: &TabletMotionEvent, - ) { - handle.motion(data, None, event); - - if self.update_location(data, event.location, false) { - handle.unset_grab(self, data, event.serial, event.time, true); - } - } - - fn down( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletDownEvent, - ) { - handle.down(data, event); - } - - fn up( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletUpEvent, - ) { - handle.up(data, event); - handle.unset_grab(self, data, event.serial, event.time, true); - } - - fn button( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - event: &TabletButtonEvent, - ) { - handle.button(data, event) - } - - fn axis( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - frame: TabletAxisFrame, - ) { - handle.axis(data, frame) - } - - fn frame( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - time: InputTime, - ) { - handle.frame(data, time) - } - - fn unset(&mut self, data: &mut State) { - self.update_location(data, self.last_loc.as_logical(), true); - } - - fn proximity_in( - &mut self, - data: &mut State, - handle: &mut TabletToolInnerHandle<'_, State>, - focus: Option<(::ToolFocus, Point)>, - event: &ProximityInEvent, - ) { - handle.proximity_in(data, focus, event); - } -} diff --git a/src/shell/layout/tiling/grabs/swap.rs b/src/shell/layout/tiling/grabs/swap.rs index 9ac531d3..afe93cf0 100644 --- a/src/shell/layout/tiling/grabs/swap.rs +++ b/src/shell/layout/tiling/grabs/swap.rs @@ -1,6 +1,6 @@ use cosmic_settings_config::shortcuts; use smithay::{ - backend::input::{InputTime, KeyState, Keycode}, + backend::input::{KeyState, Keycode}, input::{ Seat, SeatHandler, keyboard::{ @@ -38,7 +38,7 @@ impl KeyboardGrab for SwapWindowGrab { state: KeyState, modifiers: Option, serial: Serial, - time: InputTime, + time: u32, ) { if !matches!(&data.common.shell.read().overview_mode.active_trigger(), Some(Trigger::KeyboardSwap(_, d)) if d == &self.desc) { diff --git a/src/shell/layout/tiling/mod.rs b/src/shell/layout/tiling/mod.rs index 8706dc59..2d95cd27 100644 --- a/src/shell/layout/tiling/mod.rs +++ b/src/shell/layout/tiling/mod.rs @@ -3381,7 +3381,7 @@ impl TilingLayout { let Some(root) = tree.root_node_id() else { if matches!( overview.active_trigger(), - Some(Trigger::Pointer(_) | Trigger::Touch(_) | Trigger::Tool(_, _)) + Some(Trigger::Pointer(_) | Trigger::Touch(_)) ) && location_f64.is_some() { let mut tree = tree.copy_clone(); @@ -3414,7 +3414,7 @@ impl TilingLayout { if matches!( overview.active_trigger(), - Some(Trigger::Pointer(_) | Trigger::Touch(_) | Trigger::Tool(_, _)) + Some(Trigger::Pointer(_) | Trigger::Touch(_)) ) { let non_exclusive_zone = layer_map_for_output(&self.output) .non_exclusive_zone() @@ -4062,11 +4062,8 @@ impl TilingLayout { let draw_groups = overview.0.alpha(); let is_overview = !matches!(overview.0, OverviewMode::None); - let is_mouse_tiling = (matches!( - overview.0.trigger(), - Some(Trigger::Pointer(_) | Trigger::Tool(_, _)) - )) - .then(|| self.last_overview_hover.as_ref().map(|(_, zone)| zone)); + let is_mouse_tiling = (matches!(overview.0.trigger(), Some(Trigger::Pointer(_)))) + .then(|| self.last_overview_hover.as_ref().map(|(_, zone)| zone)); let swap_desc = if let Some(Trigger::KeyboardSwap(_, desc)) = overview.0.trigger() { Some(desc.clone()) } else { @@ -4219,11 +4216,8 @@ impl TilingLayout { }; let draw_groups = overview.0.alpha(); - let is_mouse_tiling = (matches!( - overview.0.trigger(), - Some(Trigger::Pointer(_) | Trigger::Tool(_, _)) - )) - .then(|| self.last_overview_hover.as_ref().map(|(_, zone)| zone)); + let is_mouse_tiling = (matches!(overview.0.trigger(), Some(Trigger::Pointer(_)))) + .then(|| self.last_overview_hover.as_ref().map(|(_, zone)| zone)); let swap_desc = if let Some(Trigger::KeyboardSwap(_, desc)) = overview.0.trigger() { Some(desc.clone()) } else { diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 8439b13f..009c98dc 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -19,10 +19,7 @@ use crate::{ utils, wayland::{ handlers::data_device::{self, get_dnd_icon}, - protocols::{ - session_lock_layer::layer_show_on_lock, - workspace::{State as WState, WorkspaceCapabilities}, - }, + protocols::workspace::{State as WState, WorkspaceCapabilities}, }, }; use cosmic_comp_config::{ @@ -35,10 +32,7 @@ use cosmic_settings_config::shortcuts::action::{Direction, FocusDirection, Resiz use cosmic_settings_config::{shortcuts, window_rules::ApplicationException}; use keyframe::{ease, functions::EaseInOutCubic}; use smithay::{ - backend::{ - input::{TabletToolDescriptor, TouchSlot}, - renderer::element::RenderElementStates, - }, + backend::{input::TouchSlot, renderer::element::RenderElementStates}, desktop::{ LayerSurface, PopupKind, WindowSurface, WindowSurfaceType, layer_map_for_output, space::SpaceElement, @@ -52,7 +46,6 @@ use smithay::{ pointer::{ CursorImageStatus, CursorImageSurfaceData, Focus, GrabStartData as PointerGrabStartData, }, - tablet::{TabletSeatTrait, tool::GrabTrigger as TabletGrabTrigger}, }, output::{Output, WeakOutput}, reexports::{ @@ -137,7 +130,6 @@ pub enum Trigger { KeyboardMove(shortcuts::Modifiers), Pointer(u32), Touch(TouchSlot), - Tool(TabletToolDescriptor, TabletGrabTrigger), } #[derive(Debug, Clone)] @@ -262,7 +254,6 @@ pub struct PendingWindow { pub surface: CosmicSurface, pub seat: Seat, pub fullscreen: Option, - pub minimized: bool, pub maximized: bool, pub sticky: bool, } @@ -1763,7 +1754,7 @@ impl Shell { if let Some(set) = self.workspaces.sets.get_mut(output) { if matches!( self.overview_mode.active_trigger(), - Some(Trigger::Pointer(_) | Trigger::Touch(_) | Trigger::Tool(_, _)) + Some(Trigger::Pointer(_) | Trigger::Touch(_)) ) { set.workspaces[set.active].tiling_layer.cleanup_drag(); } @@ -1814,7 +1805,7 @@ impl Shell { if let Some(set) = self.workspaces.sets.get_mut(output) { if matches!( self.overview_mode.active_trigger(), - Some(Trigger::Pointer(_) | Trigger::Touch(_) | Trigger::Tool(_, _)) + Some(Trigger::Pointer(_) | Trigger::Touch(_)) ) { set.workspaces[set.active].tiling_layer.cleanup_drag(); } @@ -2049,27 +2040,12 @@ impl Shell { } pub fn visible_output_for_surface(&self, surface: &WlSurface) -> Option<&Output> { - // NOTE: Keep in sync with surface iteration in `render_input_order_internal` - if let Some(session_lock) = &self.session_lock { - if let Some((output, _)) = session_lock + return session_lock .surfaces .iter() .find(|(_, v)| v.wl_surface() == surface) - { - return Some(output); - } - for o in self.outputs() { - let map = layer_map_for_output(o); - if let Some(layer_surface) = map.layer_for_surface(surface, WindowSurfaceType::ALL) - { - if layer_show_on_lock(layer_surface.wl_surface()) { - return Some(o); - } else { - return None; - } - } - } + .map(|(k, _)| k); } self.outputs() @@ -2880,7 +2856,6 @@ impl Shell { surface: window, seat, fullscreen: output, - minimized: should_be_minimized, maximized: should_be_maximized, sticky: mut should_be_sticky, } = self.pending_windows.remove(pos); @@ -2964,7 +2939,6 @@ impl Shell { if let Some(FocusTarget::Window(focused)) = maybe_focused && let Some(stack) = focused.stack_ref() && !is_dialog - && !should_be_minimized && !should_be_maximized && !(workspace.is_tiled(&focused.active_window()) && floating_exception) { @@ -3014,13 +2988,8 @@ impl Shell { self.maximize_request(&mapped, &seat, false, loop_handle); } - if should_be_minimized { - self.minimize_request(&window); - } - - let new_target = if should_be_minimized { - None - } else if (workspace_output == seat.active_output() && active_handle == workspace_handle) + let new_target = if (workspace_output == seat.active_output() + && active_handle == workspace_handle) || should_be_sticky { // TODO: enforce focus stealing prevention by also checking the same rules as for the else case. @@ -3144,7 +3113,6 @@ impl Shell { surface, seat: seat.clone(), fullscreen: None, - minimized: false, maximized: false, sticky: false, }); @@ -3863,7 +3831,6 @@ impl Shell { let trigger = match &start_data { GrabStartData::Pointer(start_data) => Trigger::Pointer(start_data.button), GrabStartData::Touch(start_data) => Trigger::Touch(start_data.slot), - GrabStartData::TabletTool { tool, data } => Trigger::Tool(tool.clone(), data.trigger), }; let active_hint = if config.cosmic_conf.active_hint { self.theme.cosmic().active_hint as u8 @@ -5182,19 +5149,10 @@ pub fn check_grab_preconditions( let pointer = seat.get_pointer().unwrap(); let touch = seat.get_touch().unwrap(); - let tablet = seat.tablet_seat(); - let tools = tablet.get_tools(); let start_data = if serial.is_some_and(|serial| touch.has_grab(serial)) { GrabStartData::Touch(touch.grab_start_data().unwrap()) - } else if let Some((desc, tool)) = - serial.and_then(|serial| tools.iter().find(|(_, tool)| tool.has_grab(serial))) - { - GrabStartData::TabletTool { - tool: desc.clone(), - data: tool.grab_start_data().unwrap(), - } } else { GrabStartData::Pointer(pointer.grab_start_data().unwrap_or_else(|| { PointerGrabStartData { @@ -5208,16 +5166,8 @@ pub fn check_grab_preconditions( if let Some(surface) = client_initiated { // Check that this surface has a click or touch down grab. if !match serial { - Some(serial) => { - pointer.has_grab(serial) - || touch.has_grab(serial) - || tools.values().any(|tool| tool.has_grab(serial)) - } - None => { - pointer.is_grabbed() - || touch.is_grabbed() - || tools.values().any(|tool| tool.is_grabbed()) - } + Some(serial) => pointer.has_grab(serial) || touch.has_grab(serial), + None => pointer.is_grabbed() | touch.is_grabbed(), } { return None; } diff --git a/src/shell/zoom.rs b/src/shell/zoom.rs index dcddfb27..25a16e9c 100644 --- a/src/shell/zoom.rs +++ b/src/shell/zoom.rs @@ -11,31 +11,19 @@ use cosmic_comp_config::{ZoomConfig, ZoomMovement}; use cosmic_config::ConfigSet; use keyframe::{ease, functions::Linear}; use smithay::{ - backend::{ - input::{InputTime, TabletToolDescriptor}, - renderer::ImportMem, - }, + backend::renderer::ImportMem, desktop::space::SpaceElement, input::{ Seat, pointer::{ - AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, Focus, - GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, - GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, - GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent as PointerMotionEvent, - PointerTarget, RelativeMotionEvent, - }, - tablet::{ - Tablet, TabletSeatTrait, - tool::{ - AxisFrame as TabletAxisFrame, ButtonEvent as TabletButtonEvent, - DownEvent as TabletDownEvent, MotionEvent as TabletMotionEvent, TabletToolTarget, - UpEvent as TabletUpEvent, - }, + AxisFrame, ButtonEvent, Focus, GestureHoldBeginEvent, GestureHoldEndEvent, + GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, + GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, + MotionEvent as PointerMotionEvent, PointerTarget, RelativeMotionEvent, }, touch::{ - DownEvent as TouchDownEvent, FrameMarker, MotionEvent as TouchMotionEvent, - OrientationEvent, ShapeEvent, TouchTarget, UpEvent as TouchUpEvent, + DownEvent, FrameMarker, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, + TouchTarget, UpEvent, }, }, output::Output, @@ -45,7 +33,6 @@ use tracing::error; use crate::{ backend::render::element::AsGlowRenderer, - shell::grabs::GrabType, state::State, utils::{ iced::{IcedElement, IcedRenderElement, Program}, @@ -712,27 +699,15 @@ impl Program for ZoomProgram { ); std::mem::drop(shell); - match grab.grab_type() { - GrabType::Touch => { - seat.get_touch().unwrap().set_grab(state, grab, serial) - } - GrabType::Pointer => seat.get_pointer().unwrap().set_grab( + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab(state, grab, serial); + } else { + seat.get_pointer().unwrap().set_grab( state, grab, serial, Focus::Clear, - ), - GrabType::TabletTool => seat - .tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab( - state, - grab, - InputTime::now(), - serial, - Focus::Clear, - ), + ); } } } @@ -811,27 +786,15 @@ impl Program for ZoomProgram { ); std::mem::drop(shell); - match grab.grab_type() { - GrabType::Touch => { - seat.get_touch().unwrap().set_grab(state, grab, serial) - } - GrabType::Pointer => seat.get_pointer().unwrap().set_grab( + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab(state, grab, serial); + } else { + seat.get_pointer().unwrap().set_grab( state, grab, serial, Focus::Clear, - ), - GrabType::TabletTool => seat - .tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab( - state, - grab, - InputTime::now(), - serial, - Focus::Clear, - ), + ); } } } @@ -921,14 +884,14 @@ impl PointerTarget for ZoomFocusTarget { } } - fn button(&self, seat: &Seat, data: &mut State, event: &PointerButtonEvent) { + fn button(&self, seat: &Seat, data: &mut State, event: &ButtonEvent) { match self { ZoomFocusTarget::Main(elem) => PointerTarget::button(elem, seat, data, event), ZoomFocusTarget::Menu(elem) => PointerTarget::button(elem, seat, data, event), } } - fn axis(&self, seat: &Seat, data: &mut State, frame: PointerAxisFrame) { + fn axis(&self, seat: &Seat, data: &mut State, frame: AxisFrame) { match self { ZoomFocusTarget::Main(elem) => PointerTarget::axis(elem, seat, data, frame), ZoomFocusTarget::Menu(elem) => PointerTarget::axis(elem, seat, data, frame), @@ -1061,7 +1024,7 @@ impl PointerTarget for ZoomFocusTarget { } } - fn leave(&self, seat: &Seat, data: &mut State, serial: Serial, time: InputTime) { + fn leave(&self, seat: &Seat, data: &mut State, serial: Serial, time: u32) { match self { ZoomFocusTarget::Main(elem) => PointerTarget::leave(elem, seat, data, serial, time), ZoomFocusTarget::Menu(elem) => PointerTarget::leave(elem, seat, data, serial, time), @@ -1070,14 +1033,14 @@ impl PointerTarget for ZoomFocusTarget { } impl TouchTarget for ZoomFocusTarget { - fn down(&self, seat: &Seat, data: &mut State, event: &TouchDownEvent) { + fn down(&self, seat: &Seat, data: &mut State, event: &DownEvent) { match self { ZoomFocusTarget::Main(elem) => TouchTarget::down(elem, seat, data, event), ZoomFocusTarget::Menu(elem) => TouchTarget::down(elem, seat, data, event), } } - fn up(&self, seat: &Seat, data: &mut State, event: &TouchUpEvent) { + fn up(&self, seat: &Seat, data: &mut State, event: &UpEvent) { match self { ZoomFocusTarget::Main(elem) => TouchTarget::up(elem, seat, data, event), ZoomFocusTarget::Menu(elem) => TouchTarget::up(elem, seat, data, event), @@ -1127,144 +1090,6 @@ impl TouchTarget for ZoomFocusTarget { } } -impl TabletToolTarget for ZoomFocusTarget { - fn proximity_in( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - tablet: &Tablet, - serial: Serial, - ) { - match self { - ZoomFocusTarget::Main(elem) => { - TabletToolTarget::proximity_in(elem, seat, data, tool_descriptor, tablet, serial) - } - ZoomFocusTarget::Menu(elem) => { - TabletToolTarget::proximity_in(elem, seat, data, tool_descriptor, tablet, serial) - } - } - } - - fn proximity_out( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - ) { - match self { - ZoomFocusTarget::Main(elem) => { - TabletToolTarget::proximity_out(elem, seat, data, tool_descriptor) - } - ZoomFocusTarget::Menu(elem) => { - TabletToolTarget::proximity_out(elem, seat, data, tool_descriptor) - } - } - } - - fn down( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &TabletDownEvent, - ) { - match self { - ZoomFocusTarget::Main(elem) => { - TabletToolTarget::down(elem, seat, data, tool_descriptor, event) - } - ZoomFocusTarget::Menu(elem) => { - TabletToolTarget::down(elem, seat, data, tool_descriptor, event) - } - } - } - - fn up( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &TabletUpEvent, - ) { - match self { - ZoomFocusTarget::Main(elem) => { - TabletToolTarget::up(elem, seat, data, tool_descriptor, event) - } - ZoomFocusTarget::Menu(elem) => { - TabletToolTarget::up(elem, seat, data, tool_descriptor, event) - } - } - } - - fn motion( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &TabletMotionEvent, - ) { - match self { - ZoomFocusTarget::Main(elem) => { - TabletToolTarget::motion(elem, seat, data, tool_descriptor, event) - } - ZoomFocusTarget::Menu(elem) => { - TabletToolTarget::motion(elem, seat, data, tool_descriptor, event) - } - } - } - - fn axis( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - frame: TabletAxisFrame, - ) { - match self { - ZoomFocusTarget::Main(elem) => { - TabletToolTarget::axis(elem, seat, data, tool_descriptor, frame) - } - ZoomFocusTarget::Menu(elem) => { - TabletToolTarget::axis(elem, seat, data, tool_descriptor, frame) - } - } - } - - fn button( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - event: &TabletButtonEvent, - ) { - match self { - ZoomFocusTarget::Main(elem) => { - TabletToolTarget::button(elem, seat, data, tool_descriptor, event) - } - ZoomFocusTarget::Menu(elem) => { - TabletToolTarget::button(elem, seat, data, tool_descriptor, event) - } - } - } - - fn frame( - &self, - seat: &Seat, - data: &mut State, - tool_descriptor: &TabletToolDescriptor, - time: InputTime, - ) { - match self { - ZoomFocusTarget::Main(elem) => { - TabletToolTarget::frame(elem, seat, data, tool_descriptor, time) - } - ZoomFocusTarget::Menu(elem) => { - TabletToolTarget::frame(elem, seat, data, tool_descriptor, time) - } - } - } -} - impl IsAlive for ZoomFocusTarget { fn alive(&self) -> bool { match self { diff --git a/src/state.rs b/src/state.rs index 86f5e23e..5ccc7a7b 100644 --- a/src/state.rs +++ b/src/state.rs @@ -23,7 +23,6 @@ use crate::{ output_configuration::OutputConfigurationState, output_power::OutputPowerState, overlap_notify::OverlapNotifyState, - session_lock_layer::SessionLockLayerState, toplevel_info::ToplevelInfoState, toplevel_management::{ManagementCapabilities, ToplevelManagementState}, workspace::{WorkspaceState, WorkspaceUpdateGuard}, @@ -321,7 +320,6 @@ pub struct Common { pub xwayland_state: Option, pub xwayland_shell_state: XWaylandShellState, pub pointer_focus_state: Option, - pub session_lock_layer_state: SessionLockLayerState, #[cfg(feature = "logind")] pub inhibit_lid_fd: Option, @@ -667,7 +665,7 @@ impl State { .unwrap(); let clock = Clock::new(); - let config = Config::load(&handle, kiosk_command.is_some()); + let config = Config::load(&handle); let compositor_state = CompositorState::new::(dh); let corner_radius_state = CornerRadiusState::new::(dh); let data_device_state = DataDeviceState::new::(dh); @@ -765,9 +763,6 @@ impl State { let dbus_state = DBusState::init(&handle); - let session_lock_layer_state = - SessionLockLayerState::new::(dh, client_not_sandboxed); - State { common: Common { config, @@ -835,7 +830,6 @@ impl State { pointer_focus_state: None, dbus_state, keyboard_layout_state, - session_lock_layer_state, #[cfg(feature = "logind")] inhibit_lid_fd: None, @@ -974,8 +968,6 @@ impl Common { output: &Output, render_element_states: &RenderElementStates, ) { - // NOTE: Keep in sync with surface iteration in `render_input_order_internal` - let shell = self.shell.read(); let processor = |namespace: Option| { move |surface: &WlSurface, states: &SurfaceData| { @@ -1082,8 +1074,6 @@ impl Common { render_element_states: &RenderElementStates, mut dmabuf_feedback: impl FnMut(DrmNode) -> Option, ) { - // NOTE: Keep in sync with surface iteration in `render_input_order_internal` - let shell = self.shell.read(); if let Some(session_lock) = shell.session_lock.as_ref() @@ -1297,8 +1287,6 @@ impl Common { #[profiling::function] pub fn send_frames(&self, output: &Output, sequence: Option) { - // NOTE: Keep in sync with surface iteration in `render_input_order_internal` - let time = self.clock.now(); let should_send = |surface: &WlSurface, states: &SurfaceData| { // Do the standard primary scanout output check. For pointer surfaces it deduplicates @@ -1340,12 +1328,8 @@ impl Common { const THROTTLE: Option = Some(Duration::from_millis(995)); const SCREENCOPY_THROTTLE: Option = Some(Duration::from_nanos(16_666_666)); - fn throttle(session_holder: &impl SessionHolder, is_xwayland: bool) -> Option { - if is_xwayland { - Some(Duration::ZERO) - } else if session_holder.sessions().is_empty() - && session_holder.cursor_sessions().is_empty() - { + fn throttle(session_holder: &impl SessionHolder) -> Option { + if session_holder.sessions().is_empty() && session_holder.cursor_sessions().is_empty() { THROTTLE } else { SCREENCOPY_THROTTLE @@ -1381,8 +1365,7 @@ impl Common { && let Some(grab_state) = move_grab.lock().unwrap().as_ref() { for (window, _) in grab_state.element().windows() { - let throttle = throttle(&window, window.x11_surface().is_some()); - window.send_frame(output, time, throttle, should_send); + window.send_frame(output, time, throttle(&window), should_send); } } @@ -1406,28 +1389,25 @@ impl Common { .mapped() .for_each(|mapped| { for (window, _) in mapped.windows() { - let throttle = throttle(&window, window.x11_surface().is_some()); - window.send_frame(output, time, throttle, should_send); + window.send_frame(output, time, throttle(&window), should_send); } }); if let Some(active) = shell.active_space(output) { if let Some(fs) = active.get_fullscreen(shell.seats.last_active()) { - let throttle = throttle(&fs.surface, fs.surface.x11_surface().is_some()); - fs.surface.send_frame(output, time, throttle, should_send); + fs.surface + .send_frame(output, time, throttle(&fs.surface), should_send); } active.mapped().for_each(|mapped| { for (window, _) in mapped.windows() { - let throttle = throttle(&window, window.x11_surface().is_some()); - window.send_frame(output, time, throttle, should_send); + window.send_frame(output, time, throttle(&window), should_send); } }); // other (throttled) windows active.minimized_windows.iter().for_each(|m| { for window in m.windows() { - let throttle = throttle(&window, window.x11_surface().is_some()); - window.send_frame(output, time, throttle, |_, _| None); + window.send_frame(output, time, throttle(&window), |_, _| None); } }); @@ -1437,25 +1417,18 @@ impl Common { .filter(|w| w.handle != active.handle) { if let Some(fs) = space.get_fullscreen(shell.seats.last_active()) { - let throttle = min( - throttle(space, false), - throttle(&fs.surface, fs.surface.x11_surface().is_some()), - ); + let throttle = min(throttle(space), throttle(&fs.surface)); fs.surface.send_frame(output, time, throttle, |_, _| None); } space.mapped().for_each(|mapped| { for (window, _) in mapped.windows() { - let throttle = min( - throttle(space, false), - throttle(&window, window.x11_surface().is_some()), - ); + let throttle = min(throttle(space), throttle(&window)); window.send_frame(output, time, throttle, |_, _| None); } }); space.minimized_windows.iter().for_each(|m| { for window in m.windows() { - let throttle = throttle(&window, window.x11_surface().is_some()); - window.send_frame(output, time, throttle, |_, _| None); + window.send_frame(output, time, throttle(&window), |_, _| None); } }) } diff --git a/src/utils/iced/mod.rs b/src/utils/iced/mod.rs index 4522644b..2bfe888d 100644 --- a/src/utils/iced/mod.rs +++ b/src/utils/iced/mod.rs @@ -31,7 +31,7 @@ use ordered_float::OrderedFloat; use smithay::{ backend::{ allocator::Fourcc, - input::{ButtonState, InputTime, KeyState, TabletToolDescriptor}, + input::{ButtonState, KeyState}, renderer::{ ImportMem, element::{ @@ -45,23 +45,14 @@ use smithay::{ Seat, keyboard::{KeyboardTarget, KeysymHandle, ModifiersState}, pointer::{ - AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, - GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, - GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, - GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent as PointerMotionEvent, + AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent, + GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, + GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent, PointerTarget, RelativeMotionEvent, }, - tablet::{ - Tablet, - tool::{ - AxisFrame as ToolAxisFrame, ButtonEvent as ToolButtonEvent, - DownEvent as ToolDownEvent, MotionEvent as ToolMotionEvent, TabletToolTarget, - UpEvent as ToolUpEvent, - }, - }, touch::{ - DownEvent as TouchDownEvent, FrameMarker, MotionEvent as TouchMotionEvent, - OrientationEvent, ShapeEvent, TouchTarget, UpEvent as TouchUpEvent, + DownEvent, FrameMarker, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, + TouchTarget, UpEvent, }, }, output::Output, @@ -198,7 +189,6 @@ pub(crate) struct IcedElementInternal { touch_map: HashMap, last_touch_frame: Option, last_touch_serial: Option, - last_tablet_serial: Option, // iced theme: Theme, @@ -250,7 +240,6 @@ impl Clone for IcedElementInternal

{ touch_map: self.touch_map.clone(), last_touch_frame: None, last_touch_serial: None, - last_tablet_serial: None, theme: self.theme.clone(), renderer, state, @@ -278,7 +267,6 @@ impl fmt::Debug for IcedElementInternal

{ .field("touch_map", &self.touch_map) .field("last_touch_frame", &self.last_touch_frame) .field("last_touch_serial", &self.last_touch_serial) - .field("last_tablet_serial", &self.last_tablet_serial) .field("theme", &"...") .field("renderer", &"...") .field("state", &"...") @@ -338,7 +326,6 @@ impl IcedElement

{ touch_map: HashMap::new(), last_touch_frame: None, last_touch_serial: None, - last_tablet_serial: None, theme, renderer, state, @@ -494,143 +481,12 @@ impl IcedElementInternal

{ } } -impl TabletToolTarget for IcedElement

{ - fn proximity_in( - &self, - seat: &Seat, - _data: &mut crate::state::State, - _tool_descriptor: &TabletToolDescriptor, - _tablet: &Tablet, - serial: Serial, - ) { - let mut internal = self.0.lock().unwrap(); - internal - .state - .queue_event(Event::Mouse(MouseEvent::CursorEntered)); - internal.last_tablet_serial = Some(serial); - *internal.last_seat.lock().unwrap() = Some((seat.clone(), serial)); - internal.update(false); - } - - fn proximity_out( - &self, - _seat: &Seat, - _data: &mut crate::state::State, - _tool_descriptor: &TabletToolDescriptor, - ) { - let mut internal = self.0.lock().unwrap(); - internal - .state - .queue_event(Event::Mouse(MouseEvent::CursorLeft)); - internal.update(false); - } - - fn down( - &self, - seat: &Seat, - _data: &mut crate::state::State, - _tool_descriptor: &TabletToolDescriptor, - event: &ToolDownEvent, - ) { - let mut internal = self.0.lock().unwrap(); - let id = Finger(0); - let Some(event_location) = internal.cursor_pos else { - return; - }; - let position = IcedPoint::new(event_location.x as f32, event_location.y as f32); - internal - .state - .queue_event(Event::Touch(TouchEvent::FingerPressed { id, position })); - internal.last_tablet_serial = Some(event.serial); - *internal.last_seat.lock().unwrap() = Some((seat.clone(), event.serial)); - internal.update(false); - } - - fn up( - &self, - seat: &Seat, - _data: &mut crate::state::State, - _tool_descriptor: &TabletToolDescriptor, - _event: &ToolUpEvent, - ) { - let mut internal = self.0.lock().unwrap(); - let id = Finger(0); - if let Some(event_location) = internal.cursor_pos { - *internal.last_seat.lock().unwrap() = - Some((seat.clone(), internal.last_tablet_serial.unwrap())); - let position = IcedPoint::new(event_location.x as f32, event_location.y as f32); - internal - .state - .queue_event(Event::Touch(TouchEvent::FingerLifted { id, position })); - internal.update(false); - } - } - - fn motion( - &self, - seat: &Seat, - _data: &mut crate::state::State, - _tool_descriptor: &TabletToolDescriptor, - event: &ToolMotionEvent, - ) { - let mut internal = self.0.lock().unwrap(); - let event_location = event.location.downscale(internal.additional_scale); - let position = IcedPoint::new(event_location.x as f32, event_location.y as f32); - internal - .state - .queue_event(Event::Mouse(MouseEvent::CursorMoved { position })); - internal.cursor_pos = Some(event_location); - *internal.last_seat.lock().unwrap() = - Some((seat.clone(), internal.last_tablet_serial.unwrap())); - internal.update(false); - } - - fn axis( - &self, - _seat: &Seat, - _data: &mut crate::state::State, - _tool_descriptor: &TabletToolDescriptor, - _frame: ToolAxisFrame, - ) { - } - - fn button( - &self, - seat: &Seat, - _data: &mut crate::state::State, - _tool_descriptor: &TabletToolDescriptor, - event: &ToolButtonEvent, - ) { - let mut internal = self.0.lock().unwrap(); - let button = match event.button { - 0x14b => MouseButton::Right, - 0x14c => MouseButton::Middle, - _ => return, - }; - internal.state.queue_event(Event::Mouse(match event.state { - ButtonState::Pressed => MouseEvent::ButtonPressed(button), - ButtonState::Released => MouseEvent::ButtonReleased(button), - })); - *internal.last_seat.lock().unwrap() = Some((seat.clone(), event.serial)); - internal.update(false); - } - - fn frame( - &self, - _seat: &Seat, - _data: &mut crate::state::State, - _tool_descriptor: &TabletToolDescriptor, - _time: InputTime, - ) { - } -} - impl PointerTarget for IcedElement

{ fn enter( &self, seat: &Seat, _data: &mut crate::state::State, - event: &PointerMotionEvent, + event: &MotionEvent, ) { let mut internal = self.0.lock().unwrap(); internal @@ -651,7 +507,7 @@ impl PointerTarget for IcedEle &self, seat: &Seat, _data: &mut crate::state::State, - event: &PointerMotionEvent, + event: &MotionEvent, ) { let mut internal = self.0.lock().unwrap(); let event_location = event.location.downscale(internal.additional_scale); @@ -676,7 +532,7 @@ impl PointerTarget for IcedEle &self, seat: &Seat, _data: &mut crate::state::State, - event: &PointerButtonEvent, + event: &ButtonEvent, ) { let mut internal = self.0.lock().unwrap(); let button = match event.button { @@ -697,7 +553,7 @@ impl PointerTarget for IcedEle &self, _seat: &Seat, _data: &mut crate::state::State, - frame: PointerAxisFrame, + frame: AxisFrame, ) { let mut internal = self.0.lock().unwrap(); internal @@ -725,7 +581,7 @@ impl PointerTarget for IcedEle _seat: &Seat, _data: &mut crate::state::State, _serial: Serial, - _time: InputTime, + _time: u32, ) { let mut internal = self.0.lock().unwrap(); internal @@ -797,7 +653,7 @@ impl TouchTarget for IcedEleme &self, seat: &Seat, _data: &mut crate::state::State, - event: &TouchDownEvent, + event: &DownEvent, ) { let mut internal = self.0.lock().unwrap(); let id = Finger(i32::from(event.slot) as u64); @@ -817,7 +673,7 @@ impl TouchTarget for IcedEleme &self, seat: &Seat, _data: &mut crate::state::State, - event: &TouchUpEvent, + event: &UpEvent, ) { let mut internal = self.0.lock().unwrap(); let id = Finger(i32::from(event.slot) as u64); @@ -928,7 +784,7 @@ impl KeyboardTarget for IcedEl _key: KeysymHandle<'_>, _state: KeyState, _serial: Serial, - _time: InputTime, + _time: u32, ) { // TODO convert keys } diff --git a/src/wayland/handlers/compositor.rs b/src/wayland/handlers/compositor.rs index ed40448b..12bc2e56 100644 --- a/src/wayland/handlers/compositor.rs +++ b/src/wayland/handlers/compositor.rs @@ -3,12 +3,9 @@ use crate::{shell::grabs::SeatMoveGrabState, state::ClientState, utils::prelude::*}; use calloop::Interest; use smithay::{ - backend::{ - input::InputTime, - renderer::{ - element::{Kind, surface::KindEvaluation}, - utils::{on_commit_buffer_handler, with_renderer_surface_state}, - }, + backend::renderer::{ + element::{Kind, surface::KindEvaluation}, + utils::{on_commit_buffer_handler, with_renderer_surface_state}, }, desktop::{LayerSurface, PopupKind, WindowSurfaceType, layer_map_for_output}, reexports::wayland_server::{Client, Resource, protocol::wl_surface::WlSurface}, @@ -328,11 +325,9 @@ impl CompositorHandler for State { } } else { std::mem::drop(shell); - seat.get_pointer().unwrap().unset_grab( - self, - SERIAL_COUNTER.next_serial(), - InputTime::now(), - ); + seat.get_pointer() + .unwrap() + .unset_grab(self, SERIAL_COUNTER.next_serial(), 0); return; } } diff --git a/src/wayland/handlers/corner_radius.rs b/src/wayland/handlers/corner_radius.rs index 1a541938..ded8d923 100644 --- a/src/wayland/handlers/corner_radius.rs +++ b/src/wayland/handlers/corner_radius.rs @@ -45,11 +45,18 @@ pub fn surface_corners(states: &SurfaceData, size: Size) -> Option ]) } -pub fn surface_padding(states: &SurfaceData) -> Option<[i32; 4]> { +pub fn surface_padding(states: &SurfaceData, size: Size) -> Option<[i32; 4]> { let mut guard = states.cached_state.get::(); let padding = guard.current().0?; - Some([padding.top, padding.right, padding.bottom, padding.left]) + + // guard against padding being too large + Some([ + padding.top.min(size.h / 2), + padding.right.min(size.w / 2), + padding.bottom.min(size.h / 2), + padding.left.min(size.w / 2), + ]) } pub fn pad_rect( diff --git a/src/wayland/handlers/decoration.rs b/src/wayland/handlers/decoration.rs index a1efbd0a..90ec5855 100644 --- a/src/wayland/handlers/decoration.rs +++ b/src/wayland/handlers/decoration.rs @@ -1,6 +1,5 @@ use std::{cell::RefCell, sync::Mutex}; -use cosmic_comp_config::DecorationPreference; use smithay::{ desktop::Window, reexports::{ @@ -21,7 +20,7 @@ use smithay::{ }; use wayland_backend::protocol::WEnum; -use crate::{shell::CosmicMapped, state::State}; +use crate::state::State; pub struct PreferredDecorationMode(RefCell>); @@ -30,7 +29,7 @@ impl PreferredDecorationMode { window .user_data() .get::() - .is_none_or(|mode| mode.0.borrow().is_none()) + .is_none() } pub fn mode(window: &Window) -> Option { @@ -54,72 +53,6 @@ impl PreferredDecorationMode { } } -impl State { - pub fn default_decoration(&self) -> DecorationPreference { - self.common.config.cosmic_conf.decoration_preference - } - - pub fn update_decorations(&self) { - let shell = self.common.shell.read(); - - let update = |mapped: &CosmicMapped| { - let mode = if mapped.is_stack() { - XdgMode::ServerSide - } else { - XdgMode::from_preference(self.default_decoration()) - }; - for (window, _) in mapped.windows() { - if PreferredDecorationMode::is_unset(&window.0) - && let Some(toplevel) = window.0.toplevel() - && toplevel.with_committed_state(|state| { - state.is_some_and(|state| state.decoration_mode.is_some()) - }) - { - toplevel.with_pending_state(|state| { - state.decoration_mode = Some(mode); - }); - toplevel.send_configure(); - } - } - }; - - for set in shell.workspaces.sets.values() { - set.sticky_layer.mapped().for_each(update); - } - - for space in shell.workspaces.spaces() { - space.mapped().for_each(update); - space - .minimized_windows - .iter() - .filter_map(|m| m.mapped()) - .for_each(update); - } - } -} - -trait FromDecorationPreference { - fn from_preference(preference: DecorationPreference) -> Self; -} - -impl FromDecorationPreference for XdgMode { - fn from_preference(preference: DecorationPreference) -> Self { - match preference { - DecorationPreference::ClientSide => XdgMode::ClientSide, - DecorationPreference::ServerSide => XdgMode::ServerSide, - } - } -} - -impl FromDecorationPreference for KdeMode { - fn from_preference(preference: DecorationPreference) -> Self { - match preference { - DecorationPreference::ClientSide => KdeMode::Client, - DecorationPreference::ServerSide => KdeMode::Server, - } - } -} - pub type KdeDecorationData = Mutex; #[derive(Debug, Default)] pub struct KdeDecorationSurfaceState { @@ -134,7 +67,7 @@ impl XdgDecorationHandler for State { let mode = if mapped.is_stack() { XdgMode::ServerSide } else { - XdgMode::from_preference(self.default_decoration()) + XdgMode::ClientSide }; if let Some((window, _)) = mapped @@ -147,10 +80,6 @@ impl XdgDecorationHandler for State { }); toplevel.send_configure(); } - } else { - toplevel.with_pending_state(|state| { - state.decoration_mode = Some(XdgMode::from_preference(self.default_decoration())) - }) } } @@ -170,13 +99,6 @@ impl XdgDecorationHandler for State { } } else { toplevel.with_pending_state(|state| state.decoration_mode = Some(mode)); - if let Some(pending) = shell - .pending_windows - .iter() - .find(|pending| pending.surface.0.toplevel().is_some_and(|t| t == &toplevel)) - { - PreferredDecorationMode::update(&pending.surface.0, Some(mode)); - } } } @@ -188,28 +110,11 @@ impl XdgDecorationHandler for State { .find(|(window, _)| window.wl_surface().as_deref() == Some(toplevel.wl_surface())) && let Some(toplevel) = window.0.toplevel() { - let mode = if mapped.is_stack() { - XdgMode::ServerSide - } else { - XdgMode::from_preference(self.default_decoration()) - }; - PreferredDecorationMode::update(&window.0, None); toplevel.with_pending_state(|state| { - state.decoration_mode = Some(mode); + state.decoration_mode = None; }); toplevel.send_configure(); - } else { - toplevel.with_pending_state(|state| { - state.decoration_mode = Some(XdgMode::from_preference(self.default_decoration())) - }); - if let Some(pending) = shell - .pending_windows - .iter() - .find(|pending| pending.surface.0.toplevel().is_some_and(|t| t == &toplevel)) - { - PreferredDecorationMode::update(&pending.surface.0, None); - } } } } @@ -224,10 +129,10 @@ impl KdeDecorationHandler for State { if mapped.is_stack() { KdeMode::Server } else { - KdeMode::from_preference(self.default_decoration()) + KdeMode::Client } } else { - KdeMode::from_preference(self.default_decoration()) + KdeMode::Client }; with_states(surface, |states| { diff --git a/src/wayland/handlers/keyboard_layout.rs b/src/wayland/handlers/keyboard_layout.rs index 2477f93b..ac1fda87 100644 --- a/src/wayland/handlers/keyboard_layout.rs +++ b/src/wayland/handlers/keyboard_layout.rs @@ -1,7 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-only -use smithay::input::keyboard::KeyboardHandle; - use crate::state::State; use crate::wayland::protocols::keyboard_layout::{KeyboardLayoutHandler, KeyboardLayoutState}; @@ -9,8 +7,4 @@ impl KeyboardLayoutHandler for State { fn keyboard_layout_state(&mut self) -> &mut KeyboardLayoutState { &mut self.common.keyboard_layout_state } - - fn group_changed(&mut self, keyboard: &KeyboardHandle) { - self.broadcast_ei_keyboard_modifiers(keyboard); - } } diff --git a/src/wayland/handlers/pointer_constraints.rs b/src/wayland/handlers/pointer_constraints.rs index 743b3b0b..9ce5f63a 100644 --- a/src/wayland/handlers/pointer_constraints.rs +++ b/src/wayland/handlers/pointer_constraints.rs @@ -5,10 +5,7 @@ use smithay::{ input::pointer::PointerHandle, reexports::wayland_server::protocol::wl_surface::WlSurface, utils::{Logical, Point}, - wayland::{ - pointer_constraints::{ConstraintRemove, PointerConstraintsHandler}, - seat::WaylandFocus, - }, + wayland::{pointer_constraints::PointerConstraintsHandler, seat::WaylandFocus}, }; pub use smithay::wayland::pointer_constraints::{PointerConstraintRef, with_pointer_constraint}; @@ -79,37 +76,23 @@ impl PointerConstraintsHandler for State { } } - fn remove_constraint( - &mut self, - surface: &WlSurface, - pointer: &PointerHandle, - constraint_remove: ConstraintRemove, - ) { - match constraint_remove { - ConstraintRemove::PointerLeave(_) => { - // If the constraint was broken by the pointer forcibly leaving the surface, then it doesn't - // make much sense to warp it. - } - ConstraintRemove::Destroyed(constraint) => { - let Some(seat) = self - .common - .shell - .read() - .seats - .iter() - .find(|s| s.get_pointer().as_ref() == Some(pointer)) - .cloned() - else { - return; - }; - let Some((hint_surface, hint_location)) = seat.pointer_constraint_hint() else { - return; - }; + fn remove_constraint(&mut self, surface: &WlSurface, pointer: &PointerHandle) { + if with_pointer_constraint(surface, pointer, |constraint| constraint.is_none()) { + let seat = self + .common + .shell + .read() + .seats + .iter() + .find(|s| s.get_pointer().as_ref() == Some(pointer)) + .cloned(); - if hint_surface == *surface { - self.apply_cursor_hint(surface, pointer, hint_location, Some(&constraint)); - seat.set_pointer_constraint_hint(None); - } + if let Some(seat) = seat + && let Some((hint_surface, hint_location)) = seat.pointer_constraint_hint() + && hint_surface == *surface + { + self.apply_cursor_hint(surface, pointer, hint_location); + seat.set_pointer_constraint_hint(None); } } } diff --git a/src/wayland/handlers/pointer_warp.rs b/src/wayland/handlers/pointer_warp.rs index 634817cf..971ab583 100644 --- a/src/wayland/handlers/pointer_warp.rs +++ b/src/wayland/handlers/pointer_warp.rs @@ -38,7 +38,7 @@ impl PointerWarpHandler for State { drop(shell); if let Some(pointer_handle) = pointer_handle { - self.apply_cursor_hint(&surface, &pointer_handle, pos, None); + self.apply_cursor_hint(&surface, &pointer_handle, pos); } } } diff --git a/src/wayland/handlers/tablet_manager.rs b/src/wayland/handlers/tablet_manager.rs index 7cf2b8cb..e4b84434 100644 --- a/src/wayland/handlers/tablet_manager.rs +++ b/src/wayland/handlers/tablet_manager.rs @@ -1,13 +1,13 @@ // SPDX-License-Identifier: GPL-3.0-only -use crate::{shell::focus::target::PointerFocusTarget, state::State}; +use crate::state::State; use smithay::{ backend::input::TabletToolDescriptor, input::pointer::CursorImageStatus, - input::tablet::TabletSeatHandler, + input::tablet::TabletSeatHandler, reexports::wayland_server::protocol::wl_surface, }; impl TabletSeatHandler for State { - type ToolFocus = PointerFocusTarget; + type ToolFocus = wl_surface::WlSurface; fn tablet_tool_image(&mut self, _tool: &TabletToolDescriptor, _image: CursorImageStatus) { // TODO display cursor for each tablet tool diff --git a/src/wayland/handlers/toplevel_management.rs b/src/wayland/handlers/toplevel_management.rs index b1616bca..3da39952 100644 --- a/src/wayland/handlers/toplevel_management.rs +++ b/src/wayland/handlers/toplevel_management.rs @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-only use smithay::{ - backend::input::InputTime, desktop::{WindowSurfaceType, layer_map_for_output}, input::{Seat, pointer::MotionEvent}, output::Output, @@ -125,7 +124,7 @@ impl ToplevelManagementHandler for State { &MotionEvent { location: new_pos.to_f64().as_logical(), serial, - time: InputTime::now(), + time: self.common.clock.now().as_millis(), }, ); ptr.frame(self); diff --git a/src/wayland/handlers/xdg_activation.rs b/src/wayland/handlers/xdg_activation.rs index 38ba6219..ad8ce0d0 100644 --- a/src/wayland/handlers/xdg_activation.rs +++ b/src/wayland/handlers/xdg_activation.rs @@ -243,7 +243,7 @@ impl State { { for mapped in current_workspace .mapped() - .filter(|m| m.maximized_state.lock().unwrap().is_some() && *m != &element) + .filter(|m| m.maximized_state.lock().unwrap().is_some()) .cloned() .collect::>() .into_iter() diff --git a/src/wayland/handlers/xdg_shell/mod.rs b/src/wayland/handlers/xdg_shell/mod.rs index be7084dd..b4f16c4c 100644 --- a/src/wayland/handlers/xdg_shell/mod.rs +++ b/src/wayland/handlers/xdg_shell/mod.rs @@ -1,15 +1,11 @@ // SPDX-License-Identifier: GPL-3.0-only use crate::{ - shell::{ - CosmicSurface, PendingWindow, - focus::target::KeyboardFocusTarget, - grabs::{GrabType, ReleaseMode}, - }, + shell::{CosmicSurface, PendingWindow, focus::target::KeyboardFocusTarget, grabs::ReleaseMode}, utils::prelude::*, }; +use smithay::desktop::layer_map_for_output; use smithay::{ - backend::input::InputTime, desktop::{ PopupGrab, PopupKeyboardGrab, PopupKind, PopupPointerGrab, PopupUngrabStrategy, WindowSurfaceType, find_popup_root_surface, @@ -30,7 +26,6 @@ use smithay::{ }, }, }; -use smithay::{desktop::layer_map_for_output, input::tablet::TabletSeatTrait}; use std::cell::Cell; use tracing::warn; @@ -55,7 +50,6 @@ impl XdgShellHandler for State { surface, seat, fullscreen: None, - minimized: false, maximized: false, sticky: false, }) @@ -195,17 +189,12 @@ impl XdgShellHandler for State { true, ) { std::mem::drop(shell); - match grab.grab_type() { - GrabType::Touch => seat.get_touch().unwrap().set_grab(self, grab, serial), - GrabType::Pointer => seat - .get_pointer() + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab(self, grab, serial); + } else { + seat.get_pointer() .unwrap() - .set_grab(self, grab, serial, focus), - GrabType::TabletTool => seat - .tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab(self, grab, InputTime::now(), serial, focus), + .set_grab(self, grab, serial, focus) } } } @@ -228,17 +217,12 @@ impl XdgShellHandler for State { true, ) { std::mem::drop(shell); - match grab.grab_type() { - GrabType::Touch => seat.get_touch().unwrap().set_grab(self, grab, serial), - GrabType::Pointer => seat - .get_pointer() + if grab.is_touch_grab() { + seat.get_touch().unwrap().set_grab(self, grab, serial) + } else { + seat.get_pointer() .unwrap() - .set_grab(self, grab, serial, focus), - GrabType::TabletTool => seat - .tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab(self, grab, InputTime::now(), serial, focus), + .set_grab(self, grab, serial, focus) } } } diff --git a/src/wayland/protocols/corner_radius.rs b/src/wayland/protocols/corner_radius.rs index 5c1a200c..51dc1153 100644 --- a/src/wayland/protocols/corner_radius.rs +++ b/src/wayland/protocols/corner_radius.rs @@ -5,19 +5,17 @@ use cosmic_protocols::corner_radius::v1::server::cosmic_corner_radius_toplevel_v use cosmic_protocols::corner_radius::v1::server::{ cosmic_corner_radius_manager_v1, cosmic_corner_radius_toplevel_v1, }; -use smithay::backend::renderer::buffer_dimensions; -use smithay::backend::renderer::utils::RendererSurfaceStateUserData; +use smithay::desktop::utils::bbox_from_surface_tree; use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_popup::XdgPopup; use smithay::reexports::wayland_protocols_wlr::layer_shell::v1::server::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1; use smithay::reexports::wayland_server::New; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; -use smithay::utils::{HookId, Logical, Rectangle}; +use smithay::utils::{HookId, Logical, Point, Rectangle}; +use smithay::wayland::compositor::Cacheable; use smithay::wayland::compositor::add_pre_commit_hook; use smithay::wayland::compositor::with_states; -use smithay::wayland::compositor::{BufferAssignment, Cacheable, SurfaceAttributes}; use smithay::wayland::shell::wlr_layer::WlrLayerShellHandler; use smithay::wayland::shell::xdg::{SurfaceCachedState, XdgShellSurfaceUserData}; -use smithay::wayland::viewporter::ViewportCachedState; use smithay::{ reexports::{ wayland_protocols::xdg::shell::server::xdg_toplevel::XdgToplevel, @@ -657,6 +655,7 @@ fn pad_rect( } fn layer_radius_hook(_state: &mut D, _dh: &DisplayHandle, surface: &WlSurface) { + let bbox = bbox_from_surface_tree(surface, Point::default()); with_states(surface, |surface_data| { let corners = *surface_data .cached_state @@ -666,40 +665,8 @@ fn layer_radius_hook(_state: &mut D, _dh: &DisplayHandle, surface: & .cached_state .get::() .pending(); - - // The wl_surface size after this commit is: - // - viewport destination if set - // - else the logical size of the buffer that will be current attached now - // - else existing - let size = surface_data - .cached_state - .get::() - .pending() - .size() - .or_else(|| { - let mut guard = surface_data.cached_state.get::(); - let attrs = guard.pending(); - match &attrs.buffer { - Some(BufferAssignment::NewBuffer(buffer)) => buffer_dimensions(buffer) - .map(|d| d.to_logical(attrs.buffer_scale, attrs.buffer_transform.into())), - _ => None, - } - }) - .or_else(|| { - surface_data - .data_map - .get::() - .and_then(|state| state.lock().unwrap().surface_size()) - }); - let Some(size) = size else { - return; - }; - let empty = Padding::default(); - let Some(padded_box) = pad_rect( - Rectangle::from_size(size), - padding.0.as_ref().unwrap_or(&empty), - ) else { + let Some(padded_box) = pad_rect(bbox, padding.0.as_ref().unwrap_or(&empty)) else { if let Some(hook) = surface_data.data_map.get::() { let hook_ref = hook.lock().unwrap(); if let Some((_, obj)) = hook_ref.as_ref() diff --git a/src/wayland/protocols/keyboard_layout.rs b/src/wayland/protocols/keyboard_layout.rs index 8a8840b6..f3a44f0a 100644 --- a/src/wayland/protocols/keyboard_layout.rs +++ b/src/wayland/protocols/keyboard_layout.rs @@ -17,10 +17,8 @@ use smithay::{ use std::mem; use wayland_backend::server::{ClientId, GlobalId}; -pub trait KeyboardLayoutHandler: SeatHandler { +pub trait KeyboardLayoutHandler { fn keyboard_layout_state(&mut self) -> &mut KeyboardLayoutState; - /// Group has been changed through the protocol - fn group_changed(&mut self, keyboard: &KeyboardHandle); } #[derive(Debug)] @@ -59,7 +57,6 @@ impl KeyboardLayoutState { let active_layout = handle.with_xkb_state(state, |context| { context.xkb().lock().unwrap().active_layout() }); - state.group_changed(handle); if *last_layout != Some(active_layout) { keyboard_layout.group(active_layout.0); *last_layout = Some(active_layout); diff --git a/src/wayland/protocols/mod.rs b/src/wayland/protocols/mod.rs index 48aa8337..c6c0234a 100644 --- a/src/wayland/protocols/mod.rs +++ b/src/wayland/protocols/mod.rs @@ -8,7 +8,6 @@ pub mod keyboard_layout; pub mod output_configuration; pub mod output_power; pub mod overlap_notify; -pub mod session_lock_layer; pub mod toplevel_info; pub mod toplevel_management; pub mod workspace; diff --git a/src/wayland/protocols/session_lock_layer.rs b/src/wayland/protocols/session_lock_layer.rs deleted file mode 100644 index 85edda50..00000000 --- a/src/wayland/protocols/session_lock_layer.rs +++ /dev/null @@ -1,136 +0,0 @@ -use cosmic_protocols::session_lock_layer::v1::server::cosmic_session_lock_layer_manager_v1; -use smithay::{ - reexports::wayland_server::{ - Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, backend::GlobalId, - protocol::wl_surface, - }, - wayland::{ - Dispatch2, GlobalDispatch2, - compositor::{Cacheable, with_states}, - shell::wlr_layer::WlrLayerShellHandler, - }, -}; - -struct SessionLockLayerData; - -#[derive(Debug)] -pub struct SessionLockLayerState { - global: GlobalId, -} - -impl SessionLockLayerState { - pub fn new(dh: &DisplayHandle, client_filter: F) -> Self - where - F: for<'a> Fn(&'a Client) -> bool + Clone + Send + Sync + 'static, - D: GlobalDispatch< - cosmic_session_lock_layer_manager_v1::CosmicSessionLockLayerManagerV1, - SessionLockLayerGlobalData, - > + 'static, - { - let global = dh - .create_global::( - 1, - SessionLockLayerGlobalData { - filter: Box::new(client_filter.clone()), - }, - ); - Self { global } - } - - pub fn global_id(&self) -> GlobalId { - self.global.clone() - } -} - -#[doc(hidden)] -pub struct SessionLockLayerGlobalData { - filter: Box Fn(&'a Client) -> bool + Send + Sync>, -} - -impl GlobalDispatch2 - for SessionLockLayerGlobalData -where - D: Dispatch< - cosmic_session_lock_layer_manager_v1::CosmicSessionLockLayerManagerV1, - SessionLockLayerData, - >, -{ - fn bind( - &self, - _state: &mut D, - _handle: &DisplayHandle, - _client: &Client, - resource: New, - data_init: &mut DataInit<'_, D>, - ) { - data_init.init(resource, SessionLockLayerData); - } - - fn can_view(&self, client: &Client) -> bool { - (self.filter)(client) - } -} - -#[derive(Clone, Copy, Default)] -struct SessionLockLayerSurfaceData { - show_on_lock: bool, -} - -impl Cacheable for SessionLockLayerSurfaceData { - fn commit(&mut self, _dh: &DisplayHandle) -> Self { - *self - } - - fn merge_into(self, into: &mut Self, _dh: &DisplayHandle) { - *into = self; - } -} - -pub fn layer_show_on_lock(wl_surface: &wl_surface::WlSurface) -> bool { - with_states(wl_surface, |states| { - if states.cached_state.has::() { - let mut state = states.cached_state.get::(); - state.current().show_on_lock - } else { - false - } - }) -} - -impl Dispatch2 - for SessionLockLayerData -where - D: WlrLayerShellHandler, -{ - fn request( - &self, - state: &mut D, - _: &Client, - _: &cosmic_session_lock_layer_manager_v1::CosmicSessionLockLayerManagerV1, - request: cosmic_session_lock_layer_manager_v1::Request, - _: &DisplayHandle, - _: &mut DataInit<'_, D>, - ) { - let (layer, value) = match request { - cosmic_session_lock_layer_manager_v1::Request::SetShowOnLock { layer } => (layer, true), - cosmic_session_lock_layer_manager_v1::Request::UnsetShowOnLock { layer } => { - (layer, false) - } - cosmic_session_lock_layer_manager_v1::Request::Destroy => { - return; - } - _ => unreachable!(), - }; - - if let Some(layer) = state - .shell_state() - .layer_surfaces() - .find(|surface| surface.shell_surface() == &layer) - { - with_states(layer.wl_surface(), |states| { - let mut state = states.cached_state.get::(); - state.pending().show_on_lock = value; - }); - } - } -} diff --git a/src/wayland/protocols/toplevel_info.rs b/src/wayland/protocols/toplevel_info.rs index 3146adc3..2dc76347 100644 --- a/src/wayland/protocols/toplevel_info.rs +++ b/src/wayland/protocols/toplevel_info.rs @@ -418,12 +418,6 @@ where handle.closed(); } } - // Remove the foreign handle too, so new subscribers cannot - // discover a toplevel whose window has already been destroyed. - if let Some(handle) = state.foreign_handle.take() { - self.foreign_toplevel_list.remove_toplevel(&handle); - } - *state = Default::default(); dirty = true; false } diff --git a/src/xwayland.rs b/src/xwayland.rs index cc6be3b4..da3fb36b 100644 --- a/src/xwayland.rs +++ b/src/xwayland.rs @@ -9,9 +9,7 @@ use std::{ use crate::{ backend::render::cursor::{Cursor, load_cursor_env, load_cursor_theme}, shell::{ - CosmicSurface, PendingWindow, Shell, - focus::target::KeyboardFocusTarget, - grabs::{GrabType, ReleaseMode}, + CosmicSurface, PendingWindow, Shell, focus::target::KeyboardFocusTarget, grabs::ReleaseMode, }, state::State, utils::prelude::*, @@ -22,7 +20,7 @@ use smithay::{ backend::{ allocator::Fourcc, drm::DrmNode, - input::{ButtonState, InputTime, KeyState, Keycode}, + input::{ButtonState, KeyState, Keycode}, renderer::{ Bind, Frame, Offscreen, Renderer, element::{ @@ -34,7 +32,7 @@ use smithay::{ }, }, desktop::space::SpaceElement, - input::{keyboard::ModifiersState, pointer::CursorIcon, tablet::TabletSeatTrait}, + input::{keyboard::ModifiersState, pointer::CursorIcon}, reexports::{wayland_server::Client, x11rb::protocol::xproto::Window as X11Window}, utils::{ Buffer as BufferCoords, Logical, Point, Rectangle, SERIAL_COUNTER, Serial, Size, Transform, @@ -398,7 +396,7 @@ impl Common { state: KeyState, modifiers: ModifiersState, serial: Serial, - time: InputTime, + time: u32, ) { let config = self.config.cosmic_conf.xwayland_eavesdropping.keyboard; if config == EavesdroppingKeyboardMode::None { @@ -460,7 +458,7 @@ impl Common { tracing::trace!("Forwaring key {} {:?} to xwayland", code.raw() - 8, state); for wl_keyboard in keyboard.client_keyboards(&xstate.client) { - wl_keyboard.key(serial.into(), time.millis(), code.raw() - 8, state.into()); + wl_keyboard.key(serial.into(), time, code.raw() - 8, state.into()); if xstate.last_modifier_state != Some(modifiers) { xstate.last_modifier_state = Some(modifiers); wl_keyboard.modifiers( @@ -480,7 +478,7 @@ impl Common { button: u32, state: ButtonState, serial: Serial, - time: InputTime, + time: u32, ) { if !self.config.cosmic_conf.xwayland_eavesdropping.pointer { return; @@ -520,7 +518,7 @@ impl Common { tracing::trace!("Forwaring ptr button {} {:?} to Xwayland", button, state); for wl_pointer in pointer.client_pointers(&xstate.client) { - wl_pointer.button(serial.into(), time.millis(), button, state.into()); + wl_pointer.button(serial.into(), time, button, state.into()); } } @@ -810,7 +808,6 @@ impl XwmHandler for State { ); } let fullscreen = window.is_fullscreen().then(|| seat.active_output()); - let minimized = window.is_hidden(); let maximized = window.is_maximized(); if let Some(pending) = shell .pending_windows @@ -819,7 +816,6 @@ impl XwmHandler for State { { pending.seat = seat; pending.fullscreen = fullscreen; - pending.minimized = minimized; pending.maximized = maximized; } else { let surface = CosmicSurface::from(window); @@ -827,7 +823,6 @@ impl XwmHandler for State { surface, seat, fullscreen, - minimized, maximized, sticky: false, }) @@ -1047,29 +1042,17 @@ impl XwmHandler for State { true, ) { std::mem::drop(shell); - match grab.grab_type() { - GrabType::Touch => { - seat.get_touch() - .unwrap() - .set_grab(self, grab, SERIAL_COUNTER.next_serial()) - } - GrabType::Pointer => seat.get_pointer().unwrap().set_grab( + if grab.is_touch_grab() { + seat.get_touch() + .unwrap() + .set_grab(self, grab, SERIAL_COUNTER.next_serial()) + } else { + seat.get_pointer().unwrap().set_grab( self, grab, SERIAL_COUNTER.next_serial(), focus, - ), - GrabType::TabletTool => seat - .tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab( - self, - grab, - InputTime::now(), - SERIAL_COUNTER.next_serial(), - focus, - ), + ) } } } @@ -1090,29 +1073,17 @@ impl XwmHandler for State { true, ) { std::mem::drop(shell); - match grab.grab_type() { - GrabType::Touch => { - seat.get_touch() - .unwrap() - .set_grab(self, grab, SERIAL_COUNTER.next_serial()) - } - GrabType::Pointer => seat.get_pointer().unwrap().set_grab( + if grab.is_touch_grab() { + seat.get_touch() + .unwrap() + .set_grab(self, grab, SERIAL_COUNTER.next_serial()) + } else { + seat.get_pointer().unwrap().set_grab( self, grab, SERIAL_COUNTER.next_serial(), focus, - ), - GrabType::TabletTool => seat - .tablet_seat() - .get_tool(grab.tool().unwrap()) - .unwrap() - .set_grab( - self, - grab, - InputTime::now(), - SERIAL_COUNTER.next_serial(), - focus, - ), + ) } } }