1#![allow(warnings)]
25#![allow(clippy::all)]
26use anyhow;
27#[allow(unused_imports)]
28use fuchsia_wayland_core::{Array, Enum, Fixed, NewId, NewObject};
29use fuchsia_wayland_core::{ArgKind, Arg, FromArgs, IntoMessage, Message,
30 MessageGroupSpec, MessageHeader, MessageSpec, MessageType,
31 ObjectId, EncodeError, DecodeError, Interface};
32pub mod zaura_shell {
33use super::*;
34
35#[derive(Debug)]
42pub struct ZauraShell;
43
44impl Interface for ZauraShell {
45 const NAME: &'static str = "zaura_shell";
46 const VERSION: u32 = 8;
47 const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
48 MessageSpec(&[
50 ArgKind::NewId,
51 ArgKind::Object,
52 ]),
53 MessageSpec(&[
55 ArgKind::NewId,
56 ArgKind::Object,
57 ]),
58 ]);
59 const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
60 ]);
61 type Incoming = Request;
62 type Outgoing = Event;
63}
64
65#[derive(Debug)]
66pub enum Request {
67
68 GetAuraSurface {
75 id: NewObject<ZauraSurface>,
77 surface: ObjectId,
79 },
80
81 GetAuraOutput {
86 id: NewObject<ZauraOutput>,
88 output: ObjectId,
90 },
91}
92
93impl MessageType for Request {
94 fn log(&self, this: ObjectId) -> String {
95 match *self {
96 Request::GetAuraSurface {
97 ref id,
98 ref surface,
99 } => {
100 format!("zaura_shell@{:?}::get_aura_surface(id: {:?}, surface: {:?})", this, id, surface)
101 }
102 Request::GetAuraOutput {
103 ref id,
104 ref output,
105 } => {
106 format!("zaura_shell@{:?}::get_aura_output(id: {:?}, output: {:?})", this, id, output)
107 }
108 }
109 }
110 fn message_name(&self) -> &'static std::ffi::CStr{
111 match *self {
112 Request::GetAuraSurface { .. } => c"zaura_shell::get_aura_surface",
113 Request::GetAuraOutput { .. } => c"zaura_shell::get_aura_output",
114 }
115 }
116}
117#[derive(Debug)]
118pub enum Event {
119}
120
121impl MessageType for Event {
122 fn log(&self, this: ObjectId) -> String {
123 match *self {
124 }
125 }
126 fn message_name(&self) -> &'static std::ffi::CStr{
127 match *self {
128 }
129 }
130}
131impl IntoMessage for Event {
132 type Error = EncodeError;
133 fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
134 let mut header = MessageHeader {
135 sender: id,
136 opcode: 0,
137 length: 0,
138 };
139 let mut msg = Message::new();
140 msg.write_header(&header)?;
141 match self {
142 }
143 header.length = msg.bytes().len() as u16;
144 msg.rewind();
145 msg.write_header(&header)?;
146 Ok(msg)
147 }
148}
149impl FromArgs for Request {
150 fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
151 match op {
152 0 => {
153 let mut iter = args.into_iter();
154 Ok(Request::GetAuraSurface {
155 id: iter.next()
156 .ok_or(DecodeError::InsufficientArgs)?
157 .as_new_id()?.into(),
158 surface: iter.next()
159 .ok_or(DecodeError::InsufficientArgs)?
160 .as_object()?,
161
162 })
163 },
164 1 => {
165 let mut iter = args.into_iter();
166 Ok(Request::GetAuraOutput {
167 id: iter.next()
168 .ok_or(DecodeError::InsufficientArgs)?
169 .as_new_id()?.into(),
170 output: iter.next()
171 .ok_or(DecodeError::InsufficientArgs)?
172 .as_object()?,
173
174 })
175 },
176 _ => {
177 Err(DecodeError::InvalidOpcode(op).into())
178 },
179 }
180 }
181}
182#[derive(Copy, Clone, Debug, Eq, PartialEq)]
183#[repr(u32)]
184pub enum Error {
185 AuraSurfaceExists = 0,
187 AuraOutputExists = 1,
189}
190
191impl Error {
192 pub fn from_bits(v: u32) -> Option<Self> {
193 match v {
194 0 => Some(Error::AuraSurfaceExists),
195 1 => Some(Error::AuraOutputExists),
196 _ => None,
197 }
198 }
199
200 pub fn bits(&self) -> u32 {
201 *self as u32
202 }
203}
204impl Into<Arg> for Error {
205 fn into(self) -> Arg {
206 Arg::Uint(self.bits())
207 }
208}
209} pub use crate::zaura_shell::ZauraShell;
212pub use crate::zaura_shell::Request as ZauraShellRequest;
213pub use crate::zaura_shell::Event as ZauraShellEvent;
214pub mod zaura_surface {
215use super::*;
216
217#[derive(Debug)]
222pub struct ZauraSurface;
223
224impl Interface for ZauraSurface {
225 const NAME: &'static str = "zaura_surface";
226 const VERSION: u32 = 8;
227 const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
228 MessageSpec(&[
230 ArgKind::Uint,
231 ]),
232 MessageSpec(&[
234 ArgKind::Object,
235 ArgKind::Int,
236 ArgKind::Int,
237 ]),
238 MessageSpec(&[
240 ArgKind::Uint,
241 ArgKind::Uint,
242 ]),
243 MessageSpec(&[
245 ArgKind::String,
246 ]),
247 MessageSpec(&[
249 ArgKind::String,
250 ]),
251 MessageSpec(&[
253 ArgKind::Int,
254 ]),
255 MessageSpec(&[
257 ]),
258 MessageSpec(&[
260 ]),
261 ]);
262 const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
263 MessageSpec(&[
265 ArgKind::Fixed,
266 ArgKind::Uint,
267 ]),
268 ]);
269 type Incoming = Request;
270 type Outgoing = Event;
271}
272
273#[derive(Debug)]
274pub enum Request {
275
276 SetFrame {
280 type_: u32,
282 },
283
284 SetParent {
289 parent: ObjectId,
290 x: i32,
291 y: i32,
292 },
293
294 SetFrameColors {
298 active_color: u32,
300 inactive_color: u32,
302 },
303
304 SetStartupId {
308 startup_id: String,
309 },
310
311 SetApplicationId {
315 application_id: String,
316 },
317
318 SetClientSurfaceId {
322 client_surface_id: i32,
323 },
324
325 SetOcclusionTracking,
330
331 UnsetOcclusionTracking,
335}
336
337impl MessageType for Request {
338 fn log(&self, this: ObjectId) -> String {
339 match *self {
340 Request::SetFrame {
341 ref type_,
342 } => {
343 format!("zaura_surface@{:?}::set_frame(type: {:?})", this, type_)
344 }
345 Request::SetParent {
346 ref parent,
347 ref x,
348 ref y,
349 } => {
350 format!("zaura_surface@{:?}::set_parent(parent: {:?}, x: {:?}, y: {:?})", this, parent, x, y)
351 }
352 Request::SetFrameColors {
353 ref active_color,
354 ref inactive_color,
355 } => {
356 format!("zaura_surface@{:?}::set_frame_colors(active_color: {:?}, inactive_color: {:?})", this, active_color, inactive_color)
357 }
358 Request::SetStartupId {
359 ref startup_id,
360 } => {
361 format!("zaura_surface@{:?}::set_startup_id(startup_id: {:?})", this, startup_id)
362 }
363 Request::SetApplicationId {
364 ref application_id,
365 } => {
366 format!("zaura_surface@{:?}::set_application_id(application_id: {:?})", this, application_id)
367 }
368 Request::SetClientSurfaceId {
369 ref client_surface_id,
370 } => {
371 format!("zaura_surface@{:?}::set_client_surface_id(client_surface_id: {:?})", this, client_surface_id)
372 }
373 Request::SetOcclusionTracking {
374 } => {
375 format!("zaura_surface@{:?}::set_occlusion_tracking()", this)
376 }
377 Request::UnsetOcclusionTracking {
378 } => {
379 format!("zaura_surface@{:?}::unset_occlusion_tracking()", this)
380 }
381 }
382 }
383 fn message_name(&self) -> &'static std::ffi::CStr{
384 match *self {
385 Request::SetFrame { .. } => c"zaura_surface::set_frame",
386 Request::SetParent { .. } => c"zaura_surface::set_parent",
387 Request::SetFrameColors { .. } => c"zaura_surface::set_frame_colors",
388 Request::SetStartupId { .. } => c"zaura_surface::set_startup_id",
389 Request::SetApplicationId { .. } => c"zaura_surface::set_application_id",
390 Request::SetClientSurfaceId { .. } => c"zaura_surface::set_client_surface_id",
391 Request::SetOcclusionTracking { .. } => c"zaura_surface::set_occlusion_tracking",
392 Request::UnsetOcclusionTracking { .. } => c"zaura_surface::unset_occlusion_tracking",
393 }
394 }
395}
396#[derive(Debug)]
397pub enum Event {
398
399 OcclusionChanged {
405 occlusion_fraction: Fixed,
406 occlusion_reason: u32,
407 },
408}
409
410impl MessageType for Event {
411 fn log(&self, this: ObjectId) -> String {
412 match *self {
413 Event::OcclusionChanged {
414 ref occlusion_fraction,
415 ref occlusion_reason,
416 } => {
417 format!("zaura_surface@{:?}::occlusion_changed(occlusion_fraction: {:?}, occlusion_reason: {:?})", this, occlusion_fraction, occlusion_reason)
418 }
419 }
420 }
421 fn message_name(&self) -> &'static std::ffi::CStr{
422 match *self {
423 Event::OcclusionChanged { .. } => c"zaura_surface::occlusion_changed",
424 }
425 }
426}
427impl IntoMessage for Event {
428 type Error = EncodeError;
429 fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
430 let mut header = MessageHeader {
431 sender: id,
432 opcode: 0,
433 length: 0,
434 };
435 let mut msg = Message::new();
436 msg.write_header(&header)?;
437 match self {
438 Event::OcclusionChanged {
439 occlusion_fraction,
440 occlusion_reason,
441 } => {
442 msg.write_arg(Arg::Fixed(occlusion_fraction))?;
443 msg.write_arg(Arg::Uint(occlusion_reason))?;
444 header.opcode = 0;
445 },
446 }
447 header.length = msg.bytes().len() as u16;
448 msg.rewind();
449 msg.write_header(&header)?;
450 Ok(msg)
451 }
452}
453impl FromArgs for Request {
454 fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
455 match op {
456 0 => {
457 let mut iter = args.into_iter();
458 Ok(Request::SetFrame {
459 type_: iter.next()
460 .ok_or(DecodeError::InsufficientArgs)?
461 .as_uint()?,
462
463 })
464 },
465 1 => {
466 let mut iter = args.into_iter();
467 Ok(Request::SetParent {
468 parent: iter.next()
469 .ok_or(DecodeError::InsufficientArgs)?
470 .as_object()?,
471 x: iter.next()
472 .ok_or(DecodeError::InsufficientArgs)?
473 .as_int()?,
474 y: iter.next()
475 .ok_or(DecodeError::InsufficientArgs)?
476 .as_int()?,
477
478 })
479 },
480 2 => {
481 let mut iter = args.into_iter();
482 Ok(Request::SetFrameColors {
483 active_color: iter.next()
484 .ok_or(DecodeError::InsufficientArgs)?
485 .as_uint()?,
486 inactive_color: iter.next()
487 .ok_or(DecodeError::InsufficientArgs)?
488 .as_uint()?,
489
490 })
491 },
492 3 => {
493 let mut iter = args.into_iter();
494 Ok(Request::SetStartupId {
495 startup_id: iter.next()
496 .ok_or(DecodeError::InsufficientArgs)?
497 .as_string()?,
498
499 })
500 },
501 4 => {
502 let mut iter = args.into_iter();
503 Ok(Request::SetApplicationId {
504 application_id: iter.next()
505 .ok_or(DecodeError::InsufficientArgs)?
506 .as_string()?,
507
508 })
509 },
510 5 => {
511 let mut iter = args.into_iter();
512 Ok(Request::SetClientSurfaceId {
513 client_surface_id: iter.next()
514 .ok_or(DecodeError::InsufficientArgs)?
515 .as_int()?,
516
517 })
518 },
519 6 => {
520 let mut iter = args.into_iter();
521 Ok(Request::SetOcclusionTracking {
522
523 })
524 },
525 7 => {
526 let mut iter = args.into_iter();
527 Ok(Request::UnsetOcclusionTracking {
528
529 })
530 },
531 _ => {
532 Err(DecodeError::InvalidOpcode(op).into())
533 },
534 }
535 }
536}
537
538#[derive(Copy, Clone, Debug, Eq, PartialEq)]
542#[repr(u32)]
543pub enum FrameType {
544 None = 0,
546 Normal = 1,
548 Shadow = 2,
550}
551
552impl FrameType {
553 pub fn from_bits(v: u32) -> Option<Self> {
554 match v {
555 0 => Some(FrameType::None),
556 1 => Some(FrameType::Normal),
557 2 => Some(FrameType::Shadow),
558 _ => None,
559 }
560 }
561
562 pub fn bits(&self) -> u32 {
563 *self as u32
564 }
565}
566impl Into<Arg> for FrameType {
567 fn into(self) -> Arg {
568 Arg::Uint(self.bits())
569 }
570}
571
572#[derive(Copy, Clone, Debug, Eq, PartialEq)]
578#[repr(u32)]
579pub enum OcclusionChangeReason {
580 UserAction = 1,
582}
583
584impl OcclusionChangeReason {
585 pub fn from_bits(v: u32) -> Option<Self> {
586 match v {
587 1 => Some(OcclusionChangeReason::UserAction),
588 _ => None,
589 }
590 }
591
592 pub fn bits(&self) -> u32 {
593 *self as u32
594 }
595}
596impl Into<Arg> for OcclusionChangeReason {
597 fn into(self) -> Arg {
598 Arg::Uint(self.bits())
599 }
600}
601} pub use crate::zaura_surface::ZauraSurface;
604pub use crate::zaura_surface::Request as ZauraSurfaceRequest;
605pub use crate::zaura_surface::Event as ZauraSurfaceEvent;
606pub mod zaura_output {
607use super::*;
608
609#[derive(Debug)]
614pub struct ZauraOutput;
615
616impl Interface for ZauraOutput {
617 const NAME: &'static str = "zaura_output";
618 const VERSION: u32 = 6;
619 const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
620 ]);
621 const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
622 MessageSpec(&[
624 ArgKind::Uint,
625 ArgKind::Uint,
626 ]),
627 MessageSpec(&[
629 ArgKind::Uint,
630 ]),
631 MessageSpec(&[
633 ArgKind::Uint,
634 ]),
635 ]);
636 type Incoming = Request;
637 type Outgoing = Event;
638}
639
640#[derive(Debug)]
641pub enum Request {
642}
643
644impl MessageType for Request {
645 fn log(&self, this: ObjectId) -> String {
646 match *self {
647 }
648 }
649 fn message_name(&self) -> &'static std::ffi::CStr{
650 match *self {
651 }
652 }
653}
654#[derive(Debug)]
655pub enum Event {
656
657 Scale {
667 flags: ScaleProperty,
669 scale: ScaleFactor,
671 },
672
673 Connection {
679 connection: ConnectionType,
681 },
682
683 DeviceScaleFactor {
695 scale: ScaleFactor,
697 },
698}
699
700impl MessageType for Event {
701 fn log(&self, this: ObjectId) -> String {
702 match *self {
703 Event::Scale {
704 ref flags,
705 ref scale,
706 } => {
707 format!("zaura_output@{:?}::scale(flags: {:?}, scale: {:?})", this, flags, scale)
708 }
709 Event::Connection {
710 ref connection,
711 } => {
712 format!("zaura_output@{:?}::connection(connection: {:?})", this, connection)
713 }
714 Event::DeviceScaleFactor {
715 ref scale,
716 } => {
717 format!("zaura_output@{:?}::device_scale_factor(scale: {:?})", this, scale)
718 }
719 }
720 }
721 fn message_name(&self) -> &'static std::ffi::CStr{
722 match *self {
723 Event::Scale { .. } => c"zaura_output::scale",
724 Event::Connection { .. } => c"zaura_output::connection",
725 Event::DeviceScaleFactor { .. } => c"zaura_output::device_scale_factor",
726 }
727 }
728}
729impl IntoMessage for Event {
730 type Error = EncodeError;
731 fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
732 let mut header = MessageHeader {
733 sender: id,
734 opcode: 0,
735 length: 0,
736 };
737 let mut msg = Message::new();
738 msg.write_header(&header)?;
739 match self {
740 Event::Scale {
741 flags,
742 scale,
743 } => {
744 msg.write_arg(Arg::Uint(flags.bits()))?;
745 msg.write_arg(Arg::Uint(scale.bits()))?;
746 header.opcode = 0;
747 },
748 Event::Connection {
749 connection,
750 } => {
751 msg.write_arg(Arg::Uint(connection.bits()))?;
752 header.opcode = 1;
753 },
754 Event::DeviceScaleFactor {
755 scale,
756 } => {
757 msg.write_arg(Arg::Uint(scale.bits()))?;
758 header.opcode = 2;
759 },
760 }
761 header.length = msg.bytes().len() as u16;
762 msg.rewind();
763 msg.write_header(&header)?;
764 Ok(msg)
765 }
766}
767impl FromArgs for Request {
768 fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
769 match op {
770 _ => {
771 Err(DecodeError::InvalidOpcode(op).into())
772 },
773 }
774 }
775}
776::bitflags::bitflags! {
777
778 #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
783 pub struct ScaleProperty: u32 {
784 const Current = 1;
786 const Preferred = 2;
788 }
789}
790impl Into<Arg> for ScaleProperty {
791 fn into(self) -> Arg {
792 Arg::Uint(self.bits())
793 }
794}
795#[derive(Copy, Clone, Debug, Eq, PartialEq)]
796#[repr(u32)]
797pub enum ScaleFactor {
798 _0400 = 400,
799 _0500 = 500,
800 _0550 = 550,
801 _0600 = 600,
802 _0625 = 625,
803 _0650 = 650,
804 _0700 = 700,
805 _0750 = 750,
806 _0800 = 800,
807 _0850 = 850,
808 _0900 = 900,
809 _0950 = 950,
810 _1000 = 1000,
811 _1050 = 1050,
812 _1100 = 1100,
813 _1150 = 1150,
814 _1125 = 1125,
815 _1200 = 1200,
816 _1250 = 1250,
817 _1300 = 1300,
818 _1400 = 1400,
819 _1450 = 1450,
820 _1500 = 1500,
821 _1600 = 1600,
822 _1750 = 1750,
823 _1800 = 1800,
824 _2000 = 2000,
825 _2200 = 2200,
826 _2250 = 2250,
827 _2500 = 2500,
828 _2750 = 2750,
829 _3000 = 3000,
830 _3500 = 3500,
831 _4000 = 4000,
832 _4500 = 4500,
833 _5000 = 5000,
834}
835
836impl ScaleFactor {
837 pub fn from_bits(v: u32) -> Option<Self> {
838 match v {
839 400 => Some(ScaleFactor::_0400),
840 500 => Some(ScaleFactor::_0500),
841 550 => Some(ScaleFactor::_0550),
842 600 => Some(ScaleFactor::_0600),
843 625 => Some(ScaleFactor::_0625),
844 650 => Some(ScaleFactor::_0650),
845 700 => Some(ScaleFactor::_0700),
846 750 => Some(ScaleFactor::_0750),
847 800 => Some(ScaleFactor::_0800),
848 850 => Some(ScaleFactor::_0850),
849 900 => Some(ScaleFactor::_0900),
850 950 => Some(ScaleFactor::_0950),
851 1000 => Some(ScaleFactor::_1000),
852 1050 => Some(ScaleFactor::_1050),
853 1100 => Some(ScaleFactor::_1100),
854 1150 => Some(ScaleFactor::_1150),
855 1125 => Some(ScaleFactor::_1125),
856 1200 => Some(ScaleFactor::_1200),
857 1250 => Some(ScaleFactor::_1250),
858 1300 => Some(ScaleFactor::_1300),
859 1400 => Some(ScaleFactor::_1400),
860 1450 => Some(ScaleFactor::_1450),
861 1500 => Some(ScaleFactor::_1500),
862 1600 => Some(ScaleFactor::_1600),
863 1750 => Some(ScaleFactor::_1750),
864 1800 => Some(ScaleFactor::_1800),
865 2000 => Some(ScaleFactor::_2000),
866 2200 => Some(ScaleFactor::_2200),
867 2250 => Some(ScaleFactor::_2250),
868 2500 => Some(ScaleFactor::_2500),
869 2750 => Some(ScaleFactor::_2750),
870 3000 => Some(ScaleFactor::_3000),
871 3500 => Some(ScaleFactor::_3500),
872 4000 => Some(ScaleFactor::_4000),
873 4500 => Some(ScaleFactor::_4500),
874 5000 => Some(ScaleFactor::_5000),
875 _ => None,
876 }
877 }
878
879 pub fn bits(&self) -> u32 {
880 *self as u32
881 }
882}
883impl Into<Arg> for ScaleFactor {
884 fn into(self) -> Arg {
885 Arg::Uint(self.bits())
886 }
887}
888#[derive(Copy, Clone, Debug, Eq, PartialEq)]
889#[repr(u32)]
890pub enum ConnectionType {
891 Unknown = 0,
892 Internal = 1,
893}
894
895impl ConnectionType {
896 pub fn from_bits(v: u32) -> Option<Self> {
897 match v {
898 0 => Some(ConnectionType::Unknown),
899 1 => Some(ConnectionType::Internal),
900 _ => None,
901 }
902 }
903
904 pub fn bits(&self) -> u32 {
905 *self as u32
906 }
907}
908impl Into<Arg> for ConnectionType {
909 fn into(self) -> Arg {
910 Arg::Uint(self.bits())
911 }
912}
913} pub use crate::zaura_output::ZauraOutput;
916pub use crate::zaura_output::Request as ZauraOutputRequest;
917pub use crate::zaura_output::Event as ZauraOutputEvent;