Update libcosmic
This commit is contained in:
parent
6e9119a988
commit
015f61922b
10 changed files with 394 additions and 418 deletions
698
Cargo.lock
generated
698
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -24,7 +24,7 @@ use cosmic::{
|
|||
iced::{
|
||||
self,
|
||||
event::wayland::{Event as WaylandEvent, OutputEvent},
|
||||
keyboard::KeyCode,
|
||||
keyboard::key::{Key, Named},
|
||||
wayland::{
|
||||
actions::data_device::{DataFromMimeType, DndIcon},
|
||||
data_device::{accept_mime_type, request_dnd_data, set_actions, start_drag},
|
||||
|
|
@ -632,8 +632,9 @@ impl Application for App {
|
|||
{
|
||||
Some(Msg::WaylandEvent(evt))
|
||||
} else if let iced::Event::Keyboard(iced::keyboard::Event::KeyReleased {
|
||||
key_code: KeyCode::Escape,
|
||||
key: Key::Named(Named::Escape),
|
||||
modifiers: _,
|
||||
location: _,
|
||||
}) = evt
|
||||
{
|
||||
Some(Msg::Close)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ use cosmic::{
|
|||
self,
|
||||
advanced::layout::flex::Axis,
|
||||
widget::{column, row},
|
||||
Border,
|
||||
},
|
||||
iced_core::Shadow,
|
||||
widget,
|
||||
};
|
||||
use cosmic_comp_config::workspace::{WorkspaceAmount, WorkspaceLayout};
|
||||
|
|
@ -186,9 +188,12 @@ fn workspaces_sidebar<'a>(
|
|||
text_color: Some(theme.cosmic().on_bg_color().into()),
|
||||
icon_color: Some(theme.cosmic().on_bg_color().into()),
|
||||
background: Some(iced::Color::from(theme.cosmic().background.base).into()),
|
||||
border_radius: (12.0).into(),
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
border: Border {
|
||||
radius: (12.0).into(),
|
||||
width: 0.0,
|
||||
color: iced::Color::TRANSPARENT,
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
}),
|
||||
))
|
||||
.width(width)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use cctk::{
|
||||
cosmic_protocols::screencopy::v1::client::zcosmic_screencopy_session_v1::BufferType,
|
||||
screencopy::BufferInfo,
|
||||
sctk::shm::raw::RawPool,
|
||||
wayland_client::{
|
||||
protocol::{wl_buffer, wl_shm, wl_shm_pool},
|
||||
Connection, Dispatch, QueueHandle, WEnum,
|
||||
|
|
|
|||
|
|
@ -26,14 +26,14 @@ pub struct ImageBg<'a, Msg> {
|
|||
_msg: PhantomData<Msg>,
|
||||
}
|
||||
|
||||
impl<'a, Msg> Widget<Msg, cosmic::Renderer> for ImageBg<'a, Msg> {
|
||||
impl<'a, Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for ImageBg<'a, Msg> {
|
||||
delegate::delegate! {
|
||||
to self.content.as_widget() {
|
||||
fn tag(&self) -> tree::Tag;
|
||||
fn state(&self) -> tree::State;
|
||||
fn children(&self) -> Vec<Tree>;
|
||||
fn width(&self) -> Length;
|
||||
fn height(&self) -> Length;
|
||||
fn size(&self) -> Size<Length>;
|
||||
fn size_hint(&self) -> Size<Length>;
|
||||
fn layout(
|
||||
&self,
|
||||
tree: &mut Tree,
|
||||
|
|
@ -75,7 +75,7 @@ impl<'a, Msg> Widget<Msg, cosmic::Renderer> for ImageBg<'a, Msg> {
|
|||
tree: &'b mut Tree,
|
||||
layout: Layout<'_>,
|
||||
renderer: &cosmic::Renderer,
|
||||
) -> Option<overlay::Element<'b, Msg, cosmic::Renderer>>;
|
||||
) -> Option<overlay::Element<'b, Msg, cosmic::Theme, cosmic::Renderer>>;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -123,6 +123,7 @@ impl<'a, Msg> Widget<Msg, cosmic::Renderer> for ImageBg<'a, Msg> {
|
|||
//});
|
||||
|
||||
self.content
|
||||
.as_widget()
|
||||
.draw(state, renderer, theme, style, layout, cursor, viewport)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use cosmic::iced::{
|
|||
Clipboard, Layout, Shell, Widget,
|
||||
},
|
||||
event::{self, Event},
|
||||
Length, Rectangle,
|
||||
Length, Rectangle, Size,
|
||||
};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ pub struct LayoutWrapper<'a, Msg> {
|
|||
_msg: PhantomData<Msg>,
|
||||
}
|
||||
|
||||
impl<'a, Msg> Widget<Msg, cosmic::Renderer> for LayoutWrapper<'a, Msg> {
|
||||
impl<'a, Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for LayoutWrapper<'a, Msg> {
|
||||
fn layout(
|
||||
&self,
|
||||
tree: &mut Tree,
|
||||
|
|
@ -52,8 +52,8 @@ impl<'a, Msg> Widget<Msg, cosmic::Renderer> for LayoutWrapper<'a, Msg> {
|
|||
fn tag(&self) -> tree::Tag;
|
||||
fn state(&self) -> tree::State;
|
||||
fn children(&self) -> Vec<Tree>;
|
||||
fn width(&self) -> Length;
|
||||
fn height(&self) -> Length;
|
||||
fn size(&self) -> Size<Length>;
|
||||
fn size_hint(&self) -> Size<Length>;
|
||||
fn operate(
|
||||
&self,
|
||||
tree: &mut Tree,
|
||||
|
|
@ -100,7 +100,7 @@ impl<'a, Msg> Widget<Msg, cosmic::Renderer> for LayoutWrapper<'a, Msg> {
|
|||
tree: &'b mut Tree,
|
||||
layout: Layout<'_>,
|
||||
renderer: &cosmic::Renderer,
|
||||
) -> Option<overlay::Element<'b, Msg, cosmic::Renderer>>;
|
||||
) -> Option<overlay::Element<'b, Msg, cosmic::Theme, cosmic::Renderer>>;
|
||||
fn set_id(&mut self, id: Id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use cosmic::iced::{
|
|||
Clipboard, Layout, Shell, Widget,
|
||||
},
|
||||
event::{self, Event},
|
||||
Length, Rectangle,
|
||||
Length, Rectangle, Size,
|
||||
};
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
|
@ -27,14 +27,14 @@ pub struct MouseInteractionWrapper<'a, Msg> {
|
|||
_msg: PhantomData<Msg>,
|
||||
}
|
||||
|
||||
impl<'a, Msg> Widget<Msg, cosmic::Renderer> for MouseInteractionWrapper<'a, Msg> {
|
||||
impl<'a, Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for MouseInteractionWrapper<'a, Msg> {
|
||||
delegate::delegate! {
|
||||
to self.content.as_widget() {
|
||||
fn tag(&self) -> tree::Tag;
|
||||
fn state(&self) -> tree::State;
|
||||
fn children(&self) -> Vec<Tree>;
|
||||
fn width(&self) -> Length;
|
||||
fn height(&self) -> Length;
|
||||
fn size(&self) -> Size<Length>;
|
||||
fn size_hint(&self) -> Size<Length>;
|
||||
fn layout(
|
||||
&self,
|
||||
tree: &mut Tree,
|
||||
|
|
@ -79,7 +79,7 @@ impl<'a, Msg> Widget<Msg, cosmic::Renderer> for MouseInteractionWrapper<'a, Msg>
|
|||
tree: &'b mut Tree,
|
||||
layout: Layout<'_>,
|
||||
renderer: &cosmic::Renderer,
|
||||
) -> Option<overlay::Element<'b, Msg, cosmic::Renderer>>;
|
||||
) -> Option<overlay::Element<'b, Msg, cosmic::Theme, cosmic::Renderer>>;
|
||||
fn set_id(&mut self, id: Id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,14 +54,13 @@ pub struct Toplevels<'a, Msg> {
|
|||
_msg: PhantomData<Msg>,
|
||||
}
|
||||
|
||||
impl<'a, Msg> Widget<Msg, cosmic::Renderer> for Toplevels<'a, Msg> {
|
||||
fn width(&self) -> Length {
|
||||
Length::Fill
|
||||
}
|
||||
|
||||
fn height(&self) -> Length {
|
||||
// TODO Make depend on orientation or drop that option
|
||||
Length::Shrink
|
||||
impl<'a, Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for Toplevels<'a, Msg> {
|
||||
fn size(&self) -> Size<Length> {
|
||||
Size {
|
||||
width: Length::Fill,
|
||||
// TODO Make depend on orientation or drop that option
|
||||
height: Length::Shrink,
|
||||
}
|
||||
}
|
||||
|
||||
fn layout(
|
||||
|
|
@ -81,14 +80,13 @@ impl<'a, Msg> Widget<Msg, cosmic::Renderer> for Toplevels<'a, Msg> {
|
|||
.zip(tree.children.iter_mut())
|
||||
.map(|(child, tree)| {
|
||||
let child_limits = layout::Limits::new(Size::ZERO, limits.max());
|
||||
let mut layout = child.layout(tree, renderer, &child_limits);
|
||||
let mut layout = child.as_widget().layout(tree, renderer, &child_limits);
|
||||
self.axis.main(layout.size())
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let requested_main_total: f32 = requested_mains.iter().sum::<f32>() + total_spacing as f32;
|
||||
|
||||
let scale_factor = (self.axis.main(limits.max()) / requested_main_total).min(1.0);
|
||||
dbg!(scale_factor);
|
||||
|
||||
let max_cross = self.axis.cross(limits.max());
|
||||
|
||||
|
|
@ -112,11 +110,11 @@ impl<'a, Msg> Widget<Msg, cosmic::Renderer> for Toplevels<'a, Msg> {
|
|||
let (max_width, max_height) = self.axis.pack(max_main, max_cross);
|
||||
let child_limits =
|
||||
layout::Limits::new(Size::ZERO, Size::new(max_width, max_height));
|
||||
let mut layout = child.layout(tree, renderer, &child_limits);
|
||||
let mut layout = child.as_widget().layout(tree, renderer, &child_limits);
|
||||
// Center on cross axis
|
||||
let cross = ((max_cross - self.axis.cross(layout.size())) / 2.).max(0.);
|
||||
let (x, y) = self.axis.pack(total_main, cross);
|
||||
layout.move_to(Point::new(x, y));
|
||||
layout = layout.move_to(Point::new(x, y));
|
||||
total_main += self.axis.main(layout.size());
|
||||
layout
|
||||
})
|
||||
|
|
|
|||
|
|
@ -60,13 +60,12 @@ pub struct WorkspaceBar<'a, Msg> {
|
|||
_msg: PhantomData<Msg>,
|
||||
}
|
||||
|
||||
impl<'a, Msg> Widget<Msg, cosmic::Renderer> for WorkspaceBar<'a, Msg> {
|
||||
fn width(&self) -> Length {
|
||||
Length::Fill
|
||||
}
|
||||
|
||||
fn height(&self) -> Length {
|
||||
Length::Fill
|
||||
impl<'a, Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for WorkspaceBar<'a, Msg> {
|
||||
fn size(&self) -> Size<Length> {
|
||||
Size {
|
||||
width: Length::Fill,
|
||||
height: Length::Fill,
|
||||
}
|
||||
}
|
||||
|
||||
fn layout(
|
||||
|
|
@ -103,9 +102,9 @@ impl<'a, Msg> Widget<Msg, cosmic::Renderer> for WorkspaceBar<'a, Msg> {
|
|||
let (max_width, max_height) = self.axis.pack(max_main, max_cross);
|
||||
let child_limits =
|
||||
layout::Limits::new(Size::ZERO, Size::new(max_width, max_height));
|
||||
let mut layout = child.layout(tree, renderer, &child_limits);
|
||||
let mut layout = child.as_widget().layout(tree, renderer, &child_limits);
|
||||
let (x, y) = self.axis.pack(total_main, 0.0);
|
||||
layout.move_to(Point::new(x, y));
|
||||
layout = layout.move_to(Point::new(x, y));
|
||||
total_main += self.axis.main(layout.size());
|
||||
layout
|
||||
})
|
||||
|
|
|
|||
|
|
@ -62,17 +62,16 @@ pub struct WorkspaceItem<'a, Msg> {
|
|||
_msg: PhantomData<Msg>,
|
||||
}
|
||||
|
||||
impl<'a, Msg> Widget<Msg, cosmic::Renderer> for WorkspaceItem<'a, Msg> {
|
||||
fn width(&self) -> Length {
|
||||
//Length::Fill
|
||||
// XXX doesn't work when used in standard `row` widget
|
||||
// But fixes allocation of `dnd_source` wrapping this, within `Workspaces` row
|
||||
Length::Shrink
|
||||
}
|
||||
|
||||
fn height(&self) -> Length {
|
||||
// TODO Make depend on orientation or drop that option
|
||||
Length::Shrink
|
||||
impl<'a, Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for WorkspaceItem<'a, Msg> {
|
||||
fn size(&self) -> Size<Length> {
|
||||
Size {
|
||||
// width: Length::Fill
|
||||
// XXX doesn't work when used in standard `row` widget
|
||||
// But fixes allocation of `dnd_source` wrapping this, within `Workspaces` row
|
||||
width: Length::Shrink,
|
||||
// TODO Make depend on orientation or drop that option
|
||||
height: Length::Shrink,
|
||||
}
|
||||
}
|
||||
|
||||
fn layout(
|
||||
|
|
@ -88,7 +87,9 @@ impl<'a, Msg> Widget<Msg, cosmic::Renderer> for WorkspaceItem<'a, Msg> {
|
|||
// Get layout of main widget, to set overall cross axis size
|
||||
let (max_width, max_height) = self.axis.pack(max_main, max_cross);
|
||||
let child_limits = layout::Limits::new(Size::ZERO, Size::new(max_width, max_height));
|
||||
let layout = self.children[1].layout(tree, renderer, &child_limits);
|
||||
let layout = self.children[1]
|
||||
.as_widget()
|
||||
.layout(tree, renderer, &child_limits);
|
||||
|
||||
let max_cross = self.axis.cross(layout.size());
|
||||
|
||||
|
|
@ -103,11 +104,11 @@ impl<'a, Msg> Widget<Msg, cosmic::Renderer> for WorkspaceItem<'a, Msg> {
|
|||
let (max_width, max_height) = self.axis.pack(max_main, max_cross);
|
||||
let child_limits =
|
||||
layout::Limits::new(Size::ZERO, Size::new(max_width, max_height));
|
||||
let mut layout = child.layout(tree, renderer, &child_limits);
|
||||
let mut layout = child.as_widget().layout(tree, renderer, &child_limits);
|
||||
// Center on cross axis
|
||||
let cross = ((max_cross - self.axis.cross(layout.size())) / 2.).max(0.);
|
||||
let (x, y) = self.axis.pack(total_main, cross);
|
||||
layout.move_to(Point::new(x, y));
|
||||
layout = layout.move_to(Point::new(x, y));
|
||||
total_main += self.axis.main(layout.size());
|
||||
layout
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue