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

wip: dbus activation & single instance support #203

Merged
merged 3 commits into from
Nov 18, 2023
Merged
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
15 changes: 11 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ animated-image = ["image", "dep:async-fs", "tokio?/io-util", "tokio?/fs"]
debug = ["iced/debug"]
# Enables pipewire support in ashpd, if ashpd is enabled
pipewire = ["ashpd?/pipewire"]
# Enables process spawning helper
process = ["nix"]
# Enables keycode serialization
serde-keycode = ["iced_core/serde"]
# smol async runtime
smol = ["iced/smol"]
smol = ["iced/smol", "zbus?/async-io"]
# Tokio async runtime
tokio = ["dep:tokio", "ashpd/tokio", "iced/tokio"]
tokio = ["dep:tokio", "ashpd/tokio", "iced/tokio", "zbus?/tokio"]
# Wayland window support
wayland = [
"ashpd?/wayland",
"iced_runtime/wayland",
"iced/wayland",
"iced_sctk",
"sctk",
"cctk",
]
# Render with wgpu
wgpu = ["iced/wgpu", "iced_wgpu"]
Expand All @@ -40,14 +42,16 @@ winit_wgpu = ["winit", "wgpu"]
xdg-portal = ["ashpd"]
# XXX Use "a11y"; which is causing a panic currently
applet = ["wayland", "tokio", "cosmic-panel-config", "ron"]
applet-token = []
single-instance = ["dep:zbus", "serde", "ron"]

[dependencies]
apply = "0.3.0"
derive_setters = "0.1.5"
lazy_static = "1.4.0"
palette = "0.7.3"
tokio = { version = "1.24.2", optional = true }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", optional = true, rev = "dc8c4a0" }
cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "5faec87", optional = true }
slotmap = "1.0.6"
fraction = "0.13.0"
cosmic-config = { path = "cosmic-config" }
Expand All @@ -59,6 +63,9 @@ ashpd = { version = "0.5.0", default-features = false, optional = true }
url = "2.4.0"
unicode-segmentation = "1.6"
css-color = "0.2.5"
nix = { version = "0.26", optional = true }
zbus = {version = "3.14.1", default-features = false, optional = true}
serde = { version = "1.0.180", optional = true }

[target.'cfg(unix)'.dependencies]
freedesktop-icons = "0.2.4"
Expand Down
3 changes: 3 additions & 0 deletions src/app/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ pub struct Core {

#[cfg(feature = "applet")]
pub applet: crate::applet::Context,

pub single_instance: bool,
}

impl Default for Core {
Expand Down Expand Up @@ -104,6 +106,7 @@ impl Default for Core {
},
#[cfg(feature = "applet")]
applet: crate::applet::Context::default(),
single_instance: false,
}
}
}
Expand Down
19 changes: 17 additions & 2 deletions src/app/cosmic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use super::{command, Application, ApplicationExt, Core, Subscription};
use crate::theme::{self, Theme, ThemeType, THEME};
use crate::widget::nav_bar;
use crate::{keyboard_nav, Element};
#[cfg(feature = "wayland")]
use cctk::sctk::reexports::csd_frame::{WindowManagerCapabilities, WindowState};
use cosmic_theme::ThemeMode;
#[cfg(feature = "wayland")]
use iced::event::wayland::{self, WindowEvent};
Expand All @@ -15,8 +17,6 @@ use iced::window;
use iced_runtime::command::Action;
#[cfg(not(feature = "wayland"))]
use iced_runtime::window::Action as WindowAction;
#[cfg(feature = "wayland")]
use sctk::reexports::csd_frame::{WindowManagerCapabilities, WindowState};

/// A message managed internally by COSMIC.
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -55,6 +55,8 @@ pub enum Message {
/// Capabilities the window manager supports
#[cfg(feature = "wayland")]
WmCapabilities(window::Id, WindowManagerCapabilities),
/// Activate the application
Activate(String),
}

#[derive(Default)]
Expand Down Expand Up @@ -177,6 +179,12 @@ where
})
.map(super::Message::Cosmic),
window_events.map(super::Message::Cosmic),
#[cfg(feature = "single-instance")]
self.app
.core()
.single_instance
.then(|| super::single_instance_subscription::<T>())
.unwrap_or_else(Subscription::none),
])
}

Expand Down Expand Up @@ -356,6 +364,13 @@ impl<T: Application> Cosmic<T> {
});
}
}
Message::Activate(token) => {
#[cfg(feature = "wayland")]
return iced_sctk::commands::activation::activate(
iced::window::Id::default(),
token,
);
}
}

iced::Command::none()
Expand Down
Loading
Loading