Skip to content

Commit

Permalink
chore: update libcosmic
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 authored Feb 6, 2024
1 parent bb30ba2 commit 6906964
Show file tree
Hide file tree
Showing 9 changed files with 345 additions and 331 deletions.
554 changes: 271 additions & 283 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resolver = "2"

[workspace.dependencies.libcosmic]
git = "https://github.com/pop-os/libcosmic"
features = ["single-instance", "tokio", "wayland", "xdg-portal"]
features = ["single-instance", "tokio", "wayland", "xdg-portal", "wgpu"]

[workspace.dependencies.cosmic-config]
git = "https://github.com/pop-os/libcosmic"
Expand All @@ -15,7 +15,6 @@ git = "https://github.com/pop-os/cosmic-bg"

[workspace.dependencies.cosmic-comp-config]
git = "https://github.com/pop-os/cosmic-comp"
# path = "../cosmic-comp/cosmic-comp-config"

[workspace.dependencies.cosmic-panel-config]
git = "https://github.com/pop-os/cosmic-panel"
Expand All @@ -30,3 +29,8 @@ rev = "2e9bf9f"

[profile.release]
opt-level = 3

[patch.crates-io]
wgpu = { git = "https://github.com/gfx-rs/wgpu", rev = "faed98b" }


2 changes: 2 additions & 0 deletions app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ version = "0.14.1"
features = ["fluent-system", "desktop-requester"]

[features]
default = ["wgpu"]
wgpu = ["libcosmic/wgpu"]
test = []
36 changes: 20 additions & 16 deletions app/src/pages/desktop/display/arrangement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use cosmic::iced_core::renderer::Quad;
use cosmic::iced_core::widget::{tree, Tree};
use cosmic::iced_core::{
self as core, Clipboard, Element, Layout, Length, Rectangle, Renderer as IcedRenderer, Shell,
Size, Widget,
self as core, Border, Clipboard, Element, Layout, Length, Rectangle, Renderer as IcedRenderer,
Shell, Size, Widget,
};
use cosmic::iced_core::{alignment, event, text};
use cosmic::iced_core::{layout, mouse, renderer, touch, Point};
Expand Down Expand Up @@ -63,7 +63,7 @@ impl<'a, Message> Arrangement<'a, Message> {
}
}

impl<'a, Message: Clone> Widget<Message, Renderer> for Arrangement<'a, Message> {
impl<'a, Message: Clone> Widget<Message, cosmic::Theme, Renderer> for Arrangement<'a, Message> {
fn tag(&self) -> tree::Tag {
tree::Tag::of::<State>()
}
Expand All @@ -72,12 +72,11 @@ impl<'a, Message: Clone> Widget<Message, Renderer> for Arrangement<'a, Message>
tree::State::new(State::default())
}

fn width(&self) -> Length {
self.width
}

fn height(&self) -> Length {
self.height
fn size(&self) -> Size<Length> {
Size {
width: self.width,
height: self.height,
}
}

fn layout(
Expand Down Expand Up @@ -129,7 +128,7 @@ impl<'a, Message: Clone> Widget<Message, Renderer> for Arrangement<'a, Message>
.width(Length::Fixed(width))
.height(Length::Fixed(height));

let size = limits.resolve(Size::ZERO);
let size = limits.resolve(width, height, Size::ZERO);

layout::Node::new(size)
}
Expand Down Expand Up @@ -289,9 +288,12 @@ impl<'a, Message: Clone> Widget<Message, Renderer> for Arrangement<'a, Message>
renderer.fill_quad(
Quad {
bounds: region,
border_radius: 4.0.into(),
border_width: 3.0,
border_color: border_color.into(),
border: Border {
color: border_color.into(),
radius: 4.0.into(),
width: 3.0,
},
shadow: Default::default(),
},
core::Background::Color(background.into()),
);
Expand All @@ -306,9 +308,11 @@ impl<'a, Message: Clone> Widget<Message, Renderer> for Arrangement<'a, Message>
renderer.fill_quad(
Quad {
bounds: id_bounds,
border_radius: 30.0.into(),
border_width: 0.0,
border_color: core::Color::TRANSPARENT,
border: Border {
radius: 30.0.into(),
..Default::default()
},
shadow: Default::default(),
},
core::Background::Color(cosmic_theme.palette.neutral_1.into()),
);
Expand Down
28 changes: 13 additions & 15 deletions app/src/pages/desktop/panel/applets_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ impl Page {
error!("No panel config helper. Failed to save applets.");
return;
};
dbg!("writing applet config");
if let Err(e) = config.write_entry(helper) {
error!("Failed to save applets: {:?}", e);
}
Expand Down Expand Up @@ -765,10 +766,10 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
.padding(8)
.style(theme::Container::Custom(Box::new(move |theme| {
let mut style = theme.appearance(&theme::Container::Primary);
style.border_radius = 8.0.into();
style.border.radius = 8.0.into();
if is_dragged {
style.border_color = theme.cosmic().accent_color().into();
style.border_width = 2.0;
style.border.color = theme.cosmic().accent_color().into();
style.border.width = 2.0;
}
style
})))
Expand Down Expand Up @@ -798,9 +799,9 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
.padding(8)
.style(theme::Container::Custom(Box::new(move |theme| {
let mut style = theme.appearance(&theme::Container::Primary);
style.border_radius = 8.0.into();
style.border_color = theme.cosmic().bg_divider().into();
style.border_width = 2.0;
style.border.radius = 8.0.into();
style.border.color = theme.cosmic().bg_divider().into();
style.border.width = 2.0;
style.background = Some(Color::TRANSPARENT.into());
style
})))
Expand Down Expand Up @@ -855,7 +856,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
.padding(8)
.style(theme::Container::Custom(Box::new(move |theme| {
let mut style = theme.appearance(&theme::Container::Primary);
style.border_radius = 8.0.into();
style.border.radius = 8.0.into();
style
})))
.into()
Expand Down Expand Up @@ -931,7 +932,8 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
}
}

