refactor: tiling applet
This commit is contained in:
parent
34c4bada71
commit
9c9e3986a1
9 changed files with 735 additions and 220 deletions
234
Cargo.lock
generated
234
Cargo.lock
generated
|
|
@ -4,27 +4,31 @@ version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "accesskit"
|
name = "accesskit"
|
||||||
version = "0.11.0"
|
version = "0.12.2"
|
||||||
source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8"
|
source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#5f9b61c8264000d001499c902562422e13efa7a8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "accesskit_consumer"
|
name = "accesskit_consumer"
|
||||||
version = "0.15.0"
|
version = "0.17.0"
|
||||||
source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8"
|
source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#5f9b61c8264000d001499c902562422e13efa7a8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "accesskit_unix"
|
name = "accesskit_unix"
|
||||||
version = "0.5.0"
|
version = "0.7.1"
|
||||||
source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8"
|
source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#5f9b61c8264000d001499c902562422e13efa7a8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
"accesskit_consumer",
|
"accesskit_consumer",
|
||||||
"async-channel 1.9.0",
|
"async-channel",
|
||||||
|
"async-executor",
|
||||||
|
"async-task",
|
||||||
"atspi",
|
"atspi",
|
||||||
"futures-lite 1.13.0",
|
"futures-lite 1.13.0",
|
||||||
|
"futures-util",
|
||||||
|
"once_cell",
|
||||||
"serde",
|
"serde",
|
||||||
"zbus",
|
"zbus",
|
||||||
]
|
]
|
||||||
|
|
@ -196,24 +200,13 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-channel"
|
name = "async-channel"
|
||||||
version = "1.9.0"
|
version = "2.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35"
|
checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"concurrent-queue",
|
"concurrent-queue",
|
||||||
"event-listener 2.5.3",
|
"event-listener 5.0.0",
|
||||||
"futures-core",
|
"event-listener-strategy 0.5.0",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "async-channel"
|
|
||||||
version = "2.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c"
|
|
||||||
dependencies = [
|
|
||||||
"concurrent-queue",
|
|
||||||
"event-listener 4.0.3",
|
|
||||||
"event-listener-strategy",
|
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
]
|
]
|
||||||
|
|
@ -299,7 +292,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b"
|
checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"event-listener 4.0.3",
|
"event-listener 4.0.3",
|
||||||
"event-listener-strategy",
|
"event-listener-strategy 0.4.0",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -396,29 +389,50 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atspi"
|
name = "atspi"
|
||||||
version = "0.10.1"
|
version = "0.19.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "674e7a3376837b2e7d12d34d58ac47073c491dc3bf6f71a7adaf687d4d817faa"
|
checksum = "6059f350ab6f593ea00727b334265c4dfc7fd442ee32d264794bd9bdc68e87ca"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-recursion",
|
"atspi-common",
|
||||||
"async-trait",
|
"atspi-connection",
|
||||||
"atspi-macros",
|
"atspi-proxies",
|
||||||
"enumflags2",
|
|
||||||
"futures-lite 1.13.0",
|
|
||||||
"serde",
|
|
||||||
"tracing",
|
|
||||||
"zbus",
|
|
||||||
"zbus_names",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atspi-macros"
|
name = "atspi-common"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "97fb4870a32c0eaa17e35bca0e6b16020635157121fb7d45593d242c295bc768"
|
checksum = "92af95f966d2431f962bc632c2e68eda7777330158bf640c4af4249349b2cdf5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"enumflags2",
|
||||||
"syn 1.0.109",
|
"serde",
|
||||||
|
"static_assertions",
|
||||||
|
"zbus",
|
||||||
|
"zbus_names",
|
||||||
|
"zvariant",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atspi-connection"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a0c65e7d70f86d4c0e3b2d585d9bf3f979f0b19d635a336725a88d279f76b939"
|
||||||
|
dependencies = [
|
||||||
|
"atspi-common",
|
||||||
|
"atspi-proxies",
|
||||||
|
"futures-lite 1.13.0",
|
||||||
|
"zbus",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atspi-proxies"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6495661273703e7a229356dcbe8c8f38223d697aacfaf0e13590a9ac9977bb52"
|
||||||
|
dependencies = [
|
||||||
|
"atspi-common",
|
||||||
|
"serde",
|
||||||
|
"zbus",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -505,7 +519,7 @@ version = "1.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118"
|
checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-channel 2.1.1",
|
"async-channel",
|
||||||
"async-lock 3.3.0",
|
"async-lock 3.3.0",
|
||||||
"async-task",
|
"async-task",
|
||||||
"fastrand 2.0.1",
|
"fastrand 2.0.1",
|
||||||
|
|
@ -552,9 +566,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytemuck"
|
name = "bytemuck"
|
||||||
version = "1.14.1"
|
version = "1.14.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9"
|
checksum = "ea31d69bda4949c1c1562c1e6f042a1caefac98cdc8a298260a2ff41c1e2d42b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck_derive",
|
"bytemuck_derive",
|
||||||
]
|
]
|
||||||
|
|
@ -826,7 +840,7 @@ dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"i18n-embed 0.13.9",
|
"i18n-embed 0.13.9",
|
||||||
"i18n-embed-fl 0.6.7",
|
"i18n-embed-fl 0.6.7",
|
||||||
"itertools 0.12.1",
|
"itertools 0.10.5",
|
||||||
"libcosmic",
|
"libcosmic",
|
||||||
"log",
|
"log",
|
||||||
"nix 0.26.4",
|
"nix 0.26.4",
|
||||||
|
|
@ -1007,12 +1021,17 @@ dependencies = [
|
||||||
name = "cosmic-applet-tiling"
|
name = "cosmic-applet-tiling"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"cosmic-client-toolkit",
|
||||||
|
"cosmic-comp-config",
|
||||||
|
"cosmic-protocols",
|
||||||
"cosmic-time",
|
"cosmic-time",
|
||||||
"i18n-embed 0.14.1",
|
"i18n-embed 0.14.1",
|
||||||
"i18n-embed-fl 0.7.0",
|
"i18n-embed-fl 0.7.0",
|
||||||
"libcosmic",
|
"libcosmic",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rust-embed 8.2.0",
|
"rust-embed 8.2.0",
|
||||||
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -1062,10 +1081,20 @@ dependencies = [
|
||||||
"wayland-client 0.31.2",
|
"wayland-client 0.31.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cosmic-comp-config"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/pop-os/cosmic-comp.git?rev=5eb5af4#5eb5af46756f2f2bc5e812cf68fe4c4b79efd924"
|
||||||
|
dependencies = [
|
||||||
|
"cosmic-config",
|
||||||
|
"input",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-config"
|
name = "cosmic-config"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomicwrites",
|
"atomicwrites",
|
||||||
"cosmic-config-derive",
|
"cosmic-config-derive",
|
||||||
|
|
@ -1085,7 +1114,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-config-derive"
|
name = "cosmic-config-derive"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
|
|
@ -1108,7 +1137,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-notifications-config"
|
name = "cosmic-notifications-config"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/cosmic-notifications#33ee0639630899f7cb61b61ffa4ae3f4ab4f1e23"
|
source = "git+https://github.com/pop-os/cosmic-notifications#a252fd2005e61c7d34a95fb203daea2881fd7694"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
@ -1117,7 +1146,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-notifications-util"
|
name = "cosmic-notifications-util"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/cosmic-notifications#33ee0639630899f7cb61b61ffa4ae3f4ab4f1e23"
|
source = "git+https://github.com/pop-os/cosmic-notifications#a252fd2005e61c7d34a95fb203daea2881fd7694"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"fast_image_resize",
|
"fast_image_resize",
|
||||||
|
|
@ -1138,7 +1167,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-panel-config"
|
name = "cosmic-panel-config"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/cosmic-panel#a92b60eeee5087ac4f5b64426aee8be806a4c80d"
|
source = "git+https://github.com/pop-os/cosmic-panel#47d5a704652860be3dff3787ee17bc88e007ff6d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
|
|
@ -1173,8 +1202,8 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-text"
|
name = "cosmic-text"
|
||||||
version = "0.10.0"
|
version = "0.11.2"
|
||||||
source = "git+https://github.com/pop-os/cosmic-text.git?rev=1b025ae#1b025ae56e0122cff5798b9f54fc56d47a182d2b"
|
source = "git+https://github.com/pop-os/cosmic-text.git#0cb6eba6e708e2743313ee0016162de7a0146353"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.4.2",
|
||||||
"fontdb",
|
"fontdb",
|
||||||
|
|
@ -1196,7 +1225,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-theme"
|
name = "cosmic-theme"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"almost",
|
"almost",
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
|
|
@ -1770,6 +1799,17 @@ dependencies = [
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "event-listener"
|
||||||
|
version = "5.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b72557800024fabbaa2449dd4bf24e37b93702d457a4d4f2b0dd1f0f039f20c1"
|
||||||
|
dependencies = [
|
||||||
|
"concurrent-queue",
|
||||||
|
"parking",
|
||||||
|
"pin-project-lite",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "event-listener-strategy"
|
name = "event-listener-strategy"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
|
@ -1780,6 +1820,16 @@ dependencies = [
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "event-listener-strategy"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291"
|
||||||
|
dependencies = [
|
||||||
|
"event-listener 5.0.0",
|
||||||
|
"pin-project-lite",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "exr"
|
name = "exr"
|
||||||
version = "1.72.0"
|
version = "1.72.0"
|
||||||
|
|
@ -2374,7 +2424,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glyphon"
|
name = "glyphon"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
source = "git+https://github.com/pop-os/glyphon.git?tag=cosmic-0.5-wgpu#db9620f48ceef47e214f3a058b9504e9983ed987"
|
source = "git+https://github.com/pop-os/glyphon.git?tag=v0.5.0#1b0646ff8f74da92d3be704dfc2257d7f4d7eed8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmic-text",
|
"cosmic-text",
|
||||||
"etagere",
|
"etagere",
|
||||||
|
|
@ -2697,7 +2747,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced"
|
name = "iced"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_accessibility",
|
"iced_accessibility",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2712,7 +2762,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_accessibility"
|
name = "iced_accessibility"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
"accesskit_unix",
|
"accesskit_unix",
|
||||||
|
|
@ -2721,7 +2771,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_core"
|
name = "iced_core"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"iced_accessibility",
|
"iced_accessibility",
|
||||||
|
|
@ -2740,7 +2790,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_futures"
|
name = "iced_futures"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2753,7 +2803,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_graphics"
|
name = "iced_graphics"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2777,7 +2827,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_renderer"
|
name = "iced_renderer"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
"iced_tiny_skia",
|
"iced_tiny_skia",
|
||||||
|
|
@ -2789,7 +2839,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_runtime"
|
name = "iced_runtime"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_accessibility",
|
"iced_accessibility",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2801,7 +2851,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_sctk"
|
name = "iced_sctk"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"enum-repr",
|
"enum-repr",
|
||||||
"float-cmp",
|
"float-cmp",
|
||||||
|
|
@ -2827,7 +2877,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_style"
|
name = "iced_style"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
@ -2837,7 +2887,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_tiny_skia"
|
name = "iced_tiny_skia"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"cosmic-text",
|
"cosmic-text",
|
||||||
|
|
@ -2854,7 +2904,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_wgpu"
|
name = "iced_wgpu"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2873,7 +2923,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_widget"
|
name = "iced_widget"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_renderer",
|
"iced_renderer",
|
||||||
"iced_runtime",
|
"iced_runtime",
|
||||||
|
|
@ -2966,6 +3016,26 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "input"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7911ce3db9c10c5ab4a35c49af778a5f9a827bd0f7371d9be56175d8dd2740d0"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.4.2",
|
||||||
|
"input-sys",
|
||||||
|
"io-lifetimes 1.0.11",
|
||||||
|
"libc",
|
||||||
|
"log",
|
||||||
|
"udev",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "input-sys"
|
||||||
|
version = "1.18.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bd4f5b4d1c00331c5245163aacfe5f20be75b564c7112d45893d4ae038119eb0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "instant"
|
name = "instant"
|
||||||
version = "0.1.12"
|
version = "0.1.12"
|
||||||
|
|
@ -3138,7 +3208,7 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libcosmic"
|
name = "libcosmic"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#6ebda94c79a7d349bf5e5eba944d399ac1215106"
|
source = "git+https://github.com/pop-os/libcosmic#072a3d5ca0032df6caa9011860fc496500c2a840"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"apply",
|
"apply",
|
||||||
"ashpd",
|
"ashpd",
|
||||||
|
|
@ -3160,6 +3230,7 @@ dependencies = [
|
||||||
"iced_sctk",
|
"iced_sctk",
|
||||||
"iced_style",
|
"iced_style",
|
||||||
"iced_tiny_skia",
|
"iced_tiny_skia",
|
||||||
|
"iced_wgpu",
|
||||||
"iced_widget",
|
"iced_widget",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"nix 0.27.1",
|
"nix 0.27.1",
|
||||||
|
|
@ -3643,9 +3714,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-complex"
|
name = "num-complex"
|
||||||
version = "0.4.4"
|
version = "0.4.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214"
|
checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
@ -3669,19 +3740,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.45"
|
version = "0.1.46"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
|
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-iter"
|
name = "num-iter"
|
||||||
version = "0.1.43"
|
version = "0.1.44"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252"
|
checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"num-integer",
|
"num-integer",
|
||||||
|
|
@ -3702,9 +3772,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.17"
|
version = "0.2.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
|
checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"libm",
|
"libm",
|
||||||
|
|
@ -4299,9 +4369,9 @@ checksum = "3b42e27ef78c35d3998403c1d26f3efd9e135d3e5121b0a4845cc5cc27547f4f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "read-fonts"
|
name = "read-fonts"
|
||||||
version = "0.15.2"
|
version = "0.15.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7555e052e772f964a1c99f1434f6a2c3a47a5f8e4292236921f121a7753cb2b5"
|
checksum = "a1362980db95801b70031dd592dc052a44b1810ca9da8fbcf7b25983f3174ed0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"font-types",
|
"font-types",
|
||||||
]
|
]
|
||||||
|
|
@ -4869,7 +4939,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "softbuffer"
|
name = "softbuffer"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
source = "git+https://github.com/pop-os/softbuffer?tag=cosmic-4.0#0bb85989353f0d17deb593dedb00ee4392a871e7"
|
source = "git+https://github.com/pop-os/softbuffer?tag=cosmic-4.0#6e75b1ad7e98397d37cb187886d05969bc480995"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"as-raw-xcb-connection",
|
"as-raw-xcb-connection",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -5514,9 +5584,9 @@ checksum = "7d817255e1bed6dfd4ca47258685d14d2bdcfbc64fdc9e3819bd5848057b8ecc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-segmentation"
|
name = "unicode-segmentation"
|
||||||
version = "1.10.1"
|
version = "1.11.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
|
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-vo"
|
name = "unicode-vo"
|
||||||
|
|
@ -6303,9 +6373,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winnow"
|
name = "winnow"
|
||||||
version = "0.5.37"
|
version = "0.5.39"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5"
|
checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
@ -6356,7 +6426,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xdg-shell-wrapper-config"
|
name = "xdg-shell-wrapper-config"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/xdg-shell-wrapper#b61b8ad1d679b306ae462b090514db728b4b93a4"
|
source = "git+https://github.com/pop-os/xdg-shell-wrapper#f7e2fac29229e31c9f50884fbf910ff8ff7ab6bd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"wayland-protocols-wlr",
|
"wayland-protocols-wlr",
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,14 @@ cosmic-time = { git = "https://github.com/pop-os/cosmic-time", default-features
|
||||||
"libcosmic",
|
"libcosmic",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = [
|
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = [
|
||||||
"applet",
|
"applet",
|
||||||
"applet-token",
|
"applet-token",
|
||||||
"tokio",
|
"tokio",
|
||||||
"wayland",
|
"wayland",
|
||||||
"desktop",
|
"desktop",
|
||||||
"dbus-config"
|
"dbus-config",
|
||||||
] }
|
] }
|
||||||
zbus = { version = "3.14", default-features = false, features = ["tokio"] }
|
zbus = { version = "3.14", default-features = false, features = ["tokio"] }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,23 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libcosmic.workspace = true
|
libcosmic.workspace = true
|
||||||
|
libcosmic.features = [
|
||||||
|
"applet",
|
||||||
|
"applet-token",
|
||||||
|
"dbus-config",
|
||||||
|
"desktop",
|
||||||
|
"tokio",
|
||||||
|
"wayland",
|
||||||
|
"wgpu"
|
||||||
|
]
|
||||||
cosmic-time.workspace = true
|
cosmic-time.workspace = true
|
||||||
|
cctk.workspace = true
|
||||||
|
cosmic-protocols.workspace = true
|
||||||
|
anyhow = "1.0.79"
|
||||||
once_cell = "1"
|
once_cell = "1"
|
||||||
i18n-embed = { version = "0.14.0", features = ["fluent-system", "desktop-requester"] }
|
i18n-embed = { version = "0.14.0", features = ["fluent-system", "desktop-requester"] }
|
||||||
i18n-embed-fl = "0.7.0"
|
i18n-embed-fl = "0.7.0"
|
||||||
rust-embed = "8.0.0"
|
rust-embed = "8.0.0"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
|
cosmic-comp-config = { git = "https://github.com/pop-os/cosmic-comp.git", rev = "5eb5af4" }
|
||||||
|
tokio = { version = "1.17.0", features = ["sync", "rt"] }
|
||||||
|
|
|
||||||
|
|
@ -11,3 +11,4 @@ Icon=com.system76.CosmicAppletTiling
|
||||||
StartupNotify=true
|
StartupNotify=true
|
||||||
NoDisplay=true
|
NoDisplay=true
|
||||||
X-CosmicApplet=true
|
X-CosmicApplet=true
|
||||||
|
X-HostWaylandDisplay=true
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
tile-windows = Automatically tile windows
|
tile-windows = Automatically tile windows
|
||||||
|
tile-current = Automatically tile current workspace
|
||||||
shortcuts = Shortcuts
|
shortcuts = Shortcuts
|
||||||
navigate-windows = Navigate windows
|
navigate-windows = Navigate windows
|
||||||
move-window = Move window
|
move-window = Move window
|
||||||
|
|
@ -8,7 +9,12 @@ active-hint = Active hint
|
||||||
gaps = Gaps
|
gaps = Gaps
|
||||||
floating-window-exceptions = Floating window exceptions...
|
floating-window-exceptions = Floating window exceptions...
|
||||||
window-management-settings = Window management settings...
|
window-management-settings = Window management settings...
|
||||||
|
all-workspaces = All workspaces
|
||||||
|
per-workspace = Per workspace
|
||||||
super = Super
|
super = Super
|
||||||
shift = Shift
|
shift = Shift
|
||||||
arrow-keys = arrows
|
arrow-keys = arrows
|
||||||
|
tiled = Tiled
|
||||||
|
floating = Floating
|
||||||
|
autotile-behavior = Tile windows on workspaces
|
||||||
|
new-workspace = New workspace behavior
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
use crate::window::Window;
|
use crate::window::Window;
|
||||||
|
|
||||||
mod localize;
|
mod localize;
|
||||||
|
mod wayland;
|
||||||
|
mod wayland_subscription;
|
||||||
mod window;
|
mod window;
|
||||||
|
|
||||||
fn main() -> cosmic::iced::Result {
|
fn main() -> cosmic::iced::Result {
|
||||||
|
|
|
||||||
235
cosmic-applet-tiling/src/wayland.rs
Normal file
235
cosmic-applet-tiling/src/wayland.rs
Normal file
|
|
@ -0,0 +1,235 @@
|
||||||
|
use calloop::channel::*;
|
||||||
|
use cctk::{
|
||||||
|
sctk::{
|
||||||
|
self,
|
||||||
|
output::{OutputHandler, OutputState},
|
||||||
|
reexports::{calloop, calloop_wayland_source::WaylandSource, client as wayland_client},
|
||||||
|
registry::{ProvidesRegistryState, RegistryState},
|
||||||
|
},
|
||||||
|
wayland_client::WEnum,
|
||||||
|
workspace::{WorkspaceHandler, WorkspaceState},
|
||||||
|
};
|
||||||
|
use cosmic::iced::futures;
|
||||||
|
use cosmic_protocols::workspace::v1::client::zcosmic_workspace_handle_v1::{self, TilingState};
|
||||||
|
use futures::{channel::mpsc, executor::block_on, SinkExt};
|
||||||
|
use std::{
|
||||||
|
os::{
|
||||||
|
fd::{FromRawFd, RawFd},
|
||||||
|
unix::net::UnixStream,
|
||||||
|
},
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
|
use tracing::error;
|
||||||
|
use wayland_client::{
|
||||||
|
globals::registry_queue_init,
|
||||||
|
protocol::wl_output::{self, WlOutput},
|
||||||
|
};
|
||||||
|
use wayland_client::{Connection, QueueHandle};
|
||||||
|
|
||||||
|
pub fn spawn_workspaces(tx: mpsc::Sender<TilingState>) -> SyncSender<TilingState> {
|
||||||
|
let (workspaces_tx, workspaces_rx) = calloop::channel::sync_channel(100);
|
||||||
|
|
||||||
|
let socket = std::env::var("X_PRIVILEGED_WAYLAND_SOCKET")
|
||||||
|
.ok()
|
||||||
|
.and_then(|fd| {
|
||||||
|
fd.parse::<RawFd>()
|
||||||
|
.ok()
|
||||||
|
.map(|fd| unsafe { UnixStream::from_raw_fd(fd) })
|
||||||
|
});
|
||||||
|
|
||||||
|
let conn = if let Some(socket) = socket {
|
||||||
|
Connection::from_socket(socket)
|
||||||
|
} else {
|
||||||
|
Connection::connect_to_env()
|
||||||
|
}
|
||||||
|
.map_err(anyhow::Error::msg);
|
||||||
|
|
||||||
|
if let Ok(conn) = conn {
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
let configured_output = std::env::var("COSMIC_PANEL_OUTPUT")
|
||||||
|
.ok()
|
||||||
|
.unwrap_or_default();
|
||||||
|
let mut event_loop = calloop::EventLoop::<State>::try_new().unwrap();
|
||||||
|
let loop_handle = event_loop.handle();
|
||||||
|
let (globals, event_queue) = registry_queue_init(&conn).unwrap();
|
||||||
|
let qhandle = event_queue.handle();
|
||||||
|
|
||||||
|
WaylandSource::new(conn, event_queue)
|
||||||
|
.insert(loop_handle)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let registry_state = RegistryState::new(&globals);
|
||||||
|
let mut state = State {
|
||||||
|
// Must be before `WorkspaceState`
|
||||||
|
output_state: OutputState::new(&globals, &qhandle),
|
||||||
|
configured_output,
|
||||||
|
workspace_state: WorkspaceState::new(®istry_state, &qhandle),
|
||||||
|
registry_state,
|
||||||
|
expected_output: None,
|
||||||
|
tx,
|
||||||
|
running: true,
|
||||||
|
have_workspaces: false,
|
||||||
|
};
|
||||||
|
let loop_handle = event_loop.handle();
|
||||||
|
loop_handle
|
||||||
|
.insert_source(workspaces_rx, |e, _, state| match e {
|
||||||
|
Event::Msg(autotile) => {
|
||||||
|
if let Some(w) =
|
||||||
|
state
|
||||||
|
.workspace_state
|
||||||
|
.workspace_groups()
|
||||||
|
.iter()
|
||||||
|
.find_map(|g| {
|
||||||
|
if let Some(o) = state.expected_output.as_ref() {
|
||||||
|
if !g.outputs.contains(o) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g.workspaces.iter().find(|w| {
|
||||||
|
w.state.contains(&WEnum::Value(
|
||||||
|
zcosmic_workspace_handle_v1::State::Active,
|
||||||
|
))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
{
|
||||||
|
w.handle.set_tiling_state(autotile);
|
||||||
|
state
|
||||||
|
.workspace_state
|
||||||
|
.workspace_manager()
|
||||||
|
.get()
|
||||||
|
.unwrap()
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event::Closed => {
|
||||||
|
if let Ok(workspace_manager) =
|
||||||
|
state.workspace_state.workspace_manager().get()
|
||||||
|
{
|
||||||
|
for g in state.workspace_state.workspace_groups() {
|
||||||
|
g.handle.destroy();
|
||||||
|
}
|
||||||
|
workspace_manager.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
while state.running {
|
||||||
|
event_loop
|
||||||
|
.dispatch(Duration::from_millis(16), &mut state)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
eprintln!("ENV variable WAYLAND_DISPLAY is missing. Exiting...");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
workspaces_tx
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct State {
|
||||||
|
running: bool,
|
||||||
|
tx: mpsc::Sender<TilingState>,
|
||||||
|
configured_output: String,
|
||||||
|
expected_output: Option<WlOutput>,
|
||||||
|
output_state: OutputState,
|
||||||
|
registry_state: RegistryState,
|
||||||
|
workspace_state: WorkspaceState,
|
||||||
|
have_workspaces: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl State {
|
||||||
|
pub fn tiling_state(&self) -> Option<TilingState> {
|
||||||
|
self.workspace_state
|
||||||
|
.workspace_groups()
|
||||||
|
.iter()
|
||||||
|
.find_map(|g| {
|
||||||
|
if g.outputs
|
||||||
|
.iter()
|
||||||
|
.any(|o| Some(o) == self.expected_output.as_ref())
|
||||||
|
{
|
||||||
|
g.workspaces.iter().find_map(|w| {
|
||||||
|
if w.state
|
||||||
|
.contains(&WEnum::Value(zcosmic_workspace_handle_v1::State::Active))
|
||||||
|
{
|
||||||
|
w.tiling.and_then(|e| match e {
|
||||||
|
WEnum::Value(v) => Some(v),
|
||||||
|
_ => {
|
||||||
|
error!("No tiling state for the workspace");
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ProvidesRegistryState for State {
|
||||||
|
fn registry(&mut self) -> &mut RegistryState {
|
||||||
|
&mut self.registry_state
|
||||||
|
}
|
||||||
|
sctk::registry_handlers![OutputState,];
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OutputHandler for State {
|
||||||
|
fn output_state(&mut self) -> &mut OutputState {
|
||||||
|
&mut self.output_state
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_output(
|
||||||
|
&mut self,
|
||||||
|
_conn: &Connection,
|
||||||
|
_qh: &QueueHandle<Self>,
|
||||||
|
output: wl_output::WlOutput,
|
||||||
|
) {
|
||||||
|
let info = self.output_state.info(&output).unwrap();
|
||||||
|
if info.name.as_deref() == Some(&self.configured_output) {
|
||||||
|
self.expected_output = Some(output);
|
||||||
|
if self.have_workspaces {
|
||||||
|
if let Some(s) = self.tiling_state() {
|
||||||
|
let _ = block_on(self.tx.send(s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_output(
|
||||||
|
&mut self,
|
||||||
|
_conn: &Connection,
|
||||||
|
_qh: &QueueHandle<Self>,
|
||||||
|
_output: wl_output::WlOutput,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn output_destroyed(
|
||||||
|
&mut self,
|
||||||
|
_conn: &Connection,
|
||||||
|
_qh: &QueueHandle<Self>,
|
||||||
|
_output: wl_output::WlOutput,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WorkspaceHandler for State {
|
||||||
|
fn workspace_state(&mut self) -> &mut WorkspaceState {
|
||||||
|
&mut self.workspace_state
|
||||||
|
}
|
||||||
|
|
||||||
|
fn done(&mut self) {
|
||||||
|
self.have_workspaces = true;
|
||||||
|
if let Some(s) = self.tiling_state() {
|
||||||
|
let _ = block_on(self.tx.send(s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cctk::delegate_workspace!(State);
|
||||||
|
sctk::delegate_output!(State);
|
||||||
|
sctk::delegate_registry!(State);
|
||||||
91
cosmic-applet-tiling/src/wayland_subscription.rs
Normal file
91
cosmic-applet-tiling/src/wayland_subscription.rs
Normal file
|
|
@ -0,0 +1,91 @@
|
||||||
|
use crate::wayland::{self};
|
||||||
|
use cctk::sctk::reexports::calloop::channel::SyncSender;
|
||||||
|
use cosmic::iced::{
|
||||||
|
self,
|
||||||
|
futures::{self, channel::mpsc, SinkExt, StreamExt},
|
||||||
|
subscription,
|
||||||
|
};
|
||||||
|
use cosmic_protocols::workspace::v1::client::zcosmic_workspace_handle_v1::TilingState;
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
|
pub static WAYLAND_RX: Lazy<Mutex<Option<mpsc::Receiver<TilingState>>>> =
|
||||||
|
Lazy::new(|| Mutex::new(None));
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum WorkspacesUpdate {
|
||||||
|
State(TilingState),
|
||||||
|
Started(SyncSender<TilingState>),
|
||||||
|
Errored,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn workspaces() -> iced::Subscription<WorkspacesUpdate> {
|
||||||
|
subscription::channel(
|
||||||
|
std::any::TypeId::of::<WorkspacesUpdate>(),
|
||||||
|
50,
|
||||||
|
move |mut output| async move {
|
||||||
|
let mut state = State::Waiting;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
state = start_listening(state, &mut output).await;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn start_listening(
|
||||||
|
state: State,
|
||||||
|
output: &mut futures::channel::mpsc::Sender<WorkspacesUpdate>,
|
||||||
|
) -> State {
|
||||||
|
match state {
|
||||||
|
State::Waiting => {
|
||||||
|
let mut guard = WAYLAND_RX.lock().await;
|
||||||
|
let rx = {
|
||||||
|
if guard.is_none() {
|
||||||
|
if let Ok(WorkspacesWatcher { rx, tx }) = WorkspacesWatcher::new() {
|
||||||
|
*guard = Some(rx);
|
||||||
|
_ = output.send(WorkspacesUpdate::Started(tx)).await;
|
||||||
|
} else {
|
||||||
|
_ = output.send(WorkspacesUpdate::Errored).await;
|
||||||
|
return State::Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
guard.as_mut().unwrap()
|
||||||
|
};
|
||||||
|
if let Some(w) = rx.next().await {
|
||||||
|
_ = output.send(WorkspacesUpdate::State(w)).await;
|
||||||
|
State::Waiting
|
||||||
|
} else {
|
||||||
|
_ = output.send(WorkspacesUpdate::Errored).await;
|
||||||
|
State::Error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
State::Error => cosmic::iced::futures::future::pending().await,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum State {
|
||||||
|
Waiting,
|
||||||
|
Error,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct WorkspacesWatcher {
|
||||||
|
rx: mpsc::Receiver<TilingState>,
|
||||||
|
tx: SyncSender<TilingState>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WorkspacesWatcher {
|
||||||
|
pub fn new() -> anyhow::Result<Self> {
|
||||||
|
let (tx, rx) = mpsc::channel(20);
|
||||||
|
let tx = wayland::spawn_workspaces(tx);
|
||||||
|
Ok(Self { tx, rx })
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_sender(&self) -> SyncSender<TilingState> {
|
||||||
|
self.tx.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn workspaces(&mut self) -> Option<TilingState> {
|
||||||
|
self.rx.next().await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,34 +1,46 @@
|
||||||
use crate::fl;
|
use crate::wayland_subscription::WorkspacesUpdate;
|
||||||
|
use crate::{fl, wayland_subscription};
|
||||||
|
use cctk::sctk::reexports::calloop::channel::SyncSender;
|
||||||
use cosmic::app::Core;
|
use cosmic::app::Core;
|
||||||
use cosmic::applet::{menu_button, padded_control};
|
use cosmic::applet::padded_control;
|
||||||
use cosmic::cosmic_config::{ConfigGet, ConfigSet};
|
use cosmic::cosmic_config::{Config, ConfigSet, CosmicConfigEntry};
|
||||||
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
|
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
|
||||||
use cosmic::iced::window::Id;
|
use cosmic::iced::window::Id;
|
||||||
use cosmic::iced::{Command, Length, Limits, Subscription};
|
use cosmic::iced::{Command, Length, Limits, Subscription};
|
||||||
use cosmic::iced_core::Alignment;
|
|
||||||
use cosmic::iced_style::application;
|
use cosmic::iced_style::application;
|
||||||
use cosmic::iced_widget::{column, row};
|
use cosmic::iced_widget::{column, row};
|
||||||
use cosmic::widget::{container, divider, spin_button, text};
|
use cosmic::widget::segmented_button::{Entity, SingleSelectModel};
|
||||||
|
use cosmic::widget::{
|
||||||
|
container, divider, segmented_button, segmented_selection, spin_button, text,
|
||||||
|
};
|
||||||
use cosmic::{Element, Theme};
|
use cosmic::{Element, Theme};
|
||||||
|
use cosmic_comp_config::{CosmicCompConfig, TileBehavior};
|
||||||
|
use cosmic_protocols::workspace::v1::client::zcosmic_workspace_handle_v1::TilingState;
|
||||||
use cosmic_time::{anim, chain, id, Timeline};
|
use cosmic_time::{anim, chain, id, Timeline};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
use std::thread;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
const ID: &str = "com.system76.CosmicAppletTiling";
|
const ID: &str = "com.system76.CosmicAppletTiling";
|
||||||
//const ON: &str = "com.system76.CosmicAppletTiling.On";
|
|
||||||
const OFF: &str = "com.system76.CosmicAppletTiling.Off";
|
const OFF: &str = "com.system76.CosmicAppletTiling.Off";
|
||||||
|
|
||||||
static TILE_WINDOWS: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
|
static TILE_WINDOWS: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
|
||||||
|
static ACTIVE_HINT: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
core: Core,
|
core: Core,
|
||||||
popup: Option<Id>,
|
popup: Option<Id>,
|
||||||
timeline: Timeline,
|
timeline: Timeline,
|
||||||
tile_windows: bool,
|
config: CosmicCompConfig,
|
||||||
active_hint: spin_button::Model<i32>,
|
config_helper: Config,
|
||||||
gaps: spin_button::Model<i32>,
|
autotile_behavior_model: segmented_button::SingleSelectModel,
|
||||||
|
new_workspace_behavior_model: segmented_button::SingleSelectModel,
|
||||||
|
autotile_global_entity: Entity,
|
||||||
|
new_workspace_entity: Entity,
|
||||||
|
/// may not match the config value if behavior is per-workspace
|
||||||
|
autotiled: bool,
|
||||||
|
workspace_tx: Option<SyncSender<TilingState>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
@ -37,12 +49,11 @@ pub enum Message {
|
||||||
PopupClosed(Id),
|
PopupClosed(Id),
|
||||||
Frame(Instant),
|
Frame(Instant),
|
||||||
ToggleTileWindows(chain::Toggler, bool),
|
ToggleTileWindows(chain::Toggler, bool),
|
||||||
HandleActiveHint(spin_button::Message),
|
ToggleActiveHint(chain::Toggler, bool),
|
||||||
HandleGaps(spin_button::Message),
|
MyConfigUpdate(CosmicCompConfig),
|
||||||
ViewAllShortcuts,
|
TileMode(Entity),
|
||||||
OpenFloatingWindowExceptions,
|
WorkspaceUpdate(WorkspacesUpdate),
|
||||||
OpenWindowManagementSettings,
|
NewWorkspace(Entity),
|
||||||
Ignore,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl cosmic::Application for Window {
|
impl cosmic::Application for Window {
|
||||||
|
|
@ -67,11 +78,55 @@ impl cosmic::Application for Window {
|
||||||
gaps.value = core.system_theme().cosmic().gaps.1 as i32;
|
gaps.value = core.system_theme().cosmic().gaps.1 as i32;
|
||||||
let mut active_hint = spin_button::Model::default().max(99).min(0).step(1);
|
let mut active_hint = spin_button::Model::default().max(99).min(0).step(1);
|
||||||
active_hint.value = core.system_theme().cosmic().active_hint as i32;
|
active_hint.value = core.system_theme().cosmic().active_hint as i32;
|
||||||
|
let config_helper =
|
||||||
|
Config::new("com.system76.CosmicComp", CosmicCompConfig::VERSION).unwrap();
|
||||||
|
let config = CosmicCompConfig::get_entry(&config_helper).unwrap_or_else(|(errs, c)| {
|
||||||
|
for err in errs {
|
||||||
|
error!(?err, "Error loading config");
|
||||||
|
}
|
||||||
|
c
|
||||||
|
});
|
||||||
|
let mut autotile_behavior_model = SingleSelectModel::default();
|
||||||
|
let autotile_global_entity = autotile_behavior_model
|
||||||
|
.insert()
|
||||||
|
.text(fl!("all-workspaces"))
|
||||||
|
.id();
|
||||||
|
let per = autotile_behavior_model
|
||||||
|
.insert()
|
||||||
|
.text(fl!("per-workspace"))
|
||||||
|
.id();
|
||||||
|
autotile_behavior_model.activate(match config.autotile_behavior {
|
||||||
|
TileBehavior::Global => autotile_global_entity,
|
||||||
|
TileBehavior::PerWorkspace => per,
|
||||||
|
});
|
||||||
|
|
||||||
|
let mut new_workspace_behavior_model = SingleSelectModel::default();
|
||||||
|
let new_workspace_entity = new_workspace_behavior_model
|
||||||
|
.insert()
|
||||||
|
.text(fl!("tiled"))
|
||||||
|
.id();
|
||||||
|
let floating = new_workspace_behavior_model
|
||||||
|
.insert()
|
||||||
|
.text(fl!("floating"))
|
||||||
|
.id();
|
||||||
|
new_workspace_behavior_model.activate(if config.autotile {
|
||||||
|
new_workspace_entity
|
||||||
|
} else {
|
||||||
|
floating
|
||||||
|
});
|
||||||
|
|
||||||
let window = Self {
|
let window = Self {
|
||||||
core,
|
core,
|
||||||
gaps,
|
popup: None,
|
||||||
active_hint,
|
timeline: Default::default(),
|
||||||
..Default::default()
|
autotiled: config.autotile,
|
||||||
|
config,
|
||||||
|
config_helper,
|
||||||
|
autotile_behavior_model,
|
||||||
|
new_workspace_behavior_model,
|
||||||
|
autotile_global_entity,
|
||||||
|
new_workspace_entity,
|
||||||
|
workspace_tx: None,
|
||||||
};
|
};
|
||||||
(window, Command::none())
|
(window, Command::none())
|
||||||
}
|
}
|
||||||
|
|
@ -85,11 +140,33 @@ impl cosmic::Application for Window {
|
||||||
.timeline
|
.timeline
|
||||||
.as_subscription()
|
.as_subscription()
|
||||||
.map(|(_, now)| Message::Frame(now));
|
.map(|(_, now)| Message::Frame(now));
|
||||||
Subscription::batch(vec![timeline])
|
Subscription::batch(vec![
|
||||||
|
timeline,
|
||||||
|
self.core
|
||||||
|
.watch_config::<CosmicCompConfig>("com.system76.CosmicComp")
|
||||||
|
.map(|u| Message::MyConfigUpdate(u.config)),
|
||||||
|
wayland_subscription::workspaces().map(|e| Message::WorkspaceUpdate(e)),
|
||||||
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, message: Self::Message) -> Command<cosmic::app::Message<Self::Message>> {
|
fn update(&mut self, message: Self::Message) -> Command<cosmic::app::Message<Self::Message>> {
|
||||||
match message {
|
match message {
|
||||||
|
Message::WorkspaceUpdate(msg) => match msg {
|
||||||
|
WorkspacesUpdate::State(state) => {
|
||||||
|
self.autotiled = matches!(state, TilingState::TilingEnabled);
|
||||||
|
self.timeline.set_chain(if self.autotiled {
|
||||||
|
cosmic_time::chain::Toggler::on(TILE_WINDOWS.clone(), 1.0)
|
||||||
|
} else {
|
||||||
|
cosmic_time::chain::Toggler::off(TILE_WINDOWS.clone(), 1.0)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
WorkspacesUpdate::Started(tx) => {
|
||||||
|
self.workspace_tx = Some(tx);
|
||||||
|
}
|
||||||
|
WorkspacesUpdate::Errored => {
|
||||||
|
error!("Workspaces subscription failed...");
|
||||||
|
}
|
||||||
|
},
|
||||||
Message::TogglePopup => {
|
Message::TogglePopup => {
|
||||||
return if let Some(p) = self.popup.take() {
|
return if let Some(p) = self.popup.take() {
|
||||||
destroy_popup(p)
|
destroy_popup(p)
|
||||||
|
|
@ -101,7 +178,7 @@ impl cosmic::Application for Window {
|
||||||
.applet
|
.applet
|
||||||
.get_popup_settings(Id::MAIN, new_id, None, None, None);
|
.get_popup_settings(Id::MAIN, new_id, None, None, None);
|
||||||
popup_settings.positioner.size_limits = Limits::NONE
|
popup_settings.positioner.size_limits = Limits::NONE
|
||||||
.max_width(372.0)
|
.max_width(400.0)
|
||||||
.min_width(300.0)
|
.min_width(300.0)
|
||||||
.min_height(200.0)
|
.min_height(200.0)
|
||||||
.max_height(1080.0);
|
.max_height(1080.0);
|
||||||
|
|
@ -116,103 +193,106 @@ impl cosmic::Application for Window {
|
||||||
Message::Frame(now) => self.timeline.now(now),
|
Message::Frame(now) => self.timeline.now(now),
|
||||||
Message::ToggleTileWindows(chain, toggled) => {
|
Message::ToggleTileWindows(chain, toggled) => {
|
||||||
self.timeline.set_chain(chain).start();
|
self.timeline.set_chain(chain).start();
|
||||||
self.tile_windows = toggled
|
self.autotiled = toggled;
|
||||||
|
if matches!(self.config.autotile_behavior, TileBehavior::Global) {
|
||||||
|
self.config.autotile = toggled;
|
||||||
|
if toggled {
|
||||||
|
self.new_workspace_behavior_model.activate_position(0);
|
||||||
|
} else {
|
||||||
|
self.new_workspace_behavior_model.activate_position(1);
|
||||||
|
}
|
||||||
|
let helper = self.config_helper.clone();
|
||||||
|
thread::spawn(move || {
|
||||||
|
if let Err(err) = helper.set("autotile", toggled) {
|
||||||
|
error!(?err, "Failed to set autotile {toggled}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// set via protocol
|
||||||
|
if let Some(tx) = self.workspace_tx.as_ref() {
|
||||||
|
let state = if toggled {
|
||||||
|
TilingState::TilingEnabled
|
||||||
|
} else {
|
||||||
|
TilingState::FloatingOnly
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(err) = tx.send(state) {
|
||||||
|
error!("Failed to send the tiling state update. {err:?}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Message::HandleActiveHint(msg) => {
|
Message::ToggleActiveHint(chain, toggled) => {
|
||||||
match msg {
|
self.timeline.set_chain(chain).start();
|
||||||
spin_button::Message::Increment => {
|
self.config.active_hint = toggled;
|
||||||
self.active_hint.update(spin_button::Message::Increment)
|
|
||||||
|
let helper = self.config_helper.clone();
|
||||||
|
thread::spawn(move || {
|
||||||
|
if let Err(err) = helper.set("active_hint", toggled) {
|
||||||
|
error!(?err, "Failed to set active_hint {toggled}");
|
||||||
}
|
}
|
||||||
spin_button::Message::Decrement => {
|
});
|
||||||
self.active_hint.update(spin_button::Message::Decrement)
|
}
|
||||||
|
Message::MyConfigUpdate(c) => {
|
||||||
|
if matches!(c.autotile_behavior, TileBehavior::Global) {
|
||||||
|
if c.autotile != self.config.autotile {
|
||||||
|
self.timeline.set_chain(if c.autotile {
|
||||||
|
cosmic_time::chain::Toggler::on(TILE_WINDOWS.clone(), 1.0)
|
||||||
|
} else {
|
||||||
|
cosmic_time::chain::Toggler::off(TILE_WINDOWS.clone(), 1.0)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
self.autotile_behavior_model.activate_position(0);
|
||||||
|
} else {
|
||||||
|
if c.autotile != self.config.autotile {
|
||||||
|
self.new_workspace_behavior_model
|
||||||
|
.activate_position(if c.autotile { 0 } else { 1 });
|
||||||
|
}
|
||||||
|
self.autotile_behavior_model.activate_position(1);
|
||||||
|
}
|
||||||
|
if c.active_hint != self.config.active_hint {
|
||||||
|
self.timeline.set_chain(if c.active_hint {
|
||||||
|
cosmic_time::chain::Toggler::on(ACTIVE_HINT.clone(), 1.0)
|
||||||
|
} else {
|
||||||
|
cosmic_time::chain::Toggler::off(ACTIVE_HINT.clone(), 1.0)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
self.config = c;
|
||||||
|
}
|
||||||
|
Message::TileMode(e) => {
|
||||||
|
let behavior = if e == self.autotile_global_entity {
|
||||||
|
TileBehavior::Global
|
||||||
|
} else {
|
||||||
|
TileBehavior::PerWorkspace
|
||||||
};
|
};
|
||||||
let is_dark = self.core.system_theme().cosmic().is_dark;
|
|
||||||
let active_hint = self.active_hint.value;
|
|
||||||
return Command::perform(
|
|
||||||
async move {
|
|
||||||
let config = if is_dark {
|
|
||||||
cosmic::cosmic_theme::ThemeBuilder::dark_config()
|
|
||||||
} else {
|
|
||||||
cosmic::cosmic_theme::ThemeBuilder::light_config()
|
|
||||||
};
|
|
||||||
let Ok(config) = config else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Err(err) = ConfigSet::set(&config, "active_hint", active_hint) {
|
self.config.autotile_behavior = behavior;
|
||||||
error!(?err, "Error setting active_hint");
|
self.autotile_behavior_model.activate(e);
|
||||||
}
|
let helper = self.config_helper.clone();
|
||||||
|
let need_to_reset_autotile = self.autotiled != self.config.autotile
|
||||||
let config = if is_dark {
|
&& matches!(behavior, TileBehavior::Global);
|
||||||
cosmic::theme::CosmicTheme::dark_config()
|
if need_to_reset_autotile {
|
||||||
} else {
|
self.autotiled = self.config.autotile;
|
||||||
cosmic::theme::CosmicTheme::light_config()
|
}
|
||||||
};
|
thread::spawn(move || {
|
||||||
let Ok(config) = config else {
|
if let Err(err) = helper.set("autotile_behavior", behavior) {
|
||||||
return;
|
error!(?err, "Failed to set autotile_behavior {behavior:?}");
|
||||||
};
|
|
||||||
|
|
||||||
if let Err(err) = ConfigSet::set(&config, "active_hint", active_hint) {
|
|
||||||
error!(?err, "Error setting active_hint");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|_| cosmic::app::Message::App(Message::Ignore),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Message::HandleGaps(msg) => {
|
|
||||||
match msg {
|
|
||||||
spin_button::Message::Increment => {
|
|
||||||
self.gaps.update(spin_button::Message::Increment)
|
|
||||||
}
|
}
|
||||||
spin_button::Message::Decrement => {
|
});
|
||||||
self.gaps.update(spin_button::Message::Decrement)
|
}
|
||||||
}
|
Message::NewWorkspace(e) => {
|
||||||
};
|
let autotile_new = self.new_workspace_entity == e;
|
||||||
let is_dark = self.core.system_theme().cosmic().is_dark;
|
self.config.autotile = autotile_new;
|
||||||
let gaps = self.gaps.value;
|
self.new_workspace_behavior_model.activate(e);
|
||||||
return Command::perform(
|
// set the config autotile behavior
|
||||||
async move {
|
let helper = self.config_helper.clone();
|
||||||
let config = if is_dark {
|
thread::spawn(move || {
|
||||||
cosmic::cosmic_theme::ThemeBuilder::dark_config()
|
if let Err(err) = helper.set("autotile", autotile_new) {
|
||||||
} else {
|
error!(?err, "Failed to set autotile {autotile_new:?}");
|
||||||
cosmic::cosmic_theme::ThemeBuilder::light_config()
|
}
|
||||||
};
|
});
|
||||||
let Ok(config) = config else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
let Ok(mut c_gaps) = ConfigGet::get::<(u32, u32)>(&config, "gaps") else {
|
|
||||||
error!("Error getting gaps");
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
c_gaps.1 = gaps as u32;
|
|
||||||
|
|
||||||
if let Err(err) = ConfigSet::set(&config, "gaps", c_gaps) {
|
|
||||||
error!(?err, "Error setting gaps");
|
|
||||||
}
|
|
||||||
|
|
||||||
let config = if is_dark {
|
|
||||||
cosmic::theme::CosmicTheme::dark_config()
|
|
||||||
} else {
|
|
||||||
cosmic::theme::CosmicTheme::light_config()
|
|
||||||
};
|
|
||||||
let Ok(config) = config else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Err(err) = ConfigSet::set(&config, "gaps", c_gaps) {
|
|
||||||
error!(?err, "Error setting gaps");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|_| cosmic::app::Message::App(Message::Ignore),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
Message::ViewAllShortcuts => println!("View all shortcuts..."),
|
|
||||||
Message::OpenFloatingWindowExceptions => println!("Floating window exceptions..."),
|
|
||||||
Message::OpenWindowManagementSettings => println!("Window management settings..."),
|
|
||||||
Message::Ignore => {}
|
|
||||||
}
|
}
|
||||||
Command::none()
|
Command::none()
|
||||||
}
|
}
|
||||||
|
|
@ -226,22 +306,47 @@ impl cosmic::Application for Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view_window(&self, _id: Id) -> Element<Self::Message> {
|
fn view_window(&self, _id: Id) -> Element<Self::Message> {
|
||||||
let cosmic = self.core.system_theme().cosmic();
|
let space_xxs = self.core.system_theme().cosmic().space_xxs();
|
||||||
let active_hint = cosmic.active_hint;
|
let mut new_workspace_behavior_button =
|
||||||
let gaps = cosmic.gaps.1;
|
segmented_selection::horizontal(&self.new_workspace_behavior_model);
|
||||||
|
if matches!(self.config.autotile_behavior, TileBehavior::PerWorkspace) {
|
||||||
|
new_workspace_behavior_button =
|
||||||
|
new_workspace_behavior_button.on_activate(|e| Message::NewWorkspace(e));
|
||||||
|
}
|
||||||
let content_list = column![
|
let content_list = column![
|
||||||
padded_control(container(
|
padded_control(container(
|
||||||
anim!(
|
anim!(
|
||||||
TILE_WINDOWS,
|
TILE_WINDOWS,
|
||||||
&self.timeline,
|
&self.timeline,
|
||||||
fl!("tile-windows"),
|
if matches!(self.config.autotile_behavior, TileBehavior::Global) {
|
||||||
self.tile_windows,
|
fl!("tile-windows")
|
||||||
|
} else {
|
||||||
|
fl!("tile-current")
|
||||||
|
},
|
||||||
|
self.autotiled,
|
||||||
|chain, enable| { Message::ToggleTileWindows(chain, enable) },
|
|chain, enable| { Message::ToggleTileWindows(chain, enable) },
|
||||||
)
|
)
|
||||||
.text_size(14)
|
.text_size(14)
|
||||||
.width(Length::Fill),
|
.width(Length::Fill),
|
||||||
))
|
))
|
||||||
.width(Length::Fill),
|
.width(Length::Fill),
|
||||||
|
padded_control(
|
||||||
|
column![
|
||||||
|
divider::horizontal::default(),
|
||||||
|
column![
|
||||||
|
text(fl!("autotile-behavior")).size(14),
|
||||||
|
segmented_selection::horizontal(&self.autotile_behavior_model)
|
||||||
|
.on_activate(|e| Message::TileMode(e))
|
||||||
|
],
|
||||||
|
divider::horizontal::default(),
|
||||||
|
column![
|
||||||
|
text(fl!("new-workspace")).size(14),
|
||||||
|
new_workspace_behavior_button,
|
||||||
|
]
|
||||||
|
]
|
||||||
|
.spacing(space_xxs)
|
||||||
|
),
|
||||||
|
padded_control(divider::horizontal::default()),
|
||||||
padded_control(row!(
|
padded_control(row!(
|
||||||
text(fl!("navigate-windows")).size(14).width(Length::Fill),
|
text(fl!("navigate-windows")).size(14).width(Length::Fill),
|
||||||
text(format!("{} + {}", fl!("super"), fl!("arrow-keys"))).size(14),
|
text(format!("{} + {}", fl!("super"), fl!("arrow-keys"))).size(14),
|
||||||
|
|
@ -264,26 +369,16 @@ impl cosmic::Application for Window {
|
||||||
)),
|
)),
|
||||||
padded_control(divider::horizontal::default()),
|
padded_control(divider::horizontal::default()),
|
||||||
padded_control(
|
padded_control(
|
||||||
row!(
|
anim!(
|
||||||
text(fl!("active-hint")).size(14).width(Length::Fill),
|
ACTIVE_HINT,
|
||||||
spin_button(active_hint.to_string(), Message::HandleActiveHint),
|
&self.timeline,
|
||||||
|
fl!("active-hint"),
|
||||||
|
self.config.active_hint,
|
||||||
|
|chain, enable| { Message::ToggleActiveHint(chain, enable) },
|
||||||
)
|
)
|
||||||
.align_items(Alignment::Center),
|
.text_size(14)
|
||||||
|
.width(Length::Fill),
|
||||||
),
|
),
|
||||||
padded_control(
|
|
||||||
row!(
|
|
||||||
text(fl!("gaps")).size(14).width(Length::Fill),
|
|
||||||
spin_button(gaps.to_string(), Message::HandleGaps),
|
|
||||||
)
|
|
||||||
.align_items(Alignment::Center),
|
|
||||||
),
|
|
||||||
padded_control(divider::horizontal::default()),
|
|
||||||
menu_button(text(fl!("view-all-shortcuts")).size(14))
|
|
||||||
.on_press(Message::ViewAllShortcuts),
|
|
||||||
menu_button(text(fl!("floating-window-exceptions")).size(14))
|
|
||||||
.on_press(Message::OpenFloatingWindowExceptions),
|
|
||||||
menu_button(text(fl!("window-management-settings")).size(14))
|
|
||||||
.on_press(Message::OpenWindowManagementSettings)
|
|
||||||
]
|
]
|
||||||
.padding([8, 0]);
|
.padding([8, 0]);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue