alternative to assert
[gtkD.git] / gtkD / src / gdk / Display.d
blob76089820f2828417494573764ff504a8900e5fa7
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GdkDisplay.html
26 * outPack = gdk
27 * outFile = Display
28 * strct = GdkDisplay
29 * realStrct=
30 * ctorStrct=
31 * clss = Display
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gdk_display_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.Str
45 * - gdk.Display
46 * - gdk.Screen
47 * - glib.ListG
48 * - gdk.Event
49 * - gdk.Window
50 * structWrap:
51 * - GList* -> ListG
52 * - GdkDisplay* -> Display
53 * - GdkEvent* -> Event
54 * - GdkScreen* -> Screen
55 * - GdkWindow* -> Window
56 * module aliases:
57 * local aliases:
60 module gdk.Display;
62 version(noAssert)
64 version(Tango)
66 import tango.io.Stdout; // use the tango loging?
70 private import gtkc.gdktypes;
72 private import gtkc.gdk;
75 private import glib.Str;
76 private import gdk.Display;
77 private import gdk.Screen;
78 private import glib.ListG;
79 private import gdk.Event;
80 private import gdk.Window;
85 /**
86 * Description
87 * GdkDisplay objects purpose are two fold:
88 * To grab/ungrab keyboard focus and mouse pointer
89 * To manage and provide information about the GdkScreen(s)
90 * available for this GdkDisplay
91 * GdkDisplay objects are the GDK representation of the X Display which can be
92 * described as a workstation consisting of a keyboard a pointing
93 * device (such as a mouse) and one or more screens.
94 * It is used to open and keep track of various GdkScreen objects currently
95 * instanciated by the application. It is also used to grab and release the keyboard
96 * and the mouse pointer.
98 private import gobject.ObjectG;
99 public class Display : ObjectG
102 /** the main Gtk struct */
103 protected GdkDisplay* gdkDisplay;
106 public GdkDisplay* getDisplayStruct()
108 return gdkDisplay;
112 /** the main Gtk struct as a void* */
113 protected void* getStruct()
115 return cast(void*)gdkDisplay;
119 * Sets our main struct and passes it to the parent class
121 public this (GdkDisplay* gdkDisplay)
123 version(noAssert)
125 if ( gdkDisplay is null )
127 int zero = 0;
128 version(Tango)
130 Stdout("struct gdkDisplay is null on constructor").newline;
132 else
134 printf("struct gdkDisplay is null on constructor");
136 zero = zero / zero;
139 else
141 assert(gdkDisplay !is null, "struct gdkDisplay is null on constructor");
143 super(cast(GObject*)gdkDisplay);
144 this.gdkDisplay = gdkDisplay;
150 // imports for the signal processing
151 private import gobject.Signals;
152 private import gtkc.gdktypes;
153 int[char[]] connectedSignals;
155 void delegate(gboolean, Display)[] onClosedListeners;
156 void addOnClosed(void delegate(gboolean, Display) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
158 if ( !("closed" in connectedSignals) )
160 Signals.connectData(
161 getStruct(),
162 "closed",
163 cast(GCallback)&callBackClosed,
164 cast(void*)this,
165 null,
166 connectFlags);
167 connectedSignals["closed"] = 1;
169 onClosedListeners ~= dlg;
171 extern(C) static void callBackClosed(GdkDisplay* displayStruct, gboolean isError, Display display)
173 bool consumed = false;
175 foreach ( void delegate(gboolean, Display) dlg ; display.onClosedListeners )
177 dlg(isError, display);
180 return consumed;
186 * Opens a display.
187 * display_name:
188 * the name of the display to open
189 * Returns:
190 * a GdkDisplay, or NULL if the display
191 * could not be opened.
192 * Since 2.2
194 public static Display open(char[] displayName)
196 // GdkDisplay* gdk_display_open (const gchar *display_name);
197 return new Display( gdk_display_open(Str.toStringz(displayName)) );
201 * Gets the default GdkDisplay. This is a convenience
202 * function for:
203 * gdk_display_manager_get_default_display (gdk_display_manager_get ())
204 * Returns:
205 * a GdkDisplay, or NULL if there is no default
206 * display.
207 * Since 2.2
209 public static Display getDefault()
211 // GdkDisplay* gdk_display_get_default (void);
212 return new Display( gdk_display_get_default() );
216 * Gets the name of the display.
217 * display:
218 * a GdkDisplay
219 * Returns:
220 * a string representing the display name. This string is owned
221 * by GDK and should not be modified or freed.
222 * Since 2.2
224 public char[] getName()
226 // const gchar* gdk_display_get_name (GdkDisplay *display);
227 return Str.toString(gdk_display_get_name(gdkDisplay) );
231 * Gets the number of screen managed by the display.
232 * display:
233 * a GdkDisplay
234 * Returns:
235 * number of screens.
236 * Since 2.2
238 public int getNScreens()
240 // gint gdk_display_get_n_screens (GdkDisplay *display);
241 return gdk_display_get_n_screens(gdkDisplay);
245 * Returns a screen object for one of the screens of the display.
246 * display:
247 * a GdkDisplay
248 * screen_num:
249 * the screen number
250 * Returns:
251 * the GdkScreen object
252 * Since 2.2
254 public Screen getScreen(int screenNum)
256 // GdkScreen* gdk_display_get_screen (GdkDisplay *display, gint screen_num);
257 return new Screen( gdk_display_get_screen(gdkDisplay, screenNum) );
261 * Get the default GdkScreen for display.
262 * display:
263 * a GdkDisplay
264 * Returns:
265 * the default GdkScreen object for display
266 * Since 2.2
268 public Screen getDefaultScreen()
270 // GdkScreen* gdk_display_get_default_screen (GdkDisplay *display);
271 return new Screen( gdk_display_get_default_screen(gdkDisplay) );
275 * Release any pointer grab.
276 * display:
277 * a GdkDisplay.
278 * time_:
279 * a timestap (e.g. GDK_CURRENT_TIME).
280 * Since 2.2
282 public void pointerUngrab(uint time)
284 // void gdk_display_pointer_ungrab (GdkDisplay *display, guint32 time_);
285 gdk_display_pointer_ungrab(gdkDisplay, time);
289 * Release any keyboard grab
290 * display:
291 * a GdkDisplay.
292 * time_:
293 * a timestap (e.g GDK_CURRENT_TIME).
294 * Since 2.2
296 public void keyboardUngrab(uint time)
298 // void gdk_display_keyboard_ungrab (GdkDisplay *display, guint32 time_);
299 gdk_display_keyboard_ungrab(gdkDisplay, time);
303 * Test if the pointer is grabbed.
304 * display:
305 * a GdkDisplay
306 * Returns:
307 * TRUE if an active X pointer grab is in effect
308 * Since 2.2
310 public int pointerIsGrabbed()
312 // gboolean gdk_display_pointer_is_grabbed (GdkDisplay *display);
313 return gdk_display_pointer_is_grabbed(gdkDisplay);
317 * Emits a short beep on display
318 * display:
319 * a GdkDisplay
320 * Since 2.2
322 public void beep()
324 // void gdk_display_beep (GdkDisplay *display);
325 gdk_display_beep(gdkDisplay);
329 * Flushes any requests queued for the windowing system and waits until all
330 * requests have been handled. This is often used for making sure that the
331 * display is synchronized with the current state of the program. Calling
332 * gdk_display_sync() before gdk_error_trap_pop() makes sure that any errors
333 * generated from earlier requests are handled before the error trap is
334 * removed.
335 * This is most useful for X11. On windowing systems where requests are
336 * handled synchronously, this function will do nothing.
337 * display:
338 * a GdkDisplay
339 * Since 2.2
341 public void sync()
343 // void gdk_display_sync (GdkDisplay *display);
344 gdk_display_sync(gdkDisplay);
348 * Flushes any requests queued for the windowing system; this happens automatically
349 * when the main loop blocks waiting for new events, but if your application
350 * is drawing without returning control to the main loop, you may need
351 * to call this function explicitely. A common case where this function
352 * needs to be called is when an application is executing drawing commands
353 * from a thread other than the thread where the main loop is running.
354 * This is most useful for X11. On windowing systems where requests are
355 * handled synchronously, this function will do nothing.
356 * display:
357 * a GdkDisplay
358 * Since 2.4
360 public void flush()
362 // void gdk_display_flush (GdkDisplay *display);
363 gdk_display_flush(gdkDisplay);
367 * Closes the connection to the windowing system for the given display,
368 * and cleans up associated resources.
369 * display:
370 * a GdkDisplay
371 * Since 2.2
373 public void close()
375 // void gdk_display_close (GdkDisplay *display);
376 gdk_display_close(gdkDisplay);
380 * Returns the list of available input devices attached to display.
381 * The list is statically allocated and should not be freed.
382 * display:
383 * a GdkDisplay
384 * Returns:
385 * a list of GdkDevice
386 * Since 2.2
388 public ListG listDevices()
390 // GList* gdk_display_list_devices (GdkDisplay *display);
391 return new ListG( gdk_display_list_devices(gdkDisplay) );
395 * Gets the next GdkEvent to be processed for display, fetching events from the
396 * windowing system if necessary.
397 * display:
398 * a GdkDisplay
399 * Returns:
400 * the next GdkEvent to be processed, or NULL if no events
401 * are pending. The returned GdkEvent should be freed with gdk_event_free().
402 * Since 2.2
404 public Event getEvent()
406 // GdkEvent* gdk_display_get_event (GdkDisplay *display);
407 return new Event( gdk_display_get_event(gdkDisplay) );
411 * Gets a copy of the first GdkEvent in the display's event queue, without
412 * removing the event from the queue. (Note that this function will
413 * not get more events from the windowing system. It only checks the events
414 * that have already been moved to the GDK event queue.)
415 * display:
416 * a GdkDisplay
417 * Returns:
418 * a copy of the first GdkEvent on the event queue, or NULL
419 * if no events are in the queue. The returned GdkEvent should be freed with
420 * gdk_event_free().
421 * Since 2.2
423 public Event peekEvent()
425 // GdkEvent* gdk_display_peek_event (GdkDisplay *display);
426 return new Event( gdk_display_peek_event(gdkDisplay) );
430 * Appends a copy of the given event onto the front of the event
431 * queue for display.
432 * display:
433 * a GdkDisplay
434 * event:
435 * a GdkEvent.
436 * Since 2.2
438 public void putEvent(Event event)
440 // void gdk_display_put_event (GdkDisplay *display, GdkEvent *event);
441 gdk_display_put_event(gdkDisplay, (event is null) ? null : event.getEventStruct());
445 * Adds a filter to be called when X ClientMessage events are received.
446 * display:
447 * a GdkDisplay for which this message filter applies
448 * message_type:
449 * the type of ClientMessage events to receive.
450 * This will be checked against the message_type field
451 * of the XClientMessage event struct.
452 * func:
453 * the function to call to process the event.
454 * data:
455 * user data to pass to func.
456 * Since 2.2
458 public void addClientMessageFilter(GdkAtom messageType, GdkFilterFunc func, void* data)
460 // void gdk_display_add_client_message_filter (GdkDisplay *display, GdkAtom message_type, GdkFilterFunc func, gpointer data);
461 gdk_display_add_client_message_filter(gdkDisplay, messageType, func, data);
465 * Sets the double click time (two clicks within this time interval
466 * count as a double click and result in a GDK_2BUTTON_PRESS event).
467 * Applications should not set this, it is a global
468 * user-configured setting.
469 * display:
470 * a GdkDisplay
471 * msec:
472 * double click time in milliseconds (thousandths of a second)
473 * Since 2.2
475 public void setDoubleClickTime(uint msec)
477 // void gdk_display_set_double_click_time (GdkDisplay *display, guint msec);
478 gdk_display_set_double_click_time(gdkDisplay, msec);
482 * Sets the double click distance (two clicks within this distance
483 * count as a double click and result in a GDK_2BUTTON_PRESS event).
484 * See also gdk_display_set_double_click_time().
485 * Applications should not set this, it is a global
486 * user-configured setting.
487 * display:
488 * a GdkDisplay
489 * distance:
490 * distance in pixels
491 * Since 2.4
493 public void setDoubleClickDistance(uint distance)
495 // void gdk_display_set_double_click_distance (GdkDisplay *display, guint distance);
496 gdk_display_set_double_click_distance(gdkDisplay, distance);
500 * Gets the current location of the pointer and the current modifier
501 * mask for a given display.
502 * display:
503 * a GdkDisplay
504 * screen:
505 * location to store the screen that the
506 * cursor is on, or NULL.
507 * x:
508 * location to store root window X coordinate of pointer, or NULL.
509 * y:
510 * location to store root window Y coordinate of pointer, or NULL.
511 * mask:
512 * location to store current modifier mask, or NULL
513 * Since 2.2
515 public void getPointer(GdkScreen** screen, int* x, int* y, GdkModifierType* mask)
517 // void gdk_display_get_pointer (GdkDisplay *display, GdkScreen **screen, gint *x, gint *y, GdkModifierType *mask);
518 gdk_display_get_pointer(gdkDisplay, screen, x, y, mask);
522 * Obtains the window underneath the mouse pointer, returning the location
523 * of that window in win_x, win_y for screen. Returns NULL if the window
524 * under the mouse pointer is not known to GDK (for example, belongs to
525 * another application).
526 * display:
527 * a GdkDisplay
528 * win_x:
529 * return location for origin of the window under the pointer
530 * win_y:
531 * return location for origin of the window under the pointer
532 * Returns:
533 * the window under the mouse pointer, or NULL
534 * Since 2.2
536 public Window getWindowAtPointer(int* winX, int* winY)
538 // GdkWindow* gdk_display_get_window_at_pointer (GdkDisplay *display, gint *win_x, gint *win_y);
539 return new Window( gdk_display_get_window_at_pointer(gdkDisplay, winX, winY) );
544 * This function allows for hooking into the operation
545 * of getting the current location of the pointer on a particular
546 * display. This is only useful for such low-level tools as an
547 * event recorder. Applications should never have any
548 * reason to use this facility.
549 * display:
550 * a GdkDisplay
551 * new_hooks:
552 * a table of pointers to functions for getting
553 * quantities related to the current pointer position,
554 * or NULL to restore the default table.
555 * Returns:
556 * the previous pointer hook table
557 * Since 2.2
559 public GdkDisplayPointerHooks* setPointerHooks(GdkDisplayPointerHooks* newHooks)
561 // GdkDisplayPointerHooks* gdk_display_set_pointer_hooks (GdkDisplay *display, const GdkDisplayPointerHooks *new_hooks);
562 return gdk_display_set_pointer_hooks(gdkDisplay, newHooks);
566 * Warps the pointer of display to the point x,y on
567 * the screen screen, unless the pointer is confined
568 * to a window by a grab, in which case it will be moved
569 * as far as allowed by the grab. Warping the pointer
570 * creates events as if the user had moved the mouse
571 * instantaneously to the destination.
572 * Note that the pointer should normally be under the
573 * control of the user. This function was added to cover
574 * some rare use cases like keyboard navigation support
575 * for the color picker in the GtkColorSelectionDialog.
576 * display:
577 * a GdkDisplay
578 * screen:
579 * the screen of display to warp the pointer to
580 * x:
581 * the x coordinate of the destination
582 * y:
583 * the y coordinate of the destination
584 * Since 2.8
586 public void warpPointer(Screen screen, int x, int y)
588 // void gdk_display_warp_pointer (GdkDisplay *display, GdkScreen *screen, gint x, gint y);
589 gdk_display_warp_pointer(gdkDisplay, (screen is null) ? null : screen.getScreenStruct(), x, y);
593 * Returns TRUE if multicolored cursors are supported
594 * on display. Otherwise, cursors have only a forground
595 * and a background color.
596 * display:
597 * a GdkDisplay
598 * Returns:
599 * whether cursors can have multiple colors.
600 * Since 2.4
602 public int supportsCursorColor()
604 // gboolean gdk_display_supports_cursor_color (GdkDisplay *display);
605 return gdk_display_supports_cursor_color(gdkDisplay);
609 * Returns TRUE if cursors can use an 8bit alpha channel
610 * on display. Otherwise, cursors are restricted to bilevel
611 * alpha (i.e. a mask).
612 * display:
613 * a GdkDisplay
614 * Returns:
615 * whether cursors can have alpha channels.
616 * Since 2.4
618 public int supportsCursorAlpha()
620 // gboolean gdk_display_supports_cursor_alpha (GdkDisplay *display);
621 return gdk_display_supports_cursor_alpha(gdkDisplay);
625 * Returns the default size to use for cursors on display.
626 * display:
627 * a GdkDisplay
628 * Returns:
629 * the default cursor size.
630 * Since 2.4
632 public uint getDefaultCursorSize()
634 // guint gdk_display_get_default_cursor_size (GdkDisplay *display);
635 return gdk_display_get_default_cursor_size(gdkDisplay);
639 * Gets the maximal size to use for cursors on display.
640 * display:
641 * a GdkDisplay
642 * width:
643 * the return location for the maximal cursor width
644 * height:
645 * the return location for the maximal cursor height
646 * Since 2.4
648 public void getMaximalCursorSize(uint* width, uint* height)
650 // void gdk_display_get_maximal_cursor_size (GdkDisplay *display, guint *width, guint *height);
651 gdk_display_get_maximal_cursor_size(gdkDisplay, width, height);
655 * Returns the default group leader window for all toplevel windows
656 * on display. This window is implicitly created by GDK.
657 * See gdk_window_set_group().
658 * display:
659 * a GdkDisplay
660 * Returns:
661 * The default group leader window for display
662 * Since 2.4
664 public Window getDefaultGroup()
666 // GdkWindow* gdk_display_get_default_group (GdkDisplay *display);
667 return new Window( gdk_display_get_default_group(gdkDisplay) );
671 * Returns whether GdkEventOwnerChange events will be
672 * sent when the owner of a selection changes.
673 * display:
674 * a GdkDisplay
675 * Returns:
676 * whether GdkEventOwnerChange events will
677 * be sent.
678 * Since 2.6
680 public int supportsSelectionNotification()
682 // gboolean gdk_display_supports_selection_notification (GdkDisplay *display);
683 return gdk_display_supports_selection_notification(gdkDisplay);
687 * Request GdkEventOwnerChange events for ownership changes
688 * of the selection named by the given atom.
689 * display:
690 * a GdkDisplay
691 * selection:
692 * the GdkAtom naming the selection for which
693 * ownership change notification is requested
694 * Returns:
695 * whether GdkEventOwnerChange events will
696 * be sent.
697 * Since 2.6
699 public int requestSelectionNotification(GdkAtom selection)
701 // gboolean gdk_display_request_selection_notification (GdkDisplay *display, GdkAtom selection);
702 return gdk_display_request_selection_notification(gdkDisplay, selection);
706 * Returns whether the speicifed display supports clipboard
707 * persistance; i.e. if it's possible to store the clipboard data after an
708 * application has quit. On X11 this checks if a clipboard daemon is
709 * running.
710 * display:
711 * a GdkDisplay
712 * Returns:
713 * TRUE if the display supports clipboard persistance.
714 * Since 2.6
716 public int supportsClipboardPersistence()
718 // gboolean gdk_display_supports_clipboard_persistence (GdkDisplay *display);
719 return gdk_display_supports_clipboard_persistence(gdkDisplay);
723 * Issues a request to the clipboard manager to store the
724 * clipboard data. On X11, this is a special program that works
725 * according to the freedesktop clipboard specification, available at
726 * http://www.freedesktop.org/Standards/clipboard-manager-spec.
727 * display:
728 * a GdkDisplay
729 * clipboard_window:
730 * a GdkWindow belonging to the clipboard owner
731 * time_:
732 * a timestamp
733 * targets:
734 * an array of targets that should be saved, or NULL
735 * if all available targets should be saved.
736 * n_targets:
737 * length of the targets array
738 * Since 2.6
740 public void storeClipboard(Window clipboardWindow, uint time, GdkAtom* targets, int nTargets)
742 // void gdk_display_store_clipboard (GdkDisplay *display, GdkWindow *clipboard_window, guint32 time_, GdkAtom *targets, gint n_targets);
743 gdk_display_store_clipboard(gdkDisplay, (clipboardWindow is null) ? null : clipboardWindow.getWindowStruct(), time, targets, nTargets);
747 * Returns TRUE if gdk_window_shape_combine_mask() can
748 * be used to create shaped windows on display.
749 * display:
750 * a GdkDisplay
751 * Returns:
752 * TRUE if shaped windows are supported
753 * Since 2.10
755 public int supportsShapes()
757 // gboolean gdk_display_supports_shapes (GdkDisplay *display);
758 return gdk_display_supports_shapes(gdkDisplay);
762 * Returns TRUE if gdk_window_input_shape_combine_mask() can
763 * be used to modify the input shape of windows on display.
764 * display:
765 * a GdkDisplay
766 * Returns:
767 * TRUE if windows with modified input shape are supported
768 * Since 2.10
769 * Signal Details
770 * The "closed" signal
771 * void user_function (GdkDisplay *display,
772 * gboolean is_error,
773 * gpointer user_data) : Run Last
774 * The ::closed signal is emitted when the connection to the windowing
775 * system for display is closed.
776 * display:
777 * the object on which the signal is emitted
778 * is_error:
779 * TRUE if the display was closed due to an error
780 * user_data:
781 * user data set when the signal handler was connected.
782 * Since 2.2
784 public int supportsInputShapes()
786 // gboolean gdk_display_supports_input_shapes (GdkDisplay *display);
787 return gdk_display_supports_input_shapes(gdkDisplay);