From 2b7a8b133ee949cee7f024a828911c94022e5fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuka=C5=A1in=20Vojinovi=C4=87?= Date: Wed, 9 Apr 2025 13:40:08 +0200 Subject: [PATCH] improv(view): make workspace item sizing more dynamic This makes the `workspace_bar` more responsive to different child sizes, which enables fixing the size of the smaller dimension of the screencopy, while allowing it to expand unrestricted in the larger dimension (to match the aspect ratio). --- Cargo.lock | 400 +++++++++++++++++------------------ Cargo.toml | 14 +- src/desktop_info.rs | 6 +- src/view/mod.rs | 146 ++++++++----- src/widgets/workspace_bar.rs | 45 ++-- 5 files changed, 322 insertions(+), 289 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b78c105..9252a4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -141,12 +141,6 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" -[[package]] -name = "allocator-api2" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" - [[package]] name = "almost" version = "0.2.0" @@ -575,6 +569,18 @@ dependencies = [ "zbus 3.15.2", ] +[[package]] +name = "auto_enums" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c170965892137a3a9aeb000b4524aa3cc022a310e709d848b6e1cdce4ab4781" +dependencies = [ + "derive_utils", + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "autocfg" version = "1.4.0" @@ -734,39 +740,6 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" -[[package]] -name = "cached" -version = "0.54.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9718806c4a2fe9e8a56fd736f97b340dd10ed1be8ed733ed50449f351dc33cae" -dependencies = [ - "ahash", - "cached_proc_macro", - "cached_proc_macro_types", - "hashbrown 0.14.5", - "once_cell", - "thiserror 1.0.69", - "web-time", -] - -[[package]] -name = "cached_proc_macro" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f42a145ed2d10dce2191e1dcf30cfccfea9026660e143662ba5eec4017d5daa" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.98", -] - -[[package]] -name = "cached_proc_macro_types" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" - [[package]] name = "calloop" version = "0.13.0" @@ -856,16 +829,16 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" -version = "0.4.39" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" +checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.6", + "windows-link", ] [[package]] @@ -933,7 +906,7 @@ version = "0.2.2" source = "git+https://github.com/pop-os/window_clipboard.git?tag=pop-0.13-2#6b9faab87bea9cebec6ae036906fd67fed254f5f" dependencies = [ "dnd", - "mime", + "mime 0.1.0", "smithay-clipboard", ] @@ -1004,7 +977,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a5f405d474b9d05e0a093d3120e77e9bf26461b57a84b40aa2a221ac5617fb6" dependencies = [ - "csscolorparser", + "csscolorparser 0.6.2", ] [[package]] @@ -1057,26 +1030,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "const-random" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" -dependencies = [ - "const-random-macro", -] - -[[package]] -name = "const-random-macro" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" -dependencies = [ - "getrandom 0.2.15", - "once_cell", - "tiny-keccak", -] - [[package]] name = "core-foundation" version = "0.9.4" @@ -1157,16 +1110,16 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "atomicwrites", "cosmic-config-derive", - "dirs", + "dirs 6.0.0", "iced_futures", "known-folders", "notify", "once_cell", - "ron 0.9.0-alpha.1", + "ron 0.9.0", "serde", "tokio", "tracing", @@ -1176,7 +1129,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "quote", "syn 1.0.109", @@ -1185,12 +1138,12 @@ dependencies = [ [[package]] name = "cosmic-freedesktop-icons" version = "0.3.0" -source = "git+https://github.com/pop-os/freedesktop-icons#98f78d49022c893be2e974e95d95aaea963a6833" +source = "git+https://github.com/pop-os/freedesktop-icons#8a05c322c482ff3c69cf34bacfee98907ac45307" dependencies = [ - "dirs", + "dirs 5.0.1", "ini_core", - "once_cell", - "thiserror 1.0.69", + "memmap2 0.9.5", + "thiserror 2.0.12", "tracing", "xdg", ] @@ -1211,8 +1164,8 @@ dependencies = [ [[package]] name = "cosmic-text" -version = "0.13.2" -source = "git+https://github.com/pop-os/cosmic-text.git#500a8fc6d172de5c9e08c6013070b6b7fcdf79dd" +version = "0.14.1" +source = "git+https://github.com/pop-os/cosmic-text.git#87a937056da57e3c8ac367b5d74c6d488dd94ac6" dependencies = [ "bitflags 2.8.0", "fontdb 0.16.2", @@ -1234,18 +1187,18 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "almost", "cosmic-config", - "csscolorparser", - "dirs", + "csscolorparser 0.7.0", + "dirs 6.0.0", "lazy_static", "palette", - "ron 0.9.0-alpha.1", + "ron 0.9.0", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.12", ] [[package]] @@ -1262,7 +1215,6 @@ dependencies = [ "cosmic-config", "delegate", "env_logger", - "freedesktop-desktop-entry", "freedesktop-icons", "futures-channel", "futures-executor", @@ -1298,15 +1250,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "crossbeam-utils" version = "0.8.21" @@ -1340,6 +1283,15 @@ name = "csscolorparser" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb2a7d3066da2de787b7f032c736763eb7ae5d355f81a68bab2675a96008b0bf" +dependencies = [ + "phf", +] + +[[package]] +name = "csscolorparser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46f9a16a848a7fb95dd47ce387ac1ee9a6df879ba784b815537fcd388a1a8288" dependencies = [ "phf", "serde", @@ -1457,6 +1409,17 @@ dependencies = [ "syn 2.0.98", ] +[[package]] +name = "derive_utils" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccfae181bab5ab6c5478b2ccb69e4c68a02f8c3ec72f6616bfec9dbc599d2ee0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "digest" version = "0.10.7" @@ -1473,7 +1436,16 @@ version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ - "dirs-sys", + "dirs-sys 0.4.1", +] + +[[package]] +name = "dirs" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" +dependencies = [ + "dirs-sys 0.5.0", ] [[package]] @@ -1484,10 +1456,22 @@ checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ "libc", "option-ext", - "redox_users", + "redox_users 0.4.6", "windows-sys 0.48.0", ] +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users 0.5.0", + "windows-sys 0.59.0", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -1514,22 +1498,13 @@ dependencies = [ "libloading", ] -[[package]] -name = "dlv-list" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" -dependencies = [ - "const-random", -] - [[package]] name = "dnd" version = "0.1.0" source = "git+https://github.com/pop-os/window_clipboard.git?tag=pop-0.13-2#6b9faab87bea9cebec6ae036906fd67fed254f5f" dependencies = [ "bitflags 2.8.0", - "mime", + "mime 0.1.0", "raw-window-handle", "smithay-client-toolkit", "smithay-clipboard", @@ -1976,31 +1951,29 @@ dependencies = [ [[package]] name = "freedesktop-desktop-entry" -version = "0.7.7" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "016f6ee9509f11c985aa402451f4ee900d1fafeb501a4c3d734ebecfc1130e05" +checksum = "2258b98a780699da05c858682498ceaf3942013d7d93ca7584e26fbacc58f2d9" dependencies = [ - "cached", - "dirs", "gettext-rs", "log", "memchr", - "strsim", - "textdistance", - "thiserror 2.0.11", + "thiserror 2.0.12", + "unicase", "xdg", ] [[package]] name = "freedesktop-icons" -version = "0.2.6" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8ef34245e0540c9a3ce7a28340b98d2c12b75da0d446da4e8224923fcaa0c16" +checksum = "72e592df580f8f0e7c48135383e9c0e0d18d9de346b95f9839857fe27a67ad47" dependencies = [ - "dirs", + "dirs 5.0.1", + "ini_core", "once_cell", - "rust-ini", "thiserror 1.0.69", + "tracing", "xdg", ] @@ -2355,10 +2328,6 @@ name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", - "allocator-api2", -] [[package]] name = "hashbrown" @@ -2520,7 +2489,7 @@ dependencies = [ [[package]] name = "iced" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "dnd", "iced_accessibility", @@ -2530,7 +2499,7 @@ dependencies = [ "iced_widget", "iced_winit", "image", - "mime", + "mime 0.1.0", "thiserror 1.0.69", "window_clipboard", ] @@ -2538,7 +2507,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "accesskit", "accesskit_winit", @@ -2547,7 +2516,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "bitflags 2.8.0", "bytes", @@ -2555,7 +2524,7 @@ dependencies = [ "dnd", "glam", "log", - "mime", + "mime 0.1.0", "num-traits", "once_cell", "palette", @@ -2571,7 +2540,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "futures", "iced_core", @@ -2597,7 +2566,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "bitflags 2.8.0", "bytemuck", @@ -2619,7 +2588,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2631,7 +2600,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "bytes", "cosmic-client-toolkit", @@ -2646,7 +2615,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "bytemuck", "cosmic-text", @@ -2662,7 +2631,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "as-raw-xcb-connection", "bitflags 2.8.0", @@ -2693,7 +2662,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "cosmic-client-toolkit", "dnd", @@ -2711,7 +2680,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "cosmic-client-toolkit", "dnd", @@ -2932,11 +2901,11 @@ dependencies = [ [[package]] name = "inotify" -version = "0.9.6" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" +checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.8.0", "inotify-sys", "libc", ] @@ -3159,17 +3128,18 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.169" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#337b80d4ca02a63631668212bccbace22b8bb49f" +source = "git+https://github.com/pop-os/libcosmic#0ddde755ee922edcff1a3b11cc00753cb29fe3b0" dependencies = [ "apply", "ashpd 0.9.2", + "auto_enums", "chrono", "cosmic-client-toolkit", "cosmic-config", @@ -3177,6 +3147,8 @@ dependencies = [ "cosmic-theme", "css-color", "derive_setters", + "freedesktop-desktop-entry", + "futures", "iced", "iced_core", "iced_futures", @@ -3188,13 +3160,17 @@ dependencies = [ "iced_winit", "image", "lazy_static", + "libc", + "mime 0.3.17", "palette", "rfd", - "ron 0.8.1", + "ron 0.9.0", + "rustix 1.0.5", "serde", + "shlex", "slotmap", "taffy", - "thiserror 1.0.69", + "thiserror 2.0.12", "tokio", "tracing", "unicode-segmentation", @@ -3257,6 +3233,12 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a385b1be4e5c3e362ad2ffa73c392e53f031eaa5b7d648e64cd87f27f6063d7" +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + [[package]] name = "litemap" version = "0.7.4" @@ -3430,6 +3412,12 @@ dependencies = [ "smithay-clipboard", ] +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + [[package]] name = "miniz_oxide" version = "0.8.3" @@ -3440,18 +3428,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "mio" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" -dependencies = [ - "libc", - "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", -] - [[package]] name = "mio" version = "1.0.3" @@ -3459,6 +3435,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", + "log", "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] @@ -3556,23 +3533,29 @@ dependencies = [ [[package]] name = "notify" -version = "6.1.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" +checksum = "2fee8403b3d66ac7b26aee6e40a897d85dc5ce26f44da36b8b73e987cc52e943" dependencies = [ "bitflags 2.8.0", - "crossbeam-channel", "filetime", "fsevent-sys", "inotify", "kqueue", "libc", "log", - "mio 0.8.11", + "mio", + "notify-types", "walkdir", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] +[[package]] +name = "notify-types" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d" + [[package]] name = "num-traits" version = "0.2.19" @@ -3857,9 +3840,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.2" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "option-ext" @@ -3876,16 +3859,6 @@ dependencies = [ "libredox", ] -[[package]] -name = "ordered-multimap" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79" -dependencies = [ - "dlv-list", - "hashbrown 0.14.5", -] - [[package]] name = "ordered-stream" version = "0.2.0" @@ -4365,6 +4338,17 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "redox_users" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" +dependencies = [ + "getrandom 0.2.15", + "libredox", + "thiserror 2.0.12", +] + [[package]] name = "regex" version = "1.11.1" @@ -4462,9 +4446,9 @@ dependencies = [ [[package]] name = "ron" -version = "0.9.0-alpha.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7644a2a539ff7fa991c8f4652373cd722d387e39229415103243914249730836" +checksum = "63f3aa105dea217ef30d89581b65a4d527a19afc95ef5750be3890e8d3c5b837" dependencies = [ "base64 0.22.1", "bitflags 2.8.0", @@ -4513,16 +4497,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "rust-ini" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e0698206bcb8882bf2a9ecb4c1e7785db57ff052297085a6efd4fe42302068a" -dependencies = [ - "cfg-if", - "ordered-multimap", -] - [[package]] name = "rustc-demangle" version = "0.1.24" @@ -4568,6 +4542,19 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "rustix" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf" +dependencies = [ + "bitflags 2.8.0", + "errno", + "libc", + "linux-raw-sys 0.9.4", + "windows-sys 0.59.0", +] + [[package]] name = "rustversion" version = "1.0.19" @@ -4648,18 +4635,18 @@ checksum = "c2fdfc24bc566f839a2da4c4295b82db7d25a24253867d5c64355abb5799bdbe" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -4668,9 +4655,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.138" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "indexmap", "itoa", @@ -5025,12 +5012,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "textdistance" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa672c55ab69f787dbc9126cc387dbe57fdd595f585e4524cf89018fa44ab819" - [[package]] name = "thiserror" version = "1.0.69" @@ -5042,11 +5023,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl 2.0.11", + "thiserror-impl 2.0.12", ] [[package]] @@ -5062,24 +5043,15 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", "syn 2.0.98", ] -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - [[package]] name = "tiny-skia" version = "0.11.4" @@ -5146,14 +5118,14 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.43.0" +version = "1.44.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48" dependencies = [ "backtrace", "bytes", "libc", - "mio 1.0.3", + "mio", "pin-project-lite", "signal-hook-registry", "socket2 0.5.8", @@ -5328,6 +5300,12 @@ dependencies = [ "tinystr", ] +[[package]] +name = "unicase" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" + [[package]] name = "unicode-bidi" version = "0.3.18" @@ -5885,7 +5863,7 @@ dependencies = [ "clipboard_wayland", "clipboard_x11", "dnd", - "mime", + "mime 0.1.0", "raw-window-handle", "thiserror 1.0.69", ] @@ -5953,6 +5931,12 @@ dependencies = [ "syn 2.0.98", ] +[[package]] +name = "windows-link" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" + [[package]] name = "windows-result" version = "0.1.2" diff --git a/Cargo.toml b/Cargo.toml index 106dcbb..15b408d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,10 +12,16 @@ cosmic-comp-config = { git = "https://github.com/pop-os/cosmic-comp" } env_logger = "0.11.0" futures-channel = "0.3.25" gbm = "0.18.0" -libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = ["tokio", "wayland", "single-instance", "multi-window", "winit"] } +libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = [ + "tokio", + "wayland", + "single-instance", + "desktop", + "multi-window", + "winit", +] } cosmic-config = { git = "https://github.com/pop-os/libcosmic" } -freedesktop-desktop-entry = "0.7.0" -freedesktop-icons = "0.2.4" +freedesktop-icons = "0.3.1" memmap2 = "0.9.0" tokio = "1.23.0" @@ -26,7 +32,7 @@ itertools = "0.14.0" log = "0.4.20" i18n-embed-fl = "0.9.0" rust-embed = "8.1.0" -rustix = { version = "0.38.30", features = ["fs"] } +rustix = { version = "0.38.30", features = ["fs"] } calloop-wayland-source = "0.4.0" aliasable = "0.1.3" futures-executor = { version = "0.3.31", features = ["thread-pool"] } diff --git a/src/desktop_info.rs b/src/desktop_info.rs index 70607ac..7640974 100644 --- a/src/desktop_info.rs +++ b/src/desktop_info.rs @@ -1,7 +1,7 @@ // Coppied from cosmic-app-list // - Put in a library? libcosmic? -use freedesktop_desktop_entry::DesktopEntry; +use cosmic::desktop::fde; use itertools::Itertools; use std::path::PathBuf; @@ -47,9 +47,9 @@ fn default_app_icon() -> PathBuf { fn desktop_info_for_app_ids(mut app_ids: Vec) -> Vec { let app_ids_clone = app_ids.clone(); - let mut ret = freedesktop_desktop_entry::Iter::new(freedesktop_desktop_entry::default_paths()) + let mut ret = fde::Iter::new(fde::default_paths()) .filter_map(|path| { - DesktopEntry::from_path::(path.clone(), None) + fde::DesktopEntry::from_path::(path.clone(), None) .ok() .and_then(|de| { if let Some(i) = app_ids.iter().position(|s| { diff --git a/src/view/mod.rs b/src/view/mod.rs index ec7f1f1..d66fdc0 100644 --- a/src/view/mod.rs +++ b/src/view/mod.rs @@ -8,7 +8,7 @@ use cosmic::{ advanced::layout::flex::Axis, clipboard::mime::AllowedMimeTypes, widget::{column, row}, - Border, + Border, Length, }, iced_core::{text::Wrapping, Shadow}, iced_winit::platform_specific::wayland::subsurface_widget::Subsurface, @@ -99,14 +99,14 @@ pub(crate) fn layer_surface<'a>( WorkspaceLayout::Vertical => widget::layer_container( row![sidebar, toplevels] .spacing(12) - .height(iced::Length::Fill) - .width(iced::Length::Fill), + .height(Length::Fill) + .width(Length::Fill), ), WorkspaceLayout::Horizontal => widget::layer_container( column![sidebar, toplevels] .spacing(12) - .height(iced::Length::Fill) - .width(iced::Length::Fill), + .height(Length::Fill) + .width(Length::Fill), ), }; let output = surface.output.clone(); @@ -147,40 +147,90 @@ fn workspace_item_appearance( fn workspace_item<'a>( workspace: &'a Workspace, _output: &wl_output::WlOutput, + layout: WorkspaceLayout, is_drop_target: bool, ) -> cosmic::Element<'static, Msg> { - let image = capture_image(workspace.img.as_ref(), 1.0); + let (image, image_height) = if let Some(img) = workspace.img.as_ref() { + let is_rotated = matches!( + img.transform, + wl_output::Transform::_90 + | wl_output::Transform::_270 + | wl_output::Transform::Flipped90 + | wl_output::Transform::Flipped270 + ); + let (effective_width, effective_height) = if is_rotated { + // If rotated, swap width and height + (img.height, img.width) + } else { + (img.width, img.height) + }; + + let fixed_size = 126.0; + if effective_width > effective_height { + ( + // Landscape: fix height + widget::container(capture_image(Some(img), 1.0)).max_height(fixed_size), + fixed_size, + ) + } else { + ( + // Portrait: fix width + widget::container(capture_image(Some(img), 1.0)).max_width(fixed_size), + fixed_size * effective_height as f32 / effective_width as f32, + ) + } + } else { + ( + widget::container(capture_image(None, 1.0)) + .max_width(224.0) + .max_height(126.0), + 126.0, + ) + }; + + let workspace_name = widget::text::body(fl!( + "workspace", + HashMap::from([("number", &workspace.name)]) + )); + + // Needed to prevent text getting pushed out when scaling on Vertical layout + let content = match layout { + WorkspaceLayout::Horizontal => column![image, workspace_name] + .align_x(iced::Alignment::Center) + .spacing(4) + .apply(widget::container), + WorkspaceLayout::Vertical => column![image.height(Length::Fill), workspace_name] + .align_x(iced::Alignment::Center) + .spacing(4) + .apply(widget::container) + .max_height(image_height + 21.0 + 4.0), // text height + spacing + }; + let is_active = workspace.is_active; // TODO editable name? - widget::button::custom( - column![ - image, - widget::text::body(fl!( - "workspace", - HashMap::from([("number", &workspace.name)]) - )) - ] - .align_x(iced::Alignment::Center) - .spacing(4), - ) - .selected(workspace.is_active) - .class(cosmic::theme::Button::Custom { - active: Box::new(move |_focused, theme| { - workspace_item_appearance(theme, is_active, is_drop_target) - }), - disabled: Box::new(|_theme| unreachable!()), - hovered: Box::new(move |_focused, theme| workspace_item_appearance(theme, is_active, true)), - pressed: Box::new(move |_focused, theme| workspace_item_appearance(theme, is_active, true)), - }) - .on_press(Msg::ActivateWorkspace(workspace.handle.clone())) - .padding(8) - .width(iced::Length::Fixed(240.0)) - .into() + widget::button::custom(content) + .selected(workspace.is_active) + .class(cosmic::theme::Button::Custom { + active: Box::new(move |_focused, theme| { + workspace_item_appearance(theme, is_active, is_drop_target) + }), + disabled: Box::new(|_theme| unreachable!()), + hovered: Box::new(move |_focused, theme| { + workspace_item_appearance(theme, is_active, true) + }), + pressed: Box::new(move |_focused, theme| { + workspace_item_appearance(theme, is_active, true) + }), + }) + .on_press(Msg::ActivateWorkspace(workspace.handle.clone())) + .padding(8) + .into() } fn workspace_sidebar_entry<'a>( workspace: &'a Workspace, output: &'a wl_output::WlOutput, + layout: WorkspaceLayout, is_drop_target: bool, ) -> cosmic::Element<'a, Msg> { /* XXX @@ -190,7 +240,7 @@ fn workspace_sidebar_entry<'a>( iced::mouse::Interaction::Idle }; */ - let item = workspace_item(workspace, output, is_drop_target); + let item = workspace_item(workspace, output, layout, is_drop_target); /* TODO allow moving workspaces (needs compositor support) let workspace_clone = workspace.clone(); // TODO avoid clone let output_clone = output.clone(); @@ -227,19 +277,15 @@ fn workspaces_sidebar<'a>( drop_target: Option<&backend::ExtWorkspaceHandleV1>, ) -> cosmic::Element<'a, Msg> { let sidebar_entries = workspaces - .map(|w| workspace_sidebar_entry(w, output, drop_target == Some(&w.handle))) + .map(|w| workspace_sidebar_entry(w, output, layout, drop_target == Some(&w.handle))) .collect(); - let axis = match layout { - WorkspaceLayout::Vertical => Axis::Vertical, - WorkspaceLayout::Horizontal => Axis::Horizontal, + let (axis, width, height) = match layout { + WorkspaceLayout::Vertical => (Axis::Vertical, Length::Shrink, Length::Fill), + WorkspaceLayout::Horizontal => (Axis::Horizontal, Length::Fill, Length::Shrink), }; let sidebar_entries_container = widget::container(crate::widgets::workspace_bar(sidebar_entries, axis)).padding(8.0); - let (width, height) = match layout { - WorkspaceLayout::Vertical => (iced::Length::Fixed(256.0), iced::Length::Shrink), - WorkspaceLayout::Horizontal => (iced::Length::Shrink, iced::Length::Fill), - }; widget::container( widget::container(sidebar_entries_container) .width(width) @@ -304,8 +350,8 @@ fn toplevel_preview(toplevel: &Toplevel, is_being_dragged: bool) -> cosmic::Elem } })) .apply(widget::container) - .width(iced::Length::FillPortion(5)), - widget::horizontal_space().width(iced::Length::Fixed(8.0)), + .width(Length::FillPortion(5)), + widget::horizontal_space().width(Length::Fixed(8.0)), close_button(Msg::CloseToplevel(toplevel.handle.clone())) ] .padding([0, 0, 4, 0]) @@ -326,7 +372,7 @@ fn toplevel_preview(toplevel: &Toplevel, is_being_dragged: bool) -> cosmic::Elem ) //.spacing(4) //.align_items(iced::Alignment::Center) - //.width(iced::Length::Fill) + //.width(Length::Fill) .into() } @@ -367,8 +413,8 @@ fn toplevel_previews<'a>( drag_toplevel: Option<&'a backend::ExtForeignToplevelHandleV1>, ) -> cosmic::Element<'a, Msg> { let (width, height) = match layout { - WorkspaceLayout::Vertical => (iced::Length::FillPortion(4), iced::Length::Fill), - WorkspaceLayout::Horizontal => (iced::Length::Fill, iced::Length::FillPortion(4)), + WorkspaceLayout::Vertical => (Length::FillPortion(4), Length::Fill), + WorkspaceLayout::Horizontal => (Length::Fill, Length::FillPortion(4)), }; let entries = toplevels .map(|t| toplevel_previews_entry(t, drag_toplevel == Some(&t.handle))) @@ -401,12 +447,12 @@ fn bg_element<'a>( widget::image::Handle::from_path(path), ) .content_fit(iced::ContentFit::Cover) - .width(iced::Length::Fill) - .height(iced::Length::Fill) + .width(Length::Fill) + .height(Length::Fill) .into(), Some(Source::Color(color)) => widget::layer_container(widget::horizontal_space()) - .width(iced::Length::Fill) - .height(iced::Length::Fill) + .width(Length::Fill) + .height(Length::Fill) .class(cosmic::theme::Container::Custom(Box::new(move |_| { let color = color.clone(); cosmic::iced::widget::container::Style { @@ -441,8 +487,8 @@ fn bg_element<'a>( "/usr/share/backgrounds/pop/kate-hazen-COSMIC-desktop-wallpaper.png", )) .content_fit(iced::ContentFit::Cover) - .width(iced::Length::Fill) - .height(iced::Length::Fill) + .width(Length::Fill) + .height(Length::Fill) .into() } } diff --git a/src/widgets/workspace_bar.rs b/src/widgets/workspace_bar.rs index 7c49741..44e228a 100644 --- a/src/widgets/workspace_bar.rs +++ b/src/widgets/workspace_bar.rs @@ -61,8 +61,8 @@ pub struct WorkspaceBar<'a, Msg> { impl Widget for WorkspaceBar<'_, Msg> { fn size(&self) -> Size { Size { - width: Length::Fill, - height: Length::Fill, + width: Length::Shrink, + height: Length::Shrink, } } @@ -72,48 +72,45 @@ impl Widget for WorkspaceBar<'_, Msg> renderer: &cosmic::Renderer, limits: &layout::Limits, ) -> layout::Node { - // TODO configurable - let spacing = 8.0; - - /* - layout::flex::resolve( - layout::flex::Axis::Vertical, - renderer, - &limits, - iced::Padding::ZERO, - 0.0, // spacing - iced::Alignment::Start, - &self.children, - &mut tree.children, - ) - */ - if self.children.is_empty() { return layout::Node::new(limits.min()); } - let total_spacing = spacing * (self.children.len().saturating_sub(1)).max(0) as f32; - let max_main = - (self.axis.main(limits.max()) - total_spacing) / self.children().len() as f32; + // TODO configurable + let spacing = 8.0; + + let total_spacing = spacing * (self.children.len() - 1) as f32; + let max_main = (self.axis.main(limits.max()) - total_spacing) / self.children.len() as f32; let max_cross = self.axis.cross(limits.max()); let mut total_main = 0.0; + let mut max_child_cross = 0.0; let nodes = self .children .iter() .zip(tree.children.iter_mut()) - .map(|(child, tree)| { + .enumerate() + .map(|(i, (child, tree))| { let (max_width, max_height) = self.axis.pack(max_main, max_cross); let child_limits = layout::Limits::new(Size::ZERO, Size::new(max_width, max_height)); let mut layout = child.as_widget().layout(tree, renderer, &child_limits); + let child_size = layout.size(); let (x, y) = self.axis.pack(total_main, 0.0); layout = layout.move_to(Point::new(x, y)); - total_main += self.axis.main(layout.size()) + spacing; + max_child_cross = f32::max(max_child_cross, self.axis.cross(child_size)); + let main = self.axis.main(child_size); + // XXX Don't add spacing for 0 length `dnd_source` placeholder widget + if main != 0.0 { + total_main += main; + if i < self.children.len() - 1 { + total_main += spacing; + } + } layout }) .collect(); - let (total_width, total_height) = self.axis.pack(total_main, max_cross); + let (total_width, total_height) = self.axis.pack(total_main, max_child_cross); let size = Size::new(total_width, total_height); layout::Node::with_children(size, nodes) }