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

@ -48,27 +48,6 @@ mod error;
mod objects;
mod tasks;
bitflags! {
ClientCaps: u32;
CAP_DATA_CONTROL_MANAGER = 1 << 0,
CAP_VIRTUAL_KEYBOARD_MANAGER = 1 << 1,
CAP_FOREIGN_TOPLEVEL_LIST = 1 << 2,
CAP_IDLE_NOTIFIER = 1 << 3,
CAP_SESSION_LOCK_MANAGER = 1 << 4,
CAP_JAY_COMPOSITOR = 1 << 5,
CAP_LAYER_SHELL = 1 << 6,
CAP_SCREENCOPY_MANAGER = 1 << 7,
CAP_SEAT_MANAGER = 1 << 8,
CAP_DRM_LEASE = 1 << 9,
CAP_INPUT_METHOD = 1 << 10,
CAP_WORKSPACE = 1 << 11,
CAP_FOREIGN_TOPLEVEL_MANAGER = 1 << 12,
CAP_HEAD_MANAGER = 1 << 13,
CAP_GAMMA_CONTROL_MANAGER = 1 << 14,
CAP_VIRTUAL_POINTER_MANAGER = 1 << 15,
CAP_FOREIGN_TOPLEVEL_GEOMETRY_TRACKING = 1 << 16,
}
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
pub struct ClientId(u64);
@ -220,13 +199,12 @@ impl Clients {
}
}
pub fn broadcast<B>(&self, required_caps: ClientCaps, xwayland_only: bool, mut f: B)
pub fn broadcast<B>(&self, xwayland_only: bool, mut f: B)
where
B: FnMut(&Rc<Client>),
{
let clients = self.clients.borrow();
for client in clients.values() {
let _ = required_caps;
if !xwayland_only || client.data.is_xwayland {
f(&client.data);
}

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);
}

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_DATA_CONTROL_MANAGER, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::data_transfer::{
TransferLocation,
@ -105,10 +105,6 @@ impl Global for ExtDataControlManagerV1Global {
fn version(&self) -> u32 {
1
}
fn required_caps(&self) -> ClientCaps {
CAP_DATA_CONTROL_MANAGER
}
}
simple_add_global!(ExtDataControlManagerV1Global);

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_DATA_CONTROL_MANAGER, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::data_transfer::{
TransferLocation,
@ -105,10 +105,6 @@ impl Global for ZwlrDataControlManagerV1Global {
fn version(&self) -> u32 {
2
}
fn required_caps(&self) -> ClientCaps {
CAP_DATA_CONTROL_MANAGER
}
}
simple_add_global!(ZwlrDataControlManagerV1Global);

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_FOREIGN_TOPLEVEL_LIST, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::{
ext_foreign_toplevel_handle_v1::ExtForeignToplevelHandleV1,
@ -137,10 +137,6 @@ impl Global for ExtForeignToplevelListV1Global {
fn version(&self) -> u32 {
1
}
fn required_caps(&self) -> ClientCaps {
CAP_FOREIGN_TOPLEVEL_LIST
}
}
simple_add_global!(ExtForeignToplevelListV1Global);

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_IDLE_NOTIFIER, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::ext_idle_notification_v1::ExtIdleNotificationV1,
leaks::Tracker,
@ -143,10 +143,6 @@ impl Global for ExtIdleNotifierV1Global {
fn version(&self) -> u32 {
2
}
fn required_caps(&self) -> ClientCaps {
CAP_IDLE_NOTIFIER
}
}
simple_add_global!(ExtIdleNotifierV1Global);

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_SCREENCOPY_MANAGER, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::{
ext_image_capture_source_v1::ImageCaptureSource,
@ -145,10 +145,6 @@ impl Global for ExtImageCopyCaptureManagerV1Global {
fn version(&self) -> u32 {
1
}
fn required_caps(&self) -> ClientCaps {
CAP_SCREENCOPY_MANAGER
}
}
simple_add_global!(ExtImageCopyCaptureManagerV1Global);

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_SESSION_LOCK_MANAGER, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::ext_session_lock_v1::ExtSessionLockV1,
leaks::Tracker,
@ -94,10 +94,6 @@ impl Global for ExtSessionLockManagerV1Global {
fn version(&self) -> u32 {
1
}
fn required_caps(&self) -> ClientCaps {
CAP_SESSION_LOCK_MANAGER
}
}
simple_add_global!(ExtSessionLockManagerV1Global);

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_HEAD_MANAGER, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::head_management::{
HeadMgrCommon, head_management_macros::send_available_extensions,
@ -65,10 +65,6 @@ impl Global for JayHeadManagerV1Global {
fn version(&self) -> u32 {
1
}
fn required_caps(&self) -> ClientCaps {
CAP_HEAD_MANAGER
}
}
pub(super) struct JayHeadManagerV1 {

View file

@ -1,7 +1,7 @@
use {
crate::{
backend::transaction::BackendConnectorTransactionError,
client::{CAP_JAY_COMPOSITOR, Client, ClientCaps, ClientError, ClientId},
client::{Client, ClientError, ClientId},
globals::{Global, GlobalName},
ifs::{
jay_client_query::JayClientQuery,
@ -80,10 +80,6 @@ impl Global for JayCompositorGlobal {
fn version(&self) -> u32 {
31
}
fn required_caps(&self) -> ClientCaps {
CAP_JAY_COMPOSITOR
}
}
simple_add_global!(JayCompositorGlobal);

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_JAY_COMPOSITOR, Client, ClientCaps, ClientError},
client::{Client, ClientError},
cmm::cmm_eotf::Eotf,
gfx_api::AlphaMode,
globals::{Global, GlobalName},
@ -56,10 +56,6 @@ impl Global for JayDamageTrackingGlobal {
fn version(&self) -> u32 {
1
}
fn required_caps(&self) -> ClientCaps {
CAP_JAY_COMPOSITOR
}
}
simple_add_global!(JayDamageTrackingGlobal);

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{Client, ClientCaps},
client::Client,
globals::{Global, GlobalName, GlobalsError, Singleton},
leaks::Tracker,
object::{Interface, Object, Version},
@ -61,7 +61,7 @@ impl WlRegistryRequestHandler for WlRegistry {
fn bind(&self, bind: Bind, _slf: &Rc<Self>) -> Result<(), Self::Error> {
let name = GlobalName::from_raw(bind.name);
let globals = &self.client.state.globals;
let global = globals.get(name, ClientCaps::all(), self.client.is_xwayland)?;
let global = globals.get(name, self.client.is_xwayland)?;
if global.interface().name() != bind.interface {
return Err(WlRegistryError::InvalidInterface(InterfaceError {
name: global.name(),

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_SEAT_MANAGER, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::wl_seat::ext_transient_seat_v1::ExtTransientSeatV1,
leaks::Tracker,
@ -55,10 +55,6 @@ impl Global for ExtTransientSeatManagerV1Global {
fn version(&self) -> u32 {
1
}
fn required_caps(&self) -> ClientCaps {
CAP_SEAT_MANAGER
}
}
simple_add_global!(ExtTransientSeatManagerV1Global);

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_INPUT_METHOD, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::wl_seat::text_input::zwp_input_method_v2::ZwpInputMethodV2,
leaks::Tracker,
@ -55,10 +55,6 @@ impl Global for ZwpInputMethodManagerV2Global {
fn version(&self) -> u32 {
1
}
fn required_caps(&self) -> ClientCaps {
CAP_INPUT_METHOD
}
}
simple_add_global!(ZwpInputMethodManagerV2Global);

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_VIRTUAL_KEYBOARD_MANAGER, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::wl_seat::zwp_virtual_keyboard_v1::ZwpVirtualKeyboardV1,
keyboard::KeyboardState,
@ -56,10 +56,6 @@ impl Global for ZwpVirtualKeyboardManagerV1Global {
fn version(&self) -> u32 {
1
}
fn required_caps(&self) -> ClientCaps {
CAP_VIRTUAL_KEYBOARD_MANAGER
}
}
simple_add_global!(ZwpVirtualKeyboardManagerV1Global);

View file

@ -1,7 +1,7 @@
use {
crate::{
backend::Mode,
client::{CAP_HEAD_MANAGER, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::wlr_output_manager::{
zwlr_output_configuration_v1::ZwlrOutputConfigurationV1,
@ -276,10 +276,6 @@ impl Global for ZwlrOutputManagerV1Global {
fn version(&self) -> u32 {
4
}
fn required_caps(&self) -> ClientCaps {
CAP_HEAD_MANAGER
}
}
simple_add_global!(ZwlrOutputManagerV1Global);

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_WORKSPACE, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::{
wl_output::OutputGlobalOpt,
@ -249,10 +249,6 @@ impl Global for ExtWorkspaceManagerV1Global {
fn version(&self) -> u32 {
1
}
fn required_caps(&self) -> ClientCaps {
CAP_WORKSPACE
}
}
simple_add_global!(ExtWorkspaceManagerV1Global);

View file

@ -1,7 +1,7 @@
use {
crate::{
backend::DrmDeviceId,
client::{CAP_DRM_LEASE, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::{
wp_drm_lease_connector_v1::WpDrmLeaseConnectorV1,
@ -84,10 +84,6 @@ impl Global for WpDrmLeaseDeviceV1Global {
fn version(&self) -> u32 {
1
}
fn required_caps(&self) -> ClientCaps {
CAP_DRM_LEASE
}
}
pub struct WpDrmLeaseDeviceV1 {

View file

@ -1,7 +1,7 @@
use {
crate::{
backend::DrmDeviceId,
client::{CAP_DRM_LEASE, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName, RemovableWaylandGlobal},
ifs::wp_drm_lease_device_v1::{WpDrmLeaseDeviceV1, WpDrmLeaseDeviceV1Global},
object::Version,
@ -53,10 +53,6 @@ impl Global for RemovedWpDrmLeaseDeviceV1Global {
fn version(&self) -> u32 {
1
}
fn required_caps(&self) -> ClientCaps {
CAP_DRM_LEASE
}
}
impl RemovableWaylandGlobal for WpDrmLeaseDeviceV1Global {

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_FOREIGN_TOPLEVEL_GEOMETRY_TRACKING, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::{
ext_foreign_toplevel_handle_v1::ExtForeignToplevelHandleV1,
@ -100,10 +100,6 @@ impl Global for XxForeignToplevelGeometryTrackingManagerV1Global {
fn version(&self) -> u32 {
1
}
fn required_caps(&self) -> ClientCaps {
CAP_FOREIGN_TOPLEVEL_GEOMETRY_TRACKING
}
}
simple_add_global!(XxForeignToplevelGeometryTrackingManagerV1Global);

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_FOREIGN_TOPLEVEL_MANAGER, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::{
wl_surface::{x_surface::xwindow::Xwindow, xdg_surface::xdg_toplevel::XdgToplevel},
@ -129,10 +129,6 @@ impl Global for ZwlrForeignToplevelManagerV1Global {
fn version(&self) -> u32 {
3
}
fn required_caps(&self) -> ClientCaps {
CAP_FOREIGN_TOPLEVEL_MANAGER
}
}
simple_add_global!(ZwlrForeignToplevelManagerV1Global);

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_GAMMA_CONTROL_MANAGER, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::zwlr_gamma_control_v1::*,
leaks::Tracker,
@ -50,10 +50,6 @@ impl Global for ZwlrGammaControlManagerV1Global {
fn version(&self) -> u32 {
1
}
fn required_caps(&self) -> ClientCaps {
CAP_GAMMA_CONTROL_MANAGER
}
}
pub struct ZwlrGammaControlManagerV1 {

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_LAYER_SHELL, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::{
wl_output::OutputGlobalOpt,
@ -112,10 +112,6 @@ impl Global for ZwlrLayerShellV1Global {
fn version(&self) -> u32 {
5
}
fn required_caps(&self) -> ClientCaps {
CAP_LAYER_SHELL
}
}
simple_add_global!(ZwlrLayerShellV1Global);

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_SCREENCOPY_MANAGER, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::zwlr_screencopy_frame_v1::ZwlrScreencopyFrameV1,
leaks::Tracker,
@ -54,10 +54,6 @@ impl Global for ZwlrScreencopyManagerV1Global {
fn version(&self) -> u32 {
3
}
fn required_caps(&self) -> ClientCaps {
CAP_SCREENCOPY_MANAGER
}
}
pub struct ZwlrScreencopyManagerV1 {

View file

@ -1,6 +1,6 @@
use {
crate::{
client::{CAP_VIRTUAL_POINTER_MANAGER, Client, ClientCaps, ClientError},
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::zwlr_virtual_pointer_v1::ZwlrVirtualPointerV1,
leaks::Tracker,
@ -53,10 +53,6 @@ impl Global for ZwlrVirtualPointerManagerV1Global {
fn version(&self) -> u32 {
2
}
fn required_caps(&self) -> ClientCaps {
CAP_VIRTUAL_POINTER_MANAGER
}
}
pub struct ZwlrVirtualPointerManagerV1 {