forge
Explore
Log in

Don't you dare go Hollow

niri

Clone
★ 0

0 watching0 forksRustGPL-3.012.1 MiBb0eb8adIvan Molodetskikh3 months ago2857 commits

mutter_x11_interop.rs75 lines, 2.0 KiBHistoryRawDownload
1use mutter_x11_interop::MutterX11Interop;
2use smithay::reexports::wayland_server::{
3 Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource,
4};
5use smithay::wayland::{Dispatch2, GlobalData, GlobalDispatch2};
6
7use super::raw::mutter_x11_interop::v1::server::mutter_x11_interop;
8
9const VERSION: u32 = 1;
10
11pub struct MutterX11InteropManagerState {}
12
13pub struct MutterX11InteropManagerGlobalData {
14 filter: Box<dyn for<'c> Fn(&'c Client) -> bool + Send + Sync>,
15}
16
17pub trait MutterX11InteropHandler {}
18
19impl MutterX11InteropManagerState {
20 pub fn new<D, F>(display: &DisplayHandle, filter: F) -> Self
21 where
22 D: GlobalDispatch<MutterX11Interop, MutterX11InteropManagerGlobalData>,
23 D: MutterX11InteropHandler,
24 D: 'static,
25 F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static,
26 {
27 let global_data = MutterX11InteropManagerGlobalData {
28 filter: Box::new(filter),
29 };
30 display.create_global::<D, MutterX11Interop, _>(VERSION, global_data);
31
32 Self {}
33 }
34}
35
36impl<D> GlobalDispatch2<MutterX11Interop, D> for MutterX11InteropManagerGlobalData
37where
38 D: Dispatch<MutterX11Interop, GlobalData>,
39 D: MutterX11InteropHandler,
40{
41 fn bind(
42 &self,
43 _state: &mut D,
44 _handle: &DisplayHandle,
45 _client: &Client,
46 manager: New<MutterX11Interop>,
47 data_init: &mut DataInit<'_, D>,
48 ) {
49 data_init.init(manager, GlobalData);
50 }
51
52 fn can_view(&self, client: &Client) -> bool {
53 (self.filter)(client)
54 }
55}
56
57impl<D> Dispatch2<MutterX11Interop, D> for GlobalData
58where
59 D: MutterX11InteropHandler,
60{
61 fn request(
62 &self,
63 _state: &mut D,
64 _client: &Client,
65 _resource: &MutterX11Interop,
66 request: <MutterX11Interop as Resource>::Request,
67 _dhandle: &DisplayHandle,
68 _data_init: &mut DataInit<'_, D>,
69 ) {
70 match request {
71 mutter_x11_interop::Request::Destroy => (),
72 mutter_x11_interop::Request::SetX11Parent { .. } => (),
73 }
74 }
75}