1
0
Fork 0
forked from wry/wry

globals: remove client capability permissions

This commit is contained in:
kossLAN 2026-05-29 18:16:06 -04:00
parent 8a35bc3ca4
commit 698110c265
No known key found for this signature in database
25 changed files with 35 additions and 155 deletions

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{Client, ClientCaps},
client::Client,
ifs::{
color_management::wp_color_manager_v1::WpColorManagerV1Global,
ext_foreign_toplevel_image_capture_source_manager_v1::ExtForeignToplevelImageCaptureSourceManagerV1Global,
@ -121,9 +121,6 @@ pub trait GlobalBase {
pub trait Global: GlobalBase {
fn version(&self) -> u32;
fn required_caps(&self) -> ClientCaps {
ClientCaps::none()
}
fn xwayland_only(&self) -> bool {
false
}
@ -131,12 +128,11 @@ pub trait Global: GlobalBase {
let _ = state;
true
}
fn permitted(&self, caps: ClientCaps, xwayland: bool) -> bool {
let _ = caps;
fn permitted(&self, xwayland: bool) -> bool {
xwayland || !self.xwayland_only()
}
fn not_permitted(&self, caps: ClientCaps, xwayland: bool) -> bool {
!self.permitted(caps, xwayland)
fn not_permitted(&self, xwayland: bool) -> bool {
!self.permitted(xwayland)
}
}
@ -281,19 +277,16 @@ impl Globals {
fn insert(&self, state: &State, global: Rc<dyn Global>) {
self.insert_no_broadcast_(&global);
self.broadcast(state, global.required_caps(), global.xwayland_only(), |r| {
r.handle_global(&global)
});
self.broadcast(state, global.xwayland_only(), |r| r.handle_global(&global));
}
pub fn get(
&self,
name: GlobalName,
client_caps: ClientCaps,
allow_xwayland_only: bool,
) -> Result<Rc<dyn Global>, GlobalsError> {
let global = self.take(name, false)?;
if global.not_permitted(client_caps, allow_xwayland_only) {
if global.not_permitted(allow_xwayland_only) {
return Err(GlobalsError::GlobalDoesNotExist(name));
}
Ok(global)
@ -310,7 +303,7 @@ impl Globals {
assert_eq!(global.name(), replacement.name());
assert_eq!(global.interface().0, replacement.interface().0);
self.removed.set(global.name(), replacement);
self.broadcast(state, global.required_caps(), global.xwayland_only(), |r| {
self.broadcast(state, global.xwayland_only(), |r| {
r.handle_global_removed(&**global)
});
Ok(())
@ -321,7 +314,6 @@ impl Globals {
}
pub fn notify_all(&self, registry: &Rc<WlRegistry>) {
let caps = ClientCaps::all();
let xwayland = registry.client.is_xwayland;
let globals = self.registry.lock();
macro_rules! emit {
@ -329,7 +321,7 @@ impl Globals {
for global in globals.values() {
if global.singleton().is_some() == $singleton {
if global.exposed(&registry.client.state)
&& global.permitted(caps, xwayland)
&& global.permitted(xwayland)
{
registry.handle_global(global);
}
@ -344,11 +336,10 @@ impl Globals {
fn broadcast<F: Fn(&Rc<WlRegistry>)>(
&self,
state: &State,
required_caps: ClientCaps,
xwayland_only: bool,
f: F,
) {
state.clients.broadcast(required_caps, xwayland_only, |c| {
state.clients.broadcast(xwayland_only, |c| {
let registries = c.lock_registries();
for registry in registries.values() {
f(registry);
@ -405,10 +396,9 @@ impl Globals {
}
for client in state.clients.clients.borrow().values() {
let client = &client.data;
let caps = ClientCaps::all();
let xwayland = client.is_xwayland;
for global in &singletons {
if global.permitted(caps, xwayland) {
if global.permitted(xwayland) {
for registry in client.objects.registries.lock().values() {
registry.handle_global(global);
}