Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix close popup jammy #171

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 72 additions & 73 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ members = [
resolver = "2"

[workspace.dependencies]
cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "5faec87" }
cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "c1b6516" }
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = [
"client",
], rev = "5faec87" }
], rev = "c1b6516" }
cosmic-time = { git = "https://github.com/pop-os/cosmic-time", default-features = false, features = [
"libcosmic",
"once_cell",
Expand Down
28 changes: 15 additions & 13 deletions cosmic-app-list/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use cosmic::iced::widget::vertical_space;
use cosmic::iced::widget::{column, dnd_source, mouse_area, row, Column, Row};
use cosmic::iced::Color;
use cosmic::iced::{window, Subscription};
use cosmic::iced_core::event::wayland;
use cosmic::iced_core::event::PlatformSpecific;
use cosmic::iced_runtime::core::alignment::Horizontal;
use cosmic::iced_runtime::core::event;
use cosmic::iced_sctk::commands::data_device::accept_mime_type;
Expand Down Expand Up @@ -124,15 +126,16 @@ impl DockItem {
container(vertical_space(Length::Fixed(0.0)))
.padding(dot_radius)
.style(<Theme as container::StyleSheet>::Style::Custom(Box::new(
|theme| container::Appearance {
text_color: Some(Color::TRANSPARENT),
background: Some(Background::Color(
theme.cosmic().on_bg_color().into(),
)),
border_radius: 4.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
icon_color: Some(Color::TRANSPARENT),
|theme| {
let cosmic = theme.cosmic();
container::Appearance {
text_color: Some(Color::TRANSPARENT),
background: Some(Background::Color(cosmic.on_bg_color().into())),
border_radius: cosmic.corner_radii.radius_xs.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
icon_color: Some(Color::TRANSPARENT),
}
},
)))
.into()
Expand Down Expand Up @@ -1124,6 +1127,9 @@ impl cosmic::Application for CosmicAppList {
| event::wayland::DndOfferEvent::DropPerformed,
)),
) => Some(Message::StopListeningForDnd),
cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
wayland::Event::Popup(wayland::PopupEvent::Done, _, id),
)) => Some(Message::CloseRequested(id)),
_ => None,
}),
rectangle_tracker_subscription(0).map(|update| Message::Rectangle(update.1)),
Expand All @@ -1144,8 +1150,4 @@ impl cosmic::Application for CosmicAppList {
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::applet::style())
}

fn on_close_requested(&self, id: window::Id) -> Option<Message> {
Some(Message::CloseRequested(id))
}
}
17 changes: 13 additions & 4 deletions cosmic-applet-audio/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
widget::{column, row, slider, text},
window, Alignment, Length, Subscription,
};
use cosmic::iced_core::event::wayland;
use cosmic::iced_core::event::PlatformSpecific;
use cosmic::iced_futures::event::listen_with;
use cosmic::iced_runtime::core::alignment::Horizontal;
use cosmic::iced_style::application;
use cosmic::widget::button;
Expand Down Expand Up @@ -446,10 +449,10 @@
pulse::Event::Disconnected => {
self.pulse_state.disconnected();
if let Some(mut conn) = self.pulse_state.connection().cloned() {
_ = tokio::spawn(async move {
tokio::time::sleep(tokio::time::Duration::from_secs(30)).await;
conn.send(pulse::Message::UpdateConnection);
});

Check warning on line 455 in cosmic-applet-audio/src/main.rs

View workflow job for this annotation

GitHub Actions / linting

non-binding `let` on a future

warning: non-binding `let` on a future --> cosmic-applet-audio/src/main.rs:452:25 | 452 | / _ = tokio::spawn(async move { 453 | | tokio::time::sleep(tokio::time::Duration::from_secs(30)).await; 454 | | conn.send(pulse::Message::UpdateConnection); 455 | | }); | |__________________________^ | = help: consider awaiting the future or dropping explicitly with `std::mem::drop` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_future = note: `#[warn(clippy::let_underscore_future)]` on by default

Check warning on line 455 in cosmic-applet-audio/src/main.rs

View workflow job for this annotation

GitHub Actions / linting

non-binding `let` on a future

warning: non-binding `let` on a future --> cosmic-applet-audio/src/main.rs:452:25 | 452 | / _ = tokio::spawn(async move { 453 | | tokio::time::sleep(tokio::time::Duration::from_secs(30)).await; 454 | | conn.send(pulse::Message::UpdateConnection); 455 | | }); | |__________________________^ | = help: consider awaiting the future or dropping explicitly with `std::mem::drop` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_future = note: `#[warn(clippy::let_underscore_future)]` on by default
}
}
},
Expand Down Expand Up @@ -570,6 +573,16 @@
}),
mpris_subscription::mpris_subscription(0).map(Message::Mpris),
activation_token_subscription(0).map(Message::Token),
listen_with(|e, _| {
if let cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
wayland::Event::Popup(wayland::PopupEvent::Done, _, id),
)) = e
{
Some(Message::CloseRequested(id))
} else {
None
}
}),
])
}

