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"
28 #include "gdkevents.h"
29 #include "gdkwindowimpl.h"
30 #include "gdkinternals.h"
31 #include "gdkmarshalers.h"
32 #include "gdkscreen.h"
40 * @Short_description: Controls the keyboard/mouse pointer grabs and a set of <type>GdkScreen</type>s
43 * #GdkDisplay objects purpose are two fold:
46 * To grab/ungrab keyboard focus and mouse pointer
49 * To manage and provide information about the #GdkScreen(s)
50 * available for this #GdkDisplay
54 * #GdkDisplay objects are the GDK representation of the X Display which can be
55 * described as <emphasis>a workstation consisting of a keyboard a pointing
56 * device (such as a mouse) and one or more screens</emphasis>.
57 * It is used to open and keep track of various #GdkScreen objects currently
58 * instanciated by the application. It is also used to grab and release the keyboard
59 * and the mouse pointer.
69 static void gdk_display_dispose (GObject *object);
70 static void gdk_display_finalize (GObject *object);
72 static void multihead_get_device_state (GdkDisplay *display,
77 GdkModifierType *mask);
78 static GdkWindow * multihead_window_get_device_position (GdkDisplay *display,
83 GdkModifierType *mask);
84 static GdkWindow * multihead_window_at_device_position (GdkDisplay *display,
89 static void multihead_default_get_pointer (GdkDisplay *display,
93 GdkModifierType *mask);
94 static GdkWindow * multihead_default_window_get_pointer (GdkDisplay *display,
98 GdkModifierType *mask);
99 static GdkWindow * multihead_default_window_at_pointer (GdkDisplay *display,
104 static void singlehead_get_pointer (GdkDisplay *display,
108 GdkModifierType *mask);
109 static GdkWindow* singlehead_window_get_pointer (GdkDisplay *display,
113 GdkModifierType *mask);
114 static GdkWindow* singlehead_window_at_pointer (GdkDisplay *display,
118 static GdkWindow* singlehead_default_window_get_pointer (GdkWindow *window,
121 GdkModifierType *mask);
122 static GdkWindow* singlehead_default_window_at_pointer (GdkScreen *screen,
124 gint *win_y);static GdkWindow *gdk_window_real_window_get_device_position (GdkDisplay *display,
129 GdkModifierType *mask);
130 static GdkWindow *gdk_display_real_get_window_at_device_position (GdkDisplay *display,
134 static GdkAppLaunchContext *gdk_display_real_get_app_launch_context (GdkDisplay *display);
136 static guint signals[LAST_SIGNAL] = { 0 };
138 static char *gdk_sm_client_id;
140 static const GdkDisplayDeviceHooks default_device_hooks = {
141 _gdk_windowing_get_device_state,
142 gdk_window_real_window_get_device_position,
143 gdk_display_real_get_window_at_device_position
146 static const GdkDisplayDeviceHooks multihead_pointer_hooks = {
147 multihead_get_device_state,
148 multihead_window_get_device_position,
149 multihead_window_at_device_position
152 static const GdkDisplayPointerHooks multihead_default_pointer_hooks = {
153 multihead_default_get_pointer,
154 multihead_default_window_get_pointer,
155 multihead_default_window_at_pointer
158 static const GdkDisplayPointerHooks singlehead_pointer_hooks = {
159 singlehead_get_pointer,
160 singlehead_window_get_pointer,
161 singlehead_window_at_pointer
164 static const GdkPointerHooks singlehead_default_pointer_hooks = {
165 singlehead_default_window_get_pointer,
166 singlehead_default_window_at_pointer
169 static const GdkPointerHooks *singlehead_current_pointer_hooks = &singlehead_default_pointer_hooks;
170 static const GdkDisplayPointerHooks *multihead_current_pointer_hooks = &multihead_default_pointer_hooks;
172 G_DEFINE_TYPE (GdkDisplay, gdk_display, G_TYPE_OBJECT)
175 gdk_display_class_init (GdkDisplayClass *class)
177 GObjectClass *object_class = G_OBJECT_CLASS (class);
179 object_class->finalize = gdk_display_finalize;
180 object_class->dispose = gdk_display_dispose;
182 class->get_app_launch_context = gdk_display_real_get_app_launch_context;
185 * GdkDisplay::opened:
186 * @display: the object on which the signal is emitted
188 * The ::opened signal is emitted when the connection to the windowing
189 * system for @display is opened.
192 g_signal_new (g_intern_static_string ("opened"),
193 G_OBJECT_CLASS_TYPE (object_class),
196 g_cclosure_marshal_VOID__VOID,
200 * GdkDisplay::closed:
201 * @display: the object on which the signal is emitted
202 * @is_error: %TRUE if the display was closed due to an error
204 * The ::closed signal is emitted when the connection to the windowing
205 * system for @display is closed.
210 g_signal_new (g_intern_static_string ("closed"),
211 G_OBJECT_CLASS_TYPE (object_class),
213 G_STRUCT_OFFSET (GdkDisplayClass, closed),
215 _gdk_marshal_VOID__BOOLEAN,
222 free_pointer_info (GdkPointerWindowInfo *info)
224 g_object_unref (info->toplevel_under_pointer);
225 g_slice_free (GdkPointerWindowInfo, info);
229 free_device_grab (GdkDeviceGrabInfo *info)
231 g_object_unref (info->window);
232 g_object_unref (info->native_window);
237 free_device_grabs_foreach (gpointer key,
243 g_list_foreach (list, (GFunc) free_device_grab, NULL);
250 device_removed_cb (GdkDeviceManager *device_manager,
254 g_hash_table_remove (display->multiple_click_info, device);
255 g_hash_table_remove (display->device_grabs, device);
256 g_hash_table_remove (display->pointers_info, device);
258 /* FIXME: change core pointer and remove from device list */
262 gdk_display_opened (GdkDisplay *display)
264 GdkDeviceManager *device_manager;
266 device_manager = gdk_display_get_device_manager (display);
268 g_signal_connect (device_manager, "device-removed",
269 G_CALLBACK (device_removed_cb), display);
273 gdk_display_init (GdkDisplay *display)
275 _gdk_displays = g_slist_prepend (_gdk_displays, display);
277 display->double_click_time = 250;
278 display->double_click_distance = 5;
280 display->device_hooks = &default_device_hooks;
282 display->device_grabs = g_hash_table_new (NULL, NULL);
283 display->motion_hint_info = g_hash_table_new_full (NULL, NULL, NULL,
284 (GDestroyNotify) g_free);
286 display->pointers_info = g_hash_table_new_full (NULL, NULL, NULL,
287 (GDestroyNotify) free_pointer_info);
289 display->multiple_click_info = g_hash_table_new_full (NULL, NULL, NULL,
290 (GDestroyNotify) g_free);
292 g_signal_connect (display, "opened",
293 G_CALLBACK (gdk_display_opened), NULL);
297 gdk_display_dispose (GObject *object)
299 GdkDisplay *display = GDK_DISPLAY_OBJECT (object);
300 GdkDeviceManager *device_manager;
302 device_manager = gdk_display_get_device_manager (GDK_DISPLAY_OBJECT (object));
304 g_list_foreach (display->queued_events, (GFunc)gdk_event_free, NULL);
305 g_list_free (display->queued_events);
306 display->queued_events = NULL;
307 display->queued_tail = NULL;
309 _gdk_displays = g_slist_remove (_gdk_displays, object);
311 if (gdk_display_get_default () == display)
314 gdk_display_manager_set_default_display (gdk_display_manager_get(),
315 _gdk_displays->data);
317 gdk_display_manager_set_default_display (gdk_display_manager_get(),
323 /* this is to make it drop devices which may require using the X
324 * display and therefore can't be cleaned up in finalize.
325 * It will also disconnect device_removed_cb
327 g_object_run_dispose (G_OBJECT (display->device_manager));
330 G_OBJECT_CLASS (gdk_display_parent_class)->dispose (object);
334 gdk_display_finalize (GObject *object)
336 GdkDisplay *display = GDK_DISPLAY_OBJECT (object);
338 g_hash_table_foreach_remove (display->device_grabs,
339 free_device_grabs_foreach,
341 g_hash_table_destroy (display->device_grabs);
343 g_hash_table_destroy (display->pointers_info);
344 g_hash_table_destroy (display->multiple_click_info);
346 if (display->device_manager)
347 g_object_unref (display->device_manager);
349 G_OBJECT_CLASS (gdk_display_parent_class)->finalize (object);
354 * @display: a #GdkDisplay
356 * Closes the connection to the windowing system for the given display,
357 * and cleans up associated resources.
362 gdk_display_close (GdkDisplay *display)
364 g_return_if_fail (GDK_IS_DISPLAY (display));
366 if (!display->closed)
368 display->closed = TRUE;
370 g_signal_emit (display, signals[CLOSED], 0, FALSE);
371 g_object_run_dispose (G_OBJECT (display));
373 g_object_unref (display);
378 * gdk_display_is_closed:
379 * @display: a #GdkDisplay
381 * Finds out if the display has been closed.
383 * Returns: %TRUE if the display is closed.
388 gdk_display_is_closed (GdkDisplay *display)
390 g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
392 return display->closed;
396 * gdk_display_get_event:
397 * @display: a #GdkDisplay
399 * Gets the next #GdkEvent to be processed for @display, fetching events from the
400 * windowing system if necessary.
402 * Return value: the next #GdkEvent to be processed, or %NULL if no events
403 * are pending. The returned #GdkEvent should be freed with gdk_event_free().
408 gdk_display_get_event (GdkDisplay *display)
410 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
412 _gdk_events_queue (display);
413 return _gdk_event_unqueue (display);
417 * gdk_display_peek_event:
418 * @display: a #GdkDisplay
420 * Gets a copy of the first #GdkEvent in the @display's event queue, without
421 * removing the event from the queue. (Note that this function will
422 * not get more events from the windowing system. It only checks the events
423 * that have already been moved to the GDK event queue.)
425 * Return value: a copy of the first #GdkEvent on the event queue, or %NULL
426 * if no events are in the queue. The returned #GdkEvent should be freed with
432 gdk_display_peek_event (GdkDisplay *display)
436 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
438 tmp_list = _gdk_event_queue_find_first (display);
441 return gdk_event_copy (tmp_list->data);
447 * gdk_display_put_event:
448 * @display: a #GdkDisplay
449 * @event: a #GdkEvent.
451 * Appends a copy of the given event onto the front of the event
452 * queue for @display.
457 gdk_display_put_event (GdkDisplay *display,
458 const GdkEvent *event)
460 g_return_if_fail (GDK_IS_DISPLAY (display));
461 g_return_if_fail (event != NULL);
463 _gdk_event_queue_append (display, gdk_event_copy (event));
464 /* If the main loop is blocking in a different thread, wake it up */
465 g_main_context_wakeup (NULL);
469 * gdk_display_pointer_ungrab:
470 * @display: a #GdkDisplay.
471 * @time_: a timestap (e.g. %GDK_CURRENT_TIME).
473 * Release any pointer grab.
477 * Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
481 gdk_display_pointer_ungrab (GdkDisplay *display,
484 GdkDeviceManager *device_manager;
485 GList *devices, *dev;
488 g_return_if_fail (GDK_IS_DISPLAY (display));
490 device_manager = gdk_display_get_device_manager (display);
491 devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
493 /* FIXME: Should this be generic to all backends? */
494 /* FIXME: What happens with extended devices? */
495 for (dev = devices; dev; dev = dev->next)
499 if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
502 gdk_device_ungrab (device, time_);
505 g_list_free (devices);
509 * gdk_pointer_ungrab:
510 * @time_: a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no
511 * timestamp is available.
513 * Ungrabs the pointer on the default display, if it is grabbed by this
516 * Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
520 gdk_pointer_ungrab (guint32 time)
522 gdk_display_pointer_ungrab (gdk_display_get_default (), time);
526 * gdk_pointer_is_grabbed:
528 * Returns %TRUE if the pointer on the default display is currently
529 * grabbed by this application.
531 * Note that this does not take the inmplicit pointer grab on button
532 * presses into account.
534 * Return value: %TRUE if the pointer is currently grabbed by this application.
536 * Deprecated: 3.0: Use gdk_display_device_is_grabbed() instead.
539 gdk_pointer_is_grabbed (void)
541 return gdk_display_pointer_is_grabbed (gdk_display_get_default ());
545 * gdk_display_keyboard_ungrab:
546 * @display: a #GdkDisplay.
547 * @time_: a timestap (e.g #GDK_CURRENT_TIME).
549 * Release any keyboard grab
553 * Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
557 gdk_display_keyboard_ungrab (GdkDisplay *display,
560 GdkDeviceManager *device_manager;
561 GList *devices, *dev;
564 g_return_if_fail (GDK_IS_DISPLAY (display));
566 device_manager = gdk_display_get_device_manager (display);
567 devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
569 /* FIXME: Should this be generic to all backends? */
570 /* FIXME: What happens with extended devices? */
571 for (dev = devices; dev; dev = dev->next)
575 if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
578 gdk_device_ungrab (device, time);
581 g_list_free (devices);
585 * gdk_keyboard_ungrab:
586 * @time_: a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no
587 * timestamp is available.
589 * Ungrabs the keyboard on the default display, if it is grabbed by this
592 * Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
596 gdk_keyboard_ungrab (guint32 time)
598 gdk_display_keyboard_ungrab (gdk_display_get_default (), time);
604 * Emits a short beep on the default display.
609 gdk_display_beep (gdk_display_get_default ());
613 * gdk_event_send_client_message:
614 * @event: the #GdkEvent to send, which should be a #GdkEventClient.
615 * @winid: the window to send the X ClientMessage event to.
617 * Sends an X ClientMessage event to a given window (which must be
618 * on the default #GdkDisplay.)
619 * This could be used for communicating between different applications,
620 * though the amount of data is limited to 20 bytes.
622 * Return value: non-zero on success.
625 gdk_event_send_client_message (GdkEvent *event,
626 GdkNativeWindow winid)
628 g_return_val_if_fail (event != NULL, FALSE);
630 return gdk_event_send_client_message_for_display (gdk_display_get_default (),
635 * gdk_event_send_clientmessage_toall:
636 * @event: the #GdkEvent to send, which should be a #GdkEventClient.
638 * Sends an X ClientMessage event to all toplevel windows on the default
641 * Toplevel windows are determined by checking for the WM_STATE property, as
642 * described in the Inter-Client Communication Conventions Manual (ICCCM).
643 * If no windows are found with the WM_STATE property set, the message is sent
644 * to all children of the root window.
647 gdk_event_send_clientmessage_toall (GdkEvent *event)
649 g_return_if_fail (event != NULL);
651 gdk_screen_broadcast_client_message (gdk_screen_get_default (), event);
655 * gdk_set_sm_client_id:
656 * @sm_client_id: the client id assigned by the session manager when the
657 * connection was opened, or %NULL to remove the property.
659 * Sets the <literal>SM_CLIENT_ID</literal> property on the application's leader window so that
660 * the window manager can save the application's state using the X11R6 ICCCM
661 * session management protocol.
663 * See the X Session Management Library documentation for more information on
664 * session management and the Inter-Client Communication Conventions Manual
665 * (ICCCM) for information on the <literal>WM_CLIENT_LEADER</literal> property.
666 * (Both documents are part of the X Window System distribution.)
669 gdk_set_sm_client_id (const gchar* sm_client_id)
671 GSList *displays, *tmp_list;
673 g_free (gdk_sm_client_id);
674 gdk_sm_client_id = g_strdup (sm_client_id);
676 displays = gdk_display_manager_list_displays (gdk_display_manager_get ());
677 for (tmp_list = displays; tmp_list; tmp_list = tmp_list->next)
678 _gdk_windowing_display_set_sm_client_id (tmp_list->data, sm_client_id);
680 g_slist_free (displays);
684 * _gdk_get_sm_client_id:
686 * Gets the client ID set with gdk_set_sm_client_id(), if any.
688 * Return value: Session ID, or %NULL if gdk_set_sm_client_id()
689 * has never been called.
692 _gdk_get_sm_client_id (void)
694 return gdk_sm_client_id;
698 _gdk_display_enable_motion_hints (GdkDisplay *display,
701 gulong *device_serial, serial;
703 device_serial = g_hash_table_lookup (display->motion_hint_info, device);
707 device_serial = g_new0 (gulong, 1);
708 *device_serial = G_MAXULONG;
709 g_hash_table_insert (display->motion_hint_info, device, device_serial);
712 if (*device_serial != 0)
714 serial = _gdk_windowing_window_get_next_serial (display);
715 /* We might not actually generate the next request, so
716 make sure this triggers always, this may cause it to
717 trigger slightly too early, but this is just a hint
721 if (serial < *device_serial)
722 *device_serial = serial;
727 * gdk_display_get_device_state:
728 * @display: a #GdkDisplay.
729 * @device: pointer device to query status about.
730 * @screen: (out) (transfer none) (allow-none): location to store the #GdkScreen
731 * the @device is on, or %NULL.
732 * @x: (out) (allow-none): location to store root window X coordinate of @device, or %NULL.
733 * @y: (out) (allow-none): location to store root window Y coordinate of @device, or %NULL.
734 * @mask: (out) (allow-none): location to store current modifier mask for @device, or %NULL.
736 * Gets the current location and state of @device for a given display.
741 gdk_display_get_device_state (GdkDisplay *display,
746 GdkModifierType *mask)
748 GdkScreen *tmp_screen;
750 GdkModifierType tmp_mask;
752 g_return_if_fail (GDK_IS_DISPLAY (display));
753 g_return_if_fail (GDK_IS_DEVICE (device));
754 g_return_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD);
756 display->device_hooks->get_device_state (display, device, &tmp_screen, &tmp_x, &tmp_y, &tmp_mask);
759 *screen = tmp_screen;
769 * gdk_display_get_window_at_device_position:
770 * @display: a #GdkDisplay.
771 * @device: pointer #GdkDevice to query info to.
772 * @win_x: (out) (allow-none): return location for the X coordinate of the device location,
773 * relative to the window origin, or %NULL.
774 * @win_y: (out) (allow-none): return location for the Y coordinate of the device location,
775 * relative to the window origin, or %NULL.
777 * Obtains the window underneath @device, returning the location of the device in @win_x and @win_y. Returns
778 * %NULL if the window tree under @device is not known to GDK (for example, belongs to another application).
780 * Returns: (transfer none): the #GdkWindow under the device position, or %NULL.
785 gdk_display_get_window_at_device_position (GdkDisplay *display,
793 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
794 g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
795 g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, NULL);
797 window = display->device_hooks->window_at_device_position (display, device, &tmp_x, &tmp_y);
808 * gdk_display_set_device_hooks:
809 * @display: a #GdkDisplay.
810 * @new_hooks: (allow-none): a table of pointers to functions for getting quantities related
811 * to all devices position, or %NULL to restore the default table.
813 * This function allows for hooking into the operation of getting the current location of any
814 * #GdkDevice on a particular #GdkDisplay. This is only useful for such low-level tools as
815 * an event recorder. Applications should never have any reason to use this facility.
817 * Returns: (transfer none): The previous device hook table.
821 GdkDisplayDeviceHooks *
822 gdk_display_set_device_hooks (GdkDisplay *display,
823 const GdkDisplayDeviceHooks *new_hooks)
825 const GdkDisplayDeviceHooks *result;
827 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
828 result = display->device_hooks;
831 display->device_hooks = new_hooks;
833 display->device_hooks = &default_device_hooks;
835 return (GdkDisplayDeviceHooks *) result;
839 * gdk_display_get_pointer:
840 * @display: a #GdkDisplay
841 * @screen: (allow-none): location to store the screen that the
842 * cursor is on, or %NULL.
843 * @x: (out) (allow-none): location to store root window X coordinate of pointer, or %NULL.
844 * @y: (out) (allow-none): location to store root window Y coordinate of pointer, or %NULL.
845 * @mask: (out) (allow-none): location to store current modifier mask, or %NULL
847 * Gets the current location of the pointer and the current modifier
848 * mask for a given display.
852 * Deprecated: 3.0: Use gdk_display_get_device_state() instead.
855 gdk_display_get_pointer (GdkDisplay *display,
859 GdkModifierType *mask)
861 g_return_if_fail (GDK_IS_DISPLAY (display));
863 gdk_display_get_device_state (display, display->core_pointer, screen, x, y, mask);
867 gdk_display_real_get_window_at_device_position (GdkDisplay *display,
875 window = _gdk_windowing_window_at_device_position (display, device, &x, &y, NULL, FALSE);
877 /* This might need corrections, as the native window returned
878 may contain client side children */
883 window = _gdk_window_find_descendant_at (window,
886 x = floor (xx + 0.5);
887 y = floor (yy + 0.5);
897 gdk_window_real_window_get_device_position (GdkDisplay *display,
902 GdkModifierType *mask)
905 GdkModifierType tmp_mask;
906 gboolean normal_child;
908 normal_child = GDK_WINDOW_IMPL_GET_CLASS (window->impl)->get_device_state (window,
912 /* We got the coords on the impl, convert to the window */
913 tmpx -= window->abs_x;
914 tmpy -= window->abs_y;
924 return _gdk_window_find_child_at (window, tmpx, tmpy);
929 * gdk_display_get_window_at_pointer:
930 * @display: a #GdkDisplay
931 * @win_x: (out) (allow-none): return location for x coordinate of the pointer location relative
932 * to the window origin, or %NULL
933 * @win_y: (out) (allow-none): return location for y coordinate of the pointer location relative
934 & to the window origin, or %NULL
936 * Obtains the window underneath the mouse pointer, returning the location
937 * of the pointer in that window in @win_x, @win_y for @screen. Returns %NULL
938 * if the window under the mouse pointer is not known to GDK (for example,
939 * belongs to another application).
941 * Returns: (transfer none): the window under the mouse pointer, or %NULL
945 * Deprecated: 3.0: Use gdk_display_get_window_at_device_position() instead.
948 gdk_display_get_window_at_pointer (GdkDisplay *display,
952 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
954 return gdk_display_get_window_at_device_position (display, display->core_pointer, win_x, win_y);
958 multihead_get_device_state (GdkDisplay *display,
963 GdkModifierType *mask)
965 multihead_current_pointer_hooks->get_pointer (display, screen, x, y, mask);
969 multihead_window_get_device_position (GdkDisplay *display,
974 GdkModifierType *mask)
976 return multihead_current_pointer_hooks->window_get_pointer (display, window, x, y, mask);
980 multihead_window_at_device_position (GdkDisplay *display,
985 return multihead_current_pointer_hooks->window_at_pointer (display, win_x, win_y);
989 multihead_default_get_pointer (GdkDisplay *display,
993 GdkModifierType *mask)
995 return _gdk_windowing_get_device_state (display,
996 display->core_pointer,
1001 multihead_default_window_get_pointer (GdkDisplay *display,
1005 GdkModifierType *mask)
1007 return gdk_window_real_window_get_device_position (display,
1008 display->core_pointer,
1009 window, x, y, mask);
1013 multihead_default_window_at_pointer (GdkDisplay *display,
1017 return gdk_display_real_get_window_at_device_position (display,
1018 display->core_pointer,
1023 * gdk_display_set_pointer_hooks:
1024 * @display: a #GdkDisplay
1025 * @new_hooks: (allow-none): a table of pointers to functions for getting
1026 * quantities related to the current pointer position,
1027 * or %NULL to restore the default table.
1029 * This function allows for hooking into the operation
1030 * of getting the current location of the pointer on a particular
1031 * display. This is only useful for such low-level tools as an
1032 * event recorder. Applications should never have any
1033 * reason to use this facility.
1035 * Return value: (transfer none): the previous pointer hook table
1039 * Deprecated: 3.0: Use gdk_display_set_device_hooks() instead.
1041 GdkDisplayPointerHooks *
1042 gdk_display_set_pointer_hooks (GdkDisplay *display,
1043 const GdkDisplayPointerHooks *new_hooks)
1045 const GdkDisplayPointerHooks *result = multihead_current_pointer_hooks;
1047 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1050 multihead_current_pointer_hooks = new_hooks;
1052 multihead_current_pointer_hooks = &multihead_default_pointer_hooks;
1054 gdk_display_set_device_hooks (display, &multihead_pointer_hooks);
1056 return (GdkDisplayPointerHooks *)result;
1060 singlehead_get_pointer (GdkDisplay *display,
1064 GdkModifierType *mask)
1066 GdkScreen *default_screen = gdk_display_get_default_screen (display);
1067 GdkWindow *root_window = gdk_screen_get_root_window (default_screen);
1069 *screen = default_screen;
1071 singlehead_current_pointer_hooks->get_pointer (root_window, x, y, mask);
1075 singlehead_window_get_pointer (GdkDisplay *display,
1079 GdkModifierType *mask)
1081 return singlehead_current_pointer_hooks->get_pointer (window, x, y, mask);
1085 singlehead_window_at_pointer (GdkDisplay *display,
1089 GdkScreen *default_screen = gdk_display_get_default_screen (display);
1091 return singlehead_current_pointer_hooks->window_at_pointer (default_screen,
1096 singlehead_default_window_get_pointer (GdkWindow *window,
1099 GdkModifierType *mask)
1101 GdkDisplay *display;
1103 display = gdk_window_get_display (window);
1105 return gdk_window_real_window_get_device_position (display,
1106 display->core_pointer,
1107 window, x, y, mask);
1111 singlehead_default_window_at_pointer (GdkScreen *screen,
1115 GdkDisplay *display;
1117 display = gdk_screen_get_display (screen);
1119 return gdk_display_real_get_window_at_device_position (display,
1120 display->core_pointer,
1125 * gdk_set_pointer_hooks:
1126 * @new_hooks: (allow-none): a table of pointers to functions for getting
1127 * quantities related to the current pointer position,
1128 * or %NULL to restore the default table.
1130 * This function allows for hooking into the operation
1131 * of getting the current location of the pointer. This
1132 * is only useful for such low-level tools as an
1133 * event recorder. Applications should never have any
1134 * reason to use this facility.
1136 * This function is not multihead safe. For multihead operation,
1137 * see gdk_display_set_pointer_hooks().
1139 * Return value: the previous pointer hook table
1141 * Deprecated: 3.0: Use gdk_display_set_device_hooks() instead.
1144 gdk_set_pointer_hooks (const GdkPointerHooks *new_hooks)
1146 const GdkPointerHooks *result = singlehead_current_pointer_hooks;
1149 singlehead_current_pointer_hooks = new_hooks;
1151 singlehead_current_pointer_hooks = &singlehead_default_pointer_hooks;
1153 gdk_display_set_pointer_hooks (gdk_display_get_default (),
1154 &singlehead_pointer_hooks);
1156 return (GdkPointerHooks *)result;
1160 generate_grab_broken_event (GdkWindow *window,
1163 GdkWindow *grab_window)
1165 g_return_if_fail (window != NULL);
1167 if (!GDK_WINDOW_DESTROYED (window))
1171 event = gdk_event_new (GDK_GRAB_BROKEN);
1172 event->grab_broken.window = g_object_ref (window);
1173 event->grab_broken.send_event = FALSE;
1174 event->grab_broken.implicit = implicit;
1175 event->grab_broken.grab_window = grab_window;
1176 gdk_event_set_device (event, device);
1177 event->grab_broken.keyboard = (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD) ? TRUE : FALSE;
1179 gdk_event_put (event);
1180 gdk_event_free (event);
1185 _gdk_display_get_last_device_grab (GdkDisplay *display,
1190 l = g_hash_table_lookup (display->device_grabs, device);
1194 l = g_list_last (l);
1202 _gdk_display_add_device_grab (GdkDisplay *display,
1205 GdkWindow *native_window,
1206 GdkGrabOwnership grab_ownership,
1207 gboolean owner_events,
1208 GdkEventMask event_mask,
1209 unsigned long serial_start,
1213 GdkDeviceGrabInfo *info, *other_info;
1216 info = g_new0 (GdkDeviceGrabInfo, 1);
1218 info->window = g_object_ref (window);
1219 info->native_window = g_object_ref (native_window);
1220 info->serial_start = serial_start;
1221 info->serial_end = G_MAXULONG;
1222 info->owner_events = owner_events;
1223 info->event_mask = event_mask;
1225 info->implicit = implicit;
1226 info->ownership = grab_ownership;
1228 grabs = g_hash_table_lookup (display->device_grabs, device);
1230 /* Find the first grab that has a larger start time (if any) and insert
1231 * before that. I.E we insert after already existing grabs with same
1233 for (l = grabs; l != NULL; l = l->next)
1235 other_info = l->data;
1237 if (info->serial_start < other_info->serial_start)
1241 grabs = g_list_insert_before (grabs, l, info);
1243 /* Make sure the new grab end before next grab */
1246 other_info = l->data;
1247 info->serial_end = other_info->serial_start;
1250 /* Find any previous grab and update its end time */
1251 l = g_list_find (grabs, info);
1255 other_info = l->data;
1256 other_info->serial_end = serial_start;
1259 g_hash_table_insert (display->device_grabs, device, grabs);
1264 /* _gdk_synthesize_crossing_events only works inside one toplevel.
1265 This function splits things into two calls if needed, converting the
1266 coordinates to the right toplevel */
1268 synthesize_crossing_events (GdkDisplay *display,
1270 GdkDevice *source_device,
1271 GdkWindow *src_window,
1272 GdkWindow *dest_window,
1273 GdkCrossingMode crossing_mode,
1277 GdkWindow *src_toplevel, *dest_toplevel;
1278 GdkModifierType state;
1281 /* We use the native crossing events if all native */
1282 if (_gdk_native_windows)
1286 src_toplevel = gdk_window_get_toplevel (src_window);
1288 src_toplevel = NULL;
1290 dest_toplevel = gdk_window_get_toplevel (dest_window);
1292 dest_toplevel = NULL;
1294 if (src_toplevel == NULL && dest_toplevel == NULL)
1297 if (src_toplevel == NULL ||
1298 src_toplevel == dest_toplevel)
1300 /* Same toplevels */
1301 gdk_window_get_pointer (dest_toplevel,
1303 _gdk_synthesize_crossing_events (display,
1306 device, source_device,
1313 else if (dest_toplevel == NULL)
1315 gdk_window_get_pointer (src_toplevel,
1317 _gdk_synthesize_crossing_events (display,
1320 device, source_device,
1329 /* Different toplevels */
1330 gdk_window_get_pointer (src_toplevel,
1332 _gdk_synthesize_crossing_events (display,
1335 device, source_device,
1341 gdk_window_get_pointer (dest_toplevel,
1343 _gdk_synthesize_crossing_events (display,
1346 device, source_device,
1356 get_current_toplevel (GdkDisplay *display,
1360 GdkModifierType *state_out)
1362 GdkWindow *pointer_window;
1364 GdkModifierType state;
1366 pointer_window = _gdk_windowing_window_at_device_position (display, device, &x, &y, &state, TRUE);
1368 if (pointer_window != NULL &&
1369 (GDK_WINDOW_DESTROYED (pointer_window) ||
1370 GDK_WINDOW_TYPE (pointer_window) == GDK_WINDOW_ROOT ||
1371 GDK_WINDOW_TYPE (pointer_window) == GDK_WINDOW_FOREIGN))
1372 pointer_window = NULL;
1377 return pointer_window;
1381 switch_to_pointer_grab (GdkDisplay *display,
1383 GdkDevice *source_device,
1384 GdkDeviceGrabInfo *grab,
1385 GdkDeviceGrabInfo *last_grab,
1389 GdkWindow *src_window, *pointer_window, *new_toplevel;
1390 GdkPointerWindowInfo *info;
1392 GdkModifierType state;
1395 /* Temporarily unset pointer to make sure we send the crossing events below */
1396 old_grabs = g_hash_table_lookup (display->device_grabs, device);
1397 g_hash_table_steal (display->device_grabs, device);
1398 info = _gdk_display_get_pointer_info (display, device);
1402 /* New grab is in effect */
1404 /* We need to generate crossing events for the grab.
1405 * However, there are never any crossing events for implicit grabs
1406 * TODO: ... Actually, this could happen if the pointer window
1407 * doesn't have button mask so a parent gets the event...
1409 if (!grab->implicit)
1411 /* We send GRAB crossing events from the window under the pointer to the
1412 grab window. Except if there is an old grab then we start from that */
1414 src_window = last_grab->window;
1416 src_window = info->window_under_pointer;
1418 if (src_window != grab->window)
1419 synthesize_crossing_events (display, device, source_device,
1420 src_window, grab->window,
1421 GDK_CROSSING_GRAB, time, serial);
1423 /* !owner_event Grabbing a window that we're not inside, current status is
1424 now NULL (i.e. outside grabbed window) */
1425 if (!grab->owner_events && info->window_under_pointer != grab->window)
1426 _gdk_display_set_window_under_pointer (display, device, NULL);
1429 grab->activated = TRUE;
1434 new_toplevel = NULL;
1436 if (grab == NULL /* ungrab */ ||
1437 (!last_grab->owner_events && grab->owner_events) /* switched to owner_events */ )
1439 /* We force check what window we're in, and update the toplevel_under_pointer info,
1440 * as that won't get told of this change with toplevel enter events.
1442 if (info->toplevel_under_pointer)
1443 g_object_unref (info->toplevel_under_pointer);
1444 info->toplevel_under_pointer = NULL;
1446 new_toplevel = get_current_toplevel (display, device, &x, &y, &state);
1449 /* w is now toplevel and x,y in toplevel coords */
1450 info->toplevel_under_pointer = g_object_ref (new_toplevel);
1451 info->toplevel_x = x;
1452 info->toplevel_y = y;
1453 info->state = state;
1457 if (grab == NULL) /* Ungrabbed, send events */
1459 pointer_window = NULL;
1462 /* Find (possibly virtual) child window */
1464 _gdk_window_find_descendant_at (new_toplevel,
1469 if (pointer_window != last_grab->window)
1470 synthesize_crossing_events (display, device, source_device,
1471 last_grab->window, pointer_window,
1472 GDK_CROSSING_UNGRAB, time, serial);
1474 /* We're now ungrabbed, update the window_under_pointer */
1475 _gdk_display_set_window_under_pointer (display, device, pointer_window);
1479 g_hash_table_insert (display->device_grabs, device, old_grabs);
1483 _gdk_display_device_grab_update (GdkDisplay *display,
1485 GdkDevice *source_device,
1486 gulong current_serial)
1488 GdkDeviceGrabInfo *current_grab, *next_grab;
1492 time = display->last_event_time;
1493 grabs = g_hash_table_lookup (display->device_grabs, device);
1495 while (grabs != NULL)
1497 current_grab = grabs->data;
1499 if (current_grab->serial_start > current_serial)
1500 return; /* Hasn't started yet */
1502 if (current_grab->serial_end > current_serial)
1504 /* This one hasn't ended yet.
1505 its the currently active one or scheduled to be active */
1507 if (!current_grab->activated)
1509 if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
1510 switch_to_pointer_grab (display, device, source_device, current_grab, NULL, time, current_serial);
1519 /* This is the next active grab */
1520 next_grab = grabs->next->data;
1522 if (next_grab->serial_start > current_serial)
1523 next_grab = NULL; /* Actually its not yet active */
1526 if ((next_grab == NULL && current_grab->implicit_ungrab) ||
1527 (next_grab != NULL && current_grab->window != next_grab->window))
1528 generate_grab_broken_event (GDK_WINDOW (current_grab->window),
1530 current_grab->implicit,
1531 next_grab? next_grab->window : NULL);
1533 /* Remove old grab */
1534 grabs = g_list_delete_link (grabs, grabs);
1535 g_hash_table_insert (display->device_grabs, device, grabs);
1537 if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
1538 switch_to_pointer_grab (display, device, source_device,
1539 next_grab, current_grab,
1540 time, current_serial);
1542 free_device_grab (current_grab);
1547 grab_list_find (GList *grabs,
1550 GdkDeviceGrabInfo *grab;
1556 if (serial >= grab->serial_start && serial < grab->serial_end)
1559 grabs = grabs->next;
1566 find_device_grab (GdkDisplay *display,
1572 l = g_hash_table_lookup (display->device_grabs, device);
1573 return grab_list_find (l, serial);
1577 _gdk_display_has_device_grab (GdkDisplay *display,
1583 l = find_device_grab (display, device, serial);
1590 /* Returns true if last grab was ended
1591 * If if_child is non-NULL, end the grab only if the grabbed
1592 * window is the same as if_child or a descendant of it */
1594 _gdk_display_end_device_grab (GdkDisplay *display,
1597 GdkWindow *if_child,
1600 GdkDeviceGrabInfo *grab;
1603 l = find_device_grab (display, device, serial);
1610 (if_child == NULL ||
1611 _gdk_window_event_parent_of (if_child, grab->window)))
1613 grab->serial_end = serial;
1614 grab->implicit_ungrab = implicit;
1615 return l->next == NULL;
1621 /* Returns TRUE if device events are not blocked by any grab */
1623 _gdk_display_check_grab_ownership (GdkDisplay *display,
1627 GHashTableIter iter;
1628 gpointer key, value;
1629 GdkGrabOwnership higher_ownership, device_ownership;
1630 gboolean device_is_keyboard;
1632 g_hash_table_iter_init (&iter, display->device_grabs);
1633 higher_ownership = device_ownership = GDK_OWNERSHIP_NONE;
1634 device_is_keyboard = (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD);
1636 while (g_hash_table_iter_next (&iter, &key, &value))
1638 GdkDeviceGrabInfo *grab;
1644 grabs = grab_list_find (grabs, serial);
1649 /* Discard device if it's not of the same type */
1650 if ((device_is_keyboard && gdk_device_get_source (dev) != GDK_SOURCE_KEYBOARD) ||
1651 (!device_is_keyboard && gdk_device_get_source (dev) == GDK_SOURCE_KEYBOARD))
1657 device_ownership = grab->ownership;
1660 if (grab->ownership > higher_ownership)
1661 higher_ownership = grab->ownership;
1665 if (higher_ownership > device_ownership)
1667 /* There's a higher priority ownership
1668 * going on for other device(s)
1676 GdkPointerWindowInfo *
1677 _gdk_display_get_pointer_info (GdkDisplay *display,
1680 GdkPointerWindowInfo *info;
1682 if (G_UNLIKELY (!device))
1685 info = g_hash_table_lookup (display->pointers_info, device);
1687 if (G_UNLIKELY (!info))
1689 info = g_slice_new0 (GdkPointerWindowInfo);
1690 g_hash_table_insert (display->pointers_info, device, info);
1697 _gdk_display_pointer_info_foreach (GdkDisplay *display,
1698 GdkDisplayPointerInfoForeach func,
1701 GHashTableIter iter;
1702 gpointer key, value;
1704 g_hash_table_iter_init (&iter, display->pointers_info);
1706 while (g_hash_table_iter_next (&iter, &key, &value))
1708 GdkPointerWindowInfo *info = value;
1709 GdkDevice *device = key;
1711 (func) (display, device, info, user_data);
1716 * gdk_device_grab_info_libgtk_only:
1717 * @display: the display for which to get the grab information
1718 * @device: device to get the grab information from
1719 * @grab_window: (out) (transfer none): location to store current grab window
1720 * @owner_events: (out): location to store boolean indicating whether
1721 * the @owner_events flag to gdk_keyboard_grab() or
1722 * gdk_pointer_grab() was %TRUE.
1724 * Determines information about the current keyboard grab.
1725 * This is not public API and must not be used by applications.
1727 * Return value: %TRUE if this application currently has the
1731 gdk_device_grab_info_libgtk_only (GdkDisplay *display,
1733 GdkWindow **grab_window,
1734 gboolean *owner_events)
1736 GdkDeviceGrabInfo *info;
1738 g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
1739 g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
1741 info = _gdk_display_get_last_device_grab (display, device);
1746 *grab_window = info->window;
1748 *owner_events = info->owner_events;
1757 * gdk_display_pointer_is_grabbed:
1758 * @display: a #GdkDisplay
1760 * Test if the pointer is grabbed.
1762 * Returns: %TRUE if an active X pointer grab is in effect
1766 * Deprecated: 3.0: Use gdk_display_device_is_grabbed() instead.
1769 gdk_display_pointer_is_grabbed (GdkDisplay *display)
1771 GdkDeviceManager *device_manager;
1772 GList *devices, *dev;
1775 g_return_val_if_fail (GDK_IS_DISPLAY (display), TRUE);
1777 device_manager = gdk_display_get_device_manager (display);
1778 devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
1780 for (dev = devices; dev; dev = dev->next)
1784 if (gdk_device_get_source (device) == GDK_SOURCE_MOUSE &&
1785 gdk_display_device_is_grabbed (display, device))
1793 * gdk_display_device_is_grabbed:
1794 * @display: a #GdkDisplay
1795 * @device: a #GdkDevice
1797 * Returns %TRUE if there is an ongoing grab on @device for @display.
1799 * Returns: %TRUE if there is a grab in effect for @device.
1802 gdk_display_device_is_grabbed (GdkDisplay *display,
1805 GdkDeviceGrabInfo *info;
1807 g_return_val_if_fail (GDK_IS_DISPLAY (display), TRUE);
1808 g_return_val_if_fail (GDK_IS_DEVICE (device), TRUE);
1810 /* What we're interested in is the steady state (ie last grab),
1811 because we're interested e.g. if we grabbed so that we
1812 can ungrab, even if our grab is not active just yet. */
1813 info = _gdk_display_get_last_device_grab (display, device);
1815 return (info && !info->implicit);
1819 * gdk_display_get_device_manager:
1820 * @display: a #GdkDisplay.
1822 * Returns the #GdkDeviceManager associated to @display.
1824 * Returns: (transfer none): A #GdkDeviceManager, or %NULL. This memory is
1825 * owned by GDK and must not be freed or unreferenced.
1830 gdk_display_get_device_manager (GdkDisplay *display)
1832 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1834 return display->device_manager;
1838 * gdk_display_get_name:
1839 * @display: a #GdkDisplay
1841 * Gets the name of the display.
1843 * Returns: a string representing the display name. This string is owned
1844 * by GDK and should not be modified or freed.
1848 G_CONST_RETURN gchar *
1849 gdk_display_get_name (GdkDisplay *display)
1851 return GDK_DISPLAY_GET_CLASS(display)->get_name (display);
1855 gdk_get_display (void)
1857 return g_strdup (gdk_display_get_name (gdk_display_get_default ()));
1861 * gdk_display_get_n_screens:
1862 * @display: a #GdkDisplay
1864 * Gets the number of screen managed by the @display.
1866 * Returns: number of screens.
1871 gdk_display_get_n_screens (GdkDisplay *display)
1873 return GDK_DISPLAY_GET_CLASS(display)->get_n_screens (display);
1877 * gdk_display_get_screen:
1878 * @display: a #GdkDisplay
1879 * @screen_num: the screen number
1881 * Returns a screen object for one of the screens of the display.
1883 * Returns: (transfer none): the #GdkScreen object
1888 gdk_display_get_screen (GdkDisplay *display,
1891 return GDK_DISPLAY_GET_CLASS(display)->get_screen (display, screen_num);
1895 * gdk_display_get_default_screen:
1896 * @display: a #GdkDisplay
1898 * Get the default #GdkScreen for @display.
1900 * Returns: (transfer none): the default #GdkScreen object for @display
1905 gdk_display_get_default_screen (GdkDisplay *display)
1907 return GDK_DISPLAY_GET_CLASS(display)->get_default_screen (display);
1912 * @display: a #GdkDisplay
1914 * Emits a short beep on @display
1919 gdk_display_beep (GdkDisplay *display)
1921 GDK_DISPLAY_GET_CLASS(display)->beep (display);
1926 * @display: a #GdkDisplay
1928 * Flushes any requests queued for the windowing system and waits until all
1929 * requests have been handled. This is often used for making sure that the
1930 * display is synchronized with the current state of the program. Calling
1931 * gdk_display_sync() before gdk_error_trap_pop() makes sure that any errors
1932 * generated from earlier requests are handled before the error trap is
1935 * This is most useful for X11. On windowing systems where requests are
1936 * handled synchronously, this function will do nothing.
1941 gdk_display_sync (GdkDisplay *display)
1943 GDK_DISPLAY_GET_CLASS(display)->sync (display);
1947 * gdk_display_flush:
1948 * @display: a #GdkDisplay
1950 * Flushes any requests queued for the windowing system; this happens automatically
1951 * when the main loop blocks waiting for new events, but if your application
1952 * is drawing without returning control to the main loop, you may need
1953 * to call this function explicitely. A common case where this function
1954 * needs to be called is when an application is executing drawing commands
1955 * from a thread other than the thread where the main loop is running.
1957 * This is most useful for X11. On windowing systems where requests are
1958 * handled synchronously, this function will do nothing.
1963 gdk_display_flush (GdkDisplay *display)
1965 GDK_DISPLAY_GET_CLASS(display)->flush (display);
1969 * gdk_display_get_default_group:
1970 * @display: a #GdkDisplay
1972 * Returns the default group leader window for all toplevel windows
1973 * on @display. This window is implicitly created by GDK.
1974 * See gdk_window_set_group().
1976 * Return value: (transfer none): The default group leader window
1982 gdk_display_get_default_group (GdkDisplay *display)
1984 return GDK_DISPLAY_GET_CLASS(display)->get_default_group (display);
1988 * gdk_display_supports_selection_notification:
1989 * @display: a #GdkDisplay
1991 * Returns whether #GdkEventOwnerChange events will be
1992 * sent when the owner of a selection changes.
1994 * Return value: whether #GdkEventOwnerChange events will
2000 gdk_display_supports_selection_notification (GdkDisplay *display)
2002 return GDK_DISPLAY_GET_CLASS(display)->supports_selection_notification (display);
2006 * gdk_display_request_selection_notification:
2007 * @display: a #GdkDisplay
2008 * @selection: the #GdkAtom naming the selection for which
2009 * ownership change notification is requested
2011 * Request #GdkEventOwnerChange events for ownership changes
2012 * of the selection named by the given atom.
2014 * Return value: whether #GdkEventOwnerChange events will
2020 gdk_display_request_selection_notification (GdkDisplay *display,
2024 return GDK_DISPLAY_GET_CLASS(display)->request_selection_notification (display, selection);
2028 * gdk_display_supports_clipboard_persistence
2029 * @display: a #GdkDisplay
2031 * Returns whether the speicifed display supports clipboard
2032 * persistance; i.e. if it's possible to store the clipboard data after an
2033 * application has quit. On X11 this checks if a clipboard daemon is
2036 * Returns: %TRUE if the display supports clipboard persistance.
2041 gdk_display_supports_clipboard_persistence (GdkDisplay *display)
2043 return GDK_DISPLAY_GET_CLASS(display)->supports_clipboard_persistence (display);
2047 * gdk_display_store_clipboard
2048 * @display: a #GdkDisplay
2049 * @clipboard_window: a #GdkWindow belonging to the clipboard owner
2050 * @time_: a timestamp
2051 * @targets: an array of targets that should be saved, or %NULL
2052 * if all available targets should be saved.
2053 * @n_targets: length of the @targets array
2055 * Issues a request to the clipboard manager to store the
2056 * clipboard data. On X11, this is a special program that works
2057 * according to the freedesktop clipboard specification, available at
2058 * <ulink url="http://www.freedesktop.org/Standards/clipboard-manager-spec">
2059 * http://www.freedesktop.org/Standards/clipboard-manager-spec</ulink>.
2064 gdk_display_store_clipboard (GdkDisplay *display,
2065 GdkWindow *clipboard_window,
2067 const GdkAtom *targets,
2070 GDK_DISPLAY_GET_CLASS(display)->store_clipboard (display, clipboard_window, time_, targets, n_targets);
2074 * gdk_display_supports_shapes:
2075 * @display: a #GdkDisplay
2077 * Returns %TRUE if gdk_window_shape_combine_mask() can
2078 * be used to create shaped windows on @display.
2080 * Returns: %TRUE if shaped windows are supported
2085 gdk_display_supports_shapes (GdkDisplay *display)
2087 return GDK_DISPLAY_GET_CLASS(display)->supports_shapes (display);
2091 * gdk_display_supports_input_shapes:
2092 * @display: a #GdkDisplay
2094 * Returns %TRUE if gdk_window_input_shape_combine_mask() can
2095 * be used to modify the input shape of windows on @display.
2097 * Returns: %TRUE if windows with modified input shape are supported
2102 gdk_display_supports_input_shapes (GdkDisplay *display)
2104 return GDK_DISPLAY_GET_CLASS(display)->supports_input_shapes (display);
2108 * gdk_display_supports_composite:
2109 * @display: a #GdkDisplay
2111 * Returns %TRUE if gdk_window_set_composited() can be used
2112 * to redirect drawing on the window using compositing.
2114 * Currently this only works on X11 with XComposite and
2115 * XDamage extensions available.
2117 * Returns: %TRUE if windows may be composited.
2122 gdk_display_supports_composite (GdkDisplay *display)
2124 return GDK_DISPLAY_GET_CLASS(display)->supports_composite (display);
2128 * gdk_display_list_devices:
2129 * @display: a #GdkDisplay
2131 * Returns the list of available input devices attached to @display.
2132 * The list is statically allocated and should not be freed.
2134 * Return value: (transfer none) (element-type GdkDevice):
2135 * a list of #GdkDevice
2139 * Deprecated: 3.0: Use gdk_device_manager_list_devices() instead.
2142 gdk_display_list_devices (GdkDisplay *display)
2144 return GDK_DISPLAY_GET_CLASS(display)->list_devices (display);
2148 * gdk_event_send_client_message_for_display:
2149 * @display: the #GdkDisplay for the window where the message is to be sent.
2150 * @event: the #GdkEvent to send, which should be a #GdkEventClient.
2151 * @winid: the window to send the client message to.
2153 * On X11, sends an X ClientMessage event to a given window. On
2154 * Windows, sends a message registered with the name
2155 * GDK_WIN32_CLIENT_MESSAGE.
2157 * This could be used for communicating between different
2158 * applications, though the amount of data is limited to 20 bytes on
2159 * X11, and to just four bytes on Windows.
2161 * Returns: non-zero on success.
2166 gdk_event_send_client_message_for_display (GdkDisplay *display,
2168 GdkNativeWindow winid)
2170 return GDK_DISPLAY_GET_CLASS(display)->send_client_message (display, event, winid);
2174 * gdk_display_add_client_message_filter:
2175 * @display: a #GdkDisplay for which this message filter applies
2176 * @message_type: the type of ClientMessage events to receive.
2177 * This will be checked against the @message_type field
2178 * of the XClientMessage event struct.
2179 * @func: the function to call to process the event.
2180 * @data: user data to pass to @func.
2182 * Adds a filter to be called when X ClientMessage events are received.
2183 * See gdk_window_add_filter() if you are interested in filtering other
2189 gdk_display_add_client_message_filter (GdkDisplay *display,
2190 GdkAtom message_type,
2194 GDK_DISPLAY_GET_CLASS(display)->add_client_message_filter (display, message_type, func, data);
2198 * gdk_add_client_message_filter:
2199 * @message_type: the type of ClientMessage events to receive. This will be
2200 * checked against the <structfield>message_type</structfield> field of the
2201 * XClientMessage event struct.
2202 * @func: the function to call to process the event.
2203 * @data: user data to pass to @func.
2205 * Adds a filter to the default display to be called when X ClientMessage events
2206 * are received. See gdk_display_add_client_message_filter().
2209 gdk_add_client_message_filter (GdkAtom message_type,
2213 gdk_display_add_client_message_filter (gdk_display_get_default (),
2214 message_type, func, data);
2217 static GdkAppLaunchContext *
2218 gdk_display_real_get_app_launch_context (GdkDisplay *display)
2220 GdkAppLaunchContext *ctx;
2222 ctx = gdk_app_launch_context_new ();
2223 gdk_app_launch_context_set_display (ctx, display);
2229 * gdk_display_get_app_launch_context:
2230 * @display: a #GdkDisplay
2232 * Returns a #GdkAppLaunchContext suitable for launching
2233 * applications on the given display.
2235 * Returns: a new #GdkAppLaunchContext for @display.
2236 * Free with g_object_unref() when done
2240 GdkAppLaunchContext *
2241 gdk_display_get_app_launch_context (GdkDisplay *display)
2243 return GDK_DISPLAY_GET_CLASS(display)->get_app_launch_context (display);