wip rebase updates

This commit is contained in:
Ashley Wulber 2026-02-10 15:37:41 -05:00
parent 86dcf8af6c
commit e10459fb37
68 changed files with 1776 additions and 1544 deletions

View file

@ -217,7 +217,7 @@ where
}
fn layout(
&self,
&mut self,
tree: &mut Tree,
renderer: &Renderer,
limits: &layout::Limits,
@ -233,25 +233,26 @@ where
self.padding,
self.spacing,
self.align,
&self.children,
&mut self.children,
&mut tree.children,
)
}
fn operate(
&self,
&mut self,
tree: &mut Tree,
layout: Layout<'_>,
renderer: &Renderer,
operation: &mut dyn Operation,
) {
operation.container(None, layout.bounds(), &mut |operation| {
operation.container(None, layout.bounds());
operation.traverse(&mut |operation| {
self.children
.iter()
.iter_mut()
.zip(&mut tree.children)
.zip(layout.children())
.for_each(|((child, state), c_layout)| {
child.as_widget().operate(
child.as_widget_mut().operate(
state,
c_layout.with_virtual_offset(layout.virtual_offset()),
renderer,
@ -261,17 +262,17 @@ where
});
}
fn on_event(
fn update(
&mut self,
tree: &mut Tree,
event: Event,
event: &Event,
layout: Layout<'_>,
cursor: mouse::Cursor,
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
viewport: &Rectangle,
) -> event::Status {
) {
let my_state = tree.state.downcast_mut::<State>();
if let Some(hovered) = my_state.hovered {
@ -285,7 +286,7 @@ where
e,
mouse::Event::CursorLeft | mouse::Event::ButtonReleased { .. }
) {
return self.children[hovered].as_widget_mut().on_event(
return self.children[hovered].as_widget_mut().update(
&mut tree.children[hovered],
event,
child_layout.with_virtual_offset(layout.virtual_offset()),
@ -302,7 +303,7 @@ where
iced::core::touch::Event::FingerLifted { .. }
| iced::core::touch::Event::FingerLost { .. }
) {
return self.children[hovered].as_widget_mut().on_event(
return self.children[hovered].as_widget_mut().update(
&mut tree.children[hovered],
event,
child_layout.with_virtual_offset(layout.virtual_offset()),
@ -336,9 +337,9 @@ where
) && cursor.is_over(c_layout.bounds())
{
my_state.hovered = Some(i);
return child.as_widget_mut().on_event(
return child.as_widget_mut().update(
state,
event.clone(),
&event,
c_layout.with_virtual_offset(layout.virtual_offset()),
cursor_virtual,
renderer,
@ -350,9 +351,9 @@ where
cursor_virtual = mouse::Cursor::Unavailable;
}
child.as_widget_mut().on_event(
child.as_widget_mut().update(
state,
event.clone(),
&event,
c_layout.with_virtual_offset(layout.virtual_offset()),
cursor_virtual,
renderer,
@ -360,8 +361,7 @@ where
shell,
viewport,
)
})
.fold(event::Status::Ignored, event::Status::merge)
});
}
fn mouse_interaction(
@ -436,11 +436,19 @@ where
fn overlay<'b>(
&'b mut self,
tree: &'b mut Tree,
layout: Layout<'_>,
layout: Layout<'b>,
renderer: &Renderer,
viewport: &Rectangle,
translation: Vector,
) -> Option<overlay::Element<'b, Message, Theme, Renderer>> {
overlay::from_children(&mut self.children, tree, layout, renderer, translation)
overlay::from_children(
&mut self.children,
tree,
layout,
renderer,
viewport,
translation,
)
}
#[cfg(feature = "a11y")]

View file

@ -1,7 +1,7 @@
#[cfg(feature = "applet-token")]
pub mod token;
use crate::app::cosmic;
use crate::app::{BootData, BootDataInner, cosmic};
use crate::{
Application, Element, Renderer,
app::iced_settings,
@ -18,17 +18,19 @@ use crate::{
self,
autosize::{self, Autosize, autosize},
column::Column,
horizontal_space, layer_container,
layer_container,
row::Row,
vertical_space,
space::horizontal,
space::vertical,
},
};
pub use cosmic_panel_config;
use cosmic_panel_config::{CosmicPanelBackground, PanelAnchor, PanelSize};
use iced_core::{Padding, Shadow};
use iced_runtime::platform_specific::wayland::popup::{SctkPopupSettings, SctkPositioner};
use iced_widget::Text;
use iced_widget::runtime::platform_specific::wayland::popup::{SctkPopupSettings, SctkPositioner};
use sctk::reexports::protocols::xdg::shell::client::xdg_positioner::{Anchor, Gravity};
use std::cell::RefCell;
use std::{borrow::Cow, num::NonZeroU32, rc::Rc, sync::LazyLock, time::Duration};
use tracing::info;
@ -386,6 +388,7 @@ impl Context {
},
shadow: Shadow::default(),
icon_color: Some(cosmic.background.on.into()),
snap: true,
}
}),
)
@ -567,30 +570,36 @@ pub fn run<App: Application>(flags: App::Flags) -> iced::Result {
window_settings.decorations = false;
window_settings.exit_on_close_request = true;
window_settings.resizable = false;
window_settings.resize_border = 0;
// window_settings.resize_border = 0;
// TODO make multi-window not mandatory
let mut app = super::app::multi_window::multi_window::<_, _, _, _, App::Executor>(
cosmic::Cosmic::title,
let no_main_window = core.main_window.is_none();
if no_main_window {
// TODO still apply window settings?
// window_settings = window_settings.clone();
core.main_window = Some(iced_core::window::Id::RESERVED);
}
let mut app = iced::daemon(
BootData(Rc::new(RefCell::new(Some(BootDataInner::<App> {
flags,
core,
})))),
cosmic::Cosmic::update,
cosmic::Cosmic::view,
);
if core.main_window.is_none() {
app = app.window(window_settings.clone());
core.main_window = Some(iced_core::window::Id::RESERVED);
}
app.subscription(cosmic::Cosmic::subscription)
.style(cosmic::Cosmic::style)
.theme(cosmic::Cosmic::theme)
.settings(iced_settings)
.run_with(move || cosmic::Cosmic::<App>::init((core, flags)))
.run()
}
#[must_use]
pub fn style() -> iced_runtime::Appearance {
pub fn style() -> iced::theme::Style {
let theme = crate::theme::THEME.lock().unwrap();
iced_runtime::Appearance {
iced::theme::Style {
background_color: Color::from_rgba(0.0, 0.0, 0.0, 0.0),
text_color: theme.cosmic().on_bg_color().into(),
icon_color: theme.cosmic().on_bg_color().into(),

View file

@ -208,7 +208,7 @@ where
}
fn layout(
&self,
&mut self,
tree: &mut Tree,
renderer: &Renderer,
limits: &layout::Limits,
@ -222,25 +222,26 @@ where
self.padding,
self.spacing,
self.align,
&self.children,
&mut self.children,
&mut tree.children,
)
}
fn operate(
&self,
&mut self,
tree: &mut Tree,
layout: Layout<'_>,
renderer: &Renderer,
operation: &mut dyn Operation,
) {
operation.container(None, layout.bounds(), &mut |operation| {
operation.container(None, layout.bounds());
operation.traverse(&mut |operation| {
self.children
.iter()
.iter_mut()
.zip(&mut tree.children)
.zip(layout.children())
.for_each(|((child, state), c_layout)| {
child.as_widget().operate(
child.as_widget_mut().operate(
state,
c_layout.with_virtual_offset(layout.virtual_offset()),
renderer,
@ -250,17 +251,17 @@ where
});
}
fn on_event(
fn update(
&mut self,
tree: &mut Tree,
event: Event,
event: &Event,
layout: Layout<'_>,
cursor: mouse::Cursor,
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
viewport: &Rectangle,
) -> event::Status {
) {
let my_state = tree.state.downcast_mut::<State>();
if let Some(hovered) = my_state.hovered {
@ -274,7 +275,7 @@ where
e,
mouse::Event::CursorLeft | mouse::Event::ButtonReleased { .. }
) {
return self.children[hovered].as_widget_mut().on_event(
return self.children[hovered].as_widget_mut().update(
&mut tree.children[hovered],
event,
child_layout.with_virtual_offset(layout.virtual_offset()),
@ -291,7 +292,7 @@ where
iced::core::touch::Event::FingerLifted { .. }
| iced::core::touch::Event::FingerLost { .. }
) {
return self.children[hovered].as_widget_mut().on_event(
return self.children[hovered].as_widget_mut().update(
&mut tree.children[hovered],
event,
child_layout.with_virtual_offset(layout.virtual_offset()),
@ -326,9 +327,9 @@ where
) && cursor.is_over(c_layout.bounds())
{
my_state.hovered = Some(i);
return child.as_widget_mut().on_event(
return child.as_widget_mut().update(
state,
event.clone(),
&event,
c_layout.with_virtual_offset(layout.virtual_offset()),
cursor_virtual,
renderer,
@ -340,9 +341,9 @@ where
cursor_virtual = mouse::Cursor::Unavailable;
}
child.as_widget_mut().on_event(
child.as_widget_mut().update(
state,
event.clone(),
&event,
c_layout.with_virtual_offset(layout.virtual_offset()),
cursor_virtual,
renderer,
@ -350,8 +351,7 @@ where
shell,
viewport,
)
})
.fold(event::Status::Ignored, event::Status::merge)
});
}
fn mouse_interaction(
@ -426,11 +426,19 @@ where
fn overlay<'b>(
&'b mut self,
tree: &'b mut Tree,
layout: Layout<'_>,
layout: Layout<'b>,
renderer: &Renderer,
viewport: &Rectangle,
translation: Vector,
) -> Option<overlay::Element<'b, Message, Theme, Renderer>> {
overlay::from_children(&mut self.children, tree, layout, renderer, translation)
overlay::from_children(
&mut self.children,
tree,
layout,
renderer,
viewport,
translation,
)
}
#[cfg(feature = "a11y")]

View file

@ -14,16 +14,15 @@ use super::wayland_handler::wayland_handler;
pub fn activation_token_subscription<I: 'static + Hash + Copy + Send + Sync + Debug>(
id: I,
) -> iced::Subscription<TokenUpdate> {
Subscription::run_with_id(
id,
Subscription::run_with(id, |_| {
stream::channel(50, move |mut output| async move {
let mut state = State::Ready;
loop {
state = start_listening(state, &mut output).await;
}
}),
)
})
})
}
pub enum State {