update libcosmic: adds tooltip support

This commit is contained in:
Ashley Wulber 2025-02-26 14:23:53 -05:00 committed by Ashley Wulber
parent 38982176f0
commit 0de336d0d7
16 changed files with 352 additions and 70 deletions

View file

@ -69,15 +69,19 @@ serde = { version = "1.0.217", features = ["derive"] }
freedesktop-desktop-entry = "0.7.8" freedesktop-desktop-entry = "0.7.8"
[profile.release] [profile.release]
lto = "fat" # lto = "fat"
opt-level = 1
[workspace.metadata.cargo-machete] [workspace.metadata.cargo-machete]
ignored = ["libcosmic"] 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//" } cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "drop-menu-tree-changes" }
# libcosmic = { git = "https://github.com/pop-os/libcosmic//" } libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "drop-menu-tree-changes" }
iced_futures = { git = "https://github.com/pop-os/libcosmic//", branch = "drop-menu-tree-changes" }
# cosmic-config = { path = "../libcosmic/cosmic-config" } # cosmic-config = { path = "../libcosmic/cosmic-config" }
# libcosmic = { path = "../libcosmic" } # libcosmic = { path = "../libcosmic" }
# iced_futures = { path = "../libcosmic/iced/futures" }
# [patch."https://github.com/pop-os/winit.git"] # [patch."https://github.com/pop-os/winit.git"]
# winit = { git = "https://github.com/rust-windowing/winit.git", rev = "241b7a80bba96c91fa3901729cd5dec66abb9be4" } # winit = { git = "https://github.com/rust-windowing/winit.git", rev = "241b7a80bba96c91fa3901729cd5dec66abb9be4" }

View file

@ -36,6 +36,7 @@ use cosmic::{
}, },
iced_core::{Border, Padding, Shadow}, iced_core::{Border, Padding, Shadow},
iced_runtime::{core::event, dnd::peek_dnd}, iced_runtime::{core::event, dnd::peek_dnd},
surface_message::{MessageWrapper, SurfaceMessage},
theme::{self, Button, Container}, theme::{self, Button, Container},
widget::{ widget::{
button, divider, dnd_source, horizontal_space, button, divider, dnd_source, horizontal_space,
@ -371,6 +372,22 @@ enum Message {
ConfigUpdated(AppListConfig), ConfigUpdated(AppListConfig),
OpenFavorites, OpenFavorites,
OpenActive, OpenActive,
Surface(SurfaceMessage),
}
impl From<Message> for MessageWrapper<Message> {
fn from(value: Message) -> Self {
match value {
Message::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Message {
fn from(value: SurfaceMessage) -> Self {
Message::Surface(value)
}
} }
fn index_in_list( fn index_in_list(
@ -787,7 +804,6 @@ impl cosmic::Application for CosmicAppList {
return get_popup(popup_settings); return get_popup(popup_settings);
} }
} }
Message::PinApp(id) => { Message::PinApp(id) => {
if let Some(i) = self.active_list.iter().position(|t| t.id == id) { if let Some(i) = self.active_list.iter().position(|t| t.id == id) {
let entry = self.active_list.remove(i); let entry = self.active_list.remove(i);
@ -1354,6 +1370,7 @@ impl cosmic::Application for CosmicAppList {
return self.close_popups(); return self.close_popups();
} }
} }
Message::Surface(surface_message) => {}
} }
Task::none() Task::none()

View file

@ -22,6 +22,7 @@ use cosmic::{
}, },
iced_runtime::core::layout::Limits, iced_runtime::core::layout::Limits,
iced_widget::column, iced_widget::column,
surface_message::{MessageWrapper, SurfaceMessage},
theme, theme,
widget::{divider, text}, widget::{divider, text},
Element, Task, Element, Task,
@ -59,6 +60,22 @@ enum Message {
OpenSettings, OpenSettings,
DBusUpdate(DBusUpdate), DBusUpdate(DBusUpdate),
WaylandUpdate(WaylandUpdate), WaylandUpdate(WaylandUpdate),
Surface(SurfaceMessage),
}
impl From<Message> for MessageWrapper<Message> {
fn from(value: Message) -> Self {
match value {
Message::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Message {
fn from(value: SurfaceMessage) -> Self {
Message::Surface(value)
}
} }
impl cosmic::Application for CosmicA11yApplet { impl cosmic::Application for CosmicA11yApplet {
@ -202,6 +219,7 @@ impl cosmic::Application for CosmicA11yApplet {
self.wayland_sender = Some(tx); self.wayland_sender = Some(tx);
} }
}, },
Message::Surface(surface_message) => {}
} }
Task::none() Task::none()
} }

