feat(applets): add overflow support

This commit is contained in:
Ashley Wulber 2024-07-16 11:15:22 -04:00 committed by GitHub
parent 1e566c13aa
commit d35cc71b90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 89 additions and 22 deletions

View file

@ -84,6 +84,9 @@ pub enum Message {
Focus(window::Id),
/// Window focus lost
Unfocus(window::Id),
/// Tracks updates to window suggested size.
#[cfg(feature = "applet")]
Configure(cctk::sctk::shell::xdg::window::WindowConfigure),
}
#[derive(Default)]
@ -186,6 +189,12 @@ where
| wayland::Event::Layer(wayland::LayerEvent::Done, _, id) => {
return Some(Message::SurfaceClosed(id));
}
#[cfg(feature = "applet")]
wayland::Event::Window(WindowEvent::Configure(conf), _surface, id)
if id == window::Id::MAIN =>
{
return Some(Message::Configure(conf));
}
_ => (),
},
_ => (),
@ -638,6 +647,16 @@ impl<T: Application> Cosmic<T> {
core.focused_window = None;
}
}
#[cfg(feature = "applet")]
Message::Configure(configure) => {
if let Some(w) = configure.new_size.0 {
self.app.core_mut().set_window_width(w.get());
}
if let Some(h) = configure.new_size.1 {
self.app.core_mut().set_window_height(h.get());
}
self.app.core_mut().applet.configure = Some(configure);
}
}
iced::Command::none()