1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::AppLaunchContext;
use crate::Atom;
use crate::Device;
use crate::Event;
use crate::Monitor;
use crate::Screen;
use crate::Seat;
use crate::Window;
use glib::object::ObjectType as ObjectType_;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem;
use std::mem::transmute;
glib::wrapper! {
/// [`Display`][crate::Display] objects purpose are two fold:
///
/// - To manage and provide information about input devices (pointers and keyboards)
///
/// - To manage and provide information about the available `GdkScreens`
///
/// GdkDisplay objects are the GDK representation of an X Display,
/// which can be described as a workstation consisting of
/// a keyboard, a pointing device (such as a mouse) and one or more
/// screens.
/// It is used to open and keep track of various GdkScreen objects
/// currently instantiated by the application. It is also used to
/// access the keyboard(s) and mouse pointer(s) of the display.
///
/// Most of the input device handling has been factored out into
/// the separate [`DeviceManager`][crate::DeviceManager] object. Every display has a
/// device manager, which you can obtain using
/// `gdk_display_get_device_manager()`.
///
/// # Implements
///
/// [`DisplayExtManual`][trait@crate::prelude::DisplayExtManual]
#[doc(alias = "GdkDisplay")]
pub struct Display(Object<ffi::GdkDisplay>);
match fn {
type_ => || ffi::gdk_display_get_type(),
}
}
impl Display {
/// Emits a short beep on `self`
#[doc(alias = "gdk_display_beep")]
pub fn beep(&self) {
unsafe {
ffi::gdk_display_beep(self.to_glib_none().0);
}
}
/// Closes the connection to the windowing system for the given display,
/// and cleans up associated resources.
#[doc(alias = "gdk_display_close")]
pub fn close(&self) {
unsafe {
ffi::gdk_display_close(self.to_glib_none().0);
}
}
/// Returns [`true`] if there is an ongoing grab on `device` for `self`.
/// ## `device`
/// a [`Device`][crate::Device]
///
/// # Returns
///
/// [`true`] if there is a grab in effect for `device`.
#[doc(alias = "gdk_display_device_is_grabbed")]
pub fn device_is_grabbed(&self, device: &Device) -> bool {
unsafe {
from_glib(ffi::gdk_display_device_is_grabbed(
self.to_glib_none().0,
device.to_glib_none().0,
))
}
}
/// Flushes any requests queued for the windowing system; this happens automatically
/// when the main loop blocks waiting for new events, but if your application
/// is drawing without returning control to the main loop, you may need
/// to call this function explicitly. A common case where this function
/// needs to be called is when an application is executing drawing commands
/// from a thread other than the thread where the main loop is running.
///
/// This is most useful for X11. On windowing systems where requests are
/// handled synchronously, this function will do nothing.
#[doc(alias = "gdk_display_flush")]
pub fn flush(&self) {
unsafe {
ffi::gdk_display_flush(self.to_glib_none().0);
}
}
/// Returns a [`AppLaunchContext`][crate::AppLaunchContext] suitable for launching
/// applications on the given display.
///
/// # Returns
///
/// a new [`AppLaunchContext`][crate::AppLaunchContext] for `self`.
/// Free with `g_object_unref()` when done
#[doc(alias = "gdk_display_get_app_launch_context")]
#[doc(alias = "get_app_launch_context")]
pub fn app_launch_context(&self) -> Option<AppLaunchContext> {
unsafe {
from_glib_full(ffi::gdk_display_get_app_launch_context(
self.to_glib_none().0,
))
}
}
/// Returns the default size to use for cursors on `self`.
///
/// # Returns
///
/// the default cursor size.
#[doc(alias = "gdk_display_get_default_cursor_size")]
#[doc(alias = "get_default_cursor_size")]
pub fn default_cursor_size(&self) -> u32 {
unsafe { ffi::gdk_display_get_default_cursor_size(self.to_glib_none().0) }
}
/// Returns the default group leader window for all toplevel windows
/// on `self`. This window is implicitly created by GDK.
/// See [`Window::set_group()`][crate::Window::set_group()].
///
/// # Returns
///
/// The default group leader window
/// for `self`
#[doc(alias = "gdk_display_get_default_group")]
#[doc(alias = "get_default_group")]
pub fn default_group(&self) -> Window {
unsafe { from_glib_none(ffi::gdk_display_get_default_group(self.to_glib_none().0)) }
}
/// Get the default [`Screen`][crate::Screen] for `self`.
///
/// # Returns
///
/// the default [`Screen`][crate::Screen] object for `self`
#[doc(alias = "gdk_display_get_default_screen")]
#[doc(alias = "get_default_screen")]
pub fn default_screen(&self) -> Screen {
unsafe { from_glib_none(ffi::gdk_display_get_default_screen(self.to_glib_none().0)) }
}
/// Returns the default [`Seat`][crate::Seat] for this display.
///
/// # Returns
///
/// the default seat.
#[doc(alias = "gdk_display_get_default_seat")]
#[doc(alias = "get_default_seat")]
pub fn default_seat(&self) -> Option<Seat> {
unsafe { from_glib_none(ffi::gdk_display_get_default_seat(self.to_glib_none().0)) }
}
/// Gets the next `GdkEvent` to be processed for `self`, fetching events from the
/// windowing system if necessary.
///
/// # Returns
///
/// the next `GdkEvent` to be processed, or [`None`]
/// if no events are pending. The returned `GdkEvent` should be freed
/// with `gdk_event_free()`.
#[doc(alias = "gdk_display_get_event")]
#[doc(alias = "get_event")]
pub fn event(&self) -> Option<Event> {
unsafe { from_glib_full(ffi::gdk_display_get_event(self.to_glib_none().0)) }
}
/// Gets the maximal size to use for cursors on `self`.
///
/// # Returns
///
///
/// ## `width`
/// the return location for the maximal cursor width
///
/// ## `height`
/// the return location for the maximal cursor height
#[doc(alias = "gdk_display_get_maximal_cursor_size")]
#[doc(alias = "get_maximal_cursor_size")]
pub fn maximal_cursor_size(&self) -> (u32, u32) {
unsafe {
let mut width = mem::MaybeUninit::uninit();
let mut height = mem::MaybeUninit::uninit();
ffi::gdk_display_get_maximal_cursor_size(
self.to_glib_none().0,
width.as_mut_ptr(),
height.as_mut_ptr(),
);
(width.assume_init(), height.assume_init())
}
}
/// Gets a monitor associated with this display.
/// ## `monitor_num`
/// number of the monitor
///
/// # Returns
///
/// the [`Monitor`][crate::Monitor], or [`None`] if
/// `monitor_num` is not a valid monitor number
#[doc(alias = "gdk_display_get_monitor")]
#[doc(alias = "get_monitor")]
pub fn monitor(&self, monitor_num: i32) -> Option<Monitor> {
unsafe {
from_glib_none(ffi::gdk_display_get_monitor(
self.to_glib_none().0,
monitor_num,
))
}
}
/// Gets the monitor in which the point (`x`, `y`) is located,
/// or a nearby monitor if the point is not in any monitor.
/// ## `x`
/// the x coordinate of the point
/// ## `y`
/// the y coordinate of the point
///
/// # Returns
///
/// the monitor containing the point
#[doc(alias = "gdk_display_get_monitor_at_point")]
#[doc(alias = "get_monitor_at_point")]
pub fn monitor_at_point(&self, x: i32, y: i32) -> Option<Monitor> {
unsafe {
from_glib_none(ffi::gdk_display_get_monitor_at_point(
self.to_glib_none().0,
x,
y,
))
}
}
/// Gets the monitor in which the largest area of `window`
/// resides, or a monitor close to `window` if it is outside
/// of all monitors.
/// ## `window`
/// a [`Window`][crate::Window]
///
/// # Returns
///
/// the monitor with the largest overlap with `window`
#[doc(alias = "gdk_display_get_monitor_at_window")]
#[doc(alias = "get_monitor_at_window")]
pub fn monitor_at_window(&self, window: &Window) -> Option<Monitor> {
unsafe {
from_glib_none(ffi::gdk_display_get_monitor_at_window(
self.to_glib_none().0,
window.to_glib_none().0,
))
}
}
/// Gets the number of monitors that belong to `self`.
///
/// The returned number is valid until the next emission of the
/// `signal::Display::monitor-added` or `signal::Display::monitor-removed` signal.
///
/// # Returns
///
/// the number of monitors
#[doc(alias = "gdk_display_get_n_monitors")]
#[doc(alias = "get_n_monitors")]
pub fn n_monitors(&self) -> i32 {
unsafe { ffi::gdk_display_get_n_monitors(self.to_glib_none().0) }
}
/// Gets the name of the display.
///
/// # Returns
///
/// a string representing the display name. This string is owned
/// by GDK and should not be modified or freed.
#[doc(alias = "gdk_display_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> glib::GString {
unsafe { from_glib_none(ffi::gdk_display_get_name(self.to_glib_none().0)) }
}
/// Gets the primary monitor for the display.
///
/// The primary monitor is considered the monitor where the “main desktop”
/// lives. While normal application windows typically allow the window
/// manager to place the windows, specialized desktop applications
/// such as panels should place themselves on the primary monitor.
///
/// # Returns
///
/// the primary monitor, or [`None`] if no primary
/// monitor is configured by the user
#[doc(alias = "gdk_display_get_primary_monitor")]
#[doc(alias = "get_primary_monitor")]
pub fn primary_monitor(&self) -> Option<Monitor> {
unsafe { from_glib_none(ffi::gdk_display_get_primary_monitor(self.to_glib_none().0)) }
}
/// Returns whether the display has events that are waiting
/// to be processed.
///
/// # Returns
///
/// [`true`] if there are events ready to be processed.
#[doc(alias = "gdk_display_has_pending")]
pub fn has_pending(&self) -> bool {
unsafe { from_glib(ffi::gdk_display_has_pending(self.to_glib_none().0)) }
}
/// Finds out if the display has been closed.
///
/// # Returns
///
/// [`true`] if the display is closed.
#[doc(alias = "gdk_display_is_closed")]
pub fn is_closed(&self) -> bool {
unsafe { from_glib(ffi::gdk_display_is_closed(self.to_glib_none().0)) }
}
/// Returns the list of seats known to `self`.
///
/// # Returns
///
/// the
/// list of seats known to the [`Display`][crate::Display]
#[doc(alias = "gdk_display_list_seats")]
pub fn list_seats(&self) -> Vec<Seat> {
unsafe {
FromGlibPtrContainer::from_glib_container(ffi::gdk_display_list_seats(
self.to_glib_none().0,
))
}
}
/// Indicates to the GUI environment that the application has
/// finished loading, using a given identifier.
///
/// GTK+ will call this function automatically for `GtkWindow`
/// with custom startup-notification identifier unless
/// `gtk_window_set_auto_startup_notification()` is called to
/// disable that feature.
/// ## `startup_id`
/// a startup-notification identifier, for which
/// notification process should be completed
#[doc(alias = "gdk_display_notify_startup_complete")]
pub fn notify_startup_complete(&self, startup_id: &str) {
unsafe {
ffi::gdk_display_notify_startup_complete(
self.to_glib_none().0,
startup_id.to_glib_none().0,
);
}
}
/// Gets a copy of the first `GdkEvent` in the `self`’s event queue, without
/// removing the event from the queue. (Note that this function will
/// not get more events from the windowing system. It only checks the events
/// that have already been moved to the GDK event queue.)
///
/// # Returns
///
/// a copy of the first `GdkEvent` on the event
/// queue, or [`None`] if no events are in the queue. The returned
/// `GdkEvent` should be freed with `gdk_event_free()`.
#[doc(alias = "gdk_display_peek_event")]
pub fn peek_event(&self) -> Option<Event> {
unsafe { from_glib_full(ffi::gdk_display_peek_event(self.to_glib_none().0)) }
}
/// Appends a copy of the given event onto the front of the event
/// queue for `self`.
/// ## `event`
/// a `GdkEvent`.
#[doc(alias = "gdk_display_put_event")]
pub fn put_event(&self, event: &Event) {
unsafe {
ffi::gdk_display_put_event(self.to_glib_none().0, event.to_glib_none().0);
}
}
/// Request [`EventOwnerChange`][crate::EventOwnerChange] events for ownership changes
/// of the selection named by the given atom.
/// ## `selection`
/// the [`Atom`][crate::Atom] naming the selection for which
/// ownership change notification is requested
///
/// # Returns
///
/// whether [`EventOwnerChange`][crate::EventOwnerChange] events will
/// be sent.
#[doc(alias = "gdk_display_request_selection_notification")]
pub fn request_selection_notification(&self, selection: &Atom) -> bool {
unsafe {
from_glib(ffi::gdk_display_request_selection_notification(
self.to_glib_none().0,
selection.to_glib_none().0,
))
}
}
/// Sets the double click distance (two clicks within this distance
/// count as a double click and result in a [`EventType::_2buttonPress`][crate::EventType::_2buttonPress] event).
/// See also [`set_double_click_time()`][Self::set_double_click_time()].
/// Applications should not set this, it is a global
/// user-configured setting.
/// ## `distance`
/// distance in pixels
#[doc(alias = "gdk_display_set_double_click_distance")]
pub fn set_double_click_distance(&self, distance: u32) {
unsafe {
ffi::gdk_display_set_double_click_distance(self.to_glib_none().0, distance);
}
}
/// Sets the double click time (two clicks within this time interval
/// count as a double click and result in a [`EventType::_2buttonPress`][crate::EventType::_2buttonPress] event).
/// Applications should not set this, it is a global
/// user-configured setting.
/// ## `msec`
/// double click time in milliseconds (thousandths of a second)
#[doc(alias = "gdk_display_set_double_click_time")]
pub fn set_double_click_time(&self, msec: u32) {
unsafe {
ffi::gdk_display_set_double_click_time(self.to_glib_none().0, msec);
}
}
/// Issues a request to the clipboard manager to store the
/// clipboard data. On X11, this is a special program that works
/// according to the
/// [FreeDesktop Clipboard Specification](http://www.freedesktop.org/Standards/clipboard-manager-spec).
/// ## `clipboard_window`
/// a [`Window`][crate::Window] belonging to the clipboard owner
/// ## `time_`
/// a timestamp
/// ## `targets`
/// an array of targets
/// that should be saved, or [`None`]
/// if all available targets should be saved.
#[doc(alias = "gdk_display_store_clipboard")]
pub fn store_clipboard(&self, clipboard_window: &Window, time_: u32, targets: &[Atom]) {
let n_targets = targets.len() as i32;
unsafe {
ffi::gdk_display_store_clipboard(
self.to_glib_none().0,
clipboard_window.to_glib_none().0,
time_,
targets.to_glib_none().0,
n_targets,
);
}
}
/// Returns whether the speicifed display supports clipboard
/// persistance; i.e. if it’s possible to store the clipboard data after an
/// application has quit. On X11 this checks if a clipboard daemon is
/// running.
///
/// # Returns
///
/// [`true`] if the display supports clipboard persistance.
#[doc(alias = "gdk_display_supports_clipboard_persistence")]
pub fn supports_clipboard_persistence(&self) -> bool {
unsafe {
from_glib(ffi::gdk_display_supports_clipboard_persistence(
self.to_glib_none().0,
))
}
}
/// Returns [`true`] if cursors can use an 8bit alpha channel
/// on `self`. Otherwise, cursors are restricted to bilevel
/// alpha (i.e. a mask).
///
/// # Returns
///
/// whether cursors can have alpha channels.
#[doc(alias = "gdk_display_supports_cursor_alpha")]
pub fn supports_cursor_alpha(&self) -> bool {
unsafe {
from_glib(ffi::gdk_display_supports_cursor_alpha(
self.to_glib_none().0,
))
}
}
/// Returns [`true`] if multicolored cursors are supported
/// on `self`. Otherwise, cursors have only a forground
/// and a background color.
///
/// # Returns
///
/// whether cursors can have multiple colors.
#[doc(alias = "gdk_display_supports_cursor_color")]
pub fn supports_cursor_color(&self) -> bool {
unsafe {
from_glib(ffi::gdk_display_supports_cursor_color(
self.to_glib_none().0,
))
}
}
/// Returns [`true`] if `gdk_window_input_shape_combine_mask()` can
/// be used to modify the input shape of windows on `self`.
///
/// # Returns
///
/// [`true`] if windows with modified input shape are supported
#[doc(alias = "gdk_display_supports_input_shapes")]
pub fn supports_input_shapes(&self) -> bool {
unsafe {
from_glib(ffi::gdk_display_supports_input_shapes(
self.to_glib_none().0,
))
}
}
/// Returns whether [`EventOwnerChange`][crate::EventOwnerChange] events will be
/// sent when the owner of a selection changes.
///
/// # Returns
///
/// whether [`EventOwnerChange`][crate::EventOwnerChange] events will
/// be sent.
#[doc(alias = "gdk_display_supports_selection_notification")]
pub fn supports_selection_notification(&self) -> bool {
unsafe {
from_glib(ffi::gdk_display_supports_selection_notification(
self.to_glib_none().0,
))
}
}
/// Returns [`true`] if `gdk_window_shape_combine_mask()` can
/// be used to create shaped windows on `self`.
///
/// # Returns
///
/// [`true`] if shaped windows are supported
#[doc(alias = "gdk_display_supports_shapes")]
pub fn supports_shapes(&self) -> bool {
unsafe { from_glib(ffi::gdk_display_supports_shapes(self.to_glib_none().0)) }
}
/// Flushes any requests queued for the windowing system and waits until all
/// requests have been handled. This is often used for making sure that the
/// display is synchronized with the current state of the program. Calling
/// [`sync()`][Self::sync()] before [`error_trap_pop()`][crate::error_trap_pop()] makes sure that any errors
/// generated from earlier requests are handled before the error trap is
/// removed.
///
/// This is most useful for X11. On windowing systems where requests are
/// handled synchronously, this function will do nothing.
#[doc(alias = "gdk_display_sync")]
pub fn sync(&self) {
unsafe {
ffi::gdk_display_sync(self.to_glib_none().0);
}
}
/// Gets the default [`Display`][crate::Display]. This is a convenience
/// function for:
/// `gdk_display_manager_get_default_display (gdk_display_manager_get ())`.
///
/// # Returns
///
/// a [`Display`][crate::Display], or [`None`] if
/// there is no default display.
#[doc(alias = "gdk_display_get_default")]
#[doc(alias = "get_default")]
pub fn default() -> Option<Display> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::gdk_display_get_default()) }
}
/// Opens a display.
/// ## `display_name`
/// the name of the display to open
///
/// # Returns
///
/// a [`Display`][crate::Display], or [`None`] if the
/// display could not be opened
#[doc(alias = "gdk_display_open")]
pub fn open(display_name: &str) -> Option<Display> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::gdk_display_open(display_name.to_glib_none().0)) }
}
/// The ::closed signal is emitted when the connection to the windowing
/// system for `display` is closed.
/// ## `is_error`
/// [`true`] if the display was closed due to an error
#[doc(alias = "closed")]
pub fn connect_closed<F: Fn(&Self, bool) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn closed_trampoline<F: Fn(&Display, bool) + 'static>(
this: *mut ffi::GdkDisplay,
is_error: glib::ffi::gboolean,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), from_glib(is_error))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"closed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
closed_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// The ::monitor-added signal is emitted whenever a monitor is
/// added.
/// ## `monitor`
/// the monitor that was just added
#[doc(alias = "monitor-added")]
pub fn connect_monitor_added<F: Fn(&Self, &Monitor) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn monitor_added_trampoline<F: Fn(&Display, &Monitor) + 'static>(
this: *mut ffi::GdkDisplay,
monitor: *mut ffi::GdkMonitor,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), &from_glib_borrow(monitor))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"monitor-added\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
monitor_added_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// The ::monitor-removed signal is emitted whenever a monitor is
/// removed.
/// ## `monitor`
/// the monitor that was just removed
#[doc(alias = "monitor-removed")]
pub fn connect_monitor_removed<F: Fn(&Self, &Monitor) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn monitor_removed_trampoline<F: Fn(&Display, &Monitor) + 'static>(
this: *mut ffi::GdkDisplay,
monitor: *mut ffi::GdkMonitor,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), &from_glib_borrow(monitor))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"monitor-removed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
monitor_removed_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// The ::opened signal is emitted when the connection to the windowing
/// system for `display` is opened.
#[doc(alias = "opened")]
pub fn connect_opened<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn opened_trampoline<F: Fn(&Display) + 'static>(
this: *mut ffi::GdkDisplay,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"opened\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
opened_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// The ::seat-added signal is emitted whenever a new seat is made
/// known to the windowing system.
/// ## `seat`
/// the seat that was just added
#[doc(alias = "seat-added")]
pub fn connect_seat_added<F: Fn(&Self, &Seat) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn seat_added_trampoline<F: Fn(&Display, &Seat) + 'static>(
this: *mut ffi::GdkDisplay,
seat: *mut ffi::GdkSeat,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), &from_glib_borrow(seat))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"seat-added\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
seat_added_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// The ::seat-removed signal is emitted whenever a seat is removed
/// by the windowing system.
/// ## `seat`
/// the seat that was just removed
#[doc(alias = "seat-removed")]
pub fn connect_seat_removed<F: Fn(&Self, &Seat) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn seat_removed_trampoline<F: Fn(&Display, &Seat) + 'static>(
this: *mut ffi::GdkDisplay,
seat: *mut ffi::GdkSeat,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), &from_glib_borrow(seat))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"seat-removed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
seat_removed_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl fmt::Display for Display {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(&self.name())
}
}