simple_window/common/protocols_data/wayland/
wl_data_device_manager.rs1use {super::super::all_types::*, ::wl_client::builder::prelude::*};
15
16static INTERFACE: wl_interface = wl_interface {
17 name: c"wl_data_device_manager".as_ptr(),
18 version: 3,
19 method_count: 2,
20 methods: {
21 static MESSAGES: [wl_message; 2] = [
22 wl_message {
23 name: c"create_data_source".as_ptr(),
24 signature: c"n".as_ptr(),
25 types: {
26 static TYPES: [Option<&'static wl_interface>; 1] =
27 [Some(WlDataSource::WL_INTERFACE)];
28 TYPES.as_ptr().cast()
29 },
30 },
31 wl_message {
32 name: c"get_data_device".as_ptr(),
33 signature: c"no".as_ptr(),
34 types: {
35 static TYPES: [Option<&'static wl_interface>; 2] =
36 [Some(WlDataDevice::WL_INTERFACE), Some(WlSeat::WL_INTERFACE)];
37 TYPES.as_ptr().cast()
38 },
39 },
40 ];
41 MESSAGES.as_ptr()
42 },
43 event_count: 0,
44 events: ptr::null(),
45};
46
47#[derive(Clone, Eq, PartialEq)]
51#[repr(transparent)]
52pub struct WlDataDeviceManager {
53 proxy: UntypedOwnedProxy,
55}
56
57#[derive(Eq, PartialEq)]
61#[repr(transparent)]
62pub struct WlDataDeviceManagerRef {
63 proxy: UntypedBorrowedProxy,
65}
66
67unsafe impl UntypedOwnedProxyWrapper for WlDataDeviceManager {}
69
70unsafe impl OwnedProxy for WlDataDeviceManager {
73 const INTERFACE: &'static str = "wl_data_device_manager";
74 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
75 const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
76 private::EventHandler(private::NoOpEventHandler);
77 const MAX_VERSION: u32 = 3;
78
79 type Borrowed = WlDataDeviceManagerRef;
80 type Api = private::ProxyApi;
81 type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
82}
83
84unsafe impl UntypedBorrowedProxyWrapper for WlDataDeviceManagerRef {}
86
87unsafe impl BorrowedProxy for WlDataDeviceManagerRef {
89 type Owned = WlDataDeviceManager;
90}
91
92impl Deref for WlDataDeviceManager {
93 type Target = WlDataDeviceManagerRef;
94
95 fn deref(&self) -> &Self::Target {
96 proxy::low_level::deref(self)
97 }
98}
99
100mod private {
101 pub struct ProxyApi;
102
103 #[allow(dead_code)]
104 pub struct EventHandler<H>(pub(super) H);
105
106 #[allow(dead_code)]
107 pub struct NoOpEventHandler;
108}
109
110impl Debug for WlDataDeviceManager {
111 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
112 write!(f, "wl_data_device_manager#{}", self.proxy.id())
113 }
114}
115
116impl Debug for WlDataDeviceManagerRef {
117 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
118 write!(f, "wl_data_device_manager#{}", self.proxy.id())
119 }
120}
121
122impl PartialEq<WlDataDeviceManagerRef> for WlDataDeviceManager {
123 fn eq(&self, other: &WlDataDeviceManagerRef) -> bool {
124 self.proxy == other.proxy
125 }
126}
127
128impl PartialEq<WlDataDeviceManager> for WlDataDeviceManagerRef {
129 fn eq(&self, other: &WlDataDeviceManager) -> bool {
130 self.proxy == other.proxy
131 }
132}
133
134#[allow(dead_code)]
135impl WlDataDeviceManager {
136 #[allow(dead_code)]
138 pub const REQ__CREATE_DATA_SOURCE__SINCE: u32 = 1;
139
140 #[inline]
144 pub fn create_data_source(&self) -> WlDataSource {
145 let mut args = [wl_argument { n: 0 }];
146 let data = unsafe {
151 self.proxy
152 .send_constructor::<false>(0, &mut args, WlDataSource::WL_INTERFACE, None)
153 };
154 unsafe { proxy::low_level::from_untyped_owned(data) }
156 }
157
158 #[allow(dead_code)]
160 pub const REQ__GET_DATA_DEVICE__SINCE: u32 = 1;
161
162 #[inline]
170 pub fn get_data_device(&self, seat: &WlSeatRef) -> WlDataDevice {
171 let (arg1,) = (seat,);
172 let obj1_lock = proxy::lock(arg1);
173 let obj1 = check_argument_proxy("seat", obj1_lock.wl_proxy());
174 let mut args = [wl_argument { n: 0 }, wl_argument { o: obj1 }];
175 let data = unsafe {
180 self.proxy
181 .send_constructor::<false>(1, &mut args, WlDataDevice::WL_INTERFACE, None)
182 };
183 unsafe { proxy::low_level::from_untyped_owned(data) }
185 }
186}
187
188#[allow(dead_code)]
189impl WlDataDeviceManagerRef {
190 #[inline]
198 pub fn create_data_source(&self, _queue: &Queue) -> WlDataSource {
199 let mut args = [wl_argument { n: 0 }];
200 let data = unsafe {
205 self.proxy
206 .send_constructor(_queue, 0, &mut args, WlDataSource::WL_INTERFACE, None)
207 };
208 unsafe { proxy::low_level::from_untyped_owned(data) }
210 }
211
212 #[inline]
221 pub fn get_data_device(&self, _queue: &Queue, seat: &WlSeatRef) -> WlDataDevice {
222 let (arg1,) = (seat,);
223 let obj1_lock = proxy::lock(arg1);
224 let obj1 = check_argument_proxy("seat", obj1_lock.wl_proxy());
225 let mut args = [wl_argument { n: 0 }, wl_argument { o: obj1 }];
226 let data = unsafe {
231 self.proxy
232 .send_constructor(_queue, 1, &mut args, WlDataDevice::WL_INTERFACE, None)
233 };
234 unsafe { proxy::low_level::from_untyped_owned(data) }
236 }
237}
238
239#[allow(dead_code)]
241pub trait WlDataDeviceManagerEventHandler {
242 type Data: 'static;
243}
244
245impl WlDataDeviceManagerEventHandler for private::NoOpEventHandler {
246 type Data = ();
247}
248
249unsafe impl<H> EventHandler for private::EventHandler<H>
252where
253 H: WlDataDeviceManagerEventHandler,
254{
255 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
256
257 #[inline]
258 fn mutable_type() -> Option<(TypeId, &'static str)> {
259 let id = TypeId::of::<H::Data>();
260 let name = std::any::type_name::<H::Data>();
261 Some((id, name))
262 }
263
264 #[allow(unused_variables)]
265 unsafe fn handle_event(
266 &self,
267 queue: &Queue,
268 data: *mut u8,
269 slf: &UntypedBorrowedProxy,
270 opcode: u32,
271 args: *mut wl_argument,
272 ) {
273 invalid_opcode("wl_data_device_manager", opcode);
274 }
275}
276
277impl<H> CreateEventHandler<H> for private::ProxyApi
278where
279 H: WlDataDeviceManagerEventHandler,
280{
281 type EventHandler = private::EventHandler<H>;
282
283 #[inline]
284 fn create_event_handler(handler: H) -> Self::EventHandler {
285 private::EventHandler(handler)
286 }
287}
288
289impl WlDataDeviceManager {
290 #[allow(dead_code)]
292 pub const ENM__DND_ACTION_NONE__SINCE: u32 = 1;
293 #[allow(dead_code)]
295 pub const ENM__DND_ACTION_COPY__SINCE: u32 = 1;
296 #[allow(dead_code)]
298 pub const ENM__DND_ACTION_MOVE__SINCE: u32 = 1;
299 #[allow(dead_code)]
301 pub const ENM__DND_ACTION_ASK__SINCE: u32 = 1;
302}
303
304#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
330#[allow(dead_code)]
331pub struct WlDataDeviceManagerDndAction(pub u32);
332
333#[derive(Clone, Debug)]
337pub struct WlDataDeviceManagerDndActionIter(pub u32);
338
339impl WlDataDeviceManagerDndAction {
340 #[allow(dead_code)]
342 pub const NONE: Self = Self(0);
343
344 #[allow(dead_code)]
346 pub const COPY: Self = Self(1);
347
348 #[allow(dead_code)]
350 pub const MOVE: Self = Self(2);
351
352 #[allow(dead_code)]
354 pub const ASK: Self = Self(4);
355}
356
357#[allow(dead_code)]
358impl WlDataDeviceManagerDndAction {
359 #[inline]
360 pub const fn empty() -> Self {
361 Self(0)
362 }
363
364 #[inline]
365 #[must_use]
366 pub const fn is_empty(self) -> bool {
367 self.0 == 0
368 }
369
370 #[inline]
371 #[must_use]
372 pub const fn contains(self, other: Self) -> bool {
373 self.0 & other.0 == other.0
374 }
375
376 #[inline]
377 #[must_use]
378 pub const fn intersects(self, other: Self) -> bool {
379 self.0 & other.0 != 0
380 }
381
382 #[inline]
383 pub const fn insert(&mut self, other: Self) {
384 *self = self.union(other);
385 }
386
387 #[inline]
388 pub const fn remove(&mut self, other: Self) {
389 *self = self.difference(other);
390 }
391
392 #[inline]
393 pub const fn toggle(&mut self, other: Self) {
394 *self = self.symmetric_difference(other);
395 }
396
397 #[inline]
398 pub const fn set(&mut self, other: Self, value: bool) {
399 if value {
400 self.insert(other);
401 } else {
402 self.remove(other);
403 }
404 }
405
406 #[inline]
407 #[must_use]
408 pub const fn intersection(self, other: Self) -> Self {
409 Self(self.0 & other.0)
410 }
411
412 #[inline]
413 #[must_use]
414 pub const fn union(self, other: Self) -> Self {
415 Self(self.0 | other.0)
416 }
417
418 #[inline]
419 #[must_use]
420 pub const fn difference(self, other: Self) -> Self {
421 Self(self.0 & !other.0)
422 }
423
424 #[inline]
425 #[must_use]
426 pub const fn complement(self) -> Self {
427 Self(!self.0)
428 }
429
430 #[inline]
431 #[must_use]
432 pub const fn symmetric_difference(self, other: Self) -> Self {
433 Self(self.0 ^ other.0)
434 }
435
436 #[inline]
437 pub const fn all_known() -> Self {
438 #[allow(clippy::eq_op, clippy::identity_op)]
439 Self(0 | 0 | 1 | 2 | 4)
440 }
441}
442
443impl Iterator for WlDataDeviceManagerDndActionIter {
444 type Item = WlDataDeviceManagerDndAction;
445
446 fn next(&mut self) -> Option<Self::Item> {
447 if self.0 == 0 {
448 return None;
449 }
450 let bit = 1 << self.0.trailing_zeros();
451 self.0 &= !bit;
452 Some(WlDataDeviceManagerDndAction(bit))
453 }
454}
455
456impl IntoIterator for WlDataDeviceManagerDndAction {
457 type Item = WlDataDeviceManagerDndAction;
458 type IntoIter = WlDataDeviceManagerDndActionIter;
459
460 fn into_iter(self) -> Self::IntoIter {
461 WlDataDeviceManagerDndActionIter(self.0)
462 }
463}
464
465impl BitAnd for WlDataDeviceManagerDndAction {
466 type Output = Self;
467
468 fn bitand(self, rhs: Self) -> Self::Output {
469 self.intersection(rhs)
470 }
471}
472
473impl BitAndAssign for WlDataDeviceManagerDndAction {
474 fn bitand_assign(&mut self, rhs: Self) {
475 *self = self.intersection(rhs);
476 }
477}
478
479impl BitOr for WlDataDeviceManagerDndAction {
480 type Output = Self;
481
482 fn bitor(self, rhs: Self) -> Self::Output {
483 self.union(rhs)
484 }
485}
486
487impl BitOrAssign for WlDataDeviceManagerDndAction {
488 fn bitor_assign(&mut self, rhs: Self) {
489 *self = self.union(rhs);
490 }
491}
492
493impl BitXor for WlDataDeviceManagerDndAction {
494 type Output = Self;
495
496 fn bitxor(self, rhs: Self) -> Self::Output {
497 self.symmetric_difference(rhs)
498 }
499}
500
501impl BitXorAssign for WlDataDeviceManagerDndAction {
502 fn bitxor_assign(&mut self, rhs: Self) {
503 *self = self.symmetric_difference(rhs);
504 }
505}
506
507impl Sub for WlDataDeviceManagerDndAction {
508 type Output = Self;
509
510 fn sub(self, rhs: Self) -> Self::Output {
511 self.difference(rhs)
512 }
513}
514
515impl SubAssign for WlDataDeviceManagerDndAction {
516 fn sub_assign(&mut self, rhs: Self) {
517 *self = self.difference(rhs);
518 }
519}
520
521impl Not for WlDataDeviceManagerDndAction {
522 type Output = Self;
523
524 fn not(self) -> Self::Output {
525 self.complement()
526 }
527}
528
529impl Debug for WlDataDeviceManagerDndAction {
530 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
531 let mut v = self.0;
532 let mut first = true;
533 if v & 1 == 1 {
534 v &= !1;
535 if first {
536 first = false;
537 } else {
538 f.write_str(" | ")?;
539 }
540 f.write_str("COPY")?;
541 }
542 if v & 2 == 2 {
543 v &= !2;
544 if first {
545 first = false;
546 } else {
547 f.write_str(" | ")?;
548 }
549 f.write_str("MOVE")?;
550 }
551 if v & 4 == 4 {
552 v &= !4;
553 if first {
554 first = false;
555 } else {
556 f.write_str(" | ")?;
557 }
558 f.write_str("ASK")?;
559 }
560 if v != 0 {
561 if first {
562 first = false;
563 } else {
564 f.write_str(" | ")?;
565 }
566 write!(f, "0x{v:032x}")?;
567 }
568 if first {
569 f.write_str("NONE")?;
570 }
571 Ok(())
572 }
573}
574
575pub mod event_handlers {
577 use super::*;
578
579 impl WlDataDeviceManager {}
580}