From eebeed1f2774146c3d7df90c7a982f58428d4cff Mon Sep 17 00:00:00 2001 From: MaxVerevkin Date: Mon, 2 Jan 2023 20:23:35 +0200 Subject: rewrite using wayrs --- src/river_protocols/control.rs | 112 ----------------------------------------- 1 file changed, 112 deletions(-) delete mode 100644 src/river_protocols/control.rs (limited to 'src/river_protocols/control.rs') diff --git a/src/river_protocols/control.rs b/src/river_protocols/control.rs deleted file mode 100644 index 7cce23d..0000000 --- a/src/river_protocols/control.rs +++ /dev/null @@ -1,112 +0,0 @@ -use wayland_client::globals::{BindError, GlobalList}; -use wayland_client::{protocol::wl_seat, Connection, Dispatch, QueueHandle}; - -use protocol::{zriver_command_callback_v1, zriver_control_v1}; - -#[derive(Debug, Clone)] -pub struct RiverControlState { - control: zriver_control_v1::ZriverControlV1, -} - -impl RiverControlState { - pub fn new(globals: &GlobalList, qh: &QueueHandle) -> Result - where - D: Dispatch + 'static, - { - let control = globals.bind(qh, 1..=1, ())?; - Ok(Self { control }) - } - - pub fn run_command(&self, qh: &QueueHandle, seat: &wl_seat::WlSeat, args: Args) - where - D: Dispatch - + 'static, - Args: IntoIterator, - Arg: Into, - { - for arg in args { - self.control.add_argument(arg.into()); - } - self.control - .run_command(seat, qh, RiverCommandCallbackData {}); - } -} - -pub trait RiverControlHandler: Sized { - fn river_control_state(&mut self) -> &mut RiverControlState; - - fn command_failure(&mut self, conn: &Connection, qh: &QueueHandle, message: String); - - fn command_success(&mut self, conn: &Connection, qh: &QueueHandle, message: String); -} - -#[derive(Debug)] -pub struct RiverCommandCallbackData { - // This is empty right now, but may be populated in the future. -} - -#[macro_export] -macro_rules! delegate_river_control { - ($ty: ty) => { - ::smithay_client_toolkit::reexports::client::delegate_dispatch!($ty: [ - $crate::river_protocols::control::protocol::zriver_control_v1::ZriverControlV1: () - ] => $crate::river_protocols::control::RiverControlState); - ::smithay_client_toolkit::reexports::client::delegate_dispatch!($ty: [ - $crate::river_protocols::control::protocol::zriver_command_callback_v1::ZriverCommandCallbackV1: $crate::river_protocols::control::RiverCommandCallbackData - ] => $crate::river_protocols::control::RiverControlState); - }; -} - -impl Dispatch for RiverControlState -where - D: Dispatch + RiverControlHandler + 'static, -{ - fn event( - _: &mut D, - _: &zriver_control_v1::ZriverControlV1, - _: zriver_control_v1::Event, - _: &(), - _: &Connection, - _: &QueueHandle, - ) { - unreachable!("zriver_control_v1 has no events") - } -} - -impl Dispatch - for RiverControlState -where - D: Dispatch - + RiverControlHandler - + 'static, -{ - fn event( - data: &mut D, - _callback: &zriver_command_callback_v1::ZriverCommandCallbackV1, - event: zriver_command_callback_v1::Event, - _udata: &RiverCommandCallbackData, - conn: &Connection, - qh: &QueueHandle, - ) { - use zriver_command_callback_v1::Event; - match event { - Event::Success { output } => data.command_success(conn, qh, output), - Event::Failure { failure_message } => data.command_success(conn, qh, failure_message), - } - } -} - -pub mod protocol { - #![allow(non_upper_case_globals)] - - use smithay_client_toolkit::reexports::client as wayland_client; - use smithay_client_toolkit::reexports::client::protocol::*; - - pub mod __interfaces { - use smithay_client_toolkit::reexports::client::protocol::__interfaces::*; - wayland_scanner::generate_interfaces!("protocols/river-control-unstable-v1.xml"); - } - use self::__interfaces::*; - - wayland_scanner::generate_client_code!("protocols/river-control-unstable-v1.xml"); -} -- cgit v1.3.1