feat: activation of apps
This commit is contained in:
parent
8223c76361
commit
86ed2d4e31
5 changed files with 185 additions and 84 deletions
62
applets/cosmic-app-list/Cargo.lock
generated
62
applets/cosmic-app-list/Cargo.lock
generated
|
|
@ -390,7 +390,6 @@ dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"i18n-embed",
|
"i18n-embed",
|
||||||
"i18n-embed-fl",
|
"i18n-embed-fl",
|
||||||
"iced",
|
|
||||||
"itertools",
|
"itertools",
|
||||||
"libcosmic",
|
"libcosmic",
|
||||||
"log",
|
"log",
|
||||||
|
|
@ -407,19 +406,18 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-client-toolkit"
|
name = "cosmic-client-toolkit"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/cosmic-protocols#85afc5b7e3358b15a35b794c7d482b776c1a3ce4"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmic-protocols",
|
"cosmic-protocols",
|
||||||
"gl_generator",
|
"gl_generator",
|
||||||
"smithay",
|
"smithay",
|
||||||
"smithay-client-toolkit 0.16.0 (git+https://github.com/Smithay/client-toolkit?rev=45a2ea5)",
|
"smithay-client-toolkit",
|
||||||
"wayland-client",
|
"wayland-client",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[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#35d61a3a617b2ef552931645ec35c545a3a688f6"
|
source = "git+https://github.com/pop-os/cosmic-panel#c20dd262e25adfbc5dd5a8c2e85dc61b1f498387"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"ron",
|
"ron",
|
||||||
|
|
@ -433,7 +431,6 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-protocols"
|
name = "cosmic-protocols"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/cosmic-protocols#85afc5b7e3358b15a35b794c7d482b776c1a3ce4"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"wayland-backend",
|
"wayland-backend",
|
||||||
|
|
@ -1411,7 +1408,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced"
|
name = "iced"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
source = "git+https://github.com/pop-os/iced.git?branch=sctk-cosmic#91f51e94ed906deada8462a1cb8a6dfdf43e558c"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#db8b53b83699bf4e10c205873ba281de8d6a5bc3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"iced_futures",
|
"iced_futures",
|
||||||
|
|
@ -1427,7 +1424,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_core"
|
name = "iced_core"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
source = "git+https://github.com/pop-os/iced.git?branch=sctk-cosmic#91f51e94ed906deada8462a1cb8a6dfdf43e558c"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#db8b53b83699bf4e10c205873ba281de8d6a5bc3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"palette",
|
"palette",
|
||||||
|
|
@ -1437,7 +1434,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_futures"
|
name = "iced_futures"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
source = "git+https://github.com/pop-os/iced.git?branch=sctk-cosmic#91f51e94ed906deada8462a1cb8a6dfdf43e558c"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#db8b53b83699bf4e10c205873ba281de8d6a5bc3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"log",
|
"log",
|
||||||
|
|
@ -1449,7 +1446,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_glow"
|
name = "iced_glow"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
source = "git+https://github.com/pop-os/iced.git?branch=sctk-cosmic#91f51e94ed906deada8462a1cb8a6dfdf43e558c"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#db8b53b83699bf4e10c205873ba281de8d6a5bc3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"euclid",
|
"euclid",
|
||||||
|
|
@ -1464,7 +1461,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_graphics"
|
name = "iced_graphics"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "git+https://github.com/pop-os/iced.git?branch=sctk-cosmic#91f51e94ed906deada8462a1cb8a6dfdf43e558c"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#db8b53b83699bf4e10c205873ba281de8d6a5bc3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -1484,7 +1481,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_lazy"
|
name = "iced_lazy"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/pop-os/iced.git?branch=sctk-cosmic#91f51e94ed906deada8462a1cb8a6dfdf43e558c"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#db8b53b83699bf4e10c205873ba281de8d6a5bc3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_native",
|
"iced_native",
|
||||||
"ouroboros",
|
"ouroboros",
|
||||||
|
|
@ -1493,13 +1490,13 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_native"
|
name = "iced_native"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
source = "git+https://github.com/pop-os/iced.git?branch=sctk-cosmic#91f51e94ed906deada8462a1cb8a6dfdf43e558c"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#db8b53b83699bf4e10c205873ba281de8d6a5bc3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"iced_futures",
|
"iced_futures",
|
||||||
"iced_style",
|
"iced_style",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"smithay-client-toolkit 0.16.0 (git+https://github.com/Smithay/client-toolkit)",
|
"smithay-client-toolkit",
|
||||||
"twox-hash",
|
"twox-hash",
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
]
|
]
|
||||||
|
|
@ -1507,7 +1504,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/iced-sctk#d126b62ef1001b22dc946db91928395890ff8d9f"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#db8b53b83699bf4e10c205873ba281de8d6a5bc3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"enum-repr",
|
"enum-repr",
|
||||||
"futures",
|
"futures",
|
||||||
|
|
@ -1518,7 +1515,7 @@ dependencies = [
|
||||||
"iced_native",
|
"iced_native",
|
||||||
"log",
|
"log",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"smithay-client-toolkit 0.16.0 (git+https://github.com/Smithay/client-toolkit)",
|
"smithay-client-toolkit",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"wayland-backend",
|
"wayland-backend",
|
||||||
]
|
]
|
||||||
|
|
@ -1526,7 +1523,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_style"
|
name = "iced_style"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
source = "git+https://github.com/pop-os/iced.git?branch=sctk-cosmic#91f51e94ed906deada8462a1cb8a6dfdf43e558c"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#db8b53b83699bf4e10c205873ba281de8d6a5bc3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
@ -1536,7 +1533,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_wgpu"
|
name = "iced_wgpu"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
source = "git+https://github.com/pop-os/iced.git?branch=sctk-cosmic#91f51e94ed906deada8462a1cb8a6dfdf43e558c"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#db8b53b83699bf4e10c205873ba281de8d6a5bc3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -1715,7 +1712,7 @@ checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libcosmic"
|
name = "libcosmic"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic/?branch=master#91e826d8eacd03d8e7ef5b1a767b2164f8719ed0"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#db8b53b83699bf4e10c205873ba281de8d6a5bc3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"apply",
|
"apply",
|
||||||
"cosmic-panel-config",
|
"cosmic-panel-config",
|
||||||
|
|
@ -1724,13 +1721,13 @@ dependencies = [
|
||||||
"freedesktop-icons",
|
"freedesktop-icons",
|
||||||
"iced",
|
"iced",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
"iced_glow",
|
||||||
"iced_lazy",
|
"iced_lazy",
|
||||||
"iced_native",
|
"iced_native",
|
||||||
"iced_style",
|
"iced_style",
|
||||||
"iced_wgpu",
|
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"palette",
|
"palette",
|
||||||
"smithay-client-toolkit 0.16.0 (git+https://github.com/Smithay/client-toolkit)",
|
"smithay-client-toolkit",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -2745,30 +2742,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smithay-client-toolkit"
|
name = "smithay-client-toolkit"
|
||||||
version = "0.16.0"
|
version = "0.16.0"
|
||||||
source = "git+https://github.com/Smithay/client-toolkit?rev=45a2ea5#45a2ea56ed17883fa6f99df4d87fbc3fc8d8170a"
|
source = "git+https://github.com/Smithay/client-toolkit?rev=f1d9c3e#f1d9c3ef9cfbd508d986f7f98b2fc267fcc39b84"
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"calloop",
|
|
||||||
"dlib",
|
|
||||||
"lazy_static",
|
|
||||||
"log",
|
|
||||||
"memmap2 0.5.8",
|
|
||||||
"nix 0.24.3",
|
|
||||||
"pkg-config",
|
|
||||||
"thiserror",
|
|
||||||
"wayland-backend",
|
|
||||||
"wayland-client",
|
|
||||||
"wayland-cursor",
|
|
||||||
"wayland-protocols",
|
|
||||||
"wayland-protocols-wlr",
|
|
||||||
"wayland-scanner",
|
|
||||||
"xkbcommon",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "smithay-client-toolkit"
|
|
||||||
version = "0.16.0"
|
|
||||||
source = "git+https://github.com/Smithay/client-toolkit#f1d9c3ef9cfbd508d986f7f98b2fc267fcc39b84"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"calloop",
|
"calloop",
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,12 @@ edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cctk = {git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit"}
|
cctk = {path = "../../../cosmic-protocols/client-toolkit", package = "cosmic-client-toolkit"}
|
||||||
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = ["client"] }
|
# cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = ["client"] }
|
||||||
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet"] }
|
cosmic-protocols = { path = "../../../cosmic-protocols", default-features = false, features = ["client"] }
|
||||||
|
|
||||||
|
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet", "tokio"] }
|
||||||
|
# libcosmic = { path = "../../../libcosmic", default-features = false, features = ["wayland", "applet"] }
|
||||||
ron = "0.8"
|
ron = "0.8"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
|
|
@ -27,11 +30,3 @@ freedesktop-icons = {git = "https://github.com/wash2/freedestkop-icons"}
|
||||||
i18n-embed = { version = "0.13", features = ["fluent-system", "desktop-requester"] }
|
i18n-embed = { version = "0.13", features = ["fluent-system", "desktop-requester"] }
|
||||||
i18n-embed-fl = "0.6"
|
i18n-embed-fl = "0.6"
|
||||||
rust-embed = "6.3"
|
rust-embed = "6.3"
|
||||||
|
|
||||||
|
|
||||||
[dependencies.iced]
|
|
||||||
git = "https://github.com/pop-os/iced.git"
|
|
||||||
branch = "sctk-cosmic"
|
|
||||||
# path = "../iced"
|
|
||||||
default-features = false
|
|
||||||
features = ["image", "svg", "tokio", "wayland"]
|
|
||||||
|
|
@ -8,12 +8,15 @@ use crate::toplevel_subscription::ToplevelRequest;
|
||||||
use crate::toplevel_subscription::ToplevelUpdate;
|
use crate::toplevel_subscription::ToplevelUpdate;
|
||||||
use calloop::channel::Sender;
|
use calloop::channel::Sender;
|
||||||
use cctk::toplevel_info::ToplevelInfo;
|
use cctk::toplevel_info::ToplevelInfo;
|
||||||
|
use cctk::wayland_client::protocol::wl_seat::WlSeat;
|
||||||
use cosmic::applet::CosmicAppletHelper;
|
use cosmic::applet::CosmicAppletHelper;
|
||||||
|
use cosmic::iced;
|
||||||
use cosmic::iced::wayland::popup::destroy_popup;
|
use cosmic::iced::wayland::popup::destroy_popup;
|
||||||
use cosmic::iced::wayland::popup::get_popup;
|
use cosmic::iced::wayland::popup::get_popup;
|
||||||
use cosmic::iced::wayland::SurfaceIdWrapper;
|
use cosmic::iced::wayland::SurfaceIdWrapper;
|
||||||
use cosmic::iced::widget::{column, row};
|
use cosmic::iced::widget::{column, row};
|
||||||
use cosmic::iced::{executor, window, Application, Command, Subscription};
|
use cosmic::iced::{executor, window, Application, Command, Subscription};
|
||||||
|
use cosmic::iced_native::subscription::events_with;
|
||||||
use cosmic::iced_style::application::{self, Appearance};
|
use cosmic::iced_style::application::{self, Appearance};
|
||||||
use cosmic::iced_style::Color;
|
use cosmic::iced_style::Color;
|
||||||
use cosmic::theme::Button;
|
use cosmic::theme::Button;
|
||||||
|
|
@ -22,13 +25,13 @@ use cosmic::{Element, Theme};
|
||||||
use cosmic_panel_config::PanelAnchor;
|
use cosmic_panel_config::PanelAnchor;
|
||||||
use cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1;
|
use cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1;
|
||||||
use freedesktop_desktop_entry::DesktopEntry;
|
use freedesktop_desktop_entry::DesktopEntry;
|
||||||
use iced::Alignment;
|
|
||||||
use iced::Background;
|
|
||||||
use iced::wayland::window::resize_window;
|
use iced::wayland::window::resize_window;
|
||||||
use iced::widget::container;
|
use iced::widget::container;
|
||||||
use iced::widget::horizontal_space;
|
use iced::widget::horizontal_space;
|
||||||
use iced::widget::svg;
|
use iced::widget::svg;
|
||||||
use iced::widget::Image;
|
use iced::widget::Image;
|
||||||
|
use iced::Alignment;
|
||||||
|
use iced::Background;
|
||||||
use iced::Length;
|
use iced::Length;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
|
|
@ -54,6 +57,7 @@ struct CosmicAppList {
|
||||||
config: AppListConfig,
|
config: AppListConfig,
|
||||||
toplevel_sender: Option<Sender<ToplevelRequest>>,
|
toplevel_sender: Option<Sender<ToplevelRequest>>,
|
||||||
applet_helper: CosmicAppletHelper,
|
applet_helper: CosmicAppletHelper,
|
||||||
|
seat: Option<WlSeat>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO DnD after sctk merges DnD
|
// TODO DnD after sctk merges DnD
|
||||||
|
|
@ -67,6 +71,8 @@ enum Message {
|
||||||
Quit(ZcosmicToplevelHandleV1),
|
Quit(ZcosmicToplevelHandleV1),
|
||||||
Errored(String),
|
Errored(String),
|
||||||
Ignore,
|
Ignore,
|
||||||
|
NewSeat(WlSeat),
|
||||||
|
RemovedSeat(WlSeat),
|
||||||
}
|
}
|
||||||
fn icon_for_app_ids(mut app_ids: Vec<String>) -> Vec<(String, PathBuf)> {
|
fn icon_for_app_ids(mut app_ids: Vec<String>) -> Vec<(String, PathBuf)> {
|
||||||
let mut ret = freedesktop_desktop_entry::Iter::new(freedesktop_desktop_entry::default_paths())
|
let mut ret = freedesktop_desktop_entry::Iter::new(freedesktop_desktop_entry::default_paths())
|
||||||
|
|
@ -155,8 +161,8 @@ impl Application for CosmicAppList {
|
||||||
let _ = self.config.remove_favorite(id);
|
let _ = self.config.remove_favorite(id);
|
||||||
}
|
}
|
||||||
Message::Activate(handle) => {
|
Message::Activate(handle) => {
|
||||||
if let (Some(tx), Some(handle)) = (self.toplevel_sender.as_ref(), handle) {
|
if let (Some(tx), Some(seat), Some(handle)) = (self.toplevel_sender.as_ref(), self.seat.as_ref(), handle) {
|
||||||
let _ = tx.send(ToplevelRequest::Activate(handle));
|
let _ = tx.send(ToplevelRequest::Activate(handle, seat.clone()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::Quit(handle) => {
|
Message::Quit(handle) => {
|
||||||
|
|
@ -188,7 +194,16 @@ impl Application for CosmicAppList {
|
||||||
let padding = 8;
|
let padding = 8;
|
||||||
let dot_size = 4;
|
let dot_size = 4;
|
||||||
let spacing = 4;
|
let spacing = 4;
|
||||||
let length = self.toplevel_list.iter().map(|t| (pixel_size + 2 * padding).max((dot_size + spacing) * t.toplevels.len() as u16) as u32 + spacing as u32).sum();
|
let length = self
|
||||||
|
.toplevel_list
|
||||||
|
.iter()
|
||||||
|
.map(|t| {
|
||||||
|
(pixel_size + 2 * padding)
|
||||||
|
.max((dot_size + spacing) * t.toplevels.len() as u16)
|
||||||
|
as u32
|
||||||
|
+ spacing as u32
|
||||||
|
})
|
||||||
|
.sum();
|
||||||
let thickness = (pixel_size + 2 * padding + dot_size + spacing) as u32;
|
let thickness = (pixel_size + 2 * padding + dot_size + spacing) as u32;
|
||||||
let (w, h) = match self.applet_helper.anchor {
|
let (w, h) = match self.applet_helper.anchor {
|
||||||
PanelAnchor::Left | PanelAnchor::Right => (thickness, length),
|
PanelAnchor::Left | PanelAnchor::Right => (thickness, length),
|
||||||
|
|
@ -202,6 +217,9 @@ impl Application for CosmicAppList {
|
||||||
}
|
}
|
||||||
ToplevelUpdate::Finished => {
|
ToplevelUpdate::Finished => {
|
||||||
self.subscription_ctr += 1;
|
self.subscription_ctr += 1;
|
||||||
|
for t in &mut self.toplevel_list {
|
||||||
|
t.toplevels.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ToplevelUpdate::RemoveToplevel(handle) => {
|
ToplevelUpdate::RemoveToplevel(handle) => {
|
||||||
if let Some(i) = self.toplevel_list.iter_mut().position(
|
if let Some(i) = self.toplevel_list.iter_mut().position(
|
||||||
|
|
@ -223,7 +241,16 @@ impl Application for CosmicAppList {
|
||||||
let padding = 8;
|
let padding = 8;
|
||||||
let dot_size = 4;
|
let dot_size = 4;
|
||||||
let spacing = 4;
|
let spacing = 4;
|
||||||
let length = self.toplevel_list.iter().map(|t| (pixel_size + 2 * padding).max((dot_size + spacing) * t.toplevels.len() as u16) as u32 + spacing as u32).sum();
|
let length = self
|
||||||
|
.toplevel_list
|
||||||
|
.iter()
|
||||||
|
.map(|t| {
|
||||||
|
(pixel_size + 2 * padding)
|
||||||
|
.max((dot_size + spacing) * t.toplevels.len() as u16)
|
||||||
|
as u32
|
||||||
|
+ spacing as u32
|
||||||
|
})
|
||||||
|
.sum();
|
||||||
let thickness = (pixel_size + 2 * padding + dot_size + spacing) as u32;
|
let thickness = (pixel_size + 2 * padding + dot_size + spacing) as u32;
|
||||||
let (w, h) = match self.applet_helper.anchor {
|
let (w, h) = match self.applet_helper.anchor {
|
||||||
PanelAnchor::Left | PanelAnchor::Right => (thickness, length),
|
PanelAnchor::Left | PanelAnchor::Right => (thickness, length),
|
||||||
|
|
@ -245,7 +272,16 @@ impl Application for CosmicAppList {
|
||||||
let padding = 8;
|
let padding = 8;
|
||||||
let dot_size = 4;
|
let dot_size = 4;
|
||||||
let spacing = 4;
|
let spacing = 4;
|
||||||
let length = self.toplevel_list.iter().map(|t| (pixel_size + 2 * padding).max((dot_size + spacing) * t.toplevels.len() as u16) as u32 + spacing as u32).sum();
|
let length = self
|
||||||
|
.toplevel_list
|
||||||
|
.iter()
|
||||||
|
.map(|t| {
|
||||||
|
(pixel_size + 2 * padding)
|
||||||
|
.max((dot_size + spacing) * t.toplevels.len() as u16)
|
||||||
|
as u32
|
||||||
|
+ spacing as u32
|
||||||
|
})
|
||||||
|
.sum();
|
||||||
let thickness = (pixel_size + 2 * padding + dot_size + spacing) as u32;
|
let thickness = (pixel_size + 2 * padding + dot_size + spacing) as u32;
|
||||||
let (w, h) = match self.applet_helper.anchor {
|
let (w, h) = match self.applet_helper.anchor {
|
||||||
PanelAnchor::Left | PanelAnchor::Right => (thickness, length),
|
PanelAnchor::Left | PanelAnchor::Right => (thickness, length),
|
||||||
|
|
@ -256,6 +292,12 @@ impl Application for CosmicAppList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::Ignore => {}
|
Message::Ignore => {}
|
||||||
|
Message::NewSeat(s) => {
|
||||||
|
self.seat.replace(s);
|
||||||
|
},
|
||||||
|
Message::RemovedSeat(_) => {
|
||||||
|
self.seat.take();
|
||||||
|
},
|
||||||
}
|
}
|
||||||
Command::none()
|
Command::none()
|
||||||
}
|
}
|
||||||
|
|
@ -287,16 +329,18 @@ impl Application for CosmicAppList {
|
||||||
.height(Length::Units(self.applet_helper.suggested_icon_size()))
|
.height(Length::Units(self.applet_helper.suggested_icon_size()))
|
||||||
.into()
|
.into()
|
||||||
};
|
};
|
||||||
let dot_size = (self.applet_helper.suggested_icon_size() / 8).max(2);
|
let dot_radius = (self.applet_helper.suggested_icon_size() / 8).max(2);
|
||||||
let dots = (0..toplevels.len())
|
let dots = (0..toplevels.len())
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|_| {
|
.map(|_| {
|
||||||
container(horizontal_space(Length::Units(0)))
|
container(horizontal_space(Length::Units(0)))
|
||||||
.padding(dot_size)
|
.padding(dot_radius)
|
||||||
.style(<Self::Theme as container::StyleSheet>::Style::Custom(
|
.style(<Self::Theme as container::StyleSheet>::Style::Custom(
|
||||||
|theme| container::Appearance {
|
|theme| container::Appearance {
|
||||||
text_color: Some(Color::TRANSPARENT),
|
text_color: Some(Color::TRANSPARENT),
|
||||||
background: Some(Background::Color(theme.cosmic().on_bg_color().into())),
|
background: Some(Background::Color(
|
||||||
|
theme.cosmic().on_bg_color().into(),
|
||||||
|
)),
|
||||||
border_radius: 4.0,
|
border_radius: 4.0,
|
||||||
border_width: 0.0,
|
border_width: 0.0,
|
||||||
border_color: Color::TRANSPARENT,
|
border_color: Color::TRANSPARENT,
|
||||||
|
|
@ -307,16 +351,29 @@ impl Application for CosmicAppList {
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
|
||||||
let icon_wrapper = match &self.applet_helper.anchor {
|
let icon_wrapper = match &self.applet_helper.anchor {
|
||||||
PanelAnchor::Left => row(vec![column(dots).spacing(2).into(), icon]).align_items(iced::Alignment::Center).spacing(2).into(),
|
PanelAnchor::Left => row(vec![column(dots).spacing(4).into(), icon])
|
||||||
PanelAnchor::Right => row(vec![icon, column(dots).spacing(2).into()]).align_items(iced::Alignment::Center).spacing(2).into(),
|
.align_items(iced::Alignment::Center)
|
||||||
PanelAnchor::Top => column(vec![row(dots).spacing(2).into(), icon]).align_items(iced::Alignment::Center).spacing(2).into(),
|
.spacing(4)
|
||||||
PanelAnchor::Bottom => column(vec![icon, row(dots).spacing(2).into()]).align_items(iced::Alignment::Center).spacing(2).into(),
|
.into(),
|
||||||
|
PanelAnchor::Right => row(vec![icon, column(dots).spacing(4).into()])
|
||||||
|
.align_items(iced::Alignment::Center)
|
||||||
|
.spacing(4)
|
||||||
|
.into(),
|
||||||
|
PanelAnchor::Top => column(vec![row(dots).spacing(4).into(), icon])
|
||||||
|
.align_items(iced::Alignment::Center)
|
||||||
|
.spacing(4)
|
||||||
|
.into(),
|
||||||
|
PanelAnchor::Bottom => column(vec![icon, row(dots).spacing(4).into()])
|
||||||
|
.align_items(iced::Alignment::Center)
|
||||||
|
.spacing(4)
|
||||||
|
.into(),
|
||||||
};
|
};
|
||||||
// TODO tooltip on hover
|
// TODO tooltip on hover
|
||||||
let icon_button = cosmic::widget::button(Button::Text)
|
let icon_button = cosmic::widget::button(Button::Text)
|
||||||
.custom(vec![icon_wrapper])
|
.custom(vec![icon_wrapper])
|
||||||
.on_press(Message::Activate(toplevels.first().map(|t| t.0.clone())))
|
.on_press(Message::Activate(toplevels.first().map(|t| t.0.clone())))
|
||||||
.padding(8).into();
|
.padding(8)
|
||||||
|
.into();
|
||||||
if self.config.favorites.contains(&app_id) {
|
if self.config.favorites.contains(&app_id) {
|
||||||
favorites.push(icon_button)
|
favorites.push(icon_button)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -327,10 +384,20 @@ impl Application for CosmicAppList {
|
||||||
);
|
);
|
||||||
match &self.applet_helper.anchor {
|
match &self.applet_helper.anchor {
|
||||||
PanelAnchor::Left | PanelAnchor::Right => {
|
PanelAnchor::Left | PanelAnchor::Right => {
|
||||||
column![column(favorites), horizontal_rule(1), column(running)].spacing(4).align_items(Alignment::Center).height(Length::Fill).width(Length::Fill).into()
|
column![column(favorites), horizontal_rule(1), column(running)]
|
||||||
|
.spacing(4)
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.height(Length::Fill)
|
||||||
|
.width(Length::Fill)
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
PanelAnchor::Top | PanelAnchor::Bottom => {
|
PanelAnchor::Top | PanelAnchor::Bottom => {
|
||||||
row![row(favorites), vertical_rule(1), row(running)].spacing(4).align_items(Alignment::Center).height(Length::Fill).width(Length::Fill).into()
|
row![row(favorites), vertical_rule(1), row(running)]
|
||||||
|
.spacing(4)
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.height(Length::Fill)
|
||||||
|
.width(Length::Fill)
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -342,7 +409,22 @@ impl Application for CosmicAppList {
|
||||||
|
|
||||||
fn subscription(&self) -> Subscription<Message> {
|
fn subscription(&self) -> Subscription<Message> {
|
||||||
Subscription::batch(vec![
|
Subscription::batch(vec![
|
||||||
toplevel_subscription(self.subscription_ctr).map(|(_, event)| Message::Toplevel(event))
|
toplevel_subscription(self.subscription_ctr).map(|(_, event)| Message::Toplevel(event)),
|
||||||
|
events_with(|e, status| match e {
|
||||||
|
cosmic::iced_native::Event::PlatformSpecific(
|
||||||
|
cosmic::iced_native::event::PlatformSpecific::Wayland(
|
||||||
|
cosmic::iced_native::event::wayland::Event::Seat(e, seat),
|
||||||
|
),
|
||||||
|
) => match e {
|
||||||
|
cosmic::iced_native::event::wayland::SeatEvent::Enter => {
|
||||||
|
Some(Message::NewSeat(seat))
|
||||||
|
},
|
||||||
|
cosmic::iced_native::event::wayland::SeatEvent::Leave => {
|
||||||
|
Some(Message::RemovedSeat(seat))
|
||||||
|
},
|
||||||
|
},
|
||||||
|
_ => None
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,17 @@
|
||||||
use cctk::{
|
use cctk::{
|
||||||
sctk::{self, event_loop::WaylandSource},
|
sctk::{self, event_loop::WaylandSource, seat::{SeatHandler, SeatState}, reexports::client::protocol::wl_seat::WlSeat},
|
||||||
toplevel_info::{ToplevelInfoHandler, ToplevelInfoState},
|
toplevel_info::{ToplevelInfoHandler, ToplevelInfoState},
|
||||||
wayland_client,
|
toplevel_management::{ToplevelManagerHandler, ToplevelManagerState},
|
||||||
|
wayland_client::{self, Proxy, backend::ObjectId},
|
||||||
|
};
|
||||||
|
use cosmic_protocols::{
|
||||||
|
toplevel_info::v1::client::zcosmic_toplevel_handle_v1,
|
||||||
|
toplevel_management::v1::client::zcosmic_toplevel_manager_v1,
|
||||||
};
|
};
|
||||||
use cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1;
|
|
||||||
use futures::channel::mpsc::UnboundedSender;
|
use futures::channel::mpsc::UnboundedSender;
|
||||||
use sctk::registry::{ProvidesRegistryState, RegistryState};
|
use sctk::registry::{ProvidesRegistryState, RegistryState};
|
||||||
use wayland_client::{globals::registry_queue_init, Connection, QueueHandle};
|
use wayland_client::{globals::registry_queue_init, Connection, QueueHandle};
|
||||||
|
use itertools::Itertools;
|
||||||
use crate::toplevel_subscription::{ToplevelRequest, ToplevelUpdate};
|
use crate::toplevel_subscription::{ToplevelRequest, ToplevelUpdate};
|
||||||
|
|
||||||
struct AppData {
|
struct AppData {
|
||||||
|
|
@ -15,6 +19,8 @@ struct AppData {
|
||||||
tx: UnboundedSender<ToplevelUpdate>,
|
tx: UnboundedSender<ToplevelUpdate>,
|
||||||
registry_state: RegistryState,
|
registry_state: RegistryState,
|
||||||
toplevel_info_state: ToplevelInfoState,
|
toplevel_info_state: ToplevelInfoState,
|
||||||
|
toplevel_manager_state: ToplevelManagerState,
|
||||||
|
seat_state: SeatState,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProvidesRegistryState for AppData {
|
impl ProvidesRegistryState for AppData {
|
||||||
|
|
@ -25,6 +31,42 @@ impl ProvidesRegistryState for AppData {
|
||||||
sctk::registry_handlers!();
|
sctk::registry_handlers!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SeatHandler for AppData {
|
||||||
|
fn seat_state(&mut self) -> &mut sctk::seat::SeatState {
|
||||||
|
&mut self.seat_state
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_seat(&mut self, conn: &Connection, qh: &QueueHandle<Self>, seat: WlSeat) {}
|
||||||
|
|
||||||
|
fn new_capability(
|
||||||
|
&mut self,
|
||||||
|
conn: &Connection,
|
||||||
|
qh: &QueueHandle<Self>,
|
||||||
|
seat: WlSeat,
|
||||||
|
capability: sctk::seat::Capability,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
fn remove_capability(
|
||||||
|
&mut self,
|
||||||
|
conn: &Connection,
|
||||||
|
qh: &QueueHandle<Self>,
|
||||||
|
seat: WlSeat,
|
||||||
|
capability: sctk::seat::Capability,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
fn remove_seat(&mut self, conn: &Connection, qh: &QueueHandle<Self>, seat: WlSeat) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToplevelManagerHandler for AppData {
|
||||||
|
fn toplevel_manager_state(&mut self) -> &mut cctk::toplevel_management::ToplevelManagerState {
|
||||||
|
&mut self.toplevel_manager_state
|
||||||
|
}
|
||||||
|
|
||||||
|
fn capabilities(&mut self, conn: &Connection, qh: &QueueHandle<Self>, capabilities: Vec<u8>) {
|
||||||
|
// TODO capabilities could affect the options in the applet
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ToplevelInfoHandler for AppData {
|
impl ToplevelInfoHandler for AppData {
|
||||||
fn toplevel_info_state(&mut self) -> &mut ToplevelInfoState {
|
fn toplevel_info_state(&mut self) -> &mut ToplevelInfoState {
|
||||||
&mut self.toplevel_info_state
|
&mut self.toplevel_info_state
|
||||||
|
|
@ -90,8 +132,12 @@ pub(crate) fn toplevel_handler(
|
||||||
if handle
|
if handle
|
||||||
.insert_source(rx, |event, _, state| match event {
|
.insert_source(rx, |event, _, state| match event {
|
||||||
calloop::channel::Event::Msg(req) => match req {
|
calloop::channel::Event::Msg(req) => match req {
|
||||||
ToplevelRequest::Activate(_) => {} // TODO
|
ToplevelRequest::Activate(handle, seat) => {
|
||||||
ToplevelRequest::Quit(_) => {} // TODO
|
|
||||||
|
let manager = &state.toplevel_manager_state.manager;
|
||||||
|
manager.activate(&handle, &seat);
|
||||||
|
} // TODO
|
||||||
|
ToplevelRequest::Quit(_) => {} // TODO
|
||||||
ToplevelRequest::Exit => {
|
ToplevelRequest::Exit => {
|
||||||
state.exit = true;
|
state.exit = true;
|
||||||
}
|
}
|
||||||
|
|
@ -108,7 +154,9 @@ pub(crate) fn toplevel_handler(
|
||||||
let mut app_data = AppData {
|
let mut app_data = AppData {
|
||||||
exit: false,
|
exit: false,
|
||||||
tx,
|
tx,
|
||||||
|
seat_state: SeatState::new(&globals, &qh),
|
||||||
toplevel_info_state: ToplevelInfoState::new(®istry_state, &qh),
|
toplevel_info_state: ToplevelInfoState::new(®istry_state, &qh),
|
||||||
|
toplevel_manager_state: ToplevelManagerState::new(®istry_state, &qh),
|
||||||
registry_state,
|
registry_state,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -120,5 +168,7 @@ pub(crate) fn toplevel_handler(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sctk::delegate_seat!(AppData);
|
||||||
sctk::delegate_registry!(AppData);
|
sctk::delegate_registry!(AppData);
|
||||||
cctk::delegate_toplevel_info!(AppData);
|
cctk::delegate_toplevel_info!(AppData);
|
||||||
|
cctk::delegate_toplevel_manager!(AppData);
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,15 @@
|
||||||
//!
|
//!
|
||||||
//! This code was generated by `zbus-xmlgen` `2.0.1` from DBus introspection data.
|
//! This code was generated by `zbus-xmlgen` `2.0.1` from DBus introspection data.
|
||||||
//! Source: `Interface '/org/freedesktop/UPower/KbdBacklight' from service 'org.freedesktop.UPower' on system bus`.
|
//! Source: `Interface '/org/freedesktop/UPower/KbdBacklight' from service 'org.freedesktop.UPower' on system bus`.
|
||||||
|
use cctk::sctk::reexports::client::protocol::wl_seat::WlSeat;
|
||||||
use cctk::toplevel_info::ToplevelInfo;
|
use cctk::toplevel_info::ToplevelInfo;
|
||||||
use cosmic::iced;
|
use cosmic::iced;
|
||||||
|
use cosmic::iced::subscription;
|
||||||
use cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1;
|
use cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1;
|
||||||
use futures::{
|
use futures::{
|
||||||
channel::mpsc::{unbounded, UnboundedReceiver},
|
channel::mpsc::{unbounded, UnboundedReceiver},
|
||||||
StreamExt,
|
StreamExt,
|
||||||
};
|
};
|
||||||
use iced::subscription;
|
|
||||||
use std::{fmt::Debug, hash::Hash};
|
use std::{fmt::Debug, hash::Hash};
|
||||||
|
|
||||||
use crate::toplevel_handler::toplevel_handler;
|
use crate::toplevel_handler::toplevel_handler;
|
||||||
|
|
@ -65,7 +65,7 @@ pub enum ToplevelUpdate {
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum ToplevelRequest {
|
pub enum ToplevelRequest {
|
||||||
Activate(ZcosmicToplevelHandleV1),
|
Activate(ZcosmicToplevelHandleV1, WlSeat),
|
||||||
Quit(ZcosmicToplevelHandleV1),
|
Quit(ZcosmicToplevelHandleV1),
|
||||||
Exit,
|
Exit,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue