1
0
Fork 0
forked from wry/wry

Merge pull request #773 from mahkoh/jorth/infer-singleton

globals: send to old registries when exposed changes
This commit is contained in:
mahkoh 2026-03-05 17:22:13 +01:00 committed by GitHub
commit 3b3293675b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
72 changed files with 115 additions and 285 deletions

View file

@ -299,12 +299,17 @@ fn write_request_handler<W: Write>(
Ok(()) Ok(())
} }
fn write_file<W: Write>(f: &mut W, file: &DirEntry) -> Result<()> { fn write_file<W: Write>(
f: &mut W,
file: &DirEntry,
interface_names: &mut Vec<String>,
) -> Result<()> {
let file_name = file.file_name(); let file_name = file.file_name();
let file_name = std::str::from_utf8(file_name.as_bytes())?; let file_name = std::str::from_utf8(file_name.as_bytes())?;
println!("cargo:rerun-if-changed=wire/{}", file_name); println!("cargo:rerun-if-changed=wire/{}", file_name);
let obj_name = file_name.split(".").next().unwrap(); let obj_name = file_name.split(".").next().unwrap();
let camel_obj_name = to_camel(obj_name); let camel_obj_name = to_camel(obj_name);
interface_names.push(camel_obj_name.clone());
writeln!(f)?; writeln!(f)?;
writeln!(f, "id!({}Id);", camel_obj_name)?; writeln!(f, "id!({}Id);", camel_obj_name)?;
writeln!(f)?; writeln!(f)?;
@ -355,9 +360,21 @@ pub fn main() -> Result<()> {
files.push(file?); files.push(file?);
} }
files.sort_by_key(|f| f.file_name()); files.sort_by_key(|f| f.file_name());
let mut interface_names = vec![];
for file in files { for file in files {
write_file(&mut f, &file) write_file(&mut f, &file, &mut interface_names)
.with_context(|| format!("While processing {}", file.path().display()))?; .with_context(|| format!("While processing {}", file.path().display()))?;
} }
writeln!(f)?;
writeln!(f, "#[doc(hidden)]")?;
writeln!(f, "#[expect(dead_code)]")?;
writeln!(f, "pub mod interface_singletons {{")?;
for interface in &interface_names {
writeln!(
f,
" pub const {interface}: Option<crate::globals::Singleton> = None;"
)?;
}
writeln!(f, "}}")?;
Ok(()) Ok(())
} }

View file

@ -1155,11 +1155,11 @@ impl ConfigProxyHandler {
} }
fn handle_set_explicit_sync_enabled(&self, enabled: bool) { fn handle_set_explicit_sync_enabled(&self, enabled: bool) {
self.state.explicit_sync_enabled.set(enabled); self.state.set_explicit_sync_enabled(enabled);
} }
fn handle_set_color_management_enabled(&self, enabled: bool) { fn handle_set_color_management_enabled(&self, enabled: bool) {
self.state.color_management_enabled.set(enabled); self.state.set_color_management_enabled(enabled);
} }
fn handle_get_socket_path(&self) { fn handle_get_socket_path(&self) {
@ -2366,7 +2366,7 @@ impl ConfigProxyHandler {
} }
fn handle_set_middle_click_paste_enabled(&self, enabled: bool) { fn handle_set_middle_click_paste_enabled(&self, enabled: bool) {
self.state.enable_primary_selection.set(enabled); self.state.set_primary_selection_enabled(enabled);
} }
fn handle_seat_create_mark(&self, seat: Seat, kc: Option<u32>) -> Result<(), CphError> { fn handle_seat_create_mark(&self, seat: Seat, kc: Option<u32>) -> Result<(), CphError> {

View file

@ -80,6 +80,7 @@ use {
numcell::NumCell, numcell::NumCell,
}, },
}, },
arrayvec::ArrayVec,
linearize::{Linearize, StaticMap}, linearize::{Linearize, StaticMap},
std::{ std::{
error::Error, error::Error,
@ -135,10 +136,10 @@ pub trait GlobalBase {
version: Version, version: Version,
) -> Result<(), GlobalsError>; ) -> Result<(), GlobalsError>;
fn interface(&self) -> Interface; fn interface(&self) -> Interface;
fn singleton(&self) -> Option<Singleton>;
} }
pub trait Global: GlobalBase { pub trait Global: GlobalBase {
fn singleton(&self) -> bool;
fn version(&self) -> u32; fn version(&self) -> u32;
fn required_caps(&self) -> ClientCaps { fn required_caps(&self) -> ClientCaps {
ClientCaps::none() ClientCaps::none()
@ -150,6 +151,12 @@ pub trait Global: GlobalBase {
let _ = state; let _ = state;
true true
} }
fn permitted(&self, caps: ClientCaps, xwayland: bool) -> bool {
caps.contains(self.required_caps()) && (xwayland || !self.xwayland_only())
}
fn not_permitted(&self, caps: ClientCaps, xwayland: bool) -> bool {
!self.permitted(caps, xwayland)
}
} }
macro_rules! singletons { macro_rules! singletons {
@ -168,6 +175,15 @@ macro_rules! singletons {
globals.singletons[Singleton::$name] = name; 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);
)*
}
}; };
} }
@ -239,7 +255,7 @@ pub struct Globals {
removed: CopyHashMap<GlobalName, Rc<dyn Global>>, removed: CopyHashMap<GlobalName, Rc<dyn Global>>,
pub outputs: CopyHashMap<GlobalName, Rc<WlOutputGlobal>>, pub outputs: CopyHashMap<GlobalName, Rc<WlOutputGlobal>>,
pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>, pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>,
pub singletons: StaticMap<Singleton, GlobalName>, singletons: StaticMap<Singleton, GlobalName>,
} }
impl Globals { impl Globals {
@ -281,7 +297,7 @@ impl Globals {
fn insert(&self, state: &State, global: Rc<dyn Global>) { fn insert(&self, state: &State, global: Rc<dyn Global>) {
self.insert_no_broadcast_(&global); self.insert_no_broadcast_(&global);
self.broadcast(state, global.required_caps(), global.xwayland_only(), |r| { self.broadcast(state, global.required_caps(), global.xwayland_only(), |r| {
r.send_global(&global) r.handle_global(&global)
}); });
} }
@ -292,9 +308,7 @@ impl Globals {
allow_xwayland_only: bool, allow_xwayland_only: bool,
) -> Result<Rc<dyn Global>, GlobalsError> { ) -> Result<Rc<dyn Global>, GlobalsError> {
let global = self.take(name, false)?; let global = self.take(name, false)?;
if client_caps.not_contains(global.required_caps()) if global.not_permitted(client_caps, allow_xwayland_only) {
|| (global.xwayland_only() && !allow_xwayland_only)
{
return Err(GlobalsError::GlobalDoesNotExist(name)); return Err(GlobalsError::GlobalDoesNotExist(name));
} }
Ok(global) Ok(global)
@ -312,7 +326,7 @@ impl Globals {
assert_eq!(global.interface().0, replacement.interface().0); assert_eq!(global.interface().0, replacement.interface().0);
self.removed.set(global.name(), replacement); self.removed.set(global.name(), replacement);
self.broadcast(state, global.required_caps(), global.xwayland_only(), |r| { self.broadcast(state, global.required_caps(), global.xwayland_only(), |r| {
r.send_global_remove(global.name()) r.handle_global_removed(&**global)
}); });
Ok(()) Ok(())
} }
@ -328,12 +342,11 @@ impl Globals {
macro_rules! emit { macro_rules! emit {
($singleton:expr) => { ($singleton:expr) => {
for global in globals.values() { for global in globals.values() {
if global.singleton() == $singleton { if global.singleton().is_some() == $singleton {
if global.exposed(&registry.client.state) if global.exposed(&registry.client.state)
&& caps.contains(global.required_caps()) && global.permitted(caps, xwayland)
&& (xwayland || !global.xwayland_only())
{ {
registry.send_global(global); registry.handle_global(global);
} }
} }
} }
@ -391,6 +404,29 @@ impl Globals {
global.clone().add(self); global.clone().add(self);
self.insert_no_broadcast(global.clone()); self.insert_no_broadcast(global.clone());
} }
pub fn expose_new_singletons(&self, state: &State) {
let mut singletons = ArrayVec::<_, { Singleton::LENGTH }>::new();
for name in self.singletons.values() {
if let Some(global) = self.registry.get(name)
&& global.exposed(state)
{
singletons.push(global);
}
}
for client in state.clients.clients.borrow().values() {
let client = &client.data;
let caps = client.effective_caps.get();
let xwayland = client.is_xwayland;
for global in &singletons {
if global.permitted(caps, xwayland) {
for registry in client.objects.registries.lock().values() {
registry.handle_global(global);
}
}
}
}
}
} }
pub trait WaylandGlobal: Global + 'static { pub trait WaylandGlobal: Global + 'static {

View file

@ -283,10 +283,6 @@ global_base!(
); );
impl Global for WpColorManagerV1Global { impl Global for WpColorManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
2 2
} }

View file

@ -79,10 +79,6 @@ global_base!(
); );
impl Global for ExtForeignToplevelImageCaptureSourceManagerV1Global { impl Global for ExtForeignToplevelImageCaptureSourceManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -134,10 +134,6 @@ global_base!(
); );
impl Global for ExtForeignToplevelListV1Global { impl Global for ExtForeignToplevelListV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -140,10 +140,6 @@ global_base!(
); );
impl Global for ExtIdleNotifierV1Global { impl Global for ExtIdleNotifierV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
2 2
} }

View file

@ -142,10 +142,6 @@ global_base!(
); );
impl Global for ExtImageCopyCaptureManagerV1Global { impl Global for ExtImageCopyCaptureManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -76,10 +76,6 @@ global_base!(
); );
impl Global for ExtOutputImageCaptureSourceManagerV1Global { impl Global for ExtOutputImageCaptureSourceManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -91,10 +91,6 @@ global_base!(
); );
impl Global for ExtSessionLockManagerV1Global { impl Global for ExtSessionLockManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -62,10 +62,6 @@ global_base!(
simple_add_global!(JayHeadManagerV1Global); simple_add_global!(JayHeadManagerV1Global);
impl Global for JayHeadManagerV1Global { impl Global for JayHeadManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -102,10 +102,6 @@ global_base!(
); );
impl Global for ExtDataControlManagerV1Global { impl Global for ExtDataControlManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -102,10 +102,6 @@ global_base!(
); );
impl Global for ZwlrDataControlManagerV1Global { impl Global for ZwlrDataControlManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
2 2
} }

View file

@ -95,10 +95,6 @@ global_base!(
); );
impl Global for WlDataDeviceManagerGlobal { impl Global for WlDataDeviceManagerGlobal {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
4 4
} }

View file

@ -90,10 +90,6 @@ global_base!(
); );
impl Global for ZwpPrimarySelectionDeviceManagerV1Global { impl Global for ZwpPrimarySelectionDeviceManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -49,8 +49,7 @@ impl JayColorManagementRequestHandler for JayColorManagement {
fn set_enabled(&self, req: SetEnabled, _slf: &Rc<Self>) -> Result<(), Self::Error> { fn set_enabled(&self, req: SetEnabled, _slf: &Rc<Self>) -> Result<(), Self::Error> {
self.client self.client
.state .state
.color_management_enabled .set_color_management_enabled(req.enabled != 0);
.set(req.enabled != 0);
Ok(()) Ok(())
} }
} }

