diff --git a/Cargo.lock b/Cargo.lock index b17527fa..4f21612d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -105,7 +105,7 @@ checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" dependencies = [ "addr2line", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", "object", @@ -118,6 +118,18 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + +[[package]] +name = "bumpalo" +version = "3.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" + [[package]] name = "calloop" version = "0.9.3" @@ -134,6 +146,12 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -163,6 +181,119 @@ dependencies = [ "winapi", ] +[[package]] +name = "cocoa" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63902e9223530efb4e26ccd0cf55ec30d592d3b42e21a28defc42a9586e832" +dependencies = [ + "bitflags", + "block", + "cocoa-foundation", + "core-foundation 0.9.2", + "core-graphics 0.22.3", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "cocoa-foundation" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318" +dependencies = [ + "bitflags", + "block", + "core-foundation 0.9.2", + "core-graphics-types", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "core-foundation" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" +dependencies = [ + "core-foundation-sys 0.7.0", + "libc", +] + +[[package]] +name = "core-foundation" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3" +dependencies = [ + "core-foundation-sys 0.8.3", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "core-graphics" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923" +dependencies = [ + "bitflags", + "core-foundation 0.7.0", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" +dependencies = [ + "bitflags", + "core-foundation 0.9.2", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" +dependencies = [ + "bitflags", + "core-foundation 0.9.2", + "foreign-types", + "libc", +] + +[[package]] +name = "core-video-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828" +dependencies = [ + "cfg-if 0.1.10", + "core-foundation-sys 0.7.0", + "core-graphics 0.19.2", + "libc", + "objc", +] + [[package]] name = "cosmic-comp" version = "0.1.0" @@ -185,7 +316,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -195,17 +326,58 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "lazy_static", ] +[[package]] +name = "cty" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" + +[[package]] +name = "darling" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "dirs-next" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "dirs-sys-next", ] @@ -220,6 +392,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + [[package]] name = "dlib" version = "0.5.0" @@ -310,6 +488,27 @@ dependencies = [ "instant", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "gbm" version = "0.7.0" @@ -348,7 +547,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi", ] @@ -385,6 +584,12 @@ dependencies = [ "libc", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "indexmap" version = "1.8.0" @@ -401,7 +606,25 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + +[[package]] +name = "js-sys" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" +dependencies = [ + "wasm-bindgen", ] [[package]] @@ -428,7 +651,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "winapi", ] @@ -447,7 +670,16 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", +] + +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", ] [[package]] @@ -456,6 +688,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "memmap2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b6c2ebff6180198788f5db08d7ce3bc1d0b617176678831a7510825973e357" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.6.5" @@ -465,6 +706,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.4.4" @@ -475,6 +722,74 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mio" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2" +dependencies = [ + "libc", + "log", + "miow", + "ntapi", + "winapi", +] + +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", +] + +[[package]] +name = "ndk" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d868f654c72e75f8687572699cdabe755f03effbb62542768e995d5b8d699d" +dependencies = [ + "bitflags", + "jni-sys", + "ndk-sys", + "num_enum", + "thiserror", +] + +[[package]] +name = "ndk-glue" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc291b8de2095cba8dab7cf381bf582ff4c17a09acf854c32e46545b08085d28" +dependencies = [ + "lazy_static", + "libc", + "log", + "ndk", + "ndk-macro", + "ndk-sys", +] + +[[package]] +name = "ndk-macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c" +dependencies = [ + "darling", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ndk-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121" + [[package]] name = "nix" version = "0.22.0" @@ -483,7 +798,7 @@ checksum = "cf1e25ee6b412c2a1e3fcb6a4499a5c1bfe7f43e014bdce9a6b6666e5aa2d187" dependencies = [ "bitflags", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "memoffset", ] @@ -494,6 +809,26 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" +[[package]] +name = "nom" +version = "7.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" +dependencies = [ + "memchr", + "minimal-lexical", + "version_check", +] + +[[package]] +name = "ntapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +dependencies = [ + "winapi", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -513,6 +848,36 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_enum" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "720d3ea1055e4e4574c0c0b0f8c3fd4f24c4cdaf465948206dea090b57b526ad" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d992b768490d7fe0d8586d9b5745f6c49f557da6d81dc982b1d167ad4edbb21" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", +] + [[package]] name = "object" version = "0.27.1" @@ -554,7 +919,7 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "instant", "libc", "redox_syscall", @@ -562,6 +927,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + [[package]] name = "pkg-config" version = "0.3.24" @@ -574,6 +945,16 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +[[package]] +name = "proc-macro-crate" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebace6889caf889b4d3f76becee12e90353f2b8c7d875534a71e5742f8f6f83" +dependencies = [ + "thiserror", + "toml", +] + [[package]] name = "proc-macro2" version = "1.0.36" @@ -632,6 +1013,15 @@ dependencies = [ "rand_core", ] +[[package]] +name = "raw-window-handle" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba75eee94a9d5273a68c9e1e105d9cffe1ef700532325788389e5a83e2522b7" +dependencies = [ + "cty", +] + [[package]] name = "redox_syscall" version = "0.2.10" @@ -690,6 +1080,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "serde" +version = "1.0.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a" + [[package]] name = "slog" version = "2.7.0" @@ -777,13 +1173,34 @@ dependencies = [ "tempfile", "thiserror", "wayland-commons", + "wayland-egl", "wayland-protocols", "wayland-server", "wayland-sys", + "winit", "x11rb", "xkbcommon", ] +[[package]] +name = "smithay-client-toolkit" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1325f292209cee78d5035530932422a30aa4c8fda1a16593ac083c1de211e68a" +dependencies = [ + "bitflags", + "calloop", + "dlib", + "lazy_static", + "log", + "memmap2", + "nix", + "pkg-config", + "wayland-client", + "wayland-cursor", + "wayland-protocols", +] + [[package]] name = "smithay-egui" version = "0.1.0" @@ -797,6 +1214,12 @@ dependencies = [ "xkbcommon", ] +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "syn" version = "1.0.85" @@ -820,7 +1243,7 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "fastrand", "libc", "redox_syscall", @@ -878,6 +1301,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "toml" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +dependencies = [ + "serde", +] + [[package]] name = "ttf-parser" version = "0.14.0" @@ -902,6 +1334,76 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +[[package]] +name = "wasm-bindgen" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" + +[[package]] +name = "wayland-client" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91223460e73257f697d9e23d401279123d36039a3f7a449e983f123292d4458f" +dependencies = [ + "bitflags", + "downcast-rs", + "libc", + "nix", + "scoped-tls", + "wayland-commons", + "wayland-scanner", + "wayland-sys", +] + [[package]] name = "wayland-commons" version = "0.29.4" @@ -914,6 +1416,27 @@ dependencies = [ "wayland-sys", ] +[[package]] +name = "wayland-cursor" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c52758f13d5e7861fc83d942d3d99bf270c83269575e52ac29e5b73cb956a6bd" +dependencies = [ + "nix", + "wayland-client", + "xcursor", +] + +[[package]] +name = "wayland-egl" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83281d69ee162b59031c666385e93bde4039ec553b90c4191cdb128ceea29a3a" +dependencies = [ + "wayland-client", + "wayland-sys", +] + [[package]] name = "wayland-protocols" version = "0.29.4" @@ -921,6 +1444,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60147ae23303402e41fe034f74fb2c35ad0780ee88a1c40ac09a3be1e7465741" dependencies = [ "bitflags", + "wayland-client", "wayland-commons", "wayland-scanner", "wayland-server", @@ -962,11 +1486,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9341df79a8975679188e37dab3889bfa57c44ac2cb6da166f519a81cbe452d4" dependencies = [ "dlib", + "lazy_static", "libc", "memoffset", "pkg-config", ] +[[package]] +name = "web-sys" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi" version = "0.3.9" @@ -998,6 +1533,50 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "winit" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b43cc931d58b99461188607efd7acb2a093e65fc621f54cad78517a6063e73a" +dependencies = [ + "bitflags", + "cocoa", + "core-foundation 0.9.2", + "core-graphics 0.22.3", + "core-video-sys", + "dispatch", + "instant", + "lazy_static", + "libc", + "log", + "mio", + "ndk", + "ndk-glue", + "ndk-sys", + "objc", + "parking_lot", + "percent-encoding", + "raw-window-handle", + "smithay-client-toolkit", + "wasm-bindgen", + "wayland-client", + "wayland-protocols", + "web-sys", + "winapi", + "x11-dl", +] + +[[package]] +name = "x11-dl" +version = "2.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea26926b4ce81a6f5d9d0f3a0bc401e5a37c6ae14a1bfaa8ff6099ca80038c59" +dependencies = [ + "lazy_static", + "libc", + "pkg-config", +] + [[package]] name = "x11rb" version = "0.9.0" @@ -1010,6 +1589,15 @@ dependencies = [ "winapi-wsapoll", ] +[[package]] +name = "xcursor" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7" +dependencies = [ + "nom", +] + [[package]] name = "xkbcommon" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 55515f3f..8d7b1faf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ version = "0.3" git = "https://github.com/Smithay/smithay.git" rev = "92d04ba8" default-features = false -features = ["backend_x11", "backend_egl", "desktop", "use_system_lib", "renderer_gl", "wayland_frontend", "slog-stdlog"] +features = ["backend_x11", "backend_egl", "backend_winit", "desktop", "use_system_lib", "renderer_gl", "wayland_frontend", "slog-stdlog"] [dependencies.smithay-egui] git = "https://github.com/Smithay/smithay-egui.git" diff --git a/src/backend/mod.rs b/src/backend/mod.rs index eea336ef..7b86e7b5 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -5,14 +5,27 @@ use anyhow::Result; use smithay::reexports::calloop::EventLoop; pub mod x11; +pub mod winit; // TODO // pub mod wayland; // tbd in smithay // pub mod udev; pub fn init_backend_auto(event_loop: &mut EventLoop, state: &mut State) -> Result<()> { - if std::env::var_os("DISPLAY").is_some() { - x11::init_backend(event_loop, state) - } else { - unimplemented!("Currently this runs only nested") + match std::env::var("COSMIC_BACKEND") { + Ok(x) if x == "x11" => x11::init_backend(event_loop, state), + Ok(x) if x == "winit" => winit::init_backend(event_loop, state), + Ok(_) => unimplemented!("There is no backend with this identifier"), + Err(_) => if std::env::var_os("DISPLAY").is_some() || std::env::var_os("WAYLAND_DISPLAY").is_some() { + match x11::init_backend(event_loop, state) { + Ok(_) => Ok(()), + Err(err) => { + slog_scope::warn!("X11 Backend failed with error: {}", err); + slog_scope::info!("Falling back to winit backend."); + winit::init_backend(event_loop, state) + } + } + } else { + unimplemented!("Currently this runs only nested") + } } } diff --git a/src/backend/winit.rs b/src/backend/winit.rs new file mode 100644 index 00000000..4b3e0984 --- /dev/null +++ b/src/backend/winit.rs @@ -0,0 +1,224 @@ +// SPDX-License-Identifier: GPL-3.0-only + +use crate::state::Common; +use crate::{ + input::{set_active_output, Devices}, + state::{BackendData, State}, +}; +use anyhow::{Context, Result}; +use smithay::{ + backend::{ + renderer::{ImportDma, ImportEgl}, + winit::{self, WinitGraphicsBackend, WinitEvent, WinitVirtualDevice}, + }, + desktop::layer_map_for_output, + reexports::{ + calloop::{ping, EventLoop}, + wayland_server::{ + protocol::wl_output::{Subpixel, Transform}, + Display, + }, + }, + wayland::{ + dmabuf::init_dmabuf_global, + output::{Mode, Output, PhysicalProperties}, + }, +}; +use std::{ + cell::RefCell, + rc::Rc, +}; + +#[cfg(feature = "debug")] +use smithay::backend::renderer::gles2::Gles2Renderer; +#[cfg(feature = "debug")] +use crate::{debug::debug_ui, state::Fps}; + +pub struct WinitState { + // The winit backend currently has no notion of multiple windows + backend: Rc>, + //_global: GlobalDrop, + output: Output, + #[cfg(feature = "debug")] + fps: Fps, +} + +impl WinitState { + pub fn render_output( + &mut self, + state: &mut Common, + ) -> Result<()> { + #[allow(unused_mut)] + let mut custom_elements = Vec::new(); + + #[cfg(feature = "debug")] + { + let space = state.spaces.active_space(&self.output); + let size = space.output_geometry(&self.output).unwrap(); + let scale = space.output_scale(&self.output).unwrap(); + let frame = debug_ui(state, &self.fps, size, scale, true); + custom_elements.push( + Box::new(frame) as smithay::desktop::space::DynamicRenderElements + ); + } + + let space = state.spaces.active_space_mut(&self.output); + let mut backend = self.backend.borrow_mut(); + + let age = backend.buffer_age(); + backend.bind().with_context(|| "Failed to bind buffer")?; + match space.render_output( + backend.renderer(), + &self.output, + age as usize, + [0.153, 0.161, 0.165, 1.0], + &*custom_elements, + ) { + Ok(damage) => { + space.send_frames(false, state.start_time.elapsed().as_millis() as u32); + backend + .submit(damage.as_ref().map(|x| &**x), 1.0) + .with_context(|| "Failed to submit buffer for display")?; + #[cfg(feature = "debug")] + { + self.fps.tick(); + } + } + Err(err) => { + anyhow::bail!("Rendering failed: {}", err); + } + }; + + Ok(()) + } +} + +pub fn init_backend(event_loop: &mut EventLoop, state: &mut State) -> Result<()> { + let (backend, mut input) = winit::init(None).with_context(|| "Failed to initilize winit backend")?; + let backend = Rc::new(RefCell::new(backend)); + + init_egl_client_side(&mut *state.common.display.borrow_mut(), backend.clone())?; + + let name = format!("WINIT-0"); + let size = backend.borrow().window_size(); + let props = PhysicalProperties { + size: (0, 0).into(), + subpixel: Subpixel::Unknown, + make: "COSMIC".to_string(), + model: name.clone(), + }; + let mode = Mode { + size: (size.physical_size.w as i32, size.physical_size.h as i32).into(), + refresh: 60_000, + }; + let (output, _global) = Output::new(&mut *state.common.display.borrow_mut(), name, props, None); + //let _global = global.into(); + output.change_current_state(Some(mode), Some(Transform::Flipped180), None, Some((0, 0).into())); + output.set_preferred(mode); + + state.common.spaces.map_output(&output); + + let (event_ping, event_source) = ping::make_ping().with_context(|| "Failed to init eventloop timer for winit")?; + let (render_ping, render_source) = ping::make_ping().with_context(|| "Failed to init eventloop timer for winit")?; + let event_ping_handle = event_ping.clone(); + let render_ping_handle = render_ping.clone(); + let mut token = Some(event_loop + .handle() + .insert_source( + render_source, + move |_, _, state| { + if let Err(err) = state.backend.winit().render_output(&mut state.common) { + slog_scope::error!("Failed to render frame: {}", err); + render_ping.ping(); + } + } + ).map_err(|_| anyhow::anyhow!("Failed to init eventloop timer for winit"))?); + let event_loop_handle = event_loop.handle(); + event_loop + .handle() + .insert_source( + event_source, + move |_, _, state| { + match input.dispatch_new_events(|event| state.process_winit_event(event, &render_ping_handle)) { + Ok(_) => { + event_ping_handle.ping(); + render_ping_handle.ping(); + }, + Err(winit::WinitError::WindowClosed) => { + let winit_state = state.backend.winit(); + state.common.spaces.unmap_output(&winit_state.output); + if let Some(token) = token.take() { + event_loop_handle.remove(token); + } + } + }; + } + ).map_err(|_| anyhow::anyhow!("Failed to init eventloop timer for winit"))?; + event_ping.ping(); + + state.backend = BackendData::Winit(WinitState { + backend, + output, + #[cfg(feature = "debug")] + fps: Fps::default(), + }); + + Ok(()) +} + +fn init_egl_client_side(display: &mut Display, renderer: Rc>) -> Result<()> { + let bind_result = renderer.borrow_mut().renderer().bind_wl_display(display); + match bind_result { + Ok(_) => { + slog_scope::info!("EGL hardware-acceleration enabled"); + let dmabuf_formats = renderer + .borrow_mut() + .renderer() + .dmabuf_formats() + .cloned() + .collect::>(); + init_dmabuf_global( + display, + dmabuf_formats, + move |buffer, _| renderer.borrow_mut().renderer().import_dmabuf(buffer).is_ok(), + None, + ); + } + Err(err) => slog_scope::warn!("Unable to initialize bind display to EGL: {}", err), + }; + + Ok(()) +} + +impl State { + pub fn process_winit_event(&mut self, event: WinitEvent, render_ping: &ping::Ping) { + // here we can handle special cases for winit inputs + match event { + WinitEvent::Focus(true) => { + for seat in self.common.seats.clone().iter() { + let devices = seat.user_data().get::().unwrap(); + if devices.has_device(&WinitVirtualDevice) { + set_active_output(seat, &self.backend.winit().output); + break; + } + } + } + WinitEvent::Resized { size, .. } => { + let winit_state = self.backend.winit(); + let output = &winit_state.output; + let mode = Mode { + size, + refresh: 60_000, + }; + output.delete_mode(output.current_mode().unwrap()); + output.change_current_state(Some(mode), None, None, None); + output.set_preferred(mode); + layer_map_for_output(output).arrange(); + render_ping.ping(); + }, + WinitEvent::Refresh => render_ping.ping(), + WinitEvent::Input(event) => self.common.process_input_event(event), + _ => {}, + }; + } +} diff --git a/src/state.rs b/src/state.rs index 35b04e92..736dfff0 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,7 +1,10 @@ // SPDX-License-Identifier: GPL-3.0-only use crate::{ - backend::x11::X11State, + backend::{ + x11::X11State, + winit::WinitState, + }, shell::{init_shell, workspaces::Workspaces, ShellStates}, }; use smithay::{ @@ -59,6 +62,7 @@ pub struct Fps { pub enum BackendData { X11(X11State), + Winit(WinitState), // TODO // Wayland(WaylandState), // Udev(UdevState), @@ -72,6 +76,13 @@ impl BackendData { _ => unreachable!("Called x11 in non x11 backend"), } } + + pub fn winit(&mut self) -> &mut WinitState { + match self { + BackendData::Winit(ref mut winit_state) => winit_state, + _ => unreachable!("Called winit in non winit backend"), + } + } } impl State {