applet overlap
chore: mpris dep fix: dock buttons improv: battery and audio improvements feat: overlapping padding fix: input source text button fix: apply panel spacing to app tray chore: update libcosmic fix: spacing and padding fix(minimize): hide when empty
This commit is contained in:
parent
b026db6f7c
commit
836c0e378b
26 changed files with 627 additions and 576 deletions
762
Cargo.lock
generated
762
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -72,7 +72,10 @@ lto = "thin"
|
|||
[workspace.metadata.cargo-machete]
|
||||
ignored = ["libcosmic"]
|
||||
|
||||
# [patch."https://github.com/pop-os/libcosmic"]
|
||||
[patch."https://github.com/pop-os/libcosmic"]
|
||||
cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "shrinkable-applets" }
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "shrinkable-applets" }
|
||||
iced_futures = { git = "https://github.com/pop-os/libcosmic//", branch = "shrinkable-applets" }
|
||||
# cosmic-config = { path = "../libcosmic/cosmic-config" }
|
||||
# libcosmic = { path = "../libcosmic" }
|
||||
# iced_futures = { path = "../libcosmic/iced/futures" }
|
||||
|
|
|
|||
|
|
@ -79,8 +79,13 @@ static DND_FAVORITES: u64 = u64::MAX;
|
|||
impl AppletIconData {
|
||||
fn new(applet: &Context) -> Self {
|
||||
let icon_size = applet.suggested_size(false).0;
|
||||
let padding = applet.suggested_padding(false);
|
||||
let icon_spacing = 4.0;
|
||||
let (major_padding, cross_padding) = applet.suggested_padding(false);
|
||||
let (h_padding, v_padding) = if applet.is_horizontal() {
|
||||
(major_padding as f32, cross_padding as f32)
|
||||
} else {
|
||||
(cross_padding as f32, major_padding as f32)
|
||||
};
|
||||
let icon_spacing = applet.spacing as f32;
|
||||
|
||||
let (dot_radius, bar_size) = match applet.size {
|
||||
Size::Hardcoded(_) => (2.0, 8.0),
|
||||
|
|
@ -98,14 +103,31 @@ impl AppletIconData {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
let padding = padding as f32;
|
||||
|
||||
let padding = match applet.anchor {
|
||||
PanelAnchor::Top => [padding - (dot_radius * 2. + 1.), padding, padding, padding],
|
||||
PanelAnchor::Bottom => [padding, padding, padding - (dot_radius * 2. + 1.), padding],
|
||||
PanelAnchor::Left => [padding, padding, padding, padding - (dot_radius * 2. + 1.)],
|
||||
PanelAnchor::Right => [padding, padding - (dot_radius * 2. + 1.), padding, padding],
|
||||
PanelAnchor::Top => [
|
||||
v_padding - (dot_radius * 2. + 1.),
|
||||
h_padding,
|
||||
v_padding,
|
||||
h_padding,
|
||||
],
|
||||
PanelAnchor::Bottom => [
|
||||
v_padding,
|
||||
h_padding,
|
||||
v_padding - (dot_radius * 2. + 1.),
|
||||
h_padding,
|
||||
],
|
||||
PanelAnchor::Left => [
|
||||
v_padding,
|
||||
h_padding,
|
||||
v_padding,
|
||||
h_padding - (dot_radius * 2. + 1.),
|
||||
],
|
||||
PanelAnchor::Right => [
|
||||
v_padding,
|
||||
h_padding - (dot_radius * 2. + 1.),
|
||||
v_padding,
|
||||
h_padding,
|
||||
],
|
||||
};
|
||||
AppletIconData {
|
||||
icon_size,
|
||||
|
|
@ -920,7 +942,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
}
|
||||
Message::DndEnter(x, y) => {
|
||||
let item_size = self.core.applet.suggested_size(false).0
|
||||
+ 2 * self.core.applet.suggested_padding(false);
|
||||
+ 2 * self.core.applet.suggested_padding(false).0;
|
||||
let pos_in_list = match self.core.applet.anchor {
|
||||
PanelAnchor::Top | PanelAnchor::Bottom => x as f32,
|
||||
PanelAnchor::Left | PanelAnchor::Right => y as f32,
|
||||
|
|
@ -942,7 +964,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
}
|
||||
Message::DndMotion(x, y) => {
|
||||
let item_size = self.core.applet.suggested_size(false).0
|
||||
+ 2 * self.core.applet.suggested_padding(false);
|
||||
+ 2 * self.core.applet.suggested_padding(false).0;
|
||||
let pos_in_list = match self.core.applet.anchor {
|
||||
PanelAnchor::Top | PanelAnchor::Bottom => x as f32,
|
||||
PanelAnchor::Left | PanelAnchor::Right => y as f32,
|
||||
|
|
@ -1350,7 +1372,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
};
|
||||
}
|
||||
let applet_suggested_size = self.core.applet.suggested_size(false).0
|
||||
+ 2 * self.core.applet.suggested_padding(false);
|
||||
+ 2 * self.core.applet.suggested_padding(false).0;
|
||||
let (_favorite_popup_cutoff, active_popup_cutoff) =
|
||||
self.panel_overflow_lengths();
|
||||
let popup_applet_count =
|
||||
|
|
@ -1407,7 +1429,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
};
|
||||
}
|
||||
let applet_suggested_size = self.core.applet.suggested_size(false).0
|
||||
+ 2 * self.core.applet.suggested_padding(false);
|
||||
+ 2 * self.core.applet.suggested_padding(false).0;
|
||||
let (favorite_popup_cutoff, _active_popup_cutoff) =
|
||||
self.panel_overflow_lengths();
|
||||
let popup_applet_count =
|
||||
|
|
@ -1573,7 +1595,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
icon::from_name("starred-symbolic.symbolic")
|
||||
.size(self.core.applet.suggested_size(false).0),
|
||||
)
|
||||
.padding(self.core.applet.suggested_padding(false))
|
||||
.padding(self.core.applet.suggested_padding(false).1) // TODO
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
|
|
@ -1643,13 +1665,13 @@ impl cosmic::Application for CosmicAppList {
|
|||
let window_size = self.core.applet.suggested_bounds.as_ref();
|
||||
let max_num = if self.core.applet.is_horizontal() {
|
||||
let suggested_width = self.core.applet.suggested_size(false).0
|
||||
+ self.core.applet.suggested_padding(false) * 2;
|
||||
+ self.core.applet.suggested_padding(false).0 * 2;
|
||||
window_size
|
||||
.map(|w| w.width)
|
||||
.map_or(u32::MAX, |b| (b / suggested_width as f32) as u32) as usize
|
||||
} else {
|
||||
let suggested_height = self.core.applet.suggested_size(false).1
|
||||
+ self.core.applet.suggested_padding(false) * 2;
|
||||
+ self.core.applet.suggested_padding(false).0 * 2;
|
||||
window_size
|
||||
.map(|w| w.height)
|
||||
.map_or(u32::MAX, |b| (b / suggested_height as f32) as u32) as usize
|
||||
|
|
@ -2247,7 +2269,7 @@ impl CosmicAppList {
|
|||
let applet_icon = AppletIconData::new(&self.core.applet);
|
||||
|
||||
let button_total_size = self.core.applet.suggested_size(true).0
|
||||
+ self.core.applet.suggested_padding(true) * 2
|
||||
+ self.core.applet.suggested_padding(true).0 * 2
|
||||
+ applet_icon.icon_spacing as u16;
|
||||
|
||||
let favorite_active_cnt = self
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ Icon=preferences-desktop-accessibility-symbolic
|
|||
StartupNotify=true
|
||||
NoDisplay=true
|
||||
X-CosmicApplet=true
|
||||
X-CosmicShrinkable=true
|
||||
# Indicates that the auto-hover click should go to the "end" of the hover popup
|
||||
X-CosmicHoverPopup=Auto
|
||||
X-OverflowPriority=10
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ i18n-embed-fl.workspace = true
|
|||
i18n-embed.workspace = true
|
||||
libcosmic.workspace = true
|
||||
libpulse-binding = "2.30.1"
|
||||
mpris2-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings" }
|
||||
mpris2-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "precise-capturing" }
|
||||
# mpris2-zbus = { path = "../../dbus-settings-bindings/mpris2" }
|
||||
rust-embed.workspace = true
|
||||
serde.workspace = true
|
||||
tokio.workspace = true
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ Icon=com.system76.CosmicAppletAudio-symbolic
|
|||
StartupNotify=true
|
||||
NoDisplay=true
|
||||
X-CosmicApplet=true
|
||||
X-CosmicShrinkable=true
|
||||
# Indicates that the auto-hover click should go to the "end" of the hover popup
|
||||
X-CosmicHoverPopup=End
|
||||
X-OverflowPriority=10
|
||||
|
|
|
|||
|
|
@ -12,8 +12,9 @@ use config::{AudioAppletConfig, amplification_sink, amplification_source};
|
|||
use cosmic::{
|
||||
Element, Renderer, Task, Theme, app,
|
||||
applet::{
|
||||
column as applet_column,
|
||||
cosmic_panel_config::PanelAnchor,
|
||||
menu_button, menu_control_padding, padded_control,
|
||||
menu_button, menu_control_padding, padded_control, row as applet_row,
|
||||
token::subscription::{TokenRequest, TokenUpdate, activation_token_subscription},
|
||||
},
|
||||
cctk::sctk::reexports::calloop,
|
||||
|
|
@ -166,10 +167,16 @@ pub enum Message {
|
|||
Surface(surface::Action),
|
||||
}
|
||||
|
||||
// TODO
|
||||
// mouse area with on enter and a stack widget for all buttons
|
||||
// most recently entered button is on top
|
||||
// position is a multiple of button size
|
||||
// on leave of applet, popup button is on top again
|
||||
|
||||
impl Audio {
|
||||
fn playback_buttons(&self) -> Option<Element<'_, Message>> {
|
||||
fn playback_buttons(&self) -> Vec<Element<'_, Message>> {
|
||||
let mut elements: Vec<Element<'_, Message>> = Vec::new();
|
||||
if self.player_status.is_some() && self.config.show_media_controls_in_top_panel {
|
||||
let mut elements = Vec::with_capacity(3);
|
||||
if self
|
||||
.player_status
|
||||
.as_ref()
|
||||
|
|
@ -205,18 +212,8 @@ impl Audio {
|
|||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
Some(match self.core.applet.anchor {
|
||||
PanelAnchor::Left | PanelAnchor::Right => Column::with_children(elements)
|
||||
.align_x(Alignment::Center)
|
||||
.into(),
|
||||
PanelAnchor::Top | PanelAnchor::Bottom => Row::with_children(elements)
|
||||
.align_y(Alignment::Center)
|
||||
.into(),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
elements
|
||||
}
|
||||
|
||||
fn go_previous(&self, icon_size: u16) -> Option<Element<'_, Message>> {
|
||||
|
|
@ -724,21 +721,37 @@ impl cosmic::Application for Audio {
|
|||
|
||||
self.core
|
||||
.applet
|
||||
.autosize_window(if let Some(Some(playback_buttons)) = playback_buttons {
|
||||
match self.core.applet.anchor {
|
||||
PanelAnchor::Left | PanelAnchor::Right => Element::from(
|
||||
Column::with_children([playback_buttons, btn.into()])
|
||||
.align_x(Alignment::Center),
|
||||
),
|
||||
PanelAnchor::Top | PanelAnchor::Bottom => {
|
||||
Row::with_children([playback_buttons, btn.into()])
|
||||
.align_y(Alignment::Center)
|
||||
.into()
|
||||
.autosize_window(
|
||||
if let Some(playback_buttons) = playback_buttons
|
||||
&& !playback_buttons.is_empty()
|
||||
{
|
||||
match self.core.applet.anchor {
|
||||
PanelAnchor::Left | PanelAnchor::Right => Element::from(
|
||||
applet_column::Column::with_children(playback_buttons)
|
||||
.push(btn)
|
||||
.align_x(Alignment::Center)
|
||||
// TODO configurable variable from the panel?
|
||||
.spacing(
|
||||
-(self.core.applet.suggested_padding(true).0 as f32)
|
||||
* self.core.applet.padding_overlap,
|
||||
),
|
||||
),
|
||||
PanelAnchor::Top | PanelAnchor::Bottom => {
|
||||
applet_row::Row::with_children(playback_buttons)
|
||||
.push(btn)
|
||||
.align_y(Alignment::Center)
|
||||
// TODO configurable variable from the panel?
|
||||
.spacing(
|
||||
-(self.core.applet.suggested_padding(true).0 as f32)
|
||||
* self.core.applet.padding_overlap,
|
||||
)
|
||||
.into()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
btn.into()
|
||||
})
|
||||
} else {
|
||||
btn.into()
|
||||
},
|
||||
)
|
||||
.into()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,5 +21,6 @@ Icon=com.system76.CosmicAppletBattery-symbolic
|
|||
StartupNotify=true
|
||||
NoDisplay=true
|
||||
X-CosmicApplet=true
|
||||
X-CosmicShrinkable=true
|
||||
X-CosmicHoverPopup=Start
|
||||
X-OverflowPriority=10
|
||||
|
|
|
|||
|
|
@ -484,7 +484,7 @@ impl cosmic::Application for CosmicBatteryApplet {
|
|||
}
|
||||
|
||||
fn view(&self) -> Element<'_, Message> {
|
||||
let btn = self
|
||||
let btn: Element<'_, Message> = self
|
||||
.core
|
||||
.applet
|
||||
.icon_button(&self.icon_name)
|
||||
|
|
@ -508,17 +508,24 @@ impl cosmic::Application for CosmicBatteryApplet {
|
|||
shadow: Shadow::default(),
|
||||
icon_color: Some(Color::TRANSPARENT),
|
||||
}
|
||||
})))
|
||||
.into();
|
||||
})));
|
||||
let (dot_align_x, dot_align_y) = match self.core.applet.anchor {
|
||||
PanelAnchor::Left => (Alignment::Start, Alignment::Center),
|
||||
PanelAnchor::Right => (Alignment::End, Alignment::Center),
|
||||
PanelAnchor::Top => (Alignment::Center, Alignment::Start),
|
||||
PanelAnchor::Bottom => (Alignment::Center, Alignment::End),
|
||||
};
|
||||
|
||||
match self.core.applet.anchor {
|
||||
PanelAnchor::Left | PanelAnchor::Right => Column::with_children([btn, dot])
|
||||
.align_x(Alignment::Center)
|
||||
.into(),
|
||||
PanelAnchor::Top | PanelAnchor::Bottom => Row::with_children([btn, dot])
|
||||
.align_y(Alignment::Center)
|
||||
.into(),
|
||||
}
|
||||
cosmic::iced::widget::stack![
|
||||
btn,
|
||||
container(dot)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.align_y(dot_align_y)
|
||||
.align_x(dot_align_x)
|
||||
.padding(2.0)
|
||||
]
|
||||
.into()
|
||||
};
|
||||
|
||||
self.core.applet.autosize_window(content).into()
|
||||
|
|
@ -790,7 +797,7 @@ impl cosmic::Application for CosmicBatteryApplet {
|
|||
if gpu.toggled
|
||||
&& !self.core.applet.suggested_bounds.as_ref().is_some_and(|c| {
|
||||
let suggested_size = self.core.applet.suggested_size(true);
|
||||
let padding = self.core.applet.suggested_padding(true);
|
||||
let padding = self.core.applet.suggested_padding(true).1;
|
||||
let w = suggested_size.0 + 2 * padding;
|
||||
let h = suggested_size.1 + 2 * padding;
|
||||
// if we have a configure for width and height, we're in a overflow popup
|
||||
|
|
|
|||
|
|
@ -12,5 +12,6 @@ Icon=com.system76.CosmicAppletBluetooth-symbolic
|
|||
StartupNotify=true
|
||||
NoDisplay=true
|
||||
X-CosmicApplet=true
|
||||
X-CosmicShrinkable=true
|
||||
X-CosmicHoverPopup=Auto
|
||||
X-OverflowPriority=10
|
||||
|
|
|
|||
|
|
@ -204,13 +204,6 @@ impl cosmic::Application for CosmicBluetoothApplet {
|
|||
) => {
|
||||
// my headphones seem to always request this
|
||||
// doesn't seem to be defined in the UX mockups
|
||||
// dbg!(
|
||||
// "request service authorization",
|
||||
// d.name,
|
||||
// bluer::id::Service::try_from(service)
|
||||
// .map(|s| s.to_string())
|
||||
// .unwrap_or_else(|_| "unknown".to_string())
|
||||
// );
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -21,5 +21,6 @@ Icon=com.system76.CosmicAppletInputSources-symbolic
|
|||
StartupNotify=true
|
||||
NoDisplay=true
|
||||
X-CosmicApplet=true
|
||||
X-CosmicShrinkable=true
|
||||
X-CosmicHoverPopup=Auto
|
||||
X-OverflowPriority=10
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use cosmic::{
|
|||
cosmic_config::{self, ConfigSet, CosmicConfigEntry},
|
||||
cosmic_theme::Spacing,
|
||||
iced::{
|
||||
Task,
|
||||
Rectangle, Task,
|
||||
platform_specific::shell::commands::popup::{destroy_popup, get_popup},
|
||||
widget::{column, row},
|
||||
window::Id,
|
||||
|
|
@ -20,11 +20,17 @@ use cosmic::{
|
|||
iced_runtime::{Appearance, core::window},
|
||||
prelude::*,
|
||||
surface, theme,
|
||||
widget::{self, horizontal_space, vertical_space},
|
||||
widget::{
|
||||
self, autosize, horizontal_space,
|
||||
rectangle_tracker::{RectangleTracker, RectangleUpdate, rectangle_tracker_subscription},
|
||||
vertical_space,
|
||||
},
|
||||
};
|
||||
use cosmic_comp_config::CosmicCompConfig;
|
||||
use std::sync::LazyLock;
|
||||
use xkb_data::KeyboardLayout;
|
||||
|
||||
static AUTOSIZE_MAIN_ID: LazyLock<widget::Id> = LazyLock::new(|| widget::Id::new("autosize-main"));
|
||||
pub const ID: &str = "com.system76.CosmicAppletInputSources";
|
||||
|
||||
pub fn run() -> cosmic::iced::Result {
|
||||
|
|
@ -77,6 +83,8 @@ pub struct Window {
|
|||
comp_config_handler: Option<cosmic_config::Config>,
|
||||
layouts: Vec<KeyboardLayout>,
|
||||
active_layouts: Vec<ActiveLayout>,
|
||||
rectangle_tracker: Option<RectangleTracker<u32>>,
|
||||
rectangle: Rectangle,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
@ -87,6 +95,7 @@ pub enum Message {
|
|||
SetActiveLayout(usize),
|
||||
KeyboardSettings,
|
||||
Surface(surface::Action),
|
||||
Rectangle(RectangleUpdate<u32>),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -119,6 +128,8 @@ impl cosmic::Application for Window {
|
|||
popup: None,
|
||||
comp_config: flags.comp_config,
|
||||
active_layouts: Vec::new(),
|
||||
rectangle_tracker: None,
|
||||
rectangle: Rectangle::default(),
|
||||
};
|
||||
(window, Task::none())
|
||||
}
|
||||
|
|
@ -194,6 +205,14 @@ impl cosmic::Application for Window {
|
|||
cosmic::app::Action::Surface(a),
|
||||
));
|
||||
}
|
||||
Message::Rectangle(u) => match u {
|
||||
RectangleUpdate::Rectangle(r) => {
|
||||
self.rectangle = r.1;
|
||||
}
|
||||
RectangleUpdate::Init(tracker) => {
|
||||
self.rectangle_tracker = Some(tracker);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Task::none()
|
||||
|
|
@ -205,31 +224,18 @@ impl cosmic::Application for Window {
|
|||
.first()
|
||||
.map_or("", |l| l.layout.as_str()),
|
||||
);
|
||||
|
||||
cosmic::widget::button::custom(
|
||||
row!(
|
||||
column!(
|
||||
input_source_text,
|
||||
horizontal_space().width(Length::Fixed(
|
||||
(self.core.applet.suggested_size(true).0
|
||||
+ 2 * self.core.applet.suggested_padding(true))
|
||||
as f32
|
||||
))
|
||||
)
|
||||
.width(Length::Shrink)
|
||||
.height(Length::Shrink)
|
||||
.align_x(Alignment::Center),
|
||||
vertical_space().height(Length::Fixed(
|
||||
(self.core.applet.suggested_size(true).1
|
||||
+ 2 * self.core.applet.suggested_padding(true)) as f32
|
||||
))
|
||||
)
|
||||
.align_y(Alignment::Center)
|
||||
.width(Length::Shrink)
|
||||
.height(Length::Shrink),
|
||||
let button = self
|
||||
.core
|
||||
.applet
|
||||
.text_button(input_source_text, Message::TogglePopup);
|
||||
autosize::autosize(
|
||||
if let Some(tracker) = self.rectangle_tracker.as_ref() {
|
||||
Element::from(tracker.container(0, button).ignore_bounds(true))
|
||||
} else {
|
||||
button.into()
|
||||
},
|
||||
AUTOSIZE_MAIN_ID.clone(),
|
||||
)
|
||||
.on_press_down(Message::TogglePopup)
|
||||
.class(cosmic::theme::Button::AppletIcon)
|
||||
.into()
|
||||
}
|
||||
|
||||
|
|
@ -263,18 +269,21 @@ impl cosmic::Application for Window {
|
|||
}
|
||||
|
||||
fn subscription(&self) -> Subscription<Self::Message> {
|
||||
self.core
|
||||
.watch_config("com.system76.CosmicComp")
|
||||
.map(|update| {
|
||||
if !update.errors.is_empty() {
|
||||
tracing::error!(
|
||||
"errors loading config {:?}: {:?}",
|
||||
update.keys,
|
||||
update.errors
|
||||
);
|
||||
}
|
||||
Message::CompConfig(Box::new(update.config))
|
||||
})
|
||||
Subscription::batch(vec![
|
||||
rectangle_tracker_subscription(0).map(|e| Message::Rectangle(e.1)),
|
||||
self.core
|
||||
.watch_config("com.system76.CosmicComp")
|
||||
.map(|update| {
|
||||
if !update.errors.is_empty() {
|
||||
tracing::error!(
|
||||
"errors loading config {:?}: {:?}",
|
||||
update.keys,
|
||||
update.errors
|
||||
);
|
||||
}
|
||||
Message::CompConfig(Box::new(update.config))
|
||||
}),
|
||||
])
|
||||
}
|
||||
|
||||
fn style(&self) -> Option<Appearance> {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ impl Minimize {
|
|||
return index;
|
||||
};
|
||||
let button_total_size = self.core.applet.suggested_size(true).0
|
||||
+ self.core.applet.suggested_padding(true) * 2
|
||||
+ self.core.applet.suggested_padding(true).0 * 2
|
||||
+ 4;
|
||||
let btn_count = max_major_axis_len / button_total_size as u32;
|
||||
if btn_count >= self.apps.len() as u32 {
|
||||
|
|
@ -143,8 +143,11 @@ impl cosmic::Application for Minimize {
|
|||
};
|
||||
|
||||
app.update_desktop_entries();
|
||||
|
||||
(app, Task::none())
|
||||
let t = iced::window::minimize::<cosmic::Action<Message>>(
|
||||
app.core.main_window_id().unwrap(),
|
||||
true,
|
||||
);
|
||||
(app, t)
|
||||
}
|
||||
|
||||
fn core(&self) -> &cosmic::app::Core {
|
||||
|
|
@ -205,11 +208,22 @@ impl cosmic::Application for Minimize {
|
|||
}
|
||||
|
||||
self.apps = apps;
|
||||
|
||||
return iced::window::maximize(self.core.main_window_id().unwrap(), true);
|
||||
}
|
||||
ToplevelUpdate::Remove(handle) => {
|
||||
let prev_was_empty = self.apps.is_empty();
|
||||
self.apps
|
||||
.retain(|a| a.toplevel_info.foreign_toplevel != handle);
|
||||
self.apps.shrink_to_fit();
|
||||
let changed = prev_was_empty != self.apps.is_empty();
|
||||
if self.apps.is_empty() && changed {
|
||||
// hide the window
|
||||
return iced::window::minimize(
|
||||
self.core.main_window_id().unwrap(),
|
||||
true,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
WaylandUpdate::Image(handle, img) => {
|
||||
|
|
@ -241,7 +255,7 @@ impl cosmic::Application for Minimize {
|
|||
|
||||
self.overflow_popup = Some(new_id);
|
||||
let icon_size = self.core.applet.suggested_size(true).0 as u32
|
||||
+ 2 * self.core.applet.suggested_padding(true) as u32;
|
||||
+ 2 * self.core.applet.suggested_padding(true).1 as u32;
|
||||
let spacing = self.core.system_theme().cosmic().space_xxs() as u32;
|
||||
let major_axis_len = (icon_size + spacing) * (pos.saturating_sub(1) as u32);
|
||||
let rectangle = match self.core.applet.anchor {
|
||||
|
|
@ -293,9 +307,16 @@ impl cosmic::Application for Minimize {
|
|||
}
|
||||
});
|
||||
let (width, _) = self.core.applet.suggested_size(false);
|
||||
let padding = self.core.applet.suggested_padding(false);
|
||||
let (major_padding, cross_padding) = self.core.applet.suggested_padding(false);
|
||||
let padding = if matches!(
|
||||
self.core.applet.anchor,
|
||||
PanelAnchor::Top | PanelAnchor::Bottom
|
||||
) {
|
||||
(major_padding, cross_padding)
|
||||
} else {
|
||||
(cross_padding, major_padding)
|
||||
};
|
||||
let theme = self.core.system_theme().cosmic();
|
||||
let space_xxs = theme.space_xxs();
|
||||
let icon_buttons = self.apps[..max_icon_count].iter().map(|app| {
|
||||
self.core
|
||||
.applet
|
||||
|
|
@ -332,6 +353,7 @@ impl cosmic::Application for Minimize {
|
|||
None
|
||||
};
|
||||
|
||||
let spacing = self.core.applet.spacing;
|
||||
// TODO optional dividers on ends if detects app list neighbor
|
||||
// not sure the best way to tell if there is an adjacent app-list
|
||||
let icon_buttons = icon_buttons.chain(overflow_btn);
|
||||
|
|
@ -343,14 +365,14 @@ impl cosmic::Application for Minimize {
|
|||
.align_y(cosmic::iced_core::Alignment::Center)
|
||||
.height(Length::Shrink)
|
||||
.width(Length::Shrink)
|
||||
.spacing(space_xxs)
|
||||
.spacing(spacing as f32)
|
||||
.into()
|
||||
} else {
|
||||
Column::with_children(icon_buttons)
|
||||
.align_x(cosmic::iced_core::Alignment::Center)
|
||||
.height(Length::Shrink)
|
||||
.width(Length::Shrink)
|
||||
.spacing(space_xxs)
|
||||
.spacing(spacing as f32)
|
||||
.into()
|
||||
};
|
||||
|
||||
|
|
@ -388,7 +410,15 @@ impl cosmic::Application for Minimize {
|
|||
}
|
||||
});
|
||||
let (width, _) = self.core.applet.suggested_size(false);
|
||||
let padding = self.core.applet.suggested_padding(false);
|
||||
let (major_padding, cross_padding) = self.core.applet.suggested_padding(false);
|
||||
let padding = if matches!(
|
||||
self.core.applet.anchor,
|
||||
PanelAnchor::Top | PanelAnchor::Bottom
|
||||
) {
|
||||
(major_padding, cross_padding)
|
||||
} else {
|
||||
(cross_padding, major_padding)
|
||||
};
|
||||
let theme = self.core.system_theme().cosmic();
|
||||
let space_xxs = theme.space_xxs();
|
||||
let icon_buttons = self.apps[max_icon_count..].iter().map(|app| {
|
||||
|
|
@ -429,15 +459,13 @@ impl cosmic::Application for Minimize {
|
|||
Row::with_children(icon_buttons)
|
||||
.align_y(cosmic::iced_core::Alignment::Center)
|
||||
.height(Length::Shrink)
|
||||
.width(Length::Shrink)
|
||||
.spacing(space_xxs),
|
||||
.width(Length::Shrink),
|
||||
)
|
||||
} else {
|
||||
Column::with_children(icon_buttons)
|
||||
.align_x(cosmic::iced_core::Alignment::Center)
|
||||
.height(Length::Shrink)
|
||||
.width(Length::Shrink)
|
||||
.spacing(space_xxs)
|
||||
.into()
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use cctk::{
|
|||
},
|
||||
toplevel_info::{ToplevelInfoHandler, ToplevelInfoState},
|
||||
toplevel_management::{ToplevelManagerHandler, ToplevelManagerState},
|
||||
wayland_client::{self, WEnum, protocol::wl_seat::WlSeat},
|
||||
wayland_client::{self, WEnum, delegate_noop, protocol::wl_seat::WlSeat},
|
||||
};
|
||||
use cosmic::{
|
||||
cctk::{
|
||||
|
|
@ -557,21 +557,10 @@ impl Dispatch<wl_shm_pool::WlShmPool, ()> for AppData {
|
|||
}
|
||||
}
|
||||
|
||||
impl Dispatch<wl_buffer::WlBuffer, ()> for AppData {
|
||||
fn event(
|
||||
_app_data: &mut Self,
|
||||
_buffer: &wl_buffer::WlBuffer,
|
||||
_event: wl_buffer::Event,
|
||||
(): &(),
|
||||
_: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
sctk::delegate_shm!(AppData);
|
||||
sctk::delegate_seat!(AppData);
|
||||
sctk::delegate_registry!(AppData);
|
||||
cctk::delegate_toplevel_info!(AppData);
|
||||
cctk::delegate_toplevel_manager!(AppData);
|
||||
cctk::delegate_screencopy!(AppData);
|
||||
delegate_noop!(AppData: ignore wl_buffer::WlBuffer);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ where
|
|||
icon: &fde::IconSource,
|
||||
size: f32,
|
||||
on_press: Msg,
|
||||
padding: u16,
|
||||
padding: (u16, u16),
|
||||
) -> Self {
|
||||
let border = 1.0;
|
||||
Self {
|
||||
|
|
@ -63,8 +63,9 @@ where
|
|||
.height(Length::Shrink)
|
||||
.width(Length::Shrink),
|
||||
)
|
||||
.center(Length::Fixed(size + padding as f32 * 2.0))
|
||||
.padding(padding),
|
||||
.center_x(Length::Fixed(size + padding.0 as f32 * 2.0))
|
||||
.center_y(Length::Fixed(size + padding.1 as f32 * 2.0))
|
||||
.padding([padding.0 as f32, padding.1 as f32]),
|
||||
)
|
||||
.on_press(on_press)
|
||||
.width(Length::Shrink)
|
||||
|
|
|
|||
|
|
@ -21,5 +21,6 @@ Icon=com.system76.CosmicAppletNetwork-symbolic
|
|||
StartupNotify=true
|
||||
NoDisplay=true
|
||||
X-CosmicApplet=true
|
||||
X-CosmicShrinkable=true
|
||||
X-CosmicHoverPopup=Auto
|
||||
X-OverflowPriority=10
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ Keywords=COSMIC;Iced;
|
|||
Icon=com.system76.CosmicAppletNotifications-symbolic
|
||||
NoDisplay=true
|
||||
X-CosmicApplet=true
|
||||
X-CosmicShrinkable=true
|
||||
X-NotificationsApplet=true
|
||||
X-CosmicHoverPopup=Auto
|
||||
X-OverflowPriority=10
|
||||
|
|
|
|||
|
|
@ -20,5 +20,6 @@ Icon=com.system76.CosmicAppletPower-symbolic
|
|||
StartupNotify=true
|
||||
NoDisplay=true
|
||||
X-CosmicApplet=true
|
||||
X-CosmicShrinkable=true
|
||||
X-CosmicHoverPopup=Auto
|
||||
X-OverflowPriority=10
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ impl App {
|
|||
|
||||
fn resize_window(&self) -> app::Task<Msg> {
|
||||
let icon_size = self.core.applet.suggested_size(true).0 as u32
|
||||
+ self.core.applet.suggested_padding(true) as u32 * 2;
|
||||
+ self.core.applet.suggested_padding(true).1 as u32 * 2;
|
||||
let n = self.menus.len() as u32;
|
||||
window::resize(
|
||||
self.core.main_window_id().unwrap(),
|
||||
|
|
@ -73,8 +73,8 @@ impl App {
|
|||
}
|
||||
})?;
|
||||
|
||||
let button_total_size =
|
||||
self.core.applet.suggested_size(true).0 + self.core.applet.suggested_padding(true) * 2;
|
||||
let button_total_size = self.core.applet.suggested_size(true).0
|
||||
+ self.core.applet.suggested_padding(true).1 * 2;
|
||||
|
||||
let menu_count = self.menus.len();
|
||||
|
||||
|
|
@ -250,11 +250,11 @@ impl cosmic::Application for App {
|
|||
PanelAnchor::Left | PanelAnchor::Right
|
||||
) {
|
||||
let suggested_size = self.core.applet.suggested_size(false).1
|
||||
+ 2 * self.core.applet.suggested_padding(false);
|
||||
+ 2 * self.core.applet.suggested_padding(false).1;
|
||||
popup_settings.positioner.anchor_rect.y = i as i32 * suggested_size as i32;
|
||||
} else {
|
||||
let suggested_size = self.core.applet.suggested_size(false).0
|
||||
+ 2 * self.core.applet.suggested_padding(false);
|
||||
+ 2 * self.core.applet.suggested_padding(false).1;
|
||||
popup_settings.positioner.anchor_rect.x = i as i32 * suggested_size as i32;
|
||||
}
|
||||
cmds.push(get_popup(popup_settings));
|
||||
|
|
@ -332,11 +332,11 @@ impl cosmic::Application for App {
|
|||
PanelAnchor::Left | PanelAnchor::Right
|
||||
) {
|
||||
let suggested_size = self.core.applet.suggested_size(false).1
|
||||
+ 2 * self.core.applet.suggested_padding(false);
|
||||
+ 2 * self.core.applet.suggested_padding(false).1;
|
||||
popup_settings.positioner.anchor_rect.y = i as i32 * suggested_size as i32;
|
||||
} else {
|
||||
let suggested_size = self.core.applet.suggested_size(false).0
|
||||
+ 2 * self.core.applet.suggested_padding(false);
|
||||
+ 2 * self.core.applet.suggested_padding(false).1;
|
||||
popup_settings.positioner.anchor_rect.x = i as i32 * suggested_size as i32;
|
||||
}
|
||||
cmds.push(get_popup(popup_settings));
|
||||
|
|
@ -369,12 +369,12 @@ impl cosmic::Application for App {
|
|||
PanelAnchor::Left | PanelAnchor::Right
|
||||
) {
|
||||
let suggested_size = self.core.applet.suggested_size(false).1
|
||||
+ 2 * self.core.applet.suggested_padding(false);
|
||||
+ 2 * self.core.applet.suggested_padding(false).1;
|
||||
popup_settings.positioner.anchor_rect.y =
|
||||
overflow_index as i32 * suggested_size as i32;
|
||||
} else {
|
||||
let suggested_size = self.core.applet.suggested_size(false).0
|
||||
+ 2 * self.core.applet.suggested_padding(false);
|
||||
+ 2 * self.core.applet.suggested_padding(false).1;
|
||||
popup_settings.positioner.anchor_rect.x =
|
||||
overflow_index as i32 * suggested_size as i32;
|
||||
}
|
||||
|
|
@ -418,11 +418,11 @@ impl cosmic::Application for App {
|
|||
PanelAnchor::Left | PanelAnchor::Right
|
||||
) {
|
||||
let suggested_size = self.core.applet.suggested_size(false).1
|
||||
+ 2 * self.core.applet.suggested_padding(false);
|
||||
+ 2 * self.core.applet.suggested_padding(false).1;
|
||||
popup_settings.positioner.anchor_rect.y = i as i32 * suggested_size as i32;
|
||||
} else {
|
||||
let suggested_size = self.core.applet.suggested_size(false).0
|
||||
+ 2 * self.core.applet.suggested_padding(false);
|
||||
+ 2 * self.core.applet.suggested_padding(false).1;
|
||||
popup_settings.positioner.anchor_rect.x = i as i32 * suggested_size as i32;
|
||||
}
|
||||
cmds.push(get_popup(popup_settings));
|
||||
|
|
|
|||
|
|
@ -21,5 +21,6 @@ Icon=com.system76.CosmicAppletTiling-symbolic
|
|||
StartupNotify=true
|
||||
NoDisplay=true
|
||||
X-CosmicApplet=true
|
||||
X-CosmicShrinkable=true
|
||||
X-HostWaylandDisplay=true
|
||||
X-CosmicHoverPopup=Auto
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ Keywords=COSMIC;Iced;
|
|||
Icon=com.system76.CosmicAppletTime-symbolic
|
||||
NoDisplay=true
|
||||
X-CosmicApplet=true
|
||||
X-CosmicShrinkable=true
|
||||
X-HostWaylandDisplay=true
|
||||
X-CosmicHoverPopup=Auto
|
||||
# No shrink priority, as this applet is always visible when configured
|
||||
|
|
|
|||
|
|
@ -226,7 +226,8 @@ impl Window {
|
|||
date_time_col,
|
||||
horizontal_space().width(Length::Fixed(
|
||||
(self.core.applet.suggested_size(true).0
|
||||
+ 2 * self.core.applet.suggested_padding(true)) as f32
|
||||
+ 2 * self.core.applet.suggested_padding(true).1)
|
||||
as f32
|
||||
))
|
||||
)
|
||||
.align_x(Alignment::Center),
|
||||
|
|
@ -282,7 +283,8 @@ impl Window {
|
|||
self.core.applet.text(formatted_date),
|
||||
container(vertical_space().height(Length::Fixed(
|
||||
(self.core.applet.suggested_size(true).1
|
||||
+ 2 * self.core.applet.suggested_padding(true)) as f32
|
||||
+ 2 * self.core.applet.suggested_padding(true).1)
|
||||
as f32
|
||||
)))
|
||||
)
|
||||
.align_y(Alignment::Center),
|
||||
|
|
@ -662,9 +664,9 @@ impl cosmic::Application for Window {
|
|||
self.vertical_layout()
|
||||
})
|
||||
.padding(if horizontal {
|
||||
[0, self.core.applet.suggested_padding(true)]
|
||||
[0, self.core.applet.suggested_padding(true).0]
|
||||
} else {
|
||||
[self.core.applet.suggested_padding(true), 0]
|
||||
[self.core.applet.suggested_padding(true).0, 0]
|
||||
})
|
||||
.on_press_down(Message::TogglePopup)
|
||||
.class(cosmic::theme::Button::AppletIcon);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ impl IcedWorkspacesApplet {
|
|||
return index;
|
||||
};
|
||||
let button_total_size = self.core.applet.suggested_size(true).0
|
||||
+ self.core.applet.suggested_padding(true) * 2
|
||||
+ self.core.applet.suggested_padding(true).1 * 2
|
||||
+ 4;
|
||||
let btn_count = max_major_axis_len / button_total_size as u32;
|
||||
if btn_count >= self.workspaces.len() as u32 {
|
||||
|
|
@ -219,8 +219,8 @@ impl cosmic::Application for IcedWorkspacesApplet {
|
|||
self.core.applet.anchor,
|
||||
PanelAnchor::Top | PanelAnchor::Bottom
|
||||
);
|
||||
let suggested_total =
|
||||
self.core.applet.suggested_size(true).0 + self.core.applet.suggested_padding(true) * 2;
|
||||
let suggested_total = self.core.applet.suggested_size(true).0
|
||||
+ self.core.applet.suggested_padding(true).1 * 2;
|
||||
let suggested_window_size = self.core.applet.suggested_window_size();
|
||||
let popup_index = self.popup_index().unwrap_or(self.workspaces.len());
|
||||
|
||||
|
|
@ -245,9 +245,9 @@ impl cosmic::Application for IcedWorkspacesApplet {
|
|||
.align_y(Alignment::Center),
|
||||
)
|
||||
.padding(if horizontal {
|
||||
[0, self.core.applet.suggested_padding(true)]
|
||||
[0, self.core.applet.suggested_padding(true).1]
|
||||
} else {
|
||||
[self.core.applet.suggested_padding(true), 0]
|
||||
[self.core.applet.suggested_padding(true).1, 0]
|
||||
})
|
||||
.on_press(
|
||||
if w.state.contains(ext_workspace_handle_v1::State::Active) {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,47 @@ enum Msg {
|
|||
Surface(surface::Action),
|
||||
}
|
||||
|
||||
impl Button {
|
||||
pub fn icon_button_from_handle<'a, Message: Clone + 'static>(
|
||||
&self,
|
||||
icon: cosmic::widget::icon::Handle,
|
||||
) -> cosmic::widget::Button<'a, Message> {
|
||||
let theme = cosmic::theme::active();
|
||||
let theme = theme.cosmic();
|
||||
|
||||
let suggested = self.core.applet.suggested_size(icon.symbolic);
|
||||
let (major_padding, applet_padding_minor_axis) =
|
||||
self.core.applet.suggested_padding(icon.symbolic);
|
||||
let (horizontal_padding, vertical_padding) = if self.core.applet.is_horizontal() {
|
||||
(major_padding, applet_padding_minor_axis)
|
||||
} else {
|
||||
(applet_padding_minor_axis, major_padding)
|
||||
};
|
||||
let symbolic = icon.symbolic;
|
||||
|
||||
cosmic::widget::button::custom(
|
||||
cosmic::widget::layer_container(
|
||||
cosmic::widget::icon(icon)
|
||||
.class(if symbolic {
|
||||
cosmic::theme::Svg::Custom(std::rc::Rc::new(|theme| {
|
||||
cosmic::iced_widget::svg::Style {
|
||||
color: Some(theme.cosmic().background.on.into()),
|
||||
}
|
||||
}))
|
||||
} else {
|
||||
cosmic::theme::Svg::default()
|
||||
})
|
||||
.width(Length::Fixed(suggested.0 as f32))
|
||||
.height(Length::Fixed(suggested.1 as f32)),
|
||||
)
|
||||
.center(Length::Fill),
|
||||
)
|
||||
.width(Length::Fixed((suggested.0 + 2 * horizontal_padding) as f32))
|
||||
.height(Length::Fixed((suggested.1 + 2 * vertical_padding) as f32))
|
||||
.class(cosmic::theme::Button::AppletIcon)
|
||||
}
|
||||
}
|
||||
|
||||
impl cosmic::Application for Button {
|
||||
type Message = Msg;
|
||||
type Executor = cosmic::SingleThreadExecutor;
|
||||
|
|
@ -124,13 +165,11 @@ impl cosmic::Application for Button {
|
|||
{
|
||||
cosmic::Element::from(
|
||||
self.core.applet.applet_tooltip::<Msg>(
|
||||
self.core
|
||||
.applet
|
||||
.icon_button_from_handle(
|
||||
cosmic::widget::icon::from_name(self.desktop.icon.clone().unwrap())
|
||||
.handle(),
|
||||
)
|
||||
.on_press_down(Msg::Press),
|
||||
self.icon_button_from_handle(
|
||||
cosmic::widget::icon::from_name(self.desktop.icon.clone().unwrap())
|
||||
.handle(),
|
||||
)
|
||||
.on_press_down(Msg::Press),
|
||||
self.desktop.name.clone(),
|
||||
false,
|
||||
Msg::Surface,
|
||||
|
|
@ -142,13 +181,13 @@ impl cosmic::Application for Button {
|
|||
self.core.applet.text(&self.desktop.name),
|
||||
vertical_space().height(Length::Fixed(
|
||||
(self.core.applet.suggested_size(true).1
|
||||
+ 2 * self.core.applet.suggested_padding(true))
|
||||
+ 2 * self.core.applet.suggested_padding(true).1)
|
||||
as f32
|
||||
))
|
||||
)
|
||||
.align_y(iced::Alignment::Center);
|
||||
cosmic::widget::button::custom(content)
|
||||
.padding([0, self.core.applet.suggested_padding(true)])
|
||||
.padding([0, self.core.applet.suggested_padding(true).0])
|
||||
.class(cosmic::theme::Button::AppletIcon)
|
||||
.on_press_down(Msg::Press)
|
||||
.into()
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
[toolchain]
|
||||
channel = "1.85.1"
|
||||
channel = "1.90.0"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue