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 * Conversion parameters: 26 * inFile = gdk3-X-Window-System-Interaction.html 27 * outPack = gdk 28 * outFile = X11 29 * strct = 30 * realStrct= 31 * ctorStrct= 32 * clss = X11 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gdk_x11_ 41 * omit structs: 42 * omit prefixes: 43 * - gdkx_visual_get 44 * - gdkx_colormap_get 45 * - gdk_pixmap_foreign_new 46 * - gdk_pixmap_foreign_new_for_display 47 * - gdk_pixmap_foreign_new_for_screen 48 * - gdk_window_foreign_new_for_display 49 * - gdk_xid_table_lookup_for_display 50 * - gdk_window_lookup_for_display 51 * - gdk_x11_lookup_xdisplay 52 * - gdk_net_wm_supports 53 * - gdk_x11_screen_supports_net_wm_hint 54 * - gdk_x11_screen_get_window_manager_name 55 * - gdk_x11_screen_lookup_visual 56 * - gdk_x11_display_get_user_time 57 * - gdk_x11_colormap_foreign_new 58 * - gdk_x11_colormap_get_xcolormap 59 * - gdk_x11_colormap_get_xdisplay 60 * - gdk_x11_cursor_get_xcursor 61 * - gdk_x11_cursor_get_xdisplay 62 * - gdk_x11_display_get_xdisplay 63 * - gdk_x11_display_grab 64 * - gdk_x11_display_ungrab 65 * - gdk_x11_display_set_cursor_theme 66 * - gdk_x11_register_standard_event_type 67 * - gdk_x11_drawable_get_xdisplay 68 * - gdk_x11_font_get_xdisplay 69 * - gdk_x11_gc_get_xdisplay 70 * - gdk_x11_gc_get_xgc 71 * - gdk_x11_get_default_root_xwindow 72 * - gdk_x11_get_default_xdisplay 73 * - gdk_x11_image_get_xdisplay 74 * - gdk_x11_image_get_ximage 75 * - gdk_x11_screen_get_screen_number 76 * - gdk_x11_screen_get_xscreen 77 * - gdk_x11_visual_get_xvisual 78 * - gdk_x11_atom_to_xatom 79 * - gdk_x11_atom_to_xatom_for_display 80 * - gdk_x11_xatom_to_atom 81 * - gdk_x11_xatom_to_atom_for_display 82 * - gdk_x11_get_xatom_by_name 83 * - gdk_x11_get_xatom_by_name_for_display 84 * - gdk_x11_get_xatom_name 85 * - gdk_x11_get_xatom_name_for_display 86 * - gdk_x11_window_foreign_new_for_display 87 * - gdk_x11_window_lookup_for_display 88 * omit code: 89 * - gdk_x11_window_get_xid 90 * omit signals: 91 * imports: 92 * - glib.Str 93 * - gdk.Device 94 * - gdk.DeviceManager 95 * - gdk.Display 96 * - gdk.Keymap 97 * - gdk.Screen 98 * - gdk.Window 99 * structWrap: 100 * - GdkDevice* -> Device 101 * - GdkDeviceManager* -> DeviceManager 102 * - GdkDisplay* -> Display 103 * - GdkKeymap* -> Keymap 104 * - GdkScreen* -> Screen 105 * - GdkWindow* -> Window 106 * module aliases: 107 * local aliases: 108 * overrides: 109 */ 110 111 module gdk.X11; 112 113 public import gtkc.gdktypes; 114 115 private import gtkc.gdk; 116 private import glib.ConstructionException; 117 private import gobject.ObjectG; 118 119 120 private import glib.Str; 121 private import gdk.Device; 122 private import gdk.DeviceManager; 123 private import gdk.Display; 124 private import gdk.Keymap; 125 private import gdk.Screen; 126 private import gdk.Window; 127 128 129 130 131 /** 132 * The functions in this section are specific to the GDK X11 backend. 133 * To use them, you need to include the <gdk/gdkx.h> 134 * header and use the X11-specific pkg-config files to build your 135 * application (either gdk-x11-3.0 or 136 * gtk+-x11-3.0). 137 * 138 * To make your code compile with other GDK backends, guard backend-specific 139 * calls by an ifdef as follows. Since GDK may be built with multiple 140 * backends, you should also check for the backend that is in use (e.g. by 141 * using the GDK_IS_X11_DISPLAY() macro). 142 * 143 * $(DDOC_COMMENT example) 144 */ 145 public class X11 146 { 147 148 /** 149 * Returns the X resource (window) belonging to a GdkWindow. 150 * Params: 151 * window = a native GdkWindow. 152 * Returns: the ID of drawable's X resource. 153 */ 154 public static gulong windowGetXid(Window window) 155 { 156 // Window gdk_x11_window_get_xid (GdkWindow *window); 157 return gdk_x11_window_get_xid((window is null) ? null : window.getWindowStruct()); 158 } 159 160 /** 161 */ 162 163 /** 164 * Routine to get the current X server time stamp. 165 * Params: 166 * window = a GdkWindow, used for communication 167 * with the server. The window must have 168 * GDK_PROPERTY_CHANGE_MASK in its events mask or a hang will 169 * result. [type GdkX11Window] 170 * Returns: the time stamp. 171 */ 172 public static uint getServerTime(Window window) 173 { 174 // guint32 gdk_x11_get_server_time (GdkWindow *window); 175 return gdk_x11_get_server_time((window is null) ? null : window.getWindowStruct()); 176 } 177 178 /** 179 * Returns the device ID as seen by XInput2. 180 * Note 181 * If gdk_disable_multidevice() has been called, this function 182 * will respectively return 2/3 for the core pointer and keyboard, 183 * (matching the IDs for the Virtual Core Pointer and Keyboard in 184 * XInput 2), but calling this function on any slave devices (i.e. 185 * those managed via XInput 1.x), will return 0. 186 * Params: 187 * device = a GdkDevice 188 * Returns: the XInput2 device ID. Since 3.2 189 */ 190 public static int deviceGetId(Device device) 191 { 192 // gint gdk_x11_device_get_id (GdkDevice *device); 193 return gdk_x11_device_get_id((device is null) ? null : device.getDeviceStruct()); 194 } 195 196 /** 197 * Returns the GdkDevice that wraps the given device ID. 198 * Params: 199 * deviceManager = a GdkDeviceManager 200 * deviceId = a device ID, as understood by the XInput2 protocol 201 * Returns: (allow-none): The GdkDevice wrapping the device ID, or NULL if the given ID doesn't currently represent a device. [transfer none] Since 3.2 202 */ 203 public static Device deviceManagerLookup(DeviceManager deviceManager, int deviceId) 204 { 205 // GdkDevice * gdk_x11_device_manager_lookup (GdkDeviceManager *device_manager, gint device_id); 206 auto p = gdk_x11_device_manager_lookup((deviceManager is null) ? null : deviceManager.getDeviceManagerStruct(), deviceId); 207 208 if(p is null) 209 { 210 return null; 211 } 212 213 return ObjectG.getDObject!(Device)(cast(GdkDevice*) p); 214 } 215 216 /** 217 * Gets the startup notification ID for a display. 218 * Since 2.12 219 * Params: 220 * display = a GdkDisplay. [type GdkX11Display] 221 * Returns: the startup notification ID for display 222 */ 223 public static string displayGetStartupNotificationId(Display display) 224 { 225 // const gchar * gdk_x11_display_get_startup_notification_id (GdkDisplay *display); 226 return Str.toString(gdk_x11_display_get_startup_notification_id((display is null) ? null : display.getDisplayStruct())); 227 } 228 229 /** 230 * Sets the startup notification ID for a display. 231 * This is usually taken from the value of the DESKTOP_STARTUP_ID 232 * environment variable, but in some cases (such as the application not 233 * being launched using exec()) it can come from other sources. 234 * If the ID contains the string "_TIME" then the portion following that 235 * string is taken to be the X11 timestamp of the event that triggered 236 * the application to be launched and the GDK current event time is set 237 * accordingly. 238 * The startup ID is also what is used to signal that the startup is 239 * complete (for example, when opening a window or when calling 240 * gdk_notify_startup_complete()). 241 * Params: 242 * display = a GdkDisplay. [type GdkX11Display] 243 * startupId = the startup notification ID (must be valid utf8) 244 * Since 3.0 245 */ 246 public static void displaySetStartupNotificationId(Display display, string startupId) 247 { 248 // void gdk_x11_display_set_startup_notification_id (GdkDisplay *display, const gchar *startup_id); 249 gdk_x11_display_set_startup_notification_id((display is null) ? null : display.getDisplayStruct(), Str.toStringz(startupId)); 250 } 251 252 /** 253 * Begins a range of X requests on display for which X error events 254 * will be ignored. Unignored errors (when no trap is pushed) will abort 255 * the application. Use gdk_x11_display_error_trap_pop() or 256 * gdk_x11_display_error_trap_pop_ignored()to lift a trap pushed 257 * with this function. 258 * See also gdk_error_trap_push() to push a trap on all displays. 259 * Params: 260 * display = a GdkDisplay. [type GdkX11Display] 261 * Since 3.0 262 */ 263 public static void displayErrorTrapPush(Display display) 264 { 265 // void gdk_x11_display_error_trap_push (GdkDisplay *display); 266 gdk_x11_display_error_trap_push((display is null) ? null : display.getDisplayStruct()); 267 } 268 269 /** 270 * Pops the error trap pushed by gdk_x11_display_error_trap_push(). 271 * Will XSync() if necessary and will always block until 272 * the error is known to have occurred or not occurred, 273 * so the error code can be returned. 274 * If you don't need to use the return value, 275 * gdk_x11_display_error_trap_pop_ignored() would be more efficient. 276 * See gdk_error_trap_pop() for the all-displays-at-once 277 * equivalent. 278 * Params: 279 * display = the display. [type GdkX11Display] 280 * Returns: X error code or 0 on success Since 3.0 281 */ 282 public static int displayErrorTrapPop(Display display) 283 { 284 // gint gdk_x11_display_error_trap_pop (GdkDisplay *display); 285 return gdk_x11_display_error_trap_pop((display is null) ? null : display.getDisplayStruct()); 286 } 287 288 /** 289 * Pops the error trap pushed by gdk_x11_display_error_trap_push(). 290 * Does not block to see if an error occurred; merely records the 291 * range of requests to ignore errors for, and ignores those errors 292 * if they arrive asynchronously. 293 * See gdk_error_trap_pop_ignored() for the all-displays-at-once 294 * equivalent. 295 * Params: 296 * display = the display. [type GdkX11Display] 297 * Since 3.0 298 */ 299 public static void displayErrorTrapPopIgnored(Display display) 300 { 301 // void gdk_x11_display_error_trap_pop_ignored (GdkDisplay *display); 302 gdk_x11_display_error_trap_pop_ignored((display is null) ? null : display.getDisplayStruct()); 303 } 304 305 /** 306 * Forces a specific window scale for all windows on this display, 307 * instead of using the default or user configured scale. This 308 * is can be used to disable scaling support by setting scale to 309 * 1, or to programmatically set the window scale. 310 * Once the scale is set by this call it will not change in response 311 * to later user configuration changes. 312 * Params: 313 * display = the display. [type GdkX11Display] 314 * scale = The new scale value 315 * Since 3.10 316 */ 317 public static void displaySetWindowScale(Display display, int scale) 318 { 319 // void gdk_x11_display_set_window_scale (GdkDisplay *display, gint scale); 320 gdk_x11_display_set_window_scale((display is null) ? null : display.getDisplayStruct(), scale); 321 } 322 323 /** 324 * Gets the XID of the specified output/monitor. 325 * If the X server does not support version 1.2 of the RANDR 326 * extension, 0 is returned. 327 * Since 2.14 328 * Params: 329 * screen = a GdkScreen. [type GdkX11Screen] 330 * monitorNum = number of the monitor, between 0 and gdk_screen_get_n_monitors (screen) 331 * Returns: the XID of the monitor 332 */ 333 public static uint screenGetMonitorOutput(Screen screen, int monitorNum) 334 { 335 // XID gdk_x11_screen_get_monitor_output (GdkScreen *screen, gint monitor_num); 336 return gdk_x11_screen_get_monitor_output((screen is null) ? null : screen.getScreenStruct(), monitorNum); 337 } 338 339 /** 340 * Returns the number of workspaces for screen when running under a 341 * window manager that supports multiple workspaces, as described 342 * in the Extended 343 * Window Manager Hints. 344 * Params: 345 * screen = a GdkScreen 346 * Returns: the number of workspaces, or 0 if workspaces are not supported Since 3.10 347 */ 348 public static uint screenGetNumberOfDesktops(Screen screen) 349 { 350 // guint32 gdk_x11_screen_get_number_of_desktops (GdkScreen *screen); 351 return gdk_x11_screen_get_number_of_desktops((screen is null) ? null : screen.getScreenStruct()); 352 } 353 354 /** 355 * Returns the current workspace for screen when running under a 356 * window manager that supports multiple workspaces, as described 357 * in the Extended 358 * Window Manager Hints. 359 * Params: 360 * screen = a GdkScreen 361 * Returns: the current workspace, or 0 if workspaces are not supported Since 3.10 362 */ 363 public static uint screenGetCurrentDesktop(Screen screen) 364 { 365 // guint32 gdk_x11_screen_get_current_desktop (GdkScreen *screen); 366 return gdk_x11_screen_get_current_desktop((screen is null) ? null : screen.getScreenStruct()); 367 } 368 369 /** 370 * Set a hint for the window manager, requesting that the titlebar 371 * should be hidden when the window is maximized. 372 * Note that this property is automatically updated by GTK+, so this 373 * function should only be used by applications which do not use GTK+ 374 * to create toplevel windows. 375 * Params: 376 * window = a GdkWindow. [type GdkX11Window] 377 * hideTitlebarWhenMaximized = whether to hide the titlebar when 378 * maximized 379 * Since 3.4 380 */ 381 public static void windowSetHideTitlebarWhenMaximized(Window window, int hideTitlebarWhenMaximized) 382 { 383 // void gdk_x11_window_set_hide_titlebar_when_maximized (GdkWindow *window, gboolean hide_titlebar_when_maximized); 384 gdk_x11_window_set_hide_titlebar_when_maximized((window is null) ? null : window.getWindowStruct(), hideTitlebarWhenMaximized); 385 } 386 387 /** 388 * GTK+ applications can request a dark theme variant. In order to 389 * make other applications - namely window managers using GTK+ for 390 * themeing - aware of this choice, GTK+ uses this function to 391 * export the requested theme variant as _GTK_THEME_VARIANT property 392 * on toplevel windows. 393 * Note that this property is automatically updated by GTK+, so this 394 * function should only be used by applications which do not use GTK+ 395 * to create toplevel windows. 396 * Params: 397 * window = a GdkWindow. [type GdkX11Window] 398 * variant = the theme variant to export 399 * Since 3.2 400 */ 401 public static void windowSetThemeVariant(Window window, string variant) 402 { 403 // void gdk_x11_window_set_theme_variant (GdkWindow *window, char *variant); 404 gdk_x11_window_set_theme_variant((window is null) ? null : window.getWindowStruct(), Str.toStringz(variant)); 405 } 406 407 /** 408 * The application can use this call to update the _NET_WM_USER_TIME 409 * property on a toplevel window. This property stores an Xserver 410 * time which represents the time of the last user input event 411 * received for this window. This property may be used by the window 412 * manager to alter the focus, stacking, and/or placement behavior of 413 * windows when they are mapped depending on whether the new window 414 * was created by a user action or is a "pop-up" window activated by a 415 * timer or some other event. 416 * Note that this property is automatically updated by GDK, so this 417 * function should only be used by applications which handle input 418 * events bypassing GDK. 419 * Since 2.6 420 * Params: 421 * window = A toplevel GdkWindow. [type GdkX11Window] 422 * timestamp = An XServer timestamp to which the property should be set 423 */ 424 public static void windowSetUserTime(Window window, uint timestamp) 425 { 426 // void gdk_x11_window_set_user_time (GdkWindow *window, guint32 timestamp); 427 gdk_x11_window_set_user_time((window is null) ? null : window.getWindowStruct(), timestamp); 428 } 429 430 /** 431 * Moves the window to the correct workspace when running under a 432 * window manager that supports multiple workspaces, as described 433 * in the Extended 434 * Window Manager Hints. Will not do anything if the 435 * window is already on all workspaces. 436 * Since 2.8 437 * Params: 438 * window = a GdkWindow. [type GdkX11Window] 439 */ 440 public static void windowMoveToCurrentDesktop(Window window) 441 { 442 // void gdk_x11_window_move_to_current_desktop (GdkWindow *window); 443 gdk_x11_window_move_to_current_desktop((window is null) ? null : window.getWindowStruct()); 444 } 445 446 /** 447 * Moves the window to the given workspace when running unde a 448 * window manager that supports multiple workspaces, as described 449 * in the Extended 450 * Window Manager Hints. 451 * Params: 452 * window = a GdkWindow 453 * desktop = the number of the workspace to move the window to 454 * Since 3.10 455 */ 456 public static void windowMoveToDesktop(Window window, uint desktop) 457 { 458 // void gdk_x11_window_move_to_desktop (GdkWindow *window, guint32 desktop); 459 gdk_x11_window_move_to_desktop((window is null) ? null : window.getWindowStruct(), desktop); 460 } 461 462 /** 463 * Gets the number of the workspace window is on. 464 * Params: 465 * window = a GdkWindow 466 * Returns: the current workspace of window Since 3.10 467 */ 468 public static uint windowGetDesktop(Window window) 469 { 470 // guint32 gdk_x11_window_get_desktop (GdkWindow *window); 471 return gdk_x11_window_get_desktop((window is null) ? null : window.getWindowStruct()); 472 } 473 474 /** 475 * This function modifies or removes an arbitrary X11 window 476 * property of type UTF8_STRING. If the given window is 477 * not a toplevel window, it is ignored. 478 * Params: 479 * window = a GdkWindow. [type GdkX11Window] 480 * name = Property name, will be interned as an X atom 481 * value = Property value, or NULL to delete. [allow-none] 482 * Since 3.4 483 */ 484 public static void windowSetUtf8_Property(Window window, string name, string value) 485 { 486 // void gdk_x11_window_set_utf8_property (GdkWindow *window, const gchar *name, const gchar *value); 487 gdk_x11_window_set_utf8_property((window is null) ? null : window.getWindowStruct(), Str.toStringz(name), Str.toStringz(value)); 488 } 489 490 /** 491 * Newer GTK+ windows using client-side decorations use extra geometry 492 * around their frames for effects like shadows and invisible borders. 493 * Window managers that want to maximize windows or snap to edges need 494 * to know where the extents of the actual frame lie, so that users 495 * don't feel like windows are snapping against random invisible edges. 496 * Note that this property is automatically updated by GTK+, so this 497 * function should only be used by applications which do not use GTK+ 498 * to create toplevel windows. 499 * Params: 500 * window = a GdkWindow. [type GdkX11Window] 501 * left = The left extent 502 * right = The right extent 503 * top = The top extent 504 * bottom = The bottom extent 505 * Since 3.10 506 */ 507 public static void windowSetFrameExtents(Window window, int left, int right, int top, int bottom) 508 { 509 // void gdk_x11_window_set_frame_extents (GdkWindow *window, int left, int right, int top, int bottom); 510 gdk_x11_window_set_frame_extents((window is null) ? null : window.getWindowStruct(), left, right, top, bottom); 511 } 512 513 /** 514 * This function can be used to disable frame synchronization for a window. 515 * Normally frame synchronziation will be enabled or disabled based on whether 516 * the system has a compositor that supports frame synchronization, but if 517 * the window is not directly managed by the window manager, then frame 518 * synchronziation may need to be disabled. This is the case for a window 519 * embedded via the XEMBED protocol. 520 * Params: 521 * window = a native GdkWindow. [type GdkX11Window] 522 * frameSyncEnabled = whether frame-synchronization should be enabled 523 * Since 3.8 524 */ 525 public static void windowSetFrameSyncEnabled(Window window, int frameSyncEnabled) 526 { 527 // void gdk_x11_window_set_frame_sync_enabled (GdkWindow *window, gboolean frame_sync_enabled); 528 gdk_x11_window_set_frame_sync_enabled((window is null) ? null : window.getWindowStruct(), frameSyncEnabled); 529 } 530 531 /** 532 * Gets the default GTK+ screen number. 533 * Returns: returns the screen number specified by the --display command line option or the DISPLAY environment variable when gdk_init() calls XOpenDisplay(). 534 */ 535 public static int getDefaultScreen() 536 { 537 // gint gdk_x11_get_default_screen (void); 538 return gdk_x11_get_default_screen(); 539 } 540 541 /** 542 * Call gdk_x11_display_grab() on the default display. 543 * To ungrab the server again, use gdk_x11_ungrab_server(). 544 * gdk_x11_grab_server()/gdk_x11_ungrab_server() calls can be nested. 545 */ 546 public static void grabServer() 547 { 548 // void gdk_x11_grab_server (void); 549 gdk_x11_grab_server(); 550 } 551 552 /** 553 * Ungrab the default display after it has been grabbed with 554 * gdk_x11_grab_server(). 555 */ 556 public static void ungrabServer() 557 { 558 // void gdk_x11_ungrab_server (void); 559 gdk_x11_ungrab_server(); 560 } 561 562 /** 563 * Extracts the group from the state field sent in an X Key event. 564 * This is only needed for code processing raw X events, since GdkEventKey 565 * directly includes an is_modifier field. 566 * Params: 567 * keymap = a GdkX11Keymap 568 * state = raw state returned from X 569 * Returns: the index of the active keyboard group for the event Since 3.6 570 */ 571 public static int keymapGetGroupForState(Keymap keymap, uint state) 572 { 573 // gint gdk_x11_keymap_get_group_for_state (GdkKeymap *keymap, guint state); 574 return gdk_x11_keymap_get_group_for_state((keymap is null) ? null : keymap.getKeymapStruct(), state); 575 } 576 577 /** 578 * Determines whether a particular key code represents a key that 579 * is a modifier. That is, it's a key that normally just affects 580 * the keyboard state and the behavior of other keys rather than 581 * producing a direct effect itself. This is only needed for code 582 * processing raw X events, since GdkEventKey directly includes 583 * an is_modifier field. 584 * Params: 585 * keymap = a GdkX11Keymap 586 * keycode = the hardware keycode from a key event 587 * Returns: TRUE if the hardware keycode is a modifier key Since 3.6 588 */ 589 public static int keymapKeyIsModifier(Keymap keymap, uint keycode) 590 { 591 // gboolean gdk_x11_keymap_key_is_modifier (GdkKeymap *keymap, guint keycode); 592 return gdk_x11_keymap_key_is_modifier((keymap is null) ? null : keymap.getKeymapStruct(), keycode); 593 } 594 595 /** 596 * Sets the SM_CLIENT_ID property on the application's leader window so that 597 * the window manager can save the application's state using the X11R6 ICCCM 598 * session management protocol. 599 * See the X Session Management Library documentation for more information on 600 * session management and the Inter-Client Communication Conventions Manual 601 * Since 2.24 602 * Params: 603 * smClientId = the client id assigned by the session manager when the 604 * connection was opened, or NULL to remove the property. 605 */ 606 public static void setSmClientId(string smClientId) 607 { 608 // void gdk_x11_set_sm_client_id (const gchar *sm_client_id); 609 gdk_x11_set_sm_client_id(Str.toStringz(smClientId)); 610 } 611 612 /** 613 * Convert a text string from the encoding as it is stored 614 * in a property into an array of strings in the encoding of 615 * the current locale. (The elements of the array represent the 616 * nul-separated elements of the original text string.) 617 * Since 2.24 618 * Params: 619 * display = The GdkDisplay where the encoding is defined. [type GdkX11Display] 620 * encoding = an atom representing the encoding. The most 621 * common values for this are STRING, or COMPOUND_TEXT. 622 * This is value used as the type for the property 623 * format = the format of the property 624 * text = The text data 625 * list = location to store an array of strings in 626 * the encoding of the current locale. This array should be 627 * freed using gdk_free_text_list(). 628 * Returns: the number of strings stored in list, or 0, if the conversion failed 629 */ 630 public static int displayTextPropertyToTextList(Display display, GdkAtom encoding, int format, char[] text, out string[] list) 631 { 632 // gint gdk_x11_display_text_property_to_text_list (GdkDisplay *display, GdkAtom encoding, gint format, const guchar *text, gint length, gchar ***list); 633 char** outlist = null; 634 int length; 635 636 auto p = gdk_x11_display_text_property_to_text_list((display is null) ? null : display.getDisplayStruct(), encoding, format, text.ptr, length, &outlist); 637 638 list = null; 639 foreach ( cstr; outlist[0 .. length] ) 640 { 641 list ~= Str.toString(cstr); 642 } 643 return p; 644 } 645 646 /** 647 * Frees the array of strings created by 648 * gdk_x11_display_text_property_to_text_list(). 649 * Since 2.24 650 * Params: 651 * list = the value stored in the list parameter by 652 * a call to gdk_x11_display_text_property_to_text_list(). 653 */ 654 public static void freeTextList(ref string list) 655 { 656 // void gdk_x11_free_text_list (gchar **list); 657 char* outlist = Str.toStringz(list); 658 659 gdk_x11_free_text_list(&outlist); 660 661 list = Str.toString(outlist); 662 } 663 664 /** 665 * Convert a string from the encoding of the current 666 * locale into a form suitable for storing in a window property. 667 * Since 2.24 668 * Params: 669 * display = the GdkDisplay where the encoding is defined. [type GdkX11Display] 670 * str = a nul-terminated string 671 * encoding = location to store the encoding atom 672 * (to be used as the type for the property). [out][transfer none] 673 * format = location to store the format of the property. [out] 674 * ctext = location to store newly 675 * allocated data for the property. [out][array length=length] 676 * Returns: 0 upon success, non-zero upon failure 677 */ 678 public static int displayStringToCompoundText(Display display, string str, out GdkAtom encoding, out int format, out char[] ctext) 679 { 680 // gint gdk_x11_display_string_to_compound_text (GdkDisplay *display, const gchar *str, GdkAtom *encoding, gint *format, guchar **ctext, gint *length); 681 guchar* outctext = null; 682 int length; 683 684 auto p = gdk_x11_display_string_to_compound_text((display is null) ? null : display.getDisplayStruct(), Str.toStringz(str), &encoding, &format, &outctext, &length); 685 686 ctext = outctext[0 .. length]; 687 return p; 688 } 689 690 /** 691 * Converts from UTF-8 to compound text. 692 * Since 2.24 693 * Params: 694 * display = a GdkDisplay. [type GdkX11Display] 695 * str = a UTF-8 string 696 * encoding = location to store resulting encoding. [out] 697 * format = location to store format of the result. [out] 698 * ctext = location to store the data of the result. [out][array length=length] 699 * Returns: TRUE if the conversion succeeded, otherwise FALSE 700 */ 701 public static int displayUtf8_ToCompoundText(Display display, string str, out GdkAtom encoding, out int format, out char[] ctext) 702 { 703 // gboolean gdk_x11_display_utf8_to_compound_text (GdkDisplay *display, const gchar *str, GdkAtom *encoding, gint *format, guchar **ctext, gint *length); 704 guchar* outctext = null; 705 int length; 706 707 auto p = gdk_x11_display_utf8_to_compound_text((display is null) ? null : display.getDisplayStruct(), Str.toStringz(str), &encoding, &format, &outctext, &length); 708 709 ctext = outctext[0 .. length]; 710 return p; 711 } 712 713 /** 714 * Frees the data returned from gdk_x11_display_string_to_compound_text(). 715 * Since 2.24 716 * Params: 717 * ctext = The pointer stored in ctext from a call to 718 * gdk_x11_display_string_to_compound_text(). 719 */ 720 public static void freeCompoundText(ref char ctext) 721 { 722 // void gdk_x11_free_compound_text (guchar *ctext); 723 gdk_x11_free_compound_text(&ctext); 724 } 725 }