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