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