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 type Data: 'static;
664
665 #[inline]
674 fn ping(&self, _data: &mut Self::Data, _slf: &WlShellSurfaceRef, serial: u32) {
675 let _ = serial;
676 }
677
678 #[inline]
704 fn configure(
705 &self,
706 _data: &mut Self::Data,
707 _slf: &WlShellSurfaceRef,
708 edges: WlShellSurfaceResize,
709 width: i32,
710 height: i32,
711 ) {
712 let _ = edges;
713 let _ = width;
714 let _ = height;
715 }
716
717 #[inline]
723 fn popup_done(&self, _data: &mut Self::Data, _slf: &WlShellSurfaceRef) {}
724}
725
726impl WlShellSurfaceEventHandler for private::NoOpEventHandler {
727 type Data = ();
728}
729
730unsafe impl<H> EventHandler for private::EventHandler<H>
733where
734 H: WlShellSurfaceEventHandler,
735{
736 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
737
738 #[inline]
739 fn mutable_type() -> Option<(TypeId, &'static str)> {
740 let id = TypeId::of::<H::Data>();
741 let name = std::any::type_name::<H::Data>();
742 Some((id, name))
743 }
744
745 #[allow(unused_variables)]
746 unsafe fn handle_event(
747 &self,
748 queue: &Queue,
749 data: *mut u8,
750 slf: &UntypedBorrowedProxy,
751 opcode: u32,
752 args: *mut wl_argument,
753 ) {
754 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlShellSurfaceRef>(slf) };
756 let data: &mut H::Data = unsafe { &mut *data.cast() };
760 match opcode {
761 0 => {
762 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
764 let arg0 = unsafe { args[0].u };
766 self.0.ping(data, slf, arg0);
767 }
768 1 => {
769 let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
771 let arg0 = unsafe { WlShellSurfaceResize(args[0].u) };
773 let arg1 = unsafe { args[1].i };
775 let arg2 = unsafe { args[2].i };
777 self.0.configure(data, slf, arg0, arg1, arg2);
778 }
779 2 => {
780 self.0.popup_done(data, slf);
781 }
782 _ => {
783 invalid_opcode("wl_shell_surface", opcode);
784 }
785 }
786 }
787}
788
789impl<H> CreateEventHandler<H> for private::ProxyApi
790where
791 H: WlShellSurfaceEventHandler,
792{
793 type EventHandler = private::EventHandler<H>;
794
795 #[inline]
796 fn create_event_handler(handler: H) -> Self::EventHandler {
797 private::EventHandler(handler)
798 }
799}
800
801impl WlShellSurface {
802 #[allow(dead_code)]
804 pub const ENM__RESIZE_NONE__SINCE: u32 = 1;
805 #[allow(dead_code)]
807 pub const ENM__RESIZE_TOP__SINCE: u32 = 1;
808 #[allow(dead_code)]
810 pub const ENM__RESIZE_BOTTOM__SINCE: u32 = 1;
811 #[allow(dead_code)]
813 pub const ENM__RESIZE_LEFT__SINCE: u32 = 1;
814 #[allow(dead_code)]
816 pub const ENM__RESIZE_TOP_LEFT__SINCE: u32 = 1;
817 #[allow(dead_code)]
819 pub const ENM__RESIZE_BOTTOM_LEFT__SINCE: u32 = 1;
820 #[allow(dead_code)]
822 pub const ENM__RESIZE_RIGHT__SINCE: u32 = 1;
823 #[allow(dead_code)]
825 pub const ENM__RESIZE_TOP_RIGHT__SINCE: u32 = 1;
826 #[allow(dead_code)]
828 pub const ENM__RESIZE_BOTTOM_RIGHT__SINCE: u32 = 1;
829
830 #[allow(dead_code)]
832 pub const ENM__TRANSIENT_INACTIVE__SINCE: u32 = 1;
833
834 #[allow(dead_code)]
836 pub const ENM__FULLSCREEN_METHOD_DEFAULT__SINCE: u32 = 1;
837 #[allow(dead_code)]
839 pub const ENM__FULLSCREEN_METHOD_SCALE__SINCE: u32 = 1;
840 #[allow(dead_code)]
842 pub const ENM__FULLSCREEN_METHOD_DRIVER__SINCE: u32 = 1;
843 #[allow(dead_code)]
845 pub const ENM__FULLSCREEN_METHOD_FILL__SINCE: u32 = 1;
846}
847
848#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
855#[allow(dead_code)]
856pub struct WlShellSurfaceResize(pub u32);
857
858#[derive(Clone, Debug)]
862#[allow(dead_code)]
863pub struct WlShellSurfaceResizeIter(pub u32);
864
865impl WlShellSurfaceResize {
866 #[allow(dead_code)]
868 pub const NONE: Self = Self(0);
869
870 #[allow(dead_code)]
872 pub const TOP: Self = Self(1);
873
874 #[allow(dead_code)]
876 pub const BOTTOM: Self = Self(2);
877
878 #[allow(dead_code)]
880 pub const LEFT: Self = Self(4);
881
882 #[allow(dead_code)]
884 pub const TOP_LEFT: Self = Self(5);
885
886 #[allow(dead_code)]
888 pub const BOTTOM_LEFT: Self = Self(6);
889
890 #[allow(dead_code)]
892 pub const RIGHT: Self = Self(8);
893
894 #[allow(dead_code)]
896 pub const TOP_RIGHT: Self = Self(9);
897
898 #[allow(dead_code)]
900 pub const BOTTOM_RIGHT: Self = Self(10);
901}
902
903#[allow(dead_code)]
904impl WlShellSurfaceResize {
905 #[inline]
906 pub const fn empty() -> Self {
907 Self(0)
908 }
909
910 #[inline]
911 #[must_use]
912 pub const fn is_empty(self) -> bool {
913 self.0 == 0
914 }
915
916 #[inline]
917 #[must_use]
918 pub const fn contains(self, other: Self) -> bool {
919 self.0 & other.0 == other.0
920 }
921
922 #[inline]
923 #[must_use]
924 pub const fn intersects(self, other: Self) -> bool {
925 self.0 & other.0 != 0
926 }
927
928 #[inline]
929 pub const fn insert(&mut self, other: Self) {
930 *self = self.union(other);
931 }
932
933 #[inline]
934 pub const fn remove(&mut self, other: Self) {
935 *self = self.difference(other);
936 }
937
938 #[inline]
939 pub const fn toggle(&mut self, other: Self) {
940 *self = self.symmetric_difference(other);
941 }
942
943 #[inline]
944 pub const fn set(&mut self, other: Self, value: bool) {
945 if value {
946 self.insert(other);
947 } else {
948 self.remove(other);
949 }
950 }
951
952 #[inline]
953 #[must_use]
954 pub const fn intersection(self, other: Self) -> Self {
955 Self(self.0 & other.0)
956 }
957
958 #[inline]
959 #[must_use]
960 pub const fn union(self, other: Self) -> Self {
961 Self(self.0 | other.0)
962 }
963
964 #[inline]
965 #[must_use]
966 pub const fn difference(self, other: Self) -> Self {
967 Self(self.0 & !other.0)
968 }
969
970 #[inline]
971 #[must_use]
972 pub const fn complement(self) -> Self {
973 Self(!self.0)
974 }
975
976 #[inline]
977 #[must_use]
978 pub const fn symmetric_difference(self, other: Self) -> Self {
979 Self(self.0 ^ other.0)
980 }
981
982 #[inline]
983 pub const fn all_known() -> Self {
984 #[allow(clippy::eq_op, clippy::identity_op)]
985 Self(0 | 0 | 1 | 2 | 4 | 5 | 6 | 8 | 9 | 10)
986 }
987}
988
989impl Iterator for WlShellSurfaceResizeIter {
990 type Item = WlShellSurfaceResize;
991
992 fn next(&mut self) -> Option<Self::Item> {
993 if self.0 == 0 {
994 return None;
995 }
996 let bit = 1 << self.0.trailing_zeros();
997 self.0 &= !bit;
998 Some(WlShellSurfaceResize(bit))
999 }
1000}
1001
1002impl IntoIterator for WlShellSurfaceResize {
1003 type Item = WlShellSurfaceResize;
1004 type IntoIter = WlShellSurfaceResizeIter;
1005
1006 fn into_iter(self) -> Self::IntoIter {
1007 WlShellSurfaceResizeIter(self.0)
1008 }
1009}
1010
1011impl BitAnd for WlShellSurfaceResize {
1012 type Output = Self;
1013
1014 fn bitand(self, rhs: Self) -> Self::Output {
1015 self.intersection(rhs)
1016 }
1017}
1018
1019impl BitAndAssign for WlShellSurfaceResize {
1020 fn bitand_assign(&mut self, rhs: Self) {
1021 *self = self.intersection(rhs);
1022 }
1023}
1024
1025impl BitOr for WlShellSurfaceResize {
1026 type Output = Self;
1027
1028 fn bitor(self, rhs: Self) -> Self::Output {
1029 self.union(rhs)
1030 }
1031}
1032
1033impl BitOrAssign for WlShellSurfaceResize {
1034 fn bitor_assign(&mut self, rhs: Self) {
1035 *self = self.union(rhs);
1036 }
1037}
1038
1039impl BitXor for WlShellSurfaceResize {
1040 type Output = Self;
1041
1042 fn bitxor(self, rhs: Self) -> Self::Output {
1043 self.symmetric_difference(rhs)
1044 }
1045}
1046
1047impl BitXorAssign for WlShellSurfaceResize {
1048 fn bitxor_assign(&mut self, rhs: Self) {
1049 *self = self.symmetric_difference(rhs);
1050 }
1051}
1052
1053impl Sub for WlShellSurfaceResize {
1054 type Output = Self;
1055
1056 fn sub(self, rhs: Self) -> Self::Output {
1057 self.difference(rhs)
1058 }
1059}
1060
1061impl SubAssign for WlShellSurfaceResize {
1062 fn sub_assign(&mut self, rhs: Self) {
1063 *self = self.difference(rhs);
1064 }
1065}
1066
1067impl Not for WlShellSurfaceResize {
1068 type Output = Self;
1069
1070 fn not(self) -> Self::Output {
1071 self.complement()
1072 }
1073}
1074
1075impl Debug for WlShellSurfaceResize {
1076 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1077 let mut v = self.0;
1078 let mut first = true;
1079 if v & 1 == 1 {
1080 v &= !1;
1081 if first {
1082 first = false;
1083 } else {
1084 f.write_str(" | ")?;
1085 }
1086 f.write_str("TOP")?;
1087 }
1088 if v & 2 == 2 {
1089 v &= !2;
1090 if first {
1091 first = false;
1092 } else {
1093 f.write_str(" | ")?;
1094 }
1095 f.write_str("BOTTOM")?;
1096 }
1097 if v & 4 == 4 {
1098 v &= !4;
1099 if first {
1100 first = false;
1101 } else {
1102 f.write_str(" | ")?;
1103 }
1104 f.write_str("LEFT")?;
1105 }
1106 if v & 5 == 5 {
1107 v &= !5;
1108 if first {
1109 first = false;
1110 } else {
1111 f.write_str(" | ")?;
1112 }
1113 f.write_str("TOP_LEFT")?;
1114 }
1115 if v & 6 == 6 {
1116 v &= !6;
1117 if first {
1118 first = false;
1119 } else {
1120 f.write_str(" | ")?;
1121 }
1122 f.write_str("BOTTOM_LEFT")?;
1123 }
1124 if v & 8 == 8 {
1125 v &= !8;
1126 if first {
1127 first = false;
1128 } else {
1129 f.write_str(" | ")?;
1130 }
1131 f.write_str("RIGHT")?;
1132 }
1133 if v & 9 == 9 {
1134 v &= !9;
1135 if first {
1136 first = false;
1137 } else {
1138 f.write_str(" | ")?;
1139 }
1140 f.write_str("TOP_RIGHT")?;
1141 }
1142 if v & 10 == 10 {
1143 v &= !10;
1144 if first {
1145 first = false;
1146 } else {
1147 f.write_str(" | ")?;
1148 }
1149 f.write_str("BOTTOM_RIGHT")?;
1150 }
1151 if v != 0 {
1152 if first {
1153 first = false;
1154 } else {
1155 f.write_str(" | ")?;
1156 }
1157 write!(f, "0x{v:032x}")?;
1158 }
1159 if first {
1160 f.write_str("NONE")?;
1161 }
1162 Ok(())
1163 }
1164}
1165
1166#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
1171#[allow(dead_code)]
1172pub struct WlShellSurfaceTransient(pub u32);
1173
1174#[derive(Clone, Debug)]
1178#[allow(dead_code)]
1179pub struct WlShellSurfaceTransientIter(pub u32);
1180
1181impl WlShellSurfaceTransient {
1182 #[allow(dead_code)]
1184 pub const INACTIVE: Self = Self(0x1);
1185}
1186
1187#[allow(dead_code)]
1188impl WlShellSurfaceTransient {
1189 #[inline]
1190 pub const fn empty() -> Self {
1191 Self(0)
1192 }
1193
1194 #[inline]
1195 #[must_use]
1196 pub const fn is_empty(self) -> bool {
1197 self.0 == 0
1198 }
1199
1200 #[inline]
1201 #[must_use]
1202 pub const fn contains(self, other: Self) -> bool {
1203 self.0 & other.0 == other.0
1204 }
1205
1206 #[inline]
1207 #[must_use]
1208 pub const fn intersects(self, other: Self) -> bool {
1209 self.0 & other.0 != 0
1210 }
1211
1212 #[inline]
1213 pub const fn insert(&mut self, other: Self) {
1214 *self = self.union(other);
1215 }
1216
1217 #[inline]
1218 pub const fn remove(&mut self, other: Self) {
1219 *self = self.difference(other);
1220 }
1221
1222 #[inline]
1223 pub const fn toggle(&mut self, other: Self) {
1224 *self = self.symmetric_difference(other);
1225 }
1226
1227 #[inline]
1228 pub const fn set(&mut self, other: Self, value: bool) {
1229 if value {
1230 self.insert(other);
1231 } else {
1232 self.remove(other);
1233 }
1234 }
1235
1236 #[inline]
1237 #[must_use]
1238 pub const fn intersection(self, other: Self) -> Self {
1239 Self(self.0 & other.0)
1240 }
1241
1242 #[inline]
1243 #[must_use]
1244 pub const fn union(self, other: Self) -> Self {
1245 Self(self.0 | other.0)
1246 }
1247
1248 #[inline]
1249 #[must_use]
1250 pub const fn difference(self, other: Self) -> Self {
1251 Self(self.0 & !other.0)
1252 }
1253
1254 #[inline]
1255 #[must_use]
1256 pub const fn complement(self) -> Self {
1257 Self(!self.0)
1258 }
1259
1260 #[inline]
1261 #[must_use]
1262 pub const fn symmetric_difference(self, other: Self) -> Self {
1263 Self(self.0 ^ other.0)
1264 }
1265
1266 #[inline]
1267 pub const fn all_known() -> Self {
1268 #[allow(clippy::eq_op, clippy::identity_op)]
1269 Self(0 | 0x1)
1270 }
1271}
1272
1273impl Iterator for WlShellSurfaceTransientIter {
1274 type Item = WlShellSurfaceTransient;
1275
1276 fn next(&mut self) -> Option<Self::Item> {
1277 if self.0 == 0 {
1278 return None;
1279 }
1280 let bit = 1 << self.0.trailing_zeros();
1281 self.0 &= !bit;
1282 Some(WlShellSurfaceTransient(bit))
1283 }
1284}
1285
1286impl IntoIterator for WlShellSurfaceTransient {
1287 type Item = WlShellSurfaceTransient;
1288 type IntoIter = WlShellSurfaceTransientIter;
1289
1290 fn into_iter(self) -> Self::IntoIter {
1291 WlShellSurfaceTransientIter(self.0)
1292 }
1293}
1294
1295impl BitAnd for WlShellSurfaceTransient {
1296 type Output = Self;
1297
1298 fn bitand(self, rhs: Self) -> Self::Output {
1299 self.intersection(rhs)
1300 }
1301}
1302
1303impl BitAndAssign for WlShellSurfaceTransient {
1304 fn bitand_assign(&mut self, rhs: Self) {
1305 *self = self.intersection(rhs);
1306 }
1307}
1308
1309impl BitOr for WlShellSurfaceTransient {
1310 type Output = Self;
1311
1312 fn bitor(self, rhs: Self) -> Self::Output {
1313 self.union(rhs)
1314 }
1315}
1316
1317impl BitOrAssign for WlShellSurfaceTransient {
1318 fn bitor_assign(&mut self, rhs: Self) {
1319 *self = self.union(rhs);
1320 }
1321}
1322
1323impl BitXor for WlShellSurfaceTransient {
1324 type Output = Self;
1325
1326 fn bitxor(self, rhs: Self) -> Self::Output {
1327 self.symmetric_difference(rhs)
1328 }
1329}
1330
1331impl BitXorAssign for WlShellSurfaceTransient {
1332 fn bitxor_assign(&mut self, rhs: Self) {
1333 *self = self.symmetric_difference(rhs);
1334 }
1335}
1336
1337impl Sub for WlShellSurfaceTransient {
1338 type Output = Self;
1339
1340 fn sub(self, rhs: Self) -> Self::Output {
1341 self.difference(rhs)
1342 }
1343}
1344
1345impl SubAssign for WlShellSurfaceTransient {
1346 fn sub_assign(&mut self, rhs: Self) {
1347 *self = self.difference(rhs);
1348 }
1349}
1350
1351impl Not for WlShellSurfaceTransient {
1352 type Output = Self;
1353
1354 fn not(self) -> Self::Output {
1355 self.complement()
1356 }
1357}
1358
1359impl Debug for WlShellSurfaceTransient {
1360 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1361 let mut v = self.0;
1362 let mut first = true;
1363 if v & 0x1 == 0x1 {
1364 v &= !0x1;
1365 if first {
1366 first = false;
1367 } else {
1368 f.write_str(" | ")?;
1369 }
1370 f.write_str("INACTIVE")?;
1371 }
1372 if v != 0 {
1373 if first {
1374 first = false;
1375 } else {
1376 f.write_str(" | ")?;
1377 }
1378 write!(f, "0x{v:032x}")?;
1379 }
1380 if first {
1381 f.write_str("0")?;
1382 }
1383 Ok(())
1384 }
1385}
1386
1387#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1393#[allow(dead_code)]
1394pub struct WlShellSurfaceFullscreenMethod(pub u32);
1395
1396impl WlShellSurfaceFullscreenMethod {
1397 #[allow(dead_code)]
1399 pub const DEFAULT: Self = Self(0);
1400
1401 #[allow(dead_code)]
1403 pub const SCALE: Self = Self(1);
1404
1405 #[allow(dead_code)]
1407 pub const DRIVER: Self = Self(2);
1408
1409 #[allow(dead_code)]
1411 pub const FILL: Self = Self(3);
1412}
1413
1414impl Debug for WlShellSurfaceFullscreenMethod {
1415 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1416 let name = match *self {
1417 Self::DEFAULT => "DEFAULT",
1418 Self::SCALE => "SCALE",
1419 Self::DRIVER => "DRIVER",
1420 Self::FILL => "FILL",
1421 _ => return Debug::fmt(&self.0, f),
1422 };
1423 f.write_str(name)
1424 }
1425}
1426
1427pub mod event_handlers {
1429 use super::*;
1430
1431 pub struct Ping<T, F>(F, PhantomData<fn(&mut T)>);
1433 impl<T, F> WlShellSurfaceEventHandler for Ping<T, F>
1434 where
1435 T: 'static,
1436 F: Fn(&mut T, &WlShellSurfaceRef, u32),
1437 {
1438 type Data = T;
1439
1440 #[inline]
1441 fn ping(&self, _data: &mut T, _slf: &WlShellSurfaceRef, serial: u32) {
1442 self.0(_data, _slf, serial)
1443 }
1444 }
1445
1446 pub struct Configure<T, F>(F, PhantomData<fn(&mut T)>);
1448 impl<T, F> WlShellSurfaceEventHandler for Configure<T, F>
1449 where
1450 T: 'static,
1451 F: Fn(&mut T, &WlShellSurfaceRef, WlShellSurfaceResize, i32, i32),
1452 {
1453 type Data = T;
1454
1455 #[inline]
1456 fn configure(
1457 &self,
1458 _data: &mut T,
1459 _slf: &WlShellSurfaceRef,
1460 edges: WlShellSurfaceResize,
1461 width: i32,
1462 height: i32,
1463 ) {
1464 self.0(_data, _slf, edges, width, height)
1465 }
1466 }
1467
1468 pub struct PopupDone<T, F>(F, PhantomData<fn(&mut T)>);
1470 impl<T, F> WlShellSurfaceEventHandler for PopupDone<T, F>
1471 where
1472 T: 'static,
1473 F: Fn(&mut T, &WlShellSurfaceRef),
1474 {
1475 type Data = T;
1476
1477 #[inline]
1478 fn popup_done(&self, _data: &mut T, _slf: &WlShellSurfaceRef) {
1479 self.0(_data, _slf)
1480 }
1481 }
1482
1483 impl WlShellSurface {
1484 #[allow(dead_code)]
1488 pub fn on_ping<T, F>(f: F) -> Ping<T, F>
1489 where
1490 T: 'static,
1491 F: Fn(&mut T, &WlShellSurfaceRef, u32),
1492 {
1493 Ping(f, PhantomData)
1494 }
1495
1496 #[allow(dead_code)]
1500 pub fn on_configure<T, F>(f: F) -> Configure<T, F>
1501 where
1502 T: 'static,
1503 F: Fn(&mut T, &WlShellSurfaceRef, WlShellSurfaceResize, i32, i32),
1504 {
1505 Configure(f, PhantomData)
1506 }
1507
1508 #[allow(dead_code)]
1512 pub fn on_popup_done<T, F>(f: F) -> PopupDone<T, F>
1513 where
1514 T: 'static,
1515 F: Fn(&mut T, &WlShellSurfaceRef),
1516 {
1517 PopupDone(f, PhantomData)
1518 }
1519 }
1520}