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