chore: updates after iced-rebase

This commit is contained in:
Ashley Wulber 2026-03-31 16:34:59 -04:00 committed by GitHub
parent bd0d180482
commit 71d9d6d5bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 1786 additions and 2396 deletions

View file

@ -158,7 +158,7 @@ impl cosmic::Application for Minimize {
&mut self.core
}
fn style(&self) -> Option<cosmic::iced_runtime::Appearance> {
fn style(&self) -> Option<iced::theme::Style> {
Some(cosmic::applet::style())
}

View file

@ -12,7 +12,7 @@ use cosmic::{
wayland_protocols::ext::foreign_toplevel_list::v1::client::ext_foreign_toplevel_handle_v1::ExtForeignToplevelHandleV1,
},
iced::{self, Subscription},
iced_core::image::Bytes,
iced_core::Bytes,
iced_futures::{futures, stream},
};
use futures::SinkExt;
@ -22,24 +22,26 @@ use std::fmt::Debug;
use crate::wayland_handler::wayland_handler;
pub fn wayland_subscription() -> iced::Subscription<WaylandUpdate> {
Subscription::run_with_id(
std::any::TypeId::of::<WaylandUpdate>(),
stream::channel(1, move |mut output| async move {
let (calloop_tx, calloop_rx) = calloop::channel::channel();
let runtime = tokio::runtime::Handle::current();
Subscription::run_with(std::any::TypeId::of::<WaylandUpdate>(), |_| {
stream::channel(
1,
move |mut output: futures::channel::mpsc::Sender<WaylandUpdate>| async move {
let (calloop_tx, calloop_rx) = calloop::channel::channel();
let runtime = tokio::runtime::Handle::current();
let _ = std::thread::spawn(move || {
runtime.block_on(async move {
_ = output.send(WaylandUpdate::Init(calloop_tx)).await;
wayland_handler(output.clone(), calloop_rx);
tracing::error!("Wayland handler thread died");
_ = output.send(WaylandUpdate::Finished).await;
let _ = std::thread::spawn(move || {
runtime.block_on(async move {
_ = output.send(WaylandUpdate::Init(calloop_tx)).await;
wayland_handler(output.clone(), calloop_rx);
tracing::error!("Wayland handler thread died");
_ = output.send(WaylandUpdate::Finished).await;
});
});
});
futures::future::pending().await
}),
)
futures::future::pending().await
},
)
})
}
#[derive(Clone, Debug)]

View file

@ -93,8 +93,9 @@ impl<Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for WindowImage<'_, Msg>
fn overlay<'b>(
&'b mut self,
state: &'b mut Tree,
layout: Layout<'_>,
layout: Layout<'b>,
renderer: &cosmic::Renderer,
viewport: &cosmic::iced_core::Rectangle,
translation: Vector,
) -> Option<cosmic::iced_core::overlay::Element<'b, Msg, cosmic::Theme, cosmic::Renderer>> {
let children = [&mut self.image_button, &mut self.icon]
@ -104,7 +105,7 @@ impl<Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for WindowImage<'_, Msg>
.filter_map(|((child, state), layout)| {
child
.as_widget_mut()
.overlay(state, layout, renderer, translation)
.overlay(state, layout, renderer, viewport, translation)
})
.collect::<Vec<_>>();
@ -116,7 +117,7 @@ impl<Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for WindowImage<'_, Msg>
}
fn layout(
&self,
&mut self,
tree: &mut cosmic::iced_core::widget::Tree,
renderer: &cosmic::Renderer,
limits: &cosmic::iced_core::layout::Limits,
@ -125,7 +126,7 @@ impl<Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for WindowImage<'_, Msg>
let button = &mut children[0];
let button_node = self
.image_button
.as_widget()
.as_widget_mut()
.layout(button, renderer, limits);
let img_node = &button_node.children()[0].children()[0];
@ -135,7 +136,7 @@ impl<Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for WindowImage<'_, Msg>
let icon = &mut children[1];
let icon_node = self
.icon
.as_widget()
.as_widget_mut()
.layout(
icon,
renderer,
@ -185,14 +186,14 @@ impl<Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for WindowImage<'_, Msg>
}
fn operate(
&self,
&mut self,
tree: &mut cosmic::iced_core::widget::Tree,
layout: cosmic::iced_core::Layout<'_>,
renderer: &cosmic::Renderer,
operation: &mut dyn cosmic::widget::Operation<()>,
) {
let layout = layout.children().collect::<Vec<_>>();
let children = [&self.image_button, &self.icon];
let children = [&mut self.image_button, &mut self.icon];
for (i, (layout, child)) in layout
.into_iter()
.zip(children.into_iter())
@ -200,26 +201,27 @@ impl<Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for WindowImage<'_, Msg>
.rev()
{
let tree = &mut tree.children[i];
child.as_widget().operate(tree, layout, renderer, operation);
child
.as_widget_mut()
.operate(tree, layout, renderer, operation);
}
}
fn on_event(
fn update(
&mut self,
state: &mut cosmic::iced_core::widget::Tree,
event: cosmic::iced_core::Event,
event: &cosmic::iced_core::Event,
layout: cosmic::iced_core::Layout<'_>,
cursor: cosmic::iced_core::mouse::Cursor,
renderer: &cosmic::Renderer,
clipboard: &mut dyn cosmic::iced_core::Clipboard,
shell: &mut cosmic::iced_core::Shell<'_, Msg>,
viewport: &cosmic::iced_core::Rectangle,
) -> cosmic::iced_core::event::Status {
) {
let children = [&mut self.image_button, &mut self.icon];
let layout = layout.children().collect::<Vec<_>>();
// draw children in order
let mut status = cosmic::iced_core::event::Status::Ignored;
for (i, (layout, child)) in layout
.into_iter()
.zip(children.into_iter())
@ -228,21 +230,13 @@ impl<Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for WindowImage<'_, Msg>
{
let tree = &mut state.children[i];
status = child.as_widget_mut().on_event(
tree,
event.clone(),
layout,
cursor,
renderer,
clipboard,
shell,
viewport,
child.as_widget_mut().update(
tree, event, layout, cursor, renderer, clipboard, shell, viewport,
);
if matches!(status, cosmic::iced_core::event::Status::Captured) {
return status;
if shell.is_event_captured() {
return;
}
}
status
}
fn mouse_interaction(