Skip to content

Commit

Permalink
update iced
Browse files Browse the repository at this point in the history
  • Loading branch information
git-f0x committed Nov 20, 2024
1 parent 39de757 commit b6772f1
Show file tree
Hide file tree
Showing 9 changed files with 1,768 additions and 957 deletions.
2,423 changes: 1,621 additions & 802 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ cosmic-greeter-daemon = { path = "daemon" }
dirs = "5"
env_logger.workspace = true
freedesktop_entry_parser = "1.3.0"
libcosmic = { workspace = true, features = ["tokio", "wayland"] }
libcosmic = { workspace = true, features = [
"tokio",
"wayland",
"multi-window",
"winit",
] }
log.workspace = true
pam-client = "0.5.0"
pwd.workspace = true
Expand Down
149 changes: 73 additions & 76 deletions src/greeter.rs

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions src/greeter/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only

use super::{Message, SocketState};
use cosmic::iced::Subscription;
use cosmic::iced::{stream, Subscription};
use futures_util::SinkExt;
use greetd_ipc::codec::TokioCodec;
use std::sync::Arc;
Expand All @@ -11,10 +11,9 @@ use tokio::sync::mpsc;

pub fn subscription() -> Subscription<Message> {
struct GreetdSubscription;
cosmic::iced::subscription::channel(
Subscription::run_with_id(
std::any::TypeId::of::<GreetdSubscription>(),
1,
|mut sender| async move {
stream::channel(1, |mut sender| async move {
let (tx, mut rx) = mpsc::channel::<greetd_ipc::Request>(1);
_ = sender.send(Message::GreetdChannel(tx)).await;

Expand Down Expand Up @@ -123,6 +122,6 @@ pub fn subscription() -> Subscription<Message> {
}

futures_util::future::pending().await
},
}),
)
}
23 changes: 12 additions & 11 deletions src/image_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ use cosmic::iced::widget::{
image::{draw, FilterMethod, Handle},
Container,
};
use cosmic::iced::ContentFit;
use cosmic::iced::{ContentFit, Radians, Vector};
use cosmic::iced_core::event::{self, Event};
use cosmic::iced_core::layout;
use cosmic::iced_core::mouse;
use cosmic::iced_core::overlay;
use cosmic::iced_core::renderer;
use cosmic::iced_core::widget::{Operation, Tree};
use cosmic::iced_core::{Clipboard, Element, Layout, Length, Rectangle, Shell, Size, Widget};
use cosmic::iced_renderer::core::widget::OperationOutputWrapper;

pub use cosmic::iced_style::container::StyleSheet;
pub use cosmic::widget::container::Catalog;

pub struct ImageContainer<'a, Message, Theme, Renderer>
where
Renderer: cosmic::iced_core::Renderer + cosmic::iced_core::image::Renderer<Handle = Handle>,
Theme: StyleSheet,
Theme: Catalog,
{
container: Container<'a, Message, Theme, Renderer>,
image_opt: Option<Handle>,
Expand All @@ -27,7 +26,7 @@ where
impl<'a, Message, Renderer> ImageContainer<'a, Message, cosmic::Theme, Renderer>
where
Renderer: cosmic::iced_core::Renderer + cosmic::iced_core::image::Renderer<Handle = Handle>,
cosmic::Theme: StyleSheet,
cosmic::Theme: Catalog,
{
pub fn new(container: Container<'a, Message, cosmic::Theme, Renderer>) -> Self {
Self {
Expand Down Expand Up @@ -79,7 +78,7 @@ where
tree: &mut Tree,
layout: Layout<'_>,
renderer: &Renderer,
operation: &mut dyn Operation<OperationOutputWrapper<Message>>,
operation: &mut dyn Operation<()>,
) {
self.container.operate(tree, layout, renderer, operation)
}
Expand Down Expand Up @@ -122,16 +121,17 @@ where
cursor: mouse::Cursor,
viewport: &Rectangle,
) {
match &self.image_opt {
Some(image) => draw(
if let Some(image) = &self.image_opt {
draw(
renderer,
layout,
image,
self.content_fit,
FilterMethod::Linear,
Radians(0.0).into(),
1.0,
[0.0, 0.0, 0.0, 0.0],
),
None => {}
);
}

self.container.draw(
Expand All @@ -150,8 +150,9 @@ where
tree: &'b mut Tree,
layout: Layout<'_>,
renderer: &Renderer,
translation: Vector,
) -> Option<overlay::Element<'b, Message, cosmic::Theme, Renderer>> {
self.container.overlay(tree, layout, renderer)
self.container.overlay(tree, layout, renderer, translation)
}
}

Expand Down
Loading

0 comments on commit b6772f1

Please sign in to comment.