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 = Event;
62 type Outgoing = Request;
63}
64
65#[derive(Debug)]
66pub enum Request {
67
68 GetAuraSurface {
75 id: NewId,
77 surface: ObjectId,
79 },
80
81 GetAuraOutput {
86 id: NewId,
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 Request {
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 Request::GetAuraSurface {
143 id,
144 surface,
145 } => {
146 msg.write_arg(Arg::NewId(id))?;
147 msg.write_arg(Arg::Object(surface))?;
148 header.opcode = 0;
149 },
150 Request::GetAuraOutput {
151 id,
152 output,
153 } => {
154 msg.write_arg(Arg::NewId(id))?;
155 msg.write_arg(Arg::Object(output))?;
156 header.opcode = 1;
157 },
158 }
159 header.length = msg.bytes().len() as u16;
160 msg.rewind();
161 msg.write_header(&header)?;
162 Ok(msg)
163 }
164}
165impl FromArgs for Event {
166 fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
167 match op {
168 _ => {
169 Err(DecodeError::InvalidOpcode(op).into())
170 },
171 }
172 }
173}
174#[derive(Copy, Clone, Debug, Eq, PartialEq)]
175#[repr(u32)]
176pub enum Error {
177 AuraSurfaceExists = 0,
179 AuraOutputExists = 1,
181}
182
183impl Error {
184 pub fn from_bits(v: u32) -> Option<Self> {
185 match v {
186 0 => Some(Error::AuraSurfaceExists),
187 1 => Some(Error::AuraOutputExists),
188 _ => None,
189 }
190 }
191
192 pub fn bits(&self) -> u32 {
193 *self as u32
194 }
195}
196impl Into<Arg> for Error {
197 fn into(self) -> Arg {
198 Arg::Uint(self.bits())
199 }
200}
201} pub use crate::zaura_shell::ZauraShell;
204pub use crate::zaura_shell::Request as ZauraShellRequest;
205pub use crate::zaura_shell::Event as ZauraShellEvent;
206pub mod zaura_surface {
207use super::*;
208
209#[derive(Debug)]
214pub struct ZauraSurface;
215
216impl Interface for ZauraSurface {
217 const NAME: &'static str = "zaura_surface";
218 const VERSION: u32 = 8;
219 const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
220 MessageSpec(&[
222 ArgKind::Uint,
223 ]),
224 MessageSpec(&[
226 ArgKind::Object,
227 ArgKind::Int,
228 ArgKind::Int,
229 ]),
230 MessageSpec(&[
232 ArgKind::Uint,
233 ArgKind::Uint,
234 ]),
235 MessageSpec(&[
237 ArgKind::String,
238 ]),
239 MessageSpec(&[
241 ArgKind::String,
242 ]),
243 MessageSpec(&[
245 ArgKind::Int,
246 ]),
247 MessageSpec(&[
249 ]),
250 MessageSpec(&[
252 ]),
253 ]);
254 const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
255 MessageSpec(&[
257 ArgKind::Fixed,
258 ArgKind::Uint,
259 ]),
260 ]);
261 type Incoming = Event;
262 type Outgoing = Request;
263}
264
265#[derive(Debug)]
266pub enum Request {
267
268 SetFrame {
272 type_: u32,
274 },
275
276 SetParent {
281 parent: ObjectId,
282 x: i32,
283 y: i32,
284 },
285
286 SetFrameColors {
290 active_color: u32,
292 inactive_color: u32,
294 },
295
296 SetStartupId {
300 startup_id: String,
301 },
302
303 SetApplicationId {
307 application_id: String,
308 },
309
310 SetClientSurfaceId {
314 client_surface_id: i32,
315 },
316
317 SetOcclusionTracking,
322
323 UnsetOcclusionTracking,
327}
328
329impl MessageType for Request {
330 fn log(&self, this: ObjectId) -> String {
331 match *self {
332 Request::SetFrame {
333 ref type_,
334 } => {
335 format!("zaura_surface@{:?}::set_frame(type: {:?})", this, type_)
336 }
337 Request::SetParent {
338 ref parent,
339 ref x,
340 ref y,
341 } => {
342 format!("zaura_surface@{:?}::set_parent(parent: {:?}, x: {:?}, y: {:?})", this, parent, x, y)
343 }
344 Request::SetFrameColors {
345 ref active_color,
346 ref inactive_color,
347 } => {
348 format!("zaura_surface@{:?}::set_frame_colors(active_color: {:?}, inactive_color: {:?})", this, active_color, inactive_color)
349 }
350 Request::SetStartupId {
351 ref startup_id,
352 } => {
353 format!("zaura_surface@{:?}::set_startup_id(startup_id: {:?})", this, startup_id)
354 }
355 Request::SetApplicationId {
356 ref application_id,
357 } => {
358 format!("zaura_surface@{:?}::set_application_id(application_id: {:?})", this, application_id)
359 }
360 Request::SetClientSurfaceId {
361 ref client_surface_id,
362 } => {
363 format!("zaura_surface@{:?}::set_client_surface_id(client_surface_id: {:?})", this, client_surface_id)
364 }
365 Request::SetOcclusionTracking {
366 } => {
367 format!("zaura_surface@{:?}::set_occlusion_tracking()", this)
368 }
369 Request::UnsetOcclusionTracking {
370 } => {
371 format!("zaura_surface@{:?}::unset_occlusion_tracking()", this)
372 }
373 }
374 }
375 fn message_name(&self) -> &'static std::ffi::CStr{
376 match *self {
377 Request::SetFrame { .. } => c"zaura_surface::set_frame",
378 Request::SetParent { .. } => c"zaura_surface::set_parent",
379 Request::SetFrameColors { .. } => c"zaura_surface::set_frame_colors",
380 Request::SetStartupId { .. } => c"zaura_surface::set_startup_id",
381 Request::SetApplicationId { .. } => c"zaura_surface::set_application_id",
382 Request::SetClientSurfaceId { .. } => c"zaura_surface::set_client_surface_id",
383 Request::SetOcclusionTracking { .. } => c"zaura_surface::set_occlusion_tracking",
384 Request::UnsetOcclusionTracking { .. } => c"zaura_surface::unset_occlusion_tracking",
385 }
386 }
387}
388#[derive(Debug)]
389pub enum Event {
390
391 OcclusionChanged {
397 occlusion_fraction: Fixed,
398 occlusion_reason: u32,
399 },
400}
401
402impl MessageType for Event {
403 fn log(&self, this: ObjectId) -> String {
404 match *self {
405 Event::OcclusionChanged {
406 ref occlusion_fraction,
407 ref occlusion_reason,
408 } => {
409 format!("zaura_surface@{:?}::occlusion_changed(occlusion_fraction: {:?}, occlusion_reason: {:?})", this, occlusion_fraction, occlusion_reason)
410 }
411 }
412 }
413 fn message_name(&self) -> &'static std::ffi::CStr{
414 match *self {
415 Event::OcclusionChanged { .. } => c"zaura_surface::occlusion_changed",
416 }
417 }
418}
419impl IntoMessage for Request {
420 type Error = EncodeError;
421 fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
422 let mut header = MessageHeader {
423 sender: id,
424 opcode: 0,
425 length: 0,
426 };
427 let mut msg = Message::new();
428 msg.write_header(&header)?;
429 match self {
430 Request::SetFrame {
431 type_,
432 } => {
433 msg.write_arg(Arg::Uint(type_))?;
434 header.opcode = 0;
435 },
436 Request::SetParent {
437 parent,
438 x,
439 y,
440 } => {
441 msg.write_arg(Arg::Object(parent))?;
442 msg.write_arg(Arg::Int(x))?;
443 msg.write_arg(Arg::Int(y))?;
444 header.opcode = 1;
445 },
446 Request::SetFrameColors {
447 active_color,
448 inactive_color,
449 } => {
450 msg.write_arg(Arg::Uint(active_color))?;
451 msg.write_arg(Arg::Uint(inactive_color))?;
452 header.opcode = 2;
453 },
454 Request::SetStartupId {
455 startup_id,
456 } => {
457 msg.write_arg(Arg::String(startup_id))?;
458 header.opcode = 3;
459 },
460 Request::SetApplicationId {
461 application_id,
462 } => {
463 msg.write_arg(Arg::String(application_id))?;
464 header.opcode = 4;
465 },
466 Request::SetClientSurfaceId {
467 client_surface_id,
468 } => {
469 msg.write_arg(Arg::Int(client_surface_id))?;
470 header.opcode = 5;
471 },
472 Request::SetOcclusionTracking {
473 } => {
474 header.opcode = 6;
475 },
476 Request::UnsetOcclusionTracking {
477 } => {
478 header.opcode = 7;
479 },
480 }
481 header.length = msg.bytes().len() as u16;
482 msg.rewind();
483 msg.write_header(&header)?;
484 Ok(msg)
485 }
486}
487impl FromArgs for Event {
488 fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
489 match op {
490 0 => {
491 let mut iter = args.into_iter();
492 Ok(Event::OcclusionChanged {
493 occlusion_fraction: iter.next()
494 .ok_or(DecodeError::InsufficientArgs)?
495 .as_fixed()?.into(),
496 occlusion_reason: iter.next()
497 .ok_or(DecodeError::InsufficientArgs)?
498 .as_uint()?,
499
500 })
501 },
502 _ => {
503 Err(DecodeError::InvalidOpcode(op).into())
504 },
505 }
506 }
507}
508
509#[derive(Copy, Clone, Debug, Eq, PartialEq)]
513#[repr(u32)]
514pub enum FrameType {
515 None = 0,
517 Normal = 1,
519 Shadow = 2,
521}
522
523impl FrameType {
524 pub fn from_bits(v: u32) -> Option<Self> {
525 match v {
526 0 => Some(FrameType::None),
527 1 => Some(FrameType::Normal),
528 2 => Some(FrameType::Shadow),
529 _ => None,
530 }
531 }
532
533 pub fn bits(&self) -> u32 {
534 *self as u32
535 }
536}
537impl Into<Arg> for FrameType {
538 fn into(self) -> Arg {
539 Arg::Uint(self.bits())
540 }
541}
542
543#[derive(Copy, Clone, Debug, Eq, PartialEq)]
549#[repr(u32)]
550pub enum OcclusionChangeReason {
551 UserAction = 1,
553}
554
555impl OcclusionChangeReason {
556 pub fn from_bits(v: u32) -> Option<Self> {
557 match v {
558 1 => Some(OcclusionChangeReason::UserAction),
559 _ => None,
560 }
561 }
562
563 pub fn bits(&self) -> u32 {
564 *self as u32
565 }
566}
567impl Into<Arg> for OcclusionChangeReason {
568 fn into(self) -> Arg {
569 Arg::Uint(self.bits())
570 }
571}
572} pub use crate::zaura_surface::ZauraSurface;
575pub use crate::zaura_surface::Request as ZauraSurfaceRequest;
576pub use crate::zaura_surface::Event as ZauraSurfaceEvent;
577pub mod zaura_output {
578use super::*;
579
580#[derive(Debug)]
585pub struct ZauraOutput;
586
587impl Interface for ZauraOutput {
588 const NAME: &'static str = "zaura_output";
589 const VERSION: u32 = 6;
590 const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
591 ]);
592 const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
593 MessageSpec(&[
595 ArgKind::Uint,
596 ArgKind::Uint,
597 ]),
598 MessageSpec(&[
600 ArgKind::Uint,
601 ]),
602 MessageSpec(&[
604 ArgKind::Uint,
605 ]),
606 ]);
607 type Incoming = Event;
608 type Outgoing = Request;
609}
610
611#[derive(Debug)]
612pub enum Request {
613}
614
615impl MessageType for Request {
616 fn log(&self, this: ObjectId) -> String {
617 match *self {
618 }
619 }
620 fn message_name(&self) -> &'static std::ffi::CStr{
621 match *self {
622 }
623 }
624}
625#[derive(Debug)]
626pub enum Event {
627
628 Scale {
638 flags: Enum<ScaleProperty>,
640 scale: Enum<ScaleFactor>,
642 },
643
644 Connection {
650 connection: Enum<ConnectionType>,
652 },
653
654 DeviceScaleFactor {
666 scale: Enum<ScaleFactor>,
668 },
669}
670
671impl MessageType for Event {
672 fn log(&self, this: ObjectId) -> String {
673 match *self {
674 Event::Scale {
675 ref flags,
676 ref scale,
677 } => {
678 format!("zaura_output@{:?}::scale(flags: {:?}, scale: {:?})", this, flags, scale)
679 }
680 Event::Connection {
681 ref connection,
682 } => {
683 format!("zaura_output@{:?}::connection(connection: {:?})", this, connection)
684 }
685 Event::DeviceScaleFactor {
686 ref scale,
687 } => {
688 format!("zaura_output@{:?}::device_scale_factor(scale: {:?})", this, scale)
689 }
690 }
691 }
692 fn message_name(&self) -> &'static std::ffi::CStr{
693 match *self {
694 Event::Scale { .. } => c"zaura_output::scale",
695 Event::Connection { .. } => c"zaura_output::connection",
696 Event::DeviceScaleFactor { .. } => c"zaura_output::device_scale_factor",
697 }
698 }
699}
700impl IntoMessage for Request {
701 type Error = EncodeError;
702 fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
703 let mut header = MessageHeader {
704 sender: id,
705 opcode: 0,
706 length: 0,
707 };
708 let mut msg = Message::new();
709 msg.write_header(&header)?;
710 match self {
711 }
712 header.length = msg.bytes().len() as u16;
713 msg.rewind();
714 msg.write_header(&header)?;
715 Ok(msg)
716 }
717}
718impl FromArgs for Event {
719 fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
720 match op {
721 0 => {
722 let mut iter = args.into_iter();
723 Ok(Event::Scale {
724 flags: iter.next()
725 .ok_or(DecodeError::InsufficientArgs)?
726 .as_uint().map(|i| match ScaleProperty::from_bits(i) {
727 Some(e) => Enum::Recognized(e),
728 None => Enum::Unrecognized(i),
729 })?,
730 scale: iter.next()
731 .ok_or(DecodeError::InsufficientArgs)?
732 .as_uint().map(|i| match ScaleFactor::from_bits(i) {
733 Some(e) => Enum::Recognized(e),
734 None => Enum::Unrecognized(i),
735 })?,
736
737 })
738 },
739 1 => {
740 let mut iter = args.into_iter();
741 Ok(Event::Connection {
742 connection: iter.next()
743 .ok_or(DecodeError::InsufficientArgs)?
744 .as_uint().map(|i| match ConnectionType::from_bits(i) {
745 Some(e) => Enum::Recognized(e),
746 None => Enum::Unrecognized(i),
747 })?,
748
749 })
750 },
751 2 => {
752 let mut iter = args.into_iter();
753 Ok(Event::DeviceScaleFactor {
754 scale: iter.next()
755 .ok_or(DecodeError::InsufficientArgs)?
756 .as_uint().map(|i| match ScaleFactor::from_bits(i) {
757 Some(e) => Enum::Recognized(e),
758 None => Enum::Unrecognized(i),
759 })?,
760
761 })
762 },
763 _ => {
764 Err(DecodeError::InvalidOpcode(op).into())
765 },
766 }
767 }
768}
769::bitflags::bitflags! {
770
771 #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
776 pub struct ScaleProperty: u32 {
777 const Current = 1;
779 const Preferred = 2;
781 }
782}
783impl Into<Arg> for ScaleProperty {
784 fn into(self) -> Arg {
785 Arg::Uint(self.bits())
786 }
787}
788#[derive(Copy, Clone, Debug, Eq, PartialEq)]
789#[repr(u32)]
790pub enum ScaleFactor {
791 _0400 = 400,
792 _0500 = 500,
793 _0550 = 550,
794 _0600 = 600,
795 _0625 = 625,
796 _0650 = 650,
797 _0700 = 700,
798 _0750 = 750,
799 _0800 = 800,
800 _0850 = 850,
801 _0900 = 900,
802 _0950 = 950,
803 _1000 = 1000,
804 _1050 = 1050,
805 _1100 = 1100,
806 _1150 = 1150,
807 _1125 = 1125,
808 _1200 = 1200,
809 _1250 = 1250,
810 _1300 = 1300,
811 _1400 = 1400,
812 _1450 = 1450,
813 _1500 = 1500,
814 _1600 = 1600,
815 _1750 = 1750,
816 _1800 = 1800,
817 _2000 = 2000,
818 _2200 = 2200,
819 _2250 = 2250,
820 _2500 = 2500,
821 _2750 = 2750,
822 _3000 = 3000,
823 _3500 = 3500,
824 _4000 = 4000,
825 _4500 = 4500,
826 _5000 = 5000,
827}
828
829impl ScaleFactor {
830 pub fn from_bits(v: u32) -> Option<Self> {
831 match v {
832 400 => Some(ScaleFactor::_0400),
833 500 => Some(ScaleFactor::_0500),
834 550 => Some(ScaleFactor::_0550),
835 600 => Some(ScaleFactor::_0600),
836 625 => Some(ScaleFactor::_0625),
837 650 => Some(ScaleFactor::_0650),
838 700 => Some(ScaleFactor::_0700),
839 750 => Some(ScaleFactor::_0750),
840 800 => Some(ScaleFactor::_0800),
841 850 => Some(ScaleFactor::_0850),
842 900 => Some(ScaleFactor::_0900),
843 950 => Some(ScaleFactor::_0950),
844 1000 => Some(ScaleFactor::_1000),
845 1050 => Some(ScaleFactor::_1050),
846 1100 => Some(ScaleFactor::_1100),
847 1150 => Some(ScaleFactor::_1150),
848 1125 => Some(ScaleFactor::_1125),
849 1200 => Some(ScaleFactor::_1200),
850 1250 => Some(ScaleFactor::_1250),
851 1300 => Some(ScaleFactor::_1300),
852 1400 => Some(ScaleFactor::_1400),
853 1450 => Some(ScaleFactor::_1450),
854 1500 => Some(ScaleFactor::_1500),
855 1600 => Some(ScaleFactor::_1600),
856 1750 => Some(ScaleFactor::_1750),
857 1800 => Some(ScaleFactor::_1800),
858 2000 => Some(ScaleFactor::_2000),
859 2200 => Some(ScaleFactor::_2200),
860 2250 => Some(ScaleFactor::_2250),
861 2500 => Some(ScaleFactor::_2500),
862 2750 => Some(ScaleFactor::_2750),
863 3000 => Some(ScaleFactor::_3000),
864 3500 => Some(ScaleFactor::_3500),
865 4000 => Some(ScaleFactor::_4000),
866 4500 => Some(ScaleFactor::_4500),
867 5000 => Some(ScaleFactor::_5000),
868 _ => None,
869 }
870 }
871
872 pub fn bits(&self) -> u32 {
873 *self as u32
874 }
875}
876impl Into<Arg> for ScaleFactor {
877 fn into(self) -> Arg {
878 Arg::Uint(self.bits())
879 }
880}
881#[derive(Copy, Clone, Debug, Eq, PartialEq)]
882#[repr(u32)]
883pub enum ConnectionType {
884 Unknown = 0,
885 Internal = 1,
886}
887
888impl ConnectionType {
889 pub fn from_bits(v: u32) -> Option<Self> {
890 match v {
891 0 => Some(ConnectionType::Unknown),
892 1 => Some(ConnectionType::Internal),
893 _ => None,
894 }
895 }
896
897 pub fn bits(&self) -> u32 {
898 *self as u32
899 }
900}
901impl Into<Arg> for ConnectionType {
902 fn into(self) -> Arg {
903 Arg::Uint(self.bits())
904 }
905}
906} pub use crate::zaura_output::ZauraOutput;
909pub use crate::zaura_output::Request as ZauraOutputRequest;
910pub use crate::zaura_output::Event as ZauraOutputEvent;