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/simple-window/../common/simple_window.rs (line 160)
153 fn global_remove(&self, _slf: &WlRegistryRef, name: u32) {
154 let seats = &mut *self.seats.borrow_mut();
155 let Some(seat) = seats.remove(&name) else {
156 return;
157 };
158 let data = &mut *seat.borrow_mut();
159 data.destroy_pointer();
160 if proxy::version(&*data.seat) >= WlSeat::REQ__RELEASE__SINCE {
161 data.seat.release();
162 } else {
163 proxy::destroy(&data.seat);
164 }
165 }
166}
167
168struct SeatEventHandler {
169 wp_cursor_shape_manager_v1: WpCursorShapeManagerV1,
170 data: Rc<RefCell<SeatData>>,
171}
172
173struct SeatData {
174 seat: WlSeat,
175 pointer: Option<WlPointer>,
176 shape: Option<WpCursorShapeDeviceV1>,
177}
178
179impl SeatData {
180 fn destroy_pointer(&mut self) {
181 if let Some(shape) = self.shape.take() {
182 shape.destroy();
183 }
184 if let Some(pointer) = self.pointer.take() {
185 if proxy::version(&*pointer) >= WlPointer::REQ__RELEASE__SINCE {
186 pointer.release();
187 } else {
188 proxy::destroy(&pointer);
189 }
190 }
191 }More examples
examples/keyboard-events/main.rs (line 76)
73 fn global_remove(&self, _slf: &WlRegistryRef, name: u32) {
74 if let Some(seat) = self.seats.borrow_mut().remove(&name) {
75 if let Some(kb) = seat.wl_keyboard.take() {
76 if proxy::version(&*kb) >= WlKeyboard::REQ__RELEASE__SINCE {
77 kb.release();
78 } else {
79 proxy::destroy(&kb);
80 }
81 }
82 if proxy::version(&*seat.wl_seat) >= WlSeat::REQ__RELEASE__SINCE {
83 seat.wl_seat.release();
84 } else {
85 proxy::destroy(&seat.wl_seat);
86 }
87 }
88 }
89}
90
91impl WlSeatEventHandler for SeatEventHandler {
92 fn capabilities(&self, _slf: &WlSeatRef, capabilities: WlSeatCapability) {
93 let kb = &mut *self.0.wl_keyboard.borrow_mut();
94 if capabilities.contains(WlSeatCapability::KEYBOARD) {
95 if kb.is_none() {
96 let wl_keyboard = self.0.wl_seat.get_keyboard();
97 proxy::set_event_handler_local(&wl_keyboard, self.clone());
98 *kb = Some(wl_keyboard);
99 }
100 } else {
101 if let Some(kb) = kb.take() {
102 if proxy::version(&*kb) >= WlKeyboard::REQ__RELEASE__SINCE {
103 kb.release();
104 } else {
105 proxy::destroy(&kb);
106 }
107 }
108 }
109 }