wayland: implement wl-fixes
This commit is contained in:
parent
f36993eb6e
commit
b13dd08991
14 changed files with 183 additions and 3 deletions
|
|
@ -153,6 +153,7 @@ Jay supports the following wayland protocols:
|
||||||
| wl_compositor | 6 | |
|
| wl_compositor | 6 | |
|
||||||
| wl_data_device_manager | 3 | |
|
| wl_data_device_manager | 3 | |
|
||||||
| wl_drm | 2 | |
|
| wl_drm | 2 | |
|
||||||
|
| wl_fixes | 1 | |
|
||||||
| wl_output | 4 | |
|
| wl_output | 4 | |
|
||||||
| wl_seat | 9 | |
|
| wl_seat | 9 | |
|
||||||
| wl_shm | 2 | |
|
| wl_shm | 2 | |
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
- Various bugfixes.
|
- Various bugfixes.
|
||||||
- Add support fo ext-data-control-v1.
|
- Add support fo ext-data-control-v1.
|
||||||
|
- Implement wl-fixes.
|
||||||
|
|
||||||
# 1.7.0 (2024-10-25)
|
# 1.7.0 (2024-10-25)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ use {
|
||||||
jay_damage_tracking::JayDamageTrackingGlobal,
|
jay_damage_tracking::JayDamageTrackingGlobal,
|
||||||
org_kde_kwin_server_decoration_manager::OrgKdeKwinServerDecorationManagerGlobal,
|
org_kde_kwin_server_decoration_manager::OrgKdeKwinServerDecorationManagerGlobal,
|
||||||
wl_compositor::WlCompositorGlobal,
|
wl_compositor::WlCompositorGlobal,
|
||||||
|
wl_fixes::WlFixesGlobal,
|
||||||
wl_output::WlOutputGlobal,
|
wl_output::WlOutputGlobal,
|
||||||
wl_registry::WlRegistry,
|
wl_registry::WlRegistry,
|
||||||
wl_seat::{
|
wl_seat::{
|
||||||
|
|
@ -211,6 +212,7 @@ impl Globals {
|
||||||
add_singleton!(WpFifoManagerV1Global);
|
add_singleton!(WpFifoManagerV1Global);
|
||||||
add_singleton!(WpCommitTimingManagerV1Global);
|
add_singleton!(WpCommitTimingManagerV1Global);
|
||||||
add_singleton!(ExtDataControlManagerV1Global);
|
add_singleton!(ExtDataControlManagerV1Global);
|
||||||
|
add_singleton!(WlFixesGlobal);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_backend_singletons(&self, backend: &Rc<dyn Backend>) {
|
pub fn add_backend_singletons(&self, backend: &Rc<dyn Backend>) {
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ pub mod wl_callback;
|
||||||
pub mod wl_compositor;
|
pub mod wl_compositor;
|
||||||
pub mod wl_display;
|
pub mod wl_display;
|
||||||
pub mod wl_drm;
|
pub mod wl_drm;
|
||||||
|
pub mod wl_fixes;
|
||||||
pub mod wl_output;
|
pub mod wl_output;
|
||||||
pub mod wl_region;
|
pub mod wl_region;
|
||||||
pub mod wl_registry;
|
pub mod wl_registry;
|
||||||
|
|
|
||||||
90
src/ifs/wl_fixes.rs
Normal file
90
src/ifs/wl_fixes.rs
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
use {
|
||||||
|
crate::{
|
||||||
|
client::{Client, ClientError},
|
||||||
|
globals::{Global, GlobalName},
|
||||||
|
leaks::Tracker,
|
||||||
|
object::{Object, Version},
|
||||||
|
wire::{wl_fixes::*, WlFixesId},
|
||||||
|
},
|
||||||
|
std::rc::Rc,
|
||||||
|
thiserror::Error,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct WlFixesGlobal {
|
||||||
|
pub name: GlobalName,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WlFixesGlobal {
|
||||||
|
pub fn new(name: GlobalName) -> Self {
|
||||||
|
Self { name }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bind_(
|
||||||
|
self: Rc<Self>,
|
||||||
|
id: WlFixesId,
|
||||||
|
client: &Rc<Client>,
|
||||||
|
version: Version,
|
||||||
|
) -> Result<(), WlFixesError> {
|
||||||
|
let mgr = Rc::new(WlFixes {
|
||||||
|
id,
|
||||||
|
client: client.clone(),
|
||||||
|
tracker: Default::default(),
|
||||||
|
version,
|
||||||
|
});
|
||||||
|
track!(client, mgr);
|
||||||
|
client.add_client_obj(&mgr)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
global_base!(WlFixesGlobal, WlFixes, WlFixesError);
|
||||||
|
|
||||||
|
simple_add_global!(WlFixesGlobal);
|
||||||
|
|
||||||
|
impl Global for WlFixesGlobal {
|
||||||
|
fn singleton(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
fn version(&self) -> u32 {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct WlFixes {
|
||||||
|
pub id: WlFixesId,
|
||||||
|
pub client: Rc<Client>,
|
||||||
|
pub tracker: Tracker<Self>,
|
||||||
|
pub version: Version,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WlFixesRequestHandler for WlFixes {
|
||||||
|
type Error = WlFixesError;
|
||||||
|
|
||||||
|
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
|
self.client.remove_obj(self)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn destroy_registry(&self, req: DestroyRegistry, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
|
let registry = self.client.lookup(req.registry)?;
|
||||||
|
self.client.remove_obj(&*registry)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object_base! {
|
||||||
|
self = WlFixes;
|
||||||
|
version = self.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Object for WlFixes {}
|
||||||
|
|
||||||
|
simple_add_obj!(WlFixes);
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum WlFixesError {
|
||||||
|
#[error(transparent)]
|
||||||
|
ClientError(Box<ClientError>),
|
||||||
|
}
|
||||||
|
efrom!(WlFixesError, ClientError);
|
||||||
|
|
@ -25,7 +25,7 @@ use {
|
||||||
|
|
||||||
pub struct TestClient {
|
pub struct TestClient {
|
||||||
pub run: Rc<TestRun>,
|
pub run: Rc<TestRun>,
|
||||||
pub _server: Rc<Client>,
|
pub server: Rc<Client>,
|
||||||
pub tran: Rc<TestTransport>,
|
pub tran: Rc<TestTransport>,
|
||||||
pub registry: Rc<TestRegistry>,
|
pub registry: Rc<TestRegistry>,
|
||||||
pub jc: Rc<TestJayCompositor>,
|
pub jc: Rc<TestJayCompositor>,
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ pub mod test_viewport;
|
||||||
pub mod test_viewporter;
|
pub mod test_viewporter;
|
||||||
pub mod test_virtual_keyboard;
|
pub mod test_virtual_keyboard;
|
||||||
pub mod test_virtual_keyboard_manager;
|
pub mod test_virtual_keyboard_manager;
|
||||||
|
pub mod test_wl_fixes;
|
||||||
pub mod test_xdg_activation;
|
pub mod test_xdg_activation;
|
||||||
pub mod test_xdg_activation_token;
|
pub mod test_xdg_activation_token;
|
||||||
pub mod test_xdg_base;
|
pub mod test_xdg_base;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ use {
|
||||||
test_toplevel_drag_manager::TestToplevelDragManager,
|
test_toplevel_drag_manager::TestToplevelDragManager,
|
||||||
test_viewporter::TestViewporter,
|
test_viewporter::TestViewporter,
|
||||||
test_virtual_keyboard_manager::TestVirtualKeyboardManager,
|
test_virtual_keyboard_manager::TestVirtualKeyboardManager,
|
||||||
test_xdg_activation::TestXdgActivation, test_xdg_base::TestXdgWmBase,
|
test_wl_fixes::TestWlFixes, test_xdg_activation::TestXdgActivation,
|
||||||
|
test_xdg_base::TestXdgWmBase,
|
||||||
},
|
},
|
||||||
test_object::TestObject,
|
test_object::TestObject,
|
||||||
test_transport::TestTransport,
|
test_transport::TestTransport,
|
||||||
|
|
@ -58,6 +59,7 @@ pub struct TestRegistrySingletons {
|
||||||
pub zwp_virtual_keyboard_manager_v1: u32,
|
pub zwp_virtual_keyboard_manager_v1: u32,
|
||||||
pub zwp_input_method_manager_v2: u32,
|
pub zwp_input_method_manager_v2: u32,
|
||||||
pub zwp_text_input_manager_v3: u32,
|
pub zwp_text_input_manager_v3: u32,
|
||||||
|
pub wl_fixes: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TestRegistry {
|
pub struct TestRegistry {
|
||||||
|
|
@ -85,6 +87,7 @@ pub struct TestRegistry {
|
||||||
pub virtual_keyboard_manager: CloneCell<Option<Rc<TestVirtualKeyboardManager>>>,
|
pub virtual_keyboard_manager: CloneCell<Option<Rc<TestVirtualKeyboardManager>>>,
|
||||||
pub input_method_manager: CloneCell<Option<Rc<TestInputMethodManager>>>,
|
pub input_method_manager: CloneCell<Option<Rc<TestInputMethodManager>>>,
|
||||||
pub text_input_manager: CloneCell<Option<Rc<TestTextInputManager>>>,
|
pub text_input_manager: CloneCell<Option<Rc<TestTextInputManager>>>,
|
||||||
|
pub wl_fixes: CloneCell<Option<Rc<TestWlFixes>>>,
|
||||||
pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>,
|
pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,6 +159,7 @@ impl TestRegistry {
|
||||||
zwp_virtual_keyboard_manager_v1,
|
zwp_virtual_keyboard_manager_v1,
|
||||||
zwp_input_method_manager_v2,
|
zwp_input_method_manager_v2,
|
||||||
zwp_text_input_manager_v3,
|
zwp_text_input_manager_v3,
|
||||||
|
wl_fixes,
|
||||||
};
|
};
|
||||||
self.singletons.set(Some(singletons.clone()));
|
self.singletons.set(Some(singletons.clone()));
|
||||||
Ok(singletons)
|
Ok(singletons)
|
||||||
|
|
@ -271,6 +275,7 @@ impl TestRegistry {
|
||||||
1,
|
1,
|
||||||
TestTextInputManager
|
TestTextInputManager
|
||||||
);
|
);
|
||||||
|
create_singleton!(get_wl_fixes, wl_fixes, wl_fixes, 1, TestWlFixes);
|
||||||
|
|
||||||
pub fn bind<O: TestObject>(
|
pub fn bind<O: TestObject>(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
38
src/it/test_ifs/test_wl_fixes.rs
Normal file
38
src/it/test_ifs/test_wl_fixes.rs
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
use {
|
||||||
|
crate::{
|
||||||
|
it::{
|
||||||
|
test_error::TestResult, test_ifs::test_registry::TestRegistry, test_object::TestObject,
|
||||||
|
test_transport::TestTransport,
|
||||||
|
},
|
||||||
|
wire::{wl_fixes::*, WlFixesId},
|
||||||
|
},
|
||||||
|
std::rc::Rc,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct TestWlFixes {
|
||||||
|
pub id: WlFixesId,
|
||||||
|
pub tran: Rc<TestTransport>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TestWlFixes {
|
||||||
|
pub fn new(tran: &Rc<TestTransport>) -> Self {
|
||||||
|
Self {
|
||||||
|
id: tran.id(),
|
||||||
|
tran: tran.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn destroy_registry(&self, registry: &TestRegistry) -> TestResult {
|
||||||
|
self.tran.send(DestroyRegistry {
|
||||||
|
self_id: self.id,
|
||||||
|
registry: registry.id,
|
||||||
|
})?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test_object! {
|
||||||
|
TestWlFixes, WlFixes;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TestObject for TestWlFixes {}
|
||||||
|
|
@ -73,6 +73,7 @@ impl TestTransport {
|
||||||
virtual_keyboard_manager: Default::default(),
|
virtual_keyboard_manager: Default::default(),
|
||||||
input_method_manager: Default::default(),
|
input_method_manager: Default::default(),
|
||||||
text_input_manager: Default::default(),
|
text_input_manager: Default::default(),
|
||||||
|
wl_fixes: Default::default(),
|
||||||
seats: Default::default(),
|
seats: Default::default(),
|
||||||
});
|
});
|
||||||
self.send(wl_display::GetRegistry {
|
self.send(wl_display::GetRegistry {
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ impl TestRun {
|
||||||
let client = self.state.clients.get(client_id)?;
|
let client = self.state.clients.get(client_id)?;
|
||||||
Ok(Rc::new(TestClient {
|
Ok(Rc::new(TestClient {
|
||||||
run: self.clone(),
|
run: self.clone(),
|
||||||
_server: client,
|
server: client,
|
||||||
tran,
|
tran,
|
||||||
jc,
|
jc,
|
||||||
comp: registry.get_compositor().await?,
|
comp: registry.get_compositor().await?,
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ mod t0039_alpha_modifier;
|
||||||
mod t0040_virtual_keyboard;
|
mod t0040_virtual_keyboard;
|
||||||
mod t0041_input_method;
|
mod t0041_input_method;
|
||||||
mod t0042_toplevel_select;
|
mod t0042_toplevel_select;
|
||||||
|
mod t0043_destroy_registry;
|
||||||
|
|
||||||
pub trait TestCase: Sync {
|
pub trait TestCase: Sync {
|
||||||
fn name(&self) -> &'static str;
|
fn name(&self) -> &'static str;
|
||||||
|
|
@ -135,5 +136,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> {
|
||||||
t0040_virtual_keyboard,
|
t0040_virtual_keyboard,
|
||||||
t0041_input_method,
|
t0041_input_method,
|
||||||
t0042_toplevel_select,
|
t0042_toplevel_select,
|
||||||
|
t0043_destroy_registry,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
31
src/it/tests/t0043_destroy_registry.rs
Normal file
31
src/it/tests/t0043_destroy_registry.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
use {
|
||||||
|
crate::it::{test_error::TestResult, testrun::TestRun},
|
||||||
|
std::rc::Rc,
|
||||||
|
};
|
||||||
|
|
||||||
|
testcase!();
|
||||||
|
|
||||||
|
async fn test(run: Rc<TestRun>) -> TestResult {
|
||||||
|
let client = run.create_client().await?;
|
||||||
|
let wl_fixes = client.registry.get_wl_fixes().await?;
|
||||||
|
|
||||||
|
let registry1 = client.tran.get_registry();
|
||||||
|
|
||||||
|
client.sync().await;
|
||||||
|
let before = client.server.objects.registries.len();
|
||||||
|
|
||||||
|
wl_fixes.destroy_registry(®istry1)?;
|
||||||
|
|
||||||
|
client.sync().await;
|
||||||
|
let after = client.server.objects.registries.len();
|
||||||
|
|
||||||
|
tassert_eq!(before, after + 1);
|
||||||
|
|
||||||
|
let registry2 = client.tran.get_registry();
|
||||||
|
client.sync().await;
|
||||||
|
|
||||||
|
tassert_eq!(registry1.id, registry2.id);
|
||||||
|
tassert!(registry2.globals.is_not_empty());
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
7
wire/wl_fixes.txt
Normal file
7
wire/wl_fixes.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
request destroy {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
request destroy_registry {
|
||||||
|
registry: id(wl_registry),
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue