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

@ -1730,7 +1730,7 @@ checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
[[package]]
name = "libcosmic"
version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic/?branch=fix/applets#0760008f54428ef44968df8db465dfceb7ee837d"
source = "git+https://github.com/pop-os/libcosmic/?branch=fix/applets#244569d42d94a8be3a5aa3c3af8bedff047d780e"
dependencies = [
"apply",
"cosmic-panel-config",

View file

@ -47,22 +47,13 @@ fn format_duration(duration: Duration) -> String {
pub fn run() -> cosmic::iced::Result {
let mut settings = settings();
let pixels = std::env::var("COSMIC_PANEL_SIZE")
.ok()
.and_then(|size| match size.parse::<PanelSize>() {
Ok(PanelSize::XL) => Some(64),
Ok(PanelSize::L) => Some(48),
Ok(PanelSize::M) => Some(36),
Ok(PanelSize::S) => Some(24),
Ok(PanelSize::XS) => Some(18),
Err(_) => Some(36),
})
.unwrap_or(36);
let helper = CosmicAppletHelper::default();
let pixels = helper.suggested_icon_size() as u32;
settings.initial_surface = InitialSurface::XdgWindow(SctkWindowSettings {
iced_settings: Settings {
size: (pixels + 32, pixels + 16),
min_size: Some((pixels + 32, pixels + 16)),
max_size: Some((pixels + 32, pixels + 16)),
size: (pixels + 16, pixels + 16),
min_size: Some((pixels + 16, pixels + 16)),
max_size: Some((pixels + 16, pixels + 16)),
..Default::default()
},
..Default::default()

View file

@ -1531,7 +1531,7 @@ checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
[[package]]
name = "libcosmic"
version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic/?branch=fix/applets#9d75dc8830f7ed8a21af790e2b11c93b90629b1f"
source = "git+https://github.com/pop-os/libcosmic/?branch=fix/applets#244569d42d94a8be3a5aa3c3af8bedff047d780e"
dependencies = [
"apply",
"cosmic-panel-config",

View file

@ -6,29 +6,20 @@ use cosmic::{
iced::{sctk_settings::InitialSurface, Application},
iced_native::command::platform_specific::wayland::window::SctkWindowSettings,
iced_native::window::Settings,
settings,
settings, applet::CosmicAppletHelper,
};
use cosmic_panel_config::PanelSize;
use window::*;
pub fn main() -> cosmic::iced::Result {
let mut settings = settings();
let pixels = std::env::var("COSMIC_PANEL_SIZE")
.ok()
.and_then(|size| match size.parse::<PanelSize>() {
Ok(PanelSize::XL) => Some(64),
Ok(PanelSize::L) => Some(48),
Ok(PanelSize::M) => Some(36),
Ok(PanelSize::S) => Some(24),
Ok(PanelSize::XS) => Some(18),
Err(_) => Some(36),
})
.unwrap_or(36);
let helper = CosmicAppletHelper::default();
let pixels = helper.suggested_icon_size() as u32;
settings.initial_surface = InitialSurface::XdgWindow(SctkWindowSettings {
iced_settings: Settings {
size: (pixels + 32, pixels + 16),
min_size: Some((pixels + 32, pixels + 16)),
max_size: Some((pixels + 32, pixels + 16)),
size: (pixels + 16, pixels + 16),
min_size: Some((pixels + 16, pixels + 16)),
max_size: Some((pixels + 16, pixels + 16)),
..Default::default()
},
..Default::default()

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()