Advertisement
Guest User

river_layout_unstable_v1

a guest
Mar 13th, 2021
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 36.92 KB | None | 0 0
  1. use std::os::raw::{c_char, c_void};
  2. const NULLPTR: *const c_void = 0 as *const c_void;
  3. static mut types_null: [*const sys::common::wl_interface; 5] = [
  4.     NULLPTR as *const sys::common::wl_interface,
  5.     NULLPTR as *const sys::common::wl_interface,
  6.     NULLPTR as *const sys::common::wl_interface,
  7.     NULLPTR as *const sys::common::wl_interface,
  8.     NULLPTR as *const sys::common::wl_interface,
  9. ];
  10. #[doc = "manage river layout objects\n\nA global factory for river_layout objects."]
  11. pub mod zriver_layout_manager_v1 {
  12.     use super::sys::client::*;
  13.     use super::sys::common::{wl_argument, wl_array, wl_interface, wl_message};
  14.     use super::{
  15.         smallvec, types_null, AnonymousObject, Argument, ArgumentType, Interface, Main, Message,
  16.         MessageDesc, MessageGroup, Object, ObjectMetadata, Proxy, NULLPTR,
  17.     };
  18.     use std::os::raw::c_char;
  19.     #[derive(Debug)]
  20.     #[non_exhaustive]
  21.     pub enum Request {
  22.         #[doc = "destroy the river_layout_manager object\n\nThis request indicates that the client will not use the\nriver_layout_manager object any more. Objects that have been created\nthrough this instance are not affected.\n\nThis is a destructor, once sent this object cannot be used any longer."]
  23.         Destroy,
  24.         #[doc = "create a river_layout object\n\nThis creates a new river_layout object for the given wl_output.\n\nAll layout related communication is done through this interface.\n\nThe namespace is used by the compositor to decide which river_layout\nobject will receive layout demands for the output. Namespaces must be\nunique per output. The same namespace may occur on other outputs, as\nlong as that river_layout object comes from the same client. If the\nnamespace is found to not obey these uniqueness rules, the server will\nsend a namespace_in_use event on the river_layout object immediately\nafter creation and ignore all requests on the object aside from the\ndestroy request."]
  25.         GetRiverLayout {
  26.             output: super::wl_output::WlOutput,
  27.             namespace: String,
  28.         },
  29.     }
  30.     impl super::MessageGroup for Request {
  31.         const MESSAGES: &'static [super::MessageDesc] = &[
  32.            super::MessageDesc {
  33.                name: "destroy",
  34.                since: 1,
  35.                signature: &[],
  36.                destructor: true,
  37.            },
  38.            super::MessageDesc {
  39.                name: "get_river_layout",
  40.                since: 1,
  41.                signature: &[
  42.                    super::ArgumentType::NewId,
  43.                    super::ArgumentType::Object,
  44.                    super::ArgumentType::Str,
  45.                ],
  46.                destructor: false,
  47.            },
  48.        ];
  49.        type Map = super::ProxyMap;
  50.        fn is_destructor(&self) -> bool {
  51.            match *self {
  52.                Request::Destroy => true,
  53.                _ => false,
  54.            }
  55.        }
  56.        fn opcode(&self) -> u16 {
  57.            match *self {
  58.                Request::Destroy => 0,
  59.                Request::GetRiverLayout { .. } => 1,
  60.            }
  61.        }
  62.        fn since(&self) -> u32 {
  63.            match *self {
  64.                Request::Destroy => 1,
  65.                Request::GetRiverLayout { .. } => 1,
  66.            }
  67.        }
  68.        fn child<Meta: ObjectMetadata>(
  69.            opcode: u16,
  70.            version: u32,
  71.            meta: &Meta,
  72.        ) -> Option<Object<Meta>> {
  73.            match opcode {
  74.                1 => Some(Object::from_interface::<
  75.                    super::zriver_layout_v1::ZriverLayoutV1,
  76.                >(version, meta.child())),
  77.                _ => None,
  78.            }
  79.        }
  80.        fn from_raw(msg: Message, map: &mut Self::Map) -> Result<Self, ()> {
  81.            panic!("Request::from_raw can not be used Client-side.")
  82.        }
  83.        fn into_raw(self, sender_id: u32) -> Message {
  84.            match self {
  85.                Request::Destroy => Message {
  86.                    sender_id: sender_id,
  87.                    opcode: 0,
  88.                    args: smallvec![],
  89.                },
  90.                Request::GetRiverLayout { output, namespace } => Message {
  91.                    sender_id: sender_id,
  92.                    opcode: 1,
  93.                    args: smallvec![
  94.                        Argument::NewId(0),
  95.                        Argument::Object(output.as_ref().id()),
  96.                        Argument::Str(Box::new(unsafe {
  97.                            ::std::ffi::CString::from_vec_unchecked(namespace.into())
  98.                        })),
  99.                    ],
  100.                },
  101.            }
  102.        }
  103.        unsafe fn from_raw_c(
  104.            obj: *mut ::std::os::raw::c_void,
  105.            opcode: u32,
  106.            args: *const wl_argument,
  107.        ) -> Result<Request, ()> {
  108.            panic!("Request::from_raw_c can not be used Client-side.")
  109.        }
  110.        fn as_raw_c_in<F, T>(self, f: F) -> T
  111.        where
  112.            F: FnOnce(u32, &mut [wl_argument]) -> T,
  113.        {
  114.            match self {
  115.                Request::Destroy => {
  116.                    let mut _args_array: [wl_argument; 0] = unsafe { ::std::mem::zeroed() };
  117.                    f(0, &mut _args_array)
  118.                }
  119.                Request::GetRiverLayout { output, namespace } => {
  120.                    let mut _args_array: [wl_argument; 3] = unsafe { ::std::mem::zeroed() };
  121.                    _args_array[0].o = ::std::ptr::null_mut() as *mut _;
  122.                    _args_array[1].o = output.as_ref().c_ptr() as *mut _;
  123.                    let _arg_2 = ::std::ffi::CString::new(namespace).unwrap();
  124.                    _args_array[2].s = _arg_2.as_ptr();
  125.                    f(1, &mut _args_array)
  126.                }
  127.            }
  128.        }
  129.    }
  130.    #[derive(Debug)]
  131.    #[non_exhaustive]
  132.    pub enum Event {}
  133.    impl super::MessageGroup for Event {
  134.        const MESSAGES: &'static [super::MessageDesc] = &[];
  135.         type Map = super::ProxyMap;
  136.         fn is_destructor(&self) -> bool {
  137.             match *self {}
  138.         }
  139.         fn opcode(&self) -> u16 {
  140.             match *self {}
  141.         }
  142.         fn since(&self) -> u32 {
  143.             match *self {}
  144.         }
  145.         fn child<Meta: ObjectMetadata>(
  146.             opcode: u16,
  147.             version: u32,
  148.             meta: &Meta,
  149.         ) -> Option<Object<Meta>> {
  150.             match opcode {
  151.                 _ => None,
  152.             }
  153.         }
  154.         fn from_raw(msg: Message, map: &mut Self::Map) -> Result<Self, ()> {
  155.             match msg.opcode {
  156.                 _ => Err(()),
  157.             }
  158.         }
  159.         fn into_raw(self, sender_id: u32) -> Message {
  160.             panic!("Event::into_raw can not be used Client-side.")
  161.         }
  162.         unsafe fn from_raw_c(
  163.             obj: *mut ::std::os::raw::c_void,
  164.             opcode: u32,
  165.             args: *const wl_argument,
  166.         ) -> Result<Event, ()> {
  167.             match opcode {
  168.                 _ => return Err(()),
  169.             }
  170.         }
  171.         fn as_raw_c_in<F, T>(self, f: F) -> T
  172.         where
  173.             F: FnOnce(u32, &mut [wl_argument]) -> T,
  174.         {
  175.             panic!("Event::as_raw_c_in can not be used Client-side.")
  176.         }
  177.     }
  178.     #[derive(Clone, Eq, PartialEq)]
  179.     pub struct ZriverLayoutManagerV1(Proxy<ZriverLayoutManagerV1>);
  180.     impl AsRef<Proxy<ZriverLayoutManagerV1>> for ZriverLayoutManagerV1 {
  181.         #[inline]
  182.         fn as_ref(&self) -> &Proxy<Self> {
  183.             &self.0
  184.         }
  185.     }
  186.     impl From<Proxy<ZriverLayoutManagerV1>> for ZriverLayoutManagerV1 {
  187.         #[inline]
  188.         fn from(value: Proxy<Self>) -> Self {
  189.             ZriverLayoutManagerV1(value)
  190.         }
  191.     }
  192.     impl From<ZriverLayoutManagerV1> for Proxy<ZriverLayoutManagerV1> {
  193.         #[inline]
  194.         fn from(value: ZriverLayoutManagerV1) -> Self {
  195.             value.0
  196.         }
  197.     }
  198.     impl std::fmt::Debug for ZriverLayoutManagerV1 {
  199.         fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  200.            f.write_fmt(format_args!("{:?}", self.0))
  201.        }
  202.    }
  203.    impl Interface for ZriverLayoutManagerV1 {
  204.        type Request = Request;
  205.        type Event = Event;
  206.        const NAME: &'static str = "zriver_layout_manager_v1";
  207.         const VERSION: u32 = 1;
  208.         fn c_interface() -> *const wl_interface {
  209.             unsafe { &zriver_layout_manager_v1_interface }
  210.         }
  211.     }
  212.     impl ZriverLayoutManagerV1 {
  213.         #[doc = "destroy the river_layout_manager object\n\nThis request indicates that the client will not use the\nriver_layout_manager object any more. Objects that have been created\nthrough this instance are not affected.\n\nThis is a destructor, you cannot send requests to this object any longer once this method is called."]
  214.         pub fn destroy(&self) -> () {
  215.             let msg = Request::Destroy;
  216.             self.0.send::<AnonymousObject>(msg, None);
  217.         }
  218.         #[doc = "create a river_layout object\n\nThis creates a new river_layout object for the given wl_output.\n\nAll layout related communication is done through this interface.\n\nThe namespace is used by the compositor to decide which river_layout\nobject will receive layout demands for the output. Namespaces must be\nunique per output. The same namespace may occur on other outputs, as\nlong as that river_layout object comes from the same client. If the\nnamespace is found to not obey these uniqueness rules, the server will\nsend a namespace_in_use event on the river_layout object immediately\nafter creation and ignore all requests on the object aside from the\ndestroy request."]
  219.         pub fn get_river_layout(
  220.             &self,
  221.             output: &super::wl_output::WlOutput,
  222.             namespace: String,
  223.         ) -> Main<super::zriver_layout_v1::ZriverLayoutV1> {
  224.             let msg = Request::GetRiverLayout {
  225.                 output: output.clone(),
  226.                 namespace: namespace,
  227.             };
  228.             self.0.send(msg, None).unwrap()
  229.         }
  230.     }
  231.     #[doc = r" The minimal object version supporting this request"]
  232.     pub const REQ_DESTROY_SINCE: u32 = 1u32;
  233.     #[doc = r" The minimal object version supporting this request"]
  234.     pub const REQ_GET_RIVER_LAYOUT_SINCE: u32 = 1u32;
  235.     static mut zriver_layout_manager_v1_requests_get_river_layout_types: [*const wl_interface; 3] = [
  236.         unsafe { &super::zriver_layout_v1::zriver_layout_v1_interface as *const wl_interface },
  237.         unsafe { &super::wl_output::wl_output_interface as *const wl_interface },
  238.         NULLPTR as *const wl_interface,
  239.     ];
  240.     #[doc = r" C-representation of the messages of this interface, for interop"]
  241.     pub static mut zriver_layout_manager_v1_requests: [wl_message; 2] = [
  242.         wl_message {
  243.             name: b"destroy\0" as *const u8 as *const c_char,
  244.             signature: b"\0" as *const u8 as *const c_char,
  245.             types: unsafe { &types_null as *const _ },
  246.         },
  247.         wl_message {
  248.             name: b"get_river_layout\0" as *const u8 as *const c_char,
  249.             signature: b"nos\0" as *const u8 as *const c_char,
  250.             types: unsafe { &zriver_layout_manager_v1_requests_get_river_layout_types as *const _ },
  251.         },
  252.     ];
  253.     #[doc = r" C representation of this interface, for interop"]
  254.     pub static mut zriver_layout_manager_v1_interface: wl_interface = wl_interface {
  255.         name: b"zriver_layout_manager_v1\0" as *const u8 as *const c_char,
  256.         version: 1,
  257.         request_count: 2,
  258.         requests: unsafe { &zriver_layout_manager_v1_requests as *const _ },
  259.         event_count: 0,
  260.         events: NULLPTR as *const wl_message,
  261.     };
  262. }
  263. #[doc = "receive and respond to layout demands\n\nThis interface allows clients to receive layout demands from the\ncompositor for a specific output and subsequently propose positions and\ndimensions of individual views."]
  264. pub mod zriver_layout_v1 {
  265.     use super::sys::client::*;
  266.     use super::sys::common::{wl_argument, wl_array, wl_interface, wl_message};
  267.     use super::{
  268.         smallvec, types_null, AnonymousObject, Argument, ArgumentType, Interface, Main, Message,
  269.         MessageDesc, MessageGroup, Object, ObjectMetadata, Proxy, NULLPTR,
  270.     };
  271.     use std::os::raw::c_char;
  272.     #[repr(u32)]
  273.     #[derive(Copy, Clone, Debug, PartialEq)]
  274.     #[non_exhaustive]
  275.     pub enum Error {
  276.         #[doc = "amount of proposed dimensions does not match amount of views in layout"]
  277.         ProposedDimensionMismatch = 0,
  278.     }
  279.     impl Error {
  280.         pub fn from_raw(n: u32) -> Option<Error> {
  281.             match n {
  282.                 0 => Some(Error::ProposedDimensionMismatch),
  283.                 _ => Option::None,
  284.             }
  285.         }
  286.         pub fn to_raw(&self) -> u32 {
  287.             *self as u32
  288.         }
  289.     }
  290.     #[derive(Debug)]
  291.     #[non_exhaustive]
  292.     pub enum Request {
  293.         #[doc = "destroy the river_layout object\n\nThis request indicates that the client will not use the river_layout\nobject any more.\n\nThis is a destructor, once sent this object cannot be used any longer."]
  294.         Destroy,
  295.         #[doc = "propose view dimensions\n\nThe client may use this request to push a view dimension proposal to the\nlayout.\n\nView dimension proposals apply to the views in order of the view list.\nAs an example, the first push_view_dimensions request will always affect\nthe first view in the list.\n\nA client must propose position and dimensions for the entire set of\nviews. Proposing to many or to few view dimensions is a protocol error.\n\nThis request may be sent before the corresponding view has been\nadvertised.\n\nThe compositor will transpose the dimensions so that 0 aligns with the\norigin of the usable width and height.\n\nThe serial is used to identify the layout demand this request is a\nresponse to."]
  296.         PushViewDimensions {
  297.             serial: u32,
  298.             x: i32,
  299.             y: i32,
  300.             width: u32,
  301.             height: u32,
  302.         },
  303.         #[doc = "commit a layout\n\nThe client may use this request to signal the compositor that it has\nfinished proposing a layout.\n\nSending this request irrevocably marks the layout as finished and the\nlayout demand will no longer be active. The client may not send any\nother responses to it, doing so is a protocol error.\n\nBeware that there are no guarantees that the proposed layout will be\nused, the compositor may silently ignore it.\n\nThe serial is used to identify the layout demand this request is a\nresponse to."]
  304.         Commit { serial: u32 },
  305.         #[doc = "parameters of layout have changed\n\nThe client may use this request to inform the compositor that one or\nmuliple of the parameters it uses to generate layouts have changed.\n\nIf the client is responsible for the current view layout, the compositor\nmay decide to send a new layout demand to update the layout."]
  306.         ParametersChanged,
  307.     }
  308.     impl super::MessageGroup for Request {
  309.         const MESSAGES: &'static [super::MessageDesc] = &[
  310.            super::MessageDesc {
  311.                name: "destroy",
  312.                since: 1,
  313.                signature: &[],
  314.                destructor: true,
  315.            },
  316.            super::MessageDesc {
  317.                name: "push_view_dimensions",
  318.                since: 1,
  319.                signature: &[
  320.                    super::ArgumentType::Uint,
  321.                    super::ArgumentType::Int,
  322.                    super::ArgumentType::Int,
  323.                    super::ArgumentType::Uint,
  324.                    super::ArgumentType::Uint,
  325.                ],
  326.                destructor: false,
  327.            },
  328.            super::MessageDesc {
  329.                name: "commit",
  330.                since: 1,
  331.                signature: &[super::ArgumentType::Uint],
  332.                destructor: false,
  333.            },
  334.            super::MessageDesc {
  335.                name: "parameters_changed",
  336.                since: 1,
  337.                signature: &[],
  338.                destructor: false,
  339.            },
  340.        ];
  341.        type Map = super::ProxyMap;
  342.        fn is_destructor(&self) -> bool {
  343.            match *self {
  344.                Request::Destroy => true,
  345.                _ => false,
  346.            }
  347.        }
  348.        fn opcode(&self) -> u16 {
  349.            match *self {
  350.                Request::Destroy => 0,
  351.                Request::PushViewDimensions { .. } => 1,
  352.                Request::Commit { .. } => 2,
  353.                Request::ParametersChanged => 3,
  354.            }
  355.        }
  356.        fn since(&self) -> u32 {
  357.            match *self {
  358.                Request::Destroy => 1,
  359.                Request::PushViewDimensions { .. } => 1,
  360.                Request::Commit { .. } => 1,
  361.                Request::ParametersChanged => 1,
  362.            }
  363.        }
  364.        fn child<Meta: ObjectMetadata>(
  365.            opcode: u16,
  366.            version: u32,
  367.            meta: &Meta,
  368.        ) -> Option<Object<Meta>> {
  369.            match opcode {
  370.                _ => None,
  371.            }
  372.        }
  373.        fn from_raw(msg: Message, map: &mut Self::Map) -> Result<Self, ()> {
  374.            panic!("Request::from_raw can not be used Client-side.")
  375.        }
  376.        fn into_raw(self, sender_id: u32) -> Message {
  377.            match self {
  378.                Request::Destroy => Message {
  379.                    sender_id: sender_id,
  380.                    opcode: 0,
  381.                    args: smallvec![],
  382.                },
  383.                Request::PushViewDimensions {
  384.                    serial,
  385.                    x,
  386.                    y,
  387.                    width,
  388.                    height,
  389.                } => Message {
  390.                    sender_id: sender_id,
  391.                    opcode: 1,
  392.                    args: smallvec![
  393.                        Argument::Uint(serial),
  394.                        Argument::Int(x),
  395.                        Argument::Int(y),
  396.                        Argument::Uint(width),
  397.                        Argument::Uint(height),
  398.                    ],
  399.                },
  400.                Request::Commit { serial } => Message {
  401.                    sender_id: sender_id,
  402.                    opcode: 2,
  403.                    args: smallvec![Argument::Uint(serial),],
  404.                },
  405.                Request::ParametersChanged => Message {
  406.                    sender_id: sender_id,
  407.                    opcode: 3,
  408.                    args: smallvec![],
  409.                },
  410.            }
  411.        }
  412.        unsafe fn from_raw_c(
  413.            obj: *mut ::std::os::raw::c_void,
  414.            opcode: u32,
  415.            args: *const wl_argument,
  416.        ) -> Result<Request, ()> {
  417.            panic!("Request::from_raw_c can not be used Client-side.")
  418.        }
  419.        fn as_raw_c_in<F, T>(self, f: F) -> T
  420.        where
  421.            F: FnOnce(u32, &mut [wl_argument]) -> T,
  422.        {
  423.            match self {
  424.                Request::Destroy => {
  425.                    let mut _args_array: [wl_argument; 0] = unsafe { ::std::mem::zeroed() };
  426.                    f(0, &mut _args_array)
  427.                }
  428.                Request::PushViewDimensions {
  429.                    serial,
  430.                    x,
  431.                    y,
  432.                    width,
  433.                    height,
  434.                } => {
  435.                    let mut _args_array: [wl_argument; 5] = unsafe { ::std::mem::zeroed() };
  436.                    _args_array[0].u = serial;
  437.                    _args_array[1].i = x;
  438.                    _args_array[2].i = y;
  439.                    _args_array[3].u = width;
  440.                    _args_array[4].u = height;
  441.                    f(1, &mut _args_array)
  442.                }
  443.                Request::Commit { serial } => {
  444.                    let mut _args_array: [wl_argument; 1] = unsafe { ::std::mem::zeroed() };
  445.                    _args_array[0].u = serial;
  446.                    f(2, &mut _args_array)
  447.                }
  448.                Request::ParametersChanged => {
  449.                    let mut _args_array: [wl_argument; 0] = unsafe { ::std::mem::zeroed() };
  450.                    f(3, &mut _args_array)
  451.                }
  452.            }
  453.        }
  454.    }
  455.    #[derive(Debug)]
  456.    #[non_exhaustive]
  457.    pub enum Event {
  458.        #[doc = "namespace already in use\n\nThe requested namespace is already used by another river_layout object.\nAfter receiving this event, the client should destroy the river_layout\nobject. Any other request will be ignored."]
  459.        NamespaceInUse,
  460.        #[doc = "the compositor is in demand of a layout\n\nThe compositor raises this event to inform the client that it requires a\nlayout for a set of views.\n\nThe usable width and height height indicate the space in which the\nclient can safely position views without interfering with desktop\nwidgets such as panels.\n\nThe serial of this event is used to identify subsequent events and\nrequest as belonging to this layout demand. Beware that the client\nmight need to handle multiple layout demands at the same time.\n\nThe server will ignore responses to all but the most recent\nlayout_demand. Thus, clients should only respond to the most recent\nlayout_demand received. If a newer layout_demand is received before the\nclient has finished responding to an old demand, the client should abort\nwork on the old demand as any further work would be wasted."]
  461.        LayoutDemand {
  462.            view_amount: u32,
  463.            usable_width: u32,
  464.            usable_height: u32,
  465.            serial: u32,
  466.        },
  467.        #[doc = "make layout client aware of view\n\nThis event is raised by the compositor after a layout_demand event.\nIt contains additional information about one out of the set of views\nfor which a layout has been demanded.\n\nIt is guaranteed that every view in the layout will be advertised\nexactly once, in the exact order of the view list.\n\nA client not interested in the additional information may ignore this\nevent.\n\nThe serial is the same as that of the layout demand this event belongs\nto."]
  468.        AdvertiseView {
  469.            tags: u32,
  470.            app_id: Option<String>,
  471.            serial: u32,
  472.        },
  473.        #[doc = "all views have been advertised\n\nThe compositor raises this event when it has advertised the entire set\nof views for which a layout has been demanded.\n\nA client not interested in the additional information may ignore this\nevent.\n\nThe serial is the same as that of the layout demand this event belongs\nto."]
  474.        AdvertiseDone { serial: u32 },
  475.    }
  476.    impl super::MessageGroup for Event {
  477.        const MESSAGES: &'static [super::MessageDesc] = &[
  478.             super::MessageDesc {
  479.                 name: "namespace_in_use",
  480.                 since: 1,
  481.                 signature: &[],
  482.                 destructor: false,
  483.             },
  484.             super::MessageDesc {
  485.                 name: "layout_demand",
  486.                 since: 1,
  487.                 signature: &[
  488.                     super::ArgumentType::Uint,
  489.                     super::ArgumentType::Uint,
  490.                     super::ArgumentType::Uint,
  491.                     super::ArgumentType::Uint,
  492.                 ],
  493.                 destructor: false,
  494.             },
  495.             super::MessageDesc {
  496.                 name: "advertise_view",
  497.                 since: 1,
  498.                 signature: &[
  499.                     super::ArgumentType::Uint,
  500.                     super::ArgumentType::Str,
  501.                     super::ArgumentType::Uint,
  502.                 ],
  503.                 destructor: false,
  504.             },
  505.             super::MessageDesc {
  506.                 name: "advertise_done",
  507.                 since: 1,
  508.                 signature: &[super::ArgumentType::Uint],
  509.                 destructor: false,
  510.             },
  511.         ];
  512.         type Map = super::ProxyMap;
  513.         fn is_destructor(&self) -> bool {
  514.             match *self {
  515.                 _ => false,
  516.             }
  517.         }
  518.         fn opcode(&self) -> u16 {
  519.             match *self {
  520.                 Event::NamespaceInUse => 0,
  521.                 Event::LayoutDemand { .. } => 1,
  522.                 Event::AdvertiseView { .. } => 2,
  523.                 Event::AdvertiseDone { .. } => 3,
  524.             }
  525.         }
  526.         fn since(&self) -> u32 {
  527.             match *self {
  528.                 Event::NamespaceInUse => 1,
  529.                 Event::LayoutDemand { .. } => 1,
  530.                 Event::AdvertiseView { .. } => 1,
  531.                 Event::AdvertiseDone { .. } => 1,
  532.             }
  533.         }
  534.         fn child<Meta: ObjectMetadata>(
  535.             opcode: u16,
  536.             version: u32,
  537.             meta: &Meta,
  538.         ) -> Option<Object<Meta>> {
  539.             match opcode {
  540.                 _ => None,
  541.             }
  542.         }
  543.         fn from_raw(msg: Message, map: &mut Self::Map) -> Result<Self, ()> {
  544.             match msg.opcode {
  545.                 0 => Ok(Event::NamespaceInUse),
  546.                 1 => {
  547.                     let mut args = msg.args.into_iter();
  548.                     Ok(Event::LayoutDemand {
  549.                         view_amount: {
  550.                             if let Some(Argument::Uint(val)) = args.next() {
  551.                                 val
  552.                             } else {
  553.                                 return Err(());
  554.                             }
  555.                         },
  556.                         usable_width: {
  557.                             if let Some(Argument::Uint(val)) = args.next() {
  558.                                 val
  559.                             } else {
  560.                                 return Err(());
  561.                             }
  562.                         },
  563.                         usable_height: {
  564.                             if let Some(Argument::Uint(val)) = args.next() {
  565.                                 val
  566.                             } else {
  567.                                 return Err(());
  568.                             }
  569.                         },
  570.                         serial: {
  571.                             if let Some(Argument::Uint(val)) = args.next() {
  572.                                 val
  573.                             } else {
  574.                                 return Err(());
  575.                             }
  576.                         },
  577.                     })
  578.                 }
  579.                 2 => {
  580.                     let mut args = msg.args.into_iter();
  581.                     Ok(Event::AdvertiseView {
  582.                         tags: {
  583.                             if let Some(Argument::Uint(val)) = args.next() {
  584.                                 val
  585.                             } else {
  586.                                 return Err(());
  587.                             }
  588.                         },
  589.                         app_id: {
  590.                             if let Some(Argument::Str(val)) = args.next() {
  591.                                 let s = String::from_utf8(val.into_bytes()).unwrap_or_else(|e| {
  592.                                     String::from_utf8_lossy(&e.into_bytes()).into()
  593.                                 });
  594.                                 if s.len() == 0 {
  595.                                     None
  596.                                 } else {
  597.                                     Some(s)
  598.                                 }
  599.                             } else {
  600.                                 return Err(());
  601.                             }
  602.                         },
  603.                         serial: {
  604.                             if let Some(Argument::Uint(val)) = args.next() {
  605.                                 val
  606.                             } else {
  607.                                 return Err(());
  608.                             }
  609.                         },
  610.                     })
  611.                 }
  612.                 3 => {
  613.                     let mut args = msg.args.into_iter();
  614.                     Ok(Event::AdvertiseDone {
  615.                         serial: {
  616.                             if let Some(Argument::Uint(val)) = args.next() {
  617.                                 val
  618.                             } else {
  619.                                 return Err(());
  620.                             }
  621.                         },
  622.                     })
  623.                 }
  624.                 _ => Err(()),
  625.             }
  626.         }
  627.         fn into_raw(self, sender_id: u32) -> Message {
  628.             panic!("Event::into_raw can not be used Client-side.")
  629.         }
  630.         unsafe fn from_raw_c(
  631.             obj: *mut ::std::os::raw::c_void,
  632.             opcode: u32,
  633.             args: *const wl_argument,
  634.         ) -> Result<Event, ()> {
  635.             match opcode {
  636.                 0 => Ok(Event::NamespaceInUse),
  637.                 1 => {
  638.                     let _args = ::std::slice::from_raw_parts(args, 4);
  639.                     Ok(Event::LayoutDemand {
  640.                         view_amount: _args[0].u,
  641.                         usable_width: _args[1].u,
  642.                         usable_height: _args[2].u,
  643.                         serial: _args[3].u,
  644.                     })
  645.                 }
  646.                 2 => {
  647.                     let _args = ::std::slice::from_raw_parts(args, 3);
  648.                     Ok(Event::AdvertiseView {
  649.                         tags: _args[0].u,
  650.                         app_id: if _args[1].s.is_null() {
  651.                             None
  652.                         } else {
  653.                             Some(
  654.                                 ::std::ffi::CStr::from_ptr(_args[1].s)
  655.                                     .to_string_lossy()
  656.                                     .into_owned(),
  657.                             )
  658.                         },
  659.                         serial: _args[2].u,
  660.                     })
  661.                 }
  662.                 3 => {
  663.                     let _args = ::std::slice::from_raw_parts(args, 1);
  664.                     Ok(Event::AdvertiseDone { serial: _args[0].u })
  665.                 }
  666.                 _ => return Err(()),
  667.             }
  668.         }
  669.         fn as_raw_c_in<F, T>(self, f: F) -> T
  670.         where
  671.             F: FnOnce(u32, &mut [wl_argument]) -> T,
  672.         {
  673.             panic!("Event::as_raw_c_in can not be used Client-side.")
  674.         }
  675.     }
  676.     #[derive(Clone, Eq, PartialEq)]
  677.     pub struct ZriverLayoutV1(Proxy<ZriverLayoutV1>);
  678.     impl AsRef<Proxy<ZriverLayoutV1>> for ZriverLayoutV1 {
  679.         #[inline]
  680.         fn as_ref(&self) -> &Proxy<Self> {
  681.             &self.0
  682.         }
  683.     }
  684.     impl From<Proxy<ZriverLayoutV1>> for ZriverLayoutV1 {
  685.         #[inline]
  686.         fn from(value: Proxy<Self>) -> Self {
  687.             ZriverLayoutV1(value)
  688.         }
  689.     }
  690.     impl From<ZriverLayoutV1> for Proxy<ZriverLayoutV1> {
  691.         #[inline]
  692.         fn from(value: ZriverLayoutV1) -> Self {
  693.             value.0
  694.         }
  695.     }
  696.     impl std::fmt::Debug for ZriverLayoutV1 {
  697.         fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  698.            f.write_fmt(format_args!("{:?}", self.0))
  699.        }
  700.    }
  701.    impl Interface for ZriverLayoutV1 {
  702.        type Request = Request;
  703.        type Event = Event;
  704.        const NAME: &'static str = "zriver_layout_v1";
  705.         const VERSION: u32 = 1;
  706.         fn c_interface() -> *const wl_interface {
  707.             unsafe { &zriver_layout_v1_interface }
  708.         }
  709.     }
  710.     impl ZriverLayoutV1 {
  711.         #[doc = "destroy the river_layout object\n\nThis request indicates that the client will not use the river_layout\nobject any more.\n\nThis is a destructor, you cannot send requests to this object any longer once this method is called."]
  712.         pub fn destroy(&self) -> () {
  713.             let msg = Request::Destroy;
  714.             self.0.send::<AnonymousObject>(msg, None);
  715.         }
  716.         #[doc = "propose view dimensions\n\nThe client may use this request to push a view dimension proposal to the\nlayout.\n\nView dimension proposals apply to the views in order of the view list.\nAs an example, the first push_view_dimensions request will always affect\nthe first view in the list.\n\nA client must propose position and dimensions for the entire set of\nviews. Proposing to many or to few view dimensions is a protocol error.\n\nThis request may be sent before the corresponding view has been\nadvertised.\n\nThe compositor will transpose the dimensions so that 0 aligns with the\norigin of the usable width and height.\n\nThe serial is used to identify the layout demand this request is a\nresponse to."]
  717.         pub fn push_view_dimensions(
  718.             &self,
  719.             serial: u32,
  720.             x: i32,
  721.             y: i32,
  722.             width: u32,
  723.             height: u32,
  724.         ) -> () {
  725.             let msg = Request::PushViewDimensions {
  726.                 serial: serial,
  727.                 x: x,
  728.                 y: y,
  729.                 width: width,
  730.                 height: height,
  731.             };
  732.             self.0.send::<AnonymousObject>(msg, None);
  733.         }
  734.         #[doc = "commit a layout\n\nThe client may use this request to signal the compositor that it has\nfinished proposing a layout.\n\nSending this request irrevocably marks the layout as finished and the\nlayout demand will no longer be active. The client may not send any\nother responses to it, doing so is a protocol error.\n\nBeware that there are no guarantees that the proposed layout will be\nused, the compositor may silently ignore it.\n\nThe serial is used to identify the layout demand this request is a\nresponse to."]
  735.         pub fn commit(&self, serial: u32) -> () {
  736.             let msg = Request::Commit { serial: serial };
  737.             self.0.send::<AnonymousObject>(msg, None);
  738.         }
  739.         #[doc = "parameters of layout have changed\n\nThe client may use this request to inform the compositor that one or\nmuliple of the parameters it uses to generate layouts have changed.\n\nIf the client is responsible for the current view layout, the compositor\nmay decide to send a new layout demand to update the layout."]
  740.         pub fn parameters_changed(&self) -> () {
  741.             let msg = Request::ParametersChanged;
  742.             self.0.send::<AnonymousObject>(msg, None);
  743.         }
  744.     }
  745.     #[doc = r" The minimal object version supporting this request"]
  746.     pub const REQ_DESTROY_SINCE: u32 = 1u32;
  747.     #[doc = r" The minimal object version supporting this request"]
  748.     pub const REQ_PUSH_VIEW_DIMENSIONS_SINCE: u32 = 1u32;
  749.     #[doc = r" The minimal object version supporting this request"]
  750.     pub const REQ_COMMIT_SINCE: u32 = 1u32;
  751.     #[doc = r" The minimal object version supporting this request"]
  752.     pub const REQ_PARAMETERS_CHANGED_SINCE: u32 = 1u32;
  753.     #[doc = r" The minimal object version supporting this event"]
  754.     pub const EVT_NAMESPACE_IN_USE_SINCE: u32 = 1u32;
  755.     #[doc = r" The minimal object version supporting this event"]
  756.     pub const EVT_LAYOUT_DEMAND_SINCE: u32 = 1u32;
  757.     #[doc = r" The minimal object version supporting this event"]
  758.     pub const EVT_ADVERTISE_VIEW_SINCE: u32 = 1u32;
  759.     #[doc = r" The minimal object version supporting this event"]
  760.     pub const EVT_ADVERTISE_DONE_SINCE: u32 = 1u32;
  761.     #[doc = r" C-representation of the messages of this interface, for interop"]
  762.     pub static mut zriver_layout_v1_requests: [wl_message; 4] = [
  763.         wl_message {
  764.             name: b"destroy\0" as *const u8 as *const c_char,
  765.             signature: b"\0" as *const u8 as *const c_char,
  766.             types: unsafe { &types_null as *const _ },
  767.         },
  768.         wl_message {
  769.             name: b"push_view_dimensions\0" as *const u8 as *const c_char,
  770.             signature: b"uiiuu\0" as *const u8 as *const c_char,
  771.             types: unsafe { &types_null as *const _ },
  772.         },
  773.         wl_message {
  774.             name: b"commit\0" as *const u8 as *const c_char,
  775.             signature: b"u\0" as *const u8 as *const c_char,
  776.             types: unsafe { &types_null as *const _ },
  777.         },
  778.         wl_message {
  779.             name: b"parameters_changed\0" as *const u8 as *const c_char,
  780.             signature: b"\0" as *const u8 as *const c_char,
  781.             types: unsafe { &types_null as *const _ },
  782.         },
  783.     ];
  784.     #[doc = r" C-representation of the messages of this interface, for interop"]
  785.     pub static mut zriver_layout_v1_events: [wl_message; 4] = [
  786.         wl_message {
  787.             name: b"namespace_in_use\0" as *const u8 as *const c_char,
  788.             signature: b"\0" as *const u8 as *const c_char,
  789.             types: unsafe { &types_null as *const _ },
  790.         },
  791.         wl_message {
  792.             name: b"layout_demand\0" as *const u8 as *const c_char,
  793.             signature: b"uuuu\0" as *const u8 as *const c_char,
  794.             types: unsafe { &types_null as *const _ },
  795.         },
  796.         wl_message {
  797.             name: b"advertise_view\0" as *const u8 as *const c_char,
  798.             signature: b"u?su\0" as *const u8 as *const c_char,
  799.             types: unsafe { &types_null as *const _ },
  800.         },
  801.         wl_message {
  802.             name: b"advertise_done\0" as *const u8 as *const c_char,
  803.             signature: b"u\0" as *const u8 as *const c_char,
  804.             types: unsafe { &types_null as *const _ },
  805.         },
  806.     ];
  807.     #[doc = r" C representation of this interface, for interop"]
  808.     pub static mut zriver_layout_v1_interface: wl_interface = wl_interface {
  809.         name: b"zriver_layout_v1\0" as *const u8 as *const c_char,
  810.         version: 1,
  811.         request_count: 4,
  812.         requests: unsafe { &zriver_layout_v1_requests as *const _ },
  813.         event_count: 4,
  814.         events: unsafe { &zriver_layout_v1_events as *const _ },
  815.     };
  816. }
  817.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement