chore: adopt typed surface actions from libcosmic

This commit is contained in:
Hojjat 2026-09-08 12:32:11 -06:00 • committed by Michael Murphy
parent b7005660f1
commit 7ba55f66cc
3 changed files with 37 additions and 40 deletions

View file

@ -481,7 +481,7 @@ pub enum Message {
OutputEvent(OutputEvent, WlOutput), OutputEvent(OutputEvent, WlOutput),
Cosmic(app::Action), Cosmic(app::Action),
None, None,
Surface(surface::Action), Surface(surface::Action<Message>),
CutPaths(Vec<PathBuf>), CutPaths(Vec<PathBuf>),
} }
@ -2525,7 +2525,7 @@ impl Application for App {
{ {
nav = nav nav = nav
.window_id_maybe(self.core().main_window_id()) .window_id_maybe(self.core().main_window_id())
.on_surface_action(|m| cosmic::Action::Cosmic(cosmic::app::Action::Surface(m))) .on_surface_action(|action| cosmic::Action::Surface(action.flatten()))
} }
let mut nav = nav.into_container(); let mut nav = nav.into_container();
@ -4520,6 +4520,9 @@ impl Application for App {
])); ]));
} }
tab::Command::Surface(action) => { tab::Command::Surface(action) => {
// re-type the tab's surface action the way its messages are re-typed
let action = action
.map(move |message| Message::TabMessage(Some(entity), message));
commands.push(self.update(Message::Surface(action))); commands.push(self.update(Message::Surface(action)));
} }
tab::Command::Delete(paths) => commands.push(self.delete(paths)), tab::Command::Delete(paths) => commands.push(self.delete(paths)),
@ -5249,8 +5252,7 @@ impl Application for App {
.insert(surface_id, Window::new(WindowKind::Desktop(entity))); .insert(surface_id, Window::new(WindowKind::Desktop(entity)));
return Task::batch([ return Task::batch([
command, command,
cosmic::task::message(cosmic::action::cosmic( cosmic::task::message(cosmic::Action::Surface(
cosmic::app::Action::Surface(
cosmic::surface::action::app_layer_shell( cosmic::surface::action::app_layer_shell(
|_| Default::default(), |_| Default::default(),
move |_: &mut App| SctkLayerSurfaceSettings { move |_: &mut App| SctkLayerSurfaceSettings {
@ -5272,13 +5274,10 @@ impl Application for App {
right: 0, right: 0,
}, },
exclusive_zone: 0, exclusive_zone: 0,
size_limits: Limits::NONE size_limits: Limits::NONE.min_width(1.0).min_height(1.0),
.min_width(1.0)
.min_height(1.0),
}, },
None, None,
), ),
),
)), )),
#[cfg(all(feature = "wayland", feature = "desktop-applet"))] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
overlap_notify(surface_id, true), overlap_notify(surface_id, true),
@ -5372,9 +5371,7 @@ impl Application for App {
}); });
} }
Message::Surface(action) => { Message::Surface(action) => {
return cosmic::task::message(cosmic::Action::Cosmic( return cosmic::task::message(cosmic::Action::Surface(action));
cosmic::app::Action::Surface(action),
));
} }
Message::SaveSortNames => { Message::SaveSortNames => {
self.must_save_sort_names = false; self.must_save_sort_names = false;
@ -6600,6 +6597,7 @@ impl Application for App {
return self.view_main().map(|message| match message { return self.view_main().map(|message| match message {
cosmic::Action::App(app) => app, cosmic::Action::App(app) => app,
cosmic::Action::Cosmic(cosmic) => Message::Cosmic(cosmic), cosmic::Action::Cosmic(cosmic) => Message::Cosmic(cosmic),
cosmic::Action::Surface(action) => Message::Surface(action),
cosmic::Action::None => Message::None, cosmic::Action::None => Message::None,
}); });
} }

View file

@ -468,7 +468,7 @@ enum Message {
SearchActivate, SearchActivate,
SearchClear, SearchClear,
SearchInput(String), SearchInput(String),
Surface(cosmic::surface::Action), Surface(cosmic::surface::Action<Message>),
#[allow(clippy::enum_variant_names)] #[allow(clippy::enum_variant_names)]
TabMessage(tab::Message), TabMessage(tab::Message),
TabRescan( TabRescan(
@ -501,7 +501,7 @@ impl From<AppMessage> for Message {
AppMessage::ZoomIn(_entity_opt) => Self::ZoomIn, AppMessage::ZoomIn(_entity_opt) => Self::ZoomIn,
AppMessage::ZoomOut(_entity_opt) => Self::ZoomOut, AppMessage::ZoomOut(_entity_opt) => Self::ZoomOut,
AppMessage::NewItem(_entity_opt, true) => Self::NewFolder, AppMessage::NewItem(_entity_opt, true) => Self::NewFolder,
AppMessage::Surface(action) => Self::Surface(action), AppMessage::Surface(action) => Self::Surface(action.map(Self::from)),
unsupported => { unsupported => {
log::warn!("{unsupported:?} not supported in dialog mode"); log::warn!("{unsupported:?} not supported in dialog mode");
Self::None Self::None
@ -1750,6 +1750,7 @@ impl Application for App {
])); ]));
} }
tab::Command::Surface(action) => { tab::Command::Surface(action) => {
let action = action.map(Message::TabMessage);
commands.push(self.update(Message::Surface(action))); commands.push(self.update(Message::Surface(action)));
} }
tab::Command::Iced(iced_command) => { tab::Command::Iced(iced_command) => {
@ -1905,9 +1906,7 @@ impl Application for App {
}); });
} }
Message::Surface(action) => { Message::Surface(action) => {
return cosmic::task::message(cosmic::Action::Cosmic( return cosmic::task::message(cosmic::Action::Surface(action));
cosmic::app::Action::Surface(action),
));
} }
} }

View file

@ -1742,7 +1742,7 @@ impl fmt::Debug for TaskWrapper {
#[derive(Debug)] #[derive(Debug)]
pub enum Command { pub enum Command {
Action(Action), Action(Action),
Surface(cosmic::surface::Action), Surface(cosmic::surface::Action<Message>),
AddNetworkDrive, AddNetworkDrive,
AddToSidebar(PathBuf), AddToSidebar(PathBuf),
AutoScroll(Option<f32>), AutoScroll(Option<f32>),
@ -1778,7 +1778,7 @@ pub enum Message {
Config(TabConfig), Config(TabConfig),
ContextAction(Action), ContextAction(Action),
RightClickBackground, RightClickBackground,
Surface(cosmic::surface::Action), Surface(cosmic::surface::Action<Message>),
LocationContextMenuIndex(Option<usize>), LocationContextMenuIndex(Option<usize>),
LocationMenuAction(LocationMenuAction), LocationMenuAction(LocationMenuAction),
Drag(Option<Rectangle>), Drag(Option<Rectangle>),