slightly better code

This commit is contained in:
IoIxD 2026-07-04 22:57:08 -07:00
commit c523905c49
10 changed files with 927 additions and 380 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "smithay"]
path = smithay
url = https://github.com/Smithay/smithay

556
Cargo.lock generated
View file

@ -149,7 +149,26 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f"
dependencies = [
"objc2",
"objc2 0.5.2",
]
[[package]]
name = "block2"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5"
dependencies = [
"objc2 0.6.4",
]
[[package]]
name = "borsh"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f3f6da4992df95bbcd9af42a6c7dcb994498fc9048230405f3b36ff7cd3f145"
dependencies = [
"bytes",
"cfg_aliases",
]
[[package]]
@ -223,6 +242,18 @@ dependencies = [
"wayland-client",
]
[[package]]
name = "calloop-wayland-source"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138efcf0940a02ebf0cc8d1eff41a1682a46b431630f4c52450d6265876021fa"
dependencies = [
"calloop 0.14.4",
"rustix 1.1.4",
"wayland-backend",
"wayland-client",
]
[[package]]
name = "cc"
version = "1.2.65"
@ -363,6 +394,16 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
[[package]]
name = "dispatch2"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38"
dependencies = [
"bitflags 2.13.0",
"objc2 0.6.4",
]
[[package]]
name = "dlib"
version = "0.5.3"
@ -433,6 +474,26 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "enumflags2"
version = "0.7.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef"
dependencies = [
"enumflags2_derive",
]
[[package]]
name = "enumflags2_derive"
version = "0.7.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "equivalent"
version = "1.0.2"
@ -618,9 +679,9 @@ dependencies = [
[[package]]
name = "input"
version = "0.9.1"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbdc09524a91f9cacd26f16734ff63d7dc650daffadd2b6f84d17a285bd875a9"
checksum = "f9793345a65d71317763a33066b5d8351f8760dde8d4930fe9e39b5f14a7959d"
dependencies = [
"bitflags 2.13.0",
"input-sys",
@ -724,6 +785,16 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "keyboard-types"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fbe853b403ae61a04233030ae8a79d94975281ed9770a1f9e246732b534b28d"
dependencies = [
"bitflags 2.13.0",
"serde",
]
[[package]]
name = "khronos_api"
version = "3.1.0"
@ -844,7 +915,7 @@ dependencies = [
"smithay",
"wayland-protocols",
"wayland-server",
"winit",
"winit 0.30.13",
]
[[package]]
@ -924,6 +995,15 @@ dependencies = [
"objc2-encode",
]
[[package]]
name = "objc2"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a12a8ed07aefc768292f076dc3ac8c48f3781c8f2d5851dd3d98950e8c5a89f"
dependencies = [
"objc2-encode",
]
[[package]]
name = "objc2-app-kit"
version = "0.2.2"
@ -931,15 +1011,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff"
dependencies = [
"bitflags 2.13.0",
"block2",
"block2 0.5.1",
"libc",
"objc2",
"objc2 0.5.2",
"objc2-core-data",
"objc2-core-image",
"objc2-foundation",
"objc2-foundation 0.2.2",
"objc2-quartz-core",
]
[[package]]
name = "objc2-app-kit"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"
dependencies = [
"bitflags 2.13.0",
"objc2 0.6.4",
"objc2-core-foundation",
"objc2-foundation 0.3.2",
]
[[package]]
name = "objc2-cloud-kit"
version = "0.2.2"
@ -947,10 +1039,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009"
dependencies = [
"bitflags 2.13.0",
"block2",
"objc2",
"block2 0.5.1",
"objc2 0.5.2",
"objc2-core-location",
"objc2-foundation",
"objc2-foundation 0.2.2",
]
[[package]]
@ -959,9 +1051,9 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889"
dependencies = [
"block2",
"objc2",
"objc2-foundation",
"block2 0.5.1",
"objc2 0.5.2",
"objc2-foundation 0.2.2",
]
[[package]]
@ -971,9 +1063,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef"
dependencies = [
"bitflags 2.13.0",
"block2",
"objc2",
"objc2-foundation",
"block2 0.5.1",
"objc2 0.5.2",
"objc2-foundation 0.2.2",
]
[[package]]
name = "objc2-core-foundation"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
dependencies = [
"bitflags 2.13.0",
"block2 0.6.2",
"dispatch2",
"objc2 0.6.4",
]
[[package]]
name = "objc2-core-graphics"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807"
dependencies = [
"bitflags 2.13.0",
"libc",
"objc2-core-foundation",
]
[[package]]
@ -982,9 +1097,9 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80"
dependencies = [
"block2",
"objc2",
"objc2-foundation",
"block2 0.5.1",
"objc2 0.5.2",
"objc2-foundation 0.2.2",
"objc2-metal",
]
@ -994,10 +1109,21 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781"
dependencies = [
"block2",
"objc2",
"block2 0.5.1",
"objc2 0.5.2",
"objc2-contacts",
"objc2-foundation",
"objc2-foundation 0.2.2",
]
[[package]]
name = "objc2-core-video"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6"
dependencies = [
"bitflags 2.13.0",
"objc2-core-foundation",
"objc2-core-graphics",
]
[[package]]
@ -1013,10 +1139,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8"
dependencies = [
"bitflags 2.13.0",
"block2",
"block2 0.5.1",
"dispatch",
"libc",
"objc2",
"objc2 0.5.2",
]
[[package]]
name = "objc2-foundation"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"
dependencies = [
"bitflags 2.13.0",
"block2 0.6.2",
"objc2 0.6.4",
"objc2-core-foundation",
]
[[package]]
@ -1025,10 +1163,10 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398"
dependencies = [
"block2",
"objc2",
"objc2-app-kit",
"objc2-foundation",
"block2 0.5.1",
"objc2 0.5.2",
"objc2-app-kit 0.2.2",
"objc2-foundation 0.2.2",
]
[[package]]
@ -1038,9 +1176,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6"
dependencies = [
"bitflags 2.13.0",
"block2",
"objc2",
"objc2-foundation",
"block2 0.5.1",
"objc2 0.5.2",
"objc2-foundation 0.2.2",
]
[[package]]
@ -1050,9 +1188,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a"
dependencies = [
"bitflags 2.13.0",
"block2",
"objc2",
"objc2-foundation",
"block2 0.5.1",
"objc2 0.5.2",
"objc2-foundation 0.2.2",
"objc2-metal",
]
@ -1062,8 +1200,8 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc"
dependencies = [
"objc2",
"objc2-foundation",
"objc2 0.5.2",
"objc2-foundation 0.2.2",
]
[[package]]
@ -1073,13 +1211,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f"
dependencies = [
"bitflags 2.13.0",
"block2",
"objc2",
"block2 0.5.1",
"objc2 0.5.2",
"objc2-cloud-kit",
"objc2-core-data",
"objc2-core-image",
"objc2-core-location",
"objc2-foundation",
"objc2-foundation 0.2.2",
"objc2-link-presentation",
"objc2-quartz-core",
"objc2-symbols",
@ -1087,15 +1225,27 @@ dependencies = [
"objc2-user-notifications",
]
[[package]]
name = "objc2-ui-kit"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22"
dependencies = [
"bitflags 2.13.0",
"objc2 0.6.4",
"objc2-core-foundation",
"objc2-foundation 0.3.2",
]
[[package]]
name = "objc2-uniform-type-identifiers"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe"
dependencies = [
"block2",
"objc2",
"objc2-foundation",
"block2 0.5.1",
"objc2 0.5.2",
"objc2-foundation 0.2.2",
]
[[package]]
@ -1105,10 +1255,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3"
dependencies = [
"bitflags 2.13.0",
"block2",
"objc2",
"block2 0.5.1",
"objc2 0.5.2",
"objc2-core-location",
"objc2-foundation",
"objc2-foundation 0.2.2",
]
[[package]]
@ -1379,6 +1529,18 @@ dependencies = [
"bitflags 2.13.0",
]
[[package]]
name = "reis"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81f3fedd2777cde52c1be5e572efbec485eac7b801c47820eda388d4f13b9c4b"
dependencies = [
"calloop 0.14.4",
"enumflags2",
"log",
"rustix 1.1.4",
]
[[package]]
name = "rustc_version"
version = "0.4.1"
@ -1450,7 +1612,7 @@ dependencies = [
"ab_glyph",
"log",
"memmap2",
"smithay-client-toolkit",
"smithay-client-toolkit 0.19.2",
"tiny-skia",
]
@ -1467,6 +1629,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
"serde_core",
"serde_derive",
]
[[package]]
@ -1537,8 +1700,6 @@ checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90"
[[package]]
name = "smithay"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "740cea6927892bc182d5bf70c8f79806c8bc9f68f2fb96e55a30be171b63af98"
dependencies = [
"aliasable",
"appendlist",
@ -1566,6 +1727,7 @@ dependencies = [
"pkg-config",
"profiling",
"rand",
"reis",
"rustix 1.1.4",
"scopeguard",
"sha2",
@ -1582,7 +1744,7 @@ dependencies = [
"wayland-protocols-misc",
"wayland-protocols-wlr",
"wayland-server",
"winit",
"winit 0.31.0-beta.2",
"x11rb",
"xkbcommon",
]
@ -1595,7 +1757,7 @@ checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016"
dependencies = [
"bitflags 2.13.0",
"calloop 0.13.0",
"calloop-wayland-source",
"calloop-wayland-source 0.3.0",
"cursor-icon",
"libc",
"log",
@ -1612,6 +1774,33 @@ dependencies = [
"xkeysym",
]
[[package]]
name = "smithay-client-toolkit"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0512da38f5e2b31201a93524adb8d3136276fa4fe4aafab4e1f727a82b534cc0"
dependencies = [
"bitflags 2.13.0",
"calloop 0.14.4",
"calloop-wayland-source 0.4.1",
"cursor-icon",
"libc",
"log",
"memmap2",
"rustix 1.1.4",
"thiserror 2.0.18",
"wayland-backend",
"wayland-client",
"wayland-csd-frame",
"wayland-cursor",
"wayland-protocols",
"wayland-protocols-experimental",
"wayland-protocols-misc",
"wayland-protocols-wlr",
"wayland-scanner",
"xkeysym",
]
[[package]]
name = "smol_str"
version = "0.2.2"
@ -1621,6 +1810,16 @@ dependencies = [
"serde",
]
[[package]]
name = "smol_str"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4aaa7368fcf4852a4c2dd92df0cace6a71f2091ca0a23391ce7f3a31833f1523"
dependencies = [
"borsh",
"serde_core",
]
[[package]]
name = "strict-num"
version = "0.1.1"
@ -1965,6 +2164,19 @@ dependencies = [
"wayland-server",
]
[[package]]
name = "wayland-protocols-experimental"
version = "20250721.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40a1f863128dcaaec790d7b4b396cc9b9a7a079e878e18c47e6c2d2c5a8dcbb1"
dependencies = [
"bitflags 2.13.0",
"wayland-backend",
"wayland-client",
"wayland-protocols",
"wayland-scanner",
]
[[package]]
name = "wayland-protocols-misc"
version = "0.3.12"
@ -1973,6 +2185,7 @@ checksum = "6e9567599ef23e09b8dad6e429e5738d4509dfc46b3b21f32841a304d16b29c8"
dependencies = [
"bitflags 2.13.0",
"wayland-backend",
"wayland-client",
"wayland-protocols",
"wayland-scanner",
"wayland-server",
@ -2243,7 +2456,7 @@ dependencies = [
"android-activity",
"atomic-waker",
"bitflags 2.13.0",
"block2",
"block2 0.5.1",
"bytemuck",
"calloop 0.13.0",
"cfg_aliases",
@ -2256,10 +2469,10 @@ dependencies = [
"libc",
"memmap2",
"ndk",
"objc2",
"objc2-app-kit",
"objc2-foundation",
"objc2-ui-kit",
"objc2 0.5.2",
"objc2-app-kit 0.2.2",
"objc2-foundation 0.2.2",
"objc2-ui-kit 0.2.2",
"orbclient",
"percent-encoding",
"pin-project",
@ -2267,8 +2480,8 @@ dependencies = [
"redox_syscall 0.4.1",
"rustix 0.38.44",
"sctk-adwaita",
"smithay-client-toolkit",
"smol_str",
"smithay-client-toolkit 0.19.2",
"smol_str 0.2.2",
"tracing",
"unicode-segmentation",
"wasm-bindgen",
@ -2285,6 +2498,230 @@ dependencies = [
"xkbcommon-dl",
]
[[package]]
name = "winit"
version = "0.31.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2879d2854d1a43e48f67322d4bd097afcb6eb8f8f775c8de0260a71aea1df1aa"
dependencies = [
"bitflags 2.13.0",
"cfg_aliases",
"cursor-icon",
"dpi",
"libc",
"raw-window-handle",
"rustix 1.1.4",
"smol_str 0.3.6",
"tracing",
"winit-android",
"winit-appkit",
"winit-common",
"winit-core",
"winit-orbital",
"winit-uikit",
"winit-wayland",
"winit-web",
"winit-win32",
"winit-x11",
]
[[package]]
name = "winit-android"
version = "0.31.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d9c0d2cd93efec3a9f9ad819cfaf0834782403af7c0d248c784ec0c61761df"
dependencies = [
"android-activity",
"bitflags 2.13.0",
"dpi",
"ndk",
"raw-window-handle",
"smol_str 0.3.6",
"tracing",
"winit-core",
]
[[package]]
name = "winit-appkit"
version = "0.31.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21310ca07851a49c348e0c2cc768e36b52ca65afda2c2354d78ed4b90074d8aa"
dependencies = [
"bitflags 2.13.0",
"block2 0.6.2",
"dispatch2",
"dpi",
"objc2 0.6.4",
"objc2-app-kit 0.3.2",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-core-video",
"objc2-foundation 0.3.2",
"raw-window-handle",
"smol_str 0.3.6",
"tracing",
"winit-common",
"winit-core",
]
[[package]]
name = "winit-common"
version = "0.31.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45375fbac4cbb77260d83a30b1f9d8105880dbac99a9ae97f56656694680ff69"
dependencies = [
"memmap2",
"objc2 0.6.4",
"objc2-core-foundation",
"smol_str 0.3.6",
"tracing",
"winit-core",
"x11-dl",
"xkbcommon-dl",
]
[[package]]
name = "winit-core"
version = "0.31.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4f0ccd7abb43740e2c6124ac7cae7d865ecec74eec63783e8922577ac232583"
dependencies = [
"bitflags 2.13.0",
"cursor-icon",
"dpi",
"keyboard-types",
"raw-window-handle",
"smol_str 0.3.6",
"web-time",
]
[[package]]
name = "winit-orbital"
version = "0.31.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51ea1fb262e7209f265f12bd0cc792c399b14355675e65531e9c8a87db287d46"
dependencies = [
"bitflags 2.13.0",
"dpi",
"orbclient",
"raw-window-handle",
"redox_syscall 0.5.18",
"smol_str 0.3.6",
"tracing",
"winit-core",
]
[[package]]
name = "winit-uikit"
version = "0.31.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "680a356e798837d8eb274d4556e83bceaf81698194e31aafc5cfb8a9f2fab643"
dependencies = [
"bitflags 2.13.0",
"block2 0.6.2",
"dispatch2",
"dpi",
"objc2 0.6.4",
"objc2-core-foundation",
"objc2-foundation 0.3.2",
"objc2-ui-kit 0.3.2",
"raw-window-handle",
"smol_str 0.3.6",
"tracing",
"winit-common",
"winit-core",
]
[[package]]
name = "winit-wayland"
version = "0.31.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce5afb2ba07da603f84b722c95f9f9396d2cedae3944fb6c0cda4a6f88de545"
dependencies = [
"ahash",
"bitflags 2.13.0",
"calloop 0.14.4",
"cursor-icon",
"dpi",
"libc",
"memmap2",
"raw-window-handle",
"rustix 1.1.4",
"smithay-client-toolkit 0.20.0",
"smol_str 0.3.6",
"tracing",
"wayland-backend",
"wayland-client",
"wayland-protocols",
"wayland-protocols-plasma",
"winit-common",
"winit-core",
]
[[package]]
name = "winit-web"
version = "0.31.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c2490a953fb776fbbd5e295d54f1c3847f4f15b6c3929ec53c09acda6487a92"
dependencies = [
"atomic-waker",
"bitflags 2.13.0",
"concurrent-queue",
"cursor-icon",
"dpi",
"js-sys",
"pin-project",
"raw-window-handle",
"smol_str 0.3.6",
"tracing",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"web-time",
"winit-core",
]
[[package]]
name = "winit-win32"
version = "0.31.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "644ea78af0e858aa3b092e5d1c67c41995a98220c81813f1353b28bc8bb91eaa"
dependencies = [
"bitflags 2.13.0",
"cursor-icon",
"dpi",
"raw-window-handle",
"smol_str 0.3.6",
"tracing",
"unicode-segmentation",
"windows-sys 0.59.0",
"winit-core",
]
[[package]]
name = "winit-x11"
version = "0.31.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa5b600756534c7041aa93cd0d244d44b09fca1b89e202bd1cd80dd9f3636c46"
dependencies = [
"bitflags 2.13.0",
"bytemuck",
"calloop 0.14.4",
"cursor-icon",
"dpi",
"libc",
"percent-encoding",
"raw-window-handle",
"rustix 1.1.4",
"smol_str 0.3.6",
"tracing",
"winit-common",
"winit-core",
"x11-dl",
"x11rb",
"xkbcommon-dl",
]
[[package]]
name = "winnow"
version = "1.0.3"
@ -2324,6 +2761,7 @@ dependencies = [
"once_cell",
"rustix 1.1.4",
"x11rb-protocol",
"xcursor",
]
[[package]]
@ -2340,9 +2778,9 @@ checksum = "bec9e4a500ca8864c5b47b8b482a73d62e4237670e5b5f1d6b9e3cae50f28f2b"
[[package]]
name = "xkbcommon"
version = "0.8.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d66ca9352cbd4eecbbc40871d8a11b4ac8107cfc528a6e14d7c19c69d0e1ac9"
checksum = "a7a974f48060a14e95705c01f24ad9c3345022f4d97441b8a36beb7ed5c4a02d"
dependencies = [
"libc",
"memmap2",

View file

@ -5,7 +5,7 @@ edition = "2024"
[dependencies]
parking_lot = "0.12.5"
smithay = { version = "0.7.0", features = ["wayland-backend", "xwayland"] }
smithay = { path = "./smithay", features = ["desktop", "wayland-backend", "xwayland"] }
wayland-protocols = { version = "0.32.13", features = ["wayland-server", "server"] }
wayland-server = { version = "0.31.13", features = ["dlopen"] }
winit = "0.30.13"

1
smithay Submodule

@ -0,0 +1 @@
Subproject commit cb1eb2a3f48d95a7ea4b030159a2512ba667a2fb

View file

@ -1,15 +1,11 @@
use ::winit::raw_window_handle::{HasWindowHandle, RawWindowHandle};
use smithay::{
backend::{
renderer::{gles::GlesRenderer, RendererSuper},
winit::WinitGraphicsBackend,
},
reexports::calloop::LoopHandle,
utils::{Physical, Size},
};
use crate::state::State;
pub mod winit;
pub trait Backend {

View file

@ -1,8 +1,10 @@
use std::time::Duration;
use ::winit::platform::pump_events::PumpStatus;
use smithay::backend::input::ButtonState;
use smithay::input::pointer::MotionEvent;
use smithay::reexports::calloop::EventLoop;
use smithay::reexports::winit::event_loop::pump_events::PumpStatus;
use smithay::utils::SERIAL_COUNTER;
use smithay::{
backend::{
input::{AbsolutePositionEvent, Event, InputEvent, KeyboardKeyEvent, PointerButtonEvent},
@ -19,23 +21,19 @@ use crate::state::State;
pub fn run_winit() -> Result<(), Box<dyn std::error::Error>> {
let mut display: Display<State> = Display::new()?;
let mut event_loop = EventLoop::try_new()?;
let mut state = State::new(&display, &event_loop)?;
state.setup_xwayland(&display)?;
let (mut backend, mut winit) = winit::init::<GlesRenderer>()?;
let mut state = State::new(&display, &event_loop, backend.window_size())?;
state.setup_xwayland(&display)?;
let keyboard = state
.seat
.add_keyboard(Default::default(), 600, 25)
.unwrap();
let pointer = state.seat.add_pointer();
unsafe { std::env::set_var("WAYLAND_DISPLAY", "wayland-5") };
std::process::Command::new("weston-terminal").spawn().ok();
let damage = Rectangle::from_size(backend.window_size());
let mut i = 0;
loop {
let status = winit.dispatch_new_events(|event| match event {
@ -46,7 +44,7 @@ pub fn run_winit() -> Result<(), Box<dyn std::error::Error>> {
&mut state,
event.key_code(),
event.state(),
i.into(),
SERIAL_COUNTER.next_serial(),
event.time_msec(),
|_, _, _| {
//
@ -60,43 +58,32 @@ pub fn run_winit() -> Result<(), Box<dyn std::error::Error>> {
let locationrel = event.position_transformed(Size::new(1, 1));
let ev = smithay::input::pointer::MotionEvent {
location,
serial: i.into(),
serial: SERIAL_COUNTER.next_serial(),
time: event.time_msec(),
};
state.motion_event(ev, &pointer, locationrel);
state.motion_event(ev, locationrel);
}
InputEvent::PointerButton { event } => {
let ev = smithay::input::pointer::ButtonEvent {
serial: i.into(),
serial: SERIAL_COUNTER.next_serial(),
time: event.time_msec(),
button: event.button_code(),
state: event.state(),
};
if event.state() == ButtonState::Pressed {
if let Some(surface) = state.focused_surface() {
{
if let Some(ref surface) = surface.surface {
keyboard.set_focus(
&mut state,
Some(surface.wl_surface().clone()),
i.into(),
);
}
if let Some(ref surface) = surface.xsurface {
keyboard.set_focus(&mut state, surface.wl_surface(), i.into());
}
}
{
let mut space = state.space.lock();
space.raise_element(&surface, true);
}
if let Some((surface, _)) = state.surface_under(state.pointer_location) {
keyboard.set_focus(
&mut state,
Some(surface),
SERIAL_COUNTER.next_serial(),
);
} else {
keyboard.set_focus(&mut state, None, i.into());
keyboard.set_focus(&mut state, None, SERIAL_COUNTER.next_serial());
}
}
state.button_event(ev, &pointer);
state.button_event(ev);
}
// InputEvent::PointerAxis { event } => todo!(),
@ -140,8 +127,11 @@ pub fn run_winit() -> Result<(), Box<dyn std::error::Error>> {
// swapping buffers because this operation may block.
backend.submit(Some(&[damage]))?;
event_loop.dispatch(Duration::from_millis(1), &mut state)?;
{
let mut space = state.space.lock();
space.refresh();
}
i += 1;
event_loop.dispatch(Duration::from_millis(1), &mut state)?;
}
}

View file

@ -2,7 +2,6 @@ use backend::winit::run_winit;
pub mod backend;
pub mod state;
pub mod xwayland;
fn main() -> Result<(), Box<dyn std::error::Error>> {
run_winit()

View file

@ -1,54 +1,55 @@
pub mod xdg;
pub mod xwayland;
use parking_lot::Mutex;
use std::{sync::Arc, time::Instant};
use smithay::{
backend::{renderer::{
element::{
surface::{render_elements_from_surface_tree, WaylandSurfaceRenderElement},
AsRenderElements, Kind,
backend::{
input::ButtonState,
renderer::{
element::{
surface::{render_elements_from_surface_tree, WaylandSurfaceRenderElement},
AsRenderElements, Kind,
},
gles::GlesRenderer,
utils::{draw_render_elements, on_commit_buffer_handler},
Color32F, Frame, Renderer,
},
gles::GlesRenderer,
utils::{draw_render_elements, on_commit_buffer_handler},
Color32F, Frame, Renderer,
}, input::ButtonState},
delegate_compositor, delegate_data_device, delegate_seat, delegate_shm, delegate_xdg_shell,
desktop::{space::SpaceElement, Space, Window},
},
delegate_dispatch2,
desktop::{
layer_map_for_output, space::SpaceElement, LayerSurface, Space, Window, WindowSurfaceType,
},
input::{
pointer::{
AxisFrame, ButtonEvent, Focus, GestureHoldBeginEvent, GestureHoldEndEvent,
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData,
MotionEvent, PointerGrab, PointerHandle, PointerInnerHandle, RelativeMotionEvent,
},
dnd::DndGrabHandler,
pointer::{ButtonEvent, Focus, GrabStartData, MotionEvent, PointerHandle},
Seat, SeatHandler, SeatState,
},
output::{Mode, Output, PhysicalProperties, Subpixel},
reexports::{
calloop::{EventLoop, LoopHandle},
wayland_server::{protocol::wl_seat, Display},
rustix::fs::Stat,
wayland_server::Display,
},
utils::{IsAlive, Logical, Point, Rectangle, Scale, Serial, Transform},
utils::{IsAlive, Logical, Physical, Point, Rectangle, Scale, Size, Transform},
wayland::{
buffer::BufferHandler,
compositor::{
with_surface_tree_downward, CompositorClientState, CompositorHandler, CompositorState,
SurfaceAttributes, TraversalAction,
},
seat::WaylandFocus,
output::OutputHandler,
selection::{
data_device::{
ClientDndGrabHandler, DataDeviceHandler, DataDeviceState, ServerDndGrabHandler,
},
data_device::{DataDeviceHandler, DataDeviceState, WaylandDndGrabHandler},
SelectionHandler,
},
shell::xdg::{
PopupSurface, PositionerState, ToplevelSurface, XdgShellHandler, XdgShellState,
},
shell::xdg::{ToplevelSurface, XdgShellHandler, XdgShellState},
shm::{ShmHandler, ShmState},
xwayland_shell::XWaylandShellState,
},
xwayland::{X11Surface, XWaylandClientData, xwm::ResizeEdge},
xwayland::{X11Surface, XWaylandClientData},
};
use wayland_protocols::xdg::shell::server::xdg_toplevel;
use wayland_server::{
backend::{ClientData, ClientId, DisconnectReason},
protocol::{
@ -58,16 +59,16 @@ use wayland_server::{
Client, ListeningSocket,
};
use crate::xwayland::XWaylandState;
use crate::state::{xdg::MoveGrab, xwayland::XWaylandState};
pub struct State {
output: Output,
pub seat: Seat<Self>,
pub space: Mutex<Space<AppWrapper>>,
clients: Mutex<Vec<Client>>,
pointer_location: Point<f64, Logical>,
pointer_location_rel: Point<f64, Logical>,
pub pointer_location: Point<f64, Logical>,
start_time: Instant,
listener: ListeningSocket,
@ -75,6 +76,8 @@ pub struct State {
pub event_loop_handle: LoopHandle<'static, Self>,
pub xwayland_state: XWaylandState,
pointer: Arc<PointerHandle<State>>,
start_data: GrabStartData<State>,
compositor_state: CompositorState,
@ -88,18 +91,48 @@ impl State {
pub fn new(
display: &Display<State>,
event_loop: &EventLoop<'static, Self>,
size: Size<i32, Physical>,
) -> Result<Self, Box<dyn std::error::Error>> {
let dh = display.handle();
let compositor_state = CompositorState::new::<State>(&dh);
let shm_state = ShmState::new::<State>(&dh, vec![]);
let mut seat_state = SeatState::new();
let seat = seat_state.new_wl_seat(&dh, "milkyway_seat");
let space = Space::default();
let mut seat = seat_state.new_wl_seat(&dh, "milkyway_seat");
let mut space = Space::default();
let listener = ListeningSocket::bind("wayland-5").unwrap();
let event_loop_handle = event_loop.handle();
let pointer = Arc::new(seat.add_pointer());
let mode = Mode {
size,
refresh: 60_000,
};
let output = Output::new(
"winit".to_string(),
PhysicalProperties {
size: (0, 0).into(),
subpixel: Subpixel::Unknown,
make: "Smithay".into(),
model: "Winit".into(),
serial_number: "Unknown".into(),
},
);
let _global = output.create_global::<Self>(&dh);
output.change_current_state(
Some(mode),
Some(Transform::Flipped180),
None,
Some((0, 0).into()),
);
output.set_preferred(mode);
space.map_output(&output, (0, 0));
Ok(State {
output,
compositor_state,
xdg_shell_state: XdgShellState::new::<State>(&dh),
shm_state,
@ -110,8 +143,8 @@ impl State {
listener,
clients: Mutex::new(vec![]),
space: Mutex::new(space),
pointer,
pointer_location: Point::new(0.0, 0.0),
pointer_location_rel: Point::new(0.0, 0.0),
event_loop_handle,
xwayland_state: XWaylandState {
xwm: None,
@ -141,25 +174,12 @@ impl State {
let mut elements = space
.elements()
.flat_map(|element| {
if let Some(surface) = element.surface.clone() {
return render_elements_from_surface_tree(
renderer,
surface.wl_surface(),
(0, 0),
1.0,
1.0,
Kind::Unspecified,
);
}
if let Some(surface) = element.xsurface.clone() {
return surface.render_elements(
renderer,
Point::new(0, 0),
Scale { x: 1.0, y: 1.0 },
1.0,
);
}
panic!()
let loc = space.element_location(element).unwrap_or(Point::new(0, 0));
let position =
loc.to_physical_precise_round(self.output.current_scale().fractional_scale());
element
.window
.render_elements(renderer, position, Scale { x: 1.0, y: 1.0 }, 1.0)
})
.collect::<Vec<WaylandSurfaceRenderElement<GlesRenderer>>>();
@ -192,6 +212,41 @@ impl State {
Ok(())
}
// pub fn focused_surface(&mut self) -> Option<AppWrapper> {
// let space = self.space.lock();
// // let mut surfaces = vec![];
// let mut elements = space.elements().collect::<Vec<_>>();
// elements.reverse();
// for window in elements {
// if window.is_in_input_region(&self.pointer_location) {
// return Some(window.clone());
// }
// }
// None
// }
pub fn surface_under(
&self,
pos: Point<f64, Logical>,
) -> Option<(WlSurface, Point<f64, Logical>)> {
self.space
.lock()
.element_under(pos)
.and_then(|(window, location)| {
window
.window
.surface_under(pos - location.to_f64(), WindowSurfaceType::ALL)
.map(|(s, p)| (s, (p + location).to_f64()))
})
}
pub fn button_event(&mut self, ev: ButtonEvent) {
let pointer = self.pointer.clone();
pointer.button(self, &ev);
pointer.frame(self);
}
pub fn focused_surface(&mut self) -> Option<AppWrapper> {
let space = self.space.lock();
// let mut surfaces = vec![];
@ -206,26 +261,9 @@ impl State {
None
}
pub fn button_event(&mut self, ev: ButtonEvent, pointer: &PointerHandle<Self>) {
if ev.state == ButtonState::Pressed && let Some(app) = self.focused_surface() {
let space = self.space.lock();
let initial_rect = space.element_geometry(&app).unwrap();
println!("{:?}",initial_rect);
};
pointer.button(self, &ev);
}
pub fn motion_event(
&mut self,
ev: MotionEvent,
pointer: &PointerHandle<Self>,
locationrel: Point<f64, Logical>,
) {
pub fn motion_event(&mut self, ev: MotionEvent, locationrel: Point<f64, Logical>) {
let pointer = self.pointer.clone();
self.pointer_location = ev.location;
self.pointer_location_rel = locationrel;
if let Some(surface) = self.focused_surface() {
if let Some(surface) = surface.surface {
pointer.motion(self, Some((surface.wl_surface().clone(), locationrel)), &ev);
@ -271,49 +309,14 @@ impl BufferHandler for State {
fn buffer_destroyed(&mut self, _buffer: &wl_buffer::WlBuffer) {}
}
impl XdgShellHandler for State {
fn xdg_shell_state(&mut self) -> &mut XdgShellState {
&mut self.xdg_shell_state
}
fn new_toplevel(&mut self, surface: ToplevelSurface) {
surface.with_pending_state(|state| {
state.states.set(xdg_toplevel::State::Activated);
});
surface.send_configure();
let mut space = self.space.lock();
space.map_element(AppWrapper::new_wayland(surface), (0, 0), true);
}
fn new_popup(&mut self, _surface: PopupSurface, _positioner: PositionerState) {
// Handle popup creation here
}
fn grab(&mut self, _surface: PopupSurface, _seat: wl_seat::WlSeat, _serial: Serial) {
// Handle popup grab here
}
fn reposition_request(
&mut self,
_surface: PopupSurface,
_positioner: PositionerState,
_token: u32,
) {
// Handle popup reposition here
}
}
impl SelectionHandler for State {
type SelectionUserData = ();
}
impl ClientDndGrabHandler for State {}
impl ServerDndGrabHandler for State {}
impl WaylandDndGrabHandler for State {}
impl DataDeviceHandler for State {
fn data_device_state(&self) -> &DataDeviceState {
&self.data_device_state
fn data_device_state(&mut self) -> &mut DataDeviceState {
&mut self.data_device_state
}
}
@ -361,168 +364,7 @@ impl SeatHandler for State {
}
}
pub struct MoveGrab {
start_data: GrabStartData<State>,
window: Window,
initial_window_location: Point<i32, Logical>,
}
impl PointerGrab<State> for MoveGrab {
fn motion(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
_focus: Option<(<State as SeatHandler>::PointerFocus, Point<f64, Logical>)>,
event: &MotionEvent,
) {
handle.motion(data, None, event);
// let delta = event.location - self.start_data.location;
// let mut new_width = self.initial_rect.size.w;
// let mut new_height = self.initial_rect.size.h;
// if self.edges.intersects(ResizeEdge::LEFT | ResizeEdge::RIGHT) {
// new_width = if self.edges.intersects(ResizeEdge::LEFT) {
// (self.initial_rect.size.w as f64 - delta.x) as i32
// } else {
// (self.initial_rect.size.w as f64 + delta.x) as i32
// };
// }
// if self.edges.intersects(ResizeEdge::TOP | ResizeEdge::BOTTOM) {
// new_height = if self.edges.intersects(ResizeEdge::TOP) {
// (self.initial_rect.size.h as f64 - delta.y) as i32
// } else {
// (self.initial_rect.size.h as f64 + delta.y) as i32
// };
// }
// // clamp to whatever min/max you enforce
// let (min_size, max_size) = (Size::from((100, 100)), Size::from((i32::MAX, i32::MAX)));
// new_width = new_width.clamp(min_size.w, max_size.w);
// new_height = new_height.clamp(min_size.h, max_size.h);
// self.last_window_size = (new_width, new_height).into();
// if let Some(toplevel) = self.window.toplevel() {
// toplevel.with_pending_state(|state| {
// state.size = Some(self.last_window_size);
// state.states.set(xdg_toplevel::State::Resizing);
// });
// toplevel.send_pending_configure();
// }
}
fn relative_motion(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
focus: Option<(<State as SeatHandler>::PointerFocus, Point<f64, Logical>)>,
event: &RelativeMotionEvent,
) {
handle.relative_motion(data, focus, event);
}
fn button(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &ButtonEvent,
) {
handle.button(data, event);
}
fn axis(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
details: AxisFrame,
) {
handle.axis(data, details)
}
fn frame(&mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>) {
handle.frame(data);
}
fn gesture_swipe_begin(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeBeginEvent,
) {
handle.gesture_swipe_begin(data, event);
}
fn gesture_swipe_update(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeUpdateEvent,
) {
handle.gesture_swipe_update(data, event);
}
fn gesture_swipe_end(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeEndEvent,
) {
handle.gesture_swipe_end(data, event);
}
fn gesture_pinch_begin(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchBeginEvent,
) {
handle.gesture_pinch_begin(data, event);
}
fn gesture_pinch_update(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchUpdateEvent,
) {
handle.gesture_pinch_update(data, event);
}
fn gesture_pinch_end(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchEndEvent,
) {
handle.gesture_pinch_end(data, event);
}
fn gesture_hold_begin(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureHoldBeginEvent,
) {
handle.gesture_hold_begin(data, event);
}
fn gesture_hold_end(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureHoldEndEvent,
) {
handle.gesture_hold_end(data, event);
}
fn start_data(&self) -> &GrabStartData<State> {
&self.start_data
}
fn unset(&mut self, data: &mut State) {}
}
impl DndGrabHandler for State {}
#[derive(PartialEq, Clone)]
pub struct AppWrapper {
@ -616,9 +458,7 @@ impl ClientData for ClientState {
}
}
impl OutputHandler for State {}
// Macros used to delegate protocol handling to types in the app state.
delegate_xdg_shell!(State);
delegate_compositor!(State);
delegate_shm!(State);
delegate_seat!(State);
delegate_data_device!(State);
delegate_dispatch2!(State);

283
src/state/xdg.rs Normal file
View file

@ -0,0 +1,283 @@
use smithay::desktop::Window;
use smithay::input::pointer::{
AxisFrame, ButtonEvent, Focus, GestureHoldBeginEvent, GestureHoldEndEvent,
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData, MotionEvent, PointerGrab,
PointerInnerHandle, RelativeMotionEvent,
};
use smithay::input::SeatHandler;
use smithay::utils::{Logical, Point};
use smithay::wayland::shell::xdg::PopupSurface;
use smithay::{
utils::Serial,
wayland::shell::xdg::{PositionerState, ToplevelSurface, XdgShellHandler, XdgShellState},
};
use wayland_protocols::xdg::shell::server::xdg_toplevel;
use wayland_server::protocol::{wl_output, wl_seat};
use super::{AppWrapper, State};
impl XdgShellHandler for State {
fn xdg_shell_state(&mut self) -> &mut XdgShellState {
&mut self.xdg_shell_state
}
fn new_toplevel(&mut self, surface: ToplevelSurface) {
surface.with_pending_state(|state| {
state.states.set(xdg_toplevel::State::Activated);
});
surface.send_configure();
let mut space = self.space.lock();
space.map_element(AppWrapper::new_wayland(surface), (0, 0), true);
}
fn new_popup(&mut self, _surface: PopupSurface, _positioner: PositionerState) {
// Handle popup creation here
}
fn grab(&mut self, _surface: PopupSurface, _seat: wl_seat::WlSeat, _serial: Serial) {
// Handle popup grab here
}
fn reposition_request(
&mut self,
_surface: PopupSurface,
_positioner: PositionerState,
_token: u32,
) {
// Handle popup reposition here
}
fn move_request(&mut self, wl_surface: ToplevelSurface, seat: wl_seat::WlSeat, serial: Serial) {
let window = {
let space = self.space.lock();
space
.elements()
.find(|w| {
if let Some(surface) = w.surface.clone() {
surface == wl_surface
} else {
false
}
})
.unwrap()
.clone()
};
let pointer = self.pointer.clone();
let loc = {
let space = self.space.lock();
space.element_location(&window).unwrap()
};
let start_data = self.pointer.grab_start_data().unwrap();
pointer.set_grab(
self,
MoveGrab {
start_data,
window: window.window.clone(),
initial_window_location: loc,
app: window,
},
serial,
Focus::Clear,
);
}
fn resize_request(
&mut self,
surface: ToplevelSurface,
seat: wl_seat::WlSeat,
serial: Serial,
edges: xdg_toplevel::ResizeEdge,
) {
// println!(
// "resize {:?}",
// self.pointer_location_og - self.pointer_location
// );
}
// fn maximize_request(&mut self, surface: ToplevelSurface) {
// surface.send_configure();
// }
// fn unmaximize_request(&mut self, surface: ToplevelSurface) {}
// fn fullscreen_request(
// &mut self,
// surface: ToplevelSurface,
// output: Option<wl_output::WlOutput>,
// ) {
// surface.send_configure();
// }
// fn unfullscreen_request(&mut self, surface: ToplevelSurface) {}
// fn minimize_request(&mut self, surface: ToplevelSurface) {}
// fn show_window_menu(
// &mut self,
// surface: ToplevelSurface,
// seat: wl_seat::WlSeat,
// serial: Serial,
// location: smithay::utils::Point<i32, smithay::utils::Logical>,
// ) {
// }
// fn client_destroyed(&mut self, client: smithay::wayland::shell::xdg::ShellClient) {}
// fn toplevel_destroyed(&mut self, surface: ToplevelSurface) {}
// fn popup_destroyed(&mut self, surface: PopupSurface) {}
// fn app_id_changed(&mut self, surface: ToplevelSurface) {}
// fn title_changed(&mut self, surface: ToplevelSurface) {}
// fn parent_changed(&mut self, surface: ToplevelSurface) {}
}
pub struct MoveGrab {
pub start_data: GrabStartData<State>,
pub window: Window,
pub initial_window_location: Point<i32, Logical>,
pub app: AppWrapper,
}
impl PointerGrab<State> for MoveGrab {
fn motion(
&mut self,
state: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
focus: Option<(<State as SeatHandler>::PointerFocus, Point<f64, Logical>)>,
event: &MotionEvent,
) {
handle.motion(state, None, event);
let delta = event.location - self.start_data.location;
let new_location = self.initial_window_location.to_f64() + delta;
let mut space = state.space.lock();
space.map_element(self.app.clone(), new_location.to_i32_round(), true);
}
fn relative_motion(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
focus: Option<(<State as SeatHandler>::PointerFocus, Point<f64, Logical>)>,
event: &RelativeMotionEvent,
) {
handle.relative_motion(data, focus, event);
}
fn button(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &ButtonEvent,
) {
handle.button(data, event);
// The button is a button code as defined in the
// Linux kernel's linux/input-event-codes.h header file, e.g. BTN_LEFT.
const BTN_LEFT: u32 = 0x110;
if !handle.current_pressed().contains(&BTN_LEFT) {
// No more buttons are pressed, release the grab.
handle.unset_grab(self, data, event.serial, event.time, true);
}
}
fn axis(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
details: AxisFrame,
) {
handle.axis(data, details)
}
fn frame(&mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>) {
handle.frame(data);
}
fn gesture_swipe_begin(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeBeginEvent,
) {
handle.gesture_swipe_begin(data, event);
}
fn gesture_swipe_update(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeUpdateEvent,
) {
handle.gesture_swipe_update(data, event);
}
fn gesture_swipe_end(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeEndEvent,
) {
handle.gesture_swipe_end(data, event);
}
fn gesture_pinch_begin(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchBeginEvent,
) {
handle.gesture_pinch_begin(data, event);
}
fn gesture_pinch_update(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchUpdateEvent,
) {
handle.gesture_pinch_update(data, event);
}
fn gesture_pinch_end(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchEndEvent,
) {
handle.gesture_pinch_end(data, event);
}
fn gesture_hold_begin(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureHoldBeginEvent,
) {
handle.gesture_hold_begin(data, event);
}
fn gesture_hold_end(
&mut self,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureHoldEndEvent,
) {
handle.gesture_hold_end(data, event);
}
fn start_data(&self) -> &GrabStartData<State> {
&self.start_data
}
fn unset(&mut self, data: &mut State) {}
}

View file

@ -1,8 +1,7 @@
use std::process::Stdio;
use smithay::{
delegate_xwayland_shell,
reexports::calloop::EventLoop,
delegate_dispatch2,
utils::{Logical, Rectangle},
wayland::xwayland_shell::{XWaylandShellHandler, XWaylandShellState},
xwayland::{
@ -33,7 +32,6 @@ impl XwmHandler for State {
let mut space = self.space.lock();
let z_index = space.elements().len();
space.map_element(AppWrapper::new_x11(window), (0, 0), true);
// insert it into your Space/window management here
@ -42,7 +40,7 @@ impl XwmHandler for State {
fn mapped_override_redirect_window(&mut self, _xwm: XwmId, _window: X11Surface) {}
fn unmapped_window(&mut self, _xwm: XwmId, _window: X11Surface) {
let mut space = self.space.lock();
// let mut space = self.space.lock();
}
fn destroyed_window(&mut self, _xwm: XwmId, _window: X11Surface) {}
@ -99,6 +97,7 @@ impl State {
&dh,
None,
std::iter::empty::<(String, String)>(),
std::iter::empty::<String>(),
true,
Stdio::null(),
Stdio::null(),
@ -113,7 +112,7 @@ impl State {
display_number,
} => {
let event_loop = state.event_loop_handle.clone();
let wm = X11Wm::start_wm(event_loop, x11_socket, client.clone())
let wm = X11Wm::start_wm(event_loop, &dh, x11_socket, client.clone())
.expect("failed to start X11 wm");
state.xwayland_state.xwm = Some(wm);
@ -130,5 +129,3 @@ impl State {
Ok(())
}
}
delegate_xwayland_shell!(State);