Expand Down Expand Up @@ -767,10 +780,6 @@

self.core.applet.popup_container(container(content)).into()
}

fn on_close_requested(&self, id: window::Id) -> Option<Message> {
Some(Message::CloseRequested(id))
}
}

fn revealer(
Expand Down
16 changes: 12 additions & 4 deletions cosmic-applet-battery/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use cosmic::iced::{
widget::{column, container, row, slider, text},
window, Alignment, Length, Subscription,
};
use cosmic::iced_core::event::{wayland, PlatformSpecific};
use cosmic::iced_futures::event::listen_with;
use cosmic::iced_runtime::core::layout::Limits;
use cosmic::iced_style::application;
use cosmic::widget::{divider, horizontal_space, icon};
Expand Down Expand Up @@ -504,13 +506,19 @@ impl cosmic::Application for CosmicBatteryApplet {
.as_subscription()
.map(|(_, now)| Message::Frame(now)),
activation_token_subscription(0).map(Message::Token),
listen_with(|e, _| {
if let cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
wayland::Event::Popup(wayland::PopupEvent::Done, _, id),
)) = e
{
Some(Message::CloseRequested(id))
} else {
None
}
}),
])
}

fn on_close_requested(&self, id: window::Id) -> Option<Message> {
Some(Message::CloseRequested(id))
}

fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::applet::style())
}
Expand Down
16 changes: 12 additions & 4 deletions cosmic-applet-bluetooth/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use cosmic::applet::token::subscription::{
use cosmic::cctk::sctk::reexports::calloop;

use cosmic::applet::{menu_button, padded_control};
use cosmic::iced_core::event::{wayland, PlatformSpecific};
use cosmic::iced_futures::event::listen_with;
use cosmic::Command;
use cosmic::{
iced::{
Expand Down Expand Up @@ -556,14 +558,20 @@ impl cosmic::Application for CosmicBluetoothApplet {
self.timeline
.as_subscription()
.map(|(_, now)| Message::Frame(now)),
listen_with(|e, _| {
if let cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
wayland::Event::Popup(wayland::PopupEvent::Done, _, id),
)) = e
{
Some(Message::CloseRequested(id))
} else {
None
}
}),
])
}

fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::applet::style())
}

fn on_close_requested(&self, id: window::Id) -> Option<Message> {
Some(Message::CloseRequested(id))
}
}
4 changes: 0 additions & 4 deletions cosmic-applet-graphics/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,6 @@ impl cosmic::Application for Window {
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::applet::style())
}

fn on_close_requested(&self, id: window::Id) -> Option<Message> {
Some(Message::PopupClosed(id))
}
}

fn button_icon<'a>(
Expand Down
20 changes: 14 additions & 6 deletions cosmic-applet-network/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use cosmic::applet::token::subscription::{
};
use cosmic::applet::{menu_button, menu_control_padding, padded_control};
use cosmic::cctk::sctk::reexports::calloop;
use cosmic::iced_core::event::{wayland, PlatformSpecific};
use cosmic::iced_futures::event::listen_with;
use cosmic::iced_widget::Row;
use cosmic::{
iced::{
Expand Down Expand Up @@ -819,13 +821,23 @@ impl cosmic::Application for CosmicNetworkApplet {
.as_subscription()
.map(|(_, now)| Message::Frame(now));
let token_sub = activation_token_subscription(0).map(Message::Token);

let close_sub = listen_with(|e, _| {
if let cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
wayland::Event::Popup(wayland::PopupEvent::Done, _, id),
)) = e
{
Some(Message::CloseRequested(id))
} else {
None
}
});
if let Some(conn) = self.conn.as_ref() {
let has_popup = self.popup.is_some();
Subscription::batch(vec![
timeline,
network_sub,
token_sub,
close_sub,
active_conns_subscription(self.toggle_wifi_ctr, conn.clone())
.map(Message::NetworkManagerEvent),
devices_subscription(self.toggle_wifi_ctr, has_popup, conn.clone())
Expand All @@ -834,15 +846,11 @@ impl cosmic::Application for CosmicNetworkApplet {
.map(Message::NetworkManagerEvent),
])
} else {
Subscription::batch(vec![timeline, network_sub, token_sub])
Subscription::batch(vec![timeline, network_sub, token_sub, close_sub])
}
}

fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::applet::style())
}

fn on_close_requested(&self, id: window::Id) -> Option<Message> {
Some(Message::CloseRequested(id))
}
}
16 changes: 12 additions & 4 deletions cosmic-applet-notifications/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use cosmic::iced::{
use cosmic::iced_core::alignment::Horizontal;
use cosmic::Command;

use cosmic::iced_core::event::{wayland, PlatformSpecific};
use cosmic::iced_futures::event::listen_with;
use cosmic::iced_style::application;

use cosmic::iced_widget::{scrollable, Column};
Expand Down Expand Up @@ -171,6 +173,16 @@ impl cosmic::Application for Notifications {
subscriptions::dbus::proxy().map(Message::DbusEvent),
subscriptions::notifications::notifications().map(Message::NotificationEvent),
activation_token_subscription(0).map(Message::Token),
listen_with(|e, _| {
if let cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
wayland::Event::Popup(wayland::PopupEvent::Done, _, id),
)) = e
{
Some(Message::CloseRequested(id))
} else {
None
}
}),
])
}

Expand Down Expand Up @@ -527,10 +539,6 @@ impl cosmic::Application for Notifications {

self.core.applet.popup_container(content).into()
}

fn on_close_requested(&self, id: window::Id) -> Option<Message> {
Some(Message::CloseRequested(id))
}
}

fn text_icon(name: &str, size: u16) -> cosmic::widget::Icon {
Expand Down
20 changes: 9 additions & 11 deletions cosmic-applet-power/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,15 @@ impl cosmic::Application for Power {
)
}

fn on_close_requested(&self, id: window::Id) -> Option<Message> {
Some(Message::Closed(id))
}

fn subscription(&self) -> Subscription<Message> {
let mut subscriptions = Vec::with_capacity(2);
subscriptions.push(listen_with(|e, _status| match e {
cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
wayland::Event::Layer(LayerEvent::Unfocused, ..),
)) => Some(Message::Cancel),
cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
wayland::Event::Popup(wayland::PopupEvent::Done, _, id),
)) => Some(Message::Closed(id)),
_ => None,
}));
if self.action_to_confirm.is_some() {
Expand Down Expand Up @@ -317,15 +316,14 @@ impl cosmic::Application for Power {
container(
container(content)
.style(cosmic::theme::Container::custom(|theme| {
let cosmic = theme.cosmic();
container::Appearance {
icon_color: Some(theme.cosmic().background.on.into()),
text_color: Some(theme.cosmic().background.on.into()),
background: Some(
Color::from(theme.cosmic().background.base).into(),
),
border_radius: 12.0.into(),
icon_color: Some(cosmic.background.on.into()),
text_color: Some(cosmic.background.on.into()),
background: Some(Color::from(cosmic.background.base).into()),
border_radius: cosmic.corner_radii.radius_m.into(),
border_width: 2.0,
border_color: theme.cosmic().bg_divider().into(),
border_color: cosmic.bg_divider().into(),
}
}))
.width(Length::Shrink)
Expand Down
17 changes: 13 additions & 4 deletions cosmic-applet-status-area/src/components/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use cosmic::{
},
window, Subscription,
},
iced_core::event::{wayland, PlatformSpecific},
iced_futures::event::listen_with,
iced_style::application,
Theme,
};
Expand Down Expand Up @@ -168,6 +170,17 @@ impl cosmic::Application for App {
subscriptions.push(menu.subscription().with(*id).map(Msg::StatusMenu));
}

subscriptions.push(listen_with(|e, _| {
if let cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
wayland::Event::Popup(wayland::PopupEvent::Done, _, id),
)) = e
{
Some(Msg::Closed(id))
} else {
None
}
}));

iced::Subscription::batch(subscriptions)
}

Expand Down Expand Up @@ -201,10 +214,6 @@ impl cosmic::Application for App {
None => iced::widget::text("").into(),
}
}

fn on_close_requested(&self, id: window::Id) -> Option<Msg> {
Some(Msg::Closed(id))
}
}

pub fn main() -> iced::Result {
Expand Down
20 changes: 15 additions & 5 deletions cosmic-applet-tiling/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use cosmic::cosmic_config::{ConfigGet, ConfigSet};
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced::window::Id;
use cosmic::iced::{Command, Length, Limits, Subscription};
use cosmic::iced_core::event::{wayland, PlatformSpecific};
use cosmic::iced_core::Alignment;
use cosmic::iced_futures::event::listen_with;
use cosmic::iced_style::application;
use cosmic::iced_widget::{column, row};
use cosmic::widget::{container, divider, spin_button, text};
Expand Down Expand Up @@ -76,16 +78,24 @@ impl cosmic::Application for Window {
(window, Command::none())
}

fn on_close_requested(&self, id: Id) -> Option<Message> {
Some(Message::PopupClosed(id))
}

fn subscription(&self) -> Subscription<Self::Message> {
let timeline = self
.timeline
.as_subscription()
.map(|(_, now)| Message::Frame(now));
Subscription::batch(vec![timeline])
Subscription::batch(vec![
timeline,
listen_with(|e, _| {
if let cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
wayland::Event::Popup(wayland::PopupEvent::Done, _, id),
)) = e
{
Some(Message::PopupClosed(id))
} else {
None
}
}),
])
}

fn update(&mut self, message: Self::Message) -> Command<cosmic::app::Message<Self::Message>> {
Expand Down
Loading
Loading