View file

@ -23,6 +23,7 @@ use cosmic::{
widget::{self, column, row, slider}, widget::{self, column, row, slider},
window, Alignment, Length, Limits, Subscription, window, Alignment, Length, Limits, Subscription,
}, },
surface_message::{MessageWrapper, SurfaceMessage},
theme, theme,
widget::{button, divider, horizontal_space, icon, text, Column, Row}, widget::{button, divider, horizontal_space, icon, text, Column, Row},
Element, Renderer, Task, Theme, Element, Renderer, Task, Theme,
@ -162,6 +163,22 @@ pub enum Message {
Token(TokenUpdate), Token(TokenUpdate),
OpenSettings, OpenSettings,
PulseSub(sub_pulse::Event), PulseSub(sub_pulse::Event),
Surface(SurfaceMessage),
}
impl From<Message> for MessageWrapper<Message> {
fn from(value: Message) -> Self {
match value {
Message::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Message {
fn from(value: SurfaceMessage) -> Self {
Message::Surface(value)
}
} }
impl Audio { impl Audio {
@ -675,6 +692,7 @@ impl cosmic::Application for Audio {
sub_pulse::Event::DefaultSource(_) => {} sub_pulse::Event::DefaultSource(_) => {}
sub_pulse::Event::CardInfo(_) => {} sub_pulse::Event::CardInfo(_) => {}
}, },
Message::Surface(surface_message) => {}
}; };
Task::none() Task::none()

View file

@ -26,6 +26,7 @@ use cosmic::{
iced_core::{Alignment, Background, Border, Color, Shadow}, iced_core::{Alignment, Background, Border, Color, Shadow},
iced_runtime::core::layout::Limits, iced_runtime::core::layout::Limits,
iced_widget::{Column, Row}, iced_widget::{Column, Row},
surface_message::{MessageWrapper, SurfaceMessage},
theme, theme,
widget::{divider, horizontal_space, icon, scrollable, text, vertical_space}, widget::{divider, horizontal_space, icon, scrollable, text, vertical_space},
Element, Task, Element, Task,
@ -188,6 +189,22 @@ enum Message {
OpenSettings, OpenSettings,
SettingsDaemon(settings_daemon::Event), SettingsDaemon(settings_daemon::Event),
ZbusConnection(zbus::Result<zbus::Connection>), ZbusConnection(zbus::Result<zbus::Connection>),
Surface(SurfaceMessage),
}
impl From<Message> for MessageWrapper<Message> {
fn from(value: Message) -> Self {
match value {
Message::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Message {
fn from(value: SurfaceMessage) -> Self {
Message::Surface(value)
}
} }
impl cosmic::Application for CosmicBatteryApplet { impl cosmic::Application for CosmicBatteryApplet {
@ -466,6 +483,7 @@ impl cosmic::Application for CosmicBatteryApplet {
} }
} }
}, },
Message::Surface(surface_message) => unreachable!(),
} }
Task::none() Task::none()
} }

View file

@ -5,6 +5,7 @@ use crate::bluetooth::{BluerDeviceStatus, BluerRequest, BluerState, DeviceProper
use cosmic::{ use cosmic::{
applet::token::subscription::{activation_token_subscription, TokenRequest, TokenUpdate}, applet::token::subscription::{activation_token_subscription, TokenRequest, TokenUpdate},
cctk::sctk::reexports::calloop, cctk::sctk::reexports::calloop,
surface_message::{MessageWrapper, SurfaceMessage},
}; };
use cosmic::{ use cosmic::{
@ -75,6 +76,22 @@ enum Message {
OpenSettings, OpenSettings,
Frame(Instant), Frame(Instant),
ToggleBluetooth(chain::Toggler, bool), ToggleBluetooth(chain::Toggler, bool),
Surface(SurfaceMessage),
}
impl From<Message> for MessageWrapper<Message> {
fn from(value: Message) -> Self {
match value {
Message::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Message {
fn from(value: SurfaceMessage) -> Self {
Message::Surface(value)
}
} }
impl cosmic::Application for CosmicBluetoothApplet { impl cosmic::Application for CosmicBluetoothApplet {
@ -332,6 +349,7 @@ impl cosmic::Application for CosmicBluetoothApplet {
}); });
} }
} }
Message::Surface(surface_message) => unreachable!(),
} }
self.update_icon(); self.update_icon();
Task::none() Task::none()

