fix: fix update dep & fix window size

This commit is contained in:
Ashley Wulber 2022-12-07 12:46:54 -05:00
parent 092fc40426
commit d088acd62d
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
7 changed files with 27 additions and 45 deletions

View file

@ -371,7 +371,7 @@ dependencies = [
[[package]]
name = "cosmic-panel-config"
version = "0.1.0"
source = "git+https://github.com/pop-os/cosmic-panel#a452fc323b574c28aef832951edd413a1d87bc3d"
source = "git+https://github.com/pop-os/cosmic-panel#35d61a3a617b2ef552931645ec35c545a3a688f6"
dependencies = [
"anyhow",
"ron",
@ -1375,7 +1375,7 @@ dependencies = [
[[package]]
name = "iced_sctk"
version = "0.1.0"
source = "git+https://github.com/pop-os/iced-sctk#a2c24d95ebc795245495677b99b631a4322ef876"
source = "git+https://github.com/pop-os/iced-sctk#d126b62ef1001b22dc946db91928395890ff8d9f"
dependencies = [
"enum-repr",
"futures",
@ -1574,7 +1574,7 @@ checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
[[package]]
name = "libcosmic"
version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic/?branch=sctk-cosmic-design-system#e87fe7056d09530c35e2c39d470205c6a7a920c6"
source = "git+https://github.com/pop-os/libcosmic/?branch=fix/applets#244569d42d94a8be3a5aa3c3af8bedff047d780e"
dependencies = [
"apply",
"cosmic-panel-config",

View file

@ -5,10 +5,10 @@ authors = ["Ashley Wulber <ashley@system76.com>"]
edition = "2021"
[dependencies]
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "sctk-cosmic-design-system", default-features = false, features = ["wayland", "applet"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "fix/applets", default-features = false, features = ["wayland", "applet"] }
cosmic-panel-config = {git = "https://github.com/pop-os/cosmic-panel", default-features = false }
iced_sctk = { git = "https://github.com/pop-os/iced-sctk" }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", ersion = "0.1.0-beta.13" }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", version = "0.16" }
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = ["client"] }
wayland-backend = {version = "0.1.0-beta.13", features = ["client_system"]}
wayland-client = {version = "0.30.0-beta.13"}

View file

@ -1,6 +1,6 @@
use std::{cmp::Ordering, env};
use std::cmp::Ordering;
use calloop::channel::SyncSender;
use cosmic::applet::CosmicAppletHelper;
use cosmic::iced::alignment::{Horizontal, Vertical};
use cosmic::iced::mouse::{self, ScrollDelta};
use cosmic::iced::widget::{column, container, row, text};
@ -63,13 +63,10 @@ impl Application for IcedWorkspacesApplet {
type Flags = ();
fn new(_flags: ()) -> (Self, Command<Message>) {
let applet_helper = CosmicAppletHelper::default();
(
IcedWorkspacesApplet {
layout: match env::var("COSMIC_PANEL_ANCHOR")
.ok()
.and_then(|anchor| anchor.parse::<PanelAnchor>().ok())
.unwrap_or_default()
{
layout: match &applet_helper.anchor {
PanelAnchor::Left | PanelAnchor::Right => Layout::Column,
PanelAnchor::Top | PanelAnchor::Bottom => Layout::Row,
},
@ -100,8 +97,8 @@ impl Application for IcedWorkspacesApplet {
self.workspaces = list;
let unit = 32;
let (w, h) = match self.layout {
Layout::Row => (unit * self.workspaces.len() as u32, unit),
Layout::Column => (unit, unit * self.workspaces.len() as u32),
Layout::Row => (unit * self.workspaces.len().max(1) as u32, unit),
Layout::Column => (unit, unit * self.workspaces.len().max(1) as u32),
};
return commands::window::resize_window(window::Id::new(0), w, h);
}
@ -132,6 +129,9 @@ impl Application for IcedWorkspacesApplet {
}
fn view(&self, _id: SurfaceIdWrapper) -> Element<Message> {
if self.workspaces.is_empty() {
return row![].padding(8).into();
}
let buttons = self
.workspaces
.iter()