gdk/auto/functions.rs
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
5use crate::{Atom, Display, Event, EventType, ModifierType, Screen, Window, WindowState};
6use glib::translate::*;
7use std::{mem, ptr};
8
9/// Emits a short beep on the default display.
10#[doc(alias = "gdk_beep")]
11pub fn beep() {
12 assert_initialized_main_thread!();
13 unsafe {
14 ffi::gdk_beep();
15 }
16}
17
18/// Removes an error trap pushed with [`error_trap_push()`][crate::error_trap_push()].
19/// May block until an error has been definitively received
20/// or not received from the X server. [`error_trap_pop_ignored()`][crate::error_trap_pop_ignored()]
21/// is preferred if you don’t need to know whether an error
22/// occurred, because it never has to block. If you don't
23/// need the return value of [`error_trap_pop()`][crate::error_trap_pop()], use
24/// [`error_trap_pop_ignored()`][crate::error_trap_pop_ignored()].
25///
26/// Prior to GDK 3.0, this function would not automatically
27/// sync for you, so you had to [`flush()`][crate::flush()] if your last
28/// call to Xlib was not a blocking round trip.
29///
30/// # Returns
31///
32/// X error code or 0 on success
33#[doc(alias = "gdk_error_trap_pop")]
34pub fn error_trap_pop() -> i32 {
35 assert_initialized_main_thread!();
36 unsafe { ffi::gdk_error_trap_pop() }
37}
38
39/// Removes an error trap pushed with [`error_trap_push()`][crate::error_trap_push()], but
40/// without bothering to wait and see whether an error occurred. If an
41/// error arrives later asynchronously that was triggered while the
42/// trap was pushed, that error will be ignored.
43#[doc(alias = "gdk_error_trap_pop_ignored")]
44pub fn error_trap_pop_ignored() {
45 assert_initialized_main_thread!();
46 unsafe {
47 ffi::gdk_error_trap_pop_ignored();
48 }
49}
50
51/// This function allows X errors to be trapped instead of the normal
52/// behavior of exiting the application. It should only be used if it
53/// is not possible to avoid the X error in any other way. Errors are
54/// ignored on all [`Display`][crate::Display] currently known to the
55/// [`DisplayManager`][crate::DisplayManager]. If you don’t care which error happens and just
56/// want to ignore everything, pop with [`error_trap_pop_ignored()`][crate::error_trap_pop_ignored()].
57/// If you need the error code, use [`error_trap_pop()`][crate::error_trap_pop()] which may have
58/// to block and wait for the error to arrive from the X server.
59///
60/// This API exists on all platforms but only does anything on X.
61///
62/// You can use `gdk_x11_display_error_trap_push()` to ignore errors
63/// on only a single display.
64///
65/// ## Trapping an X error
66///
67///
68///
69/// **⚠️ The following code is in C ⚠️**
70///
71/// ```C
72/// gdk_error_trap_push ();
73///
74/// // ... Call the X function which may cause an error here ...
75///
76///
77/// if (gdk_error_trap_pop ())
78/// {
79/// // ... Handle the error here ...
80/// }
81/// ```
82#[doc(alias = "gdk_error_trap_push")]
83pub fn error_trap_push() {
84 assert_initialized_main_thread!();
85 unsafe {
86 ffi::gdk_error_trap_push();
87 }
88}
89
90/// If both events contain X/Y information, this function will return [`true`]
91/// and return in `angle` the relative angle from `event1` to `event2`. The rotation
92/// direction for positive angles is from the positive X axis towards the positive
93/// Y axis.
94/// ## `event1`
95/// first `GdkEvent`
96/// ## `event2`
97/// second `GdkEvent`
98///
99/// # Returns
100///
101/// [`true`] if the angle could be calculated.
102///
103/// ## `angle`
104/// return location for the relative angle between both events
105#[doc(alias = "gdk_events_get_angle")]
106pub fn events_get_angle(event1: &mut Event, event2: &mut Event) -> Option<f64> {
107 assert_initialized_main_thread!();
108 unsafe {
109 let mut angle = mem::MaybeUninit::uninit();
110 let ret = from_glib(ffi::gdk_events_get_angle(
111 event1.to_glib_none_mut().0,
112 event2.to_glib_none_mut().0,
113 angle.as_mut_ptr(),
114 ));
115 if ret {
116 Some(angle.assume_init())
117 } else {
118 None
119 }
120 }
121}
122
123/// If both events contain X/Y information, the center of both coordinates
124/// will be returned in `x` and `y`.
125/// ## `event1`
126/// first `GdkEvent`
127/// ## `event2`
128/// second `GdkEvent`
129///
130/// # Returns
131///
132/// [`true`] if the center could be calculated.
133///
134/// ## `x`
135/// return location for the X coordinate of the center
136///
137/// ## `y`
138/// return location for the Y coordinate of the center
139#[doc(alias = "gdk_events_get_center")]
140pub fn events_get_center(event1: &mut Event, event2: &mut Event) -> Option<(f64, f64)> {
141 assert_initialized_main_thread!();
142 unsafe {
143 let mut x = mem::MaybeUninit::uninit();
144 let mut y = mem::MaybeUninit::uninit();
145 let ret = from_glib(ffi::gdk_events_get_center(
146 event1.to_glib_none_mut().0,
147 event2.to_glib_none_mut().0,
148 x.as_mut_ptr(),
149 y.as_mut_ptr(),
150 ));
151 if ret {
152 Some((x.assume_init(), y.assume_init()))
153 } else {
154 None
155 }
156 }
157}
158
159/// If both events have X/Y information, the distance between both coordinates
160/// (as in a straight line going from `event1` to `event2`) will be returned.
161/// ## `event1`
162/// first `GdkEvent`
163/// ## `event2`
164/// second `GdkEvent`
165///
166/// # Returns
167///
168/// [`true`] if the distance could be calculated.
169///
170/// ## `distance`
171/// return location for the distance
172#[doc(alias = "gdk_events_get_distance")]
173pub fn events_get_distance(event1: &mut Event, event2: &mut Event) -> Option<f64> {
174 assert_initialized_main_thread!();
175 unsafe {
176 let mut distance = mem::MaybeUninit::uninit();
177 let ret = from_glib(ffi::gdk_events_get_distance(
178 event1.to_glib_none_mut().0,
179 event2.to_glib_none_mut().0,
180 distance.as_mut_ptr(),
181 ));
182 if ret {
183 Some(distance.assume_init())
184 } else {
185 None
186 }
187 }
188}
189
190/// Checks if any events are ready to be processed for any display.
191///
192/// # Returns
193///
194/// [`true`] if any events are pending.
195#[doc(alias = "gdk_events_pending")]
196pub fn events_pending() -> bool {
197 assert_initialized_main_thread!();
198 unsafe { from_glib(ffi::gdk_events_pending()) }
199}
200
201/// Flushes the output buffers of all display connections and waits
202/// until all requests have been processed.
203/// This is rarely needed by applications.
204#[doc(alias = "gdk_flush")]
205pub fn flush() {
206 assert_initialized_main_thread!();
207 unsafe {
208 ffi::gdk_flush();
209 }
210}
211
212/// Gets the display name specified in the command line arguments passed
213/// to `gdk_init()` or `gdk_parse_args()`, if any.
214///
215/// # Returns
216///
217/// the display name, if specified explicitly,
218/// otherwise [`None`] this string is owned by GTK+ and must not be
219/// modified or freed.
220#[doc(alias = "gdk_get_display_arg_name")]
221#[doc(alias = "get_display_arg_name")]
222pub fn display_arg_name() -> Option<glib::GString> {
223 assert_initialized_main_thread!();
224 unsafe { from_glib_none(ffi::gdk_get_display_arg_name()) }
225}
226
227/// Gets the program class. Unless the program class has explicitly
228/// been set with [`set_program_class()`][crate::set_program_class()] or with the `--class`
229/// commandline option, the default value is the program name (determined
230/// with `g_get_prgname()`) with the first character converted to uppercase.
231///
232/// # Returns
233///
234/// the program class.
235#[doc(alias = "gdk_get_program_class")]
236#[doc(alias = "get_program_class")]
237pub fn program_class() -> Option<glib::GString> {
238 assert_initialized_main_thread!();
239 unsafe { from_glib_none(ffi::gdk_get_program_class()) }
240}
241
242/// Gets whether event debugging output is enabled.
243///
244/// # Returns
245///
246/// [`true`] if event debugging output is enabled.
247#[doc(alias = "gdk_get_show_events")]
248#[doc(alias = "get_show_events")]
249pub fn shows_events() -> bool {
250 assert_initialized_main_thread!();
251 unsafe { from_glib(ffi::gdk_get_show_events()) }
252}
253
254/// Indicates to the GUI environment that the application has finished
255/// loading. If the applications opens windows, this function is
256/// normally called after opening the application’s initial set of
257/// windows.
258///
259/// GTK+ will call this function automatically after opening the first
260/// `GtkWindow` unless `gtk_window_set_auto_startup_notification()` is called
261/// to disable that feature.
262#[doc(alias = "gdk_notify_startup_complete")]
263pub fn notify_startup_complete() {
264 assert_initialized_main_thread!();
265 unsafe {
266 ffi::gdk_notify_startup_complete();
267 }
268}
269
270/// Indicates to the GUI environment that the application has
271/// finished loading, using a given identifier.
272///
273/// GTK+ will call this function automatically for `GtkWindow`
274/// with custom startup-notification identifier unless
275/// `gtk_window_set_auto_startup_notification()` is called to
276/// disable that feature.
277/// ## `startup_id`
278/// a startup-notification identifier, for which
279/// notification process should be completed
280#[doc(alias = "gdk_notify_startup_complete_with_id")]
281pub fn notify_startup_complete_with_id(startup_id: &str) {
282 assert_initialized_main_thread!();
283 unsafe {
284 ffi::gdk_notify_startup_complete_with_id(startup_id.to_glib_none().0);
285 }
286}
287
288/// Creates a [`pango::Context`][crate::pango::Context] for the default GDK screen.
289///
290/// The context must be freed when you’re finished with it.
291///
292/// When using GTK+, normally you should use `gtk_widget_get_pango_context()`
293/// instead of this function, to get the appropriate context for
294/// the widget you intend to render text onto.
295///
296/// The newly created context will have the default font options (see
297/// [`cairo::FontOptions`][crate::cairo::FontOptions]) for the default screen; if these options
298/// change it will not be updated. Using `gtk_widget_get_pango_context()`
299/// is more convenient if you want to keep a context around and track
300/// changes to the screen’s font rendering settings.
301///
302/// # Returns
303///
304/// a new [`pango::Context`][crate::pango::Context] for the default display
305#[doc(alias = "gdk_pango_context_get")]
306pub fn pango_context_get() -> Option<pango::Context> {
307 assert_initialized_main_thread!();
308 unsafe { from_glib_full(ffi::gdk_pango_context_get()) }
309}
310
311/// Creates a [`pango::Context`][crate::pango::Context] for `display`.
312///
313/// The context must be freed when you’re finished with it.
314///
315/// When using GTK+, normally you should use `gtk_widget_get_pango_context()`
316/// instead of this function, to get the appropriate context for
317/// the widget you intend to render text onto.
318///
319/// The newly created context will have the default font options
320/// (see [`cairo::FontOptions`][crate::cairo::FontOptions]) for the display; if these options
321/// change it will not be updated. Using `gtk_widget_get_pango_context()`
322/// is more convenient if you want to keep a context around and track
323/// changes to the font rendering settings.
324/// ## `display`
325/// the [`Display`][crate::Display] for which the context is to be created
326///
327/// # Returns
328///
329/// a new [`pango::Context`][crate::pango::Context] for `display`
330#[doc(alias = "gdk_pango_context_get_for_display")]
331pub fn pango_context_get_for_display(display: &Display) -> Option<pango::Context> {
332 skip_assert_initialized!();
333 unsafe {
334 from_glib_full(ffi::gdk_pango_context_get_for_display(
335 display.to_glib_none().0,
336 ))
337 }
338}
339
340/// Creates a [`pango::Context`][crate::pango::Context] for `screen`.
341///
342/// The context must be freed when you’re finished with it.
343///
344/// When using GTK+, normally you should use `gtk_widget_get_pango_context()`
345/// instead of this function, to get the appropriate context for
346/// the widget you intend to render text onto.
347///
348/// The newly created context will have the default font options
349/// (see [`cairo::FontOptions`][crate::cairo::FontOptions]) for the screen; if these options
350/// change it will not be updated. Using `gtk_widget_get_pango_context()`
351/// is more convenient if you want to keep a context around and track
352/// changes to the screen’s font rendering settings.
353/// ## `screen`
354/// the [`Screen`][crate::Screen] for which the context is to be created.
355///
356/// # Returns
357///
358/// a new [`pango::Context`][crate::pango::Context] for `screen`
359#[doc(alias = "gdk_pango_context_get_for_screen")]
360pub fn pango_context_get_for_screen(screen: &Screen) -> Option<pango::Context> {
361 skip_assert_initialized!();
362 unsafe {
363 from_glib_full(ffi::gdk_pango_context_get_for_screen(
364 screen.to_glib_none().0,
365 ))
366 }
367}
368
369//#[doc(alias = "gdk_pango_layout_line_get_clip_region")]
370//pub fn pango_layout_line_get_clip_region(line: &pango::LayoutLine, x_origin: i32, y_origin: i32, index_ranges: &[i32], n_ranges: i32) -> Option<cairo::Region> {
371// unsafe { TODO: call ffi:gdk_pango_layout_line_get_clip_region() }
372//}
373
374/// Transfers image data from a [`cairo::Surface`][crate::cairo::Surface] and converts it to an RGB(A)
375/// representation inside a [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf]. This allows you to efficiently read
376/// individual pixels from cairo surfaces. For `GdkWindows`, use
377/// `gdk_pixbuf_get_from_window()` instead.
378///
379/// This function will create an RGB pixbuf with 8 bits per channel.
380/// The pixbuf will contain an alpha channel if the `surface` contains one.
381/// ## `surface`
382/// surface to copy from
383/// ## `src_x`
384/// Source X coordinate within `surface`
385/// ## `src_y`
386/// Source Y coordinate within `surface`
387/// ## `width`
388/// Width in pixels of region to get
389/// ## `height`
390/// Height in pixels of region to get
391///
392/// # Returns
393///
394/// A newly-created pixbuf with a
395/// reference count of 1, or [`None`] on error
396#[doc(alias = "gdk_pixbuf_get_from_surface")]
397pub fn pixbuf_get_from_surface(
398 surface: &cairo::Surface,
399 src_x: i32,
400 src_y: i32,
401 width: i32,
402 height: i32,
403) -> Option<gdk_pixbuf::Pixbuf> {
404 assert_initialized_main_thread!();
405 unsafe {
406 from_glib_full(ffi::gdk_pixbuf_get_from_surface(
407 mut_override(surface.to_glib_none().0),
408 src_x,
409 src_y,
410 width,
411 height,
412 ))
413 }
414}
415
416/// Deletes a property from a window.
417/// ## `window`
418/// a [`Window`][crate::Window]
419/// ## `property`
420/// the property to delete
421#[doc(alias = "gdk_property_delete")]
422pub fn property_delete(window: &Window, property: &Atom) {
423 skip_assert_initialized!();
424 unsafe {
425 ffi::gdk_property_delete(window.to_glib_none().0, property.to_glib_none().0);
426 }
427}
428
429/// Retrieves a portion of the contents of a property. If the
430/// property does not exist, then the function returns [`false`],
431/// and `GDK_NONE` will be stored in `actual_property_type`.
432///
433/// The XGetWindowProperty() function that [`property_get()`][crate::property_get()]
434/// uses has a very confusing and complicated set of semantics.
435/// Unfortunately, [`property_get()`][crate::property_get()] makes the situation
436/// worse instead of better (the semantics should be considered
437/// undefined), and also prints warnings to stderr in cases where it
438/// should return a useful error to the program. You are advised to use
439/// XGetWindowProperty() directly until a replacement function for
440/// [`property_get()`][crate::property_get()] is provided.
441/// ## `window`
442/// a [`Window`][crate::Window]
443/// ## `property`
444/// the property to retrieve
445/// ## `type_`
446/// the desired property type, or `GDK_NONE`, if any type of data
447/// is acceptable. If this does not match the actual
448/// type, then `actual_format` and `actual_length` will
449/// be filled in, a warning will be printed to stderr
450/// and no data will be returned.
451/// ## `offset`
452/// the offset into the property at which to begin
453/// retrieving data, in 4 byte units.
454/// ## `length`
455/// the length of the data to retrieve in bytes. Data is
456/// considered to be retrieved in 4 byte chunks, so `length`
457/// will be rounded up to the next highest 4 byte boundary
458/// (so be careful not to pass a value that might overflow
459/// when rounded up).
460/// ## `pdelete`
461/// if [`true`], delete the property after retrieving the
462/// data.
463///
464/// # Returns
465///
466/// [`true`] if data was successfully received and stored
467/// in `data`, otherwise [`false`].
468///
469/// ## `actual_property_type`
470/// location to store the
471/// actual type of the property.
472///
473/// ## `actual_format`
474/// location to store the actual return format of the
475/// data; either 8, 16 or 32 bits.
476///
477/// ## `data`
478/// location
479/// to store a pointer to the data. The retrieved data should be
480/// freed with `g_free()` when you are finished using it.
481#[doc(alias = "gdk_property_get")]
482pub fn property_get(
483 window: &Window,
484 property: &Atom,
485 type_: &Atom,
486 offset: libc::c_ulong,
487 length: libc::c_ulong,
488 pdelete: i32,
489) -> Option<(Atom, i32, Vec<u8>)> {
490 skip_assert_initialized!();
491 unsafe {
492 let mut actual_property_type = Atom::uninitialized();
493 let mut actual_format = mem::MaybeUninit::uninit();
494 let mut actual_length = mem::MaybeUninit::uninit();
495 let mut data = ptr::null_mut();
496 let ret = from_glib(ffi::gdk_property_get(
497 window.to_glib_none().0,
498 property.to_glib_none().0,
499 type_.to_glib_none().0,
500 offset,
501 length,
502 pdelete,
503 actual_property_type.to_glib_none_mut().0,
504 actual_format.as_mut_ptr(),
505 actual_length.as_mut_ptr(),
506 &mut data,
507 ));
508 if ret {
509 Some((
510 actual_property_type,
511 actual_format.assume_init(),
512 FromGlibContainer::from_glib_full_num(data, actual_length.assume_init() as _),
513 ))
514 } else {
515 None
516 }
517 }
518}
519
520/// Retrieves the contents of a selection in a given
521/// form.
522/// ## `requestor`
523/// a [`Window`][crate::Window].
524/// ## `selection`
525/// an atom identifying the selection to get the
526/// contents of.
527/// ## `target`
528/// the form in which to retrieve the selection.
529/// ## `time_`
530/// the timestamp to use when retrieving the
531/// selection. The selection owner may refuse the
532/// request if it did not own the selection at
533/// the time indicated by the timestamp.
534#[doc(alias = "gdk_selection_convert")]
535pub fn selection_convert(requestor: &Window, selection: &Atom, target: &Atom, time_: u32) {
536 skip_assert_initialized!();
537 unsafe {
538 ffi::gdk_selection_convert(
539 requestor.to_glib_none().0,
540 selection.to_glib_none().0,
541 target.to_glib_none().0,
542 time_,
543 );
544 }
545}
546
547/// Determines the owner of the given selection.
548/// ## `selection`
549/// an atom indentifying a selection.
550///
551/// # Returns
552///
553/// if there is a selection owner
554/// for this window, and it is a window known to the current process,
555/// the [`Window`][crate::Window] that owns the selection, otherwise [`None`]. Note
556/// that the return value may be owned by a different process if a
557/// foreign window was previously created for that window, but a new
558/// foreign window will never be created by this call.
559#[doc(alias = "gdk_selection_owner_get")]
560pub fn selection_owner_get(selection: &Atom) -> Option<Window> {
561 assert_initialized_main_thread!();
562 unsafe { from_glib_none(ffi::gdk_selection_owner_get(selection.to_glib_none().0)) }
563}
564
565/// Determine the owner of the given selection.
566///
567/// Note that the return value may be owned by a different
568/// process if a foreign window was previously created for that
569/// window, but a new foreign window will never be created by this call.
570/// ## `display`
571/// a [`Display`][crate::Display]
572/// ## `selection`
573/// an atom indentifying a selection
574///
575/// # Returns
576///
577/// if there is a selection owner
578/// for this window, and it is a window known to the current
579/// process, the [`Window`][crate::Window] that owns the selection, otherwise
580/// [`None`].
581#[doc(alias = "gdk_selection_owner_get_for_display")]
582pub fn selection_owner_get_for_display(display: &Display, selection: &Atom) -> Option<Window> {
583 skip_assert_initialized!();
584 unsafe {
585 from_glib_none(ffi::gdk_selection_owner_get_for_display(
586 display.to_glib_none().0,
587 selection.to_glib_none().0,
588 ))
589 }
590}
591
592/// Sets the owner of the given selection.
593/// ## `owner`
594/// a [`Window`][crate::Window] or [`None`] to indicate that the
595/// the owner for the given should be unset.
596/// ## `selection`
597/// an atom identifying a selection.
598/// ## `time_`
599/// timestamp to use when setting the selection.
600/// If this is older than the timestamp given last
601/// time the owner was set for the given selection, the
602/// request will be ignored.
603/// ## `send_event`
604/// if [`true`], and the new owner is different
605/// from the current owner, the current owner
606/// will be sent a SelectionClear event.
607///
608/// # Returns
609///
610/// [`true`] if the selection owner was successfully
611/// changed to `owner`, otherwise [`false`].
612#[doc(alias = "gdk_selection_owner_set")]
613pub fn selection_owner_set(
614 owner: Option<&Window>,
615 selection: &Atom,
616 time_: u32,
617 send_event: bool,
618) -> bool {
619 assert_initialized_main_thread!();
620 unsafe {
621 from_glib(ffi::gdk_selection_owner_set(
622 owner.to_glib_none().0,
623 selection.to_glib_none().0,
624 time_,
625 send_event.into_glib(),
626 ))
627 }
628}
629
630/// Sets the [`Window`][crate::Window] `owner` as the current owner of the selection `selection`.
631/// ## `display`
632/// the [`Display`][crate::Display]
633/// ## `owner`
634/// a [`Window`][crate::Window] or [`None`] to indicate that the owner for
635/// the given should be unset
636/// ## `selection`
637/// an atom identifying a selection
638/// ## `time_`
639/// timestamp to use when setting the selection
640/// If this is older than the timestamp given last time the owner was
641/// set for the given selection, the request will be ignored
642/// ## `send_event`
643/// if [`true`], and the new owner is different from the current
644/// owner, the current owner will be sent a SelectionClear event
645///
646/// # Returns
647///
648/// [`true`] if the selection owner was successfully changed to owner,
649/// otherwise [`false`].
650#[doc(alias = "gdk_selection_owner_set_for_display")]
651pub fn selection_owner_set_for_display(
652 display: &Display,
653 owner: Option<&Window>,
654 selection: &Atom,
655 time_: u32,
656 send_event: bool,
657) -> bool {
658 skip_assert_initialized!();
659 unsafe {
660 from_glib(ffi::gdk_selection_owner_set_for_display(
661 display.to_glib_none().0,
662 owner.to_glib_none().0,
663 selection.to_glib_none().0,
664 time_,
665 send_event.into_glib(),
666 ))
667 }
668}
669
670/// Sends a response to SelectionRequest event.
671/// ## `requestor`
672/// window to which to deliver response.
673/// ## `selection`
674/// selection that was requested.
675/// ## `target`
676/// target that was selected.
677/// ## `property`
678/// property in which the selection owner stored the
679/// data, or `GDK_NONE` to indicate that the request
680/// was rejected.
681/// ## `time_`
682/// timestamp.
683#[doc(alias = "gdk_selection_send_notify")]
684pub fn selection_send_notify(
685 requestor: &Window,
686 selection: &Atom,
687 target: &Atom,
688 property: &Atom,
689 time_: u32,
690) {
691 skip_assert_initialized!();
692 unsafe {
693 ffi::gdk_selection_send_notify(
694 requestor.to_glib_none().0,
695 selection.to_glib_none().0,
696 target.to_glib_none().0,
697 property.to_glib_none().0,
698 time_,
699 );
700 }
701}
702
703/// Send a response to SelectionRequest event.
704/// ## `display`
705/// the [`Display`][crate::Display] where `requestor` is realized
706/// ## `requestor`
707/// window to which to deliver response
708/// ## `selection`
709/// selection that was requested
710/// ## `target`
711/// target that was selected
712/// ## `property`
713/// property in which the selection owner stored the data,
714/// or `GDK_NONE` to indicate that the request was rejected
715/// ## `time_`
716/// timestamp
717#[doc(alias = "gdk_selection_send_notify_for_display")]
718pub fn selection_send_notify_for_display(
719 display: &Display,
720 requestor: &Window,
721 selection: &Atom,
722 target: &Atom,
723 property: &Atom,
724 time_: u32,
725) {
726 skip_assert_initialized!();
727 unsafe {
728 ffi::gdk_selection_send_notify_for_display(
729 display.to_glib_none().0,
730 requestor.to_glib_none().0,
731 selection.to_glib_none().0,
732 target.to_glib_none().0,
733 property.to_glib_none().0,
734 time_,
735 );
736 }
737}
738
739/// Sets a list of backends that GDK should try to use.
740///
741/// This can be be useful if your application does not
742/// work with certain GDK backends.
743///
744/// By default, GDK tries all included backends.
745///
746/// For example,
747///
748///
749/// **⚠️ The following code is in C ⚠️**
750///
751/// ```C
752/// gdk_set_allowed_backends ("wayland,quartz,*");
753/// ```
754/// instructs GDK to try the Wayland backend first,
755/// followed by the Quartz backend, and then all
756/// others.
757///
758/// If the `GDK_BACKEND` environment variable
759/// is set, it determines what backends are tried in what
760/// order, while still respecting the set of allowed backends
761/// that are specified by this function.
762///
763/// The possible backend names are x11, win32, quartz,
764/// broadway, wayland. You can also include a * in the
765/// list to try all remaining backends.
766///
767/// This call must happen prior to [`Display::open()`][crate::Display::open()],
768/// `gtk_init()`, `gtk_init_with_args()` or `gtk_init_check()`
769/// in order to take effect.
770/// ## `backends`
771/// a comma-separated list of backends
772#[doc(alias = "gdk_set_allowed_backends")]
773pub fn set_allowed_backends(backends: &str) {
774 skip_assert_initialized!();
775 unsafe {
776 ffi::gdk_set_allowed_backends(backends.to_glib_none().0);
777 }
778}
779
780/// Set the double click time for the default display. See
781/// [`Display::set_double_click_time()`][crate::Display::set_double_click_time()].
782/// See also [`Display::set_double_click_distance()`][crate::Display::set_double_click_distance()].
783/// Applications should not set this, it is a
784/// global user-configured setting.
785/// ## `msec`
786/// double click time in milliseconds (thousandths of a second)
787#[doc(alias = "gdk_set_double_click_time")]
788pub fn set_double_click_time(msec: u32) {
789 assert_initialized_main_thread!();
790 unsafe {
791 ffi::gdk_set_double_click_time(msec);
792 }
793}
794
795/// Sets the program class. The X11 backend uses the program class to set
796/// the class name part of the `WM_CLASS` property on
797/// toplevel windows; see the ICCCM.
798///
799/// The program class can still be overridden with the --class command
800/// line option.
801/// ## `program_class`
802/// a string.
803#[doc(alias = "gdk_set_program_class")]
804pub fn set_program_class(program_class: &str) {
805 assert_initialized_main_thread!();
806 unsafe {
807 ffi::gdk_set_program_class(program_class.to_glib_none().0);
808 }
809}
810
811/// Sets whether a trace of received events is output.
812/// Note that GTK+ must be compiled with debugging (that is,
813/// configured using the `--enable-debug` option)
814/// to use this option.
815/// ## `show_events`
816/// [`true`] to output event debugging information.
817#[doc(alias = "gdk_set_show_events")]
818pub fn set_show_events(show_events: bool) {
819 assert_initialized_main_thread!();
820 unsafe {
821 ffi::gdk_set_show_events(show_events.into_glib());
822 }
823}
824
825#[doc(alias = "gdk_synthesize_window_state")]
826pub fn synthesize_window_state(window: &Window, unset_flags: WindowState, set_flags: WindowState) {
827 skip_assert_initialized!();
828 unsafe {
829 ffi::gdk_synthesize_window_state(
830 window.to_glib_none().0,
831 unset_flags.into_glib(),
832 set_flags.into_glib(),
833 );
834 }
835}
836
837/// Retrieves a pixel from `window` to force the windowing
838/// system to carry out any pending rendering commands.
839///
840/// This function is intended to be used to synchronize with rendering
841/// pipelines, to benchmark windowing system rendering operations.
842/// ## `window`
843/// a mapped [`Window`][crate::Window]
844#[doc(alias = "gdk_test_render_sync")]
845pub fn test_render_sync(window: &Window) {
846 skip_assert_initialized!();
847 unsafe {
848 ffi::gdk_test_render_sync(window.to_glib_none().0);
849 }
850}
851
852/// This function is intended to be used in GTK+ test programs.
853/// It will warp the mouse pointer to the given (`x`,`y`) coordinates
854/// within `window` and simulate a button press or release event.
855/// Because the mouse pointer needs to be warped to the target
856/// location, use of this function outside of test programs that
857/// run in their own virtual windowing system (e.g. Xvfb) is not
858/// recommended.
859///
860/// Also, [`test_simulate_button()`][crate::test_simulate_button()] is a fairly low level function,
861/// for most testing purposes, `gtk_test_widget_click()` is the right
862/// function to call which will generate a button press event followed
863/// by its accompanying button release event.
864/// ## `window`
865/// a [`Window`][crate::Window] to simulate a button event for
866/// ## `x`
867/// x coordinate within `window` for the button event
868/// ## `y`
869/// y coordinate within `window` for the button event
870/// ## `button`
871/// Number of the pointer button for the event, usually 1, 2 or 3
872/// ## `modifiers`
873/// Keyboard modifiers the event is setup with
874/// ## `button_pressrelease`
875/// either [`EventType::ButtonPress`][crate::EventType::ButtonPress] or [`EventType::ButtonRelease`][crate::EventType::ButtonRelease]
876///
877/// # Returns
878///
879/// whether all actions necessary for a button event simulation
880/// were carried out successfully
881#[doc(alias = "gdk_test_simulate_button")]
882pub fn test_simulate_button(
883 window: &Window,
884 x: i32,
885 y: i32,
886 button: u32,
887 modifiers: ModifierType,
888 button_pressrelease: EventType,
889) -> bool {
890 skip_assert_initialized!();
891 unsafe {
892 from_glib(ffi::gdk_test_simulate_button(
893 window.to_glib_none().0,
894 x,
895 y,
896 button,
897 modifiers.into_glib(),
898 button_pressrelease.into_glib(),
899 ))
900 }
901}
902
903/// This function is intended to be used in GTK+ test programs.
904/// If (`x`,`y`) are > (-1,-1), it will warp the mouse pointer to
905/// the given (`x`,`y`) coordinates within `window` and simulate a
906/// key press or release event.
907///
908/// When the mouse pointer is warped to the target location, use
909/// of this function outside of test programs that run in their
910/// own virtual windowing system (e.g. Xvfb) is not recommended.
911/// If (`x`,`y`) are passed as (-1,-1), the mouse pointer will not
912/// be warped and `window` origin will be used as mouse pointer
913/// location for the event.
914///
915/// Also, [`test_simulate_key()`][crate::test_simulate_key()] is a fairly low level function,
916/// for most testing purposes, `gtk_test_widget_send_key()` is the
917/// right function to call which will generate a key press event
918/// followed by its accompanying key release event.
919/// ## `window`
920/// a [`Window`][crate::Window] to simulate a key event for
921/// ## `x`
922/// x coordinate within `window` for the key event
923/// ## `y`
924/// y coordinate within `window` for the key event
925/// ## `keyval`
926/// A GDK keyboard value
927/// ## `modifiers`
928/// Keyboard modifiers the event is setup with
929/// ## `key_pressrelease`
930/// either [`EventType::KeyPress`][crate::EventType::KeyPress] or [`EventType::KeyRelease`][crate::EventType::KeyRelease]
931///
932/// # Returns
933///
934/// whether all actions necessary for a key event simulation
935/// were carried out successfully
936#[doc(alias = "gdk_test_simulate_key")]
937pub fn test_simulate_key(
938 window: &Window,
939 x: i32,
940 y: i32,
941 keyval: u32,
942 modifiers: ModifierType,
943 key_pressrelease: EventType,
944) -> bool {
945 skip_assert_initialized!();
946 unsafe {
947 from_glib(ffi::gdk_test_simulate_key(
948 window.to_glib_none().0,
949 x,
950 y,
951 keyval,
952 modifiers.into_glib(),
953 key_pressrelease.into_glib(),
954 ))
955 }
956}
957
958/// Converts a text property in the given encoding to
959/// a list of UTF-8 strings.
960/// ## `display`
961/// a [`Display`][crate::Display]
962/// ## `encoding`
963/// an atom representing the encoding of the text
964/// ## `format`
965/// the format of the property
966/// ## `text`
967/// the text to convert
968///
969/// # Returns
970///
971/// the number of strings in the resulting list
972///
973/// ## `list`
974/// location to store the list
975/// of strings or [`None`]. The list should be freed with
976/// `g_strfreev()`.
977#[doc(alias = "gdk_text_property_to_utf8_list_for_display")]
978pub fn text_property_to_utf8_list_for_display(
979 display: &Display,
980 encoding: &Atom,
981 format: i32,
982 text: &[u8],
983) -> (i32, Vec<glib::GString>) {
984 skip_assert_initialized!();
985 let length = text.len() as _;
986 unsafe {
987 let mut list = ptr::null_mut();
988 let ret = ffi::gdk_text_property_to_utf8_list_for_display(
989 display.to_glib_none().0,
990 encoding.to_glib_none().0,
991 format,
992 text.to_glib_none().0,
993 length,
994 &mut list,
995 );
996 (ret, FromGlibPtrContainer::from_glib_full(list))
997 }
998}
999
1000/// Converts an UTF-8 string into the best possible representation
1001/// as a STRING. The representation of characters not in STRING
1002/// is not specified; it may be as pseudo-escape sequences
1003/// \x{ABCD}, or it may be in some other form of approximation.
1004/// ## `str`
1005/// a UTF-8 string
1006///
1007/// # Returns
1008///
1009/// the newly-allocated string, or [`None`] if the
1010/// conversion failed. (It should not fail for any properly
1011/// formed UTF-8 string unless system limits like memory or
1012/// file descriptors are exceeded.)
1013#[doc(alias = "gdk_utf8_to_string_target")]
1014pub fn utf8_to_string_target(str: &str) -> Option<glib::GString> {
1015 assert_initialized_main_thread!();
1016 unsafe { from_glib_full(ffi::gdk_utf8_to_string_target(str.to_glib_none().0)) }
1017}