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