pub struct Fixed(/* private fields */);Expand description
A signed 24.8 fixed-point number used in the wayland protocol.
This is a signed decimal type which offers a sign bit, 23 bits of integer precision and 8 bits of decimal precision.
§Arithmetic operations
This type implements all of the usual arithmetic operations for numbers. On overflow, they behave like the standard library operations except that multiplication and division always use wrapping semantics.
Implementations§
Source§impl Fixed
impl Fixed
Sourcepub const NEGATIVE_EPSILON: Self
pub const NEGATIVE_EPSILON: Self
The largest negative Fixed.
Sourcepub const fn from_wire(val: i32) -> Self
pub const fn from_wire(val: i32) -> Self
Creates a Fixed from the raw bits that appear in the wire protocol.
Examples found in repository?
340 unsafe fn handle_event(
341 &self,
342 queue: &Queue,
343 slf: &UntypedBorrowedProxy,
344 opcode: u32,
345 args: *mut wl_argument,
346 ) {
347 // SAFETY: This function required that slf has the interface INTERFACE
348 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<ZwpTabletPadRingV2Ref>(slf) };
349 match opcode {
350 0 => {
351 // SAFETY: INTERFACE requires that there are 1 arguments
352 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
353 // SAFETY: - INTERFACE requires that args[0] contains a uint
354 let arg0 = unsafe { ZwpTabletPadRingV2Source(args[0].u) };
355 self.0.source(slf, arg0);
356 }
357 1 => {
358 // SAFETY: INTERFACE requires that there are 1 arguments
359 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
360 // SAFETY: - INTERFACE requires that args[0] contains a fixed
361 let arg0 = unsafe { Fixed::from_wire(args[0].f) };
362 self.0.angle(slf, arg0);
363 }
364 2 => {
365 self.0.stop(slf);
366 }
367 3 => {
368 // SAFETY: INTERFACE requires that there are 1 arguments
369 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
370 // SAFETY: - INTERFACE requires that args[0] contains a uint
371 let arg0 = unsafe { args[0].u };
372 self.0.frame(slf, arg0);
373 }
374 _ => {
375 invalid_opcode("zwp_tablet_pad_ring_v2", opcode);
376 }
377 }
378 }More examples
419 unsafe fn handle_event(
420 &self,
421 queue: &Queue,
422 slf: &UntypedBorrowedProxy,
423 opcode: u32,
424 args: *mut wl_argument,
425 ) {
426 // SAFETY: This function required that slf has the interface INTERFACE
427 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlTouchRef>(slf) };
428 match opcode {
429 0 => {
430 // SAFETY: INTERFACE requires that there are 6 arguments
431 let args = unsafe { &*args.cast::<[wl_argument; 6]>() };
432 // SAFETY: - INTERFACE requires that args[0] contains a uint
433 let arg0 = unsafe { args[0].u };
434 // SAFETY: - INTERFACE requires that args[1] contains a uint
435 let arg1 = unsafe { args[1].u };
436 // SAFETY: - INTERFACE requires that args[2] contains an object
437 let arg2 = unsafe {
438 if let Some(p) = NonNull::new(args[2].o.cast()) {
439 Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
440 } else {
441 None
442 }
443 };
444 // SAFETY: - INTERFACE requires that the object has the interface WlSurface::WL_INTERFACE
445 let arg2 = arg2.as_ref().map(|arg2| unsafe {
446 proxy::low_level::from_untyped_borrowed::<WlSurfaceRef>(arg2)
447 });
448 // SAFETY: - INTERFACE requires that args[3] contains an int
449 let arg3 = unsafe { args[3].i };
450 // SAFETY: - INTERFACE requires that args[4] contains a fixed
451 let arg4 = unsafe { Fixed::from_wire(args[4].f) };
452 // SAFETY: - INTERFACE requires that args[5] contains a fixed
453 let arg5 = unsafe { Fixed::from_wire(args[5].f) };
454 self.0.down(slf, arg0, arg1, arg2, arg3, arg4, arg5);
455 }
456 1 => {
457 // SAFETY: INTERFACE requires that there are 3 arguments
458 let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
459 // SAFETY: - INTERFACE requires that args[0] contains a uint
460 let arg0 = unsafe { args[0].u };
461 // SAFETY: - INTERFACE requires that args[1] contains a uint
462 let arg1 = unsafe { args[1].u };
463 // SAFETY: - INTERFACE requires that args[2] contains an int
464 let arg2 = unsafe { args[2].i };
465 self.0.up(slf, arg0, arg1, arg2);
466 }
467 2 => {
468 // SAFETY: INTERFACE requires that there are 4 arguments
469 let args = unsafe { &*args.cast::<[wl_argument; 4]>() };
470 // SAFETY: - INTERFACE requires that args[0] contains a uint
471 let arg0 = unsafe { args[0].u };
472 // SAFETY: - INTERFACE requires that args[1] contains an int
473 let arg1 = unsafe { args[1].i };
474 // SAFETY: - INTERFACE requires that args[2] contains a fixed
475 let arg2 = unsafe { Fixed::from_wire(args[2].f) };
476 // SAFETY: - INTERFACE requires that args[3] contains a fixed
477 let arg3 = unsafe { Fixed::from_wire(args[3].f) };
478 self.0.motion(slf, arg0, arg1, arg2, arg3);
479 }
480 3 => {
481 self.0.frame(slf);
482 }
483 4 => {
484 self.0.cancel(slf);
485 }
486 5 => {
487 // SAFETY: INTERFACE requires that there are 3 arguments
488 let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
489 // SAFETY: - INTERFACE requires that args[0] contains an int
490 let arg0 = unsafe { args[0].i };
491 // SAFETY: - INTERFACE requires that args[1] contains a fixed
492 let arg1 = unsafe { Fixed::from_wire(args[1].f) };
493 // SAFETY: - INTERFACE requires that args[2] contains a fixed
494 let arg2 = unsafe { Fixed::from_wire(args[2].f) };
495 self.0.shape(slf, arg0, arg1, arg2);
496 }
497 6 => {
498 // SAFETY: INTERFACE requires that there are 2 arguments
499 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
500 // SAFETY: - INTERFACE requires that args[0] contains an int
501 let arg0 = unsafe { args[0].i };
502 // SAFETY: - INTERFACE requires that args[1] contains a fixed
503 let arg1 = unsafe { Fixed::from_wire(args[1].f) };
504 self.0.orientation(slf, arg0, arg1);
505 }
506 _ => {
507 invalid_opcode("wl_touch", opcode);
508 }
509 }
510 }490 unsafe fn handle_event(
491 &self,
492 queue: &Queue,
493 slf: &UntypedBorrowedProxy,
494 opcode: u32,
495 args: *mut wl_argument,
496 ) {
497 // SAFETY: This function required that slf has the interface INTERFACE
498 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlDataDeviceRef>(slf) };
499 match opcode {
500 0 => {
501 // SAFETY: INTERFACE requires that there are 1 arguments
502 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
503 // SAFETY: - INTERFACE requires that args[0] contains an object
504 // - ownership is transferred to this function
505 // - INTERFACE requires that the object has the interface WlDataOffer::WL_INTERFACE
506 let arg0 = unsafe {
507 UntypedOwnedProxy::from_plain_wl_proxy(
508 queue,
509 NonNull::new_unchecked(args[0].o.cast()),
510 WlDataOffer::WL_INTERFACE,
511 )
512 };
513 // SAFETY: - INTERFACE requires that the object has the interface WlDataOffer::WL_INTERFACE
514 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<WlDataOffer>(arg0) };
515 self.0.data_offer(slf, arg0);
516 }
517 1 => {
518 // SAFETY: INTERFACE requires that there are 5 arguments
519 let args = unsafe { &*args.cast::<[wl_argument; 5]>() };
520 // SAFETY: - INTERFACE requires that args[0] contains a uint
521 let arg0 = unsafe { args[0].u };
522 // SAFETY: - INTERFACE requires that args[1] contains an object
523 let arg1 = unsafe {
524 if let Some(p) = NonNull::new(args[1].o.cast()) {
525 Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
526 } else {
527 None
528 }
529 };
530 // SAFETY: - INTERFACE requires that the object has the interface WlSurface::WL_INTERFACE
531 let arg1 = arg1.as_ref().map(|arg1| unsafe {
532 proxy::low_level::from_untyped_borrowed::<WlSurfaceRef>(arg1)
533 });
534 // SAFETY: - INTERFACE requires that args[2] contains a fixed
535 let arg2 = unsafe { Fixed::from_wire(args[2].f) };
536 // SAFETY: - INTERFACE requires that args[3] contains a fixed
537 let arg3 = unsafe { Fixed::from_wire(args[3].f) };
538 // SAFETY: - INTERFACE requires that args[4] contains an object
539 let arg4 = unsafe {
540 if let Some(p) = NonNull::new(args[4].o.cast()) {
541 Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
542 } else {
543 None
544 }
545 };
546 // SAFETY: - INTERFACE requires that the object has the interface WlDataOffer::WL_INTERFACE
547 let arg4 = arg4.as_ref().map(|arg4| unsafe {
548 proxy::low_level::from_untyped_borrowed::<WlDataOfferRef>(arg4)
549 });
550 self.0.enter(slf, arg0, arg1, arg2, arg3, arg4);
551 }
552 2 => {
553 self.0.leave(slf);
554 }
555 3 => {
556 // SAFETY: INTERFACE requires that there are 3 arguments
557 let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
558 // SAFETY: - INTERFACE requires that args[0] contains a uint
559 let arg0 = unsafe { args[0].u };
560 // SAFETY: - INTERFACE requires that args[1] contains a fixed
561 let arg1 = unsafe { Fixed::from_wire(args[1].f) };
562 // SAFETY: - INTERFACE requires that args[2] contains a fixed
563 let arg2 = unsafe { Fixed::from_wire(args[2].f) };
564 self.0.motion(slf, arg0, arg1, arg2);
565 }
566 4 => {
567 self.0.drop(slf);
568 }
569 5 => {
570 // SAFETY: INTERFACE requires that there are 1 arguments
571 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
572 // SAFETY: - INTERFACE requires that args[0] contains an object
573 let arg0 = unsafe {
574 if let Some(p) = NonNull::new(args[0].o.cast()) {
575 Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
576 } else {
577 None
578 }
579 };
580 // SAFETY: - INTERFACE requires that the object has the interface WlDataOffer::WL_INTERFACE
581 let arg0 = arg0.as_ref().map(|arg0| unsafe {
582 proxy::low_level::from_untyped_borrowed::<WlDataOfferRef>(arg0)
583 });
584 self.0.selection(slf, arg0);
585 }
586 _ => {
587 invalid_opcode("wl_data_device", opcode);
588 }
589 }
590 }759 unsafe fn handle_event(
760 &self,
761 queue: &Queue,
762 slf: &UntypedBorrowedProxy,
763 opcode: u32,
764 args: *mut wl_argument,
765 ) {
766 // SAFETY: This function required that slf has the interface INTERFACE
767 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlPointerRef>(slf) };
768 match opcode {
769 0 => {
770 // SAFETY: INTERFACE requires that there are 4 arguments
771 let args = unsafe { &*args.cast::<[wl_argument; 4]>() };
772 // SAFETY: - INTERFACE requires that args[0] contains a uint
773 let arg0 = unsafe { args[0].u };
774 // SAFETY: - INTERFACE requires that args[1] contains an object
775 let arg1 = unsafe {
776 if let Some(p) = NonNull::new(args[1].o.cast()) {
777 Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
778 } else {
779 None
780 }
781 };
782 // SAFETY: - INTERFACE requires that the object has the interface WlSurface::WL_INTERFACE
783 let arg1 = arg1.as_ref().map(|arg1| unsafe {
784 proxy::low_level::from_untyped_borrowed::<WlSurfaceRef>(arg1)
785 });
786 // SAFETY: - INTERFACE requires that args[2] contains a fixed
787 let arg2 = unsafe { Fixed::from_wire(args[2].f) };
788 // SAFETY: - INTERFACE requires that args[3] contains a fixed
789 let arg3 = unsafe { Fixed::from_wire(args[3].f) };
790 self.0.enter(slf, arg0, arg1, arg2, arg3);
791 }
792 1 => {
793 // SAFETY: INTERFACE requires that there are 2 arguments
794 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
795 // SAFETY: - INTERFACE requires that args[0] contains a uint
796 let arg0 = unsafe { args[0].u };
797 // SAFETY: - INTERFACE requires that args[1] contains an object
798 let arg1 = unsafe {
799 if let Some(p) = NonNull::new(args[1].o.cast()) {
800 Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
801 } else {
802 None
803 }
804 };
805 // SAFETY: - INTERFACE requires that the object has the interface WlSurface::WL_INTERFACE
806 let arg1 = arg1.as_ref().map(|arg1| unsafe {
807 proxy::low_level::from_untyped_borrowed::<WlSurfaceRef>(arg1)
808 });
809 self.0.leave(slf, arg0, arg1);
810 }
811 2 => {
812 // SAFETY: INTERFACE requires that there are 3 arguments
813 let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
814 // SAFETY: - INTERFACE requires that args[0] contains a uint
815 let arg0 = unsafe { args[0].u };
816 // SAFETY: - INTERFACE requires that args[1] contains a fixed
817 let arg1 = unsafe { Fixed::from_wire(args[1].f) };
818 // SAFETY: - INTERFACE requires that args[2] contains a fixed
819 let arg2 = unsafe { Fixed::from_wire(args[2].f) };
820 self.0.motion(slf, arg0, arg1, arg2);
821 }
822 3 => {
823 // SAFETY: INTERFACE requires that there are 4 arguments
824 let args = unsafe { &*args.cast::<[wl_argument; 4]>() };
825 // SAFETY: - INTERFACE requires that args[0] contains a uint
826 let arg0 = unsafe { args[0].u };
827 // SAFETY: - INTERFACE requires that args[1] contains a uint
828 let arg1 = unsafe { args[1].u };
829 // SAFETY: - INTERFACE requires that args[2] contains a uint
830 let arg2 = unsafe { args[2].u };
831 // SAFETY: - INTERFACE requires that args[3] contains a uint
832 let arg3 = unsafe { WlPointerButtonState(args[3].u) };
833 self.0.button(slf, arg0, arg1, arg2, arg3);
834 }
835 4 => {
836 // SAFETY: INTERFACE requires that there are 3 arguments
837 let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
838 // SAFETY: - INTERFACE requires that args[0] contains a uint
839 let arg0 = unsafe { args[0].u };
840 // SAFETY: - INTERFACE requires that args[1] contains a uint
841 let arg1 = unsafe { WlPointerAxis(args[1].u) };
842 // SAFETY: - INTERFACE requires that args[2] contains a fixed
843 let arg2 = unsafe { Fixed::from_wire(args[2].f) };
844 self.0.axis(slf, arg0, arg1, arg2);
845 }
846 5 => {
847 self.0.frame(slf);
848 }
849 6 => {
850 // SAFETY: INTERFACE requires that there are 1 arguments
851 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
852 // SAFETY: - INTERFACE requires that args[0] contains a uint
853 let arg0 = unsafe { WlPointerAxisSource(args[0].u) };
854 self.0.axis_source(slf, arg0);
855 }
856 7 => {
857 // SAFETY: INTERFACE requires that there are 2 arguments
858 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
859 // SAFETY: - INTERFACE requires that args[0] contains a uint
860 let arg0 = unsafe { args[0].u };
861 // SAFETY: - INTERFACE requires that args[1] contains a uint
862 let arg1 = unsafe { WlPointerAxis(args[1].u) };
863 self.0.axis_stop(slf, arg0, arg1);
864 }
865 8 => {
866 // SAFETY: INTERFACE requires that there are 2 arguments
867 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
868 // SAFETY: - INTERFACE requires that args[0] contains a uint
869 let arg0 = unsafe { WlPointerAxis(args[0].u) };
870 // SAFETY: - INTERFACE requires that args[1] contains an int
871 let arg1 = unsafe { args[1].i };
872 self.0.axis_discrete(slf, arg0, arg1);
873 }
874 9 => {
875 // SAFETY: INTERFACE requires that there are 2 arguments
876 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
877 // SAFETY: - INTERFACE requires that args[0] contains a uint
878 let arg0 = unsafe { WlPointerAxis(args[0].u) };
879 // SAFETY: - INTERFACE requires that args[1] contains an int
880 let arg1 = unsafe { args[1].i };
881 self.0.axis_value120(slf, arg0, arg1);
882 }
883 10 => {
884 // SAFETY: INTERFACE requires that there are 2 arguments
885 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
886 // SAFETY: - INTERFACE requires that args[0] contains a uint
887 let arg0 = unsafe { WlPointerAxis(args[0].u) };
888 // SAFETY: - INTERFACE requires that args[1] contains a uint
889 let arg1 = unsafe { WlPointerAxisRelativeDirection(args[1].u) };
890 self.0.axis_relative_direction(slf, arg0, arg1);
891 }
892 _ => {
893 invalid_opcode("wl_pointer", opcode);
894 }
895 }
896 }861 unsafe fn handle_event(
862 &self,
863 queue: &Queue,
864 slf: &UntypedBorrowedProxy,
865 opcode: u32,
866 args: *mut wl_argument,
867 ) {
868 // SAFETY: This function required that slf has the interface INTERFACE
869 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<ZwpTabletToolV2Ref>(slf) };
870 match opcode {
871 0 => {
872 // SAFETY: INTERFACE requires that there are 1 arguments
873 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
874 // SAFETY: - INTERFACE requires that args[0] contains a uint
875 let arg0 = unsafe { ZwpTabletToolV2Type(args[0].u) };
876 self.0.r#type(slf, arg0);
877 }
878 1 => {
879 // SAFETY: INTERFACE requires that there are 2 arguments
880 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
881 // SAFETY: - INTERFACE requires that args[0] contains a uint
882 let arg0 = unsafe { args[0].u };
883 // SAFETY: - INTERFACE requires that args[1] contains a uint
884 let arg1 = unsafe { args[1].u };
885 self.0.hardware_serial(slf, arg0, arg1);
886 }
887 2 => {
888 // SAFETY: INTERFACE requires that there are 2 arguments
889 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
890 // SAFETY: - INTERFACE requires that args[0] contains a uint
891 let arg0 = unsafe { args[0].u };
892 // SAFETY: - INTERFACE requires that args[1] contains a uint
893 let arg1 = unsafe { args[1].u };
894 self.0.hardware_id_wacom(slf, arg0, arg1);
895 }
896 3 => {
897 // SAFETY: INTERFACE requires that there are 1 arguments
898 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
899 // SAFETY: - INTERFACE requires that args[0] contains a uint
900 let arg0 = unsafe { ZwpTabletToolV2Capability(args[0].u) };
901 self.0.capability(slf, arg0);
902 }
903 4 => {
904 self.0.done(slf);
905 }
906 5 => {
907 self.0.removed(slf);
908 }
909 6 => {
910 // SAFETY: INTERFACE requires that there are 3 arguments
911 let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
912 // SAFETY: - INTERFACE requires that args[0] contains a uint
913 let arg0 = unsafe { args[0].u };
914 // SAFETY: - INTERFACE requires that args[1] contains an object
915 let arg1 = unsafe {
916 if let Some(p) = NonNull::new(args[1].o.cast()) {
917 Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
918 } else {
919 None
920 }
921 };
922 // SAFETY: - INTERFACE requires that the object has the interface ZwpTabletV2::WL_INTERFACE
923 let arg1 = arg1.as_ref().map(|arg1| unsafe {
924 proxy::low_level::from_untyped_borrowed::<ZwpTabletV2Ref>(arg1)
925 });
926 // SAFETY: - INTERFACE requires that args[2] contains an object
927 let arg2 = unsafe {
928 if let Some(p) = NonNull::new(args[2].o.cast()) {
929 Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
930 } else {
931 None
932 }
933 };
934 // SAFETY: - INTERFACE requires that the object has the interface WlSurface::WL_INTERFACE
935 let arg2 = arg2.as_ref().map(|arg2| unsafe {
936 proxy::low_level::from_untyped_borrowed::<WlSurfaceRef>(arg2)
937 });
938 self.0.proximity_in(slf, arg0, arg1, arg2);
939 }
940 7 => {
941 self.0.proximity_out(slf);
942 }
943 8 => {
944 // SAFETY: INTERFACE requires that there are 1 arguments
945 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
946 // SAFETY: - INTERFACE requires that args[0] contains a uint
947 let arg0 = unsafe { args[0].u };
948 self.0.down(slf, arg0);
949 }
950 9 => {
951 self.0.up(slf);
952 }
953 10 => {
954 // SAFETY: INTERFACE requires that there are 2 arguments
955 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
956 // SAFETY: - INTERFACE requires that args[0] contains a fixed
957 let arg0 = unsafe { Fixed::from_wire(args[0].f) };
958 // SAFETY: - INTERFACE requires that args[1] contains a fixed
959 let arg1 = unsafe { Fixed::from_wire(args[1].f) };
960 self.0.motion(slf, arg0, arg1);
961 }
962 11 => {
963 // SAFETY: INTERFACE requires that there are 1 arguments
964 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
965 // SAFETY: - INTERFACE requires that args[0] contains a uint
966 let arg0 = unsafe { args[0].u };
967 self.0.pressure(slf, arg0);
968 }
969 12 => {
970 // SAFETY: INTERFACE requires that there are 1 arguments
971 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
972 // SAFETY: - INTERFACE requires that args[0] contains a uint
973 let arg0 = unsafe { args[0].u };
974 self.0.distance(slf, arg0);
975 }
976 13 => {
977 // SAFETY: INTERFACE requires that there are 2 arguments
978 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
979 // SAFETY: - INTERFACE requires that args[0] contains a fixed
980 let arg0 = unsafe { Fixed::from_wire(args[0].f) };
981 // SAFETY: - INTERFACE requires that args[1] contains a fixed
982 let arg1 = unsafe { Fixed::from_wire(args[1].f) };
983 self.0.tilt(slf, arg0, arg1);
984 }
985 14 => {
986 // SAFETY: INTERFACE requires that there are 1 arguments
987 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
988 // SAFETY: - INTERFACE requires that args[0] contains a fixed
989 let arg0 = unsafe { Fixed::from_wire(args[0].f) };
990 self.0.rotation(slf, arg0);
991 }
992 15 => {
993 // SAFETY: INTERFACE requires that there are 1 arguments
994 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
995 // SAFETY: - INTERFACE requires that args[0] contains an int
996 let arg0 = unsafe { args[0].i };
997 self.0.slider(slf, arg0);
998 }
999 16 => {
1000 // SAFETY: INTERFACE requires that there are 2 arguments
1001 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
1002 // SAFETY: - INTERFACE requires that args[0] contains a fixed
1003 let arg0 = unsafe { Fixed::from_wire(args[0].f) };
1004 // SAFETY: - INTERFACE requires that args[1] contains an int
1005 let arg1 = unsafe { args[1].i };
1006 self.0.wheel(slf, arg0, arg1);
1007 }
1008 17 => {
1009 // SAFETY: INTERFACE requires that there are 3 arguments
1010 let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
1011 // SAFETY: - INTERFACE requires that args[0] contains a uint
1012 let arg0 = unsafe { args[0].u };
1013 // SAFETY: - INTERFACE requires that args[1] contains a uint
1014 let arg1 = unsafe { args[1].u };
1015 // SAFETY: - INTERFACE requires that args[2] contains a uint
1016 let arg2 = unsafe { ZwpTabletToolV2ButtonState(args[2].u) };
1017 self.0.button(slf, arg0, arg1, arg2);
1018 }
1019 18 => {
1020 // SAFETY: INTERFACE requires that there are 1 arguments
1021 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
1022 // SAFETY: - INTERFACE requires that args[0] contains a uint
1023 let arg0 = unsafe { args[0].u };
1024 self.0.frame(slf, arg0);
1025 }
1026 _ => {
1027 invalid_opcode("zwp_tablet_tool_v2", opcode);
1028 }
1029 }
1030 }Sourcepub const fn to_wire(self) -> i32
pub const fn to_wire(self) -> i32
Converts this Fixed to the bits that should be set in the wire protocol.
Examples found in repository?
228 pub fn set_source(&self, x: Fixed, y: Fixed, width: Fixed, height: Fixed) {
229 let (arg0, arg1, arg2, arg3) = (x, y, width, height);
230 let mut args = [
231 wl_argument { f: arg0.to_wire() },
232 wl_argument { f: arg1.to_wire() },
233 wl_argument { f: arg2.to_wire() },
234 wl_argument { f: arg3.to_wire() },
235 ];
236 // SAFETY: - self.proxy has the interface INTERFACE
237 // - 1 < INTERFACE.method_count = 3
238 // - the request signature is `ffff`
239 unsafe {
240 self.proxy.send_request(1, &mut args);
241 }
242 }Sourcepub const fn to_f32_lossy(self) -> f32
pub const fn to_f32_lossy(self) -> f32
Sourcepub const fn from_f64_lossy(val: f64) -> Self
pub const fn from_f64_lossy(val: f64) -> Self
Creates a Fixed from an f64.
If the value cannot be represented exactly, the behavior is as when an f64 is cast to an
integer. That is
- Values are rounded towards 0.
NaNreturnsFixed::ZERO.- Values larger than the maximum return
Fixed::MAX. - Values smaller than the minimum return
Fixed::MIN.
Sourcepub const fn from_f32_lossy(val: f32) -> Self
pub const fn from_f32_lossy(val: f32) -> Self
Creates a Fixed from an f32.
The conversion behavior is the same as for Fixed::from_f64_lossy.
Sourcepub const fn from_i32_saturating(val: i32) -> Self
pub const fn from_i32_saturating(val: i32) -> Self
Creates a Fixed from an i32.
Values outside of the representable range are clamped to Fixed::MIN and Fixed::MAX.
Sourcepub const fn from_i64_saturating(val: i64) -> Self
pub const fn from_i64_saturating(val: i64) -> Self
Creates a Fixed from an i64.
Values outside of the representable range are clamped to Fixed::MIN and Fixed::MAX.
Sourcepub const fn to_i32_round_towards_nearest(self) -> i32
pub const fn to_i32_round_towards_nearest(self) -> i32
Converts this Fixed to an i32.
The conversion rounds towards the nearest integer and half-way away from 0.
Sourcepub const fn to_i32_round_towards_zero(self) -> i32
pub const fn to_i32_round_towards_zero(self) -> i32
Converts this Fixed to an i32.
The conversion rounds towards zero.
Sourcepub const fn to_i32_floor(self) -> i32
pub const fn to_i32_floor(self) -> i32
Converts this Fixed to an i32.
The conversion rounds towards minus infinity.
Sourcepub const fn to_i32_ceil(self) -> i32
pub const fn to_i32_ceil(self) -> i32
Converts this Fixed to an i32.
The conversion rounds towards infinity.
Trait Implementations§
Source§impl AddAssign for Fixed
impl AddAssign for Fixed
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl BitAndAssign for Fixed
impl BitAndAssign for Fixed
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl BitOrAssign for Fixed
impl BitOrAssign for Fixed
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl BitXorAssign for Fixed
impl BitXorAssign for Fixed
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moreSource§impl DivAssign for Fixed
impl DivAssign for Fixed
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/= operation. Read moreSource§impl MulAssign for Fixed
impl MulAssign for Fixed
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*= operation. Read moreSource§impl Ord for Fixed
impl Ord for Fixed
Source§impl PartialOrd for Fixed
impl PartialOrd for Fixed
Source§impl RemAssign for Fixed
impl RemAssign for Fixed
Source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
%= operation. Read moreSource§impl ShlAssign<&i128> for Fixed
impl ShlAssign<&i128> for Fixed
Source§fn shl_assign(&mut self, rhs: &i128)
fn shl_assign(&mut self, rhs: &i128)
<<= operation. Read moreSource§impl ShlAssign<&i16> for Fixed
impl ShlAssign<&i16> for Fixed
Source§fn shl_assign(&mut self, rhs: &i16)
fn shl_assign(&mut self, rhs: &i16)
<<= operation. Read moreSource§impl ShlAssign<&i32> for Fixed
impl ShlAssign<&i32> for Fixed
Source§fn shl_assign(&mut self, rhs: &i32)
fn shl_assign(&mut self, rhs: &i32)
<<= operation. Read moreSource§impl ShlAssign<&i64> for Fixed
impl ShlAssign<&i64> for Fixed
Source§fn shl_assign(&mut self, rhs: &i64)
fn shl_assign(&mut self, rhs: &i64)
<<= operation. Read moreSource§impl ShlAssign<&i8> for Fixed
impl ShlAssign<&i8> for Fixed
Source§fn shl_assign(&mut self, rhs: &i8)
fn shl_assign(&mut self, rhs: &i8)
<<= operation. Read moreSource§impl ShlAssign<&isize> for Fixed
impl ShlAssign<&isize> for Fixed
Source§fn shl_assign(&mut self, rhs: &isize)
fn shl_assign(&mut self, rhs: &isize)
<<= operation. Read moreSource§impl ShlAssign<&u128> for Fixed
impl ShlAssign<&u128> for Fixed
Source§fn shl_assign(&mut self, rhs: &u128)
fn shl_assign(&mut self, rhs: &u128)
<<= operation. Read moreSource§impl ShlAssign<&u16> for Fixed
impl ShlAssign<&u16> for Fixed
Source§fn shl_assign(&mut self, rhs: &u16)
fn shl_assign(&mut self, rhs: &u16)
<<= operation. Read moreSource§impl ShlAssign<&u32> for Fixed
impl ShlAssign<&u32> for Fixed
Source§fn shl_assign(&mut self, rhs: &u32)
fn shl_assign(&mut self, rhs: &u32)
<<= operation. Read moreSource§impl ShlAssign<&u64> for Fixed
impl ShlAssign<&u64> for Fixed
Source§fn shl_assign(&mut self, rhs: &u64)
fn shl_assign(&mut self, rhs: &u64)
<<= operation. Read moreSource§impl ShlAssign<&u8> for Fixed
impl ShlAssign<&u8> for Fixed
Source§fn shl_assign(&mut self, rhs: &u8)
fn shl_assign(&mut self, rhs: &u8)
<<= operation. Read moreSource§impl ShlAssign<&usize> for Fixed
impl ShlAssign<&usize> for Fixed
Source§fn shl_assign(&mut self, rhs: &usize)
fn shl_assign(&mut self, rhs: &usize)
<<= operation. Read moreSource§impl ShlAssign<i128> for Fixed
impl ShlAssign<i128> for Fixed
Source§fn shl_assign(&mut self, rhs: i128)
fn shl_assign(&mut self, rhs: i128)
<<= operation. Read moreSource§impl ShlAssign<i16> for Fixed
impl ShlAssign<i16> for Fixed
Source§fn shl_assign(&mut self, rhs: i16)
fn shl_assign(&mut self, rhs: i16)
<<= operation. Read moreSource§impl ShlAssign<i32> for Fixed
impl ShlAssign<i32> for Fixed
Source§fn shl_assign(&mut self, rhs: i32)
fn shl_assign(&mut self, rhs: i32)
<<= operation. Read moreSource§impl ShlAssign<i64> for Fixed
impl ShlAssign<i64> for Fixed
Source§fn shl_assign(&mut self, rhs: i64)
fn shl_assign(&mut self, rhs: i64)
<<= operation. Read moreSource§impl ShlAssign<i8> for Fixed
impl ShlAssign<i8> for Fixed
Source§fn shl_assign(&mut self, rhs: i8)
fn shl_assign(&mut self, rhs: i8)
<<= operation. Read moreSource§impl ShlAssign<isize> for Fixed
impl ShlAssign<isize> for Fixed
Source§fn shl_assign(&mut self, rhs: isize)
fn shl_assign(&mut self, rhs: isize)
<<= operation. Read moreSource§impl ShlAssign<u128> for Fixed
impl ShlAssign<u128> for Fixed
Source§fn shl_assign(&mut self, rhs: u128)
fn shl_assign(&mut self, rhs: u128)
<<= operation. Read moreSource§impl ShlAssign<u16> for Fixed
impl ShlAssign<u16> for Fixed
Source§fn shl_assign(&mut self, rhs: u16)
fn shl_assign(&mut self, rhs: u16)
<<= operation. Read moreSource§impl ShlAssign<u32> for Fixed
impl ShlAssign<u32> for Fixed
Source§fn shl_assign(&mut self, rhs: u32)
fn shl_assign(&mut self, rhs: u32)
<<= operation. Read moreSource§impl ShlAssign<u64> for Fixed
impl ShlAssign<u64> for Fixed
Source§fn shl_assign(&mut self, rhs: u64)
fn shl_assign(&mut self, rhs: u64)
<<= operation. Read moreSource§impl ShlAssign<u8> for Fixed
impl ShlAssign<u8> for Fixed
Source§fn shl_assign(&mut self, rhs: u8)
fn shl_assign(&mut self, rhs: u8)
<<= operation. Read moreSource§impl ShlAssign<usize> for Fixed
impl ShlAssign<usize> for Fixed
Source§fn shl_assign(&mut self, rhs: usize)
fn shl_assign(&mut self, rhs: usize)
<<= operation. Read moreSource§impl ShrAssign<&i128> for Fixed
impl ShrAssign<&i128> for Fixed
Source§fn shr_assign(&mut self, rhs: &i128)
fn shr_assign(&mut self, rhs: &i128)
>>= operation. Read moreSource§impl ShrAssign<&i16> for Fixed
impl ShrAssign<&i16> for Fixed
Source§fn shr_assign(&mut self, rhs: &i16)
fn shr_assign(&mut self, rhs: &i16)
>>= operation. Read moreSource§impl ShrAssign<&i32> for Fixed
impl ShrAssign<&i32> for Fixed
Source§fn shr_assign(&mut self, rhs: &i32)
fn shr_assign(&mut self, rhs: &i32)
>>= operation. Read moreSource§impl ShrAssign<&i64> for Fixed
impl ShrAssign<&i64> for Fixed
Source§fn shr_assign(&mut self, rhs: &i64)
fn shr_assign(&mut self, rhs: &i64)
>>= operation. Read moreSource§impl ShrAssign<&i8> for Fixed
impl ShrAssign<&i8> for Fixed
Source§fn shr_assign(&mut self, rhs: &i8)
fn shr_assign(&mut self, rhs: &i8)
>>= operation. Read moreSource§impl ShrAssign<&isize> for Fixed
impl ShrAssign<&isize> for Fixed
Source§fn shr_assign(&mut self, rhs: &isize)
fn shr_assign(&mut self, rhs: &isize)
>>= operation. Read moreSource§impl ShrAssign<&u128> for Fixed
impl ShrAssign<&u128> for Fixed
Source§fn shr_assign(&mut self, rhs: &u128)
fn shr_assign(&mut self, rhs: &u128)
>>= operation. Read moreSource§impl ShrAssign<&u16> for Fixed
impl ShrAssign<&u16> for Fixed
Source§fn shr_assign(&mut self, rhs: &u16)
fn shr_assign(&mut self, rhs: &u16)
>>= operation. Read moreSource§impl ShrAssign<&u32> for Fixed
impl ShrAssign<&u32> for Fixed
Source§fn shr_assign(&mut self, rhs: &u32)
fn shr_assign(&mut self, rhs: &u32)
>>= operation. Read moreSource§impl ShrAssign<&u64> for Fixed
impl ShrAssign<&u64> for Fixed
Source§fn shr_assign(&mut self, rhs: &u64)
fn shr_assign(&mut self, rhs: &u64)
>>= operation. Read moreSource§impl ShrAssign<&u8> for Fixed
impl ShrAssign<&u8> for Fixed
Source§fn shr_assign(&mut self, rhs: &u8)
fn shr_assign(&mut self, rhs: &u8)
>>= operation. Read moreSource§impl ShrAssign<&usize> for Fixed
impl ShrAssign<&usize> for Fixed
Source§fn shr_assign(&mut self, rhs: &usize)
fn shr_assign(&mut self, rhs: &usize)
>>= operation. Read moreSource§impl ShrAssign<i128> for Fixed
impl ShrAssign<i128> for Fixed
Source§fn shr_assign(&mut self, rhs: i128)
fn shr_assign(&mut self, rhs: i128)
>>= operation. Read moreSource§impl ShrAssign<i16> for Fixed
impl ShrAssign<i16> for Fixed
Source§fn shr_assign(&mut self, rhs: i16)
fn shr_assign(&mut self, rhs: i16)
>>= operation. Read moreSource§impl ShrAssign<i32> for Fixed
impl ShrAssign<i32> for Fixed
Source§fn shr_assign(&mut self, rhs: i32)
fn shr_assign(&mut self, rhs: i32)
>>= operation. Read moreSource§impl ShrAssign<i64> for Fixed
impl ShrAssign<i64> for Fixed
Source§fn shr_assign(&mut self, rhs: i64)
fn shr_assign(&mut self, rhs: i64)
>>= operation. Read moreSource§impl ShrAssign<i8> for Fixed
impl ShrAssign<i8> for Fixed
Source§fn shr_assign(&mut self, rhs: i8)
fn shr_assign(&mut self, rhs: i8)
>>= operation. Read moreSource§impl ShrAssign<isize> for Fixed
impl ShrAssign<isize> for Fixed
Source§fn shr_assign(&mut self, rhs: isize)
fn shr_assign(&mut self, rhs: isize)
>>= operation. Read moreSource§impl ShrAssign<u128> for Fixed
impl ShrAssign<u128> for Fixed
Source§fn shr_assign(&mut self, rhs: u128)
fn shr_assign(&mut self, rhs: u128)
>>= operation. Read moreSource§impl ShrAssign<u16> for Fixed
impl ShrAssign<u16> for Fixed
Source§fn shr_assign(&mut self, rhs: u16)
fn shr_assign(&mut self, rhs: u16)
>>= operation. Read moreSource§impl ShrAssign<u32> for Fixed
impl ShrAssign<u32> for Fixed
Source§fn shr_assign(&mut self, rhs: u32)
fn shr_assign(&mut self, rhs: u32)
>>= operation. Read moreSource§impl ShrAssign<u64> for Fixed
impl ShrAssign<u64> for Fixed
Source§fn shr_assign(&mut self, rhs: u64)
fn shr_assign(&mut self, rhs: u64)
>>= operation. Read moreSource§impl ShrAssign<u8> for Fixed
impl ShrAssign<u8> for Fixed
Source§fn shr_assign(&mut self, rhs: u8)
fn shr_assign(&mut self, rhs: u8)
>>= operation. Read moreSource§impl ShrAssign<usize> for Fixed
impl ShrAssign<usize> for Fixed
Source§fn shr_assign(&mut self, rhs: usize)
fn shr_assign(&mut self, rhs: usize)
>>= operation. Read moreSource§impl SubAssign for Fixed
impl SubAssign for Fixed
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read more