1
0
Fork 0
forked from wry/wry

globals: interfere singleton-ness from the Singleton enum

This commit is contained in:
Julian Orth 2026-03-05 15:25:28 +01:00
parent 1e55d89cc9
commit 1ef1b5a607
68 changed files with 34 additions and 264 deletions

View file

@ -135,10 +135,10 @@ pub trait GlobalBase {
version: Version,
) -> Result<(), GlobalsError>;
fn interface(&self) -> Interface;
fn singleton(&self) -> Option<Singleton>;
}
pub trait Global: GlobalBase {
fn singleton(&self) -> bool;
fn version(&self) -> u32;
fn required_caps(&self) -> ClientCaps {
ClientCaps::none()
@ -168,6 +168,15 @@ macro_rules! singletons {
globals.singletons[Singleton::$name] = name;
)*
}
#[expect(non_upper_case_globals)]
pub mod interface_singletons {
pub use crate::wire::interface_singletons::*;
$(
pub const $name: Option<crate::globals::Singleton> = Some(crate::globals::Singleton::$name);
)*
}
};
}
@ -328,7 +337,7 @@ impl Globals {
macro_rules! emit {
($singleton:expr) => {
for global in globals.values() {
if global.singleton() == $singleton {
if global.singleton().is_some() == $singleton {
if global.exposed(&registry.client.state)
&& caps.contains(global.required_caps())
&& (xwayland || !global.xwayland_only())