more compact import

This commit is contained in:
Ferdinand Schober
2022-09-20 23:57:59 +02:00
parent 65dba1624d
commit acc14d2f21

View File

@@ -22,7 +22,7 @@ use wayland_protocols::wp::{
}, },
}; };
use wayland_protocols_wlr::layer_shell::v1::client::{zwlr_layer_shell_v1, zwlr_layer_surface_v1}; use wayland_protocols_wlr::layer_shell::v1::client::{zwlr_layer_shell_v1::{ZwlrLayerShellV1, Layer}, zwlr_layer_surface_v1::{self, ZwlrLayerSurfaceV1, Anchor, KeyboardInteractivity}};
use wayland_client::{ use wayland_client::{
globals::{registry_queue_init, GlobalListContents}, globals::{registry_queue_init, GlobalListContents},
@@ -42,7 +42,7 @@ struct Globals {
shortcut_inhibit_manager: ZwpKeyboardShortcutsInhibitManagerV1, shortcut_inhibit_manager: ZwpKeyboardShortcutsInhibitManagerV1,
seat: wl_seat::WlSeat, seat: wl_seat::WlSeat,
shm: wl_shm::WlShm, shm: wl_shm::WlShm,
layer_shell: zwlr_layer_shell_v1::ZwlrLayerShellV1, layer_shell: ZwlrLayerShellV1,
} }
struct App { struct App {
@@ -65,7 +65,7 @@ struct Windows {
struct Window { struct Window {
buffer: wl_buffer::WlBuffer, buffer: wl_buffer::WlBuffer,
surface: wl_surface::WlSurface, surface: wl_surface::WlSurface,
layer_surface: zwlr_layer_surface_v1::ZwlrLayerSurfaceV1, layer_surface: ZwlrLayerSurfaceV1,
} }
impl Window { impl Window {
@@ -90,13 +90,13 @@ impl Window {
let layer_surface = g.layer_shell.get_layer_surface( let layer_surface = g.layer_shell.get_layer_surface(
&surface, &surface,
None, None,
zwlr_layer_shell_v1::Layer::Top, Layer::Top,
"LAN Mouse Sharing".into(), "LAN Mouse Sharing".into(),
&qh, &qh,
(), (),
); );
layer_surface.set_anchor(zwlr_layer_surface_v1::Anchor::Right); layer_surface.set_anchor(Anchor::Right);
layer_surface.set_size(1, 1440); layer_surface.set_size(1, 1440);
layer_surface.set_exclusive_zone(0); layer_surface.set_exclusive_zone(0);
layer_surface.set_margin(0, 0, 0, 0); layer_surface.set_margin(0, 0, 0, 0);
@@ -119,7 +119,7 @@ fn main() {
let compositor: wl_compositor::WlCompositor = globals.bind(&qh, 4..=5, ()).unwrap(); let compositor: wl_compositor::WlCompositor = globals.bind(&qh, 4..=5, ()).unwrap();
let shm: wl_shm::WlShm = globals.bind::<wl_shm::WlShm, _, _>(&qh, 1..=1, ()).unwrap(); let shm: wl_shm::WlShm = globals.bind::<wl_shm::WlShm, _, _>(&qh, 1..=1, ()).unwrap();
let layer_shell: zwlr_layer_shell_v1::ZwlrLayerShellV1 = globals.bind(&qh, 3..=4, ()).unwrap(); let layer_shell: ZwlrLayerShellV1 = globals.bind(&qh, 3..=4, ()).unwrap();
let seat: wl_seat::WlSeat = globals.bind(&qh, 7..=8, ()).unwrap(); let seat: wl_seat::WlSeat = globals.bind(&qh, 7..=8, ()).unwrap();
let pointer_constraints: ZwpPointerConstraintsV1 = globals.bind(&qh, 1..=1, ()).unwrap(); let pointer_constraints: ZwpPointerConstraintsV1 = globals.bind(&qh, 1..=1, ()).unwrap();
let relative_pointer_manager: ZwpRelativePointerManagerV1 = let relative_pointer_manager: ZwpRelativePointerManagerV1 =
@@ -173,7 +173,7 @@ impl App {
pointer.set_cursor(serial, None, 0, 0); pointer.set_cursor(serial, None, 0, 0);
let layer_surface = &self.windows.right.as_ref().unwrap().layer_surface; let layer_surface = &self.windows.right.as_ref().unwrap().layer_surface;
layer_surface layer_surface
.set_keyboard_interactivity(zwlr_layer_surface_v1::KeyboardInteractivity::Exclusive); .set_keyboard_interactivity(KeyboardInteractivity::Exclusive);
let surface = &self.windows.right.as_ref().unwrap().surface; let surface = &self.windows.right.as_ref().unwrap().surface;
surface.commit(); surface.commit();
if self.pointer_lock.is_none() { if self.pointer_lock.is_none() {
@@ -207,7 +207,7 @@ impl App {
fn ungrab(&mut self) { fn ungrab(&mut self) {
let layer_surface = &self.windows.right.as_ref().unwrap().layer_surface; let layer_surface = &self.windows.right.as_ref().unwrap().layer_surface;
layer_surface layer_surface
.set_keyboard_interactivity(zwlr_layer_surface_v1::KeyboardInteractivity::None); .set_keyboard_interactivity(KeyboardInteractivity::None);
let surface = &self.windows.right.as_ref().unwrap().surface; let surface = &self.windows.right.as_ref().unwrap().surface;
surface.commit(); surface.commit();
if let Some(pointer_lock) = &self.pointer_lock { if let Some(pointer_lock) = &self.pointer_lock {
@@ -381,8 +381,7 @@ impl Dispatch<wl_keyboard::WlKeyboard, ()> for App {
size: _, size: _,
} => { } => {
let mmap = unsafe { Mmap::map(&File::from_raw_fd(fd.as_raw_fd())).unwrap() }; let mmap = unsafe { Mmap::map(&File::from_raw_fd(fd.as_raw_fd())).unwrap() };
app.connection app.connection.offer_data(protocol::DataRequest::KeyMap, mmap);
.offer_data(protocol::DataRequest::KeyMap, mmap);
} }
_ => (), _ => (),
} }
@@ -453,11 +452,11 @@ impl Dispatch<ZwpRelativePointerV1, ()> for App {
} }
} }
impl Dispatch<zwlr_layer_shell_v1::ZwlrLayerShellV1, ()> for App { impl Dispatch<ZwlrLayerShellV1, ()> for App {
fn event( fn event(
_: &mut Self, _: &mut Self,
_: &zwlr_layer_shell_v1::ZwlrLayerShellV1, _: &ZwlrLayerShellV1,
_: <zwlr_layer_shell_v1::ZwlrLayerShellV1 as wayland_client::Proxy>::Event, _: <ZwlrLayerShellV1 as wayland_client::Proxy>::Event,
_: &(), _: &(),
_: &Connection, _: &Connection,
_: &QueueHandle<Self>, _: &QueueHandle<Self>,
@@ -465,11 +464,11 @@ impl Dispatch<zwlr_layer_shell_v1::ZwlrLayerShellV1, ()> for App {
} }
} }
impl Dispatch<zwlr_layer_surface_v1::ZwlrLayerSurfaceV1, ()> for App { impl Dispatch<ZwlrLayerSurfaceV1, ()> for App {
fn event( fn event(
app: &mut Self, app: &mut Self,
layer_surface: &zwlr_layer_surface_v1::ZwlrLayerSurfaceV1, layer_surface: &ZwlrLayerSurfaceV1,
event: <zwlr_layer_surface_v1::ZwlrLayerSurfaceV1 as wayland_client::Proxy>::Event, event: <ZwlrLayerSurfaceV1 as wayland_client::Proxy>::Event,
_: &(), _: &(),
_: &Connection, _: &Connection,
_: &QueueHandle<Self>, _: &QueueHandle<Self>,