Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
901 changes: 345 additions & 556 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cosmic-comp-config = { path = "cosmic-comp-config", features = [
"libdisplay-info",
"output",
] }
cosmic-config = { git = "https://github.com/pop-os/libcosmic/", features = [
cosmic-config = { git = "https://github.com/pop-os/libcosmic", features = [
"calloop",
"macro",
] }
Expand All @@ -39,11 +39,11 @@ i18n-embed = { version = "0.16", features = [
"desktop-requester",
] }
i18n-embed-fl = "0.10"
iced_tiny_skia = { git = "https://github.com/pop-os/libcosmic/" }
iced_tiny_skia = { git = "https://github.com/pop-os/libcosmic" }
indexmap = "2.13"
keyframe = "1.1.1"
libc = "0.2.182"
libcosmic = { git = "https://github.com/pop-os/libcosmic/", default-features = false }
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false }
libsystemd = { version = "0.7", optional = true }
log-panics = { version = "2", features = ["with-backtrace"] }
ordered-float = "5.1"
Expand Down
1 change: 1 addition & 0 deletions cosmic-comp-config/src/output/randr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl From<CompList> for cosmic_randr_shell::List {
// XXX no physical output size in the config
physical: (0, 0),
adaptive_sync_availability: None,
serial_number: String::new(),
});
}