impl<'a, Message: 'static> Widget<Message, cosmic::Renderer> for AppletReorderList<'a, Message>
impl<'a, Message: 'static> Widget<Message, cosmic::Theme, cosmic::Renderer>
for AppletReorderList<'a, Message>
where
Message: Clone,
{
Expand All @@ -951,12 +953,8 @@ where
tree.diff_children(&mut [&mut self.inner]);
}

fn width(&self) -> Length {
Length::Fill
}

fn height(&self) -> Length {
Length::Shrink
fn size(&self) -> Size<Length> {
Size::new(Length::Fill, Length::Shrink)
}

fn layout(
Expand Down Expand Up @@ -1475,7 +1473,7 @@ where
tree: &'b mut Tree,
layout: layout::Layout<'_>,
renderer: &cosmic::Renderer,
) -> Option<overlay::Element<'b, Message, cosmic::Renderer>> {
) -> Option<overlay::Element<'b, Message, cosmic::Theme, cosmic::Renderer>> {
self.inner.as_widget_mut().overlay(
&mut tree.children[0],
layout.children().next().unwrap(),
Expand Down
3 changes: 3 additions & 0 deletions app/src/pages/desktop/panel/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ impl PageInner {
Message::OutputAdded(name, output) => {
self.outputs.push(name.clone());
self.outputs_map.insert(output.id(), (name, output));
return;
}
Message::OutputRemoved(output) => {
if let Some((name, _)) = self.outputs_map.remove(&output.id()) {
Expand All @@ -436,6 +437,8 @@ impl PageInner {
panel_config.border_radius = 0;
}

dbg!("writing config");

_ = panel_config.write_entry(helper);
}
}
16 changes: 11 additions & 5 deletions app/src/pages/desktop/wallpaper/widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// SPDX-License-Identifier: GPL-3.0-only

use super::Message;
use cosmic::iced::Radius;
use cosmic::iced_core::Border;
use cosmic::iced_core::{self, gradient::Linear, Background, Color, Degrees, Length};
use cosmic::iced_runtime::core::image::Handle as ImageHandle;
use cosmic::prelude::*;
Expand Down Expand Up @@ -68,11 +70,15 @@ pub fn color_image<'a, M: 'a>(
Background::Gradient(iced_core::Gradient::Linear(linear))
}
}),
border_radius: border_radius
.map(|br| br.into())
.unwrap_or_else(|| theme.cosmic().corner_radii.radius_s.into()),
border_width: 0.0,
border_color: Color::TRANSPARENT,

border: Border {
radius: border_radius.map_or_else(
|| Radius::from(theme.cosmic().corner_radii.radius_s),
|br| br.into(),
),
..Default::default()
},
shadow: Default::default(),
}
}))
.padding(0)
Expand Down
9 changes: 6 additions & 3 deletions app/src/pages/input/keyboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use cosmic::{
widget::{self, horizontal_space},
window, Length,
},
iced_core::Border,
iced_style, theme,
widget::{button, container, icon, radio, settings},
};
Expand Down Expand Up @@ -98,9 +99,11 @@ fn popover_menu() -> cosmic::Element<'static, Message> {
icon_color: Some(theme.cosmic().background.on.into()),
text_color: Some(theme.cosmic().background.on.into()),
background: Some(iced::Color::from(theme.cosmic().background.base).into()),
border_radius: cosmic.corner_radii.radius_m.into(),
border_width: 0.0,
border_color: iced::Color::TRANSPARENT,
border: Border {
radius: cosmic.corner_radii.radius_m.into(),
..Default::default()
},
shadow: Default::default(),
}
}))
.into()
Expand Down
20 changes: 13 additions & 7 deletions app/src/theme.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: GPL-3.0-only

use cosmic::theme;
use cosmic::{iced_core::Border, theme};

#[must_use]
pub fn display_container_frame() -> cosmic::theme::Container {
Expand All @@ -11,9 +11,12 @@ pub fn display_container_frame() -> cosmic::theme::Container {
icon_color: None,
text_color: None,
background: Some(cosmic::iced::Background::Color(cosmic::iced::Color::WHITE)),
border_color: cosmic::iced::Color::WHITE,
border_radius: cosmic.corner_radii.radius_xs.into(),
border_width: 3.0,
border: Border {
color: cosmic::iced::Color::WHITE,
radius: cosmic.corner_radii.radius_xs.into(),
width: 3.0,
},
shadow: Default::default(),
}
})
}
Expand All @@ -26,9 +29,12 @@ pub fn display_container_screen() -> cosmic::theme::Container {
icon_color: None,
text_color: None,
background: Some(cosmic::iced::Background::Color(cosmic::iced::Color::BLACK)),
border_color: cosmic::iced::Color::BLACK,
border_radius: cosmic.corner_radii.radius_0.into(),
border_width: 0.0,
border: Border {
color: cosmic::iced::Color::BLACK,
radius: cosmic.corner_radii.radius_0.into(),
width: 0.0,
},
shadow: Default::default(),
}
})
}

0 comments on commit 6906964

Please sign in to comment.