View file

@ -4,6 +4,7 @@
mod localize; mod localize;
use cosmic::iced::{Alignment, Length}; use cosmic::iced::{Alignment, Length};
use cosmic::surface_message::{SurfaceMessage, MessageWrapper};
use cosmic::{ use cosmic::{
app::Core, app::Core,
applet::{self}, applet::{self},
@ -85,6 +86,22 @@ pub enum Message {
CompConfig(Box<CosmicCompConfig>), CompConfig(Box<CosmicCompConfig>),
SetActiveLayout(usize), SetActiveLayout(usize),
KeyboardSettings, KeyboardSettings,
Surface(SurfaceMessage),
}
impl From<Message> for MessageWrapper<Message> {
fn from(value: Message) -> Self {
match value {
Message::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Message {
fn from(value: SurfaceMessage) -> Self {
Message::Surface(value)
}
} }
#[derive(Debug)] #[derive(Debug)]
@ -148,24 +165,20 @@ impl cosmic::Application for Window {
get_popup(popup_settings) get_popup(popup_settings)
}; };
} }
Message::PopupClosed(id) => { Message::PopupClosed(id) => {
if self.popup.as_ref() == Some(&id) { if self.popup.as_ref() == Some(&id) {
self.popup = None; self.popup = None;
} }
} }
Message::CompConfig(config) => { Message::CompConfig(config) => {
self.comp_config = *config; self.comp_config = *config;
self.active_layouts = self.update_xkb(); self.active_layouts = self.update_xkb();
} }
Message::KeyboardSettings => { Message::KeyboardSettings => {
let mut cmd = std::process::Command::new("cosmic-settings"); let mut cmd = std::process::Command::new("cosmic-settings");
cmd.arg("keyboard"); cmd.arg("keyboard");
tokio::spawn(cosmic::process::spawn(cmd)); tokio::spawn(cosmic::process::spawn(cmd));
} }
Message::SetActiveLayout(pos) => { Message::SetActiveLayout(pos) => {
if pos == 0 { if pos == 0 {
return Task::none(); return Task::none();
@ -195,6 +208,7 @@ impl cosmic::Application for Window {
} }
} }
} }
Message::Surface(surface_message) => unreachable!(),
} }
Task::none() Task::none()

View file

@ -23,6 +23,7 @@ use cosmic::{
window::{self}, window::{self},
Length, Limits, Subscription, Length, Limits, Subscription,
}, },
surface_message::{SurfaceMessage, MessageWrapper},
widget::{autosize::autosize, mouse_area}, widget::{autosize::autosize, mouse_area},
Task, Task,
}; };
@ -82,6 +83,22 @@ enum Message {
Closed(window::Id), Closed(window::Id),
OpenOverflowPopup, OpenOverflowPopup,
CloseOverflowPopup, CloseOverflowPopup,
Surface(SurfaceMessage),
}
impl From<Message> for MessageWrapper<Message> {
fn from(value: Message) -> Self {
match value {
Message::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Message {
fn from(value: SurfaceMessage) -> Self {
Message::Surface(value)
}
} }
impl cosmic::Application for Minimize { impl cosmic::Application for Minimize {
@ -210,6 +227,7 @@ impl cosmic::Application for Minimize {
} }
} }
Message::CloseOverflowPopup => todo!(), Message::CloseOverflowPopup => todo!(),
Message::Surface(surface_message) => unreachable!(),
}; };
Task::none() Task::none()
} }

View file

