1use super::super::all_types::*;
16use ::wl_client::builder::prelude::*;
17
18static INTERFACE: wl_interface = wl_interface {
19 name: c"wl_shell_surface".as_ptr(),
20 version: 1,
21 method_count: 10,
22 methods: {
23 static MESSAGES: [wl_message; 10] = [
24 wl_message {
25 name: c"pong".as_ptr(),
26 signature: c"u".as_ptr(),
27 types: {
28 static TYPES: [Option<&'static wl_interface>; 1] = [None];
29 TYPES.as_ptr().cast()
30 },
31 },
32 wl_message {
33 name: c"move".as_ptr(),
34 signature: c"ou".as_ptr(),
35 types: {
36 static TYPES: [Option<&'static wl_interface>; 2] =
37 [Some(WlSeat::WL_INTERFACE), None];
38 TYPES.as_ptr().cast()
39 },
40 },
41 wl_message {
42 name: c"resize".as_ptr(),
43 signature: c"ouu".as_ptr(),
44 types: {
45 static TYPES: [Option<&'static wl_interface>; 3] =
46 [Some(WlSeat::WL_INTERFACE), None, None];
47 TYPES.as_ptr().cast()
48 },
49 },
50 wl_message {
51 name: c"set_toplevel".as_ptr(),
52 signature: c"".as_ptr(),
53 types: {
54 static TYPES: [Option<&'static wl_interface>; 0] = [];
55 TYPES.as_ptr().cast()
56 },
57 },
58 wl_message {
59 name: c"set_transient".as_ptr(),
60 signature: c"oiiu".as_ptr(),
61 types: {
62 static TYPES: [Option<&'static wl_interface>; 4] =
63 [Some(WlSurface::WL_INTERFACE), None, None, None];
64 TYPES.as_ptr().cast()
65 },
66 },
67 wl_message {
68 name: c"set_fullscreen".as_ptr(),
69 signature: c"uu?o".as_ptr(),
70 types: {
71 static TYPES: [Option<&'static wl_interface>; 3] =
72 [None, None, Some(WlOutput::WL_INTERFACE)];
73 TYPES.as_ptr().cast()
74 },
75 },
76 wl_message {
77 name: c"set_popup".as_ptr(),
78 signature: c"ouoiiu".as_ptr(),
79 types: {
80 static TYPES: [Option<&'static wl_interface>; 6] = [
81 Some(WlSeat::WL_INTERFACE),
82 None,
83 Some(WlSurface::WL_INTERFACE),
84 None,
85 None,
86 None,
87 ];
88 TYPES.as_ptr().cast()
89 },
90 },
91 wl_message {
92 name: c"set_maximized".as_ptr(),
93 signature: c"?o".as_ptr(),
94 types: {
95 static TYPES: [Option<&'static wl_interface>; 1] =
96 [Some(WlOutput::WL_INTERFACE)];
97 TYPES.as_ptr().cast()
98 },
99 },
100 wl_message {
101 name: c"set_title".as_ptr(),
102 signature: c"s".as_ptr(),
103 types: {
104 static TYPES: [Option<&'static wl_interface>; 1] = [None];
105 TYPES.as_ptr().cast()
106 },
107 },
108 wl_message {
109 name: c"set_class".as_ptr(),
110 signature: c"s".as_ptr(),
111 types: {
112 static TYPES: [Option<&'static wl_interface>; 1] = [None];
113 TYPES.as_ptr().cast()
114 },
115 },
116 ];
117 MESSAGES.as_ptr()
118 },
119 event_count: 3,
120 events: {
121 static MESSAGES: [wl_message; 3] = [
122 wl_message {
123 name: c"ping".as_ptr(),
124 signature: c"u".as_ptr(),
125 types: {
126 static TYPES: [Option<&'static wl_interface>; 1] = [None];
127 TYPES.as_ptr().cast()
128 },
129 },
130 wl_message {
131 name: c"configure".as_ptr(),
132 signature: c"uii".as_ptr(),
133 types: {
134 static TYPES: [Option<&'static wl_interface>; 3] = [None, None, None];
135 TYPES.as_ptr().cast()
136 },
137 },
138 wl_message {
139 name: c"popup_done".as_ptr(),
140 signature: c"".as_ptr(),
141 types: {
142 static TYPES: [Option<&'static wl_interface>; 0] = [];
143 TYPES.as_ptr().cast()
144 },
145 },
146 ];
147 MESSAGES.as_ptr()
148 },
149};
150
151#[derive(Clone, Eq, PartialEq)]
155#[repr(transparent)]
156pub struct WlShellSurface {
157 proxy: UntypedOwnedProxy,
159}
160
161#[derive(Eq, PartialEq)]
165#[repr(transparent)]
166pub struct WlShellSurfaceRef {
167 proxy: UntypedBorrowedProxy,
169}
170
171unsafe impl UntypedOwnedProxyWrapper for WlShellSurface {}
173
174unsafe impl OwnedProxy for WlShellSurface {
177 const INTERFACE: &'static str = "wl_shell_surface";
178 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
179 const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
180 private::EventHandler(private::NoOpEventHandler);
181 const MAX_VERSION: u32 = 1;
182
183 type Borrowed = WlShellSurfaceRef;
184 type Api = private::ProxyApi;
185 type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
186}
187
188unsafe impl UntypedBorrowedProxyWrapper for WlShellSurfaceRef {}
190
191unsafe impl BorrowedProxy for WlShellSurfaceRef {
193 type Owned = WlShellSurface;
194}
195
196impl Deref for WlShellSurface {
197 type Target = WlShellSurfaceRef;
198
199 fn deref(&self) -> &Self::Target {
200 proxy::low_level::deref(self)
201 }
202}
203
204mod private {
205 pub struct ProxyApi;
206
207 #[allow(dead_code)]
208 pub struct EventHandler<H>(pub(super) H);
209
210 #[allow(dead_code)]
211 pub struct NoOpEventHandler;
212}
213
214impl Debug for WlShellSurface {
215 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
216 write!(f, "wl_shell_surface#{}", self.proxy.id())
217 }
218}
219
220impl Debug for WlShellSurfaceRef {
221 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
222 write!(f, "wl_shell_surface#{}", self.proxy.id())
223 }
224}
225
226impl PartialEq<WlShellSurfaceRef> for WlShellSurface {
227 fn eq(&self, other: &WlShellSurfaceRef) -> bool {
228 self.proxy == other.proxy
229 }
230}
231
232impl PartialEq<WlShellSurface> for WlShellSurfaceRef {
233 fn eq(&self, other: &WlShellSurface) -> bool {
234 self.proxy == other.proxy
235 }
236}
237
238#[allow(dead_code)]
239impl WlShellSurface {
240 #[allow(dead_code)]
242 pub const REQ__PONG__SINCE: u32 = 1;
243
244 #[allow(dead_code)]
246 pub const REQ__MOVE__SINCE: u32 = 1;
247
248 #[allow(dead_code)]
250 pub const REQ__RESIZE__SINCE: u32 = 1;
251
252 #[allow(dead_code)]
254 pub const REQ__SET_TOPLEVEL__SINCE: u32 = 1;
255
256 #[allow(dead_code)]
258 pub const REQ__SET_TRANSIENT__SINCE: u32 = 1;
259
260 #[allow(dead_code)]
262 pub const REQ__SET_FULLSCREEN__SINCE: u32 = 1;
263
264 #[allow(dead_code)]
266 pub const REQ__SET_POPUP__SINCE: u32 = 1;
267
268 #[allow(dead_code)]
270 pub const REQ__SET_MAXIMIZED__SINCE: u32 = 1;
271
272 #[allow(dead_code)]
274 pub const REQ__SET_TITLE__SINCE: u32 = 1;
275
276 #[allow(dead_code)]
278 pub const REQ__SET_CLASS__SINCE: u32 = 1;
279}
280
281#[allow(dead_code)]
282impl WlShellSurfaceRef {
283 #[inline]
292 pub fn pong(&self, serial: u32) {
293 let (arg0,) = (serial,);
294 let mut args = [wl_argument { u: arg0 }];
295 unsafe {
299 self.proxy.send_request(0, &mut args);
300 }
301 }
302
303 #[inline]
316 pub fn r#move(&self, seat: &WlSeatRef, serial: u32) {
317 let (arg0, arg1) = (seat, serial);
318 let obj0_lock = proxy::lock(arg0);
319 let obj0 = check_argument_proxy("seat", obj0_lock.wl_proxy());
320 let mut args = [wl_argument { o: obj0 }, wl_argument { u: arg1 }];
321 unsafe {
325 self.proxy.send_request(1, &mut args);
326 }
327 }
328
329 #[inline]
343 pub fn resize(&self, seat: &WlSeatRef, serial: u32, edges: WlShellSurfaceResize) {
344 let (arg0, arg1, arg2) = (seat, serial, edges);
345 let obj0_lock = proxy::lock(arg0);
346 let obj0 = check_argument_proxy("seat", obj0_lock.wl_proxy());
347 let mut args = [
348 wl_argument { o: obj0 },
349 wl_argument { u: arg1 },
350 wl_argument { u: arg2.0 },
351 ];
352 unsafe {
356 self.proxy.send_request(2, &mut args);
357 }
358 }
359
360 #[inline]
366 pub fn set_toplevel(&self) {
367 let mut args = [];
368 unsafe {
372 self.proxy.send_request(3, &mut args);
373 }
374 }
375
376 #[inline]
393 pub fn set_transient(
394 &self,
395 parent: &WlSurfaceRef,
396 x: i32,
397 y: i32,
398 flags: WlShellSurfaceTransient,
399 ) {
400 let (arg0, arg1, arg2, arg3) = (parent, x, y, flags);
401 let obj0_lock = proxy::lock(arg0);
402 let obj0 = check_argument_proxy("parent", obj0_lock.wl_proxy());
403 let mut args = [
404 wl_argument { o: obj0 },
405 wl_argument { i: arg1 },
406 wl_argument { i: arg2 },
407 wl_argument { u: arg3.0 },
408 ];
409 unsafe {
413 self.proxy.send_request(4, &mut args);
414 }
415 }
416
417 #[inline]
459 pub fn set_fullscreen(
460 &self,
461 method: WlShellSurfaceFullscreenMethod,
462 framerate: u32,
463 output: Option<&WlOutputRef>,
464 ) {
465 let (arg0, arg1, arg2) = (method, framerate, output);
466 let obj2_lock = arg2.map(|arg2| proxy::lock(arg2));
467 let obj2 = obj2_lock
468 .map(|obj2_lock| check_argument_proxy("output", obj2_lock.wl_proxy()))
469 .unwrap_or(ptr::null_mut());
470 let mut args = [
471 wl_argument { u: arg0.0 },
472 wl_argument { u: arg1 },
473 wl_argument { o: obj2 },
474 ];
475 unsafe {
479 self.proxy.send_request(5, &mut args);
480 }
481 }
482
483 #[inline]
514 pub fn set_popup(
515 &self,
516 seat: &WlSeatRef,
517 serial: u32,
518 parent: &WlSurfaceRef,
519 x: i32,
520 y: i32,
521 flags: WlShellSurfaceTransient,
522 ) {
523 let (arg0, arg1, arg2, arg3, arg4, arg5) = (seat, serial, parent, x, y, flags);
524 let obj0_lock = proxy::lock(arg0);
525 let obj0 = check_argument_proxy("seat", obj0_lock.wl_proxy());
526 let obj2_lock = proxy::lock(arg2);
527 let obj2 = check_argument_proxy("parent", obj2_lock.wl_proxy());
528 let mut args = [
529 wl_argument { o: obj0 },
530 wl_argument { u: arg1 },
531 wl_argument { o: obj2 },
532 wl_argument { i: arg3 },
533 wl_argument { i: arg4 },
534 wl_argument { u: arg5.0 },
535 ];
536 unsafe {
540 self.proxy.send_request(6, &mut args);
541 }
542 }
543
544 #[inline]
569 pub fn set_maximized(&self, output: Option<&WlOutputRef>) {
570 let (arg0,) = (output,);
571 let obj0_lock = arg0.map(|arg0| proxy::lock(arg0));
572 let obj0 = obj0_lock
573 .map(|obj0_lock| check_argument_proxy("output", obj0_lock.wl_proxy()))
574 .unwrap_or(ptr::null_mut());
575 let mut args = [wl_argument { o: obj0 }];
576 unsafe {
580 self.proxy.send_request(7, &mut args);
581 }
582 }
583
584 #[inline]
598 pub fn set_title(&self, title: &str) {
599 let (arg0,) = (title,);
600 with_cstr_cache(|cache| {
601 let str0_offset = cache.len();
602 cache.extend_from_slice(arg0.as_bytes());
603 cache.push(0);
604 let str0 = cache[str0_offset..].as_ptr().cast();
605 let mut args = [wl_argument { s: str0 }];
606 unsafe {
610 self.proxy.send_request(8, &mut args);
611 }
612 })
613 }
614
615 #[inline]
628 pub fn set_class(&self, class_: &str) {
629 let (arg0,) = (class_,);
630 with_cstr_cache(|cache| {
631 let str0_offset = cache.len();
632 cache.extend_from_slice(arg0.as_bytes());
633 cache.push(0);
634 let str0 = cache[str0_offset..].as_ptr().cast();
635 let mut args = [wl_argument { s: str0 }];
636 unsafe {
640 self.proxy.send_request(9, &mut args);
641 }
642 })
643 }
644}
645
646impl WlShellSurface {
647 #[allow(dead_code)]
649 pub const EVT__PING__SINCE: u32 = 1;
650
651 #[allow(dead_code)]
653 pub const EVT__CONFIGURE__SINCE: u32 = 1;
654
655 #[allow(dead_code)]
657 pub const EVT__POPUP_DONE__SINCE: u32 = 1;
658}
659
660#[allow(dead_code)]
662pub trait WlShellSurfaceEventHandler {
663 #[inline]
672 fn ping(&self, _slf: &WlShellSurfaceRef, serial: u32) {
673 let _ = serial;
674 }
675
676 #[inline]
702 fn configure(
703 &self,
704 _slf: &WlShellSurfaceRef,
705 edges: WlShellSurfaceResize,
706 width: i32,
707 height: i32,
708 ) {
709 let _ = edges;
710 let _ = width;
711 let _ = height;
712 }
713
714 #[inline]
720 fn popup_done(&self, _slf: &WlShellSurfaceRef) {}
721}
722
723impl WlShellSurfaceEventHandler for private::NoOpEventHandler {}
724
725unsafe impl<H> EventHandler for private::EventHandler<H>
727where
728 H: WlShellSurfaceEventHandler,
729{
730 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
731
732 #[allow(unused_variables)]
733 unsafe fn handle_event(
734 &self,
735 queue: &Queue,
736 data: *mut u8,
737 slf: &UntypedBorrowedProxy,
738 opcode: u32,
739 args: *mut wl_argument,
740 ) {
741 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlShellSurfaceRef>(slf) };
743 match opcode {
744 0 => {
745 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
747 let arg0 = unsafe { args[0].u };
749 self.0.ping(slf, arg0);
750 }
751 1 => {
752 let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
754 let arg0 = unsafe { WlShellSurfaceResize(args[0].u) };
756 let arg1 = unsafe { args[1].i };
758 let arg2 = unsafe { args[2].i };
760 self.0.configure(slf, arg0, arg1, arg2);
761 }
762 2 => {
763 self.0.popup_done(slf);
764 }
765 _ => {
766 invalid_opcode("wl_shell_surface", opcode);
767 }
768 }
769 }
770}
771
772impl<H> CreateEventHandler<H> for private::ProxyApi
773where
774 H: WlShellSurfaceEventHandler,
775{
776 type EventHandler = private::EventHandler<H>;
777
778 #[inline]
779 fn create_event_handler(handler: H) -> Self::EventHandler {
780 private::EventHandler(handler)
781 }
782}
783
784impl WlShellSurface {
785 #[allow(dead_code)]
787 pub const ENM__RESIZE_NONE__SINCE: u32 = 1;
788 #[allow(dead_code)]
790 pub const ENM__RESIZE_TOP__SINCE: u32 = 1;
791 #[allow(dead_code)]
793 pub const ENM__RESIZE_BOTTOM__SINCE: u32 = 1;
794 #[allow(dead_code)]
796 pub const ENM__RESIZE_LEFT__SINCE: u32 = 1;
797 #[allow(dead_code)]
799 pub const ENM__RESIZE_TOP_LEFT__SINCE: u32 = 1;
800 #[allow(dead_code)]
802 pub const ENM__RESIZE_BOTTOM_LEFT__SINCE: u32 = 1;
803 #[allow(dead_code)]
805 pub const ENM__RESIZE_RIGHT__SINCE: u32 = 1;
806 #[allow(dead_code)]
808 pub const ENM__RESIZE_TOP_RIGHT__SINCE: u32 = 1;
809 #[allow(dead_code)]
811 pub const ENM__RESIZE_BOTTOM_RIGHT__SINCE: u32 = 1;
812
813 #[allow(dead_code)]
815 pub const ENM__TRANSIENT_INACTIVE__SINCE: u32 = 1;
816
817 #[allow(dead_code)]
819 pub const ENM__FULLSCREEN_METHOD_DEFAULT__SINCE: u32 = 1;
820 #[allow(dead_code)]
822 pub const ENM__FULLSCREEN_METHOD_SCALE__SINCE: u32 = 1;
823 #[allow(dead_code)]
825 pub const ENM__FULLSCREEN_METHOD_DRIVER__SINCE: u32 = 1;
826 #[allow(dead_code)]
828 pub const ENM__FULLSCREEN_METHOD_FILL__SINCE: u32 = 1;
829}
830
831#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
838#[allow(dead_code)]
839pub struct WlShellSurfaceResize(pub u32);
840
841#[derive(Clone, Debug)]
845#[allow(dead_code)]
846pub struct WlShellSurfaceResizeIter(pub u32);
847
848impl WlShellSurfaceResize {
849 #[allow(dead_code)]
851 pub const NONE: Self = Self(0);
852
853 #[allow(dead_code)]
855 pub const TOP: Self = Self(1);
856
857 #[allow(dead_code)]
859 pub const BOTTOM: Self = Self(2);
860
861 #[allow(dead_code)]
863 pub const LEFT: Self = Self(4);
864
865 #[allow(dead_code)]
867 pub const TOP_LEFT: Self = Self(5);
868
869 #[allow(dead_code)]
871 pub const BOTTOM_LEFT: Self = Self(6);
872
873 #[allow(dead_code)]
875 pub const RIGHT: Self = Self(8);
876
877 #[allow(dead_code)]
879 pub const TOP_RIGHT: Self = Self(9);
880
881 #[allow(dead_code)]
883 pub const BOTTOM_RIGHT: Self = Self(10);
884}
885
886#[allow(dead_code)]
887impl WlShellSurfaceResize {
888 #[inline]
889 pub const fn empty() -> Self {
890 Self(0)
891 }
892
893 #[inline]
894 #[must_use]
895 pub const fn is_empty(self) -> bool {
896 self.0 == 0
897 }
898
899 #[inline]
900 #[must_use]
901 pub const fn contains(self, other: Self) -> bool {
902 self.0 & other.0 == other.0
903 }
904
905 #[inline]
906 #[must_use]
907 pub const fn intersects(self, other: Self) -> bool {
908 self.0 & other.0 != 0
909 }
910
911 #[inline]
912 pub const fn insert(&mut self, other: Self) {
913 *self = self.union(other);
914 }
915
916 #[inline]
917 pub const fn remove(&mut self, other: Self) {
918 *self = self.difference(other);
919 }
920
921 #[inline]
922 pub const fn toggle(&mut self, other: Self) {
923 *self = self.symmetric_difference(other);
924 }
925
926 #[inline]
927 pub const fn set(&mut self, other: Self, value: bool) {
928 if value {
929 self.insert(other);
930 } else {
931 self.remove(other);
932 }
933 }
934
935 #[inline]
936 #[must_use]
937 pub const fn intersection(self, other: Self) -> Self {
938 Self(self.0 & other.0)
939 }
940
941 #[inline]
942 #[must_use]
943 pub const fn union(self, other: Self) -> Self {
944 Self(self.0 | other.0)
945 }
946
947 #[inline]
948 #[must_use]
949 pub const fn difference(self, other: Self) -> Self {
950 Self(self.0 & !other.0)
951 }
952
953 #[inline]
954 #[must_use]
955 pub const fn complement(self) -> Self {
956 Self(!self.0)
957 }
958
959 #[inline]
960 #[must_use]
961 pub const fn symmetric_difference(self, other: Self) -> Self {
962 Self(self.0 ^ other.0)
963 }
964
965 #[inline]
966 pub const fn all_known() -> Self {
967 #[allow(clippy::eq_op, clippy::identity_op)]
968 Self(0 | 0 | 1 | 2 | 4 | 5 | 6 | 8 | 9 | 10)
969 }
970}
971
972impl Iterator for WlShellSurfaceResizeIter {
973 type Item = WlShellSurfaceResize;
974
975 fn next(&mut self) -> Option<Self::Item> {
976 if self.0 == 0 {
977 return None;
978 }
979 let bit = 1 << self.0.trailing_zeros();
980 self.0 &= !bit;
981 Some(WlShellSurfaceResize(bit))
982 }
983}
984
985impl IntoIterator for WlShellSurfaceResize {
986 type Item = WlShellSurfaceResize;
987 type IntoIter = WlShellSurfaceResizeIter;
988
989 fn into_iter(self) -> Self::IntoIter {
990 WlShellSurfaceResizeIter(self.0)
991 }
992}
993
994impl BitAnd for WlShellSurfaceResize {
995 type Output = Self;
996
997 fn bitand(self, rhs: Self) -> Self::Output {
998 self.intersection(rhs)
999 }
1000}
1001
1002impl BitAndAssign for WlShellSurfaceResize {
1003 fn bitand_assign(&mut self, rhs: Self) {
1004 *self = self.intersection(rhs);
1005 }
1006}
1007
1008impl BitOr for WlShellSurfaceResize {
1009 type Output = Self;
1010
1011 fn bitor(self, rhs: Self) -> Self::Output {
1012 self.union(rhs)
1013 }
1014}
1015
1016impl BitOrAssign for WlShellSurfaceResize {
1017 fn bitor_assign(&mut self, rhs: Self) {
1018 *self = self.union(rhs);
1019 }
1020}
1021
1022impl BitXor for WlShellSurfaceResize {
1023 type Output = Self;
1024
1025 fn bitxor(self, rhs: Self) -> Self::Output {
1026 self.symmetric_difference(rhs)
1027 }
1028}
1029
1030impl BitXorAssign for WlShellSurfaceResize {
1031 fn bitxor_assign(&mut self, rhs: Self) {
1032 *self = self.symmetric_difference(rhs);
1033 }
1034}
1035
1036impl Sub for WlShellSurfaceResize {
1037 type Output = Self;
1038
1039 fn sub(self, rhs: Self) -> Self::Output {
1040 self.difference(rhs)
1041 }
1042}
1043
1044impl SubAssign for WlShellSurfaceResize {
1045 fn sub_assign(&mut self, rhs: Self) {
1046 *self = self.difference(rhs);
1047 }
1048}
1049
1050impl Not for WlShellSurfaceResize {
1051 type Output = Self;
1052
1053 fn not(self) -> Self::Output {
1054 self.complement()
1055 }
1056}
1057
1058impl Debug for WlShellSurfaceResize {
1059 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1060 let mut v = self.0;
1061 let mut first = true;
1062 if v & 1 == 1 {
1063 v &= !1;
1064 if first {
1065 first = false;
1066 } else {
1067 f.write_str(" | ")?;
1068 }
1069 f.write_str("TOP")?;
1070 }
1071 if v & 2 == 2 {
1072 v &= !2;
1073 if first {
1074 first = false;
1075 } else {
1076 f.write_str(" | ")?;
1077 }
1078 f.write_str("BOTTOM")?;
1079 }
1080 if v & 4 == 4 {
1081 v &= !4;
1082 if first {
1083 first = false;
1084 } else {
1085 f.write_str(" | ")?;
1086 }
1087 f.write_str("LEFT")?;
1088 }
1089 if v & 5 == 5 {
1090 v &= !5;
1091 if first {
1092 first = false;
1093 } else {
1094 f.write_str(" | ")?;
1095 }
1096 f.write_str("TOP_LEFT")?;
1097 }
1098 if v & 6 == 6 {
1099 v &= !6;
1100 if first {
1101 first = false;
1102 } else {
1103 f.write_str(" | ")?;
1104 }
1105 f.write_str("BOTTOM_LEFT")?;
1106 }
1107 if v & 8 == 8 {
1108 v &= !8;
1109 if first {
1110 first = false;
1111 } else {
1112 f.write_str(" | ")?;
1113 }
1114 f.write_str("RIGHT")?;
1115 }
1116 if v & 9 == 9 {
1117 v &= !9;
1118 if first {
1119 first = false;
1120 } else {
1121 f.write_str(" | ")?;
1122 }
1123 f.write_str("TOP_RIGHT")?;
1124 }
1125 if v & 10 == 10 {
1126 v &= !10;
1127 if first {
1128 first = false;
1129 } else {
1130 f.write_str(" | ")?;
1131 }
1132 f.write_str("BOTTOM_RIGHT")?;
1133 }
1134 if v != 0 {
1135 if first {
1136 first = false;
1137 } else {
1138 f.write_str(" | ")?;
1139 }
1140 write!(f, "0x{v:032x}")?;
1141 }
1142 if first {
1143 f.write_str("NONE")?;
1144 }
1145 Ok(())
1146 }
1147}
1148
1149#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
1154#[allow(dead_code)]
1155pub struct WlShellSurfaceTransient(pub u32);
1156
1157#[derive(Clone, Debug)]
1161#[allow(dead_code)]
1162pub struct WlShellSurfaceTransientIter(pub u32);
1163
1164impl WlShellSurfaceTransient {
1165 #[allow(dead_code)]
1167 pub const INACTIVE: Self = Self(0x1);
1168}
1169
1170#[allow(dead_code)]
1171impl WlShellSurfaceTransient {
1172 #[inline]
1173 pub const fn empty() -> Self {
1174 Self(0)
1175 }
1176
1177 #[inline]
1178 #[must_use]
1179 pub const fn is_empty(self) -> bool {
1180 self.0 == 0
1181 }
1182
1183 #[inline]
1184 #[must_use]
1185 pub const fn contains(self, other: Self) -> bool {
1186 self.0 & other.0 == other.0
1187 }
1188
1189 #[inline]
1190 #[must_use]
1191 pub const fn intersects(self, other: Self) -> bool {
1192 self.0 & other.0 != 0
1193 }
1194
1195 #[inline]
1196 pub const fn insert(&mut self, other: Self) {
1197 *self = self.union(other);
1198 }
1199
1200 #[inline]
1201 pub const fn remove(&mut self, other: Self) {
1202 *self = self.difference(other);
1203 }
1204
1205 #[inline]
1206 pub const fn toggle(&mut self, other: Self) {
1207 *self = self.symmetric_difference(other);
1208 }
1209
1210 #[inline]
1211 pub const fn set(&mut self, other: Self, value: bool) {
1212 if value {
1213 self.insert(other);
1214 } else {
1215 self.remove(other);
1216 }
1217 }
1218
1219 #[inline]
1220 #[must_use]
1221 pub const fn intersection(self, other: Self) -> Self {
1222 Self(self.0 & other.0)
1223 }
1224
1225 #[inline]
1226 #[must_use]
1227 pub const fn union(self, other: Self) -> Self {
1228 Self(self.0 | other.0)
1229 }
1230
1231 #[inline]
1232 #[must_use]
1233 pub const fn difference(self, other: Self) -> Self {
1234 Self(self.0 & !other.0)
1235 }
1236
1237 #[inline]
1238 #[must_use]
1239 pub const fn complement(self) -> Self {
1240 Self(!self.0)
1241 }
1242
1243 #[inline]
1244 #[must_use]
1245 pub const fn symmetric_difference(self, other: Self) -> Self {
1246 Self(self.0 ^ other.0)
1247 }
1248
1249 #[inline]
1250 pub const fn all_known() -> Self {
1251 #[allow(clippy::eq_op, clippy::identity_op)]
1252 Self(0 | 0x1)
1253 }
1254}
1255
1256impl Iterator for WlShellSurfaceTransientIter {
1257 type Item = WlShellSurfaceTransient;
1258
1259 fn next(&mut self) -> Option<Self::Item> {
1260 if self.0 == 0 {
1261 return None;
1262 }
1263 let bit = 1 << self.0.trailing_zeros();
1264 self.0 &= !bit;
1265 Some(WlShellSurfaceTransient(bit))
1266 }
1267}
1268
1269impl IntoIterator for WlShellSurfaceTransient {
1270 type Item = WlShellSurfaceTransient;
1271 type IntoIter = WlShellSurfaceTransientIter;
1272
1273 fn into_iter(self) -> Self::IntoIter {
1274 WlShellSurfaceTransientIter(self.0)
1275 }
1276}
1277
1278impl BitAnd for WlShellSurfaceTransient {
1279 type Output = Self;
1280
1281 fn bitand(self, rhs: Self) -> Self::Output {
1282 self.intersection(rhs)
1283 }
1284}
1285
1286impl BitAndAssign for WlShellSurfaceTransient {
1287 fn bitand_assign(&mut self, rhs: Self) {
1288 *self = self.intersection(rhs);
1289 }
1290}
1291
1292impl BitOr for WlShellSurfaceTransient {
1293 type Output = Self;
1294
1295 fn bitor(self, rhs: Self) -> Self::Output {
1296 self.union(rhs)
1297 }
1298}
1299
1300impl BitOrAssign for WlShellSurfaceTransient {
1301 fn bitor_assign(&mut self, rhs: Self) {
1302 *self = self.union(rhs);
1303 }
1304}
1305
1306impl BitXor for WlShellSurfaceTransient {
1307 type Output = Self;
1308
1309 fn bitxor(self, rhs: Self) -> Self::Output {
1310 self.symmetric_difference(rhs)
1311 }
1312}
1313
1314impl BitXorAssign for WlShellSurfaceTransient {
1315 fn bitxor_assign(&mut self, rhs: Self) {
1316 *self = self.symmetric_difference(rhs);
1317 }
1318}
1319
1320impl Sub for WlShellSurfaceTransient {
1321 type Output = Self;
1322
1323 fn sub(self, rhs: Self) -> Self::Output {
1324 self.difference(rhs)
1325 }
1326}
1327
1328impl SubAssign for WlShellSurfaceTransient {
1329 fn sub_assign(&mut self, rhs: Self) {
1330 *self = self.difference(rhs);
1331 }
1332}
1333
1334impl Not for WlShellSurfaceTransient {
1335 type Output = Self;
1336
1337 fn not(self) -> Self::Output {
1338 self.complement()
1339 }
1340}
1341
1342impl Debug for WlShellSurfaceTransient {
1343 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1344 let mut v = self.0;
1345 let mut first = true;
1346 if v & 0x1 == 0x1 {
1347 v &= !0x1;
1348 if first {
1349 first = false;
1350 } else {
1351 f.write_str(" | ")?;
1352 }
1353 f.write_str("INACTIVE")?;
1354 }
1355 if v != 0 {
1356 if first {
1357 first = false;
1358 } else {
1359 f.write_str(" | ")?;
1360 }
1361 write!(f, "0x{v:032x}")?;
1362 }
1363 if first {
1364 f.write_str("0")?;
1365 }
1366 Ok(())
1367 }
1368}
1369
1370#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1376#[allow(dead_code)]
1377pub struct WlShellSurfaceFullscreenMethod(pub u32);
1378
1379impl WlShellSurfaceFullscreenMethod {
1380 #[allow(dead_code)]
1382 pub const DEFAULT: Self = Self(0);
1383
1384 #[allow(dead_code)]
1386 pub const SCALE: Self = Self(1);
1387
1388 #[allow(dead_code)]
1390 pub const DRIVER: Self = Self(2);
1391
1392 #[allow(dead_code)]
1394 pub const FILL: Self = Self(3);
1395}
1396
1397impl Debug for WlShellSurfaceFullscreenMethod {
1398 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1399 let name = match *self {
1400 Self::DEFAULT => "DEFAULT",
1401 Self::SCALE => "SCALE",
1402 Self::DRIVER => "DRIVER",
1403 Self::FILL => "FILL",
1404 _ => return Debug::fmt(&self.0, f),
1405 };
1406 f.write_str(name)
1407 }
1408}
1409
1410pub mod event_handlers {
1412 use super::*;
1413
1414 pub struct Ping<F>(F);
1416 impl<F> WlShellSurfaceEventHandler for Ping<F>
1417 where
1418 F: Fn(&WlShellSurfaceRef, u32),
1419 {
1420 #[inline]
1421 fn ping(&self, _slf: &WlShellSurfaceRef, serial: u32) {
1422 self.0(_slf, serial)
1423 }
1424 }
1425
1426 pub struct Configure<F>(F);
1428 impl<F> WlShellSurfaceEventHandler for Configure<F>
1429 where
1430 F: Fn(&WlShellSurfaceRef, WlShellSurfaceResize, i32, i32),
1431 {
1432 #[inline]
1433 fn configure(
1434 &self,
1435 _slf: &WlShellSurfaceRef,
1436 edges: WlShellSurfaceResize,
1437 width: i32,
1438 height: i32,
1439 ) {
1440 self.0(_slf, edges, width, height)
1441 }
1442 }
1443
1444 pub struct PopupDone<F>(F);
1446 impl<F> WlShellSurfaceEventHandler for PopupDone<F>
1447 where
1448 F: Fn(&WlShellSurfaceRef),
1449 {
1450 #[inline]
1451 fn popup_done(&self, _slf: &WlShellSurfaceRef) {
1452 self.0(_slf)
1453 }
1454 }
1455
1456 impl WlShellSurface {
1457 #[allow(dead_code)]
1461 pub fn on_ping<F>(f: F) -> Ping<F>
1462 where
1463 F: Fn(&WlShellSurfaceRef, u32),
1464 {
1465 Ping(f)
1466 }
1467
1468 #[allow(dead_code)]
1472 pub fn on_configure<F>(f: F) -> Configure<F>
1473 where
1474 F: Fn(&WlShellSurfaceRef, WlShellSurfaceResize, i32, i32),
1475 {
1476 Configure(f)
1477 }
1478
1479 #[allow(dead_code)]
1483 pub fn on_popup_done<F>(f: F) -> PopupDone<F>
1484 where
1485 F: Fn(&WlShellSurfaceRef),
1486 {
1487 PopupDone(f)
1488 }
1489 }
1490}