Separate theme rendering from client subscriptions and materials

This commit is contained in:
Samuel Onoja committed 2026-10-03 00:12:59 +01:00
1 parent ccf7497b6f
commit cc0bddbec1
32 files changed
+428 -143

No files matched your search

+1
View File
@@ -6,6 +6,7 @@ license.workspace = true
rust-version.workspace = true
[dependencies]
ferese-theme-client = { path = "../../crates/ferese-theme-client" }
ferese-ipc = { path = "../../crates/ferese-ipc" }
serde_json.workspace = true
ferese-theme = { path = "../../crates/ferese-theme" }
+1 -1
View File
@@ -29,7 +29,7 @@ impl Appearance {
let doc = path
.and_then(|path| std::fs::read_to_string(path).ok())
.and_then(|source| Document::parse(&source).ok());
let mut theme = ferese_theme::service::current().presented;
let mut theme = ferese_theme_client::service::current().presented;
if let Some(path) = path.filter(|path| ferese_config::config_path().as_deref() != Some(*path))
&& let Some(document) = &doc
&& let Ok(mut connection) = ferese_ipc::theme::Connection::connect()
+1 -1
View File
@@ -192,7 +192,7 @@ impl cosmic::Application for Locker {
if self.preview {
Subscription::none()
} else {
ferese_theme::service::subscription().map(|snapshot| Message::ThemeChanged(Box::new(snapshot)))
ferese_theme_client::service::subscription().map(|snapshot| Message::ThemeChanged(Box::new(snapshot)))
},
event::listen_with(|event, _, _| match event {
Event::PlatformSpecific(PlatformSpecific::Wayland(
+1
View File
@@ -6,6 +6,7 @@ license.workspace = true
rust-version.workspace = true
[dependencies]
ferese-theme-client = { path = "../../crates/ferese-theme-client" }
ferese-ipc = { path = "../../crates/ferese-ipc" }
ferese-config = { path = "../../crates/ferese-config" }
ferese-theme = { path = "../../crates/ferese-theme" }
+6 -6
View File
@@ -26,7 +26,7 @@ struct Appearance {
impl Appearance {
fn load() -> Self {
let snapshot = ferese_theme::service::current();
let snapshot = ferese_theme_client::service::current();
Self::from_resolved(&snapshot.presented)
}
@@ -37,7 +37,7 @@ impl Appearance {
appearance: theme.appearance,
high_contrast: theme.accessibility.increase_contrast,
surface: Color {
a: ferese_theme::service::opacity(theme),
a: ferese_theme::material_opacity(theme),
..palette.sidebar
},
text: palette.text,
@@ -74,7 +74,7 @@ impl Appearance {
enum Message {
ThemeChanged(Box<ferese_ipc::theme::Snapshot>),
WindowOpened(cosmic::iced::window::Id),
MaterialAttached(Result<ferese_theme::material::ModalMaterial, String>),
MaterialAttached(Result<ferese_theme_client::material::ModalMaterial, String>),
Tick,
Input(String),
Submit,
@@ -91,7 +91,7 @@ impl std::fmt::Debug for Message {
struct Prompt {
core: Core,
material: Option<ferese_theme::material::ModalMaterial>,
material: Option<ferese_theme_client::material::ModalMaterial>,
appearance: Appearance,
incoming: Arc<Mutex<VecDeque<PromptEvent>>>,
request: AuthenticationRequest,
@@ -302,7 +302,7 @@ impl cosmic::Application for Prompt {
fn subscription(&self) -> Subscription<Message> {
Subscription::batch([
ferese_theme::service::subscription().map(|snapshot| Message::ThemeChanged(Box::new(snapshot))),
ferese_theme_client::service::subscription().map(|snapshot| Message::ThemeChanged(Box::new(snapshot))),
cosmic::iced::time::every(Duration::from_millis(30)).map(|_| Message::Tick),
cosmic::iced::event::listen_with(|event, _, id| match event {
cosmic::iced::Event::Window(cosmic::iced::window::Event::Opened { .. }) => {
@@ -320,7 +320,7 @@ impl cosmic::Application for Prompt {
return cosmic::command::set_theme(self.appearance.theme());
}
Message::WindowOpened(id) => {
return cosmic::iced::window::run(id, ferese_theme::material::ModalMaterial::attach)
return cosmic::iced::window::run(id, ferese_theme_client::material::ModalMaterial::attach)
.map(|result| cosmic::Action::App(Message::MaterialAttached(result)));
}
Message::MaterialAttached(result) => {
+1
View File
@@ -6,6 +6,7 @@ license.workspace = true
rust-version.workspace = true
[dependencies]
ferese-theme-client = { path = "../../crates/ferese-theme-client" }
ferese-theme = { path = "../../crates/ferese-theme" }
ferese-config = { path = "../../crates/ferese-config" }
libcosmic = { workspace = true, features = ["wgpu", "a11y", "xdg-portal"] }
+2 -2
View File
@@ -214,7 +214,7 @@ impl cosmic::Application for App {
.into();
let error = initial.as_ref().err().cloned();
let current = initial.unwrap_or_else(|_| Snapshot::parse(String::new()).unwrap());
let resolved = ferese_theme::service::current();
let resolved = ferese_theme_client::service::current();
let font = ferese_theme::font(Some(&resolved.presented.tokens.typography.font_family));
let native_palette = visuals::Palette::from_resolved(&resolved.presented);
let mut app = Self {
@@ -815,7 +815,7 @@ impl cosmic::Application for App {
fn subscription(&self) -> cosmic::iced::Subscription<Message> {
cosmic::iced::Subscription::batch([
cosmic::iced::Subscription::run_with(self.path.clone(), |path| watch::changes(path)),
ferese_theme::service::subscription().map(|snapshot| Message::ThemeChanged(Box::new(snapshot))),
ferese_theme_client::service::subscription().map(|snapshot| Message::ThemeChanged(Box::new(snapshot))),
if self.page == Page::Displays {
cosmic::iced::time::every(std::time::Duration::from_secs(2)).map(|_| Message::RefreshDisplays)
} else {
+2 -2
View File
@@ -22,7 +22,7 @@ fn hex(c: Color) -> String {
}
pub fn native_theme(_snapshot: Option<&Snapshot>) -> cosmic::Theme {
Palette::from_resolved(&ferese_theme::service::current().presented).native_theme()
Palette::from_resolved(&ferese_theme_client::service::current().presented).native_theme()
}
pub fn icon(page: Page, tint: Color) -> svg_icon::Icon {
@@ -41,7 +41,7 @@ pub fn action_icon(path: &str, tint: Color) -> svg_icon::Icon {
}
#[cfg(test)]
pub use ferese_theme::PRESETS;
pub use ferese_config::presets::PRESETS;
pub fn split(snapshot: &Snapshot) -> bool {
snapshot
+1
View File
@@ -6,6 +6,7 @@ license.workspace = true
rust-version.workspace = true
[dependencies]
ferese-theme-client = { path = "../../crates/ferese-theme-client" }
ferese-ipc = { path = "../../crates/ferese-ipc" }
ferese-theme = { path = "../../crates/ferese-theme" }
ferese-config = { path = "../../crates/ferese-config" }
+1 -1
View File
@@ -341,7 +341,7 @@ pub(crate) fn load() -> ShellConfig {
pub(crate) fn parse_source(source: &str) -> Result<ShellConfig, ferese_config::Error> {
let document = ferese_config::Document::parse(source)?;
let snapshot = ferese_theme::service::current();
let snapshot = ferese_theme_client::service::current();
let mut config = parse_document(
&document.with_theme(&snapshot.presented),
snapshot.presented.appearance,
+1 -1
View File
@@ -354,7 +354,7 @@ impl cosmic::Application for FereseShell {
self.control.as_ref().map_or_else(Subscription::none, |control| {
control.subscription().map(|_| Message::ControlReady)
}),
ferese_theme::service::subscription().map(|snapshot| Message::ThemeChanged(Box::new(snapshot))),
ferese_theme_client::service::subscription().map(|snapshot| Message::ThemeChanged(Box::new(snapshot))),
if self
.system_modal
.as_ref()