1 // This file was generated by gir (https://github.com/gtk-rs/gir) 2 // from gir-files (https://github.com/gtk-rs/gir-files) 3 // DO NOT EDIT 4 5 use gdk_sys; 6 use glib::object::IsA; 7 use glib::object::ObjectType as ObjectType_; 8 use glib::signal::connect_raw; 9 use glib::signal::SignalHandlerId; 10 use glib::translate::*; 11 use glib::GString; 12 use glib_sys; 13 use std::boxed::Box as Box_; 14 use std::fmt; 15 use std::mem; 16 use std::mem::transmute; 17 use AppLaunchContext; 18 use Atom; 19 use Device; 20 use DeviceManager; 21 use Event; 22 #[cfg(any(feature = "v3_22", feature = "dox"))] 23 use Monitor; 24 use Screen; 25 #[cfg(any(feature = "v3_20", feature = "dox"))] 26 use Seat; 27 use Window; 28 29 glib_wrapper! { 30 pub struct Display(Object<gdk_sys::GdkDisplay, DisplayClass>); 31 32 match fn { 33 get_type => || gdk_sys::gdk_display_get_type(), 34 } 35 } 36 37 impl Display { beep(&self)38 pub fn beep(&self) { 39 unsafe { 40 gdk_sys::gdk_display_beep(self.to_glib_none().0); 41 } 42 } 43 close(&self)44 pub fn close(&self) { 45 unsafe { 46 gdk_sys::gdk_display_close(self.to_glib_none().0); 47 } 48 } 49 device_is_grabbed(&self, device: &Device) -> bool50 pub fn device_is_grabbed(&self, device: &Device) -> bool { 51 unsafe { 52 from_glib(gdk_sys::gdk_display_device_is_grabbed( 53 self.to_glib_none().0, 54 device.to_glib_none().0, 55 )) 56 } 57 } 58 flush(&self)59 pub fn flush(&self) { 60 unsafe { 61 gdk_sys::gdk_display_flush(self.to_glib_none().0); 62 } 63 } 64 get_app_launch_context(&self) -> Option<AppLaunchContext>65 pub fn get_app_launch_context(&self) -> Option<AppLaunchContext> { 66 unsafe { 67 from_glib_full(gdk_sys::gdk_display_get_app_launch_context( 68 self.to_glib_none().0, 69 )) 70 } 71 } 72 get_default_cursor_size(&self) -> u3273 pub fn get_default_cursor_size(&self) -> u32 { 74 unsafe { gdk_sys::gdk_display_get_default_cursor_size(self.to_glib_none().0) } 75 } 76 get_default_group(&self) -> Window77 pub fn get_default_group(&self) -> Window { 78 unsafe { 79 from_glib_none(gdk_sys::gdk_display_get_default_group( 80 self.to_glib_none().0, 81 )) 82 } 83 } 84 get_default_screen(&self) -> Screen85 pub fn get_default_screen(&self) -> Screen { 86 unsafe { 87 from_glib_none(gdk_sys::gdk_display_get_default_screen( 88 self.to_glib_none().0, 89 )) 90 } 91 } 92 93 #[cfg(any(feature = "v3_20", feature = "dox"))] get_default_seat(&self) -> Option<Seat>94 pub fn get_default_seat(&self) -> Option<Seat> { 95 unsafe { from_glib_none(gdk_sys::gdk_display_get_default_seat(self.to_glib_none().0)) } 96 } 97 98 #[cfg_attr(feature = "v3_20", deprecated)] get_device_manager(&self) -> Option<DeviceManager>99 pub fn get_device_manager(&self) -> Option<DeviceManager> { 100 unsafe { 101 from_glib_none(gdk_sys::gdk_display_get_device_manager( 102 self.to_glib_none().0, 103 )) 104 } 105 } 106 get_event(&self) -> Option<Event>107 pub fn get_event(&self) -> Option<Event> { 108 unsafe { from_glib_full(gdk_sys::gdk_display_get_event(self.to_glib_none().0)) } 109 } 110 get_maximal_cursor_size(&self) -> (u32, u32)111 pub fn get_maximal_cursor_size(&self) -> (u32, u32) { 112 unsafe { 113 let mut width = mem::MaybeUninit::uninit(); 114 let mut height = mem::MaybeUninit::uninit(); 115 gdk_sys::gdk_display_get_maximal_cursor_size( 116 self.to_glib_none().0, 117 width.as_mut_ptr(), 118 height.as_mut_ptr(), 119 ); 120 let width = width.assume_init(); 121 let height = height.assume_init(); 122 (width, height) 123 } 124 } 125 126 #[cfg(any(feature = "v3_22", feature = "dox"))] get_monitor(&self, monitor_num: i32) -> Option<Monitor>127 pub fn get_monitor(&self, monitor_num: i32) -> Option<Monitor> { 128 unsafe { 129 from_glib_none(gdk_sys::gdk_display_get_monitor( 130 self.to_glib_none().0, 131 monitor_num, 132 )) 133 } 134 } 135 136 #[cfg(any(feature = "v3_22", feature = "dox"))] get_monitor_at_point(&self, x: i32, y: i32) -> Option<Monitor>137 pub fn get_monitor_at_point(&self, x: i32, y: i32) -> Option<Monitor> { 138 unsafe { 139 from_glib_none(gdk_sys::gdk_display_get_monitor_at_point( 140 self.to_glib_none().0, 141 x, 142 y, 143 )) 144 } 145 } 146 147 #[cfg(any(feature = "v3_22", feature = "dox"))] get_monitor_at_window<P: IsA<Window>>(&self, window: &P) -> Option<Monitor>148 pub fn get_monitor_at_window<P: IsA<Window>>(&self, window: &P) -> Option<Monitor> { 149 unsafe { 150 from_glib_none(gdk_sys::gdk_display_get_monitor_at_window( 151 self.to_glib_none().0, 152 window.as_ref().to_glib_none().0, 153 )) 154 } 155 } 156 157 #[cfg(any(feature = "v3_22", feature = "dox"))] get_n_monitors(&self) -> i32158 pub fn get_n_monitors(&self) -> i32 { 159 unsafe { gdk_sys::gdk_display_get_n_monitors(self.to_glib_none().0) } 160 } 161 get_name(&self) -> GString162 pub fn get_name(&self) -> GString { 163 unsafe { from_glib_none(gdk_sys::gdk_display_get_name(self.to_glib_none().0)) } 164 } 165 166 #[cfg(any(feature = "v3_22", feature = "dox"))] get_primary_monitor(&self) -> Option<Monitor>167 pub fn get_primary_monitor(&self) -> Option<Monitor> { 168 unsafe { 169 from_glib_none(gdk_sys::gdk_display_get_primary_monitor( 170 self.to_glib_none().0, 171 )) 172 } 173 } 174 175 #[cfg_attr(feature = "v3_20", deprecated)] get_screen(&self, screen_num: i32) -> Screen176 pub fn get_screen(&self, screen_num: i32) -> Screen { 177 unsafe { 178 from_glib_none(gdk_sys::gdk_display_get_screen( 179 self.to_glib_none().0, 180 screen_num, 181 )) 182 } 183 } 184 has_pending(&self) -> bool185 pub fn has_pending(&self) -> bool { 186 unsafe { from_glib(gdk_sys::gdk_display_has_pending(self.to_glib_none().0)) } 187 } 188 is_closed(&self) -> bool189 pub fn is_closed(&self) -> bool { 190 unsafe { from_glib(gdk_sys::gdk_display_is_closed(self.to_glib_none().0)) } 191 } 192 193 #[cfg(any(feature = "v3_20", feature = "dox"))] list_seats(&self) -> Vec<Seat>194 pub fn list_seats(&self) -> Vec<Seat> { 195 unsafe { 196 FromGlibPtrContainer::from_glib_container(gdk_sys::gdk_display_list_seats( 197 self.to_glib_none().0, 198 )) 199 } 200 } 201 notify_startup_complete(&self, startup_id: &str)202 pub fn notify_startup_complete(&self, startup_id: &str) { 203 unsafe { 204 gdk_sys::gdk_display_notify_startup_complete( 205 self.to_glib_none().0, 206 startup_id.to_glib_none().0, 207 ); 208 } 209 } 210 peek_event(&self) -> Option<Event>211 pub fn peek_event(&self) -> Option<Event> { 212 unsafe { from_glib_full(gdk_sys::gdk_display_peek_event(self.to_glib_none().0)) } 213 } 214 put_event(&self, event: &Event)215 pub fn put_event(&self, event: &Event) { 216 unsafe { 217 gdk_sys::gdk_display_put_event(self.to_glib_none().0, event.to_glib_none().0); 218 } 219 } 220 request_selection_notification(&self, selection: &Atom) -> bool221 pub fn request_selection_notification(&self, selection: &Atom) -> bool { 222 unsafe { 223 from_glib(gdk_sys::gdk_display_request_selection_notification( 224 self.to_glib_none().0, 225 selection.to_glib_none().0, 226 )) 227 } 228 } 229 set_double_click_distance(&self, distance: u32)230 pub fn set_double_click_distance(&self, distance: u32) { 231 unsafe { 232 gdk_sys::gdk_display_set_double_click_distance(self.to_glib_none().0, distance); 233 } 234 } 235 set_double_click_time(&self, msec: u32)236 pub fn set_double_click_time(&self, msec: u32) { 237 unsafe { 238 gdk_sys::gdk_display_set_double_click_time(self.to_glib_none().0, msec); 239 } 240 } 241 store_clipboard<P: IsA<Window>>( &self, clipboard_window: &P, time_: u32, targets: &[&Atom], )242 pub fn store_clipboard<P: IsA<Window>>( 243 &self, 244 clipboard_window: &P, 245 time_: u32, 246 targets: &[&Atom], 247 ) { 248 let n_targets = targets.len() as i32; 249 unsafe { 250 gdk_sys::gdk_display_store_clipboard( 251 self.to_glib_none().0, 252 clipboard_window.as_ref().to_glib_none().0, 253 time_, 254 targets.to_glib_none().0, 255 n_targets, 256 ); 257 } 258 } 259 supports_clipboard_persistence(&self) -> bool260 pub fn supports_clipboard_persistence(&self) -> bool { 261 unsafe { 262 from_glib(gdk_sys::gdk_display_supports_clipboard_persistence( 263 self.to_glib_none().0, 264 )) 265 } 266 } 267 268 #[cfg_attr(feature = "v3_16", deprecated)] supports_composite(&self) -> bool269 pub fn supports_composite(&self) -> bool { 270 unsafe { 271 from_glib(gdk_sys::gdk_display_supports_composite( 272 self.to_glib_none().0, 273 )) 274 } 275 } 276 supports_cursor_alpha(&self) -> bool277 pub fn supports_cursor_alpha(&self) -> bool { 278 unsafe { 279 from_glib(gdk_sys::gdk_display_supports_cursor_alpha( 280 self.to_glib_none().0, 281 )) 282 } 283 } 284 supports_cursor_color(&self) -> bool285 pub fn supports_cursor_color(&self) -> bool { 286 unsafe { 287 from_glib(gdk_sys::gdk_display_supports_cursor_color( 288 self.to_glib_none().0, 289 )) 290 } 291 } 292 supports_input_shapes(&self) -> bool293 pub fn supports_input_shapes(&self) -> bool { 294 unsafe { 295 from_glib(gdk_sys::gdk_display_supports_input_shapes( 296 self.to_glib_none().0, 297 )) 298 } 299 } 300 supports_selection_notification(&self) -> bool301 pub fn supports_selection_notification(&self) -> bool { 302 unsafe { 303 from_glib(gdk_sys::gdk_display_supports_selection_notification( 304 self.to_glib_none().0, 305 )) 306 } 307 } 308 supports_shapes(&self) -> bool309 pub fn supports_shapes(&self) -> bool { 310 unsafe { from_glib(gdk_sys::gdk_display_supports_shapes(self.to_glib_none().0)) } 311 } 312 sync(&self)313 pub fn sync(&self) { 314 unsafe { 315 gdk_sys::gdk_display_sync(self.to_glib_none().0); 316 } 317 } 318 get_default() -> Option<Display>319 pub fn get_default() -> Option<Display> { 320 assert_initialized_main_thread!(); 321 unsafe { from_glib_none(gdk_sys::gdk_display_get_default()) } 322 } 323 open(display_name: &str) -> Option<Display>324 pub fn open(display_name: &str) -> Option<Display> { 325 assert_initialized_main_thread!(); 326 unsafe { from_glib_none(gdk_sys::gdk_display_open(display_name.to_glib_none().0)) } 327 } 328 329 #[cfg_attr(feature = "v3_16", deprecated)] open_default_libgtk_only() -> Option<Display>330 pub fn open_default_libgtk_only() -> Option<Display> { 331 assert_initialized_main_thread!(); 332 unsafe { from_glib_none(gdk_sys::gdk_display_open_default_libgtk_only()) } 333 } 334 connect_closed<F: Fn(&Display, bool) + 'static>(&self, f: F) -> SignalHandlerId335 pub fn connect_closed<F: Fn(&Display, bool) + 'static>(&self, f: F) -> SignalHandlerId { 336 unsafe extern "C" fn closed_trampoline<F: Fn(&Display, bool) + 'static>( 337 this: *mut gdk_sys::GdkDisplay, 338 is_error: glib_sys::gboolean, 339 f: glib_sys::gpointer, 340 ) { 341 let f: &F = &*(f as *const F); 342 f(&from_glib_borrow(this), from_glib(is_error)) 343 } 344 unsafe { 345 let f: Box_<F> = Box_::new(f); 346 connect_raw( 347 self.as_ptr() as *mut _, 348 b"closed\0".as_ptr() as *const _, 349 Some(transmute(closed_trampoline::<F> as usize)), 350 Box_::into_raw(f), 351 ) 352 } 353 } 354 355 #[cfg(any(feature = "v3_22", feature = "dox"))] connect_monitor_added<F: Fn(&Display, &Monitor) + 'static>( &self, f: F, ) -> SignalHandlerId356 pub fn connect_monitor_added<F: Fn(&Display, &Monitor) + 'static>( 357 &self, 358 f: F, 359 ) -> SignalHandlerId { 360 unsafe extern "C" fn monitor_added_trampoline<F: Fn(&Display, &Monitor) + 'static>( 361 this: *mut gdk_sys::GdkDisplay, 362 monitor: *mut gdk_sys::GdkMonitor, 363 f: glib_sys::gpointer, 364 ) { 365 let f: &F = &*(f as *const F); 366 f(&from_glib_borrow(this), &from_glib_borrow(monitor)) 367 } 368 unsafe { 369 let f: Box_<F> = Box_::new(f); 370 connect_raw( 371 self.as_ptr() as *mut _, 372 b"monitor-added\0".as_ptr() as *const _, 373 Some(transmute(monitor_added_trampoline::<F> as usize)), 374 Box_::into_raw(f), 375 ) 376 } 377 } 378 379 #[cfg(any(feature = "v3_22", feature = "dox"))] connect_monitor_removed<F: Fn(&Display, &Monitor) + 'static>( &self, f: F, ) -> SignalHandlerId380 pub fn connect_monitor_removed<F: Fn(&Display, &Monitor) + 'static>( 381 &self, 382 f: F, 383 ) -> SignalHandlerId { 384 unsafe extern "C" fn monitor_removed_trampoline<F: Fn(&Display, &Monitor) + 'static>( 385 this: *mut gdk_sys::GdkDisplay, 386 monitor: *mut gdk_sys::GdkMonitor, 387 f: glib_sys::gpointer, 388 ) { 389 let f: &F = &*(f as *const F); 390 f(&from_glib_borrow(this), &from_glib_borrow(monitor)) 391 } 392 unsafe { 393 let f: Box_<F> = Box_::new(f); 394 connect_raw( 395 self.as_ptr() as *mut _, 396 b"monitor-removed\0".as_ptr() as *const _, 397 Some(transmute(monitor_removed_trampoline::<F> as usize)), 398 Box_::into_raw(f), 399 ) 400 } 401 } 402 connect_opened<F: Fn(&Display) + 'static>(&self, f: F) -> SignalHandlerId403 pub fn connect_opened<F: Fn(&Display) + 'static>(&self, f: F) -> SignalHandlerId { 404 unsafe extern "C" fn opened_trampoline<F: Fn(&Display) + 'static>( 405 this: *mut gdk_sys::GdkDisplay, 406 f: glib_sys::gpointer, 407 ) { 408 let f: &F = &*(f as *const F); 409 f(&from_glib_borrow(this)) 410 } 411 unsafe { 412 let f: Box_<F> = Box_::new(f); 413 connect_raw( 414 self.as_ptr() as *mut _, 415 b"opened\0".as_ptr() as *const _, 416 Some(transmute(opened_trampoline::<F> as usize)), 417 Box_::into_raw(f), 418 ) 419 } 420 } 421 422 #[cfg(any(feature = "v3_20", feature = "dox"))] connect_seat_added<F: Fn(&Display, &Seat) + 'static>(&self, f: F) -> SignalHandlerId423 pub fn connect_seat_added<F: Fn(&Display, &Seat) + 'static>(&self, f: F) -> SignalHandlerId { 424 unsafe extern "C" fn seat_added_trampoline<F: Fn(&Display, &Seat) + 'static>( 425 this: *mut gdk_sys::GdkDisplay, 426 seat: *mut gdk_sys::GdkSeat, 427 f: glib_sys::gpointer, 428 ) { 429 let f: &F = &*(f as *const F); 430 f(&from_glib_borrow(this), &from_glib_borrow(seat)) 431 } 432 unsafe { 433 let f: Box_<F> = Box_::new(f); 434 connect_raw( 435 self.as_ptr() as *mut _, 436 b"seat-added\0".as_ptr() as *const _, 437 Some(transmute(seat_added_trampoline::<F> as usize)), 438 Box_::into_raw(f), 439 ) 440 } 441 } 442 443 #[cfg(any(feature = "v3_20", feature = "dox"))] connect_seat_removed<F: Fn(&Display, &Seat) + 'static>(&self, f: F) -> SignalHandlerId444 pub fn connect_seat_removed<F: Fn(&Display, &Seat) + 'static>(&self, f: F) -> SignalHandlerId { 445 unsafe extern "C" fn seat_removed_trampoline<F: Fn(&Display, &Seat) + 'static>( 446 this: *mut gdk_sys::GdkDisplay, 447 seat: *mut gdk_sys::GdkSeat, 448 f: glib_sys::gpointer, 449 ) { 450 let f: &F = &*(f as *const F); 451 f(&from_glib_borrow(this), &from_glib_borrow(seat)) 452 } 453 unsafe { 454 let f: Box_<F> = Box_::new(f); 455 connect_raw( 456 self.as_ptr() as *mut _, 457 b"seat-removed\0".as_ptr() as *const _, 458 Some(transmute(seat_removed_trampoline::<F> as usize)), 459 Box_::into_raw(f), 460 ) 461 } 462 } 463 } 464 465 impl fmt::Display for Display { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result466 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 467 write!(f, "Display") 468 } 469 } 470