toplevel: add property_changed_source
This commit is contained in:
parent
3a03e3c584
commit
603ed6852f
2 changed files with 17 additions and 3 deletions
|
|
@ -34,6 +34,7 @@ use {
|
||||||
array_to_tuple::ArrayToTuple,
|
array_to_tuple::ArrayToTuple,
|
||||||
clonecell::CloneCell,
|
clonecell::CloneCell,
|
||||||
copyhashmap::CopyHashMap,
|
copyhashmap::CopyHashMap,
|
||||||
|
event_listener::LazyEventSource,
|
||||||
hash_map_ext::HashMapExt,
|
hash_map_ext::HashMapExt,
|
||||||
numcell::NumCell,
|
numcell::NumCell,
|
||||||
rc_eq::rc_eq,
|
rc_eq::rc_eq,
|
||||||
|
|
@ -48,7 +49,7 @@ use {
|
||||||
jay_config::{window, window::WindowType},
|
jay_config::{window, window::WindowType},
|
||||||
std::{
|
std::{
|
||||||
borrow::Borrow,
|
borrow::Borrow,
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, OnceCell, RefCell},
|
||||||
ops::Deref,
|
ops::Deref,
|
||||||
rc::{Rc, Weak},
|
rc::{Rc, Weak},
|
||||||
},
|
},
|
||||||
|
|
@ -404,6 +405,7 @@ pub struct ToplevelData {
|
||||||
pub just_mapped_scheduled: Cell<bool>,
|
pub just_mapped_scheduled: Cell<bool>,
|
||||||
pub seat_foci: CopyHashMap<SeatId, ()>,
|
pub seat_foci: CopyHashMap<SeatId, ()>,
|
||||||
pub content_type: Cell<Option<ContentType>>,
|
pub content_type: Cell<Option<ContentType>>,
|
||||||
|
pub property_changed_source: OnceCell<Rc<LazyEventSource>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToplevelData {
|
impl ToplevelData {
|
||||||
|
|
@ -457,6 +459,7 @@ impl ToplevelData {
|
||||||
just_mapped_scheduled: Cell::new(false),
|
just_mapped_scheduled: Cell::new(false),
|
||||||
seat_foci: Default::default(),
|
seat_foci: Default::default(),
|
||||||
content_type: Default::default(),
|
content_type: Default::default(),
|
||||||
|
property_changed_source: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -497,7 +500,14 @@ impl ToplevelData {
|
||||||
(width, height)
|
(width, height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn trigger_property_source(&self) {
|
||||||
|
if let Some(source) = self.property_changed_source.get() {
|
||||||
|
source.trigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn property_changed(&self, change: TlMatcherChange) {
|
pub fn property_changed(&self, change: TlMatcherChange) {
|
||||||
|
self.trigger_property_source();
|
||||||
let mgr = &self.state.tl_matcher_manager;
|
let mgr = &self.state.tl_matcher_manager;
|
||||||
let props = self.changed_properties.get();
|
let props = self.changed_properties.get();
|
||||||
if props.is_none() && mgr.has_no_interest(self, change) {
|
if props.is_none() && mgr.has_no_interest(self, change) {
|
||||||
|
|
@ -925,6 +935,12 @@ impl ToplevelData {
|
||||||
};
|
};
|
||||||
parent.node_is_workspace()
|
parent.node_is_workspace()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[expect(dead_code)]
|
||||||
|
pub fn property_changed_source(&self) -> &Rc<LazyEventSource> {
|
||||||
|
self.property_changed_source
|
||||||
|
.get_or_init(|| self.state.lazy_event_sources.create_source())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for ToplevelData {
|
impl Drop for ToplevelData {
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,6 @@ impl Deref for LazyEventSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LazyEventSource {
|
impl LazyEventSource {
|
||||||
#[expect(dead_code)]
|
|
||||||
pub fn trigger(self: &Rc<Self>) {
|
pub fn trigger(self: &Rc<Self>) {
|
||||||
if self.listeners.is_empty() {
|
if self.listeners.is_empty() {
|
||||||
return;
|
return;
|
||||||
|
|
@ -142,7 +141,6 @@ impl LazyEventSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LazyEventSources {
|
impl LazyEventSources {
|
||||||
#[expect(dead_code)]
|
|
||||||
pub fn create_source(self: &Rc<Self>) -> Rc<LazyEventSource> {
|
pub fn create_source(self: &Rc<Self>) -> Rc<LazyEventSource> {
|
||||||
Rc::new(LazyEventSource {
|
Rc::new(LazyEventSource {
|
||||||
sources: self.clone(),
|
sources: self.clone(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue