objc2_virtualization/generated/VZGraphicsDisplay.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13 /// Class representing a graphics display in a virtual machine.
14 ///
15 /// VZGraphicsDisplay should not be instantiated directly.
16 ///
17 /// Graphics displays are first configured on a VZGraphicsDeviceConfiguration subclass.
18 /// When a VZVirtualMachine is created from the configuration, the displays
19 /// are available through the VZGraphicsDevice's `displays` property.
20 ///
21 ///
22 /// See: VZMacGraphicsDisplayConfiguration
23 ///
24 /// See: VZVirtioGraphicsScanoutConfiguration
25 ///
26 /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzgraphicsdisplay?language=objc)
27 #[unsafe(super(NSObject))]
28 #[derive(Debug, PartialEq, Eq, Hash)]
29 pub struct VZGraphicsDisplay;
30);
31
32unsafe impl NSObjectProtocol for VZGraphicsDisplay {}
33
34impl VZGraphicsDisplay {
35 extern_methods!(
36 #[unsafe(method(new))]
37 #[unsafe(method_family = new)]
38 pub unsafe fn new() -> Retained<Self>;
39
40 #[unsafe(method(init))]
41 #[unsafe(method_family = init)]
42 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
43
44 #[cfg(feature = "objc2-core-foundation")]
45 /// The size of the display, in pixels.
46 #[unsafe(method(sizeInPixels))]
47 #[unsafe(method_family = none)]
48 pub unsafe fn sizeInPixels(&self) -> CGSize;
49
50 #[cfg(feature = "objc2-core-foundation")]
51 /// Resize this display.
52 ///
53 /// Parameter `sizeInPixels`: New display width and height in pixels.
54 ///
55 /// Parameter `error`: If not nil, assigned with an error describing why the new size is not valid.
56 ///
57 /// Returns: YES if the resize is successful, NO otherwise.
58 ///
59 /// If successful, the new size will be passed to the guest but the guest may or may
60 /// not respond to the new size. The guest not using the size does not return an error.
61 ///
62 /// Reconfiguration triggers a display state change which can be tracked by VZGraphicsDisplayObservers.
63 #[unsafe(method(reconfigureWithSizeInPixels:error:_))]
64 #[unsafe(method_family = none)]
65 pub unsafe fn reconfigureWithSizeInPixels_error(
66 &self,
67 size_in_pixels: CGSize,
68 ) -> Result<(), Retained<NSError>>;
69
70 #[cfg(feature = "VZGraphicsDisplayConfiguration")]
71 /// Reconfigure this display.
72 ///
73 /// Parameter `configuration`: New display configuration.
74 ///
75 /// Parameter `error`: If not nil, assigned with an error describing why the new configuration is not valid.
76 ///
77 /// Returns: YES if the reconfiguration is successful, NO otherwise.
78 ///
79 /// The type of the configuration must match the corresponding type that caused this display to be created.
80 ///
81 /// If successful, the new configuration will be passed to the guest but the guest may or may
82 /// not respond to parts of the configuration. The guest not using the new configuration does not
83 /// return an error.
84 ///
85 /// Reconfiguration triggers a display state change which can be tracked by VZGraphicsDisplayObservers.
86 #[unsafe(method(reconfigureWithConfiguration:error:_))]
87 #[unsafe(method_family = none)]
88 pub unsafe fn reconfigureWithConfiguration_error(
89 &self,
90 configuration: &VZGraphicsDisplayConfiguration,
91 ) -> Result<(), Retained<NSError>>;
92
93 /// Add an observer.
94 ///
95 /// Parameter `observer`: The new observer to be notified of display state changes.
96 #[unsafe(method(addObserver:))]
97 #[unsafe(method_family = none)]
98 pub unsafe fn addObserver(&self, observer: &ProtocolObject<dyn VZGraphicsDisplayObserver>);
99
100 /// Remove an observer.
101 ///
102 /// Parameter `observer`: The observer to be removed.
103 #[unsafe(method(removeObserver:))]
104 #[unsafe(method_family = none)]
105 pub unsafe fn removeObserver(
106 &self,
107 observer: &ProtocolObject<dyn VZGraphicsDisplayObserver>,
108 );
109 );
110}
111
112extern_protocol!(
113 /// VZGraphicsDisplayObserver observes a VZGraphicsDisplay for state changes.
114 ///
115 /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzgraphicsdisplayobserver?language=objc)
116 pub unsafe trait VZGraphicsDisplayObserver: NSObjectProtocol {
117 /// A reconfiguration operation has begun.
118 ///
119 /// A configuration change, such as a resize, has been issued and new frames are expected with a new size or configuration.
120 /// This method will be invoked on the virtual machine's queue.
121 ///
122 /// Parameter `display`: The display whose state is changing.
123 #[optional]
124 #[unsafe(method(displayDidBeginReconfiguration:))]
125 #[unsafe(method_family = none)]
126 unsafe fn displayDidBeginReconfiguration(&self, display: &VZGraphicsDisplay);
127
128 /// A reconfiguration operation has ended.
129 ///
130 /// Frame updates have arrived at the most recently requested display size and configuration.
131 /// This method will be invoked on the virtual machine's queue.
132 ///
133 /// Parameter `display`: The display whose state is changing.
134 #[optional]
135 #[unsafe(method(displayDidEndReconfiguration:))]
136 #[unsafe(method_family = none)]
137 unsafe fn displayDidEndReconfiguration(&self, display: &VZGraphicsDisplay);
138 }
139);