@ -15,6 +15,7 @@ use cosmic::{
}, },
iced_runtime::core::{layout::Limits, window}, iced_runtime::core::{layout::Limits, window},
iced_widget::Row, iced_widget::Row,
surface_message::{MessageWrapper, SurfaceMessage},
theme, theme,
widget::{ widget::{
button, container, divider, button, container, divider,
@ -244,7 +245,22 @@ pub(crate) enum Message {
ResetFailedKnownSsid(String, HwAddress), ResetFailedKnownSsid(String, HwAddress),
OpenHwDevice(Option<HwAddress>), OpenHwDevice(Option<HwAddress>),
TogglePasswordVisibility, TogglePasswordVisibility,
// Errored(String), Surface(SurfaceMessage), // Errored(String),
}
impl From<Message> for MessageWrapper<Message> {
fn from(value: Message) -> Self {
match value {
Message::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Message {
fn from(value: SurfaceMessage) -> Self {
Message::Surface(value)
}
} }
impl cosmic::Application for CosmicNetworkApplet { impl cosmic::Application for CosmicNetworkApplet {
@ -305,7 +321,6 @@ impl cosmic::Application for CosmicNetworkApplet {
return get_popup(popup_settings); return get_popup(popup_settings);
} }
} }
// Message::Errored(_) => todo!(),
Message::ToggleAirplaneMode(enabled) => { Message::ToggleAirplaneMode(enabled) => {
self.toggle_wifi_ctr += 1; self.toggle_wifi_ctr += 1;
if let Some(tx) = self.nm_sender.as_mut() { if let Some(tx) = self.nm_sender.as_mut() {
@ -340,63 +355,63 @@ impl cosmic::Application for CosmicNetworkApplet {
req, req,
} => { } => {
if let NetworkManagerRequest::SelectAccessPoint(ssid, hw_address) = &req { if let NetworkManagerRequest::SelectAccessPoint(ssid, hw_address) = &req {
let conn_match = self let conn_match = self
.new_connection
.as_ref()
.map(|c| c.ssid() == ssid && c.hw_address() == *hw_address)
.unwrap_or_default();
if conn_match && success {
if let Some(s) =
state.active_conns.iter_mut().find(|ap| &ap.name() == ssid && ap.hw_address() == *hw_address)
{
match s {
ActiveConnectionInfo::WiFi { state, .. } => {
*state = ActiveConnectionState::Activated;
}
_ => {}
};
}
self.failed_known_ssids.remove(ssid);
self.new_connection = None;
self.show_visible_networks = false;
} else if !matches!(
&self.new_connection,
Some(NewConnectionState::EnterPassword { .. })
)
{
self.failed_known_ssids.insert(ssid.clone());
}
} else if let NetworkManagerRequest::Password(ssid, _, hw_address) = &req {
if let Some(NewConnectionState::Waiting(access_point)) =
self.new_connection.clone()
{
if !success && ssid == &access_point.ssid && *hw_address == access_point.hw_address {
self.new_connection =
Some(NewConnectionState::Failure(access_point.clone()));
} else {
self.new_connection = None;
self.show_visible_networks = false;
}
} else if let Some(NewConnectionState::EnterPassword {
access_point, ..
}) = self.new_connection.clone()
{
if success && ssid == &access_point.ssid && *hw_address == access_point.hw_address {
self.new_connection = None;
self.show_visible_networks = false;
}
}
} else if self
.new_connection .new_connection
.as_ref() .as_ref()
.map(|c| c.ssid() == ssid && c.hw_address() == *hw_address) .map(|c| c.ssid()).is_some_and(|ssid| {
.unwrap_or_default(); state.active_conns.iter().any(|c|
if conn_match && success { matches!(c, ActiveConnectionInfo::WiFi { name, state: ActiveConnectionState::Activated, .. } if ssid == name)
if let Some(s) = )
state.active_conns.iter_mut().find(|ap| &ap.name() == ssid && ap.hw_address() == *hw_address) }) {
{
match s {
ActiveConnectionInfo::WiFi { state, .. } => {
*state = ActiveConnectionState::Activated;
}
_ => {}
};
}
self.failed_known_ssids.remove(ssid);
self.new_connection = None;
self.show_visible_networks = false;
} else if !matches!(
&self.new_connection,
Some(NewConnectionState::EnterPassword { .. })
)
{
self.failed_known_ssids.insert(ssid.clone());
}
} else if let NetworkManagerRequest::Password(ssid, _, hw_address) = &req {
if let Some(NewConnectionState::Waiting(access_point)) =
self.new_connection.clone()
{
if !success && ssid == &access_point.ssid && *hw_address == access_point.hw_address {
self.new_connection =
Some(NewConnectionState::Failure(access_point.clone()));
} else {
self.new_connection = None; self.new_connection = None;
self.show_visible_networks = false; self.show_visible_networks = false;
} }
} else if let Some(NewConnectionState::EnterPassword {
access_point, ..
}) = self.new_connection.clone()
{
if success && ssid == &access_point.ssid && *hw_address == access_point.hw_address {
self.new_connection = None;
self.show_visible_networks = false;
}
}
} else if self
.new_connection
.as_ref()
.map(|c| c.ssid()).is_some_and(|ssid| {
state.active_conns.iter().any(|c|
matches!(c, ActiveConnectionInfo::WiFi { name, state: ActiveConnectionState::Activated, .. } if ssid == name)
)
}) {
self.new_connection = None;
self.show_visible_networks = false;
}
if !matches!(req, NetworkManagerRequest::Reload) if !matches!(req, NetworkManagerRequest::Reload)
&& matches!(state.connectivity, NmConnectivityState::Portal) && matches!(state.connectivity, NmConnectivityState::Portal)
@ -573,6 +588,7 @@ impl cosmic::Application for CosmicNetworkApplet {
return self.update(Message::SelectWirelessAccessPoint(ap)); return self.update(Message::SelectWirelessAccessPoint(ap));
} }
} }
Message::Surface(surface_message) => unreachable!(),
} }
Task::none() Task::none()
} }
@ -991,7 +1007,7 @@ impl cosmic::Application for CosmicNetworkApplet {
) )
.on_input(Message::Password) .on_input(Message::Password)
.on_paste(Message::Password) .on_paste(Message::Password)
.on_submit(Message::SubmitPassword) .on_submit(|_| Message::SubmitPassword)
.password(), .password(),
] ]
.push_maybe( .push_maybe(

View file

@ -17,6 +17,7 @@ use cosmic::{
window, Alignment, Length, Limits, Subscription, window, Alignment, Length, Limits, Subscription,
}, },
iced_widget::{scrollable, Column}, iced_widget::{scrollable, Column},
surface_message::{SurfaceMessage, MessageWrapper},
theme, theme,
widget::{button, container, divider, icon, text}, widget::{button, container, divider, icon, text},
Element, Task, Element, Task,
@ -94,6 +95,22 @@ enum Message {
CardsToggled(String, bool), CardsToggled(String, bool),
Token(TokenUpdate), Token(TokenUpdate),
OpenSettings, OpenSettings,
Surface(SurfaceMessage),
}
impl From<Message> for MessageWrapper<Message> {
fn from(value: Message) -> Self {
match value {
Message::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Message {
fn from(value: SurfaceMessage) -> Self {
Message::Surface(value)
}
} }
impl cosmic::Application for Notifications { impl cosmic::Application for Notifications {
@ -399,6 +416,7 @@ impl cosmic::Application for Notifications {
}); });
} }
} }
Message::Surface(surface_message) => unreachable!(),
}; };
self.update_icon(); self.update_icon();
Task::none() Task::none()

