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 "gdkdeviceprivate.h"
30 #include "gdkevents.h"
31 #include "gdkwindowimpl.h"
32 #include "gdkinternals.h"
33 #include "gdkmarshalers.h"
34 #include "gdkscreen.h"
42 * @Short_description: Controls the keyboard/mouse pointer grabs and a set of <type>GdkScreen</type>s
45 * #GdkDisplay objects purpose are two fold:
48 * To grab/ungrab keyboard focus and mouse pointer
51 * To manage and provide information about the #GdkScreen(s)
52 * available for this #GdkDisplay
56 * #GdkDisplay objects are the GDK representation of the X Display which can be
57 * described as <emphasis>a workstation consisting of a keyboard a pointing
58 * device (such as a mouse) and one or more screens</emphasis>.
59 * It is used to open and keep track of various #GdkScreen objects currently
60 * instanciated by the application. It is also used to grab and release the keyboard
61 * and the mouse pointer.
71 static void gdk_display_dispose (GObject *object);
72 static void gdk_display_finalize (GObject *object);
74 static void multihead_get_device_state (GdkDisplay *display,
79 GdkModifierType *mask);
80 static GdkWindow * multihead_window_get_device_position (GdkDisplay *display,
85 GdkModifierType *mask);
86 static GdkWindow * multihead_window_at_device_position (GdkDisplay *display,
91 static void multihead_default_get_pointer (GdkDisplay *display,
95 GdkModifierType *mask);
96 static GdkWindow * multihead_default_window_get_pointer (GdkDisplay *display,
100 GdkModifierType *mask);
101 static GdkWindow * multihead_default_window_at_pointer (GdkDisplay *display,
106 static void singlehead_get_pointer (GdkDisplay *display,
110 GdkModifierType *mask);
111 static GdkWindow* singlehead_window_get_pointer (GdkDisplay *display,
115 GdkModifierType *mask);
116 static GdkWindow* singlehead_window_at_pointer (GdkDisplay *display,
120 static GdkWindow* singlehead_default_window_get_pointer (GdkWindow *window,
123 GdkModifierType *mask);
124 static GdkWindow* singlehead_default_window_at_pointer (GdkScreen *screen,
126 gint *win_y);static GdkWindow *gdk_window_real_window_get_device_position (GdkDisplay *display,
131 GdkModifierType *mask);
132 static GdkWindow *gdk_display_real_get_window_at_device_position (GdkDisplay *display,
136 static void gdk_display_real_get_device_state (GdkDisplay *display,
141 GdkModifierType *mask);
142 static GdkAppLaunchContext *gdk_display_real_get_app_launch_context (GdkDisplay *display);
144 static guint signals[LAST_SIGNAL] = { 0 };
146 static const GdkDisplayDeviceHooks default_device_hooks = {
147 gdk_display_real_get_device_state,
148 gdk_window_real_window_get_device_position,
149 gdk_display_real_get_window_at_device_position
152 static const GdkDisplayDeviceHooks multihead_pointer_hooks = {
153 multihead_get_device_state,
154 multihead_window_get_device_position,
155 multihead_window_at_device_position
158 static const GdkDisplayPointerHooks multihead_default_pointer_hooks = {
159 multihead_default_get_pointer,
160 multihead_default_window_get_pointer,
161 multihead_default_window_at_pointer
164 static const GdkDisplayPointerHooks singlehead_pointer_hooks = {
165 singlehead_get_pointer,
166 singlehead_window_get_pointer,
167 singlehead_window_at_pointer
170 static const GdkPointerHooks singlehead_default_pointer_hooks = {
171 singlehead_default_window_get_pointer,
172 singlehead_default_window_at_pointer
175 static const GdkPointerHooks *singlehead_current_pointer_hooks = &singlehead_default_pointer_hooks;
176 static const GdkDisplayPointerHooks *multihead_current_pointer_hooks = &multihead_default_pointer_hooks;
178 G_DEFINE_TYPE (GdkDisplay, gdk_display, G_TYPE_OBJECT)
181 gdk_display_class_init (GdkDisplayClass *class)
183 GObjectClass *object_class = G_OBJECT_CLASS (class);
185 object_class->finalize = gdk_display_finalize;
186 object_class->dispose = gdk_display_dispose;
188 class->get_app_launch_context = gdk_display_real_get_app_launch_context;
191 * GdkDisplay::opened:
192 * @display: the object on which the signal is emitted
194 * The ::opened signal is emitted when the connection to the windowing
195 * system for @display is opened.
198 g_signal_new (g_intern_static_string ("opened"),
199 G_OBJECT_CLASS_TYPE (object_class),
202 g_cclosure_marshal_VOID__VOID,
206 * GdkDisplay::closed:
207 * @display: the object on which the signal is emitted
208 * @is_error: %TRUE if the display was closed due to an error
210 * The ::closed signal is emitted when the connection to the windowing
211 * system for @display is closed.
216 g_signal_new (g_intern_static_string ("closed"),
217 G_OBJECT_CLASS_TYPE (object_class),
219 G_STRUCT_OFFSET (GdkDisplayClass, closed),
221 _gdk_marshal_VOID__BOOLEAN,
228 free_pointer_info (GdkPointerWindowInfo *info)
230 g_object_unref (info->toplevel_under_pointer);
231 g_slice_free (GdkPointerWindowInfo, info);
235 free_device_grab (GdkDeviceGrabInfo *info)
237 g_object_unref (info->window);
238 g_object_unref (info->native_window);
243 free_device_grabs_foreach (gpointer key,
249 g_list_foreach (list, (GFunc) free_device_grab, NULL);
256 device_removed_cb (GdkDeviceManager *device_manager,
260 g_hash_table_remove (display->multiple_click_info, device);
261 g_hash_table_remove (display->device_grabs, device);
262 g_hash_table_remove (display->pointers_info, device);
264 /* FIXME: change core pointer and remove from device list */
268 gdk_display_opened (GdkDisplay *display)
270 GdkDeviceManager *device_manager;
272 device_manager = gdk_display_get_device_manager (display);
274 g_signal_connect (device_manager, "device-removed",
275 G_CALLBACK (device_removed_cb), display);
279 gdk_display_init (GdkDisplay *display)
281 display->double_click_time = 250;
282 display->double_click_distance = 5;
284 display->device_hooks = &default_device_hooks;
286 display->device_grabs = g_hash_table_new (NULL, NULL);
287 display->motion_hint_info = g_hash_table_new_full (NULL, NULL, NULL,
288 (GDestroyNotify) g_free);
290 display->pointers_info = g_hash_table_new_full (NULL, NULL, NULL,
291 (GDestroyNotify) free_pointer_info);
293 display->multiple_click_info = g_hash_table_new_full (NULL, NULL, NULL,
294 (GDestroyNotify) g_free);
296 g_signal_connect (display, "opened",
297 G_CALLBACK (gdk_display_opened), NULL);
301 gdk_display_dispose (GObject *object)
303 GdkDisplay *display = GDK_DISPLAY_OBJECT (object);
304 GdkDeviceManager *device_manager;
306 device_manager = gdk_display_get_device_manager (GDK_DISPLAY_OBJECT (object));
308 g_list_foreach (display->queued_events, (GFunc)gdk_event_free, NULL);
309 g_list_free (display->queued_events);
310 display->queued_events = NULL;
311 display->queued_tail = NULL;
315 /* this is to make it drop devices which may require using the X
316 * display and therefore can't be cleaned up in finalize.
317 * It will also disconnect device_removed_cb
319 g_object_run_dispose (G_OBJECT (display->device_manager));
322 G_OBJECT_CLASS (gdk_display_parent_class)->dispose (object);
326 gdk_display_finalize (GObject *object)
328 GdkDisplay *display = GDK_DISPLAY_OBJECT (object);
330 g_hash_table_foreach_remove (display->device_grabs,
331 free_device_grabs_foreach,
333 g_hash_table_destroy (display->device_grabs);
335 g_hash_table_destroy (display->pointers_info);
336 g_hash_table_destroy (display->multiple_click_info);
338 if (display->device_manager)
339 g_object_unref (display->device_manager);
341 G_OBJECT_CLASS (gdk_display_parent_class)->finalize (object);
346 * @display: a #GdkDisplay
348 * Closes the connection to the windowing system for the given display,
349 * and cleans up associated resources.
354 gdk_display_close (GdkDisplay *display)
356 g_return_if_fail (GDK_IS_DISPLAY (display));
358 if (!display->closed)
360 display->closed = TRUE;
362 g_signal_emit (display, signals[CLOSED], 0, FALSE);
363 g_object_run_dispose (G_OBJECT (display));
365 g_object_unref (display);
370 * gdk_display_is_closed:
371 * @display: a #GdkDisplay
373 * Finds out if the display has been closed.
375 * Returns: %TRUE if the display is closed.
380 gdk_display_is_closed (GdkDisplay *display)
382 g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
384 return display->closed;
388 * gdk_display_get_event:
389 * @display: a #GdkDisplay
391 * Gets the next #GdkEvent to be processed for @display, fetching events from the
392 * windowing system if necessary.
394 * Return value: the next #GdkEvent to be processed, or %NULL if no events
395 * are pending. The returned #GdkEvent should be freed with gdk_event_free().
400 gdk_display_get_event (GdkDisplay *display)
402 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
404 GDK_DISPLAY_GET_CLASS (display)->queue_events (display);
405 return _gdk_event_unqueue (display);
409 * gdk_display_peek_event:
410 * @display: a #GdkDisplay
412 * Gets a copy of the first #GdkEvent in the @display's event queue, without
413 * removing the event from the queue. (Note that this function will
414 * not get more events from the windowing system. It only checks the events
415 * that have already been moved to the GDK event queue.)
417 * Return value: a copy of the first #GdkEvent on the event queue, or %NULL
418 * if no events are in the queue. The returned #GdkEvent should be freed with
424 gdk_display_peek_event (GdkDisplay *display)
428 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
430 tmp_list = _gdk_event_queue_find_first (display);
433 return gdk_event_copy (tmp_list->data);
439 * gdk_display_put_event:
440 * @display: a #GdkDisplay
441 * @event: a #GdkEvent.
443 * Appends a copy of the given event onto the front of the event
444 * queue for @display.
449 gdk_display_put_event (GdkDisplay *display,
450 const GdkEvent *event)
452 g_return_if_fail (GDK_IS_DISPLAY (display));
453 g_return_if_fail (event != NULL);
455 _gdk_event_queue_append (display, gdk_event_copy (event));
456 /* If the main loop is blocking in a different thread, wake it up */
457 g_main_context_wakeup (NULL);
461 * gdk_display_pointer_ungrab:
462 * @display: a #GdkDisplay.
463 * @time_: a timestap (e.g. %GDK_CURRENT_TIME).
465 * Release any pointer grab.
469 * Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
473 gdk_display_pointer_ungrab (GdkDisplay *display,
476 GdkDeviceManager *device_manager;
477 GList *devices, *dev;
480 g_return_if_fail (GDK_IS_DISPLAY (display));
482 device_manager = gdk_display_get_device_manager (display);
483 devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
485 /* FIXME: Should this be generic to all backends? */
486 /* FIXME: What happens with extended devices? */
487 for (dev = devices; dev; dev = dev->next)
491 if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
494 gdk_device_ungrab (device, time_);
497 g_list_free (devices);
501 * gdk_pointer_ungrab:
502 * @time_: a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no
503 * timestamp is available.
505 * Ungrabs the pointer on the default display, if it is grabbed by this
508 * Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
512 gdk_pointer_ungrab (guint32 time)
514 gdk_display_pointer_ungrab (gdk_display_get_default (), time);
518 * gdk_pointer_is_grabbed:
520 * Returns %TRUE if the pointer on the default display is currently
521 * grabbed by this application.
523 * Note that this does not take the inmplicit pointer grab on button
524 * presses into account.
526 * Return value: %TRUE if the pointer is currently grabbed by this application.
528 * Deprecated: 3.0: Use gdk_display_device_is_grabbed() instead.
531 gdk_pointer_is_grabbed (void)
533 return gdk_display_pointer_is_grabbed (gdk_display_get_default ());
537 * gdk_display_keyboard_ungrab:
538 * @display: a #GdkDisplay.
539 * @time_: a timestap (e.g #GDK_CURRENT_TIME).
541 * Release any keyboard grab
545 * Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
549 gdk_display_keyboard_ungrab (GdkDisplay *display,
552 GdkDeviceManager *device_manager;
553 GList *devices, *dev;
556 g_return_if_fail (GDK_IS_DISPLAY (display));
558 device_manager = gdk_display_get_device_manager (display);
559 devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
561 /* FIXME: Should this be generic to all backends? */
562 /* FIXME: What happens with extended devices? */
563 for (dev = devices; dev; dev = dev->next)
567 if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
570 gdk_device_ungrab (device, time);
573 g_list_free (devices);
577 * gdk_keyboard_ungrab:
578 * @time_: a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no
579 * timestamp is available.
581 * Ungrabs the keyboard on the default display, if it is grabbed by this
584 * Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
588 gdk_keyboard_ungrab (guint32 time)
590 gdk_display_keyboard_ungrab (gdk_display_get_default (), time);
596 * Emits a short beep on the default display.
601 gdk_display_beep (gdk_display_get_default ());
607 * Flushes the output buffers of all display connections and waits
608 * until all requests have been processed.
609 * This is rarely needed by applications.
616 list = gdk_display_manager_list_displays (gdk_display_manager_get ());
617 for (l = list; l; l = l->next)
619 GdkDisplay *display = l->data;
621 GDK_DISPLAY_GET_CLASS (display)->sync (display);
628 * gdk_event_send_client_message:
629 * @event: the #GdkEvent to send, which should be a #GdkEventClient.
630 * @winid: the window to send the X ClientMessage event to.
632 * Sends an X ClientMessage event to a given window (which must be
633 * on the default #GdkDisplay.)
634 * This could be used for communicating between different applications,
635 * though the amount of data is limited to 20 bytes.
637 * Return value: non-zero on success.
640 gdk_event_send_client_message (GdkEvent *event,
641 GdkNativeWindow winid)
643 g_return_val_if_fail (event != NULL, FALSE);
645 return gdk_event_send_client_message_for_display (gdk_display_get_default (),
650 * gdk_event_send_clientmessage_toall:
651 * @event: the #GdkEvent to send, which should be a #GdkEventClient.
653 * Sends an X ClientMessage event to all toplevel windows on the default
656 * Toplevel windows are determined by checking for the WM_STATE property, as
657 * described in the Inter-Client Communication Conventions Manual (ICCCM).
658 * If no windows are found with the WM_STATE property set, the message is sent
659 * to all children of the root window.
662 gdk_event_send_clientmessage_toall (GdkEvent *event)
664 g_return_if_fail (event != NULL);
666 gdk_screen_broadcast_client_message (gdk_screen_get_default (), event);
670 _gdk_display_enable_motion_hints (GdkDisplay *display,
673 gulong *device_serial, serial;
675 device_serial = g_hash_table_lookup (display->motion_hint_info, device);
679 device_serial = g_new0 (gulong, 1);
680 *device_serial = G_MAXULONG;
681 g_hash_table_insert (display->motion_hint_info, device, device_serial);
684 if (*device_serial != 0)
686 serial = _gdk_display_get_next_serial (display);
687 /* We might not actually generate the next request, so
688 make sure this triggers always, this may cause it to
689 trigger slightly too early, but this is just a hint
693 if (serial < *device_serial)
694 *device_serial = serial;
699 * gdk_display_get_device_state:
700 * @display: a #GdkDisplay.
701 * @device: pointer device to query status about.
702 * @screen: (out) (transfer none) (allow-none): location to store the #GdkScreen
703 * the @device is on, or %NULL.
704 * @x: (out) (allow-none): location to store root window X coordinate of @device, or %NULL.
705 * @y: (out) (allow-none): location to store root window Y coordinate of @device, or %NULL.
706 * @mask: (out) (allow-none): location to store current modifier mask for @device, or %NULL.
708 * Gets the current location and state of @device for a given display.
713 gdk_display_get_device_state (GdkDisplay *display,
718 GdkModifierType *mask)
720 GdkScreen *tmp_screen;
722 GdkModifierType tmp_mask;
724 g_return_if_fail (GDK_IS_DISPLAY (display));
725 g_return_if_fail (GDK_IS_DEVICE (device));
726 g_return_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD);
728 display->device_hooks->get_device_state (display, device, &tmp_screen, &tmp_x, &tmp_y, &tmp_mask);
731 *screen = tmp_screen;
741 * gdk_display_get_window_at_device_position:
742 * @display: a #GdkDisplay.
743 * @device: pointer #GdkDevice to query info to.
744 * @win_x: (out) (allow-none): return location for the X coordinate of the device location,
745 * relative to the window origin, or %NULL.
746 * @win_y: (out) (allow-none): return location for the Y coordinate of the device location,
747 * relative to the window origin, or %NULL.
749 * Obtains the window underneath @device, returning the location of the device in @win_x and @win_y. Returns
750 * %NULL if the window tree under @device is not known to GDK (for example, belongs to another application).
752 * Returns: (transfer none): the #GdkWindow under the device position, or %NULL.
757 gdk_display_get_window_at_device_position (GdkDisplay *display,
765 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
766 g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
767 g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, NULL);
769 window = display->device_hooks->window_at_device_position (display, device, &tmp_x, &tmp_y);
780 * gdk_display_set_device_hooks:
781 * @display: a #GdkDisplay.
782 * @new_hooks: (allow-none): a table of pointers to functions for getting quantities related
783 * to all devices position, or %NULL to restore the default table.
785 * This function allows for hooking into the operation of getting the current location of any
786 * #GdkDevice on a particular #GdkDisplay. This is only useful for such low-level tools as
787 * an event recorder. Applications should never have any reason to use this facility.
789 * Returns: (transfer none): The previous device hook table.
793 GdkDisplayDeviceHooks *
794 gdk_display_set_device_hooks (GdkDisplay *display,
795 const GdkDisplayDeviceHooks *new_hooks)
797 const GdkDisplayDeviceHooks *result;
799 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
800 result = display->device_hooks;
803 display->device_hooks = new_hooks;
805 display->device_hooks = &default_device_hooks;
807 return (GdkDisplayDeviceHooks *) result;
811 * gdk_display_get_pointer:
812 * @display: a #GdkDisplay
813 * @screen: (allow-none): location to store the screen that the
814 * cursor is on, or %NULL.
815 * @x: (out) (allow-none): location to store root window X coordinate of pointer, or %NULL.
816 * @y: (out) (allow-none): location to store root window Y coordinate of pointer, or %NULL.
817 * @mask: (out) (allow-none): location to store current modifier mask, or %NULL
819 * Gets the current location of the pointer and the current modifier
820 * mask for a given display.
824 * Deprecated: 3.0: Use gdk_display_get_device_state() instead.
827 gdk_display_get_pointer (GdkDisplay *display,
831 GdkModifierType *mask)
833 g_return_if_fail (GDK_IS_DISPLAY (display));
835 gdk_display_get_device_state (display, display->core_pointer, screen, x, y, mask);
839 gdk_display_real_get_window_at_device_position (GdkDisplay *display,
847 window = _gdk_device_window_at_position (device, &x, &y, NULL, FALSE);
849 /* This might need corrections, as the native window returned
850 may contain client side children */
855 window = _gdk_window_find_descendant_at (window,
858 x = floor (xx + 0.5);
859 y = floor (yy + 0.5);
869 gdk_window_real_window_get_device_position (GdkDisplay *display,
874 GdkModifierType *mask)
877 GdkModifierType tmp_mask;
878 gboolean normal_child;
880 normal_child = GDK_WINDOW_IMPL_GET_CLASS (window->impl)->get_device_state (window,
884 /* We got the coords on the impl, convert to the window */
885 tmpx -= window->abs_x;
886 tmpy -= window->abs_y;
896 return _gdk_window_find_child_at (window, tmpx, tmpy);
901 * gdk_display_get_window_at_pointer:
902 * @display: a #GdkDisplay
903 * @win_x: (out) (allow-none): return location for x coordinate of the pointer location relative
904 * to the window origin, or %NULL
905 * @win_y: (out) (allow-none): return location for y coordinate of the pointer location relative
906 & to the window origin, or %NULL
908 * Obtains the window underneath the mouse pointer, returning the location
909 * of the pointer in that window in @win_x, @win_y for @screen. Returns %NULL
910 * if the window under the mouse pointer is not known to GDK (for example,
911 * belongs to another application).
913 * Returns: (transfer none): the window under the mouse pointer, or %NULL
917 * Deprecated: 3.0: Use gdk_display_get_window_at_device_position() instead.
920 gdk_display_get_window_at_pointer (GdkDisplay *display,
924 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
926 return gdk_display_get_window_at_device_position (display, display->core_pointer, win_x, win_y);
930 multihead_get_device_state (GdkDisplay *display,
935 GdkModifierType *mask)
937 multihead_current_pointer_hooks->get_pointer (display, screen, x, y, mask);
941 multihead_window_get_device_position (GdkDisplay *display,
946 GdkModifierType *mask)
948 return multihead_current_pointer_hooks->window_get_pointer (display, window, x, y, mask);
952 multihead_window_at_device_position (GdkDisplay *display,
957 return multihead_current_pointer_hooks->window_at_pointer (display, win_x, win_y);
961 gdk_display_real_get_device_state (GdkDisplay *display,
966 GdkModifierType *mask)
968 GdkScreen *default_screen;
971 if (gdk_display_is_closed (display))
974 default_screen = gdk_display_get_default_screen (display);
976 _gdk_device_query_state (device,
977 gdk_screen_get_root_window (default_screen),
983 *screen = gdk_window_get_screen (root);
987 multihead_default_get_pointer (GdkDisplay *display,
991 GdkModifierType *mask)
993 gdk_display_real_get_device_state (display, display->core_pointer,
998 multihead_default_window_get_pointer (GdkDisplay *display,
1002 GdkModifierType *mask)
1004 return gdk_window_real_window_get_device_position (display,
1005 display->core_pointer,
1006 window, x, y, mask);
1010 multihead_default_window_at_pointer (GdkDisplay *display,
1014 return gdk_display_real_get_window_at_device_position (display,
1015 display->core_pointer,
1020 * gdk_display_set_pointer_hooks:
1021 * @display: a #GdkDisplay
1022 * @new_hooks: (allow-none): a table of pointers to functions for getting
1023 * quantities related to the current pointer position,
1024 * or %NULL to restore the default table.
1026 * This function allows for hooking into the operation
1027 * of getting the current location of the pointer on a particular
1028 * display. This is only useful for such low-level tools as an
1029 * event recorder. Applications should never have any
1030 * reason to use this facility.
1032 * Return value: (transfer none): the previous pointer hook table
1036 * Deprecated: 3.0: Use gdk_display_set_device_hooks() instead.
1038 GdkDisplayPointerHooks *
1039 gdk_display_set_pointer_hooks (GdkDisplay *display,
1040 const GdkDisplayPointerHooks *new_hooks)
1042 const GdkDisplayPointerHooks *result = multihead_current_pointer_hooks;
1044 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1047 multihead_current_pointer_hooks = new_hooks;
1049 multihead_current_pointer_hooks = &multihead_default_pointer_hooks;
1051 gdk_display_set_device_hooks (display, &multihead_pointer_hooks);
1053 return (GdkDisplayPointerHooks *)result;
1057 singlehead_get_pointer (GdkDisplay *display,
1061 GdkModifierType *mask)
1063 GdkScreen *default_screen = gdk_display_get_default_screen (display);
1064 GdkWindow *root_window = gdk_screen_get_root_window (default_screen);
1066 *screen = default_screen;
1068 singlehead_current_pointer_hooks->get_pointer (root_window, x, y, mask);
1072 singlehead_window_get_pointer (GdkDisplay *display,
1076 GdkModifierType *mask)
1078 return singlehead_current_pointer_hooks->get_pointer (window, x, y, mask);
1082 singlehead_window_at_pointer (GdkDisplay *display,
1086 GdkScreen *default_screen = gdk_display_get_default_screen (display);
1088 return singlehead_current_pointer_hooks->window_at_pointer (default_screen,
1093 singlehead_default_window_get_pointer (GdkWindow *window,
1096 GdkModifierType *mask)
1098 GdkDisplay *display;
1100 display = gdk_window_get_display (window);
1102 return gdk_window_real_window_get_device_position (display,
1103 display->core_pointer,
1104 window, x, y, mask);
1108 singlehead_default_window_at_pointer (GdkScreen *screen,
1112 GdkDisplay *display;
1114 display = gdk_screen_get_display (screen);
1116 return gdk_display_real_get_window_at_device_position (display,
1117 display->core_pointer,
1122 * gdk_set_pointer_hooks:
1123 * @new_hooks: (allow-none): a table of pointers to functions for getting
1124 * quantities related to the current pointer position,
1125 * or %NULL to restore the default table.
1127 * This function allows for hooking into the operation
1128 * of getting the current location of the pointer. This
1129 * is only useful for such low-level tools as an
1130 * event recorder. Applications should never have any
1131 * reason to use this facility.
1133 * This function is not multihead safe. For multihead operation,
1134 * see gdk_display_set_pointer_hooks().
1136 * Return value: the previous pointer hook table
1138 * Deprecated: 3.0: Use gdk_display_set_device_hooks() instead.
1141 gdk_set_pointer_hooks (const GdkPointerHooks *new_hooks)
1143 const GdkPointerHooks *result = singlehead_current_pointer_hooks;
1146 singlehead_current_pointer_hooks = new_hooks;
1148 singlehead_current_pointer_hooks = &singlehead_default_pointer_hooks;
1150 gdk_display_set_pointer_hooks (gdk_display_get_default (),
1151 &singlehead_pointer_hooks);
1153 return (GdkPointerHooks *)result;
1157 generate_grab_broken_event (GdkWindow *window,
1160 GdkWindow *grab_window)
1162 g_return_if_fail (window != NULL);
1164 if (!GDK_WINDOW_DESTROYED (window))
1168 event = gdk_event_new (GDK_GRAB_BROKEN);
1169 event->grab_broken.window = g_object_ref (window);
1170 event->grab_broken.send_event = FALSE;
1171 event->grab_broken.implicit = implicit;
1172 event->grab_broken.grab_window = grab_window;
1173 gdk_event_set_device (event, device);
1174 event->grab_broken.keyboard = (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD) ? TRUE : FALSE;
1176 gdk_event_put (event);
1177 gdk_event_free (event);
1182 _gdk_display_get_last_device_grab (GdkDisplay *display,
1187 l = g_hash_table_lookup (display->device_grabs, device);
1191 l = g_list_last (l);
1199 _gdk_display_add_device_grab (GdkDisplay *display,
1202 GdkWindow *native_window,
1203 GdkGrabOwnership grab_ownership,
1204 gboolean owner_events,
1205 GdkEventMask event_mask,
1206 unsigned long serial_start,
1210 GdkDeviceGrabInfo *info, *other_info;
1213 info = g_new0 (GdkDeviceGrabInfo, 1);
1215 info->window = g_object_ref (window);
1216 info->native_window = g_object_ref (native_window);
1217 info->serial_start = serial_start;
1218 info->serial_end = G_MAXULONG;
1219 info->owner_events = owner_events;
1220 info->event_mask = event_mask;
1222 info->implicit = implicit;
1223 info->ownership = grab_ownership;
1225 grabs = g_hash_table_lookup (display->device_grabs, device);
1227 /* Find the first grab that has a larger start time (if any) and insert
1228 * before that. I.E we insert after already existing grabs with same
1230 for (l = grabs; l != NULL; l = l->next)
1232 other_info = l->data;
1234 if (info->serial_start < other_info->serial_start)
1238 grabs = g_list_insert_before (grabs, l, info);
1240 /* Make sure the new grab end before next grab */
1243 other_info = l->data;
1244 info->serial_end = other_info->serial_start;
1247 /* Find any previous grab and update its end time */
1248 l = g_list_find (grabs, info);
1252 other_info = l->data;
1253 other_info->serial_end = serial_start;
1256 g_hash_table_insert (display->device_grabs, device, grabs);
1261 /* _gdk_synthesize_crossing_events only works inside one toplevel.
1262 This function splits things into two calls if needed, converting the
1263 coordinates to the right toplevel */
1265 synthesize_crossing_events (GdkDisplay *display,
1267 GdkDevice *source_device,
1268 GdkWindow *src_window,
1269 GdkWindow *dest_window,
1270 GdkCrossingMode crossing_mode,
1274 GdkWindow *src_toplevel, *dest_toplevel;
1275 GdkModifierType state;
1278 /* We use the native crossing events if all native */
1279 if (_gdk_native_windows)
1283 src_toplevel = gdk_window_get_toplevel (src_window);
1285 src_toplevel = NULL;
1287 dest_toplevel = gdk_window_get_toplevel (dest_window);
1289 dest_toplevel = NULL;
1291 if (src_toplevel == NULL && dest_toplevel == NULL)
1294 if (src_toplevel == NULL ||
1295 src_toplevel == dest_toplevel)
1297 /* Same toplevels */
1298 gdk_window_get_pointer (dest_toplevel,
1300 _gdk_synthesize_crossing_events (display,
1303 device, source_device,
1310 else if (dest_toplevel == NULL)
1312 gdk_window_get_pointer (src_toplevel,
1314 _gdk_synthesize_crossing_events (display,
1317 device, source_device,
1326 /* Different toplevels */
1327 gdk_window_get_pointer (src_toplevel,
1329 _gdk_synthesize_crossing_events (display,
1332 device, source_device,
1338 gdk_window_get_pointer (dest_toplevel,
1340 _gdk_synthesize_crossing_events (display,
1343 device, source_device,
1353 get_current_toplevel (GdkDisplay *display,
1357 GdkModifierType *state_out)
1359 GdkWindow *pointer_window;
1361 GdkModifierType state;
1363 pointer_window = _gdk_device_window_at_position (device, &x, &y, &state, TRUE);
1365 if (pointer_window != NULL &&
1366 (GDK_WINDOW_DESTROYED (pointer_window) ||
1367 GDK_WINDOW_TYPE (pointer_window) == GDK_WINDOW_ROOT ||
1368 GDK_WINDOW_TYPE (pointer_window) == GDK_WINDOW_FOREIGN))
1369 pointer_window = NULL;
1375 return pointer_window;
1379 switch_to_pointer_grab (GdkDisplay *display,
1381 GdkDevice *source_device,
1382 GdkDeviceGrabInfo *grab,
1383 GdkDeviceGrabInfo *last_grab,
1387 GdkWindow *src_window, *pointer_window, *new_toplevel;
1388 GdkPointerWindowInfo *info;
1390 GdkModifierType state;
1393 /* Temporarily unset pointer to make sure we send the crossing events below */
1394 old_grabs = g_hash_table_lookup (display->device_grabs, device);
1395 g_hash_table_steal (display->device_grabs, device);
1396 info = _gdk_display_get_pointer_info (display, device);
1400 /* New grab is in effect */
1402 /* We need to generate crossing events for the grab.
1403 * However, there are never any crossing events for implicit grabs
1404 * TODO: ... Actually, this could happen if the pointer window
1405 * doesn't have button mask so a parent gets the event...
1407 if (!grab->implicit)
1409 /* We send GRAB crossing events from the window under the pointer to the
1410 grab window. Except if there is an old grab then we start from that */
1412 src_window = last_grab->window;
1414 src_window = info->window_under_pointer;
1416 if (src_window != grab->window)
1417 synthesize_crossing_events (display, device, source_device,
1418 src_window, grab->window,
1419 GDK_CROSSING_GRAB, time, serial);
1421 /* !owner_event Grabbing a window that we're not inside, current status is
1422 now NULL (i.e. outside grabbed window) */
1423 if (!grab->owner_events && info->window_under_pointer != grab->window)
1424 _gdk_display_set_window_under_pointer (display, device, NULL);
1427 grab->activated = TRUE;
1432 new_toplevel = NULL;
1434 if (grab == NULL /* ungrab */ ||
1435 (!last_grab->owner_events && grab->owner_events) /* switched to owner_events */ )
1437 /* We force check what window we're in, and update the toplevel_under_pointer info,
1438 * as that won't get told of this change with toplevel enter events.
1440 if (info->toplevel_under_pointer)
1441 g_object_unref (info->toplevel_under_pointer);
1442 info->toplevel_under_pointer = NULL;
1444 new_toplevel = get_current_toplevel (display, device, &x, &y, &state);
1447 /* w is now toplevel and x,y in toplevel coords */
1448 info->toplevel_under_pointer = g_object_ref (new_toplevel);
1449 info->toplevel_x = x;
1450 info->toplevel_y = y;
1451 info->state = state;
1455 if (grab == NULL) /* Ungrabbed, send events */
1457 pointer_window = NULL;
1460 /* Find (possibly virtual) child window */
1462 _gdk_window_find_descendant_at (new_toplevel,
1467 if (pointer_window != last_grab->window)
1468 synthesize_crossing_events (display, device, source_device,
1469 last_grab->window, pointer_window,
1470 GDK_CROSSING_UNGRAB, time, serial);
1472 /* We're now ungrabbed, update the window_under_pointer */
1473 _gdk_display_set_window_under_pointer (display, device, pointer_window);
1477 g_hash_table_insert (display->device_grabs, device, old_grabs);
1481 _gdk_display_device_grab_update (GdkDisplay *display,
1483 GdkDevice *source_device,
1484 gulong current_serial)
1486 GdkDeviceGrabInfo *current_grab, *next_grab;
1490 time = display->last_event_time;
1491 grabs = g_hash_table_lookup (display->device_grabs, device);
1493 while (grabs != NULL)
1495 current_grab = grabs->data;
1497 if (current_grab->serial_start > current_serial)
1498 return; /* Hasn't started yet */
1500 if (current_grab->serial_end > current_serial)
1502 /* This one hasn't ended yet.
1503 its the currently active one or scheduled to be active */
1505 if (!current_grab->activated)
1507 if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
1508 switch_to_pointer_grab (display, device, source_device, current_grab, NULL, time, current_serial);
1517 /* This is the next active grab */
1518 next_grab = grabs->next->data;
1520 if (next_grab->serial_start > current_serial)
1521 next_grab = NULL; /* Actually its not yet active */
1524 if ((next_grab == NULL && current_grab->implicit_ungrab) ||
1525 (next_grab != NULL && current_grab->window != next_grab->window))
1526 generate_grab_broken_event (GDK_WINDOW (current_grab->window),
1528 current_grab->implicit,
1529 next_grab? next_grab->window : NULL);
1531 /* Remove old grab */
1532 grabs = g_list_delete_link (grabs, grabs);
1533 g_hash_table_insert (display->device_grabs, device, grabs);
1535 if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
1536 switch_to_pointer_grab (display, device, source_device,
1537 next_grab, current_grab,
1538 time, current_serial);
1540 free_device_grab (current_grab);
1545 grab_list_find (GList *grabs,
1548 GdkDeviceGrabInfo *grab;
1554 if (serial >= grab->serial_start && serial < grab->serial_end)
1557 grabs = grabs->next;
1564 find_device_grab (GdkDisplay *display,
1570 l = g_hash_table_lookup (display->device_grabs, device);
1571 return grab_list_find (l, serial);
1575 _gdk_display_has_device_grab (GdkDisplay *display,
1581 l = find_device_grab (display, device, serial);
1588 /* Returns true if last grab was ended
1589 * If if_child is non-NULL, end the grab only if the grabbed
1590 * window is the same as if_child or a descendant of it */
1592 _gdk_display_end_device_grab (GdkDisplay *display,
1595 GdkWindow *if_child,
1598 GdkDeviceGrabInfo *grab;
1601 l = find_device_grab (display, device, serial);
1608 (if_child == NULL ||
1609 _gdk_window_event_parent_of (if_child, grab->window)))
1611 grab->serial_end = serial;
1612 grab->implicit_ungrab = implicit;
1613 return l->next == NULL;
1619 /* Returns TRUE if device events are not blocked by any grab */
1621 _gdk_display_check_grab_ownership (GdkDisplay *display,
1625 GHashTableIter iter;
1626 gpointer key, value;
1627 GdkGrabOwnership higher_ownership, device_ownership;
1628 gboolean device_is_keyboard;
1630 g_hash_table_iter_init (&iter, display->device_grabs);
1631 higher_ownership = device_ownership = GDK_OWNERSHIP_NONE;
1632 device_is_keyboard = (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD);
1634 while (g_hash_table_iter_next (&iter, &key, &value))
1636 GdkDeviceGrabInfo *grab;
1642 grabs = grab_list_find (grabs, serial);
1647 /* Discard device if it's not of the same type */
1648 if ((device_is_keyboard && gdk_device_get_source (dev) != GDK_SOURCE_KEYBOARD) ||
1649 (!device_is_keyboard && gdk_device_get_source (dev) == GDK_SOURCE_KEYBOARD))
1655 device_ownership = grab->ownership;
1658 if (grab->ownership > higher_ownership)
1659 higher_ownership = grab->ownership;
1663 if (higher_ownership > device_ownership)
1665 /* There's a higher priority ownership
1666 * going on for other device(s)
1674 GdkPointerWindowInfo *
1675 _gdk_display_get_pointer_info (GdkDisplay *display,
1678 GdkPointerWindowInfo *info;
1680 if (G_UNLIKELY (!device))
1683 info = g_hash_table_lookup (display->pointers_info, device);
1685 if (G_UNLIKELY (!info))
1687 info = g_slice_new0 (GdkPointerWindowInfo);
1688 g_hash_table_insert (display->pointers_info, device, info);
1695 _gdk_display_pointer_info_foreach (GdkDisplay *display,
1696 GdkDisplayPointerInfoForeach func,
1699 GHashTableIter iter;
1700 gpointer key, value;
1702 g_hash_table_iter_init (&iter, display->pointers_info);
1704 while (g_hash_table_iter_next (&iter, &key, &value))
1706 GdkPointerWindowInfo *info = value;
1707 GdkDevice *device = key;
1709 (func) (display, device, info, user_data);
1714 * gdk_device_grab_info_libgtk_only:
1715 * @display: the display for which to get the grab information
1716 * @device: device to get the grab information from
1717 * @grab_window: (out) (transfer none): location to store current grab window
1718 * @owner_events: (out): location to store boolean indicating whether
1719 * the @owner_events flag to gdk_keyboard_grab() or
1720 * gdk_pointer_grab() was %TRUE.
1722 * Determines information about the current keyboard grab.
1723 * This is not public API and must not be used by applications.
1725 * Return value: %TRUE if this application currently has the
1729 gdk_device_grab_info_libgtk_only (GdkDisplay *display,
1731 GdkWindow **grab_window,
1732 gboolean *owner_events)
1734 GdkDeviceGrabInfo *info;
1736 g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
1737 g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
1739 info = _gdk_display_get_last_device_grab (display, device);
1744 *grab_window = info->window;
1746 *owner_events = info->owner_events;
1755 * gdk_display_pointer_is_grabbed:
1756 * @display: a #GdkDisplay
1758 * Test if the pointer is grabbed.
1760 * Returns: %TRUE if an active X pointer grab is in effect
1764 * Deprecated: 3.0: Use gdk_display_device_is_grabbed() instead.
1767 gdk_display_pointer_is_grabbed (GdkDisplay *display)
1769 GdkDeviceManager *device_manager;
1770 GList *devices, *dev;
1773 g_return_val_if_fail (GDK_IS_DISPLAY (display), TRUE);
1775 device_manager = gdk_display_get_device_manager (display);
1776 devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
1778 for (dev = devices; dev; dev = dev->next)
1782 if (gdk_device_get_source (device) == GDK_SOURCE_MOUSE &&
1783 gdk_display_device_is_grabbed (display, device))
1791 * gdk_display_device_is_grabbed:
1792 * @display: a #GdkDisplay
1793 * @device: a #GdkDevice
1795 * Returns %TRUE if there is an ongoing grab on @device for @display.
1797 * Returns: %TRUE if there is a grab in effect for @device.
1800 gdk_display_device_is_grabbed (GdkDisplay *display,
1803 GdkDeviceGrabInfo *info;
1805 g_return_val_if_fail (GDK_IS_DISPLAY (display), TRUE);
1806 g_return_val_if_fail (GDK_IS_DEVICE (device), TRUE);
1808 /* What we're interested in is the steady state (ie last grab),
1809 because we're interested e.g. if we grabbed so that we
1810 can ungrab, even if our grab is not active just yet. */
1811 info = _gdk_display_get_last_device_grab (display, device);
1813 return (info && !info->implicit);
1817 * gdk_display_get_device_manager:
1818 * @display: a #GdkDisplay.
1820 * Returns the #GdkDeviceManager associated to @display.
1822 * Returns: (transfer none): A #GdkDeviceManager, or %NULL. This memory is
1823 * owned by GDK and must not be freed or unreferenced.
1828 gdk_display_get_device_manager (GdkDisplay *display)
1830 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1832 return display->device_manager;
1836 * gdk_display_get_name:
1837 * @display: a #GdkDisplay
1839 * Gets the name of the display.
1841 * Returns: a string representing the display name. This string is owned
1842 * by GDK and should not be modified or freed.
1846 G_CONST_RETURN gchar *
1847 gdk_display_get_name (GdkDisplay *display)
1849 return GDK_DISPLAY_GET_CLASS(display)->get_name (display);
1853 gdk_get_display (void)
1855 return g_strdup (gdk_display_get_name (gdk_display_get_default ()));
1859 * gdk_display_get_n_screens:
1860 * @display: a #GdkDisplay
1862 * Gets the number of screen managed by the @display.
1864 * Returns: number of screens.
1869 gdk_display_get_n_screens (GdkDisplay *display)
1871 return GDK_DISPLAY_GET_CLASS(display)->get_n_screens (display);
1875 * gdk_display_get_screen:
1876 * @display: a #GdkDisplay
1877 * @screen_num: the screen number
1879 * Returns a screen object for one of the screens of the display.
1881 * Returns: (transfer none): the #GdkScreen object
1886 gdk_display_get_screen (GdkDisplay *display,
1889 return GDK_DISPLAY_GET_CLASS(display)->get_screen (display, screen_num);
1893 * gdk_display_get_default_screen:
1894 * @display: a #GdkDisplay
1896 * Get the default #GdkScreen for @display.
1898 * Returns: (transfer none): the default #GdkScreen object for @display
1903 gdk_display_get_default_screen (GdkDisplay *display)
1905 return GDK_DISPLAY_GET_CLASS(display)->get_default_screen (display);
1910 * @display: a #GdkDisplay
1912 * Emits a short beep on @display
1917 gdk_display_beep (GdkDisplay *display)
1919 GDK_DISPLAY_GET_CLASS(display)->beep (display);
1924 * @display: a #GdkDisplay
1926 * Flushes any requests queued for the windowing system and waits until all
1927 * requests have been handled. This is often used for making sure that the
1928 * display is synchronized with the current state of the program. Calling
1929 * gdk_display_sync() before gdk_error_trap_pop() makes sure that any errors
1930 * generated from earlier requests are handled before the error trap is
1933 * This is most useful for X11. On windowing systems where requests are
1934 * handled synchronously, this function will do nothing.
1939 gdk_display_sync (GdkDisplay *display)
1941 GDK_DISPLAY_GET_CLASS(display)->sync (display);
1945 * gdk_display_flush:
1946 * @display: a #GdkDisplay
1948 * Flushes any requests queued for the windowing system; this happens automatically
1949 * when the main loop blocks waiting for new events, but if your application
1950 * is drawing without returning control to the main loop, you may need
1951 * to call this function explicitely. A common case where this function
1952 * needs to be called is when an application is executing drawing commands
1953 * from a thread other than the thread where the main loop is running.
1955 * This is most useful for X11. On windowing systems where requests are
1956 * handled synchronously, this function will do nothing.
1961 gdk_display_flush (GdkDisplay *display)
1963 GDK_DISPLAY_GET_CLASS(display)->flush (display);
1967 * gdk_display_get_default_group:
1968 * @display: a #GdkDisplay
1970 * Returns the default group leader window for all toplevel windows
1971 * on @display. This window is implicitly created by GDK.
1972 * See gdk_window_set_group().
1974 * Return value: (transfer none): The default group leader window
1980 gdk_display_get_default_group (GdkDisplay *display)
1982 return GDK_DISPLAY_GET_CLASS(display)->get_default_group (display);
1986 * gdk_display_supports_selection_notification:
1987 * @display: a #GdkDisplay
1989 * Returns whether #GdkEventOwnerChange events will be
1990 * sent when the owner of a selection changes.
1992 * Return value: whether #GdkEventOwnerChange events will
1998 gdk_display_supports_selection_notification (GdkDisplay *display)
2000 return GDK_DISPLAY_GET_CLASS(display)->supports_selection_notification (display);
2004 * gdk_display_request_selection_notification:
2005 * @display: a #GdkDisplay
2006 * @selection: the #GdkAtom naming the selection for which
2007 * ownership change notification is requested
2009 * Request #GdkEventOwnerChange events for ownership changes
2010 * of the selection named by the given atom.
2012 * Return value: whether #GdkEventOwnerChange events will
2018 gdk_display_request_selection_notification (GdkDisplay *display,
2022 return GDK_DISPLAY_GET_CLASS(display)->request_selection_notification (display, selection);
2026 * gdk_display_supports_clipboard_persistence
2027 * @display: a #GdkDisplay
2029 * Returns whether the speicifed display supports clipboard
2030 * persistance; i.e. if it's possible to store the clipboard data after an
2031 * application has quit. On X11 this checks if a clipboard daemon is
2034 * Returns: %TRUE if the display supports clipboard persistance.
2039 gdk_display_supports_clipboard_persistence (GdkDisplay *display)
2041 return GDK_DISPLAY_GET_CLASS(display)->supports_clipboard_persistence (display);
2045 * gdk_display_store_clipboard
2046 * @display: a #GdkDisplay
2047 * @clipboard_window: a #GdkWindow belonging to the clipboard owner
2048 * @time_: a timestamp
2049 * @targets: an array of targets that should be saved, or %NULL
2050 * if all available targets should be saved.
2051 * @n_targets: length of the @targets array
2053 * Issues a request to the clipboard manager to store the
2054 * clipboard data. On X11, this is a special program that works
2055 * according to the freedesktop clipboard specification, available at
2056 * <ulink url="http://www.freedesktop.org/Standards/clipboard-manager-spec">
2057 * http://www.freedesktop.org/Standards/clipboard-manager-spec</ulink>.
2062 gdk_display_store_clipboard (GdkDisplay *display,
2063 GdkWindow *clipboard_window,
2065 const GdkAtom *targets,
2068 GDK_DISPLAY_GET_CLASS(display)->store_clipboard (display, clipboard_window, time_, targets, n_targets);
2072 * gdk_display_supports_shapes:
2073 * @display: a #GdkDisplay
2075 * Returns %TRUE if gdk_window_shape_combine_mask() can
2076 * be used to create shaped windows on @display.
2078 * Returns: %TRUE if shaped windows are supported
2083 gdk_display_supports_shapes (GdkDisplay *display)
2085 return GDK_DISPLAY_GET_CLASS(display)->supports_shapes (display);
2089 * gdk_display_supports_input_shapes:
2090 * @display: a #GdkDisplay
2092 * Returns %TRUE if gdk_window_input_shape_combine_mask() can
2093 * be used to modify the input shape of windows on @display.
2095 * Returns: %TRUE if windows with modified input shape are supported
2100 gdk_display_supports_input_shapes (GdkDisplay *display)
2102 return GDK_DISPLAY_GET_CLASS(display)->supports_input_shapes (display);
2106 * gdk_display_supports_composite:
2107 * @display: a #GdkDisplay
2109 * Returns %TRUE if gdk_window_set_composited() can be used
2110 * to redirect drawing on the window using compositing.
2112 * Currently this only works on X11 with XComposite and
2113 * XDamage extensions available.
2115 * Returns: %TRUE if windows may be composited.
2120 gdk_display_supports_composite (GdkDisplay *display)
2122 return GDK_DISPLAY_GET_CLASS(display)->supports_composite (display);
2126 * gdk_display_list_devices:
2127 * @display: a #GdkDisplay
2129 * Returns the list of available input devices attached to @display.
2130 * The list is statically allocated and should not be freed.
2132 * Return value: (transfer none) (element-type GdkDevice):
2133 * a list of #GdkDevice
2137 * Deprecated: 3.0: Use gdk_device_manager_list_devices() instead.
2140 gdk_display_list_devices (GdkDisplay *display)
2142 return GDK_DISPLAY_GET_CLASS(display)->list_devices (display);
2146 * gdk_event_send_client_message_for_display:
2147 * @display: the #GdkDisplay for the window where the message is to be sent.
2148 * @event: the #GdkEvent to send, which should be a #GdkEventClient.
2149 * @winid: the window to send the client message to.
2151 * On X11, sends an X ClientMessage event to a given window. On
2152 * Windows, sends a message registered with the name
2153 * GDK_WIN32_CLIENT_MESSAGE.
2155 * This could be used for communicating between different
2156 * applications, though the amount of data is limited to 20 bytes on
2157 * X11, and to just four bytes on Windows.
2159 * Returns: non-zero on success.
2164 gdk_event_send_client_message_for_display (GdkDisplay *display,
2166 GdkNativeWindow winid)
2168 return GDK_DISPLAY_GET_CLASS(display)->send_client_message (display, event, winid);
2172 * gdk_display_add_client_message_filter:
2173 * @display: a #GdkDisplay for which this message filter applies
2174 * @message_type: the type of ClientMessage events to receive.
2175 * This will be checked against the @message_type field
2176 * of the XClientMessage event struct.
2177 * @func: the function to call to process the event.
2178 * @data: user data to pass to @func.
2180 * Adds a filter to be called when X ClientMessage events are received.
2181 * See gdk_window_add_filter() if you are interested in filtering other
2187 gdk_display_add_client_message_filter (GdkDisplay *display,
2188 GdkAtom message_type,
2192 GDK_DISPLAY_GET_CLASS(display)->add_client_message_filter (display, message_type, func, data);
2196 * gdk_add_client_message_filter:
2197 * @message_type: the type of ClientMessage events to receive. This will be
2198 * checked against the <structfield>message_type</structfield> field of the
2199 * XClientMessage event struct.
2200 * @func: the function to call to process the event.
2201 * @data: user data to pass to @func.
2203 * Adds a filter to the default display to be called when X ClientMessage events
2204 * are received. See gdk_display_add_client_message_filter().
2207 gdk_add_client_message_filter (GdkAtom message_type,
2211 gdk_display_add_client_message_filter (gdk_display_get_default (),
2212 message_type, func, data);
2215 static GdkAppLaunchContext *
2216 gdk_display_real_get_app_launch_context (GdkDisplay *display)
2218 GdkAppLaunchContext *ctx;
2220 ctx = gdk_app_launch_context_new ();
2221 gdk_app_launch_context_set_display (ctx, display);
2227 * gdk_display_get_app_launch_context:
2228 * @display: a #GdkDisplay
2230 * Returns a #GdkAppLaunchContext suitable for launching
2231 * applications on the given display.
2233 * Returns: a new #GdkAppLaunchContext for @display.
2234 * Free with g_object_unref() when done
2238 GdkAppLaunchContext *
2239 gdk_display_get_app_launch_context (GdkDisplay *display)
2241 return GDK_DISPLAY_GET_CLASS(display)->get_app_launch_context (display);
2245 * gdk_drag_get_protocol_for_display:
2246 * @display: the #GdkDisplay where the destination window resides
2247 * @xid: the windowing system id of the destination window.
2248 * @protocol: location where the supported DND protocol is returned.
2250 * Finds out the DND protocol supported by a window.
2252 * Return value: the windowing system id of the window where the drop
2253 * should happen. This may be @xid or the id of a proxy window,
2254 * or zero if @xid does not support Drag and Drop.
2259 gdk_drag_get_protocol_for_display (GdkDisplay *display,
2260 GdkNativeWindow xid,
2261 GdkDragProtocol *protocol)
2263 return GDK_DISPLAY_GET_CLASS (display)->get_drag_protocol (display, xid, protocol, NULL);
2268 * @display_name: the name of the display to open
2272 * Return value: (transfer none): a #GdkDisplay, or %NULL if the display
2273 * could not be opened.
2278 gdk_display_open (const gchar *display_name)
2280 return gdk_display_manager_open_display (gdk_display_manager_get (), display_name);
2284 gdk_display_has_pending (GdkDisplay *display)
2286 return GDK_DISPLAY_GET_CLASS (display)->has_pending (display);
2290 * gdk_display_supports_cursor_alpha:
2291 * @display: a #GdkDisplay
2293 * Returns %TRUE if cursors can use an 8bit alpha channel
2294 * on @display. Otherwise, cursors are restricted to bilevel
2295 * alpha (i.e. a mask).
2297 * Returns: whether cursors can have alpha channels.
2302 gdk_display_supports_cursor_alpha (GdkDisplay *display)
2304 g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
2306 return GDK_DISPLAY_GET_CLASS (display)->supports_cursor_alpha (display);
2310 * gdk_display_supports_cursor_color:
2311 * @display: a #GdkDisplay
2313 * Returns %TRUE if multicolored cursors are supported
2314 * on @display. Otherwise, cursors have only a forground
2315 * and a background color.
2317 * Returns: whether cursors can have multiple colors.
2322 gdk_display_supports_cursor_color (GdkDisplay *display)
2324 g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
2326 return GDK_DISPLAY_GET_CLASS (display)->supports_cursor_color (display);
2330 * gdk_display_get_default_cursor_size:
2331 * @display: a #GdkDisplay
2333 * Returns the default size to use for cursors on @display.
2335 * Returns: the default cursor size.
2340 gdk_display_get_default_cursor_size (GdkDisplay *display)
2342 guint width, height;
2344 g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
2346 GDK_DISPLAY_GET_CLASS (display)->get_default_cursor_size (display,
2350 return MIN (width, height);
2354 * gdk_display_get_maximal_cursor_size:
2355 * @display: a #GdkDisplay
2356 * @width: (out): the return location for the maximal cursor width
2357 * @height: (out): the return location for the maximal cursor height
2359 * Gets the maximal size to use for cursors on @display.
2364 gdk_display_get_maximal_cursor_size (GdkDisplay *display,
2368 g_return_if_fail (GDK_IS_DISPLAY (display));
2370 GDK_DISPLAY_GET_CLASS (display)->get_maximal_cursor_size (display,
2376 * gdk_display_warp_pointer:
2377 * @display: a #GdkDisplay
2378 * @screen: the screen of @display to warp the pointer to
2379 * @x: the x coordinate of the destination
2380 * @y: the y coordinate of the destination
2382 * Warps the pointer of @display to the point @x,@y on
2383 * the screen @screen, unless the pointer is confined
2384 * to a window by a grab, in which case it will be moved
2385 * as far as allowed by the grab. Warping the pointer
2386 * creates events as if the user had moved the mouse
2387 * instantaneously to the destination.
2389 * Note that the pointer should normally be under the
2390 * control of the user. This function was added to cover
2391 * some rare use cases like keyboard navigation support
2392 * for the color picker in the #GtkColorSelectionDialog.
2396 * Deprecated: 3.0: Use gdk_display_warp_device() instead.
2399 gdk_display_warp_pointer (GdkDisplay *display,
2404 gdk_display_warp_device (display,
2405 display->core_pointer,
2411 * gdk_display_warp_device:
2412 * @display: a #GdkDisplay.
2413 * @device: a #GdkDevice.
2414 * @screen: the screen of @display to warp @device to.
2415 * @x: the X coordinate of the destination.
2416 * @y: the Y coordinate of the destination.
2418 * Warps @device in @display to the point @x,@y on
2419 * the screen @screen, unless the device is confined
2420 * to a window by a grab, in which case it will be moved
2421 * as far as allowed by the grab. Warping the pointer
2422 * creates events as if the user had moved the mouse
2423 * instantaneously to the destination.
2425 * Note that the pointer should normally be under the
2426 * control of the user. This function was added to cover
2427 * some rare use cases like keyboard navigation support
2428 * for the color picker in the #GtkColorSelectionDialog.
2433 gdk_display_warp_device (GdkDisplay *display,
2439 g_return_if_fail (GDK_IS_DISPLAY (display));
2440 g_return_if_fail (GDK_IS_DEVICE (device));
2441 g_return_if_fail (GDK_IS_SCREEN (screen));
2442 g_return_if_fail (display == gdk_device_get_display (device));
2444 GDK_DEVICE_GET_CLASS (device)->warp (device, screen, x, y);
2448 _gdk_display_get_next_serial (GdkDisplay *display)
2450 return GDK_DISPLAY_GET_CLASS (display)->get_next_serial (display);