From 791441ca107d6b2b10a91417bb2035fde575d7cd Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Tue, 21 Nov 2023 16:15:02 -0500 Subject: [PATCH] refactor: single instance --- Cargo.lock | 261 +++++++++++++++++++++++--------------- Cargo.toml | 4 +- debian/control | 1 + src/main.rs | 125 ++++++++++++------ src/toggle_dbus.rs | 46 ------- src/view/mod.rs | 23 ++-- src/wayland/buffer.rs | 1 + src/wayland/capture.rs | 1 + src/wayland/dmabuf.rs | 1 + src/wayland/mod.rs | 2 +- src/wayland/screencopy.rs | 1 + src/wayland/toplevel.rs | 1 + src/wayland/workspace.rs | 1 + 13 files changed, 272 insertions(+), 196 deletions(-) delete mode 100644 src/toggle_dbus.rs diff --git a/Cargo.lock b/Cargo.lock index 2b7b407..2cb103f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,6 +104,54 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" + +[[package]] +name = "anstyle-parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +dependencies = [ + "anstyle", + "windows-sys", +] + [[package]] name = "anyhow" version = "1.0.75" @@ -209,15 +257,15 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.6.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0c4a4f319e45986f347ee47fef8bf5e81c9abc3f6f58dc2391439f30df65f0" +checksum = "fc5ea910c42e5ab19012bab31f53cb4d63d54c3a27730f9a833a88efcf4bb52d" dependencies = [ - "async-lock 2.8.0", + "async-lock 3.1.1", "async-task", "concurrent-queue", "fastrand 2.0.1", - "futures-lite 1.13.0", + "futures-lite 2.0.1", "slab", ] @@ -259,14 +307,14 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41ed9d5715c2d329bf1b4da8d60455b99b187f27ba726df2883799af9af60997" dependencies = [ - "async-lock 3.1.0", + "async-lock 3.1.1", "cfg-if", "concurrent-queue", "futures-io", "futures-lite 2.0.1", "parking", "polling 3.3.0", - "rustix 0.38.24", + "rustix 0.38.25", "slab", "tracing", "waker-fn", @@ -284,9 +332,9 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb2ab2aa8a746e221ab826c73f48bc6ba41be6763f0855cb249eb6d154cf1d7" +checksum = "655b9c7fe787d3b25cc0f804a1a8401790f0c5bc395beb5a64dc77d8de079105" dependencies = [ "event-listener 3.1.0", "event-listener-strategy", @@ -306,7 +354,7 @@ dependencies = [ "cfg-if", "event-listener 3.1.0", "futures-lite 1.13.0", - "rustix 0.38.24", + "rustix 0.38.25", "windows-sys", ] @@ -333,7 +381,7 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix 0.38.24", + "rustix 0.38.25", "signal-hook-registry", "slab", "windows-sys", @@ -367,7 +415,7 @@ name = "atomicwrites" version = "0.4.2" source = "git+https://github.com/jackpot51/rust-atomicwrites#043ab4859d53ffd3d55334685303d8df39c9f768" dependencies = [ - "rustix 0.38.24", + "rustix 0.38.25", "tempfile", "windows-sys", ] @@ -484,7 +532,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ "async-channel 2.1.0", - "async-lock 3.1.0", + "async-lock 3.1.1", "async-task", "fastrand 2.0.1", "futures-io", @@ -540,7 +588,7 @@ dependencies = [ "bitflags 2.4.1", "log", "polling 3.3.0", - "rustix 0.38.24", + "rustix 0.38.25", "slab", "thiserror", ] @@ -552,7 +600,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" dependencies = [ "calloop", - "rustix 0.38.24", + "rustix 0.38.25", "wayland-backend 0.3.2", "wayland-client 0.31.1", ] @@ -578,6 +626,46 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +[[package]] +name = "clap" +version = "4.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "clap_lex" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" + [[package]] name = "cocoa" version = "0.25.0" @@ -624,6 +712,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "com-rs" version = "0.2.1" @@ -682,7 +776,7 @@ dependencies = [ [[package]] name = "cosmic-client-toolkit" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-protocols#5faec87be0a1fd1d72e99431ac8e6647ff1dfd41" +source = "git+https://github.com/pop-os/cosmic-protocols?rev=5faec87#5faec87be0a1fd1d72e99431ac8e6647ff1dfd41" dependencies = [ "cosmic-protocols", "smithay-client-toolkit 0.18.0", @@ -692,7 +786,7 @@ dependencies = [ [[package]] name = "cosmic-comp-config" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-comp#92c16bd4adabbd00123284176a2e4cc52b5131c7" +source = "git+https://github.com/pop-os/cosmic-comp#3dee249558c7e3f7b4b0fc46e459c996068514f9" dependencies = [ "input", "serde", @@ -701,7 +795,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -715,7 +809,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "quote", "syn 1.0.109", @@ -724,7 +818,7 @@ dependencies = [ [[package]] name = "cosmic-protocols" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-protocols#5faec87be0a1fd1d72e99431ac8e6647ff1dfd41" +source = "git+https://github.com/pop-os/cosmic-protocols?rev=5faec87#5faec87be0a1fd1d72e99431ac8e6647ff1dfd41" dependencies = [ "bitflags 2.4.1", "wayland-backend 0.3.2", @@ -757,7 +851,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "almost", "cosmic-config", @@ -774,7 +868,7 @@ version = "0.1.0" dependencies = [ "anyhow", "calloop", - "cosmic-client-toolkit", + "clap", "cosmic-comp-config", "cosmic-config", "env_logger", @@ -1066,7 +1160,7 @@ dependencies = [ "bytemuck", "drm-ffi 0.7.0", "drm-fourcc", - "rustix 0.38.24", + "rustix 0.38.25", ] [[package]] @@ -1086,7 +1180,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "220dd8c12ebf2b0cbaffa19e00de02f5f090d363fb900f16ea012c077eea1174" dependencies = [ "drm-sys 0.6.0", - "rustix 0.38.24", + "rustix 0.38.25", ] [[package]] @@ -1180,9 +1274,9 @@ dependencies = [ [[package]] name = "etagere" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf22f748754352918e082e0039335ee92454a5d62bcaf69b5e8daf5907d9644" +checksum = "306960881d6c46bd0dd6b7f07442a441418c08d0d3e63d8d080b0f64c6343e4e" dependencies = [ "euclid", "svg_fmt", @@ -1502,7 +1596,11 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" dependencies = [ + "fastrand 2.0.1", "futures-core", + "futures-io", + "memchr", + "parking", "pin-project-lite", ] @@ -1795,7 +1893,7 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "iced" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "iced_accessibility", "iced_core", @@ -1810,7 +1908,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "accesskit", "accesskit_unix", @@ -1819,7 +1917,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "bitflags 1.3.2", "iced_accessibility", @@ -1835,7 +1933,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.7.0" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "futures", "iced_core", @@ -1848,7 +1946,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -1866,7 +1964,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -1879,7 +1977,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.1.1" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "iced_accessibility", "iced_core", @@ -1891,7 +1989,7 @@ dependencies = [ [[package]] name = "iced_sctk" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "enum-repr", "float-cmp", @@ -1915,7 +2013,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "iced_core", "once_cell", @@ -1925,7 +2023,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "bytemuck", "cosmic-text", @@ -1943,7 +2041,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.11.1" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -1965,7 +2063,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.1.3" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "iced_renderer", "iced_runtime", @@ -2114,7 +2212,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.24", + "rustix 0.38.25", "windows-sys", ] @@ -2215,10 +2313,11 @@ checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#7ea8a6103b923bee3b06771fb7ae0b6635d623ea" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "apply", "ashpd", + "cosmic-client-toolkit", "cosmic-config", "cosmic-theme", "css-color", @@ -2236,14 +2335,16 @@ dependencies = [ "iced_widget", "lazy_static", "palette", + "ron", + "serde", "slotmap", - "smithay-client-toolkit 0.17.0", "taffy", "thiserror", "tokio", "tracing", "unicode-segmentation", "url", + "zbus", ] [[package]] @@ -2348,9 +2449,9 @@ dependencies = [ [[package]] name = "lyon_algorithms" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00a0349cd8f0270781bb93a824b63df6178e3b4a27794e7be3ce3763f5a44d6e" +checksum = "a3bca95f9a4955b3e4a821fbbcd5edfbd9be2a9a50bb5758173e5358bfb4c623" dependencies = [ "lyon_path", "num-traits", @@ -2421,15 +2522,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memmap2" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f49388d20533534cd19360ad3d6a7dadc885944aa802ba3995040c5ec11288c6" -dependencies = [ - "libc", -] - [[package]] name = "memmap2" version = "0.8.0" @@ -3006,7 +3098,7 @@ dependencies = [ "cfg-if", "concurrent-queue", "pin-project-lite", - "rustix 0.38.24", + "rustix 0.38.25", "tracing", "windows-sys", ] @@ -3334,9 +3426,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.24" +version = "0.38.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234" +checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" dependencies = [ "bitflags 2.4.1", "errno", @@ -3401,18 +3493,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -3513,33 +3605,6 @@ dependencies = [ "wayland-protocols 0.29.5", ] -[[package]] -name = "smithay-client-toolkit" -version = "0.17.0" -source = "git+https://github.com/smithay/client-toolkit?rev=dc8c4a0#dc8c4a035128208af65141fe12142a1dbc4a32bb" -dependencies = [ - "bitflags 2.4.1", - "bytemuck", - "calloop", - "calloop-wayland-source", - "cursor-icon", - "dlib", - "log", - "memmap2 0.7.1", - "nix 0.26.4", - "pkg-config", - "thiserror", - "wayland-backend 0.3.2", - "wayland-client 0.31.1", - "wayland-csd-frame", - "wayland-cursor 0.31.0", - "wayland-protocols 0.31.0", - "wayland-protocols-wlr", - "wayland-scanner 0.31.0", - "xkbcommon 0.5.1", - "xkeysym", -] - [[package]] name = "smithay-client-toolkit" version = "0.18.0" @@ -3554,7 +3619,7 @@ dependencies = [ "log", "memmap2 0.9.0", "pkg-config", - "rustix 0.38.24", + "rustix 0.38.25", "thiserror", "wayland-backend 0.3.2", "wayland-client 0.31.1", @@ -3563,7 +3628,7 @@ dependencies = [ "wayland-protocols 0.31.0", "wayland-protocols-wlr", "wayland-scanner 0.31.0", - "xkbcommon 0.7.0", + "xkbcommon", "xkeysym", ] @@ -3616,7 +3681,7 @@ dependencies = [ "objc", "raw-window-handle", "redox_syscall 0.4.1", - "rustix 0.38.24", + "rustix 0.38.25", "tiny-xlib", "wasm-bindgen", "wayland-backend 0.3.2", @@ -3727,7 +3792,7 @@ dependencies = [ [[package]] name = "taffy" version = "0.3.11" -source = "git+https://github.com/DioxusLabs/taffy#1876f72bee5e376023eaa518aa7b8a34c769bd1b" +source = "git+https://github.com/DioxusLabs/taffy#70b35712a2e79b6fdfef4cff4392ca94287cd0b1" dependencies = [ "arrayvec", "grid", @@ -3744,7 +3809,7 @@ dependencies = [ "cfg-if", "fastrand 2.0.1", "redox_syscall 0.4.1", - "rustix 0.38.24", + "rustix 0.38.25", "windows-sys", ] @@ -4105,6 +4170,12 @@ dependencies = [ "tiny-skia-path", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "version_check" version = "0.9.4" @@ -4815,16 +4886,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "xkbcommon" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52db25b599e92bf6e3904134618728eeb7b49a5a4f38f107f92399bb9c496b88" -dependencies = [ - "libc", - "memmap2 0.7.1", -] - [[package]] name = "xkbcommon" version = "0.7.0" diff --git a/Cargo.toml b/Cargo.toml index d407130..dd76218 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,12 +6,12 @@ edition = "2021" [dependencies] anyhow = "1.0.75" calloop = "0.12.3" -cctk = { package = "cosmic-client-toolkit", git = "https://github.com/pop-os/cosmic-protocols" } +clap = { version = "4", features = ["derive"] } cosmic-comp-config = { git = "https://github.com/pop-os/cosmic-comp" } env_logger = "0.10.0" futures-channel = "0.3.25" gbm = "0.14.0" -libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = ["tokio", "wayland"] } +libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = ["tokio", "wayland", "single-instance"] } cosmic-config = { git = "https://github.com/pop-os/libcosmic" } memmap2 = "0.9.0" tokio = "1.23.0" diff --git a/debian/control b/debian/control index 0f28fcd..e894fb5 100644 --- a/debian/control +++ b/debian/control @@ -8,6 +8,7 @@ Build-Depends: cargo, libegl1-mesa-dev, libgbm-dev, + libinput-dev, libudev-dev, libxkbcommon-dev, libwayland-dev, diff --git a/src/main.rs b/src/main.rs index 092191a..034c06b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,10 @@ use cctk::{ Connection, Proxy, WEnum, }, }; +use clap::Parser; use cosmic::{ + app::{Application, CosmicFlags, DbusActivationDetails, Message}, + cctk, iced::{ self, event::wayland::{Event as WaylandEvent, OutputEvent}, @@ -22,7 +25,7 @@ use cosmic::{ actions::data_device::{DataFromMimeType, DndIcon}, data_device::{accept_mime_type, set_actions, start_drag}, }, - widget, Application, Command, Size, Subscription, + widget, Command, Size, Subscription, }, iced_runtime::{ command::platform_specific::wayland::layer_surface::{ @@ -30,10 +33,7 @@ use cosmic::{ }, window::Id as SurfaceId, }, - iced_sctk::{ - commands::layer_surface::{destroy_layer_surface, get_layer_surface}, - settings::InitialSurface, - }, + iced_sctk::commands::layer_surface::{destroy_layer_surface, get_layer_surface}, }; use cosmic_config::ConfigGet; use std::{ @@ -43,12 +43,34 @@ use std::{ // accept_mime_type, finish_dnd, request_dnd_data, set_actions, -mod toggle_dbus; mod view; mod wayland; static WORKSPACE_MIME: &str = "text/x.cosmic-workspace-id"; +#[derive(Parser, Debug, Clone)] +#[command(author, version, about, long_about = None)] +#[command(propagate_version = true)] +pub struct Args {} + +#[derive(Default, Debug, Clone)] +pub struct WorkspaceCommands; + +impl ToString for WorkspaceCommands { + fn to_string(&self) -> String { + String::new() + } +} + +impl CosmicFlags for Args { + type SubCommand = WorkspaceCommands; + type Args = Vec; + + fn action(&self) -> Option<&WorkspaceCommands> { + None + } +} + struct WorkspaceDndId(String); impl DataFromMimeType for WorkspaceDndId { @@ -71,7 +93,6 @@ enum Msg { CloseWorkspace(zcosmic_workspace_handle_v1::ZcosmicWorkspaceHandleV1), ActivateToplevel(zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1), CloseToplevel(zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1), - DBus(toggle_dbus::Event), StartDrag(Size, DragSurface), SourceFinished, DndWorkspaceEnter(DndAction, Vec, (f32, f32)), @@ -152,6 +173,7 @@ struct App { wayland_cmd_sender: Option>, drag_surface: Option<(SurfaceId, DragSurface, Size)>, conf: Conf, + core: cosmic::app::Core, } impl App { @@ -181,7 +203,10 @@ impl App { self.toplevels.iter_mut().find(|i| &i.handle == handle) } - fn create_surface(&mut self, output: wl_output::WlOutput) -> Command { + fn create_surface( + &mut self, + output: wl_output::WlOutput, + ) -> Command> { let id = self.next_surface_id(); self.layer_surfaces.insert( id, @@ -201,7 +226,10 @@ impl App { }) } - fn destroy_surface(&mut self, output: &wl_output::WlOutput) -> Command { + fn destroy_surface( + &mut self, + output: &wl_output::WlOutput, + ) -> Command> { if let Some((id, _)) = self .layer_surfaces .iter() @@ -215,7 +243,7 @@ impl App { } } - fn toggle(&mut self) -> Command { + fn toggle(&mut self) -> Command> { if self.visible { self.hide() } else { @@ -223,7 +251,7 @@ impl App { } } - fn show(&mut self) -> Command { + fn show(&mut self) -> Command> { if !self.visible { self.visible = true; let outputs = self.outputs.clone(); @@ -241,7 +269,7 @@ impl App { } // Close all shell surfaces - fn hide(&mut self) -> Command { + fn hide(&mut self) -> Command> { self.visible = false; self.update_capture_filter(); Command::batch( @@ -273,22 +301,25 @@ impl App { impl Application for App { type Message = Msg; - type Theme = cosmic::Theme; type Executor = iced::executor::Default; - type Flags = (); - - fn new(_flags: ()) -> (Self, Command) { - (Self::default(), Command::none()) - } - - fn title(&self) -> String { - String::from("cosmic-workspaces") + type Flags = Args; + const APP_ID: &'static str = "com.system76.CosmicWorkspaces"; + + fn init( + core: cosmic::app::Core, + _flags: Self::Flags, + ) -> (Self, iced::Command>) { + ( + Self { + core, + ..Default::default() + }, + Command::none(), + ) } - - // TODO transparent style? // TODO: show panel and dock? Drag? - fn update(&mut self, message: Msg) -> Command { + fn update(&mut self, message: Msg) -> Command> { match message { Msg::WaylandEvent(evt) => match evt { WaylandEvent::Output(evt, output) => { @@ -443,9 +474,6 @@ impl Application for App { toplevel_manager.close(&toplevel_handle); } } - Msg::DBus(toggle_dbus::Event::Toggle) => { - return self.toggle(); - } Msg::StartDrag(size, drag_surface) => { match &drag_surface { DragSurface::Workspace { output, name: _ } => { @@ -487,6 +515,16 @@ impl Application for App { Command::none() } + fn dbus_activation( + &mut self, + msg: cosmic::app::DbusActivationMessage, + ) -> iced::Command> { + if let DbusActivationDetails::Activate = msg.msg { + self.toggle() + } else { + Command::none() + } + } fn subscription(&self) -> Subscription { let events = iced::subscription::events_with(|evt, _| { @@ -503,14 +541,18 @@ impl Application for App { None } }); - let mut subscriptions = vec![events, toggle_dbus::subscription().map(Msg::DBus)]; + let mut subscriptions = vec![events]; if let Some(conn) = self.conn.clone() { subscriptions.push(wayland::subscription(conn).map(Msg::Wayland)); } iced::Subscription::batch(subscriptions) } - fn view(&self, id: SurfaceId) -> cosmic::Element { + fn view(&self) -> cosmic::prelude::Element { + unreachable!() + } + + fn view_window(&self, id: iced::window::Id) -> cosmic::prelude::Element { use iced::widget::*; if let Some(surface) = self.layer_surfaces.get(&id) { return view::layer_surface(self, surface); @@ -534,18 +576,27 @@ impl Application for App { text("workspaces").into() } - fn close_requested(&self, id: SurfaceId) -> Msg { - Msg::Closed(id) + fn on_close_requested(&self, id: SurfaceId) -> Option { + Some(Msg::Closed(id)) + } + + fn core(&self) -> &cosmic::app::Core { + &self.core + } + + fn core_mut(&mut self) -> &mut cosmic::app::Core { + &mut self.core } } pub fn main() -> iced::Result { env_logger::init(); - App::run(iced::Settings { - antialiasing: true, - exit_on_close_request: false, - initial_surface: InitialSurface::None, - ..iced::Settings::default() - }) + cosmic::app::run_single_instance::( + cosmic::app::Settings::default() + .antialiasing(true) + .no_main_window(true) + .exit_on_close(false), + Args::parse(), + ) } diff --git a/src/toggle_dbus.rs b/src/toggle_dbus.rs deleted file mode 100644 index cf844ab..0000000 --- a/src/toggle_dbus.rs +++ /dev/null @@ -1,46 +0,0 @@ -use cosmic::iced::{ - self, - futures::{channel::mpsc, future, SinkExt}, - subscription, -}; -use std::fmt::Debug; -use zbus::{dbus_interface, ConnectionBuilder}; - -pub fn subscription() -> iced::Subscription { - subscription::channel("workspaces-dbus", 64, move |sender| async { - if let Some(conn) = ConnectionBuilder::session() - .ok() - .and_then(|conn| conn.name("com.system76.CosmicWorkspaces").ok()) - .and_then(|conn| { - conn.serve_at( - "/com/system76/CosmicWorkspaces", - CosmicWorkspacesServer { sender }, - ) - .ok() - }) - .map(|conn| conn.build()) - { - let _conn = conn.await; - future::pending().await - } else { - future::pending().await - } - }) -} - -#[derive(Debug, Clone, Copy)] -pub enum Event { - Toggle, -} - -#[derive(Debug)] -struct CosmicWorkspacesServer { - sender: mpsc::Sender, -} - -#[dbus_interface(name = "com.system76.CosmicWorkspaces")] -impl CosmicWorkspacesServer { - async fn toggle(&self) { - self.sender.clone().send(Event::Toggle).await.unwrap(); - } -} diff --git a/src/view/mod.rs b/src/view/mod.rs index d032984..7960e48 100644 --- a/src/view/mod.rs +++ b/src/view/mod.rs @@ -3,6 +3,7 @@ use cctk::{ wayland_client::protocol::wl_output, }; use cosmic::{ + cctk, iced::{ self, widget::{column, row}, @@ -36,17 +37,19 @@ pub(crate) fn layer_surface<'a>( }) })); match layout { - WorkspaceLayout::Vertical => row![sidebar, toplevels] - .spacing(12) - .height(iced::Length::Fill) - .width(iced::Length::Fill) - .into(), - WorkspaceLayout::Horizontal => column![sidebar, toplevels] - .spacing(12) - .height(iced::Length::Fill) - .width(iced::Length::Fill) - .into(), + WorkspaceLayout::Vertical => widget::cosmic_container::container( + row![sidebar, toplevels] + .spacing(12) + .height(iced::Length::Fill) + .width(iced::Length::Fill), + ), + WorkspaceLayout::Horizontal => widget::cosmic_container::container( + column![sidebar, toplevels] + .spacing(12) + .height(iced::Length::Fill), + ), } + .into() } fn close_button(on_press: Msg) -> cosmic::Element<'static, Msg> { diff --git a/src/wayland/buffer.rs b/src/wayland/buffer.rs index 3a50cfe..d4585de 100644 --- a/src/wayland/buffer.rs +++ b/src/wayland/buffer.rs @@ -7,6 +7,7 @@ use cctk::{ Connection, Dispatch, QueueHandle, WEnum, }, }; +use cosmic::cctk; use cosmic::iced::widget::image; use std::{ os::fd::{AsFd, OwnedFd}, diff --git a/src/wayland/capture.rs b/src/wayland/capture.rs index 5361b3f..f2842c7 100644 --- a/src/wayland/capture.rs +++ b/src/wayland/capture.rs @@ -7,6 +7,7 @@ use cctk::{ screencopy::{ScreencopySessionData, ScreencopySessionDataExt}, wayland_client::{protocol::wl_output, Proxy, QueueHandle}, }; +use cosmic::cctk; use std::sync::{ atomic::{AtomicBool, Ordering}, diff --git a/src/wayland/dmabuf.rs b/src/wayland/dmabuf.rs index 27cd85f..309df4b 100644 --- a/src/wayland/dmabuf.rs +++ b/src/wayland/dmabuf.rs @@ -5,6 +5,7 @@ use cctk::{ }, wayland_client::{protocol::wl_buffer, Connection, QueueHandle}, }; +use cosmic::cctk; use std::{fs, io, os::unix::fs::MetadataExt, path::PathBuf}; diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index 3370d2c..c6ec8bf 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -5,7 +5,6 @@ // * Need output name to compare? // TODO: Way to activate workspace, toplevel? Close? Move? - use cctk::{ cosmic_protocols::{ toplevel_info::v1::client::zcosmic_toplevel_handle_v1, @@ -30,6 +29,7 @@ use cctk::{ }, workspace::WorkspaceState, }; +use cosmic::cctk; use cosmic::iced::{ self, futures::{executor::block_on, FutureExt, SinkExt}, diff --git a/src/wayland/screencopy.rs b/src/wayland/screencopy.rs index ca45641..01f1881 100644 --- a/src/wayland/screencopy.rs +++ b/src/wayland/screencopy.rs @@ -3,6 +3,7 @@ use cctk::{ screencopy::{BufferInfo, ScreencopyHandler, ScreencopyState}, wayland_client::{Connection, QueueHandle, WEnum}, }; +use cosmic::cctk; use super::{AppData, Capture, CaptureImage, CaptureSource, Event}; diff --git a/src/wayland/toplevel.rs b/src/wayland/toplevel.rs index e7dc293..179c670 100644 --- a/src/wayland/toplevel.rs +++ b/src/wayland/toplevel.rs @@ -7,6 +7,7 @@ use cctk::{ toplevel_management::{ToplevelManagerHandler, ToplevelManagerState}, wayland_client::{Connection, QueueHandle, WEnum}, }; +use cosmic::cctk; use super::{AppData, CaptureSource, Event}; diff --git a/src/wayland/workspace.rs b/src/wayland/workspace.rs index cf06f91..ca8dab4 100644 --- a/src/wayland/workspace.rs +++ b/src/wayland/workspace.rs @@ -1,4 +1,5 @@ use cctk::workspace::{WorkspaceHandler, WorkspaceState}; +use cosmic::cctk; use super::{AppData, CaptureSource, Event};