View file

@ -1,21 +1,29 @@
// Copyright 2023 System76 <info@system76.com> // Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
use std::cell::LazyCell;
use cosmic::{ use cosmic::{
app, app,
applet::{menu_button, padded_control}, applet::{menu_button, padded_control},
cctk::wayland_protocols::xdg::shell::client::xdg_positioner::Gravity,
cosmic_theme::Spacing, cosmic_theme::Spacing,
iced::{ iced::{
self, self,
platform_specific::shell::commands::popup::{destroy_popup, get_popup}, platform_specific::{
runtime::wayland::subsurface,
shell::commands::popup::{destroy_popup, get_popup},
},
widget::{self, column, row}, widget::{self, column, row},
window, Alignment, Length, window, Alignment, Length,
}, },
iced_runtime::core::layout::Limits, iced_runtime::core::layout::Limits,
surface_message::{MessageWrapper, SurfaceMessage},
theme, theme,
widget::{button, divider, icon, text, Space}, widget::{autosize, button, divider, icon, layer_container::layer_container, text, Space},
Element, Task, Element, Task,
}; };
use once_cell::sync::Lazy;
use logind_zbus::{ use logind_zbus::{
manager::ManagerProxy, manager::ManagerProxy,
@ -32,17 +40,20 @@ pub mod session_manager;
use crate::{cosmic_session::CosmicSessionProxy, session_manager::SessionManagerProxy}; use crate::{cosmic_session::CosmicSessionProxy, session_manager::SessionManagerProxy};
static SUBSURFACE_ID: Lazy<cosmic::widget::Id> =
Lazy::new(|| cosmic::widget::Id::new("subsurface"));
pub fn run() -> cosmic::iced::Result { pub fn run() -> cosmic::iced::Result {
localize::localize(); localize::localize();
cosmic::applet::run::<Power>(()) cosmic::applet::run::<Power>(())
} }
#[derive(Default)]
struct Power { struct Power {
core: cosmic::app::Core, core: cosmic::app::Core,
icon_name: String, icon_name: String,
popup: Option<window::Id>, popup: Option<window::Id>,
subsurface_id: window::Id,
} }
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
@ -66,6 +77,20 @@ impl PowerAction {
} }
} }
} }
impl From<Message> for MessageWrapper<Message> {
fn from(value: Message) -> Self {
match value {
Message::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Message {
fn from(value: SurfaceMessage) -> Self {
Message::Surface(value)
}
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
enum Message { enum Message {
@ -74,6 +99,7 @@ enum Message {
Settings, Settings,
Zbus(Result<(), zbus::Error>), Zbus(Result<(), zbus::Error>),
Closed(window::Id), Closed(window::Id),
Surface(SurfaceMessage),
} }
impl cosmic::Application for Power { impl cosmic::Application for Power {
@ -95,7 +121,8 @@ impl cosmic::Application for Power {
Self { Self {
core, core,
icon_name: "system-shutdown-symbolic".to_string(), icon_name: "system-shutdown-symbolic".to_string(),
..Default::default() subsurface_id: window::Id::unique(),
popup: Default::default(),
}, },
Task::none(), Task::none(),
) )
@ -173,14 +200,20 @@ impl cosmic::Application for Power {
} }
Task::none() Task::none()
} }
Message::Surface(surface_message) => unimplemented!(),
} }
} }
fn view(&self) -> Element<Message> { fn view(&self) -> Element<Message> {
self.core self.core
.applet .applet
.icon_button(&self.icon_name) .applet_tooltip(
.on_press_down(Message::TogglePopup) self.core
.applet
.icon_button(&self.icon_name)
.on_press_down(Message::TogglePopup),
"power",
)
.into() .into()
} }

