1 /* GDK - The GIMP Drawing Kit
4 * Copyright 2001 Sun Microsystems Inc.
6 * Erwann Chenede <erwann.chenede@sun.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
26 #include "gdkdisplay.h"
27 #include "gdkdisplayprivate.h"
29 #include "gdkevents.h"
30 #include "gdkwindowimpl.h"
31 #include "gdkinternals.h"
32 #include "gdkmarshalers.h"
33 #include "gdkscreen.h"
41 * @Short_description: Controls the keyboard/mouse pointer grabs and a set of <type>GdkScreen</type>s
44 * #GdkDisplay objects purpose are two fold:
47 * To grab/ungrab keyboard focus and mouse pointer
50 * To manage and provide information about the #GdkScreen(s)
51 * available for this #GdkDisplay
55 * #GdkDisplay objects are the GDK representation of the X Display which can be
56 * described as <emphasis>a workstation consisting of a keyboard a pointing
57 * device (such as a mouse) and one or more screens</emphasis>.
58 * It is used to open and keep track of various #GdkScreen objects currently
59 * instanciated by the application. It is also used to grab and release the keyboard
60 * and the mouse pointer.
70 static void gdk_display_dispose (GObject *object);
71 static void gdk_display_finalize (GObject *object);
73 static void multihead_get_device_state (GdkDisplay *display,
78 GdkModifierType *mask);
79 static GdkWindow * multihead_window_get_device_position (GdkDisplay *display,
84 GdkModifierType *mask);
85 static GdkWindow * multihead_window_at_device_position (GdkDisplay *display,
90 static void multihead_default_get_pointer (GdkDisplay *display,
94 GdkModifierType *mask);
95 static GdkWindow * multihead_default_window_get_pointer (GdkDisplay *display,
99 GdkModifierType *mask);
100 static GdkWindow * multihead_default_window_at_pointer (GdkDisplay *display,
105 static void singlehead_get_pointer (GdkDisplay *display,
109 GdkModifierType *mask);
110 static GdkWindow* singlehead_window_get_pointer (GdkDisplay *display,
114 GdkModifierType *mask);
115 static GdkWindow* singlehead_window_at_pointer (GdkDisplay *display,
119 static GdkWindow* singlehead_default_window_get_pointer (GdkWindow *window,
122 GdkModifierType *mask);
123 static GdkWindow* singlehead_default_window_at_pointer (GdkScreen *screen,
125 gint *win_y);static GdkWindow *gdk_window_real_window_get_device_position (GdkDisplay *display,
130 GdkModifierType *mask);
131 static GdkWindow *gdk_display_real_get_window_at_device_position (GdkDisplay *display,
135 static GdkAppLaunchContext *gdk_display_real_get_app_launch_context (GdkDisplay *display);
137 static guint signals[LAST_SIGNAL] = { 0 };
139 static char *gdk_sm_client_id;
141 static const GdkDisplayDeviceHooks default_device_hooks = {
142 _gdk_windowing_get_device_state,
143 gdk_window_real_window_get_device_position,
144 gdk_display_real_get_window_at_device_position
147 static const GdkDisplayDeviceHooks multihead_pointer_hooks = {
148 multihead_get_device_state,
149 multihead_window_get_device_position,
150 multihead_window_at_device_position
153 static const GdkDisplayPointerHooks multihead_default_pointer_hooks = {
154 multihead_default_get_pointer,
155 multihead_default_window_get_pointer,
156 multihead_default_window_at_pointer
159 static const GdkDisplayPointerHooks singlehead_pointer_hooks = {
160 singlehead_get_pointer,
161 singlehead_window_get_pointer,
162 singlehead_window_at_pointer
165 static const GdkPointerHooks singlehead_default_pointer_hooks = {
166 singlehead_default_window_get_pointer,
167 singlehead_default_window_at_pointer
170 static const GdkPointerHooks *singlehead_current_pointer_hooks = &singlehead_default_pointer_hooks;
171 static const GdkDisplayPointerHooks *multihead_current_pointer_hooks = &multihead_default_pointer_hooks;
173 G_DEFINE_TYPE (GdkDisplay, gdk_display, G_TYPE_OBJECT)
176 gdk_display_class_init (GdkDisplayClass *class)
178 GObjectClass *object_class = G_OBJECT_CLASS (class);
180 object_class->finalize = gdk_display_finalize;
181 object_class->dispose = gdk_display_dispose;
183 class->get_app_launch_context = gdk_display_real_get_app_launch_context;
186 * GdkDisplay::opened:
187 * @display: the object on which the signal is emitted
189 * The ::opened signal is emitted when the connection to the windowing
190 * system for @display is opened.
193 g_signal_new (g_intern_static_string ("opened"),
194 G_OBJECT_CLASS_TYPE (object_class),
197 g_cclosure_marshal_VOID__VOID,
201 * GdkDisplay::closed:
202 * @display: the object on which the signal is emitted
203 * @is_error: %TRUE if the display was closed due to an error
205 * The ::closed signal is emitted when the connection to the windowing
206 * system for @display is closed.
211 g_signal_new (g_intern_static_string ("closed"),
212 G_OBJECT_CLASS_TYPE (object_class),
214 G_STRUCT_OFFSET (GdkDisplayClass, closed),
216 _gdk_marshal_VOID__BOOLEAN,
223 free_pointer_info (GdkPointerWindowInfo *info)
225 g_object_unref (info->toplevel_under_pointer);
226 g_slice_free (GdkPointerWindowInfo, info);
230 free_device_grab (GdkDeviceGrabInfo *info)
232 g_object_unref (info->window);
233 g_object_unref (info->native_window);
238 free_device_grabs_foreach (gpointer key,
244 g_list_foreach (list, (GFunc) free_device_grab, NULL);
251 device_removed_cb (GdkDeviceManager *device_manager,
255 g_hash_table_remove (display->multiple_click_info, device);
256 g_hash_table_remove (display->device_grabs, device);
257 g_hash_table_remove (display->pointers_info, device);
259 /* FIXME: change core pointer and remove from device list */
263 gdk_display_opened (GdkDisplay *display)
265 GdkDeviceManager *device_manager;
267 device_manager = gdk_display_get_device_manager (display);
269 g_signal_connect (device_manager, "device-removed",
270 G_CALLBACK (device_removed_cb), display);
274 gdk_display_init (GdkDisplay *display)
276 display->double_click_time = 250;
277 display->double_click_distance = 5;
279 display->device_hooks = &default_device_hooks;
281 display->device_grabs = g_hash_table_new (NULL, NULL);
282 display->motion_hint_info = g_hash_table_new_full (NULL, NULL, NULL,
283 (GDestroyNotify) g_free);
285 display->pointers_info = g_hash_table_new_full (NULL, NULL, NULL,
286 (GDestroyNotify) free_pointer_info);
288 display->multiple_click_info = g_hash_table_new_full (NULL, NULL, NULL,
289 (GDestroyNotify) g_free);
291 g_signal_connect (display, "opened",
292 G_CALLBACK (gdk_display_opened), NULL);
296 gdk_display_dispose (GObject *object)
298 GdkDisplay *display = GDK_DISPLAY_OBJECT (object);
299 GdkDeviceManager *device_manager;
301 device_manager = gdk_display_get_device_manager (GDK_DISPLAY_OBJECT (object));
303 g_list_foreach (display->queued_events, (GFunc)gdk_event_free, NULL);
304 g_list_free (display->queued_events);
305 display->queued_events = NULL;
306 display->queued_tail = NULL;
310 /* this is to make it drop devices which may require using the X
311 * display and therefore can't be cleaned up in finalize.
312 * It will also disconnect device_removed_cb
314 g_object_run_dispose (G_OBJECT (display->device_manager));
317 G_OBJECT_CLASS (gdk_display_parent_class)->dispose (object);
321 gdk_display_finalize (GObject *object)
323 GdkDisplay *display = GDK_DISPLAY_OBJECT (object);
325 g_hash_table_foreach_remove (display->device_grabs,
326 free_device_grabs_foreach,
328 g_hash_table_destroy (display->device_grabs);
330 g_hash_table_destroy (display->pointers_info);
331 g_hash_table_destroy (display->multiple_click_info);
333 if (display->device_manager)
334 g_object_unref (display->device_manager);
336 G_OBJECT_CLASS (gdk_display_parent_class)->finalize (object);
341 * @display: a #GdkDisplay
343 * Closes the connection to the windowing system for the given display,
344 * and cleans up associated resources.
349 gdk_display_close (GdkDisplay *display)
351 g_return_if_fail (GDK_IS_DISPLAY (display));
353 if (!display->closed)
355 display->closed = TRUE;
357 g_signal_emit (display, signals[CLOSED], 0, FALSE);
358 g_object_run_dispose (G_OBJECT (display));
360 g_object_unref (display);
365 * gdk_display_is_closed:
366 * @display: a #GdkDisplay
368 * Finds out if the display has been closed.
370 * Returns: %TRUE if the display is closed.
375 gdk_display_is_closed (GdkDisplay *display)
377 g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
379 return display->closed;
383 * gdk_display_get_event:
384 * @display: a #GdkDisplay
386 * Gets the next #GdkEvent to be processed for @display, fetching events from the
387 * windowing system if necessary.
389 * Return value: the next #GdkEvent to be processed, or %NULL if no events
390 * are pending. The returned #GdkEvent should be freed with gdk_event_free().
395 gdk_display_get_event (GdkDisplay *display)
397 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
399 GDK_DISPLAY_GET_CLASS (display)->queue_events (display);
400 return _gdk_event_unqueue (display);
404 * gdk_display_peek_event:
405 * @display: a #GdkDisplay
407 * Gets a copy of the first #GdkEvent in the @display's event queue, without
408 * removing the event from the queue. (Note that this function will
409 * not get more events from the windowing system. It only checks the events
410 * that have already been moved to the GDK event queue.)
412 * Return value: a copy of the first #GdkEvent on the event queue, or %NULL
413 * if no events are in the queue. The returned #GdkEvent should be freed with
419 gdk_display_peek_event (GdkDisplay *display)
423 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
425 tmp_list = _gdk_event_queue_find_first (display);
428 return gdk_event_copy (tmp_list->data);
434 * gdk_display_put_event:
435 * @display: a #GdkDisplay
436 * @event: a #GdkEvent.
438 * Appends a copy of the given event onto the front of the event
439 * queue for @display.
444 gdk_display_put_event (GdkDisplay *display,
445 const GdkEvent *event)
447 g_return_if_fail (GDK_IS_DISPLAY (display));
448 g_return_if_fail (event != NULL);
450 _gdk_event_queue_append (display, gdk_event_copy (event));
451 /* If the main loop is blocking in a different thread, wake it up */
452 g_main_context_wakeup (NULL);
456 * gdk_display_pointer_ungrab:
457 * @display: a #GdkDisplay.
458 * @time_: a timestap (e.g. %GDK_CURRENT_TIME).
460 * Release any pointer grab.
464 * Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
468 gdk_display_pointer_ungrab (GdkDisplay *display,
471 GdkDeviceManager *device_manager;
472 GList *devices, *dev;
475 g_return_if_fail (GDK_IS_DISPLAY (display));
477 device_manager = gdk_display_get_device_manager (display);
478 devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
480 /* FIXME: Should this be generic to all backends? */
481 /* FIXME: What happens with extended devices? */
482 for (dev = devices; dev; dev = dev->next)
486 if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
489 gdk_device_ungrab (device, time_);
492 g_list_free (devices);
496 * gdk_pointer_ungrab:
497 * @time_: a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no
498 * timestamp is available.
500 * Ungrabs the pointer on the default display, if it is grabbed by this
503 * Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
507 gdk_pointer_ungrab (guint32 time)
509 gdk_display_pointer_ungrab (gdk_display_get_default (), time);
513 * gdk_pointer_is_grabbed:
515 * Returns %TRUE if the pointer on the default display is currently
516 * grabbed by this application.
518 * Note that this does not take the inmplicit pointer grab on button
519 * presses into account.
521 * Return value: %TRUE if the pointer is currently grabbed by this application.
523 * Deprecated: 3.0: Use gdk_display_device_is_grabbed() instead.
526 gdk_pointer_is_grabbed (void)
528 return gdk_display_pointer_is_grabbed (gdk_display_get_default ());
532 * gdk_display_keyboard_ungrab:
533 * @display: a #GdkDisplay.
534 * @time_: a timestap (e.g #GDK_CURRENT_TIME).
536 * Release any keyboard grab
540 * Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
544 gdk_display_keyboard_ungrab (GdkDisplay *display,
547 GdkDeviceManager *device_manager;
548 GList *devices, *dev;
551 g_return_if_fail (GDK_IS_DISPLAY (display));
553 device_manager = gdk_display_get_device_manager (display);
554 devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
556 /* FIXME: Should this be generic to all backends? */
557 /* FIXME: What happens with extended devices? */
558 for (dev = devices; dev; dev = dev->next)
562 if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
565 gdk_device_ungrab (device, time);
568 g_list_free (devices);
572 * gdk_keyboard_ungrab:
573 * @time_: a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no
574 * timestamp is available.
576 * Ungrabs the keyboard on the default display, if it is grabbed by this
579 * Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
583 gdk_keyboard_ungrab (guint32 time)
585 gdk_display_keyboard_ungrab (gdk_display_get_default (), time);
591 * Emits a short beep on the default display.
596 gdk_display_beep (gdk_display_get_default ());
602 * Flushes the output buffers of all display connections and waits
603 * until all requests have been processed.
604 * This is rarely needed by applications.
611 list = gdk_display_manager_list_displays (gdk_display_manager_get ());
612 for (l = list; l; l = l->next)
614 GdkDisplay *display = l->data;
616 GDK_DISPLAY_GET_CLASS (display)->sync (display);
623 * gdk_event_send_client_message:
624 * @event: the #GdkEvent to send, which should be a #GdkEventClient.
625 * @winid: the window to send the X ClientMessage event to.
627 * Sends an X ClientMessage event to a given window (which must be
628 * on the default #GdkDisplay.)
629 * This could be used for communicating between different applications,
630 * though the amount of data is limited to 20 bytes.
632 * Return value: non-zero on success.
635 gdk_event_send_client_message (GdkEvent *event,
636 GdkNativeWindow winid)
638 g_return_val_if_fail (event != NULL, FALSE);
640 return gdk_event_send_client_message_for_display (gdk_display_get_default (),
645 * gdk_event_send_clientmessage_toall:
646 * @event: the #GdkEvent to send, which should be a #GdkEventClient.
648 * Sends an X ClientMessage event to all toplevel windows on the default
651 * Toplevel windows are determined by checking for the WM_STATE property, as
652 * described in the Inter-Client Communication Conventions Manual (ICCCM).
653 * If no windows are found with the WM_STATE property set, the message is sent
654 * to all children of the root window.
657 gdk_event_send_clientmessage_toall (GdkEvent *event)
659 g_return_if_fail (event != NULL);
661 gdk_screen_broadcast_client_message (gdk_screen_get_default (), event);
665 * gdk_set_sm_client_id:
666 * @sm_client_id: the client id assigned by the session manager when the
667 * connection was opened, or %NULL to remove the property.
669 * Sets the <literal>SM_CLIENT_ID</literal> property on the application's leader window so that
670 * the window manager can save the application's state using the X11R6 ICCCM
671 * session management protocol.
673 * See the X Session Management Library documentation for more information on
674 * session management and the Inter-Client Communication Conventions Manual
675 * (ICCCM) for information on the <literal>WM_CLIENT_LEADER</literal> property.
676 * (Both documents are part of the X Window System distribution.)
679 gdk_set_sm_client_id (const gchar* sm_client_id)
681 GSList *displays, *tmp_list;
683 g_free (gdk_sm_client_id);
684 gdk_sm_client_id = g_strdup (sm_client_id);
686 displays = gdk_display_manager_list_displays (gdk_display_manager_get ());
687 for (tmp_list = displays; tmp_list; tmp_list = tmp_list->next)
688 _gdk_windowing_display_set_sm_client_id (tmp_list->data, sm_client_id);
690 g_slist_free (displays);
694 * _gdk_get_sm_client_id:
696 * Gets the client ID set with gdk_set_sm_client_id(), if any.
698 * Return value: Session ID, or %NULL if gdk_set_sm_client_id()
699 * has never been called.
702 _gdk_get_sm_client_id (void)
704 return gdk_sm_client_id;
708 _gdk_display_enable_motion_hints (GdkDisplay *display,
711 gulong *device_serial, serial;
713 device_serial = g_hash_table_lookup (display->motion_hint_info, device);
717 device_serial = g_new0 (gulong, 1);
718 *device_serial = G_MAXULONG;
719 g_hash_table_insert (display->motion_hint_info, device, device_serial);
722 if (*device_serial != 0)
724 serial = _gdk_windowing_window_get_next_serial (display);
725 /* We might not actually generate the next request, so
726 make sure this triggers always, this may cause it to
727 trigger slightly too early, but this is just a hint
731 if (serial < *device_serial)
732 *device_serial = serial;
737 * gdk_display_get_device_state:
738 * @display: a #GdkDisplay.
739 * @device: pointer device to query status about.
740 * @screen: (out) (transfer none) (allow-none): location to store the #GdkScreen
741 * the @device is on, or %NULL.
742 * @x: (out) (allow-none): location to store root window X coordinate of @device, or %NULL.
743 * @y: (out) (allow-none): location to store root window Y coordinate of @device, or %NULL.
744 * @mask: (out) (allow-none): location to store current modifier mask for @device, or %NULL.
746 * Gets the current location and state of @device for a given display.
751 gdk_display_get_device_state (GdkDisplay *display,
756 GdkModifierType *mask)
758 GdkScreen *tmp_screen;
760 GdkModifierType tmp_mask;
762 g_return_if_fail (GDK_IS_DISPLAY (display));
763 g_return_if_fail (GDK_IS_DEVICE (device));
764 g_return_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD);
766 display->device_hooks->get_device_state (display, device, &tmp_screen, &tmp_x, &tmp_y, &tmp_mask);
769 *screen = tmp_screen;
779 * gdk_display_get_window_at_device_position:
780 * @display: a #GdkDisplay.
781 * @device: pointer #GdkDevice to query info to.
782 * @win_x: (out) (allow-none): return location for the X coordinate of the device location,
783 * relative to the window origin, or %NULL.
784 * @win_y: (out) (allow-none): return location for the Y coordinate of the device location,
785 * relative to the window origin, or %NULL.
787 * Obtains the window underneath @device, returning the location of the device in @win_x and @win_y. Returns
788 * %NULL if the window tree under @device is not known to GDK (for example, belongs to another application).
790 * Returns: (transfer none): the #GdkWindow under the device position, or %NULL.
795 gdk_display_get_window_at_device_position (GdkDisplay *display,
803 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
804 g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
805 g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, NULL);
807 window = display->device_hooks->window_at_device_position (display, device, &tmp_x, &tmp_y);
818 * gdk_display_set_device_hooks:
819 * @display: a #GdkDisplay.
820 * @new_hooks: (allow-none): a table of pointers to functions for getting quantities related
821 * to all devices position, or %NULL to restore the default table.
823 * This function allows for hooking into the operation of getting the current location of any
824 * #GdkDevice on a particular #GdkDisplay. This is only useful for such low-level tools as
825 * an event recorder. Applications should never have any reason to use this facility.
827 * Returns: (transfer none): The previous device hook table.
831 GdkDisplayDeviceHooks *
832 gdk_display_set_device_hooks (GdkDisplay *display,
833 const GdkDisplayDeviceHooks *new_hooks)
835 const GdkDisplayDeviceHooks *result;
837 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
838 result = display->device_hooks;
841 display->device_hooks = new_hooks;
843 display->device_hooks = &default_device_hooks;
845 return (GdkDisplayDeviceHooks *) result;
849 * gdk_display_get_pointer:
850 * @display: a #GdkDisplay
851 * @screen: (allow-none): location to store the screen that the
852 * cursor is on, or %NULL.
853 * @x: (out) (allow-none): location to store root window X coordinate of pointer, or %NULL.
854 * @y: (out) (allow-none): location to store root window Y coordinate of pointer, or %NULL.
855 * @mask: (out) (allow-none): location to store current modifier mask, or %NULL
857 * Gets the current location of the pointer and the current modifier
858 * mask for a given display.
862 * Deprecated: 3.0: Use gdk_display_get_device_state() instead.
865 gdk_display_get_pointer (GdkDisplay *display,
869 GdkModifierType *mask)
871 g_return_if_fail (GDK_IS_DISPLAY (display));
873 gdk_display_get_device_state (display, display->core_pointer, screen, x, y, mask);
877 gdk_display_real_get_window_at_device_position (GdkDisplay *display,
885 window = _gdk_windowing_window_at_device_position (display, device, &x, &y, NULL, FALSE);
887 /* This might need corrections, as the native window returned
888 may contain client side children */
893 window = _gdk_window_find_descendant_at (window,
896 x = floor (xx + 0.5);
897 y = floor (yy + 0.5);
907 gdk_window_real_window_get_device_position (GdkDisplay *display,
912 GdkModifierType *mask)
915 GdkModifierType tmp_mask;
916 gboolean normal_child;
918 normal_child = GDK_WINDOW_IMPL_GET_CLASS (window->impl)->get_device_state (window,
922 /* We got the coords on the impl, convert to the window */
923 tmpx -= window->abs_x;
924 tmpy -= window->abs_y;
934 return _gdk_window_find_child_at (window, tmpx, tmpy);
939 * gdk_display_get_window_at_pointer:
940 * @display: a #GdkDisplay
941 * @win_x: (out) (allow-none): return location for x coordinate of the pointer location relative
942 * to the window origin, or %NULL
943 * @win_y: (out) (allow-none): return location for y coordinate of the pointer location relative
944 & to the window origin, or %NULL
946 * Obtains the window underneath the mouse pointer, returning the location
947 * of the pointer in that window in @win_x, @win_y for @screen. Returns %NULL
948 * if the window under the mouse pointer is not known to GDK (for example,
949 * belongs to another application).
951 * Returns: (transfer none): the window under the mouse pointer, or %NULL
955 * Deprecated: 3.0: Use gdk_display_get_window_at_device_position() instead.
958 gdk_display_get_window_at_pointer (GdkDisplay *display,
962 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
964 return gdk_display_get_window_at_device_position (display, display->core_pointer, win_x, win_y);
968 multihead_get_device_state (GdkDisplay *display,
973 GdkModifierType *mask)
975 multihead_current_pointer_hooks->get_pointer (display, screen, x, y, mask);
979 multihead_window_get_device_position (GdkDisplay *display,
984 GdkModifierType *mask)
986 return multihead_current_pointer_hooks->window_get_pointer (display, window, x, y, mask);
990 multihead_window_at_device_position (GdkDisplay *display,
995 return multihead_current_pointer_hooks->window_at_pointer (display, win_x, win_y);
999 multihead_default_get_pointer (GdkDisplay *display,
1003 GdkModifierType *mask)
1005 return _gdk_windowing_get_device_state (display,
1006 display->core_pointer,
1007 screen, x, y, mask);
1011 multihead_default_window_get_pointer (GdkDisplay *display,
1015 GdkModifierType *mask)
1017 return gdk_window_real_window_get_device_position (display,
1018 display->core_pointer,
1019 window, x, y, mask);
1023 multihead_default_window_at_pointer (GdkDisplay *display,
1027 return gdk_display_real_get_window_at_device_position (display,
1028 display->core_pointer,
1033 * gdk_display_set_pointer_hooks:
1034 * @display: a #GdkDisplay
1035 * @new_hooks: (allow-none): a table of pointers to functions for getting
1036 * quantities related to the current pointer position,
1037 * or %NULL to restore the default table.
1039 * This function allows for hooking into the operation
1040 * of getting the current location of the pointer on a particular
1041 * display. This is only useful for such low-level tools as an
1042 * event recorder. Applications should never have any
1043 * reason to use this facility.
1045 * Return value: (transfer none): the previous pointer hook table
1049 * Deprecated: 3.0: Use gdk_display_set_device_hooks() instead.
1051 GdkDisplayPointerHooks *
1052 gdk_display_set_pointer_hooks (GdkDisplay *display,
1053 const GdkDisplayPointerHooks *new_hooks)
1055 const GdkDisplayPointerHooks *result = multihead_current_pointer_hooks;
1057 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1060 multihead_current_pointer_hooks = new_hooks;
1062 multihead_current_pointer_hooks = &multihead_default_pointer_hooks;
1064 gdk_display_set_device_hooks (display, &multihead_pointer_hooks);
1066 return (GdkDisplayPointerHooks *)result;
1070 singlehead_get_pointer (GdkDisplay *display,
1074 GdkModifierType *mask)
1076 GdkScreen *default_screen = gdk_display_get_default_screen (display);
1077 GdkWindow *root_window = gdk_screen_get_root_window (default_screen);
1079 *screen = default_screen;
1081 singlehead_current_pointer_hooks->get_pointer (root_window, x, y, mask);
1085 singlehead_window_get_pointer (GdkDisplay *display,
1089 GdkModifierType *mask)
1091 return singlehead_current_pointer_hooks->get_pointer (window, x, y, mask);
1095 singlehead_window_at_pointer (GdkDisplay *display,
1099 GdkScreen *default_screen = gdk_display_get_default_screen (display);
1101 return singlehead_current_pointer_hooks->window_at_pointer (default_screen,
1106 singlehead_default_window_get_pointer (GdkWindow *window,
1109 GdkModifierType *mask)
1111 GdkDisplay *display;
1113 display = gdk_window_get_display (window);
1115 return gdk_window_real_window_get_device_position (display,
1116 display->core_pointer,
1117 window, x, y, mask);
1121 singlehead_default_window_at_pointer (GdkScreen *screen,
1125 GdkDisplay *display;
1127 display = gdk_screen_get_display (screen);
1129 return gdk_display_real_get_window_at_device_position (display,
1130 display->core_pointer,
1135 * gdk_set_pointer_hooks:
1136 * @new_hooks: (allow-none): a table of pointers to functions for getting
1137 * quantities related to the current pointer position,
1138 * or %NULL to restore the default table.
1140 * This function allows for hooking into the operation
1141 * of getting the current location of the pointer. This
1142 * is only useful for such low-level tools as an
1143 * event recorder. Applications should never have any
1144 * reason to use this facility.
1146 * This function is not multihead safe. For multihead operation,
1147 * see gdk_display_set_pointer_hooks().
1149 * Return value: the previous pointer hook table
1151 * Deprecated: 3.0: Use gdk_display_set_device_hooks() instead.
1154 gdk_set_pointer_hooks (const GdkPointerHooks *new_hooks)
1156 const GdkPointerHooks *result = singlehead_current_pointer_hooks;
1159 singlehead_current_pointer_hooks = new_hooks;
1161 singlehead_current_pointer_hooks = &singlehead_default_pointer_hooks;
1163 gdk_display_set_pointer_hooks (gdk_display_get_default (),
1164 &singlehead_pointer_hooks);
1166 return (GdkPointerHooks *)result;
1170 generate_grab_broken_event (GdkWindow *window,
1173 GdkWindow *grab_window)
1175 g_return_if_fail (window != NULL);
1177 if (!GDK_WINDOW_DESTROYED (window))
1181 event = gdk_event_new (GDK_GRAB_BROKEN);
1182 event->grab_broken.window = g_object_ref (window);
1183 event->grab_broken.send_event = FALSE;
1184 event->grab_broken.implicit = implicit;
1185 event->grab_broken.grab_window = grab_window;
1186 gdk_event_set_device (event, device);
1187 event->grab_broken.keyboard = (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD) ? TRUE : FALSE;
1189 gdk_event_put (event);
1190 gdk_event_free (event);
1195 _gdk_display_get_last_device_grab (GdkDisplay *display,
1200 l = g_hash_table_lookup (display->device_grabs, device);
1204 l = g_list_last (l);
1212 _gdk_display_add_device_grab (GdkDisplay *display,
1215 GdkWindow *native_window,
1216 GdkGrabOwnership grab_ownership,
1217 gboolean owner_events,
1218 GdkEventMask event_mask,
1219 unsigned long serial_start,
1223 GdkDeviceGrabInfo *info, *other_info;
1226 info = g_new0 (GdkDeviceGrabInfo, 1);
1228 info->window = g_object_ref (window);
1229 info->native_window = g_object_ref (native_window);
1230 info->serial_start = serial_start;
1231 info->serial_end = G_MAXULONG;
1232 info->owner_events = owner_events;
1233 info->event_mask = event_mask;
1235 info->implicit = implicit;
1236 info->ownership = grab_ownership;
1238 grabs = g_hash_table_lookup (display->device_grabs, device);
1240 /* Find the first grab that has a larger start time (if any) and insert
1241 * before that. I.E we insert after already existing grabs with same
1243 for (l = grabs; l != NULL; l = l->next)
1245 other_info = l->data;
1247 if (info->serial_start < other_info->serial_start)
1251 grabs = g_list_insert_before (grabs, l, info);
1253 /* Make sure the new grab end before next grab */
1256 other_info = l->data;
1257 info->serial_end = other_info->serial_start;
1260 /* Find any previous grab and update its end time */
1261 l = g_list_find (grabs, info);
1265 other_info = l->data;
1266 other_info->serial_end = serial_start;
1269 g_hash_table_insert (display->device_grabs, device, grabs);
1274 /* _gdk_synthesize_crossing_events only works inside one toplevel.
1275 This function splits things into two calls if needed, converting the
1276 coordinates to the right toplevel */
1278 synthesize_crossing_events (GdkDisplay *display,
1280 GdkDevice *source_device,
1281 GdkWindow *src_window,
1282 GdkWindow *dest_window,
1283 GdkCrossingMode crossing_mode,
1287 GdkWindow *src_toplevel, *dest_toplevel;
1288 GdkModifierType state;
1291 /* We use the native crossing events if all native */
1292 if (_gdk_native_windows)
1296 src_toplevel = gdk_window_get_toplevel (src_window);
1298 src_toplevel = NULL;
1300 dest_toplevel = gdk_window_get_toplevel (dest_window);
1302 dest_toplevel = NULL;
1304 if (src_toplevel == NULL && dest_toplevel == NULL)
1307 if (src_toplevel == NULL ||
1308 src_toplevel == dest_toplevel)
1310 /* Same toplevels */
1311 gdk_window_get_pointer (dest_toplevel,
1313 _gdk_synthesize_crossing_events (display,
1316 device, source_device,
1323 else if (dest_toplevel == NULL)
1325 gdk_window_get_pointer (src_toplevel,
1327 _gdk_synthesize_crossing_events (display,
1330 device, source_device,
1339 /* Different toplevels */
1340 gdk_window_get_pointer (src_toplevel,
1342 _gdk_synthesize_crossing_events (display,
1345 device, source_device,
1351 gdk_window_get_pointer (dest_toplevel,
1353 _gdk_synthesize_crossing_events (display,
1356 device, source_device,
1366 get_current_toplevel (GdkDisplay *display,
1370 GdkModifierType *state_out)
1372 GdkWindow *pointer_window;
1374 GdkModifierType state;
1376 pointer_window = _gdk_windowing_window_at_device_position (display, device, &x, &y, &state, TRUE);
1378 if (pointer_window != NULL &&
1379 (GDK_WINDOW_DESTROYED (pointer_window) ||
1380 GDK_WINDOW_TYPE (pointer_window) == GDK_WINDOW_ROOT ||
1381 GDK_WINDOW_TYPE (pointer_window) == GDK_WINDOW_FOREIGN))
1382 pointer_window = NULL;
1387 return pointer_window;
1391 switch_to_pointer_grab (GdkDisplay *display,
1393 GdkDevice *source_device,
1394 GdkDeviceGrabInfo *grab,
1395 GdkDeviceGrabInfo *last_grab,
1399 GdkWindow *src_window, *pointer_window, *new_toplevel;
1400 GdkPointerWindowInfo *info;
1402 GdkModifierType state;
1405 /* Temporarily unset pointer to make sure we send the crossing events below */
1406 old_grabs = g_hash_table_lookup (display->device_grabs, device);
1407 g_hash_table_steal (display->device_grabs, device);
1408 info = _gdk_display_get_pointer_info (display, device);
1412 /* New grab is in effect */
1414 /* We need to generate crossing events for the grab.
1415 * However, there are never any crossing events for implicit grabs
1416 * TODO: ... Actually, this could happen if the pointer window
1417 * doesn't have button mask so a parent gets the event...
1419 if (!grab->implicit)
1421 /* We send GRAB crossing events from the window under the pointer to the
1422 grab window. Except if there is an old grab then we start from that */
1424 src_window = last_grab->window;
1426 src_window = info->window_under_pointer;
1428 if (src_window != grab->window)
1429 synthesize_crossing_events (display, device, source_device,
1430 src_window, grab->window,
1431 GDK_CROSSING_GRAB, time, serial);
1433 /* !owner_event Grabbing a window that we're not inside, current status is
1434 now NULL (i.e. outside grabbed window) */
1435 if (!grab->owner_events && info->window_under_pointer != grab->window)
1436 _gdk_display_set_window_under_pointer (display, device, NULL);
1439 grab->activated = TRUE;
1444 new_toplevel = NULL;
1446 if (grab == NULL /* ungrab */ ||
1447 (!last_grab->owner_events && grab->owner_events) /* switched to owner_events */ )
1449 /* We force check what window we're in, and update the toplevel_under_pointer info,
1450 * as that won't get told of this change with toplevel enter events.
1452 if (info->toplevel_under_pointer)
1453 g_object_unref (info->toplevel_under_pointer);
1454 info->toplevel_under_pointer = NULL;
1456 new_toplevel = get_current_toplevel (display, device, &x, &y, &state);
1459 /* w is now toplevel and x,y in toplevel coords */
1460 info->toplevel_under_pointer = g_object_ref (new_toplevel);
1461 info->toplevel_x = x;
1462 info->toplevel_y = y;
1463 info->state = state;
1467 if (grab == NULL) /* Ungrabbed, send events */
1469 pointer_window = NULL;
1472 /* Find (possibly virtual) child window */
1474 _gdk_window_find_descendant_at (new_toplevel,
1479 if (pointer_window != last_grab->window)
1480 synthesize_crossing_events (display, device, source_device,
1481 last_grab->window, pointer_window,
1482 GDK_CROSSING_UNGRAB, time, serial);
1484 /* We're now ungrabbed, update the window_under_pointer */
1485 _gdk_display_set_window_under_pointer (display, device, pointer_window);
1489 g_hash_table_insert (display->device_grabs, device, old_grabs);
1493 _gdk_display_device_grab_update (GdkDisplay *display,
1495 GdkDevice *source_device,
1496 gulong current_serial)
1498 GdkDeviceGrabInfo *current_grab, *next_grab;
1502 time = display->last_event_time;
1503 grabs = g_hash_table_lookup (display->device_grabs, device);
1505 while (grabs != NULL)
1507 current_grab = grabs->data;
1509 if (current_grab->serial_start > current_serial)
1510 return; /* Hasn't started yet */
1512 if (current_grab->serial_end > current_serial)
1514 /* This one hasn't ended yet.
1515 its the currently active one or scheduled to be active */
1517 if (!current_grab->activated)
1519 if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
1520 switch_to_pointer_grab (display, device, source_device, current_grab, NULL, time, current_serial);
1529 /* This is the next active grab */
1530 next_grab = grabs->next->data;
1532 if (next_grab->serial_start > current_serial)
1533 next_grab = NULL; /* Actually its not yet active */
1536 if ((next_grab == NULL && current_grab->implicit_ungrab) ||
1537 (next_grab != NULL && current_grab->window != next_grab->window))
1538 generate_grab_broken_event (GDK_WINDOW (current_grab->window),
1540 current_grab->implicit,
1541 next_grab? next_grab->window : NULL);
1543 /* Remove old grab */
1544 grabs = g_list_delete_link (grabs, grabs);
1545 g_hash_table_insert (display->device_grabs, device, grabs);
1547 if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
1548 switch_to_pointer_grab (display, device, source_device,
1549 next_grab, current_grab,
1550 time, current_serial);
1552 free_device_grab (current_grab);
1557 grab_list_find (GList *grabs,
1560 GdkDeviceGrabInfo *grab;
1566 if (serial >= grab->serial_start && serial < grab->serial_end)
1569 grabs = grabs->next;
1576 find_device_grab (GdkDisplay *display,
1582 l = g_hash_table_lookup (display->device_grabs, device);
1583 return grab_list_find (l, serial);
1587 _gdk_display_has_device_grab (GdkDisplay *display,
1593 l = find_device_grab (display, device, serial);
1600 /* Returns true if last grab was ended
1601 * If if_child is non-NULL, end the grab only if the grabbed
1602 * window is the same as if_child or a descendant of it */
1604 _gdk_display_end_device_grab (GdkDisplay *display,
1607 GdkWindow *if_child,
1610 GdkDeviceGrabInfo *grab;
1613 l = find_device_grab (display, device, serial);
1620 (if_child == NULL ||
1621 _gdk_window_event_parent_of (if_child, grab->window)))
1623 grab->serial_end = serial;
1624 grab->implicit_ungrab = implicit;
1625 return l->next == NULL;
1631 /* Returns TRUE if device events are not blocked by any grab */
1633 _gdk_display_check_grab_ownership (GdkDisplay *display,
1637 GHashTableIter iter;
1638 gpointer key, value;
1639 GdkGrabOwnership higher_ownership, device_ownership;
1640 gboolean device_is_keyboard;
1642 g_hash_table_iter_init (&iter, display->device_grabs);
1643 higher_ownership = device_ownership = GDK_OWNERSHIP_NONE;
1644 device_is_keyboard = (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD);
1646 while (g_hash_table_iter_next (&iter, &key, &value))
1648 GdkDeviceGrabInfo *grab;
1654 grabs = grab_list_find (grabs, serial);
1659 /* Discard device if it's not of the same type */
1660 if ((device_is_keyboard && gdk_device_get_source (dev) != GDK_SOURCE_KEYBOARD) ||
1661 (!device_is_keyboard && gdk_device_get_source (dev) == GDK_SOURCE_KEYBOARD))
1667 device_ownership = grab->ownership;
1670 if (grab->ownership > higher_ownership)
1671 higher_ownership = grab->ownership;
1675 if (higher_ownership > device_ownership)
1677 /* There's a higher priority ownership
1678 * going on for other device(s)
1686 GdkPointerWindowInfo *
1687 _gdk_display_get_pointer_info (GdkDisplay *display,
1690 GdkPointerWindowInfo *info;
1692 if (G_UNLIKELY (!device))
1695 info = g_hash_table_lookup (display->pointers_info, device);
1697 if (G_UNLIKELY (!info))
1699 info = g_slice_new0 (GdkPointerWindowInfo);
1700 g_hash_table_insert (display->pointers_info, device, info);
1707 _gdk_display_pointer_info_foreach (GdkDisplay *display,
1708 GdkDisplayPointerInfoForeach func,
1711 GHashTableIter iter;
1712 gpointer key, value;
1714 g_hash_table_iter_init (&iter, display->pointers_info);
1716 while (g_hash_table_iter_next (&iter, &key, &value))
1718 GdkPointerWindowInfo *info = value;
1719 GdkDevice *device = key;
1721 (func) (display, device, info, user_data);
1726 * gdk_device_grab_info_libgtk_only:
1727 * @display: the display for which to get the grab information
1728 * @device: device to get the grab information from
1729 * @grab_window: (out) (transfer none): location to store current grab window
1730 * @owner_events: (out): location to store boolean indicating whether
1731 * the @owner_events flag to gdk_keyboard_grab() or
1732 * gdk_pointer_grab() was %TRUE.
1734 * Determines information about the current keyboard grab.
1735 * This is not public API and must not be used by applications.
1737 * Return value: %TRUE if this application currently has the
1741 gdk_device_grab_info_libgtk_only (GdkDisplay *display,
1743 GdkWindow **grab_window,
1744 gboolean *owner_events)
1746 GdkDeviceGrabInfo *info;
1748 g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
1749 g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
1751 info = _gdk_display_get_last_device_grab (display, device);
1756 *grab_window = info->window;
1758 *owner_events = info->owner_events;
1767 * gdk_display_pointer_is_grabbed:
1768 * @display: a #GdkDisplay
1770 * Test if the pointer is grabbed.
1772 * Returns: %TRUE if an active X pointer grab is in effect
1776 * Deprecated: 3.0: Use gdk_display_device_is_grabbed() instead.
1779 gdk_display_pointer_is_grabbed (GdkDisplay *display)
1781 GdkDeviceManager *device_manager;
1782 GList *devices, *dev;
1785 g_return_val_if_fail (GDK_IS_DISPLAY (display), TRUE);
1787 device_manager = gdk_display_get_device_manager (display);
1788 devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
1790 for (dev = devices; dev; dev = dev->next)
1794 if (gdk_device_get_source (device) == GDK_SOURCE_MOUSE &&
1795 gdk_display_device_is_grabbed (display, device))
1803 * gdk_display_device_is_grabbed:
1804 * @display: a #GdkDisplay
1805 * @device: a #GdkDevice
1807 * Returns %TRUE if there is an ongoing grab on @device for @display.
1809 * Returns: %TRUE if there is a grab in effect for @device.
1812 gdk_display_device_is_grabbed (GdkDisplay *display,
1815 GdkDeviceGrabInfo *info;
1817 g_return_val_if_fail (GDK_IS_DISPLAY (display), TRUE);
1818 g_return_val_if_fail (GDK_IS_DEVICE (device), TRUE);
1820 /* What we're interested in is the steady state (ie last grab),
1821 because we're interested e.g. if we grabbed so that we
1822 can ungrab, even if our grab is not active just yet. */
1823 info = _gdk_display_get_last_device_grab (display, device);
1825 return (info && !info->implicit);
1829 * gdk_display_get_device_manager:
1830 * @display: a #GdkDisplay.
1832 * Returns the #GdkDeviceManager associated to @display.
1834 * Returns: (transfer none): A #GdkDeviceManager, or %NULL. This memory is
1835 * owned by GDK and must not be freed or unreferenced.
1840 gdk_display_get_device_manager (GdkDisplay *display)
1842 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1844 return display->device_manager;
1848 * gdk_display_get_name:
1849 * @display: a #GdkDisplay
1851 * Gets the name of the display.
1853 * Returns: a string representing the display name. This string is owned
1854 * by GDK and should not be modified or freed.
1858 G_CONST_RETURN gchar *
1859 gdk_display_get_name (GdkDisplay *display)
1861 return GDK_DISPLAY_GET_CLASS(display)->get_name (display);
1865 gdk_get_display (void)
1867 return g_strdup (gdk_display_get_name (gdk_display_get_default ()));
1871 * gdk_display_get_n_screens:
1872 * @display: a #GdkDisplay
1874 * Gets the number of screen managed by the @display.
1876 * Returns: number of screens.
1881 gdk_display_get_n_screens (GdkDisplay *display)
1883 return GDK_DISPLAY_GET_CLASS(display)->get_n_screens (display);
1887 * gdk_display_get_screen:
1888 * @display: a #GdkDisplay
1889 * @screen_num: the screen number
1891 * Returns a screen object for one of the screens of the display.
1893 * Returns: (transfer none): the #GdkScreen object
1898 gdk_display_get_screen (GdkDisplay *display,
1901 return GDK_DISPLAY_GET_CLASS(display)->get_screen (display, screen_num);
1905 * gdk_display_get_default_screen:
1906 * @display: a #GdkDisplay
1908 * Get the default #GdkScreen for @display.
1910 * Returns: (transfer none): the default #GdkScreen object for @display
1915 gdk_display_get_default_screen (GdkDisplay *display)
1917 return GDK_DISPLAY_GET_CLASS(display)->get_default_screen (display);
1922 * @display: a #GdkDisplay
1924 * Emits a short beep on @display
1929 gdk_display_beep (GdkDisplay *display)
1931 GDK_DISPLAY_GET_CLASS(display)->beep (display);
1936 * @display: a #GdkDisplay
1938 * Flushes any requests queued for the windowing system and waits until all
1939 * requests have been handled. This is often used for making sure that the
1940 * display is synchronized with the current state of the program. Calling
1941 * gdk_display_sync() before gdk_error_trap_pop() makes sure that any errors
1942 * generated from earlier requests are handled before the error trap is
1945 * This is most useful for X11. On windowing systems where requests are
1946 * handled synchronously, this function will do nothing.
1951 gdk_display_sync (GdkDisplay *display)
1953 GDK_DISPLAY_GET_CLASS(display)->sync (display);
1957 * gdk_display_flush:
1958 * @display: a #GdkDisplay
1960 * Flushes any requests queued for the windowing system; this happens automatically
1961 * when the main loop blocks waiting for new events, but if your application
1962 * is drawing without returning control to the main loop, you may need
1963 * to call this function explicitely. A common case where this function
1964 * needs to be called is when an application is executing drawing commands
1965 * from a thread other than the thread where the main loop is running.
1967 * This is most useful for X11. On windowing systems where requests are
1968 * handled synchronously, this function will do nothing.
1973 gdk_display_flush (GdkDisplay *display)
1975 GDK_DISPLAY_GET_CLASS(display)->flush (display);
1979 * gdk_display_get_default_group:
1980 * @display: a #GdkDisplay
1982 * Returns the default group leader window for all toplevel windows
1983 * on @display. This window is implicitly created by GDK.
1984 * See gdk_window_set_group().
1986 * Return value: (transfer none): The default group leader window
1992 gdk_display_get_default_group (GdkDisplay *display)
1994 return GDK_DISPLAY_GET_CLASS(display)->get_default_group (display);
1998 * gdk_display_supports_selection_notification:
1999 * @display: a #GdkDisplay
2001 * Returns whether #GdkEventOwnerChange events will be
2002 * sent when the owner of a selection changes.
2004 * Return value: whether #GdkEventOwnerChange events will
2010 gdk_display_supports_selection_notification (GdkDisplay *display)
2012 return GDK_DISPLAY_GET_CLASS(display)->supports_selection_notification (display);
2016 * gdk_display_request_selection_notification:
2017 * @display: a #GdkDisplay
2018 * @selection: the #GdkAtom naming the selection for which
2019 * ownership change notification is requested
2021 * Request #GdkEventOwnerChange events for ownership changes
2022 * of the selection named by the given atom.
2024 * Return value: whether #GdkEventOwnerChange events will
2030 gdk_display_request_selection_notification (GdkDisplay *display,
2034 return GDK_DISPLAY_GET_CLASS(display)->request_selection_notification (display, selection);
2038 * gdk_display_supports_clipboard_persistence
2039 * @display: a #GdkDisplay
2041 * Returns whether the speicifed display supports clipboard
2042 * persistance; i.e. if it's possible to store the clipboard data after an
2043 * application has quit. On X11 this checks if a clipboard daemon is
2046 * Returns: %TRUE if the display supports clipboard persistance.
2051 gdk_display_supports_clipboard_persistence (GdkDisplay *display)
2053 return GDK_DISPLAY_GET_CLASS(display)->supports_clipboard_persistence (display);
2057 * gdk_display_store_clipboard
2058 * @display: a #GdkDisplay
2059 * @clipboard_window: a #GdkWindow belonging to the clipboard owner
2060 * @time_: a timestamp
2061 * @targets: an array of targets that should be saved, or %NULL
2062 * if all available targets should be saved.
2063 * @n_targets: length of the @targets array
2065 * Issues a request to the clipboard manager to store the
2066 * clipboard data. On X11, this is a special program that works
2067 * according to the freedesktop clipboard specification, available at
2068 * <ulink url="http://www.freedesktop.org/Standards/clipboard-manager-spec">
2069 * http://www.freedesktop.org/Standards/clipboard-manager-spec</ulink>.
2074 gdk_display_store_clipboard (GdkDisplay *display,
2075 GdkWindow *clipboard_window,
2077 const GdkAtom *targets,
2080 GDK_DISPLAY_GET_CLASS(display)->store_clipboard (display, clipboard_window, time_, targets, n_targets);
2084 * gdk_display_supports_shapes:
2085 * @display: a #GdkDisplay
2087 * Returns %TRUE if gdk_window_shape_combine_mask() can
2088 * be used to create shaped windows on @display.
2090 * Returns: %TRUE if shaped windows are supported
2095 gdk_display_supports_shapes (GdkDisplay *display)
2097 return GDK_DISPLAY_GET_CLASS(display)->supports_shapes (display);
2101 * gdk_display_supports_input_shapes:
2102 * @display: a #GdkDisplay
2104 * Returns %TRUE if gdk_window_input_shape_combine_mask() can
2105 * be used to modify the input shape of windows on @display.
2107 * Returns: %TRUE if windows with modified input shape are supported
2112 gdk_display_supports_input_shapes (GdkDisplay *display)
2114 return GDK_DISPLAY_GET_CLASS(display)->supports_input_shapes (display);
2118 * gdk_display_supports_composite:
2119 * @display: a #GdkDisplay
2121 * Returns %TRUE if gdk_window_set_composited() can be used
2122 * to redirect drawing on the window using compositing.
2124 * Currently this only works on X11 with XComposite and
2125 * XDamage extensions available.
2127 * Returns: %TRUE if windows may be composited.
2132 gdk_display_supports_composite (GdkDisplay *display)
2134 return GDK_DISPLAY_GET_CLASS(display)->supports_composite (display);
2138 * gdk_display_list_devices:
2139 * @display: a #GdkDisplay
2141 * Returns the list of available input devices attached to @display.
2142 * The list is statically allocated and should not be freed.
2144 * Return value: (transfer none) (element-type GdkDevice):
2145 * a list of #GdkDevice
2149 * Deprecated: 3.0: Use gdk_device_manager_list_devices() instead.
2152 gdk_display_list_devices (GdkDisplay *display)
2154 return GDK_DISPLAY_GET_CLASS(display)->list_devices (display);
2158 * gdk_event_send_client_message_for_display:
2159 * @display: the #GdkDisplay for the window where the message is to be sent.
2160 * @event: the #GdkEvent to send, which should be a #GdkEventClient.
2161 * @winid: the window to send the client message to.
2163 * On X11, sends an X ClientMessage event to a given window. On
2164 * Windows, sends a message registered with the name
2165 * GDK_WIN32_CLIENT_MESSAGE.
2167 * This could be used for communicating between different
2168 * applications, though the amount of data is limited to 20 bytes on
2169 * X11, and to just four bytes on Windows.
2171 * Returns: non-zero on success.
2176 gdk_event_send_client_message_for_display (GdkDisplay *display,
2178 GdkNativeWindow winid)
2180 return GDK_DISPLAY_GET_CLASS(display)->send_client_message (display, event, winid);
2184 * gdk_display_add_client_message_filter:
2185 * @display: a #GdkDisplay for which this message filter applies
2186 * @message_type: the type of ClientMessage events to receive.
2187 * This will be checked against the @message_type field
2188 * of the XClientMessage event struct.
2189 * @func: the function to call to process the event.
2190 * @data: user data to pass to @func.
2192 * Adds a filter to be called when X ClientMessage events are received.
2193 * See gdk_window_add_filter() if you are interested in filtering other
2199 gdk_display_add_client_message_filter (GdkDisplay *display,
2200 GdkAtom message_type,
2204 GDK_DISPLAY_GET_CLASS(display)->add_client_message_filter (display, message_type, func, data);
2208 * gdk_add_client_message_filter:
2209 * @message_type: the type of ClientMessage events to receive. This will be
2210 * checked against the <structfield>message_type</structfield> field of the
2211 * XClientMessage event struct.
2212 * @func: the function to call to process the event.
2213 * @data: user data to pass to @func.
2215 * Adds a filter to the default display to be called when X ClientMessage events
2216 * are received. See gdk_display_add_client_message_filter().
2219 gdk_add_client_message_filter (GdkAtom message_type,
2223 gdk_display_add_client_message_filter (gdk_display_get_default (),
2224 message_type, func, data);
2227 static GdkAppLaunchContext *
2228 gdk_display_real_get_app_launch_context (GdkDisplay *display)
2230 GdkAppLaunchContext *ctx;
2232 ctx = gdk_app_launch_context_new ();
2233 gdk_app_launch_context_set_display (ctx, display);
2239 * gdk_display_get_app_launch_context:
2240 * @display: a #GdkDisplay
2242 * Returns a #GdkAppLaunchContext suitable for launching
2243 * applications on the given display.
2245 * Returns: a new #GdkAppLaunchContext for @display.
2246 * Free with g_object_unref() when done
2250 GdkAppLaunchContext *
2251 gdk_display_get_app_launch_context (GdkDisplay *display)
2253 return GDK_DISPLAY_GET_CLASS(display)->get_app_launch_context (display);
2257 * gdk_drag_get_protocol_for_display:
2258 * @display: the #GdkDisplay where the destination window resides
2259 * @xid: the windowing system id of the destination window.
2260 * @protocol: location where the supported DND protocol is returned.
2262 * Finds out the DND protocol supported by a window.
2264 * Return value: the windowing system id of the window where the drop
2265 * should happen. This may be @xid or the id of a proxy window,
2266 * or zero if @xid does not support Drag and Drop.
2271 gdk_drag_get_protocol_for_display (GdkDisplay *display,
2272 GdkNativeWindow xid,
2273 GdkDragProtocol *protocol)
2275 return GDK_DISPLAY_GET_CLASS (display)->get_drag_protocol (display, xid, protocol, NULL);
2280 * @display_name: the name of the display to open
2284 * Return value: (transfer none): a #GdkDisplay, or %NULL if the display
2285 * could not be opened.
2290 gdk_display_open (const gchar *display_name)
2292 return gdk_display_manager_open_display (gdk_display_manager_get (), display_name);
2296 gdk_display_has_pending (GdkDisplay *display)
2298 return GDK_DISPLAY_GET_CLASS (display)->has_pending (display);
2302 * gdk_display_supports_cursor_alpha:
2303 * @display: a #GdkDisplay
2305 * Returns %TRUE if cursors can use an 8bit alpha channel
2306 * on @display. Otherwise, cursors are restricted to bilevel
2307 * alpha (i.e. a mask).
2309 * Returns: whether cursors can have alpha channels.
2314 gdk_display_supports_cursor_alpha (GdkDisplay *display)
2316 g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
2318 return GDK_DISPLAY_GET_CLASS (display)->supports_cursor_alpha (display);
2322 * gdk_display_supports_cursor_color:
2323 * @display: a #GdkDisplay
2325 * Returns %TRUE if multicolored cursors are supported
2326 * on @display. Otherwise, cursors have only a forground
2327 * and a background color.
2329 * Returns: whether cursors can have multiple colors.
2334 gdk_display_supports_cursor_color (GdkDisplay *display)
2336 g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
2338 return GDK_DISPLAY_GET_CLASS (display)->supports_cursor_color (display);
2342 * gdk_display_get_default_cursor_size:
2343 * @display: a #GdkDisplay
2345 * Returns the default size to use for cursors on @display.
2347 * Returns: the default cursor size.
2352 gdk_display_get_default_cursor_size (GdkDisplay *display)
2354 guint width, height;
2356 g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
2358 GDK_DISPLAY_GET_CLASS (display)->get_default_cursor_size (display,
2362 return MIN (width, height);
2366 * gdk_display_get_maximal_cursor_size:
2367 * @display: a #GdkDisplay
2368 * @width: (out): the return location for the maximal cursor width
2369 * @height: (out): the return location for the maximal cursor height
2371 * Gets the maximal size to use for cursors on @display.
2376 gdk_display_get_maximal_cursor_size (GdkDisplay *display,
2380 g_return_if_fail (GDK_IS_DISPLAY (display));
2382 GDK_DISPLAY_GET_CLASS (display)->get_maximal_cursor_size (display,