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