View file

@ -9,6 +9,7 @@ use cosmic::{
platform_specific::shell::commands::popup::{destroy_popup, get_popup}, platform_specific::shell::commands::popup::{destroy_popup, get_popup},
window, Limits, Subscription, window, Limits, Subscription,
}, },
surface_message::{MessageWrapper, SurfaceMessage},
widget::mouse_area, widget::mouse_area,
Element, Task, Element, Task,
}; };
@ -24,6 +25,22 @@ pub enum Msg {
StatusNotifier(status_notifier_watcher::Event), StatusNotifier(status_notifier_watcher::Event),
TogglePopup(usize), TogglePopup(usize),
Hovered(usize), Hovered(usize),
Surface(SurfaceMessage),
}
impl From<Msg> for MessageWrapper<Msg> {
fn from(value: Msg) -> Self {
match value {
Msg::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Msg {
fn from(value: SurfaceMessage) -> Self {
Msg::Surface(value)
}
} }
#[derive(Default)] #[derive(Default)]
@ -226,6 +243,7 @@ impl cosmic::Application for App {
cmds.push(get_popup(popup_settings)); cmds.push(get_popup(popup_settings));
app::Task::batch(cmds) app::Task::batch(cmds)
} }
Msg::Surface(surface_message) => unreachable!(),
} }
} }

View file

