wayland: register most singletons before starting async work
This commit is contained in:
parent
6ccb555638
commit
f7e77ca94c
2 changed files with 13 additions and 5 deletions
|
|
@ -227,7 +227,7 @@ async fn start_compositor3(state: Rc<State>, test_future: Option<TestFuture>) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
state.backend.set(backend.clone());
|
state.backend.set(backend.clone());
|
||||||
state.globals.add_singletons(&backend);
|
state.globals.add_backend_singletons(&backend);
|
||||||
|
|
||||||
if backend.import_environment() {
|
if backend.import_environment() {
|
||||||
if let Some(acc) = state.acceptor.get() {
|
if let Some(acc) = state.acceptor.get() {
|
||||||
|
|
|
||||||
|
|
@ -109,12 +109,14 @@ pub struct Globals {
|
||||||
|
|
||||||
impl Globals {
|
impl Globals {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
let slf = Self {
|
||||||
next_name: NumCell::new(1),
|
next_name: NumCell::new(1),
|
||||||
registry: CopyHashMap::new(),
|
registry: CopyHashMap::new(),
|
||||||
outputs: Default::default(),
|
outputs: Default::default(),
|
||||||
seats: Default::default(),
|
seats: Default::default(),
|
||||||
}
|
};
|
||||||
|
slf.add_singletons();
|
||||||
|
slf
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear(&self) {
|
pub fn clear(&self) {
|
||||||
|
|
@ -123,7 +125,7 @@ impl Globals {
|
||||||
self.seats.clear();
|
self.seats.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_singletons(&self, backend: &Rc<dyn Backend>) {
|
fn add_singletons(&self) {
|
||||||
macro_rules! add_singleton {
|
macro_rules! add_singleton {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
self.add_global_no_broadcast(&Rc::new($name::new(self.name())));
|
self.add_global_no_broadcast(&Rc::new($name::new(self.name())));
|
||||||
|
|
@ -145,11 +147,17 @@ impl Globals {
|
||||||
add_singleton!(ExtSessionLockManagerV1Global);
|
add_singleton!(ExtSessionLockManagerV1Global);
|
||||||
add_singleton!(WpViewporterGlobal);
|
add_singleton!(WpViewporterGlobal);
|
||||||
add_singleton!(WpFractionalScaleManagerV1Global);
|
add_singleton!(WpFractionalScaleManagerV1Global);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_backend_singletons(&self, backend: &Rc<dyn Backend>) {
|
||||||
|
macro_rules! add_singleton {
|
||||||
|
($name:ident) => {
|
||||||
|
self.add_global_no_broadcast(&Rc::new($name::new(self.name())));
|
||||||
|
};
|
||||||
|
}
|
||||||
if backend.supports_idle() {
|
if backend.supports_idle() {
|
||||||
add_singleton!(ZwpIdleInhibitManagerV1Global);
|
add_singleton!(ZwpIdleInhibitManagerV1Global);
|
||||||
}
|
}
|
||||||
|
|
||||||
if backend.supports_presentation_feedback() {
|
if backend.supports_presentation_feedback() {
|
||||||
add_singleton!(WpPresentationGlobal);
|
add_singleton!(WpPresentationGlobal);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue