1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gdk.Gdk;
26 
27 private import gdk.Cursor;
28 private import gdk.Window;
29 private import glib.Str;
30 private import gtkc.gdk;
31 public  import gtkc.gdktypes;
32 
33 
34 public struct Gdk
35 {
36 	/**
37 	 */
38 
39 	/**
40 	 * Emits a short beep on the default display.
41 	 */
42 	public static void beep()
43 	{
44 		gdk_beep();
45 	}
46 
47 	/**
48 	 * Removes an error trap pushed with gdk_error_trap_push().
49 	 * May block until an error has been definitively received
50 	 * or not received from the X server. gdk_error_trap_pop_ignored()
51 	 * is preferred if you don’t need to know whether an error
52 	 * occurred, because it never has to block. If you don't
53 	 * need the return value of gdk_error_trap_pop(), use
54 	 * gdk_error_trap_pop_ignored().
55 	 *
56 	 * Prior to GDK 3.0, this function would not automatically
57 	 * sync for you, so you had to gdk_flush() if your last
58 	 * call to Xlib was not a blocking round trip.
59 	 *
60 	 * Return: X error code or 0 on success
61 	 */
62 	public static int errorTrapPop()
63 	{
64 		return gdk_error_trap_pop();
65 	}
66 
67 	/**
68 	 * Removes an error trap pushed with gdk_error_trap_push(), but
69 	 * without bothering to wait and see whether an error occurred.  If an
70 	 * error arrives later asynchronously that was triggered while the
71 	 * trap was pushed, that error will be ignored.
72 	 *
73 	 * Since: 3.0
74 	 */
75 	public static void errorTrapPopIgnored()
76 	{
77 		gdk_error_trap_pop_ignored();
78 	}
79 
80 	/**
81 	 * This function allows X errors to be trapped instead of the normal
82 	 * behavior of exiting the application. It should only be used if it
83 	 * is not possible to avoid the X error in any other way. Errors are
84 	 * ignored on all #GdkDisplay currently known to the
85 	 * #GdkDisplayManager. If you don’t care which error happens and just
86 	 * want to ignore everything, pop with gdk_error_trap_pop_ignored().
87 	 * If you need the error code, use gdk_error_trap_pop() which may have
88 	 * to block and wait for the error to arrive from the X server.
89 	 *
90 	 * This API exists on all platforms but only does anything on X.
91 	 *
92 	 * You can use gdk_x11_display_error_trap_push() to ignore errors
93 	 * on only a single display.
94 	 *
95 	 * ## Trapping an X error
96 	 *
97 	 * |[<!-- language="C" -->
98 	 * gdk_error_trap_push ();
99 	 *
100 	 * // ... Call the X function which may cause an error here ...
101 	 *
102 	 *
103 	 * if (gdk_error_trap_pop ())
104 	 * {
105 	 * // ... Handle the error here ...
106 	 * }
107 	 * ]|
108 	 */
109 	public static void errorTrapPush()
110 	{
111 		gdk_error_trap_push();
112 	}
113 
114 	/**
115 	 * Flushes the output buffers of all display connections and waits
116 	 * until all requests have been processed.
117 	 * This is rarely needed by applications.
118 	 */
119 	public static void flush()
120 	{
121 		gdk_flush();
122 	}
123 
124 	/**
125 	 * Gets the name of the display, which usually comes from the
126 	 * `DISPLAY` environment variable or the
127 	 * `--display` command line option.
128 	 *
129 	 * Deprecated: Call gdk_display_get_name (gdk_display_get_default ()))
130 	 * instead.
131 	 *
132 	 * Return: the name of the display.
133 	 */
134 	public static string getDisplay()
135 	{
136 		return Str.toString(gdk_get_display());
137 	}
138 
139 	/**
140 	 * Gets the display name specified in the command line arguments passed
141 	 * to gdk_init() or gdk_parse_args(), if any.
142 	 *
143 	 * Return: the display name, if specified explicitly,
144 	 *     otherwise %NULL this string is owned by GTK+ and must not be
145 	 *     modified or freed.
146 	 *
147 	 * Since: 2.2
148 	 */
149 	public static string getDisplayArgName()
150 	{
151 		return Str.toString(gdk_get_display_arg_name());
152 	}
153 
154 	/**
155 	 * Gets the program class. Unless the program class has explicitly
156 	 * been set with gdk_set_program_class() or with the `--class`
157 	 * commandline option, the default value is the program name (determined
158 	 * with g_get_prgname()) with the first character converted to uppercase.
159 	 *
160 	 * Return: the program class.
161 	 */
162 	public static string getProgramClass()
163 	{
164 		return Str.toString(gdk_get_program_class());
165 	}
166 
167 	/**
168 	 * Initializes the GDK library and connects to the windowing system.
169 	 * If initialization fails, a warning message is output and the application
170 	 * terminates with a call to `exit(1)`.
171 	 *
172 	 * Any arguments used by GDK are removed from the array and @argc and @argv
173 	 * are updated accordingly.
174 	 *
175 	 * GTK+ initializes GDK in gtk_init() and so this function is not usually
176 	 * needed by GTK+ applications.
177 	 *
178 	 * Params:
179 	 *     argc = the number of command line arguments.
180 	 *     argv = the array of command line arguments.
181 	 */
182 	public static void init(ref string[] argv)
183 	{
184 		int argc = cast(int)argv.length;
185 		char** outargv = Str.toStringzArray(argv);
186 		
187 		gdk_init(&argc, &outargv);
188 		
189 		argv = Str.toStringArray(outargv, argc);
190 	}
191 
192 	/**
193 	 * Initializes the GDK library and connects to the windowing system,
194 	 * returning %TRUE on success.
195 	 *
196 	 * Any arguments used by GDK are removed from the array and @argc and @argv
197 	 * are updated accordingly.
198 	 *
199 	 * GTK+ initializes GDK in gtk_init() and so this function is not usually
200 	 * needed by GTK+ applications.
201 	 *
202 	 * Params:
203 	 *     argc = the number of command line arguments.
204 	 *     argv = the array of command line arguments.
205 	 *
206 	 * Return: %TRUE if initialization succeeded.
207 	 */
208 	public static bool initCheck(ref string[] argv)
209 	{
210 		int argc = cast(int)argv.length;
211 		char** outargv = Str.toStringzArray(argv);
212 		
213 		auto p = gdk_init_check(&argc, &outargv) != 0;
214 		
215 		argv = Str.toStringArray(outargv, argc);
216 		
217 		return p;
218 	}
219 
220 	/**
221 	 * Grabs the keyboard so that all events are passed to this
222 	 * application until the keyboard is ungrabbed with gdk_keyboard_ungrab().
223 	 * This overrides any previous keyboard grab by this client.
224 	 *
225 	 * If you set up anything at the time you take the grab that needs to be cleaned
226 	 * up when the grab ends, you should handle the #GdkEventGrabBroken events that
227 	 * are emitted when the grab ends unvoluntarily.
228 	 *
229 	 * Deprecated: Use gdk_device_grab() instead.
230 	 *
231 	 * Params:
232 	 *     window = the #GdkWindow which will own the grab (the grab window).
233 	 *     ownerEvents = if %FALSE then all keyboard events are reported with respect to
234 	 *         @window. If %TRUE then keyboard events for this application are
235 	 *         reported as normal, but keyboard events outside this application
236 	 *         are reported with respect to @window. Both key press and key
237 	 *         release events are always reported, independant of the event mask
238 	 *         set by the application.
239 	 *     time = a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no timestamp is
240 	 *         available.
241 	 *
242 	 * Return: %GDK_GRAB_SUCCESS if the grab was successful.
243 	 */
244 	public static GdkGrabStatus keyboardGrab(Window window, bool ownerEvents, uint time)
245 	{
246 		return gdk_keyboard_grab((window is null) ? null : window.getWindowStruct(), ownerEvents, time);
247 	}
248 
249 	/**
250 	 * Ungrabs the keyboard on the default display, if it is grabbed by this
251 	 * application.
252 	 *
253 	 * Deprecated: Use gdk_device_ungrab(), together with gdk_device_grab()
254 	 * instead.
255 	 *
256 	 * Params:
257 	 *     time = a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no
258 	 *         timestamp is available.
259 	 */
260 	public static void keyboardUngrab(uint time)
261 	{
262 		gdk_keyboard_ungrab(time);
263 	}
264 
265 	/**
266 	 * Indicates to the GUI environment that the application has finished
267 	 * loading. If the applications opens windows, this function is
268 	 * normally called after opening the application’s initial set of
269 	 * windows.
270 	 *
271 	 * GTK+ will call this function automatically after opening the first
272 	 * #GtkWindow unless gtk_window_set_auto_startup_notification() is called
273 	 * to disable that feature.
274 	 *
275 	 * Since: 2.2
276 	 */
277 	public static void notifyStartupComplete()
278 	{
279 		gdk_notify_startup_complete();
280 	}
281 
282 	/**
283 	 * Indicates to the GUI environment that the application has
284 	 * finished loading, using a given identifier.
285 	 *
286 	 * GTK+ will call this function automatically for #GtkWindow
287 	 * with custom startup-notification identifier unless
288 	 * gtk_window_set_auto_startup_notification() is called to
289 	 * disable that feature.
290 	 *
291 	 * Params:
292 	 *     startupId = a startup-notification identifier, for which
293 	 *         notification process should be completed
294 	 *
295 	 * Since: 2.12
296 	 */
297 	public static void notifyStartupCompleteWithId(string startupId)
298 	{
299 		gdk_notify_startup_complete_with_id(Str.toStringz(startupId));
300 	}
301 
302 	/**
303 	 * Parse command line arguments, and store for future
304 	 * use by calls to gdk_display_open().
305 	 *
306 	 * Any arguments used by GDK are removed from the array and @argc and @argv are
307 	 * updated accordingly.
308 	 *
309 	 * You shouldn’t call this function explicitly if you are using
310 	 * gtk_init(), gtk_init_check(), gdk_init(), or gdk_init_check().
311 	 *
312 	 * Params:
313 	 *     argc = the number of command line arguments.
314 	 *     argv = the array of command line arguments.
315 	 *
316 	 * Since: 2.2
317 	 */
318 	public static void parseArgs(ref string[] argv)
319 	{
320 		int argc = cast(int)argv.length;
321 		char** outargv = Str.toStringzArray(argv);
322 		
323 		gdk_parse_args(&argc, &outargv);
324 		
325 		argv = Str.toStringArray(outargv, argc);
326 	}
327 
328 	/**
329 	 * Grabs the pointer (usually a mouse) so that all events are passed to this
330 	 * application until the pointer is ungrabbed with gdk_pointer_ungrab(), or
331 	 * the grab window becomes unviewable.
332 	 * This overrides any previous pointer grab by this client.
333 	 *
334 	 * Pointer grabs are used for operations which need complete control over mouse
335 	 * events, even if the mouse leaves the application.
336 	 * For example in GTK+ it is used for Drag and Drop, for dragging the handle in
337 	 * the #GtkHPaned and #GtkVPaned widgets.
338 	 *
339 	 * Note that if the event mask of an X window has selected both button press and
340 	 * button release events, then a button press event will cause an automatic
341 	 * pointer grab until the button is released.
342 	 * X does this automatically since most applications expect to receive button
343 	 * press and release events in pairs.
344 	 * It is equivalent to a pointer grab on the window with @owner_events set to
345 	 * %TRUE.
346 	 *
347 	 * If you set up anything at the time you take the grab that needs to be cleaned
348 	 * up when the grab ends, you should handle the #GdkEventGrabBroken events that
349 	 * are emitted when the grab ends unvoluntarily.
350 	 *
351 	 * Deprecated: Use gdk_device_grab() instead.
352 	 *
353 	 * Params:
354 	 *     window = the #GdkWindow which will own the grab (the grab window).
355 	 *     ownerEvents = if %FALSE then all pointer events are reported with respect to
356 	 *         @window and are only reported if selected by @event_mask. If %TRUE then pointer
357 	 *         events for this application are reported as normal, but pointer events outside
358 	 *         this application are reported with respect to @window and only if selected by
359 	 *         @event_mask. In either mode, unreported events are discarded.
360 	 *     eventMask = specifies the event mask, which is used in accordance with
361 	 *         @owner_events. Note that only pointer events (i.e. button and motion events)
362 	 *         may be selected.
363 	 *     confineTo = If non-%NULL, the pointer will be confined to this
364 	 *         window during the grab. If the pointer is outside @confine_to, it will
365 	 *         automatically be moved to the closest edge of @confine_to and enter
366 	 *         and leave events will be generated as necessary.
367 	 *     cursor = the cursor to display while the grab is active. If this is %NULL then
368 	 *         the normal cursors are used for @window and its descendants, and the cursor
369 	 *         for @window is used for all other windows.
370 	 *     time = the timestamp of the event which led to this pointer grab. This usually
371 	 *         comes from a #GdkEventButton struct, though %GDK_CURRENT_TIME can be used if
372 	 *         the time isn’t known.
373 	 *
374 	 * Return: %GDK_GRAB_SUCCESS if the grab was successful.
375 	 */
376 	public static GdkGrabStatus pointerGrab(Window window, bool ownerEvents, GdkEventMask eventMask, Window confineTo, Cursor cursor, uint time)
377 	{
378 		return gdk_pointer_grab((window is null) ? null : window.getWindowStruct(), ownerEvents, eventMask, (confineTo is null) ? null : confineTo.getWindowStruct(), (cursor is null) ? null : cursor.getCursorStruct(), time);
379 	}
380 
381 	/**
382 	 * Returns %TRUE if the pointer on the default display is currently
383 	 * grabbed by this application.
384 	 *
385 	 * Note that this does not take the inmplicit pointer grab on button
386 	 * presses into account.
387 	 *
388 	 * Deprecated: Use gdk_display_device_is_grabbed() instead.
389 	 *
390 	 * Return: %TRUE if the pointer is currently grabbed by this application.
391 	 */
392 	public static bool pointerIsGrabbed()
393 	{
394 		return gdk_pointer_is_grabbed() != 0;
395 	}
396 
397 	/**
398 	 * Ungrabs the pointer on the default display, if it is grabbed by this
399 	 * application.
400 	 *
401 	 * Deprecated: Use gdk_device_ungrab(), together with gdk_device_grab()
402 	 * instead.
403 	 *
404 	 * Params:
405 	 *     time = a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no
406 	 *         timestamp is available.
407 	 */
408 	public static void pointerUngrab(uint time)
409 	{
410 		gdk_pointer_ungrab(time);
411 	}
412 
413 	/**
414 	 * Sets a list of backends that GDK should try to use.
415 	 *
416 	 * This can be be useful if your application does not
417 	 * work with certain GDK backends.
418 	 *
419 	 * By default, GDK tries all included backends.
420 	 *
421 	 * For example,
422 	 * |[<!-- language="C" -->
423 	 * gdk_set_allowed_backends ("wayland,quartz,*");
424 	 * ]|
425 	 * instructs GDK to try the Wayland backend first,
426 	 * followed by the Quartz backend, and then all
427 	 * others.
428 	 *
429 	 * If the `GDK_BACKEND` environment variable
430 	 * is set, it determines what backends are tried in what
431 	 * order, while still respecting the set of allowed backends
432 	 * that are specified by this function.
433 	 *
434 	 * The possible backend names are x11, win32, quartz,
435 	 * broadway, wayland. You can also include a * in the
436 	 * list to try all remaining backends.
437 	 *
438 	 * This call must happen prior to gdk_display_open(),
439 	 * gtk_init(), gtk_init_with_args() or gtk_init_check()
440 	 * in order to take effect.
441 	 *
442 	 * Params:
443 	 *     backends = a comma-separated list of backends
444 	 *
445 	 * Since: 3.10
446 	 */
447 	public static void setAllowedBackends(string backends)
448 	{
449 		gdk_set_allowed_backends(Str.toStringz(backends));
450 	}
451 
452 	/**
453 	 * Set the double click time for the default display. See
454 	 * gdk_display_set_double_click_time().
455 	 * See also gdk_display_set_double_click_distance().
456 	 * Applications should not set this, it is a
457 	 * global user-configured setting.
458 	 *
459 	 * Params:
460 	 *     msec = double click time in milliseconds (thousandths of a second)
461 	 */
462 	public static void setDoubleClickTime(uint msec)
463 	{
464 		gdk_set_double_click_time(msec);
465 	}
466 
467 	/**
468 	 * Sets the program class. The X11 backend uses the program class to set
469 	 * the class name part of the `WM_CLASS` property on
470 	 * toplevel windows; see the ICCCM.
471 	 *
472 	 * Params:
473 	 *     programClass = a string.
474 	 */
475 	public static void setProgramClass(string programClass)
476 	{
477 		gdk_set_program_class(Str.toStringz(programClass));
478 	}
479 }