@ -16,6 +16,7 @@ use cosmic::{
Length, Limits, Subscription, Task, Length, Limits, Subscription, Task,
}, },
iced_widget::{column, row}, iced_widget::{column, row},
surface_message::{SurfaceMessage, MessageWrapper},
theme, theme,
widget::{ widget::{
container, divider, container, divider,
@ -60,6 +61,22 @@ pub enum Message {
WorkspaceUpdate(WorkspacesUpdate), WorkspaceUpdate(WorkspacesUpdate),
NewWorkspace(Entity), NewWorkspace(Entity),
OpenSettings, OpenSettings,
Surface(SurfaceMessage),
}
impl From<Message> for MessageWrapper<Message> {
fn from(value: Message) -> Self {
match value {
Message::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Message {
fn from(value: SurfaceMessage) -> Self {
Message::Surface(value)
}
} }
impl cosmic::Application for Window { impl cosmic::Application for Window {
@ -270,6 +287,7 @@ impl cosmic::Application for Window {
cmd.arg("window-management"); cmd.arg("window-management");
tokio::spawn(cosmic::process::spawn(cmd)); tokio::spawn(cosmic::process::spawn(cmd));
} }
Message::Surface(surface_message) => unreachable!(),
} }
Task::none() Task::none()
} }

View file

@ -5,6 +5,7 @@ use std::str::FromStr;
use chrono::{Datelike, Timelike}; use chrono::{Datelike, Timelike};
use cosmic::iced_futures::stream; use cosmic::iced_futures::stream;
use cosmic::surface_message::{SurfaceMessage, MessageWrapper};
use cosmic::widget::Id; use cosmic::widget::Id;
use cosmic::{ use cosmic::{
app, app,
@ -79,6 +80,22 @@ pub enum Message {
Token(TokenUpdate), Token(TokenUpdate),
ConfigChanged(TimeAppletConfig), ConfigChanged(TimeAppletConfig),
TimezoneUpdate(String), TimezoneUpdate(String),
Surface(SurfaceMessage),
}
impl From<Message> for MessageWrapper<Message> {
fn from(value: Message) -> Self {
match value {
Message::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Message {
fn from(value: SurfaceMessage) -> Self {
Message::Surface(value)
}
} }
impl Window { impl Window {
@ -442,6 +459,7 @@ impl cosmic::Application for Window {
self.update(Message::Tick) self.update(Message::Tick)
} }
Message::Surface(surface_message) => unreachable!(),
} }
} }

View file

@ -21,6 +21,7 @@ use cosmic::{
Length, Limits, Subscription, Length, Limits, Subscription,
}, },
iced_core::{Background, Border}, iced_core::{Background, Border},
surface_message::{SurfaceMessage, MessageWrapper},
widget::{autosize, container, horizontal_space, vertical_space, Id}, widget::{autosize, container, horizontal_space, vertical_space, Id},
Element, Task, Theme, Element, Task, Theme,
}; };
@ -93,6 +94,22 @@ enum Message {
WorkspacePressed(ExtWorkspaceHandleV1), WorkspacePressed(ExtWorkspaceHandleV1),
WheelScrolled(ScrollDelta), WheelScrolled(ScrollDelta),
WorkspaceOverview, WorkspaceOverview,
Surface(SurfaceMessage),
}
impl From<Message> for MessageWrapper<Message> {
fn from(value: Message) -> Self {
match value {
Message::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Message {
fn from(value: SurfaceMessage) -> Self {
Message::Surface(value)
}
} }
impl cosmic::Application for IcedWorkspacesApplet { impl cosmic::Application for IcedWorkspacesApplet {
@ -215,6 +232,7 @@ impl cosmic::Application for IcedWorkspacesApplet {
Message::WorkspaceOverview => { Message::WorkspaceOverview => {
let _ = ShellCommand::new("cosmic-workspaces").spawn(); let _ = ShellCommand::new("cosmic-workspaces").spawn();
} }
Message::Surface(surface_message) => unreachable!(),
} }
Task::none() Task::none()
} }

View file

@ -10,6 +10,7 @@ use cosmic::{
}, },
iced::{self, Length}, iced::{self, Length},
iced_widget::row, iced_widget::row,
surface_message::{MessageWrapper, SurfaceMessage},
widget::{autosize, vertical_space, Id}, widget::{autosize, vertical_space, Id},
Task, Task,
}; };
@ -39,6 +40,22 @@ struct Button {
enum Msg { enum Msg {
Press, Press,
ConfigUpdated(CosmicPanelButtonConfig), ConfigUpdated(CosmicPanelButtonConfig),
Surface(SurfaceMessage),
}
impl From<Msg> for MessageWrapper<Msg> {
fn from(value: Msg) -> Self {
match value {
Msg::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Msg {
fn from(value: SurfaceMessage) -> Self {
Msg::Surface(value)
}
} }
impl cosmic::Application for Button { impl cosmic::Application for Button {
@ -94,6 +111,7 @@ impl cosmic::Application for Button {
.cloned() .cloned()
.unwrap_or_default(); .unwrap_or_default();
} }
Msg::Surface(_) => unreachable!(),
} }
Task::none() Task::none()
} }