Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions src/shell/element/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ use std::{
};

mod tab;
mod tab_text;
mod tabs;

use self::{
Expand Down Expand Up @@ -1131,6 +1130,7 @@ impl Program for CosmicStackInternal {
.to_i32_round();
cursor.y -= TAB_HEIGHT;
let res = shell.menu_request(
false,
&surface,
&seat,
serial,
Expand Down Expand Up @@ -1173,6 +1173,7 @@ impl Program for CosmicStackInternal {
.to_i32_round();
cursor.y -= TAB_HEIGHT;
let res = shell.menu_request(
false,
&surface,
&seat,
serial,
Expand Down Expand Up @@ -1303,7 +1304,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 +1346,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
90 changes: 48 additions & 42 deletions src/shell/element/stack/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ use cosmic::{
Border, Clipboard, Color, Length, Rectangle, Shell, Size, alignment, event,
layout::{Layout, Limits, Node},
mouse, overlay, renderer,
text::{Ellipsize, EllipsizeHeightLimit, Shaping, Wrapping},
widget::{Id, Widget, operation::Operation, tree::Tree},
},
iced_widget::scrollable::AbsoluteOffset,
theme,
widget::{Icon, icon::from_name},
widget::{Icon, icon::from_name, text},
};

use super::tab_text::tab_text;

#[derive(Clone, Copy)]
pub(super) enum TabRuleTheme {
ActiveActivated,
Expand All @@ -30,19 +29,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 +61,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 +77,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,17 +187,20 @@ 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)
.width(Length::Shrink)
.padding([2, 4])
.center_y(Length::Fill)
.into(),
tab_text(self.title, self.active)
text::body(self.title)
.font(self.font)
.font_size(14.0)
.wrapping(Wrapping::None)
.shaping(Shaping::Advanced)
.ellipsize(Ellipsize::End(EllipsizeHeightLimit::Lines(1)))
.align_y(alignment::Vertical::Center)
.height(Length::Fill)
.width(Length::Fill)
.into(),
Expand Down Expand Up @@ -262,7 +266,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 +299,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 +369,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 +445,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,
)
}
}
Loading
Loading