Skip to content

Commit 14204ed

Browse files
committed
feat: panel / dock blur support
1 parent d518c7d commit 14204ed

20 files changed

Lines changed: 813 additions & 407 deletions

Cargo.lock

Lines changed: 329 additions & 302 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@ sctk = { package = "smithay-client-toolkit", version = "0.20.0", features = [
2222
] }
2323

2424
[patch."https://github.com/pop-os/cosmic-protocols"]
25-
cctk = { package = "cosmic-client-toolkit", git = "https://github.com/pop-os//cosmic-protocols" }
25+
cctk = { package = "cosmic-client-toolkit", git = "https://github.com/pop-os//cosmic-protocols", rev = "a7d2d7a" }
26+
cosmic-protocols = { git = "https://github.com/pop-os//cosmic-protocols", rev = "a7d2d7a" }
2627

2728
# [patch."https://github.com/pop-os/xdg-shell-wrapper"]
2829
# xdg-shell-wrapper-config = { path = "../xdg-shell-wrapper/xdg-shell-wrapper-config" }
2930
# xdg-shell-wrapper = { path = "../xdg-shell-wrapper" }
3031
# xdg-shell-wrapper = { git = "https://github.com/pop-os/xdg-shell-wrapper//", branch = "update" }
3132
# xdg-shell-wrapper-config = { git = "https://github.com/pop-os/xdg-shell-wrapper//", branch = "update" }
3233

33-
# [patch."https://github.com/pop-os/libcosmic"]
34-
# cosmic-config = { git = "https://github.com/pop-os/libcosmic//" }
35-
# libcosmic = { git = "https://github.com/pop-os/libcosmic//" }
36-
# cosmic-theme = { git = "https://github.com/pop-os/libcosmic//" }
37-
# iced_tiny_skia = { git = "https://github.com/pop-os/libcosmic//" }
34+
[patch."https://github.com/pop-os/libcosmic"]
35+
cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "theme-v2" }
36+
libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "theme-v2" }
37+
cosmic-theme = { git = "https://github.com/pop-os/libcosmic//", branch = "theme-v2" }
38+
iced_tiny_skia = { git = "https://github.com/pop-os/libcosmic//", branch = "theme-v2" }

cosmic-panel-bin/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ wayland-protocols = { version = "0.32.11", features = ["staging"] }
2525

2626
xdg-shell-wrapper-config = { path = "../xdg-shell-wrapper-config" }
2727
cctk = { package = "cosmic-client-toolkit", git = "https://github.com/pop-os/cosmic-protocols" }
28+
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = [
29+
"client",
30+
"server",
31+
], rev = "a7d2d7a" }
2832
# cctk = { package = "cosmic-client-toolkit", path = "../../cosmic-protocols/client-toolkit" }
2933
wayland-egl = "0.32.10"
3034
wayland-protocols-wlr = { version = "0.3.11", features = ["client"] }

cosmic-panel-bin/src/config_watching.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ pub fn watch_cosmic_theme(
3737
handle.insert_source(entries_rx, move |event, _, state| {
3838
match event {
3939
channel::Event::Msg(ThemeUpdate::Dark(theme)) => {
40-
state.space.set_dark(theme);
40+
state.space.set_dark(theme, state.client_state.blur_enabled);
4141
},
4242
channel::Event::Msg(ThemeUpdate::Mode(is_dark)) => {
43-
state.space.set_theme_mode(is_dark);
43+
state.space.set_theme_mode(is_dark, state.client_state.blur_enabled);
4444
},
4545
channel::Event::Msg(ThemeUpdate::Light(theme)) => {
46-
state.space.set_light(theme);
46+
state.space.set_light(theme, state.client_state.blur_enabled);
4747
},
4848
channel::Event::Closed => {},
4949
};

cosmic-panel-bin/src/iced/elements/background.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Element for rendering a panel background
22

33
use calloop::LoopHandle;
4+
use cosmic::iced::core::Shadow;
45
use cosmic::iced::{Color, Length, id};
5-
use cosmic::iced_core::Shadow;
66
use cosmic::widget::space;
77
use cosmic::{Theme, theme};
88

@@ -68,16 +68,16 @@ impl Program for Background {
6868
let cosmic = theme.cosmic();
6969

7070
cosmic::widget::container::Style {
71-
text_color: Some(cosmic.background.on.into()),
71+
text_color: Some(cosmic.background(theme.transparent).on.into()),
7272
background: Some(Color::from(color).into()),
7373
border: cosmic::iced::Border {
7474
radius: radius_arr.into(),
7575
width: 0.,
76-
color: cosmic.background.divider.into(),
76+
color: cosmic.background(theme.transparent).divider.into(),
7777
},
7878
shadow: Shadow::default(),
7979
snap: true,
80-
icon_color: Some(cosmic.background.on.into()),
80+
icon_color: Some(cosmic.background(theme.transparent).on.into()),
8181
}
8282
})),
8383
)

cosmic-panel-bin/src/iced/elements/overflow_button.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use calloop::LoopHandle;
99
use crate::xdg_shell_wrapper::shared_state::GlobalState;
1010
use crate::xdg_shell_wrapper::{self};
1111
use cosmic::Element;
12+
use cosmic::iced::core::id;
1213
use cosmic::iced::{Length, Padding};
13-
use cosmic::iced_core::id;
1414
use cosmic::theme::{self, Button};
1515
use cosmic::widget::{Id, button, layer_container};
1616
use smithay::utils::{Logical, Point, Size};
@@ -167,10 +167,8 @@ impl Program for OverflowButton {
167167
button::custom(
168168
layer_container(
169169
cosmic::widget::icon(cosmic::widget::icon::from_name(self.icon.clone()).into())
170-
.class(theme::Svg::Custom(Rc::new(|theme| {
171-
cosmic::iced_widget::svg::Style {
172-
color: Some(theme.cosmic().background.on.into()),
173-
}
170+
.class(theme::Svg::Custom(Rc::new(|theme| cosmic::widget::svg::Style {
171+
color: Some(theme.cosmic().background(theme.transparent).on.into()),
174172
})))
175173
.width(Length::Fixed(self.icon_size as f32))
176174
.height(Length::Fixed(self.icon_size as f32)),

cosmic-panel-bin/src/iced/elements/overflow_popup.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// popup for rendering overflow items in their own space
22

33
use calloop::LoopHandle;
4+
use cosmic::iced::core::Shadow;
45
use cosmic::iced::{Color, Length, id};
5-
use cosmic::iced_core::Shadow;
66
use cosmic::widget::{container, space};
77
use cosmic::{Theme, theme};
88

@@ -55,15 +55,17 @@ impl Program for OverflowPopup {
5555
let radius_m = cosmic.corner_radii.radius_m;
5656

5757
container::Style {
58-
text_color: Some(cosmic.background.on.into()),
59-
background: Some(Color::from(cosmic.background.base).into()),
58+
text_color: Some(cosmic.background(theme.transparent).on.into()),
59+
background: Some(
60+
Color::from(cosmic.background(theme.transparent).base).into(),
61+
),
6062
border: cosmic::iced::Border {
6163
radius: radius_m.into(),
6264
width: border_width,
63-
color: cosmic.background.divider.into(),
65+
color: cosmic.background(theme.transparent).divider.into(),
6466
},
6567
shadow: Shadow::default(),
66-
icon_color: Some(cosmic.background.on.into()),
68+
icon_color: Some(cosmic.background(theme.transparent).on.into()),
6769
snap: true,
6870
}
6971
})),

cosmic-panel-bin/src/iced/mod.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ use std::time::{Duration, Instant};
1212
use crate::iced::state::State;
1313
use crate::xdg_shell_wrapper::shared_state::GlobalState;
1414
use cosmic::Theme;
15+
use cosmic::iced::Renderer as IcedRenderer;
1516
use cosmic::iced::advanced::widget::Tree;
17+
use cosmic::iced::core::clipboard::Null as NullClipboard;
18+
use cosmic::iced::core::renderer::Style;
19+
use cosmic::iced::core::{Color, Font, Length, Pixels};
1620
use cosmic::iced::event::Event;
1721
use cosmic::iced::futures::{self, FutureExt, StreamExt};
1822
use cosmic::iced::keyboard::{Event as KeyboardEvent, Modifiers as IcedModifiers};
1923
use cosmic::iced::mouse::{Button as MouseButton, Cursor, Event as MouseEvent, ScrollDelta};
24+
use cosmic::iced::runtime::Action;
25+
use cosmic::iced::runtime::task::into_stream;
2026
use cosmic::iced::touch::{Event as TouchEvent, Finger};
2127
use cosmic::iced::window::Event as WindowEvent;
2228
use cosmic::iced::{self, Limits, Point as IcedPoint, Size as IcedSize, Task};
23-
use cosmic::iced_core::clipboard::Null as NullClipboard;
24-
use cosmic::iced_core::renderer::Style;
25-
use cosmic::iced_core::{Color, Font, Length, Pixels};
26-
use cosmic::iced_renderer::Renderer as IcedRenderer;
27-
use cosmic::iced_runtime::Action;
28-
use cosmic::iced_runtime::task::into_stream;
2929
use cosmic::widget::Id;
3030
use iced_tiny_skia::graphics::Viewport;
3131
use ordered_float::OrderedFloat;
@@ -169,7 +169,10 @@ impl iced::Executor for MyExecutor {
169169
Ok(MyExecutor { scheduler, executor_token: Some(executor_token) })
170170
}
171171

172-
fn spawn(&self, future: impl Future<Output = ()> + cosmic::iced_futures::MaybeSend + 'static) {
172+
fn spawn(
173+
&self,
174+
future: impl Future<Output = ()> + iced::runtime::futures::MaybeSend + 'static,
175+
) {
173176
self.scheduler.schedule(future).unwrap();
174177
}
175178

@@ -288,10 +291,11 @@ impl<P: Program + Send + 'static> IcedElement<P> {
288291
program: P,
289292
size: impl Into<Size<i32, Logical>>,
290293
handle: LoopHandle<'static, GlobalState>,
291-
theme: cosmic::Theme,
294+
mut theme: cosmic::Theme,
292295
panel_id: usize,
293296
request_redraws: bool,
294297
) -> IcedElement<P> {
298+
theme.transparent = theme.cosmic().frosted_applets;
295299
let size = size.into();
296300
let mut renderer = IcedRenderer::new(Font::default(), Pixels(16.0));
297301

@@ -383,7 +387,8 @@ impl<P: Program + Send + 'static> IcedElement<P> {
383387
self.0.lock().unwrap().update(true);
384388
}
385389

386-
pub fn set_theme(&self, theme: cosmic::Theme) {
390+
pub fn set_theme(&self, mut theme: cosmic::Theme) {
391+
theme.transparent = theme.cosmic().frosted_applets;
387392
let mut guard = self.0.lock().unwrap();
388393
guard.theme = theme.clone();
389394
}

cosmic-panel-bin/src/iced/state.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use super::IcedProgram as Program;
22
use cosmic::iced::core::event::{self, Event};
33
use cosmic::iced::core::widget::operation::{self, Operation};
44
use cosmic::iced::core::{Clipboard, Size, mouse, renderer};
5-
use cosmic::iced_core;
6-
use cosmic::iced_runtime::Task;
7-
use cosmic::iced_runtime::user_interface::{self, UserInterface};
5+
use cosmic::iced::runtime::Task;
6+
use cosmic::iced::runtime::user_interface::{self, UserInterface};
87

98
/// The execution state of a [`Program`]. It leverages caching, event
109
/// processing, and rendering primitive storage.
@@ -27,7 +26,7 @@ where
2726
/// Creates a new [`State`] with the provided [`Program`], initializing its
2827
/// primitive with the given logical bounds and renderer.
2928
pub fn new(
30-
id: iced_core::id::Id,
29+
id: cosmic::iced::core::id::Id,
3130
mut program: P,
3231
bounds: Size,
3332
renderer: &mut cosmic::Renderer,
@@ -88,7 +87,7 @@ where
8887
/// after updating it, only if an update was necessary.
8988
pub fn update(
9089
&mut self,
91-
id: iced_core::id::Id,
90+
id: cosmic::iced::core::id::Id,
9291
bounds: Size,
9392
cursor: mouse::Cursor,
9493
renderer: &mut cosmic::Renderer,
@@ -121,7 +120,7 @@ where
121120
messages.append(&mut self.queued_messages);
122121

123122
let task = if messages.is_empty() {
124-
if let cosmic::iced_runtime::user_interface::State::Updated {
123+
if let cosmic::iced::runtime::user_interface::State::Updated {
125124
mouse_interaction, ..
126125
} = state
127126
{
@@ -144,7 +143,7 @@ where
144143
let mut user_interface =
145144
build_user_interface(id, &mut self.program, temp_cache, renderer, bounds);
146145

147-
if let cosmic::iced_runtime::user_interface::State::Updated {
146+
if let cosmic::iced::runtime::user_interface::State::Updated {
148147
mouse_interaction, ..
149148
} = state
150149
{
@@ -164,7 +163,7 @@ where
164163
/// Applies [`Operation`]s to the [`State`]
165164
pub fn operate(
166165
&mut self,
167-
id: iced_core::id::Id,
166+
id: cosmic::iced::core::id::Id,
168167
renderer: &mut cosmic::Renderer,
169168
operations: impl Iterator<Item = Box<dyn Operation>>,
170169
bounds: Size,
@@ -198,7 +197,7 @@ where
198197
}
199198

200199
fn build_user_interface<'a, P: Program>(
201-
_id: iced_core::id::Id,
200+
_id: cosmic::iced::core::id::Id,
202201
program: &'a mut P,
203202
cache: user_interface::Cache,
204203
renderer: &mut cosmic::Renderer,

cosmic-panel-bin/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ fn main() -> Result<()> {
313313
let mut server_state = ServerState::new(s_dh.clone());
314314

315315
let mut client_state = ClientState::new(event_loop.handle(), &mut space, &mut server_state)?;
316+
space.corner_radius_manager = client_state.cosmic_corner_radius_manager.clone();
316317
client_state.init_workspace_state();
317318
client_state.init_toplevel_info_state();
318319
client_state.init_toplevel_manager_state();

0 commit comments

Comments
 (0)