Expand Down
2 changes: 1 addition & 1 deletion examples/customized-window-decorations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<Internal, Message: std::clone::Clone + 'static, Lower: Decorations<Internal
widget::column()
.push(canvas(Circle {
radius: (self.height as f32 / 2.) * 0.8,
color: Color::new(1.0, 0.0, 0.0, 1.0),
color: Color::from_rgba(1.0, 0.0, 0.0, 1.0),
}))
.width(self.height as f32),
)
Expand Down
13 changes: 7 additions & 6 deletions src/shell/element/resize_indicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use cosmic::{
Apply,
iced::{
Alignment,
widget::{column, container, horizontal_space, row, vertical_space},
widget::{column, container, row, space},
},
iced_core::{Background, Border, Color, Length},
theme,
Expand Down Expand Up @@ -70,6 +70,7 @@ impl Program for ResizeIndicatorInternal {
let edges = self.edges.lock().unwrap();
let icon_container_style = || {
theme::Container::custom(|theme| container::Style {
snap: true,
icon_color: Some(Color::from(theme.cosmic().accent.on)),
text_color: Some(Color::from(theme.cosmic().accent.on)),
background: Some(Background::Color(theme.cosmic().accent_color().into())),
Expand Down Expand Up @@ -99,7 +100,7 @@ impl Program for ResizeIndicatorInternal {
.center_x(Length::Fill)
.into()
} else {
vertical_space().height(36).into()
space::vertical().height(36).into()
},
row(vec![
if edges.contains(ResizeEdge::LEFT) {
Expand All @@ -118,12 +119,12 @@ impl Program for ResizeIndicatorInternal {
.center_y(Length::Fill)
.into()
} else {
horizontal_space().width(36).into()
space::horizontal().width(36).into()
},
row(vec![
text::heading(&self.shortcut1).into(),
text::body(fl!("grow-window")).into(),
horizontal_space().width(40).into(),
space::horizontal().width(40).into(),
text::heading(&self.shortcut2).into(),
text::body(fl!("shrink-window")).into(),
])
Expand Down Expand Up @@ -155,7 +156,7 @@ impl Program for ResizeIndicatorInternal {
.center_y(Length::Fill)
.into()
} else {
horizontal_space().width(36).into()
space::horizontal().width(36).into()
},
])
.width(Length::Fill)
Expand All @@ -177,7 +178,7 @@ impl Program for ResizeIndicatorInternal {
.center_x(Length::Fill)
.into()
} else {
vertical_space().height(36).into()
space::vertical().height(36).into()
},
])
.into()
Expand Down
3 changes: 2 additions & 1 deletion src/shell/element/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ impl Decorations<CosmicStackInternal, Message> for DefaultDecorations {
.height(Length::Fill)
.width(Length::Fill),
),
iced_widget::horizontal_space()
iced_widget::space::horizontal()
.width(Length::Fixed(0.0))
.apply(iced_widget::container)
.padding([64, 24])
Expand Down Expand Up @@ -1345,6 +1345,7 @@ impl Decorations<CosmicStackInternal, Message> for DefaultDecorations {
};

iced_widget::container::Style {
snap: true,
icon_color: Some(cosmic_theme.background.on.into()),
text_color: Some(cosmic_theme.background.on.into()),
background: Some(Background::Color(background.into())),
Expand Down
78 changes: 41 additions & 37 deletions src/shell/element/stack/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ impl From<TabRuleTheme> for theme::Rule {
match theme {
TabRuleTheme::ActiveActivated => Self::custom(|theme| widget::rule::Style {
color: theme.cosmic().accent_color().into(),
width: 4,
snap: true,
radius: 0.0.into(),
fill_mode: FillMode::Full,
}),
TabRuleTheme::ActiveDeactivated => Self::custom(|theme| widget::rule::Style {
color: theme.cosmic().palette.neutral_5.into(),
width: 4,
snap: true,
radius: 0.0.into(),
fill_mode: FillMode::Full,
}),
TabRuleTheme::Default => Self::custom(|theme| widget::rule::Style {
color: theme.cosmic().palette.neutral_5.into(),
width: 4,
snap: true,
radius: 8.0.into(),
fill_mode: FillMode::Padded(4),
}),
Expand All @@ -62,6 +62,7 @@ impl From<TabBackgroundTheme> for theme::Container<'_> {
match background_theme {
TabBackgroundTheme::ActiveActivated => {
Self::custom(move |theme| widget::container::Style {
snap: true,
icon_color: Some(Color::from(theme.cosmic().accent_text_color())),
text_color: Some(Color::from(theme.cosmic().accent_text_color())),
background: Some(Background::Color(
Expand All @@ -77,6 +78,7 @@ impl From<TabBackgroundTheme> for theme::Container<'_> {
}
TabBackgroundTheme::ActiveDeactivated => {
Self::custom(move |theme| widget::container::Style {
snap: true,
icon_color: None,
text_color: None,
background: Some(Background::Color(
Expand Down Expand Up @@ -186,7 +188,7 @@ impl<Message: TabMessage + 'static> Tab<Message> {
}

let items = vec![
widget::vertical_rule(4).class(self.rule_theme).into(),
widget::rule::vertical(4).class(self.rule_theme).into(),
self.app_icon
.clone()
.apply(widget::container)
Expand Down Expand Up @@ -262,7 +264,7 @@ where
Size::new(Length::Fill, Length::Fill)
}

fn layout(&self, tree: &mut Tree, renderer: &cosmic::Renderer, limits: &Limits) -> Node {
fn layout(&mut self, tree: &mut Tree, renderer: &cosmic::Renderer, limits: &Limits) -> Node {
let min_size = Size {
height: TAB_HEIGHT as f32,
width: if self.active {
Expand Down Expand Up @@ -295,74 +297,68 @@ where
8.,
cosmic::iced::Alignment::Center,
if size.width >= CLOSE_BREAKPOINT as f32 {
&self.elements
&mut self.elements
} else if size.width >= TEXT_BREAKPOINT as f32 {
&self.elements[0..3]
&mut self.elements[0..3]
} else {
&self.elements[0..2]
&mut self.elements[0..2]
},
&mut tree.children,
)
}

fn operate(
&self,
&mut self,
tree: &mut Tree,
layout: Layout<'_>,
renderer: &cosmic::Renderer,
operation: &mut dyn Operation<()>,
) {
operation.container(None, layout.bounds(), &mut |operation| {
operation.container(None, layout.bounds());
operation.traverse(&mut |operation| {
self.elements
.iter()
.iter_mut()
.zip(&mut tree.children)
.zip(layout.children())
.for_each(|((child, state), layout)| {
child
.as_widget()
.as_widget_mut()
.operate(state, layout, renderer, operation);
});
});
}

fn on_event(
fn update(
&mut self,
tree: &mut Tree,
event: event::Event,
event: &event::Event,
layout: Layout<'_>,
cursor: mouse::Cursor,
renderer: &cosmic::Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
viewport: &Rectangle,
) -> event::Status {
let status = self
) {
for ((child, state), layout) in self
.elements
.iter_mut()
.zip(&mut tree.children)
.zip(layout.children())
.map(|((child, state), layout)| {
child.as_widget_mut().on_event(
state,
event.clone(),
layout,
cursor,
renderer,
clipboard,
shell,
viewport,
)
})
.fold(event::Status::Ignored, event::Status::merge);
{
child.as_widget_mut().update(
state, event, layout, cursor, renderer, clipboard, shell, viewport,
);
}

if status == event::Status::Ignored && cursor.is_over(layout.bounds()) {
if !shell.is_event_captured() && cursor.is_over(layout.bounds()) {
if matches!(
event,
event::Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
) {
if let Some(message) = self.press_message.clone() {
shell.publish(message);
return event::Status::Captured;
shell.capture_event();
return;
}
}
if matches!(
Expand All @@ -371,19 +367,19 @@ where
) {
if let Some(message) = self.right_click_message.clone() {
shell.publish(message);
return event::Status::Captured;
shell.capture_event();
return;
}
}
if matches!(
event,
event::Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
) {
shell.publish(Message::activate(self.idx));
return event::Status::Captured;
shell.capture_event();
return;
}
}

status
}

fn mouse_interaction(
Expand Down Expand Up @@ -447,10 +443,18 @@ where
fn overlay<'b>(
&'b mut self,
tree: &'b mut Tree,
layout: Layout<'_>,
layout: Layout<'b>,
renderer: &cosmic::Renderer,
viewport: &Rectangle,
translation: cosmic::iced::Vector,
) -> Option<overlay::Element<'b, Message, cosmic::Theme, cosmic::Renderer>> {
overlay::from_children(&mut self.elements, tree, layout, renderer, translation)
overlay::from_children(
&mut self.elements,
tree,
layout,
renderer,
viewport,
translation,
)
}
}
14 changes: 9 additions & 5 deletions src/shell/element/stack/tab_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ impl TabText {
<cosmic::Renderer as TextRenderer>::Paragraph::with_text(Text {
content: &self.text,
size: cosmic::iced_core::Pixels(self.font_size),
bounds: Size::INFINITY,
bounds: Size::INFINITE,
font: self.font,
horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Center,
align_x: cosmic::iced_core::text::Alignment::Left,
align_y: alignment::Vertical::Center,
shaping: Shaping::Advanced,
line_height: LineHeight::default(),
wrapping: Wrapping::None,
Expand All @@ -107,7 +107,7 @@ impl<Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabText {
Size::new(self.width, self.height)
}

fn layout(&self, tree: &mut Tree, _renderer: &cosmic::Renderer, limits: &Limits) -> Node {
fn layout(&mut self, tree: &mut Tree, _renderer: &cosmic::Renderer, limits: &Limits) -> Node {
let state = tree.state.downcast_mut::<LocalState>();
let text_bounds = state.paragraph.min_bounds();
state.overflowed = limits.max().width < text_bounds.width;
Expand Down Expand Up @@ -142,7 +142,10 @@ impl<Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabText {
renderer.with_layer(bounds, |renderer| {
renderer.fill_paragraph(
&state.paragraph,
Point::new(bounds.x, bounds.y + bounds.height / 2.0),
Point::new(
bounds.x,
bounds.y + bounds.height / 2.0 - state.paragraph.min_bounds().height / 2.0,
),
style.text_color,
bounds,
);
Expand All @@ -166,6 +169,7 @@ impl<Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabText {

renderer.fill_quad(
renderer::Quad {
snap: true,
bounds: Rectangle {
x: (bounds.x + bounds.width - 24.).max(bounds.x),
width: 24.0_f32.min(bounds.width),
Expand Down
Loading