1
0
Fork 0
forked from wry/wry

refactor: split cargo workspace

This commit is contained in:
kossLAN 2026-06-05 11:56:21 -04:00
parent 5db14936e7
commit 1c21bd1259
695 changed files with 32023 additions and 44964 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,
@ -11,7 +11,7 @@ use {
ext_session_lock_manager_v1::ExtSessionLockManagerV1Global,
head_management::jay_head_manager_v1::JayHeadManagerV1Global,
hyprland_focus_grab_manager_v1::HyprlandFocusGrabManagerV1Global,
ipc::{
data_transfer::{
data_control::{
ext_data_control_manager_v1::ExtDataControlManagerV1Global,
zwlr_data_control_manager_v1::ZwlrDataControlManagerV1Global,
@ -56,7 +56,6 @@ use {
wp_fractional_scale_manager_v1::WpFractionalScaleManagerV1Global,
wp_linux_drm_syncobj_manager_v1::WpLinuxDrmSyncobjManagerV1Global,
wp_presentation::WpPresentationGlobal,
wp_security_context_manager_v1::WpSecurityContextManagerV1Global,
wp_single_pixel_buffer_manager_v1::WpSinglePixelBufferManagerV1Global,
wp_tearing_control_manager_v1::WpTearingControlManagerV1Global,
wp_viewporter::WpViewporterGlobal,
@ -85,14 +84,10 @@ use {
},
arrayvec::ArrayVec,
linearize::{Linearize, StaticMap},
std::{
cell::Cell,
error::Error,
fmt::{Display, Formatter},
rc::Rc,
},
std::{cell::Cell, error::Error, rc::Rc},
thiserror::Error,
};
pub use jay_wire_types::GlobalName;
#[derive(Debug, Error)]
pub enum GlobalsError {
@ -112,25 +107,6 @@ pub struct GlobalError {
pub error: Box<dyn Error>,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub struct GlobalName(u32);
impl GlobalName {
pub fn from_raw(id: u32) -> Self {
Self(id)
}
pub fn raw(self) -> u32 {
self.0
}
}
impl Display for GlobalName {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Display::fmt(&self.0, f)
}
}
pub trait GlobalBase {
fn name(&self) -> GlobalName;
fn bind<'a>(
@ -145,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
}
@ -155,11 +128,11 @@ pub trait Global: GlobalBase {
let _ = state;
true
}
fn permitted(&self, caps: ClientCaps, xwayland: bool) -> bool {
caps.contains(self.required_caps()) && (xwayland || !self.xwayland_only())
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)
}
}
@ -227,7 +200,6 @@ singletons! {
ZwpVirtualKeyboardManagerV1,
ZwpInputMethodManagerV2,
ZwpTextInputManagerV3,
WpSecurityContextManagerV1,
XdgWmDialogV1,
ExtTransientSeatManagerV1,
ZwpPointerGesturesV1,
@ -274,7 +246,7 @@ impl Globals {
removed: CopyHashMap::new(),
outputs: Default::default(),
seats: Default::default(),
singletons: StaticMap::from_fn(|_| GlobalName(0)),
singletons: StaticMap::from_fn(|_| GlobalName::from_raw(0)),
exposed: Default::default(),
};
add_singletons(&mut slf);
@ -292,7 +264,7 @@ impl Globals {
if id == 0 {
panic!("Global names overflowed");
}
GlobalName(id)
GlobalName::from_raw(id)
}
fn insert_no_broadcast<'a>(&'a self, global: Rc<dyn Global>) {
@ -305,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)
@ -334,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(())
@ -345,7 +314,6 @@ impl Globals {
}
pub fn notify_all(&self, registry: &Rc<WlRegistry>) {
let caps = registry.client.effective_caps.get();
let xwayland = registry.client.is_xwayland;
let globals = self.registry.lock();
macro_rules! emit {
@ -353,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);
}
@ -368,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);
@ -429,10 +396,9 @@ impl Globals {
}
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) {
if global.permitted(xwayland) {
for registry in client.objects.registries.lock().values() {
registry.handle_global(global);
}