update libcosmic

This commit is contained in:
Ashley Wulber 2023-04-05 20:40:22 -04:00 • committed by Ashley Wulber
parent 2c74a551c7
commit 903a5589a3
19 changed files with 2261 additions and 1877 deletions

1452
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,6 @@ use cosmic::iced;
use cosmic::iced::wayland::actions::window::SctkWindowSettings;
use cosmic::iced::wayland::popup::destroy_popup;
use cosmic::iced::wayland::popup::get_popup;
use cosmic::iced::wayland::SurfaceIdWrapper;
use cosmic::iced::widget::mouse_listener;
use cosmic::iced::widget::{column, row};
use cosmic::iced::Settings;
@ -39,7 +38,6 @@ use cosmic::{Element, Theme};
use cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1;
use freedesktop_desktop_entry::DesktopEntry;
use iced::widget::container;
use iced::widget::horizontal_space;
use iced::Alignment;
use iced::Background;
use iced::Length;
@ -380,10 +378,78 @@ impl Application for CosmicAppList {
Command::none()
}
fn view(&self, id: SurfaceIdWrapper) -> Element<Message> {
match id {
SurfaceIdWrapper::LayerSurface(_) => unimplemented!(),
SurfaceIdWrapper::Window(_) => {
fn view(&self, id: window::Id) -> Element<Message> {
if let Some(Toplevel {
toplevels,
desktop_info,
..
}) = self.toplevel_list.iter().find(|t| t.popup == Some(id))
{
let is_favorite = self.config.favorites.contains(&desktop_info.id)
|| self.config.favorites.contains(&desktop_info.name);
let mut content = column![
iced::widget::text(&desktop_info.name).horizontal_alignment(Horizontal::Center),
cosmic::widget::button(Button::Text)
.custom(vec![iced::widget::text(fl!("new-window")).into()])
.on_press(Message::Exec(desktop_info.exec.clone())),
]
.padding(8)
.spacing(4)
.align_items(Alignment::Center);
if !toplevels.is_empty() {
let mut list_col = column![];
for (handle, info) in toplevels {
let title = if info.title.len() > 20 {
format!("{:.24}...", &info.title)
} else {
info.title.clone()
};
list_col = list_col.push(
cosmic::widget::button(Button::Text)
.custom(vec![iced::widget::text(title).into()])
.on_press(Message::Activate(handle.clone())),
);
}
content = content.push(divider::horizontal::light());
content = content.push(list_col);
content = content.push(divider::horizontal::light());
}
content = content.push(if is_favorite {
cosmic::widget::button(Button::Text)
.custom(vec![iced::widget::text(fl!("unfavorite")).into()])
.on_press(Message::UnFavorite(desktop_info.id.clone()))
} else {
cosmic::widget::button(Button::Text)
.custom(vec![iced::widget::text(fl!("favorite")).into()])
.on_press(Message::Favorite(desktop_info.id.clone()))
});
content = match toplevels.len() {
0 => content,
1 => content.push(
cosmic::widget::button(Button::Text)
.custom(vec![iced::widget::text(fl!("quit")).into()])
.on_press(Message::Quit(desktop_info.id.clone())),
),
_ => content.push(
cosmic::widget::button(Button::Text)
.custom(vec![iced::widget::text(&fl!("quit-all")).into()])
.on_press(Message::Quit(desktop_info.id.clone())),
),
};
// return Container::new(Container::new(content.width(Length::Shrink).height(Length::Shrink)).style(
// cosmic::Container::Custom(|theme| container::Appearance {
// text_color: Some(theme.cosmic().on_bg_color().into()),
// background: Some(theme.extended_palette().background.base.color.into()),
// border_radius: 12.0,
// border_width: 0.0,
// border_color: Color::TRANSPARENT,
// }),
// )).into();
return self.applet_helper.popup_container(content).into();
}
let (favorites, running) = self.toplevel_list.iter().fold(
(Vec::new(), Vec::new()),
|(mut favorites, mut running),
@ -457,9 +523,8 @@ impl Application for CosmicAppList {
}
// TODO tooltip on hover
let icon_button = mouse_listener(
icon_button.width(Length::Shrink).height(Length::Shrink),
)
let icon_button =
mouse_listener(icon_button.width(Length::Shrink).height(Length::Shrink))
.on_right_release(Message::Popup(desktop_info.id.clone()));
let icon_button = if let Some(tracker) = self.rectangle_tracker.as_ref() {
tracker.container(*id, icon_button).into()
@ -511,82 +576,6 @@ impl Application for CosmicAppList {
content.into()
}
}
SurfaceIdWrapper::Popup(p) => {
if let Some(Toplevel {
toplevels,
desktop_info,
..
}) = self.toplevel_list.iter().find(|t| t.popup == Some(p))
{
let is_favorite = self.config.favorites.contains(&desktop_info.id)
|| self.config.favorites.contains(&desktop_info.name);
let mut content = column![
iced::widget::text(&desktop_info.name)
.horizontal_alignment(Horizontal::Center),
cosmic::widget::button(Button::Text)
.custom(vec![iced::widget::text(fl!("new-window")).into()])
.on_press(Message::Exec(desktop_info.exec.clone())),
]
.padding(8)
.spacing(4)
.align_items(Alignment::Center);
if !toplevels.is_empty() {
let mut list_col = column![];
for (handle, info) in toplevels {
let title = if info.title.len() > 20 {
format!("{:.24}...", &info.title)
} else {
info.title.clone()
};
list_col = list_col.push(
cosmic::widget::button(Button::Text)
.custom(vec![iced::widget::text(title).into()])
.on_press(Message::Activate(handle.clone())),
);
}
content = content.push(divider::horizontal::light());
content = content.push(list_col);
content = content.push(divider::horizontal::light());
}
content = content.push(if is_favorite {
cosmic::widget::button(Button::Text)
.custom(vec![iced::widget::text(fl!("unfavorite")).into()])
.on_press(Message::UnFavorite(desktop_info.id.clone()))
} else {
cosmic::widget::button(Button::Text)
.custom(vec![iced::widget::text(fl!("favorite")).into()])
.on_press(Message::Favorite(desktop_info.id.clone()))
});
content = match toplevels.len() {
0 => content,
1 => content.push(
cosmic::widget::button(Button::Text)
.custom(vec![iced::widget::text(fl!("quit")).into()])
.on_press(Message::Quit(desktop_info.id.clone())),
),
_ => content.push(
cosmic::widget::button(Button::Text)
.custom(vec![iced::widget::text(&fl!("quit-all")).into()])
.on_press(Message::Quit(desktop_info.id.clone())),
),
};
// return Container::new(Container::new(content.width(Length::Shrink).height(Length::Shrink)).style(
// cosmic::Container::Custom(|theme| container::Appearance {
// text_color: Some(theme.cosmic().on_bg_color().into()),
// background: Some(theme.extended_palette().background.base.color.into()),
// border_radius: 12.0,
// border_width: 0.0,
// border_color: Color::TRANSPARENT,
// }),
// )).into();
return self.applet_helper.popup_container(content).into();
}
horizontal_space(Length::Units(1)).into()
}
}
}
fn subscription(&self) -> Subscription<Message> {
Subscription::batch(vec![
@ -614,7 +603,7 @@ impl Application for CosmicAppList {
self.theme
}
fn close_requested(&self, _id: SurfaceIdWrapper) -> Self::Message {
fn close_requested(&self, _id: window::Id) -> Self::Message {
Message::Ignore
}

View file

@ -11,6 +11,5 @@ libpulse-binding = "2.26.0"
libpulse-glib-binding = "2.25.0"
tokio = { version = "1.20.1", features=["full"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["tokio", "wayland", "applet"] }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "69bffe5" }
log = "0.4.14"
pretty_env_logger = "0.4.0"

View file

@ -1,4 +1,3 @@
use cosmic::iced::wayland::SurfaceIdWrapper;
use cosmic::iced::widget;
use cosmic::iced_native::alignment::Horizontal;
use cosmic::iced_native::layout::Limits;
@ -97,7 +96,7 @@ impl Application for Audio {
self.theme
}
fn close_requested(&self, _id: SurfaceIdWrapper) -> Self::Message {
fn close_requested(&self, _id: window::Id) -> Self::Message {
Message::Ignore
}
@ -268,15 +267,13 @@ impl Application for Audio {
pulse::connect().map(Message::Pulse)
}
fn view(&self, id: SurfaceIdWrapper) -> Element<Message> {
match id {
SurfaceIdWrapper::LayerSurface(_) => unimplemented!(),
SurfaceIdWrapper::Window(_) => self
.applet_helper
fn view(&self, id: window::Id) -> Element<Message> {
if id == window::Id::new(0) {
self.applet_helper
.icon_button(&self.icon_name)
.on_press(Message::TogglePopup)
.into(),
SurfaceIdWrapper::Popup(_) => {
.into()
} else {
let audio_disabled = matches!(self.pulse_state, PulseState::Disconnected(_));
let out_f64 = VolumeLinear::from(
self.current_output
@ -398,7 +395,6 @@ impl Application for Audio {
}
}
}
}
fn revealer(
open: bool,

View file

@ -6,7 +6,6 @@ edition = "2021"
[dependencies]
once_cell = "1.16.0"
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["tokio", "wayland", "applet"] }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "69bffe5" }
futures = "0.3"
zbus = { version = "3.5", default-features = false, features = ["tokio"] }
log = "0.4"

View file

@ -13,7 +13,6 @@ use crate::upower_kbdbacklight::{
use cosmic::applet::{CosmicAppletHelper, APPLET_BUTTON_THEME};
use cosmic::iced::alignment::Horizontal;
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced::wayland::SurfaceIdWrapper;
use cosmic::iced::{
widget::{column, container, row, slider, text},
window, Alignment, Application, Command, Length, Subscription,
@ -213,15 +212,13 @@ impl Application for CosmicBatteryApplet {
}
Command::none()
}
fn view(&self, id: SurfaceIdWrapper) -> Element<Message> {
match id {
SurfaceIdWrapper::LayerSurface(_) => unimplemented!(),
SurfaceIdWrapper::Window(_) => self
.applet_helper
fn view(&self, id: window::Id) -> Element<Message> {
if id == window::Id::new(0) {
self.applet_helper
.icon_button(&self.icon_name)
.on_press(Message::TogglePopup)
.into(),
SurfaceIdWrapper::Popup(_) => {
.into()
} else {
let name = text(fl!("battery")).size(18);
let description = text(
if "battery-full-charging-symbolic" == self.icon_name
@ -358,9 +355,7 @@ impl Application for CosmicBatteryApplet {
.width(Length::Fill)
.padding([0, 12]),
button(APPLET_BUTTON_THEME)
.custom(vec![text(fl!("power-settings"))
.width(Length::Fill)
.into()])
.custom(vec![text(fl!("power-settings")).width(Length::Fill).into()])
.on_press(Message::OpenBatterySettings)
.width(Length::Fill)
.padding([8, 24])
@ -371,7 +366,6 @@ impl Application for CosmicBatteryApplet {
.into()
}
}
}
fn subscription(&self) -> Subscription<Message> {
Subscription::batch(vec![
@ -406,7 +400,7 @@ impl Application for CosmicBatteryApplet {
self.theme
}
fn close_requested(&self, _id: SurfaceIdWrapper) -> Self::Message {
fn close_requested(&self, _id: window::Id) -> Message {
Message::Ignore
}

View file

@ -9,7 +9,6 @@ once_cell = "1.16.0"
bluer = { version = "0.15", features = ["bluetoothd", "id"] }
futures-util = "0.3.21"
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet", "tokio"] }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "69bffe5" }
futures = "0.3"
log = "0.4"
pretty_env_logger = "0.4"

View file

@ -6,7 +6,6 @@ use cosmic::{
iced::{
wayland::{
popup::{destroy_popup, get_popup},
SurfaceIdWrapper,
},
widget::{column, container, row, scrollable, text, Column},
Alignment, Application, Color, Command, Length, Subscription,
@ -275,7 +274,7 @@ impl Application for CosmicBluetoothApplet {
}
Command::none()
}
fn view(&self, id: SurfaceIdWrapper) -> Element<Message> {
fn view(&self, id: window::Id) -> Element<Message> {
let button_style = Button::Custom {
active: |t| iced_style::button::Appearance {
border_radius: BorderRadius::from(0.0),
@ -286,14 +285,12 @@ impl Application for CosmicBluetoothApplet {
..t.hovered(&Button::Text)
},
};
match id {
SurfaceIdWrapper::LayerSurface(_) => unimplemented!(),
SurfaceIdWrapper::Window(_) => self
.applet_helper
if id == window::Id::new(0) {
self.applet_helper
.icon_button(&self.icon_name)
.on_press(Message::TogglePopup)
.into(),
SurfaceIdWrapper::Popup(_) => {
.into()
} else {
let mut known_bluetooth = column![];
for dev in self.bluer_state.devices.iter().filter(|d| {
!self
@ -527,7 +524,6 @@ impl Application for CosmicBluetoothApplet {
self.applet_helper.popup_container(content).into()
}
}
}
fn subscription(&self) -> Subscription<Message> {
bluetooth_subscription(0).map(|e| Message::BluetoothEvent(e.1))
@ -537,7 +533,7 @@ impl Application for CosmicBluetoothApplet {
self.theme
}
fn close_requested(&self, _id: SurfaceIdWrapper) -> Self::Message {
fn close_requested(&self, _id: window::Id) -> Self::Message {
Message::Ignore
}

View file

@ -8,7 +8,6 @@ edition = "2021"
[dependencies]
zbus = "3.4"
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["tokio", "wayland", "applet"] }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "69bffe5" }
once_cell = "1"
# Application i18n
i18n-embed = { version = "0.13.4", features = ["fluent-system", "desktop-requester"] }

View file

@ -3,7 +3,6 @@ use crate::fl;
use crate::graphics::{get_current_graphics, set_graphics, Graphics};
use cosmic::applet::CosmicAppletHelper;
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced::wayland::SurfaceIdWrapper;
use cosmic::iced_native::alignment::Horizontal;
use cosmic::iced_native::Alignment;
use cosmic::iced_style::application::{self, Appearance};
@ -121,7 +120,7 @@ impl Application for Window {
Message::CurrentGraphics(match cur_graphics {
Ok(g) => Some(g),
Err(err) => {
dbg!(err);
eprintln!("{err}");
None
}
})
@ -184,10 +183,9 @@ impl Application for Window {
Command::none()
}
fn view(&self, id: SurfaceIdWrapper) -> Element<Message> {
match id {
SurfaceIdWrapper::LayerSurface(_) => unimplemented!(),
SurfaceIdWrapper::Window(_) => match self.applet_helper.anchor {
fn view(&self, id: window::Id) -> Element<Message> {
if id == window::Id::new(0) {
match self.applet_helper.anchor {
PanelAnchor::Left | PanelAnchor::Right => self
.applet_helper
.icon_button("input-gaming-symbolic")
@ -219,8 +217,8 @@ impl Application for Window {
.width(Length::Shrink)
.height(Length::Shrink)
.into(),
},
SurfaceIdWrapper::Popup(_) => {
}
} else {
let content_list = vec![
button(APPLET_BUTTON_THEME)
.custom(vec![row![
@ -260,9 +258,7 @@ impl Application for Window {
.into(),
button(APPLET_BUTTON_THEME)
.custom(vec![row![
column![
text(format!("{} {}", fl!("nvidia"), fl!("graphics"))).size(14),
]
column![text(format!("{} {}", fl!("nvidia"), fl!("graphics"))).size(14),]
.width(Length::Fill),
icon(
match self.graphics_mode {
@ -387,19 +383,19 @@ impl Application for Window {
.into()
}
}
}
fn close_requested(&self, id: SurfaceIdWrapper) -> Self::Message {
match id {
SurfaceIdWrapper::LayerSurface(_) | SurfaceIdWrapper::Window(_) => unimplemented!(),
SurfaceIdWrapper::Popup(id) => Message::PopupClosed(id),
fn close_requested(&self, id: window::Id) -> Self::Message {
if id != window::Id::new(0) {
Message::PopupClosed(id)
} else {
unimplemented!();
}
}
fn style(&self) -> <Self::Theme as application::StyleSheet>::Style {
<Self::Theme as application::StyleSheet>::Style::Custom(|theme| Appearance {
background_color: Color::from_rgba(0.0, 0.0, 0.0, 0.0),
text_color: theme.cosmic().on_bg_color().into(),
text_color: theme.cosmic().background.on.into(),
})
}

View file

@ -10,7 +10,6 @@ cosmic-dbus-networkmanager = { git = "https://github.com/pop-os/dbus-settings-bi
# cosmic-dbus-networkmanager = { path = "../../../dbus-settings-bindings/networkmanager" }
futures-util = "0.3.21"
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet", "tokio"] }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "69bffe5" }
futures = "0.3"
zbus = { version = "3.7", default-features = false }
log = "0.4"

View file

@ -2,10 +2,7 @@ use cosmic::iced_style;
use cosmic::{
applet::CosmicAppletHelper,
iced::{
wayland::{
popup::{destroy_popup, get_popup},
SurfaceIdWrapper,
},
wayland::popup::{destroy_popup, get_popup},
widget::{column, container, row, scrollable, text, text_input, Column},
Alignment, Application, Color, Command, Length, Subscription,
},
@ -34,7 +31,8 @@ use crate::{
pub fn run() -> cosmic::iced::Result {
let helper = CosmicAppletHelper::default();
CosmicNetworkApplet::run(helper.window_settings())
let settings = helper.window_settings();
CosmicNetworkApplet::run(settings)
}
#[derive(Debug)]
@ -338,7 +336,7 @@ impl Application for CosmicNetworkApplet {
}
Command::none()
}
fn view(&self, id: SurfaceIdWrapper) -> Element<Message> {
fn view(&self, id: window::Id) -> Element<Message> {
let button_style = Button::Custom {
active: |t| iced_style::button::Appearance {
border_radius: BorderRadius::from(0.0),
@ -349,14 +347,12 @@ impl Application for CosmicNetworkApplet {
..t.hovered(&Button::Text)
},
};
match id {
SurfaceIdWrapper::LayerSurface(_) => unimplemented!(),
SurfaceIdWrapper::Window(_) => self
.applet_helper
if id == window::Id::new(0) {
self.applet_helper
.icon_button(&self.icon_name)
.on_press(Message::TogglePopup)
.into(),
SurfaceIdWrapper::Popup(_) => {
.into()
} else {
let mut vpn_ethernet_col = column![];
let mut known_wifi = column![];
for conn in &self.nm_state.active_conns {
@ -487,9 +483,7 @@ impl Application for CosmicNetworkApplet {
| DeviceState::NeedAuth => {
btn.on_press(Message::ActivateKnownWifi(known.ssid.clone()))
}
DeviceState::Activated => {
btn.on_press(Message::Disconnect(known.ssid.clone()))
}
DeviceState::Activated => btn.on_press(Message::Disconnect(known.ssid.clone())),
_ => btn,
};
known_wifi = known_wifi.push(row![btn].align_items(Alignment::Center));
@ -693,7 +687,6 @@ impl Application for CosmicNetworkApplet {
self.applet_helper.popup_container(content).into()
}
}
}
fn subscription(&self) -> Subscription<Message> {
network_manager_subscription(0).map(|(_, event)| Message::NetworkManagerEvent(event))
@ -703,7 +696,7 @@ impl Application for CosmicNetworkApplet {
self.theme
}
fn close_requested(&self, _id: SurfaceIdWrapper) -> Self::Message {
fn close_requested(&self, _id: window::Id) -> Self::Message {
Message::Ignore
}

View file

@ -1,7 +1,6 @@
use cosmic::applet::{CosmicAppletHelper, APPLET_BUTTON_THEME};
use cosmic::iced::wayland::{
popup::{destroy_popup, get_popup},
SurfaceIdWrapper,
};
use cosmic::iced::{
widget::{button, column, row, text, Row, Space},
@ -65,7 +64,7 @@ impl Application for Notifications {
self.theme
}
fn close_requested(&self, _id: SurfaceIdWrapper) -> Self::Message {
fn close_requested(&self, _id: window::Id) -> Self::Message {
Message::Ignore
}
@ -112,15 +111,13 @@ impl Application for Notifications {
}
}
fn view(&self, id: SurfaceIdWrapper) -> Element<Message> {
match id {
SurfaceIdWrapper::LayerSurface(_) => unimplemented!(),
SurfaceIdWrapper::Window(_) => self
.applet_helper
fn view(&self, id: window::Id) -> Element<Message> {
if id == window::Id::new(0) {
self.applet_helper
.icon_button(&self.icon_name)
.on_press(Message::TogglePopup)
.into(),
SurfaceIdWrapper::Popup(_) => {
.into()
} else {
let do_not_disturb =
row![
toggler(String::from("Do Not Disturb"), self.do_not_disturb, |b| {
@ -165,7 +162,6 @@ impl Application for Notifications {
}
}
}
}
// todo put into libcosmic doing so will fix the row_button's boarder radius
fn row_button(

View file

@ -10,7 +10,6 @@ libpulse-binding = "2.26.0"
libpulse-glib-binding = "2.25.0"
tokio = { version = "1.20.1", features=["full"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["tokio", "wayland", "applet"] }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "69bffe5" }
nix = "0.26.1"
zbus = "3.7"
logind-zbus = "3.1"

View file

@ -2,7 +2,6 @@ use std::process;
use cosmic::applet::{CosmicAppletHelper, APPLET_BUTTON_THEME};
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced::wayland::SurfaceIdWrapper;
use cosmic::iced_native::layout::Limits;
use cosmic::iced_native::widget::Space;
use cosmic::widget::{button, divider, icon};
@ -80,7 +79,7 @@ impl Application for Power {
self.theme
}
fn close_requested(&self, _id: SurfaceIdWrapper) -> Self::Message {
fn close_requested(&self, _id: window::Id) -> Self::Message {
Message::Ignore
}
@ -139,15 +138,13 @@ impl Application for Power {
}
}
fn view(&self, id: SurfaceIdWrapper) -> Element<Message> {
match id {
SurfaceIdWrapper::LayerSurface(_) => unimplemented!(),
SurfaceIdWrapper::Window(_) => self
.applet_helper
fn view(&self, id: window::Id) -> Element<Message> {
if id == window::Id::new(0) {
self.applet_helper
.icon_button(&self.icon_name)
.on_press(Message::TogglePopup)
.into(),
SurfaceIdWrapper::Popup(_) => {
.into()
} else {
let settings = row_button(vec!["Settings...".into()]).on_press(Message::Settings);
let session = column![
@ -168,11 +165,9 @@ impl Application for Power {
];
let power = row![
power_buttons("system-lock-screen-symbolic", "Suspend")
.on_press(Message::Suspend),
power_buttons("system-lock-screen-symbolic", "Suspend").on_press(Message::Suspend),
power_buttons("system-restart-symbolic", "Restart").on_press(Message::Restart),
power_buttons("system-shutdown-symbolic", "Shutdown")
.on_press(Message::Shutdown),
power_buttons("system-shutdown-symbolic", "Shutdown").on_press(Message::Shutdown),
]
.spacing(24)
.padding([0, 24]);
@ -196,7 +191,6 @@ impl Application for Power {
}
}
}
}
// ### UI Helplers

View file

@ -1,8 +1,5 @@
use cosmic::applet::{cosmic_panel_config::PanelAnchor, CosmicAppletHelper};
use cosmic::iced::wayland::{
popup::{destroy_popup, get_popup},
SurfaceIdWrapper,
};
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced::{
time,
wayland::InitialSurface,
@ -28,9 +25,7 @@ pub fn main() -> cosmic::iced::Result {
s.iced_settings.min_size = Some((1, 1));
s.iced_settings.max_size = None;
s.autosize = true;
s.size_limits = Limits::NONE
.min_height(1)
.min_width(1);
s.size_limits = Limits::NONE.min_height(1).min_width(1);
}
_ => {}
};
@ -98,7 +93,7 @@ impl Application for Time {
self.theme
}
fn close_requested(&self, _id: SurfaceIdWrapper) -> Self::Message {
fn close_requested(&self, _id: window::Id) -> Self::Message {
Message::Ignore
}
@ -198,10 +193,8 @@ impl Application for Time {
}
}
fn view(&self, id: SurfaceIdWrapper) -> Element<Message> {
match id {
SurfaceIdWrapper::LayerSurface(_) => unimplemented!(),
SurfaceIdWrapper::Window(_) => {
fn view(&self, id: window::Id) -> Element<Message> {
if id == window::Id::new(0) {
let button = button(
if matches!(
self.applet_helper.anchor,
@ -242,8 +235,7 @@ impl Application for Time {
} else {
button.into()
}
}
SurfaceIdWrapper::Popup(_) => {
} else {
let content = column![]
.align_items(Alignment::Start)
.spacing(12)
@ -255,4 +247,3 @@ impl Application for Time {
}
}
}
}

View file

@ -4,7 +4,7 @@ use cosmic::applet::CosmicAppletHelper;
use cosmic::iced::alignment::{Horizontal, Vertical};
use cosmic::iced::mouse::{self, ScrollDelta};
use cosmic::iced::wayland::actions::window::SctkWindowSettings;
use cosmic::iced::wayland::{window::resize_window, InitialSurface, SurfaceIdWrapper};
use cosmic::iced::wayland::{window::resize_window, InitialSurface};
use cosmic::iced::widget::{column, container, row, text};
use cosmic::iced::{
subscription, widget::button, window, Application, Command, Event::Mouse, Length, Settings,
@ -131,7 +131,7 @@ impl Application for IcedWorkspacesApplet {
Command::none()
}
fn view(&self, _id: SurfaceIdWrapper) -> Element<Message> {
fn view(&self, _id: window::Id) -> Element<Message> {
if self.workspaces.is_empty() {
return row![].padding(8).into();
}
@ -200,7 +200,7 @@ impl Application for IcedWorkspacesApplet {
self.theme
}
fn close_requested(&self, _id: SurfaceIdWrapper) -> Self::Message {
fn close_requested(&self, _id: window::Id) -> Self::Message {
unimplemented!()
}

View file

@ -97,7 +97,7 @@ pub fn spawn_workspaces(tx: mpsc::Sender<WorkspaceList>) -> SyncSender<Workspace
.workspace_groups()
.iter()
.find_map(|g| {
if g.output != state.expected_output {
if !g.outputs.iter().any(|o| Some(o) == state.expected_output.as_ref()) {
return None;
}
g.workspaces
@ -179,7 +179,7 @@ impl State {
.workspace_groups()
.iter()
.filter_map(|g| {
if g.output == self.expected_output {
if g.outputs.iter().any(|o| Some(o) == self.expected_output.as_ref()) {
Some(g.workspaces.iter().map(|w| {
(
w.name.clone(),

View file

@ -2,11 +2,12 @@ use cosmic::{
applet::CosmicAppletHelper,
iced::{
self,
wayland::{InitialSurface, SurfaceIdWrapper},
wayland::InitialSurface,
Application,
},
iced_sctk::layout::Limits,
iced_style::application,
iced_native::window,
};
use freedesktop_desktop_entry::DesktopEntry;
use std::{env, fs, process::Command};
@ -41,7 +42,7 @@ impl iced::Application for Button {
String::from("Button")
}
fn close_requested(&self, _id: SurfaceIdWrapper) -> Msg {
fn close_requested(&self, _id: window::Id) -> Msg {
unimplemented!()
}
@ -65,7 +66,7 @@ impl iced::Application for Button {
}
}
fn view(&self, _id: SurfaceIdWrapper) -> cosmic::Element<Msg> {
fn view(&self, _id: window::Id) -> cosmic::Element<Msg> {
// TODO icon?
cosmic::widget::button(cosmic::theme::Button::Text)
.text(&self.desktop.name)