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