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