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
// 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
#![allow(deprecated)]
use crate::X11Screen;
use glib::translate::*;
use std::{fmt, mem, ptr};
glib::wrapper! {
///
///
/// ## Signals
///
///
/// #### `xevent`
/// The ::xevent signal is a low level signal that is emitted
/// whenever an XEvent has been received.
///
/// When handlers to this signal return [`true`], no other handlers will be
/// invoked. In particular, the default handler for this function is
/// GDK's own event handling mechanism, so by returning [`true`] for an event
/// that GDK expects to translate, you may break GDK and/or GTK+ in
/// interesting ways. You have been warned.
///
/// If you want this signal handler to queue a [`gdk::Event`][crate::gdk::Event], you can use
/// gdk_display_put_event().
///
/// If you are interested in X GenericEvents, bear in mind that
/// XGetEventData() has been already called on the event, and
/// XFreeEventData() will be called afterwards.
///
///
/// <details><summary><h4>Display</h4></summary>
///
///
/// #### `closed`
/// Emitted when the connection to the windowing system for @display is closed.
///
///
///
///
/// #### `opened`
/// Emitted when the connection to the windowing system for @display is opened.
///
///
///
///
/// #### `seat-added`
/// Emitted whenever a new seat is made known to the windowing system.
///
///
///
///
/// #### `seat-removed`
/// Emitted whenever a seat is removed by the windowing system.
///
///
///
///
/// #### `setting-changed`
/// Emitted whenever a setting changes its value.
///
///
/// </details>
///
/// # Implements
///
/// [`trait@gdk::prelude::DisplayExt`]
#[doc(alias = "GdkX11Display")]
pub struct X11Display(Object<ffi::GdkX11Display, ffi::GdkX11DisplayClass>) @extends gdk::Display;
match fn {
type_ => || ffi::gdk_x11_display_get_type(),
}
}
impl X11Display {
//#[doc(alias = "gdk_x11_display_broadcast_startup_message")]
//pub fn broadcast_startup_message(&self, message_type: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
// unsafe { TODO: call ffi:gdk_x11_display_broadcast_startup_message() }
//}
/// Pops the error trap pushed by gdk_x11_display_error_trap_push().
/// Will XSync() if necessary and will always block until
/// the error is known to have occurred or not occurred,
/// so the error code can be returned.
///
/// If you don’t need to use the return value,
/// gdk_x11_display_error_trap_pop_ignored() would be more efficient.
///
/// # Returns
///
/// X error code or 0 on success
#[doc(alias = "gdk_x11_display_error_trap_pop")]
pub fn error_trap_pop(&self) -> i32 {
unsafe { ffi::gdk_x11_display_error_trap_pop(self.to_glib_none().0) }
}
/// Pops the error trap pushed by gdk_x11_display_error_trap_push().
/// Does not block to see if an error occurred; merely records the
/// range of requests to ignore errors for, and ignores those errors
/// if they arrive asynchronously.
#[doc(alias = "gdk_x11_display_error_trap_pop_ignored")]
pub fn error_trap_pop_ignored(&self) {
unsafe {
ffi::gdk_x11_display_error_trap_pop_ignored(self.to_glib_none().0);
}
}
/// Begins a range of X requests on @self for which X error events
/// will be ignored. Unignored errors (when no trap is pushed) will abort
/// the application. Use gdk_x11_display_error_trap_pop() or
/// gdk_x11_display_error_trap_pop_ignored()to lift a trap pushed
/// with this function.
#[doc(alias = "gdk_x11_display_error_trap_push")]
pub fn error_trap_push(&self) {
unsafe {
ffi::gdk_x11_display_error_trap_push(self.to_glib_none().0);
}
}
/// Returns the default group leader surface for all toplevel surfaces
/// on @self. This surface is implicitly created by GDK.
/// See gdk_x11_surface_set_group().
///
/// # Returns
///
/// The default group leader surface
/// for @self
#[doc(alias = "gdk_x11_display_get_default_group")]
#[doc(alias = "get_default_group")]
pub fn default_group(&self) -> gdk::Surface {
unsafe {
from_glib_none(ffi::gdk_x11_display_get_default_group(
self.to_glib_none().0,
))
}
}
/// Retrieves the version of the EGL implementation.
///
/// # Returns
///
/// [`true`] if EGL is available
///
/// ## `major`
/// return location for the EGL major version
///
/// ## `minor`
/// return location for the EGL minor version
#[cfg(feature = "v4_4")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
#[doc(alias = "gdk_x11_display_get_egl_version")]
#[doc(alias = "get_egl_version")]
pub fn egl_version(&self) -> Option<(i32, i32)> {
unsafe {
let mut major = mem::MaybeUninit::uninit();
let mut minor = mem::MaybeUninit::uninit();
let ret = from_glib(ffi::gdk_x11_display_get_egl_version(
self.to_glib_none().0,
major.as_mut_ptr(),
minor.as_mut_ptr(),
));
if ret {
Some((major.assume_init(), minor.assume_init()))
} else {
None
}
}
}
/// Retrieves the version of the GLX implementation.
///
/// # Returns
///
/// [`true`] if GLX is available
///
/// ## `major`
/// return location for the GLX major version
///
/// ## `minor`
/// return location for the GLX minor version
#[doc(alias = "gdk_x11_display_get_glx_version")]
#[doc(alias = "get_glx_version")]
pub fn glx_version(&self) -> Option<(i32, i32)> {
unsafe {
let mut major = mem::MaybeUninit::uninit();
let mut minor = mem::MaybeUninit::uninit();
let ret = from_glib(ffi::gdk_x11_display_get_glx_version(
self.to_glib_none().0,
major.as_mut_ptr(),
minor.as_mut_ptr(),
));
if ret {
Some((major.assume_init(), minor.assume_init()))
} else {
None
}
}
}
/// Gets the primary monitor for the display.
///
/// The primary monitor is considered the monitor where the “main desktop”
/// lives. While normal application surfaces typically allow the window
/// manager to place the surfaces, specialized desktop applications
/// such as panels should place themselves on the primary monitor.
///
/// If no monitor is the designated primary monitor, any monitor
/// (usually the first) may be returned.
///
/// # Returns
///
/// the primary monitor, or any monitor if no
/// primary monitor is configured by the user
#[doc(alias = "gdk_x11_display_get_primary_monitor")]
#[doc(alias = "get_primary_monitor")]
pub fn primary_monitor(&self) -> gdk::Monitor {
unsafe {
from_glib_none(ffi::gdk_x11_display_get_primary_monitor(
self.to_glib_none().0,
))
}
}
/// Retrieves the [`X11Screen`][crate::X11Screen] of the @self.
///
/// # Returns
///
/// the [`X11Screen`][crate::X11Screen]
#[doc(alias = "gdk_x11_display_get_screen")]
#[doc(alias = "get_screen")]
pub fn screen(&self) -> X11Screen {
unsafe { from_glib_none(ffi::gdk_x11_display_get_screen(self.to_glib_none().0)) }
}
/// Gets the startup notification ID for a display.
///
/// # Deprecated since 4.10
///
///
/// # Returns
///
/// the startup notification ID for @self
#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
#[allow(deprecated)]
#[doc(alias = "gdk_x11_display_get_startup_notification_id")]
#[doc(alias = "get_startup_notification_id")]
pub fn startup_notification_id(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::gdk_x11_display_get_startup_notification_id(
self.to_glib_none().0,
))
}
}
/// Returns the timestamp of the last user interaction on
/// @self. The timestamp is taken from events caused
/// by user interaction such as key presses or pointer
/// movements. See gdk_x11_surface_set_user_time().
///
/// # Returns
///
/// the timestamp of the last user interaction
#[doc(alias = "gdk_x11_display_get_user_time")]
#[doc(alias = "get_user_time")]
pub fn user_time(&self) -> u32 {
unsafe { ffi::gdk_x11_display_get_user_time(self.to_glib_none().0) }
}
/// Call XGrabServer() on @self.
/// To ungrab the display again, use gdk_x11_display_ungrab().
///
/// gdk_x11_display_grab()/gdk_x11_display_ungrab() calls can be nested.
#[doc(alias = "gdk_x11_display_grab")]
pub fn grab(&self) {
unsafe {
ffi::gdk_x11_display_grab(self.to_glib_none().0);
}
}
/// Sets the cursor theme from which the images for cursor
/// should be taken.
///
/// If the windowing system supports it, existing cursors created
/// with [`gdk::Cursor::from_name()`][crate::gdk::Cursor::from_name()] are updated to reflect the theme
/// change. Custom cursors constructed with [`gdk::Cursor::from_texture()`][crate::gdk::Cursor::from_texture()]
/// will have to be handled by the application (GTK applications can learn
/// about cursor theme changes by listening for change notification
/// for the corresponding `GtkSetting`).
/// ## `theme`
/// the name of the cursor theme to use, or [`None`]
/// to unset a previously set value
/// ## `size`
/// the cursor size to use, or 0 to keep the previous size
#[doc(alias = "gdk_x11_display_set_cursor_theme")]
pub fn set_cursor_theme(&self, theme: Option<&str>, size: i32) {
unsafe {
ffi::gdk_x11_display_set_cursor_theme(
self.to_glib_none().0,
theme.to_glib_none().0,
size,
);
}
}
/// Sets the startup notification ID for a display.
///
/// This is usually taken from the value of the DESKTOP_STARTUP_ID
/// environment variable, but in some cases (such as the application not
/// being launched using exec()) it can come from other sources.
///
/// If the ID contains the string "_TIME" then the portion following that
/// string is taken to be the X11 timestamp of the event that triggered
/// the application to be launched and the GDK current event time is set
/// accordingly.
///
/// The startup ID is also what is used to signal that the startup is
/// complete (for example, when opening a window or when calling
/// gdk_display_notify_startup_complete()).
///
/// # Deprecated since 4.10
///
/// Using `Gdk::Toplevel::set_startup_id()` is sufficient
/// ## `startup_id`
/// the startup notification ID (must be valid utf8)
#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
#[allow(deprecated)]
#[doc(alias = "gdk_x11_display_set_startup_notification_id")]
pub fn set_startup_notification_id(&self, startup_id: &str) {
unsafe {
ffi::gdk_x11_display_set_startup_notification_id(
self.to_glib_none().0,
startup_id.to_glib_none().0,
);
}
}
/// Forces a specific window scale for all windows on this display,
/// instead of using the default or user configured scale. This
/// is can be used to disable scaling support by setting @scale to
/// 1, or to programmatically set the window scale.
///
/// Once the scale is set by this call it will not change in response
/// to later user configuration changes.
/// ## `scale`
/// The new scale value
#[doc(alias = "gdk_x11_display_set_surface_scale")]
pub fn set_surface_scale(&self, scale: i32) {
unsafe {
ffi::gdk_x11_display_set_surface_scale(self.to_glib_none().0, scale);
}
}
/// Convert a string from the encoding of the current
/// locale into a form suitable for storing in a window property.
/// ## `str`
/// a nul-terminated string
///
/// # Returns
///
/// 0 upon success, non-zero upon failure
///
/// ## `encoding`
/// location to store the encoding
/// (to be used as the type for the property)
///
/// ## `format`
/// location to store the format of the property
///
/// ## `ctext`
/// location to store newly
/// allocated data for the property
#[doc(alias = "gdk_x11_display_string_to_compound_text")]
pub fn string_to_compound_text(&self, str: &str) -> (i32, glib::GString, i32, Vec<u8>) {
unsafe {
let mut encoding = ptr::null();
let mut format = mem::MaybeUninit::uninit();
let mut ctext = ptr::null_mut();
let mut length = mem::MaybeUninit::uninit();
let ret = ffi::gdk_x11_display_string_to_compound_text(
self.to_glib_none().0,
str.to_glib_none().0,
&mut encoding,
format.as_mut_ptr(),
&mut ctext,
length.as_mut_ptr(),
);
(
ret,
from_glib_none(encoding),
format.assume_init(),
FromGlibContainer::from_glib_full_num(ctext, length.assume_init() as _),
)
}
}
/// Ungrab @self after it has been grabbed with
/// gdk_x11_display_grab().
#[doc(alias = "gdk_x11_display_ungrab")]
pub fn ungrab(&self) {
unsafe {
ffi::gdk_x11_display_ungrab(self.to_glib_none().0);
}
}
/// Converts from UTF-8 to compound text.
/// ## `str`
/// a UTF-8 string
///
/// # Returns
///
/// [`true`] if the conversion succeeded, otherwise [`false`]
///
/// ## `encoding`
/// location to store resulting encoding
///
/// ## `format`
/// location to store format of the result
///
/// ## `ctext`
/// location to store the data of the result
#[doc(alias = "gdk_x11_display_utf8_to_compound_text")]
pub fn utf8_to_compound_text(&self, str: &str) -> Option<(glib::GString, i32, Vec<u8>)> {
unsafe {
let mut encoding = ptr::null();
let mut format = mem::MaybeUninit::uninit();
let mut ctext = ptr::null_mut();
let mut length = mem::MaybeUninit::uninit();
let ret = from_glib(ffi::gdk_x11_display_utf8_to_compound_text(
self.to_glib_none().0,
str.to_glib_none().0,
&mut encoding,
format.as_mut_ptr(),
&mut ctext,
length.as_mut_ptr(),
));
if ret {
Some((
from_glib_none(encoding),
format.assume_init(),
FromGlibContainer::from_glib_full_num(ctext, length.assume_init() as _),
))
} else {
None
}
}
}
/// Tries to open a new display to the X server given by
/// @display_name. If opening the display fails, [`None`] is
/// returned.
/// ## `display_name`
/// name of the X display.
/// See the XOpenDisplay() for details.
///
/// # Returns
///
/// The new display
#[doc(alias = "gdk_x11_display_open")]
pub fn open(display_name: Option<&str>) -> Option<gdk::Display> {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gdk_x11_display_open(display_name.to_glib_none().0)) }
}
}
impl fmt::Display for X11Display {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("X11Display")
}
}