pub fn version(proxy: &impl UntypedBorrowedProxyWrapper) -> u32Expand description
Returns the version of this proxy object.
The version of the display object is always 0.
§Panic
Panics if the proxy is already destroyed.
§Example
let lib = Libwayland::open().unwrap();
let con = lib.connect_to_default_display().unwrap();
let queue = con.create_queue(c"");
let display: WlDisplay = queue.display();
assert_eq!(proxy::version(&*display), 0);Examples found in repository?
examples/get-registry/../common/simple_window.rs (line 164)
157 fn global_remove(&self, _slf: &WlRegistryRef, name: u32) {
158 let seats = &mut *self.seats.borrow_mut();
159 let Some(seat) = seats.remove(&name) else {
160 return;
161 };
162 let data = &mut *seat.borrow_mut();
163 data.destroy_pointer();
164 if proxy::version(&*data.seat) >= WlSeat::REQ__RELEASE__SINCE {
165 data.seat.release();
166 } else {
167 proxy::destroy(&data.seat);
168 }
169 }
170}
171
172struct SeatEventHandler {
173 wp_cursor_shape_manager_v1: WpCursorShapeManagerV1,
174 data: Rc<RefCell<SeatData>>,
175}
176
177struct SeatData {
178 seat: WlSeat,
179 pointer: Option<WlPointer>,
180 shape: Option<WpCursorShapeDeviceV1>,
181}
182
183impl SeatData {
184 fn destroy_pointer(&mut self) {
185 if let Some(shape) = self.shape.take() {
186 shape.destroy();
187 }
188 if let Some(pointer) = self.pointer.take() {
189 if proxy::version(&*pointer) >= WlPointer::REQ__RELEASE__SINCE {
190 pointer.release();
191 } else {
192 proxy::destroy(&pointer);
193 }
194 }
195 }More examples
examples/keyboard-events/main.rs (line 78)
75 fn global_remove(&self, _slf: &WlRegistryRef, name: u32) {
76 if let Some(seat) = self.seats.borrow_mut().remove(&name) {
77 if let Some(kb) = seat.wl_keyboard.take() {
78 if proxy::version(&*kb) >= WlKeyboard::REQ__RELEASE__SINCE {
79 kb.release();
80 } else {
81 proxy::destroy(&kb);
82 }
83 }
84 if proxy::version(&*seat.wl_seat) >= WlSeat::REQ__RELEASE__SINCE {
85 seat.wl_seat.release();
86 } else {
87 proxy::destroy(&seat.wl_seat);
88 }
89 }
90 }
91}
92
93impl WlSeatEventHandler for SeatEventHandler {
94 fn capabilities(&self, _slf: &WlSeatRef, capabilities: WlSeatCapability) {
95 let kb = &mut *self.0.wl_keyboard.borrow_mut();
96 if capabilities.contains(WlSeatCapability::KEYBOARD) {
97 if kb.is_none() {
98 let wl_keyboard = self.0.wl_seat.get_keyboard();
99 proxy::set_event_handler_local(&wl_keyboard, self.clone());
100 *kb = Some(wl_keyboard);
101 }
102 } else {
103 if let Some(kb) = kb.take() {
104 if proxy::version(&*kb) >= WlKeyboard::REQ__RELEASE__SINCE {
105 kb.release();
106 } else {
107 proxy::destroy(&kb);
108 }
109 }
110 }
111 }