get_registry/common/protocols_data/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 type Data: 'static;
247}
248
249impl WlDataDeviceManagerEventHandler for private::NoOpEventHandler {
250 type Data = ();
251}
252
253unsafe impl<H> EventHandler for private::EventHandler<H>
256where
257 H: WlDataDeviceManagerEventHandler,
258{
259 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
260
261 #[inline]
262 fn mutable_type() -> Option<(TypeId, &'static str)> {
263 let id = TypeId::of::<H::Data>();
264 let name = std::any::type_name::<H::Data>();
265 Some((id, name))
266 }
267
268 #[allow(unused_variables)]
269 unsafe fn handle_event(
270 &self,
271 queue: &Queue,
272 data: *mut u8,
273 slf: &UntypedBorrowedProxy,
274 opcode: u32,
275 args: *mut wl_argument,
276 ) {
277 invalid_opcode("wl_data_device_manager", opcode);
278 }
279}
280
281impl<H> CreateEventHandler<H> for private::ProxyApi
282where
283 H: WlDataDeviceManagerEventHandler,
284{
285 type EventHandler = private::EventHandler<H>;
286
287 #[inline]
288 fn create_event_handler(handler: H) -> Self::EventHandler {
289 private::EventHandler(handler)
290 }
291}
292
293impl WlDataDeviceManager {
294 #[allow(dead_code)]
296 pub const ENM__DND_ACTION_NONE__SINCE: u32 = 1;
297 #[allow(dead_code)]
299 pub const ENM__DND_ACTION_COPY__SINCE: u32 = 1;
300 #[allow(dead_code)]
302 pub const ENM__DND_ACTION_MOVE__SINCE: u32 = 1;
303 #[allow(dead_code)]
305 pub const ENM__DND_ACTION_ASK__SINCE: u32 = 1;
306}
307
308#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
334#[allow(dead_code)]
335pub struct WlDataDeviceManagerDndAction(pub u32);
336
337#[derive(Clone, Debug)]
341#[allow(dead_code)]
342pub struct WlDataDeviceManagerDndActionIter(pub u32);
343
344impl WlDataDeviceManagerDndAction {
345 #[allow(dead_code)]
347 pub const NONE: Self = Self(0);
348
349 #[allow(dead_code)]
351 pub const COPY: Self = Self(1);
352
353 #[allow(dead_code)]
355 pub const MOVE: Self = Self(2);
356
357 #[allow(dead_code)]
359 pub const ASK: Self = Self(4);
360}
361
362#[allow(dead_code)]
363impl WlDataDeviceManagerDndAction {
364 #[inline]
365 pub const fn empty() -> Self {
366 Self(0)
367 }
368
369 #[inline]
370 #[must_use]
371 pub const fn is_empty(self) -> bool {
372 self.0 == 0
373 }
374
375 #[inline]
376 #[must_use]
377 pub const fn contains(self, other: Self) -> bool {
378 self.0 & other.0 == other.0
379 }
380
381 #[inline]
382 #[must_use]
383 pub const fn intersects(self, other: Self) -> bool {
384 self.0 & other.0 != 0
385 }
386
387 #[inline]
388 pub const fn insert(&mut self, other: Self) {
389 *self = self.union(other);
390 }
391
392 #[inline]
393 pub const fn remove(&mut self, other: Self) {
394 *self = self.difference(other);
395 }
396
397 #[inline]
398 pub const fn toggle(&mut self, other: Self) {
399 *self = self.symmetric_difference(other);
400 }
401
402 #[inline]
403 pub const fn set(&mut self, other: Self, value: bool) {
404 if value {
405 self.insert(other);
406 } else {
407 self.remove(other);
408 }
409 }
410
411 #[inline]
412 #[must_use]
413 pub const fn intersection(self, other: Self) -> Self {
414 Self(self.0 & other.0)
415 }
416
417 #[inline]
418 #[must_use]
419 pub const fn union(self, other: Self) -> Self {
420 Self(self.0 | other.0)
421 }
422
423 #[inline]
424 #[must_use]
425 pub const fn difference(self, other: Self) -> Self {
426 Self(self.0 & !other.0)
427 }
428
429 #[inline]
430 #[must_use]
431 pub const fn complement(self) -> Self {
432 Self(!self.0)
433 }
434
435 #[inline]
436 #[must_use]
437 pub const fn symmetric_difference(self, other: Self) -> Self {
438 Self(self.0 ^ other.0)
439 }
440
441 #[inline]
442 pub const fn all_known() -> Self {
443 #[allow(clippy::eq_op, clippy::identity_op)]
444 Self(0 | 0 | 1 | 2 | 4)
445 }
446}
447
448impl Iterator for WlDataDeviceManagerDndActionIter {
449 type Item = WlDataDeviceManagerDndAction;
450
451 fn next(&mut self) -> Option<Self::Item> {
452 if self.0 == 0 {
453 return None;
454 }
455 let bit = 1 << self.0.trailing_zeros();
456 self.0 &= !bit;
457 Some(WlDataDeviceManagerDndAction(bit))
458 }
459}
460
461impl IntoIterator for WlDataDeviceManagerDndAction {
462 type Item = WlDataDeviceManagerDndAction;
463 type IntoIter = WlDataDeviceManagerDndActionIter;
464
465 fn into_iter(self) -> Self::IntoIter {
466 WlDataDeviceManagerDndActionIter(self.0)
467 }
468}
469
470impl BitAnd for WlDataDeviceManagerDndAction {
471 type Output = Self;
472
473 fn bitand(self, rhs: Self) -> Self::Output {
474 self.intersection(rhs)
475 }
476}
477
478impl BitAndAssign for WlDataDeviceManagerDndAction {
479 fn bitand_assign(&mut self, rhs: Self) {
480 *self = self.intersection(rhs);
481 }
482}
483
484impl BitOr for WlDataDeviceManagerDndAction {
485 type Output = Self;
486
487 fn bitor(self, rhs: Self) -> Self::Output {
488 self.union(rhs)
489 }
490}
491
492impl BitOrAssign for WlDataDeviceManagerDndAction {
493 fn bitor_assign(&mut self, rhs: Self) {
494 *self = self.union(rhs);
495 }
496}
497
498impl BitXor for WlDataDeviceManagerDndAction {
499 type Output = Self;
500
501 fn bitxor(self, rhs: Self) -> Self::Output {
502 self.symmetric_difference(rhs)
503 }
504}
505
506impl BitXorAssign for WlDataDeviceManagerDndAction {
507 fn bitxor_assign(&mut self, rhs: Self) {
508 *self = self.symmetric_difference(rhs);
509 }
510}
511
512impl Sub for WlDataDeviceManagerDndAction {
513 type Output = Self;
514
515 fn sub(self, rhs: Self) -> Self::Output {
516 self.difference(rhs)
517 }
518}
519
520impl SubAssign for WlDataDeviceManagerDndAction {
521 fn sub_assign(&mut self, rhs: Self) {
522 *self = self.difference(rhs);
523 }
524}
525
526impl Not for WlDataDeviceManagerDndAction {
527 type Output = Self;
528
529 fn not(self) -> Self::Output {
530 self.complement()
531 }
532}
533
534impl Debug for WlDataDeviceManagerDndAction {
535 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
536 let mut v = self.0;
537 let mut first = true;
538 if v & 1 == 1 {
539 v &= !1;
540 if first {
541 first = false;
542 } else {
543 f.write_str(" | ")?;
544 }
545 f.write_str("COPY")?;
546 }
547 if v & 2 == 2 {
548 v &= !2;
549 if first {
550 first = false;
551 } else {
552 f.write_str(" | ")?;
553 }
554 f.write_str("MOVE")?;
555 }
556 if v & 4 == 4 {
557 v &= !4;
558 if first {
559 first = false;
560 } else {
561 f.write_str(" | ")?;
562 }
563 f.write_str("ASK")?;
564 }
565 if v != 0 {
566 if first {
567 first = false;
568 } else {
569 f.write_str(" | ")?;
570 }
571 write!(f, "0x{v:032x}")?;
572 }
573 if first {
574 f.write_str("NONE")?;
575 }
576 Ok(())
577 }
578}
579
580pub mod event_handlers {
582 use super::*;
583
584 impl WlDataDeviceManager {}
585}