View file

@ -75,10 +75,6 @@ impl JayCompositorGlobal {
global_base!(JayCompositorGlobal, JayCompositor, JayCompositorError); global_base!(JayCompositorGlobal, JayCompositor, JayCompositorError);
impl Global for JayCompositorGlobal { impl Global for JayCompositorGlobal {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
25 25
} }

View file

@ -53,10 +53,6 @@ global_base!(
); );
impl Global for JayDamageTrackingGlobal { impl Global for JayDamageTrackingGlobal {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -54,10 +54,6 @@ global_base!(
); );
impl Global for JayPopupExtManagerV1Global { impl Global for JayPopupExtManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -50,10 +50,6 @@ impl JayTrayV1Global {
global_base!(JayTrayV1Global, JayTrayV1, JayTrayManagerV1Error); global_base!(JayTrayV1Global, JayTrayV1, JayTrayManagerV1Error);
impl Global for JayTrayV1Global { impl Global for JayTrayV1Global {
fn singleton(&self) -> bool {
false
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -53,10 +53,6 @@ global_base!(
); );
impl Global for OrgKdeKwinServerDecorationManagerGlobal { impl Global for OrgKdeKwinServerDecorationManagerGlobal {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -79,10 +79,6 @@ impl WlCompositorRequestHandler for WlCompositor {
global_base!(WlCompositorGlobal, WlCompositor, WlCompositorError); global_base!(WlCompositorGlobal, WlCompositor, WlCompositorError);
impl Global for WlCompositorGlobal { impl Global for WlCompositorGlobal {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
7 7
} }

View file

@ -56,10 +56,6 @@ impl WlDrmGlobal {
global_base!(WlDrmGlobal, WlDrm, WlDrmError); global_base!(WlDrmGlobal, WlDrm, WlDrmError);
impl Global for WlDrmGlobal { impl Global for WlDrmGlobal {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
2 2
} }

View file

@ -42,10 +42,6 @@ global_base!(WlFixesGlobal, WlFixes, WlFixesError);
simple_add_global!(WlFixesGlobal); simple_add_global!(WlFixesGlobal);
impl Global for WlFixesGlobal { impl Global for WlFixesGlobal {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -423,10 +423,6 @@ global_base!(WlOutputGlobal, WlOutput, WlOutputError);
const OUTPUT_VERSION: u32 = 4; const OUTPUT_VERSION: u32 = 4;
impl Global for WlOutputGlobal { impl Global for WlOutputGlobal {
fn singleton(&self) -> bool {
false
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
OUTPUT_VERSION OUTPUT_VERSION
} }

View file

@ -38,10 +38,6 @@ impl RemovedOutputGlobal {
global_base!(RemovedOutputGlobal, WlOutput, RemovedOutputError); global_base!(RemovedOutputGlobal, WlOutput, RemovedOutputError);
impl Global for RemovedOutputGlobal { impl Global for RemovedOutputGlobal {
fn singleton(&self) -> bool {
false
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
OUTPUT_VERSION OUTPUT_VERSION
} }

View file

@ -1,12 +1,13 @@
use { use {
crate::{ crate::{
client::Client, client::Client,
globals::{Global, GlobalName, GlobalsError}, globals::{Global, GlobalName, GlobalsError, Singleton},
leaks::Tracker, leaks::Tracker,
object::{Interface, Object, Version}, object::{Interface, Object, Version},
wire::{WlRegistryId, wl_registry::*}, wire::{WlRegistryId, wl_registry::*},
}, },
std::rc::Rc, linearize::StaticMap,
std::{cell::Cell, rc::Rc},
thiserror::Error, thiserror::Error,
}; };
@ -14,6 +15,7 @@ pub struct WlRegistry {
id: WlRegistryId, id: WlRegistryId,
pub client: Rc<Client>, pub client: Rc<Client>,
pub tracker: Tracker<Self>, pub tracker: Tracker<Self>,
advertised: StaticMap<Singleton, Cell<bool>>,
} }
impl WlRegistry { impl WlRegistry {
@ -22,23 +24,34 @@ impl WlRegistry {
id, id,
client: client.clone(), client: client.clone(),
tracker: Default::default(), tracker: Default::default(),
advertised: Default::default(),
} }
} }
pub fn send_global(self: &Rc<Self>, global: &Rc<dyn Global>) { pub fn handle_global(&self, global: &Rc<dyn Global>) {
if let Some(singleton) = global.singleton()
&& self.advertised[singleton].replace(true)
{
return;
}
self.client.event(crate::wire::wl_registry::Global { self.client.event(crate::wire::wl_registry::Global {
self_id: self.id, self_id: self.id,
name: global.name().raw(), name: global.name().raw(),
interface: global.interface().name(), interface: global.interface().name(),
version: global.version(), version: global.version(),
}) });
} }
pub fn send_global_remove(self: &Rc<Self>, name: GlobalName) { pub fn handle_global_removed(&self, global: &dyn Global) {
if let Some(singleton) = global.singleton()
&& !self.advertised[singleton].replace(false)
{
return;
}
self.client.event(GlobalRemove { self.client.event(GlobalRemove {
self_id: self.id, self_id: self.id,
name: name.raw(), name: global.name().raw(),
}) });
} }
} }

View file

@ -1599,10 +1599,6 @@ impl CursorUserOwner for WlSeatGlobal {
global_base!(WlSeatGlobal, WlSeat, WlSeatError); global_base!(WlSeatGlobal, WlSeat, WlSeatError);
impl Global for WlSeatGlobal { impl Global for WlSeatGlobal {
fn singleton(&self) -> bool {
false
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
10 10
} }

View file

@ -52,10 +52,6 @@ global_base!(
); );
impl Global for ExtTransientSeatManagerV1Global { impl Global for ExtTransientSeatManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -52,10 +52,6 @@ global_base!(
); );
impl Global for ZwpTabletManagerV2Global { impl Global for ZwpTabletManagerV2Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
2 2
} }

View file

@ -52,10 +52,6 @@ global_base!(
); );
impl Global for ZwpInputMethodManagerV2Global { impl Global for ZwpInputMethodManagerV2Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -52,10 +52,6 @@ global_base!(
); );
impl Global for ZwpTextInputManagerV3Global { impl Global for ZwpTextInputManagerV3Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -45,10 +45,6 @@ impl WpPointerWarpV1Global {
global_base!(WpPointerWarpV1Global, WpPointerWarpV1, WpPointerWarpV1Error); global_base!(WpPointerWarpV1Global, WpPointerWarpV1, WpPointerWarpV1Error);
impl Global for WpPointerWarpV1Global { impl Global for WpPointerWarpV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -313,10 +313,6 @@ global_base!(
); );
impl Global for ZwpPointerConstraintsV1Global { impl Global for ZwpPointerConstraintsV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -56,10 +56,6 @@ global_base!(
); );
impl Global for ZwpPointerGesturesV1Global { impl Global for ZwpPointerGesturesV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
3 3
} }

View file

@ -52,10 +52,6 @@ global_base!(
); );
impl Global for ZwpRelativePointerManagerV1Global { impl Global for ZwpRelativePointerManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -53,10 +53,6 @@ global_base!(
); );
impl Global for ZwpVirtualKeyboardManagerV1Global { impl Global for ZwpVirtualKeyboardManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -85,10 +85,6 @@ impl WlShmRequestHandler for WlShm {
global_base!(WlShmGlobal, WlShm, WlShmError); global_base!(WlShmGlobal, WlShm, WlShmError);
impl Global for WlShmGlobal { impl Global for WlShmGlobal {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
2 2
} }

View file

@ -70,10 +70,6 @@ impl WlSubcompositorRequestHandler for WlSubcompositor {
global_base!(WlSubcompositorGlobal, WlSubcompositor, WlSubcompositorError); global_base!(WlSubcompositorGlobal, WlSubcompositor, WlSubcompositorError);
impl Global for WlSubcompositorGlobal { impl Global for WlSubcompositorGlobal {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -79,10 +79,6 @@ impl XwaylandShellV1RequestHandler for XwaylandShellV1 {
global_base!(XwaylandShellV1Global, XwaylandShellV1, XwaylandShellV1Error); global_base!(XwaylandShellV1Global, XwaylandShellV1, XwaylandShellV1Error);
impl Global for XwaylandShellV1Global { impl Global for XwaylandShellV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -253,10 +253,6 @@ global_base!(
); );
impl Global for ZwlrOutputManagerV1Global { impl Global for ZwlrOutputManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
4 4
} }

View file

@ -211,10 +211,6 @@ global_base!(
); );
impl Global for ExtWorkspaceManagerV1Global { impl Global for ExtWorkspaceManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -75,10 +75,6 @@ global_base!(
); );
impl Global for WpAlphaModifierV1Global { impl Global for WpAlphaModifierV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -126,10 +126,6 @@ global_base!(
); );
impl Global for WpColorRepresentationManagerV1Global { impl Global for WpColorRepresentationManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -57,10 +57,6 @@ global_base!(
); );
impl Global for WpCommitTimingManagerV1Global { impl Global for WpCommitTimingManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -47,10 +47,6 @@ global_base!(
simple_add_global!(WpContentTypeManagerV1Global); simple_add_global!(WpContentTypeManagerV1Global);
impl Global for WpContentTypeManagerV1Global { impl Global for WpContentTypeManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -47,10 +47,6 @@ global_base!(
simple_add_global!(WpCursorShapeManagerV1Global); simple_add_global!(WpCursorShapeManagerV1Global);
impl Global for WpCursorShapeManagerV1Global { impl Global for WpCursorShapeManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
2 2
} }

View file

@ -77,10 +77,6 @@ global_base!(
simple_add_global!(WpDrmLeaseDeviceV1Global); simple_add_global!(WpDrmLeaseDeviceV1Global);
impl Global for WpDrmLeaseDeviceV1Global { impl Global for WpDrmLeaseDeviceV1Global {
fn singleton(&self) -> bool {
false
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -50,10 +50,6 @@ global_base!(
simple_add_global!(RemovedWpDrmLeaseDeviceV1Global); simple_add_global!(RemovedWpDrmLeaseDeviceV1Global);
impl Global for RemovedWpDrmLeaseDeviceV1Global { impl Global for RemovedWpDrmLeaseDeviceV1Global {
fn singleton(&self) -> bool {
false
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -48,10 +48,6 @@ impl WpFifoManagerV1Global {
global_base!(WpFifoManagerV1Global, WpFifoManagerV1, WpFifoManagerV1Error); global_base!(WpFifoManagerV1Global, WpFifoManagerV1, WpFifoManagerV1Error);
impl Global for WpFifoManagerV1Global { impl Global for WpFifoManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -52,10 +52,6 @@ global_base!(
); );
impl Global for WpFractionalScaleManagerV1Global { impl Global for WpFractionalScaleManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -59,10 +59,6 @@ global_base!(
); );
impl Global for WpLinuxDrmSyncobjManagerV1Global { impl Global for WpLinuxDrmSyncobjManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -44,10 +44,6 @@ impl WpPresentationGlobal {
global_base!(WpPresentationGlobal, WpPresentation, WpPresentationError); global_base!(WpPresentationGlobal, WpPresentation, WpPresentationError);
impl Global for WpPresentationGlobal { impl Global for WpPresentationGlobal {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
2 2
} }

View file

@ -45,10 +45,6 @@ global_base!(
); );
impl Global for WpSecurityContextManagerV1Global { impl Global for WpSecurityContextManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -45,10 +45,6 @@ global_base!(
); );
impl Global for WpSinglePixelBufferManagerV1Global { impl Global for WpSinglePixelBufferManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -45,10 +45,6 @@ global_base!(
); );
impl Global for WpTearingControlManagerV1Global { impl Global for WpTearingControlManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -41,10 +41,6 @@ impl WpViewporterGlobal {
global_base!(WpViewporterGlobal, WpViewporter, WpViewporterError); global_base!(WpViewporterGlobal, WpViewporter, WpViewporterError);
impl Global for WpViewporterGlobal { impl Global for WpViewporterGlobal {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -44,10 +44,6 @@ global_base!(XdgActivationV1Global, XdgActivationV1, XdgActivationV1Error);
simple_add_global!(XdgActivationV1Global); simple_add_global!(XdgActivationV1Global);
impl Global for XdgActivationV1Global { impl Global for XdgActivationV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -47,10 +47,6 @@ global_base!(
simple_add_global!(XdgToplevelDragManagerV1Global); simple_add_global!(XdgToplevelDragManagerV1Global);
impl Global for XdgToplevelDragManagerV1Global { impl Global for XdgToplevelDragManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -46,10 +46,6 @@ global_base!(
); );
impl Global for XdgToplevelTagManagerV1Global { impl Global for XdgToplevelTagManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -107,10 +107,6 @@ impl XdgWmBaseRequestHandler for XdgWmBase {
global_base!(XdgWmBaseGlobal, XdgWmBase, XdgWmBaseError); global_base!(XdgWmBaseGlobal, XdgWmBase, XdgWmBaseError);
impl Global for XdgWmBaseGlobal { impl Global for XdgWmBaseGlobal {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
7 7
} }

View file

@ -43,10 +43,6 @@ impl XdgWmDialogV1Global {
global_base!(XdgWmDialogV1Global, XdgWmDialogV1, XdgWmDialogV1Error); global_base!(XdgWmDialogV1Global, XdgWmDialogV1, XdgWmDialogV1Error);
impl Global for XdgWmDialogV1Global { impl Global for XdgWmDialogV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -126,10 +126,6 @@ global_base!(
); );
impl Global for ZwlrForeignToplevelManagerV1Global { impl Global for ZwlrForeignToplevelManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
3 3
} }

View file

@ -47,10 +47,6 @@ global_base!(
simple_add_global!(ZwlrGammaControlManagerV1Global); simple_add_global!(ZwlrGammaControlManagerV1Global);
impl Global for ZwlrGammaControlManagerV1Global { impl Global for ZwlrGammaControlManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -102,10 +102,6 @@ global_base!(
); );
impl Global for ZwlrLayerShellV1Global { impl Global for ZwlrLayerShellV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
5 5
} }

View file

@ -51,10 +51,6 @@ global_base!(
simple_add_global!(ZwlrScreencopyManagerV1Global); simple_add_global!(ZwlrScreencopyManagerV1Global);
impl Global for ZwlrScreencopyManagerV1Global { impl Global for ZwlrScreencopyManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
3 3
} }

View file

@ -48,10 +48,6 @@ global_base!(
); );
impl Global for ZwpIdleInhibitManagerV1Global { impl Global for ZwpIdleInhibitManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
1 1
} }

View file

@ -65,10 +65,6 @@ global_base!(
); );
impl Global for ZwpLinuxDmabufV1Global { impl Global for ZwpLinuxDmabufV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
5 5
} }

View file

@ -45,10 +45,6 @@ global_base!(
); );
impl Global for ZxdgDecorationManagerV1Global { impl Global for ZxdgDecorationManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
2 2
} }

View file

@ -77,10 +77,6 @@ global_base!(
); );
impl Global for ZxdgOutputManagerV1Global { impl Global for ZxdgOutputManagerV1Global {
fn singleton(&self) -> bool {
true
}
fn version(&self) -> u32 { fn version(&self) -> u32 {
3 3
} }

View file

@ -87,6 +87,10 @@ macro_rules! global_base {
fn interface(&self) -> crate::object::Interface { fn interface(&self) -> crate::object::Interface {
crate::wire::$ifname crate::wire::$ifname
} }
fn singleton(&self) -> Option<crate::globals::Singleton> {
crate::globals::interface_singletons::$ifname
}
} }
impl From<$ename> for crate::globals::GlobalError { impl From<$ename> for crate::globals::GlobalError {

View file

@ -736,6 +736,8 @@ impl State {
for sc in scs { for sc in scs {
sc.do_destroy(); sc.do_destroy();
} }
self.expose_new_singletons();
} }
fn reload_cursors(&self) { fn reload_cursors(&self) {
@ -1667,6 +1669,25 @@ impl State {
ws.desired_output.set(output.global.output_id.clone()); ws.desired_output.set(output.global.output_id.clone());
self.tree_changed(); self.tree_changed();
} }
fn expose_new_singletons(&self) {
self.globals.expose_new_singletons(self);
}
pub fn set_color_management_enabled(&self, enabled: bool) {
self.color_management_enabled.set(enabled);
self.expose_new_singletons();
}
pub fn set_primary_selection_enabled(&self, enabled: bool) {
self.enable_primary_selection.set(enabled);
self.expose_new_singletons();
}
pub fn set_explicit_sync_enabled(&self, enabled: bool) {
self.explicit_sync_enabled.set(enabled);
self.expose_new_singletons();
}
} }
#[derive(Debug, Error)] #[derive(Debug, Error)]