1 /* GDK - The GIMP Drawing Kit
4 * Copyright 2001 Sun Microsystems Inc.
5 * Copyright (C) 2004 Nokia Corporation
7 * Erwann Chenede <erwann.chenede@sun.com>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
27 #include "gdkdisplay-x11.h"
31 #include "gdkdisplay.h"
32 #include "gdkeventsource.h"
33 #include "gdkeventtranslator.h"
34 #include "gdkinternals.h"
35 #include "gdkscreen.h"
36 #include "gdkscreen-x11.h"
37 #include "gdkinternals.h"
38 #include "gdkdeviceprivate.h"
39 #include "gdkdevicemanager.h"
40 #include "xsettings-client.h"
43 #include <glib/gprintf.h>
49 #include <X11/Xatom.h>
52 #include <X11/XKBlib.h>
56 #include <X11/extensions/Xfixes.h>
59 #include <X11/extensions/shape.h>
61 #ifdef HAVE_XCOMPOSITE
62 #include <X11/extensions/Xcomposite.h>
66 #include <X11/extensions/Xdamage.h>
70 #include <X11/extensions/Xrandr.h>
73 typedef struct _GdkErrorTrap GdkErrorTrap;
77 /* Next sequence when trap was pushed, i.e. first sequence to
80 gulong start_sequence;
82 /* Next sequence when trap was popped, i.e. first sequence
83 * to not ignore. 0 if trap is still active.
87 /* Most recent error code within the sequence */
91 static void gdk_display_x11_dispose (GObject *object);
92 static void gdk_display_x11_finalize (GObject *object);
94 static void gdk_display_x11_event_translator_init (GdkEventTranslatorIface *iface);
96 static gboolean gdk_display_x11_translate_event (GdkEventTranslator *translator,
102 static void gdk_internal_connection_watch (Display *display,
106 XPointer *watch_data);
107 #endif /* HAVE_X11R6 */
109 typedef struct _GdkEventTypeX11 GdkEventTypeX11;
111 struct _GdkEventTypeX11
117 /* Note that we never *directly* use WM_LOCALE_NAME, WM_PROTOCOLS,
118 * but including them here has the side-effect of getting them
119 * into the internal Xlib cache
121 static const char *const precache_atoms[] = {
131 "_NET_ACTIVE_WINDOW",
132 "_NET_CURRENT_DESKTOP",
133 "_NET_FRAME_EXTENTS",
143 "_NET_WM_STATE_ABOVE",
144 "_NET_WM_STATE_BELOW",
145 "_NET_WM_STATE_FULLSCREEN",
146 "_NET_WM_STATE_MODAL",
147 "_NET_WM_STATE_MAXIMIZED_VERT",
148 "_NET_WM_STATE_MAXIMIZED_HORZ",
149 "_NET_WM_STATE_SKIP_TASKBAR",
150 "_NET_WM_STATE_SKIP_PAGER",
151 "_NET_WM_STATE_STICKY",
152 "_NET_WM_SYNC_REQUEST",
153 "_NET_WM_SYNC_REQUEST_COUNTER",
154 "_NET_WM_WINDOW_TYPE",
155 "_NET_WM_WINDOW_TYPE_NORMAL",
160 static char *gdk_sm_client_id;
162 G_DEFINE_TYPE_WITH_CODE (GdkDisplayX11, _gdk_display_x11, GDK_TYPE_DISPLAY,
163 G_IMPLEMENT_INTERFACE (GDK_TYPE_EVENT_TRANSLATOR,
164 gdk_display_x11_event_translator_init))
168 _gdk_display_x11_init (GdkDisplayX11 *display)
170 _gdk_x11_display_manager_add_display (gdk_display_manager_get (),
171 GDK_DISPLAY_OBJECT (display));
175 gdk_display_x11_event_translator_init (GdkEventTranslatorIface *iface)
177 iface->translate_event = gdk_display_x11_translate_event;
181 do_net_wm_state_changes (GdkWindow *window)
183 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
184 GdkWindowState old_state;
186 if (GDK_WINDOW_DESTROYED (window) ||
187 gdk_window_get_window_type (window) != GDK_WINDOW_TOPLEVEL)
190 old_state = gdk_window_get_state (window);
192 /* For found_sticky to remain TRUE, we have to also be on desktop
195 if (old_state & GDK_WINDOW_STATE_STICKY)
197 if (!(toplevel->have_sticky && toplevel->on_all_desktops))
198 gdk_synthesize_window_state (window,
199 GDK_WINDOW_STATE_STICKY,
204 if (toplevel->have_sticky || toplevel->on_all_desktops)
205 gdk_synthesize_window_state (window,
207 GDK_WINDOW_STATE_STICKY);
210 if (old_state & GDK_WINDOW_STATE_FULLSCREEN)
212 if (!toplevel->have_fullscreen)
213 gdk_synthesize_window_state (window,
214 GDK_WINDOW_STATE_FULLSCREEN,
219 if (toplevel->have_fullscreen)
220 gdk_synthesize_window_state (window,
222 GDK_WINDOW_STATE_FULLSCREEN);
225 /* Our "maximized" means both vertical and horizontal; if only one,
226 * we don't expose that via GDK
228 if (old_state & GDK_WINDOW_STATE_MAXIMIZED)
230 if (!(toplevel->have_maxvert && toplevel->have_maxhorz))
231 gdk_synthesize_window_state (window,
232 GDK_WINDOW_STATE_MAXIMIZED,
237 if (toplevel->have_maxvert && toplevel->have_maxhorz)
238 gdk_synthesize_window_state (window,
240 GDK_WINDOW_STATE_MAXIMIZED);
245 gdk_check_wm_desktop_changed (GdkWindow *window)
247 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
248 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
258 gdk_x11_display_error_trap_push (display);
259 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
260 GDK_WINDOW_XID (window),
261 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
262 0, G_MAXLONG, False, XA_CARDINAL, &type,
264 &bytes_after, &data);
265 gdk_x11_display_error_trap_pop_ignored (display);
269 desktop = (gulong *)data;
270 toplevel->on_all_desktops = (*desktop == 0xFFFFFFFF);
274 toplevel->on_all_desktops = FALSE;
276 do_net_wm_state_changes (window);
280 gdk_check_wm_state_changed (GdkWindow *window)
282 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
283 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
293 gboolean had_sticky = toplevel->have_sticky;
295 toplevel->have_sticky = FALSE;
296 toplevel->have_maxvert = FALSE;
297 toplevel->have_maxhorz = FALSE;
298 toplevel->have_fullscreen = FALSE;
301 gdk_x11_display_error_trap_push (display);
302 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
303 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"),
304 0, G_MAXLONG, False, XA_ATOM, &type, &format, &nitems,
305 &bytes_after, &data);
306 gdk_x11_display_error_trap_pop_ignored (display);
310 Atom sticky_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_STICKY");
311 Atom maxvert_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_MAXIMIZED_VERT");
312 Atom maxhorz_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_MAXIMIZED_HORZ");
313 Atom fullscreen_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_FULLSCREEN");
315 atoms = (Atom *)data;
320 if (atoms[i] == sticky_atom)
321 toplevel->have_sticky = TRUE;
322 else if (atoms[i] == maxvert_atom)
323 toplevel->have_maxvert = TRUE;
324 else if (atoms[i] == maxhorz_atom)
325 toplevel->have_maxhorz = TRUE;
326 else if (atoms[i] == fullscreen_atom)
327 toplevel->have_fullscreen = TRUE;
335 /* When have_sticky is turned on, we have to check the DESKTOP property
338 if (toplevel->have_sticky && !had_sticky)
339 gdk_check_wm_desktop_changed (window);
341 do_net_wm_state_changes (window);
345 get_event_window (GdkEventTranslator *translator,
351 display = (GdkDisplay *) translator;
353 switch (xevent->type)
356 xwindow = xevent->xdestroywindow.window;
359 xwindow = xevent->xunmap.window;
362 xwindow = xevent->xmap.window;
364 case ConfigureNotify:
365 xwindow = xevent->xconfigure.window;
368 xwindow = xevent->xany.window;
371 return gdk_x11_window_lookup_for_display (display, xwindow);
375 gdk_display_x11_translate_event (GdkEventTranslator *translator,
381 GdkWindowImplX11 *window_impl = NULL;
382 GdkScreen *screen = NULL;
383 GdkScreenX11 *screen_x11 = NULL;
384 GdkToplevelX11 *toplevel = NULL;
385 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
387 Window xwindow = None;
389 /* Find the GdkWindow that this event relates to.
390 * Basically this means substructure events
391 * are reported same as structure events
393 window = get_event_window (translator, xevent);
397 /* We may receive events such as NoExpose/GraphicsExpose
398 * and ShmCompletion for pixmaps
400 if (!GDK_IS_WINDOW (window))
403 screen = GDK_WINDOW_SCREEN (window);
404 screen_x11 = GDK_SCREEN_X11 (screen);
405 toplevel = _gdk_x11_window_get_toplevel (window);
406 window_impl = GDK_WINDOW_IMPL_X11 (window->impl);
407 xwindow = GDK_WINDOW_XID (window);
409 g_object_ref (window);
412 event->any.window = window;
413 event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
415 if (window && GDK_WINDOW_DESTROYED (window))
417 if (xevent->type != DestroyNotify)
424 if (xevent->type == DestroyNotify)
428 n = gdk_display_get_n_screens (display);
429 for (i = 0; i < n; i++)
431 screen = gdk_display_get_screen (display, i);
432 screen_x11 = GDK_SCREEN_X11 (screen);
434 if (screen_x11->wmspec_check_window == xwindow)
436 screen_x11->wmspec_check_window = None;
437 screen_x11->last_wmspec_check_time = 0;
438 g_free (screen_x11->window_manager_name);
439 screen_x11->window_manager_name = g_strdup ("unknown");
441 /* careful, reentrancy */
442 _gdk_x11_screen_window_manager_changed (screen);
450 /* We do a "manual" conversion of the XEvent to a
451 * GdkEvent. The structures are mostly the same so
452 * the conversion is fairly straightforward. We also
453 * optionally print debugging info regarding events
459 switch (xevent->type)
463 g_message ("keymap notify"));
465 /* Not currently handled */
471 g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d%s",
472 xevent->xexpose.window, xevent->xexpose.count,
473 xevent->xexpose.x, xevent->xexpose.y,
474 xevent->xexpose.width, xevent->xexpose.height,
475 event->any.send_event ? " (send)" : ""));
484 GdkRectangle expose_rect;
486 expose_rect.x = xevent->xexpose.x;
487 expose_rect.y = xevent->xexpose.y;
488 expose_rect.width = xevent->xexpose.width;
489 expose_rect.height = xevent->xexpose.height;
491 _gdk_window_process_expose (window, xevent->xexpose.serial, &expose_rect);
499 GdkRectangle expose_rect;
502 g_message ("graphics expose:\tdrawable: %ld",
503 xevent->xgraphicsexpose.drawable));
511 expose_rect.x = xevent->xgraphicsexpose.x;
512 expose_rect.y = xevent->xgraphicsexpose.y;
513 expose_rect.width = xevent->xgraphicsexpose.width;
514 expose_rect.height = xevent->xgraphicsexpose.height;
516 _gdk_window_process_expose (window, xevent->xgraphicsexpose.serial, &expose_rect);
521 case VisibilityNotify:
522 #ifdef G_ENABLE_DEBUG
523 if (_gdk_debug_flags & GDK_DEBUG_EVENTS)
524 switch (xevent->xvisibility.state)
526 case VisibilityFullyObscured:
527 g_message ("visibility notify:\twindow: %ld none",
528 xevent->xvisibility.window);
530 case VisibilityPartiallyObscured:
531 g_message ("visibility notify:\twindow: %ld partial",
532 xevent->xvisibility.window);
534 case VisibilityUnobscured:
535 g_message ("visibility notify:\twindow: %ld full",
536 xevent->xvisibility.window);
539 #endif /* G_ENABLE_DEBUG */
547 event->visibility.type = GDK_VISIBILITY_NOTIFY;
548 event->visibility.window = window;
550 switch (xevent->xvisibility.state)
552 case VisibilityFullyObscured:
553 event->visibility.state = GDK_VISIBILITY_FULLY_OBSCURED;
556 case VisibilityPartiallyObscured:
557 event->visibility.state = GDK_VISIBILITY_PARTIAL;
560 case VisibilityUnobscured:
561 event->visibility.state = GDK_VISIBILITY_UNOBSCURED;
569 g_message ("create notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d parent: %ld ovr: %d",
570 xevent->xcreatewindow.window,
571 xevent->xcreatewindow.x,
572 xevent->xcreatewindow.y,
573 xevent->xcreatewindow.width,
574 xevent->xcreatewindow.height,
575 xevent->xcreatewindow.border_width,
576 xevent->xcreatewindow.parent,
577 xevent->xcreatewindow.override_redirect));
578 /* not really handled */
583 g_message ("destroy notify:\twindow: %ld",
584 xevent->xdestroywindow.window));
586 /* Ignore DestroyNotify from SubstructureNotifyMask */
587 if (xevent->xdestroywindow.window == xevent->xdestroywindow.event)
589 event->any.type = GDK_DESTROY;
590 event->any.window = window;
592 return_val = window && !GDK_WINDOW_DESTROYED (window);
594 if (window && GDK_WINDOW_XID (window) != screen_x11->xroot_window)
595 gdk_window_destroy_notify (window);
604 g_message ("unmap notify:\t\twindow: %ld",
605 xevent->xmap.window));
607 event->any.type = GDK_UNMAP;
608 event->any.window = window;
610 /* If we are shown (not withdrawn) and get an unmap, it means we
611 * were iconified in the X sense. If we are withdrawn, and get
612 * an unmap, it means we hid the window ourselves, so we
613 * will have already flipped the iconified bit off.
617 if (GDK_WINDOW_IS_MAPPED (window))
618 gdk_synthesize_window_state (window,
620 GDK_WINDOW_STATE_ICONIFIED);
622 _gdk_xgrab_check_unmap (window, xevent->xany.serial);
629 g_message ("map notify:\t\twindow: %ld",
630 xevent->xmap.window));
632 event->any.type = GDK_MAP;
633 event->any.window = window;
635 /* Unset iconified if it was set */
636 if (window && (window->state & GDK_WINDOW_STATE_ICONIFIED))
637 gdk_synthesize_window_state (window,
638 GDK_WINDOW_STATE_ICONIFIED,
645 g_message ("reparent notify:\twindow: %ld x,y: %d %d parent: %ld ovr: %d",
646 xevent->xreparent.window,
649 xevent->xreparent.parent,
650 xevent->xreparent.override_redirect));
652 /* Not currently handled */
656 case ConfigureNotify:
658 g_message ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d%s",
659 xevent->xconfigure.window,
660 xevent->xconfigure.x,
661 xevent->xconfigure.y,
662 xevent->xconfigure.width,
663 xevent->xconfigure.height,
664 xevent->xconfigure.border_width,
665 xevent->xconfigure.above,
666 xevent->xconfigure.override_redirect,
669 : window->window_type == GDK_WINDOW_CHILD
670 ? " (discarding child)"
671 : xevent->xconfigure.event != xevent->xconfigure.window
672 ? " (discarding substructure)"
674 if (window && GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
676 window->width = xevent->xconfigure.width;
677 window->height = xevent->xconfigure.height;
679 _gdk_window_update_size (window);
680 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
681 _gdk_x11_screen_size_changed (screen, xevent);
685 if (toplevel && display_x11->use_sync && !XSyncValueIsZero (toplevel->pending_counter_value))
687 toplevel->current_counter_value = toplevel->pending_counter_value;
688 XSyncIntToValue (&toplevel->pending_counter_value, 0);
693 xevent->xconfigure.event != xevent->xconfigure.window ||
694 GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD ||
695 GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
699 event->configure.type = GDK_CONFIGURE;
700 event->configure.window = window;
701 event->configure.width = xevent->xconfigure.width;
702 event->configure.height = xevent->xconfigure.height;
704 if (!xevent->xconfigure.send_event &&
705 !xevent->xconfigure.override_redirect &&
706 !GDK_WINDOW_DESTROYED (window))
710 Window child_window = 0;
712 gdk_x11_display_error_trap_push (display);
713 if (XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
714 GDK_WINDOW_XID (window),
715 screen_x11->xroot_window,
720 event->configure.x = tx;
721 event->configure.y = ty;
723 gdk_x11_display_error_trap_pop_ignored (display);
727 event->configure.x = xevent->xconfigure.x;
728 event->configure.y = xevent->xconfigure.y;
730 window->x = event->configure.x;
731 window->y = event->configure.y;
732 window->width = xevent->xconfigure.width;
733 window->height = xevent->xconfigure.height;
735 _gdk_window_update_size (window);
736 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
738 if (window->resize_count >= 1)
740 window->resize_count -= 1;
742 if (window->resize_count == 0)
743 _gdk_moveresize_configure_done (display, window);
750 g_message ("property notify:\twindow: %ld, atom(%ld): %s%s%s",
751 xevent->xproperty.window,
752 xevent->xproperty.atom,
754 gdk_x11_get_xatom_name_for_display (display, xevent->xproperty.atom),
763 /* We compare with the serial of the last time we mapped the
764 * window to avoid refetching properties that we set ourselves
767 xevent->xproperty.serial >= toplevel->map_serial)
769 if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"))
770 gdk_check_wm_state_changed (window);
772 if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"))
773 gdk_check_wm_desktop_changed (window);
776 if (window->event_mask & GDK_PROPERTY_CHANGE_MASK)
778 event->property.type = GDK_PROPERTY_NOTIFY;
779 event->property.window = window;
780 event->property.atom = gdk_x11_xatom_to_atom_for_display (display, xevent->xproperty.atom);
781 event->property.time = xevent->xproperty.time;
782 event->property.state = xevent->xproperty.state;
791 g_message ("selection clear:\twindow: %ld",
792 xevent->xproperty.window));
794 if (_gdk_selection_filter_clear_event (&xevent->xselectionclear))
796 event->selection.type = GDK_SELECTION_CLEAR;
797 event->selection.window = window;
798 event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionclear.selection);
799 event->selection.time = xevent->xselectionclear.time;
806 case SelectionRequest:
808 g_message ("selection request:\twindow: %ld",
809 xevent->xproperty.window));
811 event->selection.type = GDK_SELECTION_REQUEST;
812 event->selection.window = window;
813 event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.selection);
814 event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.target);
815 event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.property);
816 event->selection.requestor = xevent->xselectionrequest.requestor;
817 event->selection.time = xevent->xselectionrequest.time;
821 case SelectionNotify:
823 g_message ("selection notify:\twindow: %ld",
824 xevent->xproperty.window));
826 event->selection.type = GDK_SELECTION_NOTIFY;
827 event->selection.window = window;
828 event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.selection);
829 event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.target);
830 if (xevent->xselection.property == None)
831 event->selection.property = GDK_NONE;
833 event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.property);
834 event->selection.time = xevent->xselection.time;
840 g_message ("colormap notify:\twindow: %ld",
841 xevent->xcolormap.window));
843 /* Not currently handled */
850 GdkFilterReturn result = GDK_FILTER_CONTINUE;
851 GdkAtom message_type = gdk_x11_xatom_to_atom_for_display (display, xevent->xclient.message_type);
854 g_message ("client message:\twindow: %ld",
855 xevent->xclient.window));
857 tmp_list = display_x11->client_filters;
860 GdkClientFilter *filter = tmp_list->data;
861 tmp_list = tmp_list->next;
863 if (filter->type == message_type)
865 result = (*filter->function) (xevent, event, filter->data);
866 if (result != GDK_FILTER_CONTINUE)
873 case GDK_FILTER_REMOVE:
876 case GDK_FILTER_TRANSLATE:
879 case GDK_FILTER_CONTINUE:
880 /* Send unknown ClientMessage's on to Gtk for it to use */
887 event->client.type = GDK_CLIENT_EVENT;
888 event->client.window = window;
889 event->client.message_type = message_type;
890 event->client.data_format = xevent->xclient.format;
891 memcpy(&event->client.data, &xevent->xclient.data,
892 sizeof(event->client.data));
902 g_message ("mapping notify"));
904 /* Let XLib know that there is a new keyboard mapping.
906 XRefreshKeyboardMapping (&xevent->xmapping);
907 _gdk_keymap_keys_changed (display);
913 if (xevent->type - display_x11->xfixes_event_base == XFixesSelectionNotify)
915 XFixesSelectionNotifyEvent *selection_notify = (XFixesSelectionNotifyEvent *)xevent;
917 _gdk_x11_screen_process_owner_change (screen, xevent);
919 event->owner_change.type = GDK_OWNER_CHANGE;
920 event->owner_change.window = window;
921 event->owner_change.owner = selection_notify->owner;
922 event->owner_change.reason = selection_notify->subtype;
923 event->owner_change.selection =
924 gdk_x11_xatom_to_atom_for_display (display,
925 selection_notify->selection);
926 event->owner_change.time = selection_notify->timestamp;
927 event->owner_change.selection_time = selection_notify->selection_timestamp;
934 if (xevent->type - display_x11->xrandr_event_base == RRScreenChangeNotify ||
935 xevent->type - display_x11->xrandr_event_base == RRNotify)
938 _gdk_x11_screen_size_changed (screen, xevent);
942 #if defined(HAVE_XCOMPOSITE) && defined (HAVE_XDAMAGE) && defined (HAVE_XFIXES)
943 if (display_x11->have_xdamage && window && window->composited &&
944 xevent->type == display_x11->xdamage_event_base + XDamageNotify &&
945 ((XDamageNotifyEvent *) xevent)->damage == window_impl->damage)
947 XDamageNotifyEvent *damage_event = (XDamageNotifyEvent *) xevent;
948 XserverRegion repair;
951 rect.x = window->x + damage_event->area.x;
952 rect.y = window->y + damage_event->area.y;
953 rect.width = damage_event->area.width;
954 rect.height = damage_event->area.height;
956 repair = XFixesCreateRegion (display_x11->xdisplay,
957 &damage_event->area, 1);
958 XDamageSubtract (display_x11->xdisplay,
961 XFixesDestroyRegion (display_x11->xdisplay, repair);
963 if (window->parent != NULL)
964 _gdk_window_process_expose (window->parent,
965 damage_event->serial, &rect);
972 if (xevent->type == display_x11->xkb_event_type)
974 XkbEvent *xkb_event = (XkbEvent *) xevent;
976 switch (xkb_event->any.xkb_type)
978 case XkbNewKeyboardNotify:
980 _gdk_keymap_keys_changed (display);
986 _gdk_keymap_state_changed (display, xevent);
998 if (event->any.window)
999 g_object_ref (event->any.window);
1003 /* Mark this event as having no resources to be freed */
1004 event->any.window = NULL;
1005 event->any.type = GDK_NOTHING;
1009 g_object_unref (window);
1014 static GdkFilterReturn
1015 gdk_wm_protocols_filter (GdkXEvent *xev,
1019 XEvent *xevent = (XEvent *)xev;
1020 GdkWindow *win = event->any.window;
1021 GdkDisplay *display;
1025 return GDK_FILTER_REMOVE;
1027 display = GDK_WINDOW_DISPLAY (win);
1028 atom = (Atom)xevent->xclient.data.l[0];
1030 if (atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW"))
1032 /* The delete window request specifies a window
1033 * to delete. We don't actually destroy the
1034 * window because "it is only a request". (The
1035 * window might contain vital data that the
1036 * program does not want destroyed). Instead
1037 * the event is passed along to the program,
1038 * which should then destroy the window.
1041 g_message ("delete window:\t\twindow: %ld",
1042 xevent->xclient.window));
1044 event->any.type = GDK_DELETE;
1046 gdk_x11_window_set_user_time (win, xevent->xclient.data.l[1]);
1048 return GDK_FILTER_TRANSLATE;
1050 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS"))
1052 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (event->any.window);
1054 /* There is no way of knowing reliably whether we are viewable;
1055 * _gdk_x11_set_input_focus_safe() traps errors asynchronously.
1057 if (toplevel && win->accept_focus)
1058 _gdk_x11_set_input_focus_safe (display, toplevel->focus_window,
1060 xevent->xclient.data.l[1]);
1062 return GDK_FILTER_REMOVE;
1064 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PING") &&
1065 !_gdk_x11_display_is_root_window (display,
1066 xevent->xclient.window))
1068 XClientMessageEvent xclient = xevent->xclient;
1070 xclient.window = GDK_WINDOW_XROOTWIN (win);
1071 XSendEvent (GDK_WINDOW_XDISPLAY (win),
1074 SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&xclient);
1076 return GDK_FILTER_REMOVE;
1078 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_SYNC_REQUEST") &&
1079 GDK_DISPLAY_X11 (display)->use_sync)
1081 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (event->any.window);
1085 XSyncIntsToValue (&toplevel->pending_counter_value,
1086 xevent->xclient.data.l[2],
1087 xevent->xclient.data.l[3]);
1090 return GDK_FILTER_REMOVE;
1093 return GDK_FILTER_CONTINUE;
1097 gdk_event_init (GdkDisplay *display)
1099 GdkDisplayX11 *display_x11;
1100 GdkDeviceManager *device_manager;
1102 display_x11 = GDK_DISPLAY_X11 (display);
1103 display_x11->event_source = gdk_x11_event_source_new (display);
1105 gdk_x11_event_source_add_translator ((GdkEventSource *) display_x11->event_source,
1106 GDK_EVENT_TRANSLATOR (display));
1108 device_manager = gdk_display_get_device_manager (display);
1109 gdk_x11_event_source_add_translator ((GdkEventSource *) display_x11->event_source,
1110 GDK_EVENT_TRANSLATOR (device_manager));
1112 gdk_display_add_client_message_filter (display,
1113 gdk_atom_intern_static_string ("WM_PROTOCOLS"),
1114 gdk_wm_protocols_filter,
1119 gdk_input_init (GdkDisplay *display)
1121 GdkDisplayX11 *display_x11;
1122 GdkDeviceManager *device_manager;
1126 display_x11 = GDK_DISPLAY_X11 (display);
1127 device_manager = gdk_display_get_device_manager (display);
1129 /* For backwards compatibility, just add
1130 * floating devices that are not keyboards.
1132 list = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_FLOATING);
1134 for (l = list; l; l = l->next)
1138 if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
1141 display_x11->input_devices = g_list_prepend (display_x11->input_devices,
1142 g_object_ref (l->data));
1147 /* Now set "core" pointer to the first
1148 * master device that is a pointer.
1150 list = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
1152 for (l = list; l; l = l->next)
1154 device = list->data;
1156 if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
1159 display->core_pointer = device;
1163 /* Add the core pointer to the devices list */
1164 display_x11->input_devices = g_list_prepend (display_x11->input_devices,
1165 g_object_ref (display->core_pointer));
1171 set_sm_client_id (GdkDisplay *display,
1172 const gchar *sm_client_id)
1174 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
1176 if (gdk_display_is_closed (display))
1179 if (sm_client_id && strcmp (sm_client_id, ""))
1180 XChangeProperty (display_x11->xdisplay, display_x11->leader_window,
1181 gdk_x11_get_xatom_by_name_for_display (display, "SM_CLIENT_ID"),
1182 XA_STRING, 8, PropModeReplace, (guchar *)sm_client_id,
1183 strlen (sm_client_id));
1185 XDeleteProperty (display_x11->xdisplay, display_x11->leader_window,
1186 gdk_x11_get_xatom_by_name_for_display (display, "SM_CLIENT_ID"));
1191 * @display_name: the name of the display to open
1195 * Return value: (transfer none): a #GdkDisplay, or %NULL if the display
1196 * could not be opened.
1201 _gdk_x11_display_open (const gchar *display_name)
1204 GdkDisplay *display;
1205 GdkDisplayX11 *display_x11;
1210 XClassHint *class_hint;
1216 xdisplay = XOpenDisplay (display_name);
1220 display = g_object_new (GDK_TYPE_DISPLAY_X11, NULL);
1221 display_x11 = GDK_DISPLAY_X11 (display);
1223 display_x11->xdisplay = xdisplay;
1226 /* Set up handlers for Xlib internal connections */
1227 XAddConnectionWatch (xdisplay, gdk_internal_connection_watch, NULL);
1228 #endif /* HAVE_X11R6 */
1230 _gdk_x11_precache_atoms (display, precache_atoms, G_N_ELEMENTS (precache_atoms));
1232 /* RandR must be initialized before we initialize the screens */
1233 display_x11->have_randr13 = FALSE;
1235 if (XRRQueryExtension (display_x11->xdisplay,
1236 &display_x11->xrandr_event_base, &ignore))
1240 XRRQueryVersion (display_x11->xdisplay, &major, &minor);
1242 if ((major == 1 && minor >= 3) || major > 1)
1243 display_x11->have_randr13 = TRUE;
1245 gdk_x11_register_standard_event_type (display, display_x11->xrandr_event_base, RRNumberEvents);
1249 /* initialize the display's screens */
1250 display_x11->screens = g_new (GdkScreen *, ScreenCount (display_x11->xdisplay));
1251 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1252 display_x11->screens[i] = _gdk_x11_screen_new (display, i);
1254 /* We need to initialize events after we have the screen
1255 * structures in places
1257 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1258 _gdk_x11_screen_init_events (display_x11->screens[i]);
1260 /*set the default screen */
1261 display_x11->default_screen = display_x11->screens[DefaultScreen (display_x11->xdisplay)];
1263 display->device_manager = _gdk_x11_device_manager_new (display);
1265 gdk_event_init (display);
1267 attr.window_type = GDK_WINDOW_TOPLEVEL;
1268 attr.wclass = GDK_INPUT_OUTPUT;
1273 attr.event_mask = 0;
1275 display_x11->leader_gdk_window = gdk_window_new (GDK_SCREEN_X11 (display_x11->default_screen)->root_window,
1276 &attr, GDK_WA_X | GDK_WA_Y);
1277 (_gdk_x11_window_get_toplevel (display_x11->leader_gdk_window))->is_leader = TRUE;
1279 display_x11->leader_window = GDK_WINDOW_XID (display_x11->leader_gdk_window);
1281 display_x11->leader_window_title_set = FALSE;
1284 if (XFixesQueryExtension (display_x11->xdisplay,
1285 &display_x11->xfixes_event_base,
1288 display_x11->have_xfixes = TRUE;
1290 gdk_x11_register_standard_event_type (display,
1291 display_x11->xfixes_event_base,
1292 XFixesNumberEvents);
1296 display_x11->have_xfixes = FALSE;
1298 #ifdef HAVE_XCOMPOSITE
1299 if (XCompositeQueryExtension (display_x11->xdisplay,
1304 XCompositeQueryVersion (display_x11->xdisplay, &major, &minor);
1306 /* Prior to Composite version 0.4, composited windows clipped their
1307 * parents, so you had to use IncludeInferiors to draw to the parent
1308 * This isn't useful for our purposes, so require 0.4
1310 display_x11->have_xcomposite = major > 0 || (major == 0 && minor >= 4);
1314 display_x11->have_xcomposite = FALSE;
1317 if (XDamageQueryExtension (display_x11->xdisplay,
1318 &display_x11->xdamage_event_base,
1321 display_x11->have_xdamage = TRUE;
1323 gdk_x11_register_standard_event_type (display,
1324 display_x11->xdamage_event_base,
1325 XDamageNumberEvents);
1329 display_x11->have_xdamage = FALSE;
1331 display_x11->have_shapes = FALSE;
1332 display_x11->have_input_shapes = FALSE;
1334 if (XShapeQueryExtension (GDK_DISPLAY_XDISPLAY (display), &display_x11->shape_event_base, &ignore))
1336 display_x11->have_shapes = TRUE;
1338 if (XShapeQueryVersion (GDK_DISPLAY_XDISPLAY (display), &maj, &min))
1339 display_x11->have_input_shapes = (maj == 1 && min >= 1);
1343 display_x11->trusted_client = TRUE;
1346 int rootx, rooty, winx, winy;
1349 gdk_x11_display_error_trap_push (display);
1350 XQueryPointer (display_x11->xdisplay,
1351 GDK_SCREEN_X11 (display_x11->default_screen)->xroot_window,
1352 &root, &child, &rootx, &rooty, &winx, &winy, &xmask);
1353 if (G_UNLIKELY (gdk_x11_display_error_trap_pop (display) == BadWindow))
1355 g_warning ("Connection to display %s appears to be untrusted. Pointer and keyboard grabs and inter-client communication may not work as expected.", gdk_display_get_name (display));
1356 display_x11->trusted_client = FALSE;
1360 if (_gdk_synchronize)
1361 XSynchronize (display_x11->xdisplay, True);
1363 class_hint = XAllocClassHint();
1364 class_hint->res_name = g_get_prgname ();
1366 class_hint->res_class = (char *)gdk_get_program_class ();
1368 /* XmbSetWMProperties sets the RESOURCE_NAME environment variable
1369 * from argv[0], so we just synthesize an argument array here.
1372 argv[0] = g_get_prgname ();
1374 XmbSetWMProperties (display_x11->xdisplay,
1375 display_x11->leader_window,
1376 NULL, NULL, argv, argc, NULL, NULL,
1380 if (gdk_sm_client_id)
1381 set_sm_client_id (display, gdk_sm_client_id);
1384 XChangeProperty (display_x11->xdisplay,
1385 display_x11->leader_window,
1386 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PID"),
1387 XA_CARDINAL, 32, PropModeReplace, (guchar *) & pid, 1);
1389 /* We don't yet know a valid time. */
1390 display_x11->user_time = 0;
1394 gint xkb_major = XkbMajorVersion;
1395 gint xkb_minor = XkbMinorVersion;
1396 if (XkbLibraryVersion (&xkb_major, &xkb_minor))
1398 xkb_major = XkbMajorVersion;
1399 xkb_minor = XkbMinorVersion;
1401 if (XkbQueryExtension (display_x11->xdisplay,
1402 NULL, &display_x11->xkb_event_type, NULL,
1403 &xkb_major, &xkb_minor))
1405 Bool detectable_autorepeat_supported;
1407 display_x11->use_xkb = TRUE;
1409 XkbSelectEvents (display_x11->xdisplay,
1411 XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask,
1412 XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask);
1414 /* keep this in sync with _gdk_keymap_state_changed() */
1415 XkbSelectEventDetails (display_x11->xdisplay,
1416 XkbUseCoreKbd, XkbStateNotify,
1417 XkbAllStateComponentsMask,
1418 XkbGroupLockMask|XkbModifierLockMask);
1420 XkbSetDetectableAutoRepeat (display_x11->xdisplay,
1422 &detectable_autorepeat_supported);
1424 GDK_NOTE (MISC, g_message ("Detectable autorepeat %s.",
1425 detectable_autorepeat_supported ?
1426 "supported" : "not supported"));
1428 display_x11->have_xkb_autorepeat = detectable_autorepeat_supported;
1434 display_x11->use_sync = FALSE;
1438 int error_base, event_base;
1440 if (XSyncQueryExtension (display_x11->xdisplay,
1441 &event_base, &error_base) &&
1442 XSyncInitialize (display_x11->xdisplay,
1444 display_x11->use_sync = TRUE;
1448 gdk_input_init (display);
1449 _gdk_x11_dnd_init (display);
1451 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1452 _gdk_x11_screen_setup (display_x11->screens[i]);
1454 g_signal_emit_by_name (display, "opened");
1455 g_signal_emit_by_name (gdk_display_manager_get (), "display-opened", display);
1462 * XLib internal connection handling
1464 typedef struct _GdkInternalConnection GdkInternalConnection;
1466 struct _GdkInternalConnection
1474 process_internal_connection (GIOChannel *gioc,
1478 GdkInternalConnection *connection = (GdkInternalConnection *)data;
1480 GDK_THREADS_ENTER ();
1482 XProcessInternalConnection ((Display*)connection->display, connection->fd);
1484 GDK_THREADS_LEAVE ();
1490 gdk_x11_display_get_next_serial (GdkDisplay *display)
1492 return NextRequest (GDK_DISPLAY_XDISPLAY (display));
1496 static GdkInternalConnection *
1497 gdk_add_connection_handler (Display *display,
1500 GIOChannel *io_channel;
1501 GdkInternalConnection *connection;
1503 connection = g_new (GdkInternalConnection, 1);
1505 connection->fd = fd;
1506 connection->display = display;
1508 io_channel = g_io_channel_unix_new (fd);
1510 connection->source = g_io_create_watch (io_channel, G_IO_IN);
1511 g_source_set_callback (connection->source,
1512 (GSourceFunc)process_internal_connection, connection, NULL);
1513 g_source_attach (connection->source, NULL);
1515 g_io_channel_unref (io_channel);
1521 gdk_remove_connection_handler (GdkInternalConnection *connection)
1523 g_source_destroy (connection->source);
1524 g_free (connection);
1528 gdk_internal_connection_watch (Display *display,
1532 XPointer *watch_data)
1535 *watch_data = (XPointer)gdk_add_connection_handler (display, fd);
1537 gdk_remove_connection_handler ((GdkInternalConnection *)*watch_data);
1539 #endif /* HAVE_X11R6 */
1541 static G_CONST_RETURN gchar *
1542 gdk_x11_display_get_name (GdkDisplay *display)
1544 return (gchar *) DisplayString (GDK_DISPLAY_X11 (display)->xdisplay);
1548 gdk_x11_display_get_n_screens (GdkDisplay *display)
1550 return ScreenCount (GDK_DISPLAY_X11 (display)->xdisplay);
1554 gdk_x11_display_get_screen (GdkDisplay *display,
1557 g_return_val_if_fail (ScreenCount (GDK_DISPLAY_X11 (display)->xdisplay) > screen_num, NULL);
1559 return GDK_DISPLAY_X11 (display)->screens[screen_num];
1563 gdk_x11_display_get_default_screen (GdkDisplay *display)
1565 return GDK_DISPLAY_X11 (display)->default_screen;
1569 _gdk_x11_display_is_root_window (GdkDisplay *display,
1570 Window xroot_window)
1572 GdkDisplayX11 *display_x11;
1575 display_x11 = GDK_DISPLAY_X11 (display);
1577 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1579 if (GDK_SCREEN_XROOTWIN (display_x11->screens[i]) == xroot_window)
1585 struct XPointerUngrabInfo {
1586 GdkDisplay *display;
1590 #define XSERVER_TIME_IS_LATER(time1, time2) \
1591 ( (( time1 > time2 ) && ( time1 - time2 < ((guint32)-1)/2 )) || \
1592 (( time1 < time2 ) && ( time2 - time1 > ((guint32)-1)/2 )) \
1596 _gdk_x11_display_update_grab_info (GdkDisplay *display,
1600 if (status == GrabSuccess)
1601 _gdk_x11_roundtrip_async (display,
1602 (GdkRoundTripCallback)_gdk_display_device_grab_update,
1607 _gdk_x11_display_update_grab_info_ungrab (GdkDisplay *display,
1612 GdkDeviceGrabInfo *grab;
1614 XFlush (GDK_DISPLAY_XDISPLAY (display));
1616 grab = _gdk_display_get_last_device_grab (display, device);
1618 (time == GDK_CURRENT_TIME ||
1619 grab->time == GDK_CURRENT_TIME ||
1620 !XSERVER_TIME_IS_LATER (grab->time, time)))
1622 grab->serial_end = serial;
1623 _gdk_x11_roundtrip_async (display,
1624 (GdkRoundTripCallback)_gdk_display_device_grab_update,
1630 gdk_x11_display_beep (GdkDisplay *display)
1633 XkbBell (GDK_DISPLAY_XDISPLAY (display), None, 0, None);
1635 XBell (GDK_DISPLAY_XDISPLAY (display), 0);
1640 gdk_x11_display_sync (GdkDisplay *display)
1642 XSync (GDK_DISPLAY_XDISPLAY (display), False);
1646 gdk_x11_display_flush (GdkDisplay *display)
1648 if (!display->closed)
1649 XFlush (GDK_DISPLAY_XDISPLAY (display));
1653 gdk_x11_display_has_pending (GdkDisplay *display)
1655 return XPending (GDK_DISPLAY_XDISPLAY (display));
1659 gdk_x11_display_get_default_group (GdkDisplay *display)
1661 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1663 return GDK_DISPLAY_X11 (display)->leader_gdk_window;
1667 * gdk_x11_display_grab:
1668 * @display: a #GdkDisplay
1670 * Call XGrabServer() on @display.
1671 * To ungrab the display again, use gdk_x11_display_ungrab().
1673 * gdk_x11_display_grab()/gdk_x11_display_ungrab() calls can be nested.
1678 gdk_x11_display_grab (GdkDisplay *display)
1680 GdkDisplayX11 *display_x11;
1682 g_return_if_fail (GDK_IS_DISPLAY (display));
1684 display_x11 = GDK_DISPLAY_X11 (display);
1686 if (display_x11->grab_count == 0)
1687 XGrabServer (display_x11->xdisplay);
1688 display_x11->grab_count++;
1692 * gdk_x11_display_ungrab:
1693 * @display: a #GdkDisplay
1695 * Ungrab @display after it has been grabbed with
1696 * gdk_x11_display_grab().
1701 gdk_x11_display_ungrab (GdkDisplay *display)
1703 GdkDisplayX11 *display_x11;
1705 g_return_if_fail (GDK_IS_DISPLAY (display));
1707 display_x11 = GDK_DISPLAY_X11 (display);;
1708 g_return_if_fail (display_x11->grab_count > 0);
1710 display_x11->grab_count--;
1711 if (display_x11->grab_count == 0)
1713 XUngrabServer (display_x11->xdisplay);
1714 XFlush (display_x11->xdisplay);
1719 gdk_display_x11_dispose (GObject *object)
1721 GdkDisplay *display = GDK_DISPLAY_OBJECT (object);
1722 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (object);
1725 _gdk_x11_display_manager_remove_display (gdk_display_manager_get (), display);
1727 g_list_foreach (display_x11->input_devices, (GFunc) g_object_run_dispose, NULL);
1729 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1730 _gdk_screen_close (display_x11->screens[i]);
1732 if (display_x11->event_source)
1734 g_source_destroy (display_x11->event_source);
1735 g_source_unref (display_x11->event_source);
1736 display_x11->event_source = NULL;
1739 G_OBJECT_CLASS (_gdk_display_x11_parent_class)->dispose (object);
1743 gdk_display_x11_finalize (GObject *object)
1745 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (object);
1749 if (display_x11->keymap)
1750 g_object_unref (display_x11->keymap);
1752 /* Free motif Dnd */
1753 if (display_x11->motif_target_lists)
1755 for (i = 0; i < display_x11->motif_n_target_lists; i++)
1756 g_list_free (display_x11->motif_target_lists[i]);
1757 g_free (display_x11->motif_target_lists);
1760 _gdk_x11_cursor_display_finalize (GDK_DISPLAY_OBJECT(display_x11));
1762 /* Atom Hashtable */
1763 g_hash_table_destroy (display_x11->atom_from_virtual);
1764 g_hash_table_destroy (display_x11->atom_to_virtual);
1767 XDestroyWindow (display_x11->xdisplay, display_x11->leader_window);
1769 /* list of filters for client messages */
1770 g_list_foreach (display_x11->client_filters, (GFunc) g_free, NULL);
1771 g_list_free (display_x11->client_filters);
1773 /* List of event window extraction functions */
1774 g_slist_foreach (display_x11->event_types, (GFunc)g_free, NULL);
1775 g_slist_free (display_x11->event_types);
1777 /* input GdkDevice list */
1778 g_list_foreach (display_x11->input_devices, (GFunc) g_object_unref, NULL);
1779 g_list_free (display_x11->input_devices);
1781 /* input GdkWindow list */
1782 g_list_foreach (display_x11->input_windows, (GFunc) g_free, NULL);
1783 g_list_free (display_x11->input_windows);
1785 /* Free all GdkScreens */
1786 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1787 g_object_unref (display_x11->screens[i]);
1788 g_free (display_x11->screens);
1790 g_free (display_x11->startup_notification_id);
1792 /* X ID hashtable */
1793 g_hash_table_destroy (display_x11->xid_ht);
1795 XCloseDisplay (display_x11->xdisplay);
1798 while (display_x11->error_traps != NULL)
1800 GdkErrorTrap *trap = display_x11->error_traps->data;
1802 display_x11->error_traps =
1803 g_slist_delete_link (display_x11->error_traps,
1804 display_x11->error_traps);
1806 if (trap->end_sequence == 0)
1807 g_warning ("Display finalized with an unpopped error trap");
1809 g_slice_free (GdkErrorTrap, trap);
1812 G_OBJECT_CLASS (_gdk_display_x11_parent_class)->finalize (object);
1816 * gdk_x11_lookup_xdisplay:
1817 * @xdisplay: a pointer to an X Display
1819 * Find the #GdkDisplay corresponding to @display, if any exists.
1821 * Return value: (transfer none): the #GdkDisplay, if found, otherwise %NULL.
1826 gdk_x11_lookup_xdisplay (Display *xdisplay)
1829 GdkDisplay *display;
1833 list = gdk_display_manager_list_displays (gdk_display_manager_get ());
1835 for (l = list; l; l = l->next)
1837 if (GDK_DISPLAY_XDISPLAY (l->data) == xdisplay)
1844 g_slist_free (list);
1850 * _gdk_x11_display_screen_for_xrootwin:
1851 * @display: a #GdkDisplay
1852 * @xrootwin: window ID for one of of the screen's of the display.
1854 * Given the root window ID of one of the screen's of a #GdkDisplay,
1857 * Return value: the #GdkScreen corresponding to @xrootwin, or %NULL.
1860 _gdk_x11_display_screen_for_xrootwin (GdkDisplay *display,
1865 for (i = 0; i < ScreenCount (GDK_DISPLAY_X11 (display)->xdisplay); i++)
1867 GdkScreen *screen = gdk_display_get_screen (display, i);
1868 if (GDK_SCREEN_XROOTWIN (screen) == xrootwin)
1876 * gdk_x11_display_get_xdisplay:
1877 * @display: a #GdkDisplay
1878 * @returns: an X display.
1880 * Returns the X display of a #GdkDisplay.
1885 gdk_x11_display_get_xdisplay (GdkDisplay *display)
1887 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1888 return GDK_DISPLAY_X11 (display)->xdisplay;
1892 _gdk_x11_display_make_default (GdkDisplay *display)
1894 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
1895 const gchar *startup_id;
1897 g_free (display_x11->startup_notification_id);
1898 display_x11->startup_notification_id = NULL;
1900 startup_id = g_getenv ("DESKTOP_STARTUP_ID");
1901 if (startup_id && *startup_id != '\0')
1903 if (!g_utf8_validate (startup_id, -1, NULL))
1904 g_warning ("DESKTOP_STARTUP_ID contains invalid UTF-8");
1906 gdk_x11_display_set_startup_notification_id (display, startup_id);
1908 /* Clear the environment variable so it won't be inherited by
1909 * child processes and confuse things.
1911 g_unsetenv ("DESKTOP_STARTUP_ID");
1916 broadcast_xmessage (GdkDisplay *display,
1917 const char *message_type,
1918 const char *message_type_begin,
1919 const char *message)
1921 Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
1922 GdkScreen *screen = gdk_display_get_default_screen (display);
1923 GdkWindow *root_window = gdk_screen_get_root_window (screen);
1924 Window xroot_window = GDK_WINDOW_XID (root_window);
1927 Atom type_atom_begin;
1930 if (!G_LIKELY (GDK_DISPLAY_X11 (display)->trusted_client))
1934 XSetWindowAttributes attrs;
1936 attrs.override_redirect = True;
1937 attrs.event_mask = PropertyChangeMask | StructureNotifyMask;
1940 XCreateWindow (xdisplay,
1946 (Visual *)CopyFromParent,
1947 CWOverrideRedirect | CWEventMask,
1951 type_atom = gdk_x11_get_xatom_by_name_for_display (display,
1953 type_atom_begin = gdk_x11_get_xatom_by_name_for_display (display,
1954 message_type_begin);
1957 XClientMessageEvent xclient;
1959 const char *src_end;
1963 memset(&xclient, 0, sizeof (xclient));
1964 xclient.type = ClientMessage;
1965 xclient.message_type = type_atom_begin;
1966 xclient.display =xdisplay;
1967 xclient.window = xwindow;
1971 src_end = message + strlen (message) + 1; /* +1 to include nul byte */
1973 while (src != src_end)
1975 dest = &xclient.data.b[0];
1976 dest_end = dest + 20;
1978 while (dest != dest_end &&
1986 while (dest != dest_end)
1992 XSendEvent (xdisplay,
1996 (XEvent *)&xclient);
1998 xclient.message_type = type_atom;
2002 XDestroyWindow (xdisplay, xwindow);
2007 * gdk_x11_display_broadcast_startup_message:
2008 * @display: a #GdkDisplay
2009 * @message_type: startup notification message type ("new", "change",
2011 * @...: a list of key/value pairs (as strings), terminated by a
2012 * %NULL key. (A %NULL value for a key will cause that key to be
2013 * skipped in the output.)
2015 * Sends a startup notification message of type @message_type to
2018 * This is a convenience function for use by code that implements the
2019 * freedesktop startup notification specification. Applications should
2020 * not normally need to call it directly. See the <ulink
2021 * url="http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">Startup
2022 * Notification Protocol specification</ulink> for
2023 * definitions of the message types and keys that can be used.
2028 gdk_x11_display_broadcast_startup_message (GdkDisplay *display,
2029 const char *message_type,
2034 const char *key, *value, *p;
2036 message = g_string_new (message_type);
2037 g_string_append_c (message, ':');
2039 va_start (ap, message_type);
2040 while ((key = va_arg (ap, const char *)))
2042 value = va_arg (ap, const char *);
2046 g_string_append_printf (message, " %s=\"", key);
2047 for (p = value; *p; p++)
2054 g_string_append_c (message, '\\');
2058 g_string_append_c (message, *p);
2060 g_string_append_c (message, '\"');
2064 broadcast_xmessage (display,
2065 "_NET_STARTUP_INFO",
2066 "_NET_STARTUP_INFO_BEGIN",
2069 g_string_free (message, TRUE);
2073 gdk_x11_display_notify_startup_complete (GdkDisplay *display,
2074 const gchar *startup_id)
2076 if (startup_id == NULL)
2078 startup_id = GDK_DISPLAY_X11 (display)->startup_notification_id;
2079 if (startup_id == NULL)
2083 gdk_x11_display_broadcast_startup_message (display, "remove",
2089 gdk_x11_display_supports_selection_notification (GdkDisplay *display)
2091 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
2093 return display_x11->have_xfixes;
2097 gdk_x11_display_request_selection_notification (GdkDisplay *display,
2102 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
2105 if (display_x11->have_xfixes)
2107 atom = gdk_x11_atom_to_xatom_for_display (display,
2109 XFixesSelectSelectionInput (display_x11->xdisplay,
2110 display_x11->leader_window,
2112 XFixesSetSelectionOwnerNotifyMask |
2113 XFixesSelectionWindowDestroyNotifyMask |
2114 XFixesSelectionClientCloseNotifyMask);
2123 gdk_x11_display_supports_clipboard_persistence (GdkDisplay *display)
2125 Atom clipboard_manager;
2127 /* It might make sense to cache this */
2128 clipboard_manager = gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER");
2129 return XGetSelectionOwner (GDK_DISPLAY_X11 (display)->xdisplay, clipboard_manager) != None;
2133 gdk_x11_display_store_clipboard (GdkDisplay *display,
2134 GdkWindow *clipboard_window,
2136 const GdkAtom *targets,
2139 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
2140 Atom clipboard_manager, save_targets;
2142 g_return_if_fail (GDK_WINDOW_IS_X11 (clipboard_window));
2144 clipboard_manager = gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER");
2145 save_targets = gdk_x11_get_xatom_by_name_for_display (display, "SAVE_TARGETS");
2147 gdk_x11_display_error_trap_push (display);
2149 if (XGetSelectionOwner (display_x11->xdisplay, clipboard_manager) != None)
2151 Atom property_name = None;
2157 property_name = gdk_x11_atom_to_xatom_for_display (display, _gdk_selection_property);
2159 xatoms = g_new (Atom, n_targets);
2160 for (i = 0; i < n_targets; i++)
2161 xatoms[i] = gdk_x11_atom_to_xatom_for_display (display, targets[i]);
2163 XChangeProperty (display_x11->xdisplay, GDK_WINDOW_XID (clipboard_window),
2164 property_name, XA_ATOM,
2165 32, PropModeReplace, (guchar *)xatoms, n_targets);
2170 XConvertSelection (display_x11->xdisplay,
2171 clipboard_manager, save_targets, property_name,
2172 GDK_WINDOW_XID (clipboard_window), time_);
2175 gdk_x11_display_error_trap_pop_ignored (display);
2180 * gdk_x11_display_get_user_time:
2181 * @display: a #GdkDisplay
2183 * Returns the timestamp of the last user interaction on
2184 * @display. The timestamp is taken from events caused
2185 * by user interaction such as key presses or pointer
2186 * movements. See gdk_x11_window_set_user_time().
2188 * Returns: the timestamp of the last user interaction
2193 gdk_x11_display_get_user_time (GdkDisplay *display)
2195 return GDK_DISPLAY_X11 (display)->user_time;
2199 gdk_x11_display_supports_shapes (GdkDisplay *display)
2201 return GDK_DISPLAY_X11 (display)->have_shapes;
2205 gdk_x11_display_supports_input_shapes (GdkDisplay *display)
2207 return GDK_DISPLAY_X11 (display)->have_input_shapes;
2212 * gdk_x11_display_get_startup_notification_id:
2213 * @display: a #GdkDisplay
2215 * Gets the startup notification ID for a display.
2217 * Returns: the startup notification ID for @display
2221 G_CONST_RETURN gchar *
2222 gdk_x11_display_get_startup_notification_id (GdkDisplay *display)
2224 return GDK_DISPLAY_X11 (display)->startup_notification_id;
2228 * gdk_x11_display_set_startup_notification_id:
2229 * @display: a #GdkDisplay
2230 * @startup_id: the startup notification ID (must be valid utf8)
2232 * Sets the startup notification ID for a display.
2234 * This is usually taken from the value of the DESKTOP_STARTUP_ID
2235 * environment variable, but in some cases (such as the application not
2236 * being launched using exec()) it can come from other sources.
2238 * If the ID contains the string "_TIME" then the portion following that
2239 * string is taken to be the X11 timestamp of the event that triggered
2240 * the application to be launched and the GDK current event time is set
2243 * The startup ID is also what is used to signal that the startup is
2244 * complete (for example, when opening a window or when calling
2245 * gdk_notify_startup_complete()).
2250 gdk_x11_display_set_startup_notification_id (GdkDisplay *display,
2251 const gchar *startup_id)
2253 GdkDisplayX11 *display_x11;
2256 display_x11 = GDK_DISPLAY_X11 (display);
2258 g_free (display_x11->startup_notification_id);
2259 display_x11->startup_notification_id = g_strdup (startup_id);
2261 /* Find the launch time from the startup_id, if it's there. Newer spec
2262 * states that the startup_id is of the form <unique>_TIME<timestamp>
2264 time_str = g_strrstr (startup_id, "_TIME");
2265 if (time_str != NULL)
2271 /* Skip past the "_TIME" part */
2274 retval = strtoul (time_str, &end, 0);
2275 if (end != time_str && errno == 0)
2276 display_x11->user_time = retval;
2279 /* Set the startup id on the leader window so it
2280 * applies to all windows we create on this display
2282 XChangeProperty (display_x11->xdisplay,
2283 display_x11->leader_window,
2284 gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"),
2285 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
2287 (guchar *)startup_id, strlen (startup_id));
2291 gdk_x11_display_supports_composite (GdkDisplay *display)
2293 GdkDisplayX11 *x11_display = GDK_DISPLAY_X11 (display);
2295 return x11_display->have_xcomposite &&
2296 x11_display->have_xdamage &&
2297 x11_display->have_xfixes;
2301 gdk_x11_display_list_devices (GdkDisplay *display)
2303 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
2305 return GDK_DISPLAY_X11 (display)->input_devices;
2309 gdk_x11_display_send_client_message (GdkDisplay *display,
2311 GdkNativeWindow winid)
2315 g_return_val_if_fail(event != NULL, FALSE);
2317 /* Set up our event to send, with the exception of its target window */
2318 sev.xclient.type = ClientMessage;
2319 sev.xclient.display = GDK_DISPLAY_XDISPLAY (display);
2320 sev.xclient.format = event->client.data_format;
2321 sev.xclient.window = winid;
2322 memcpy(&sev.xclient.data, &event->client.data, sizeof (sev.xclient.data));
2323 sev.xclient.message_type = gdk_x11_atom_to_xatom_for_display (display, event->client.message_type);
2325 return _gdk_send_xevent (display, winid, False, NoEventMask, &sev);
2329 gdk_x11_display_add_client_message_filter (GdkDisplay *display,
2330 GdkAtom message_type,
2334 GdkClientFilter *filter;
2335 g_return_if_fail (GDK_IS_DISPLAY (display));
2336 filter = g_new (GdkClientFilter, 1);
2338 filter->type = message_type;
2339 filter->function = func;
2340 filter->data = data;
2342 GDK_DISPLAY_X11(display)->client_filters =
2343 g_list_append (GDK_DISPLAY_X11 (display)->client_filters,
2348 * gdk_x11_register_standard_event_type:
2349 * @display: a #GdkDisplay
2350 * @event_base: first event type code to register
2351 * @n_events: number of event type codes to register
2353 * Registers interest in receiving extension events with type codes
2354 * between @event_base and <literal>event_base + n_events - 1</literal>.
2355 * The registered events must have the window field in the same place
2356 * as core X events (this is not the case for e.g. XKB extension events).
2358 * If an event type is registered, events of this type will go through
2359 * global and window-specific filters (see gdk_window_add_filter()).
2360 * Unregistered events will only go through global filters.
2361 * GDK may register the events of some X extensions on its own.
2363 * This function should only be needed in unusual circumstances, e.g.
2364 * when filtering XInput extension events on the root window.
2369 gdk_x11_register_standard_event_type (GdkDisplay *display,
2373 GdkEventTypeX11 *event_type;
2374 GdkDisplayX11 *display_x11;
2376 display_x11 = GDK_DISPLAY_X11 (display);
2377 event_type = g_new (GdkEventTypeX11, 1);
2379 event_type->base = event_base;
2380 event_type->n_events = n_events;
2382 display_x11->event_types = g_slist_prepend (display_x11->event_types, event_type);
2385 /* compare X sequence numbers handling wraparound */
2386 #define SEQUENCE_COMPARE(a,op,b) (((long) (a) - (long) (b)) op 0)
2388 /* delivers an error event from the error handler in gdkmain-x11.c */
2390 _gdk_x11_display_error_event (GdkDisplay *display,
2393 GdkDisplayX11 *display_x11;
2397 display_x11 = GDK_DISPLAY_X11 (display);
2400 for (tmp_list = display_x11->error_traps;
2402 tmp_list = tmp_list->next)
2406 trap = tmp_list->data;
2408 if (SEQUENCE_COMPARE (trap->start_sequence, <=, error->serial) &&
2409 (trap->end_sequence == 0 ||
2410 SEQUENCE_COMPARE (trap->end_sequence, >, error->serial)))
2413 trap->error_code = error->error_code;
2414 break; /* only innermost trap gets the error code */
2423 XGetErrorText (display_x11->xdisplay, error->error_code, buf, 63);
2426 g_strdup_printf ("The program '%s' received an X Window System error.\n"
2427 "This probably reflects a bug in the program.\n"
2428 "The error was '%s'.\n"
2429 " (Details: serial %ld error_code %d request_code %d minor_code %d)\n"
2430 " (Note to programmers: normally, X errors are reported asynchronously;\n"
2431 " that is, you will receive the error a while after causing it.\n"
2432 " To debug your program, run it with the --sync command line\n"
2433 " option to change this behavior. You can then get a meaningful\n"
2434 " backtrace from your debugger if you break on the gdk_x_error() function.)",
2439 error->request_code,
2442 #ifdef G_ENABLE_DEBUG
2443 g_error ("%s", msg);
2444 #else /* !G_ENABLE_DEBUG */
2445 g_warning ("%s\n", msg);
2448 #endif /* G_ENABLE_DEBUG */
2453 delete_outdated_error_traps (GdkDisplayX11 *display_x11)
2456 gulong processed_sequence;
2458 processed_sequence = XLastKnownRequestProcessed (display_x11->xdisplay);
2460 tmp_list = display_x11->error_traps;
2461 while (tmp_list != NULL)
2463 GdkErrorTrap *trap = tmp_list->data;
2465 if (trap->end_sequence != 0 &&
2466 SEQUENCE_COMPARE (trap->end_sequence, <=, processed_sequence))
2468 GSList *free_me = tmp_list;
2470 tmp_list = tmp_list->next;
2471 display_x11->error_traps =
2472 g_slist_delete_link (display_x11->error_traps, free_me);
2473 g_slice_free (GdkErrorTrap, trap);
2477 tmp_list = tmp_list->next;
2483 * gdk_x11_display_error_trap_push:
2484 * @display: a #GdkDisplay
2486 * Begins a range of X requests on @display for which X error events
2487 * will be ignored. Unignored errors (when no trap is pushed) will abort
2488 * the application. Use gdk_x11_display_error_trap_pop() or
2489 * gdk_x11_display_error_trap_pop_ignored()to lift a trap pushed
2490 * with this function.
2492 * See also gdk_error_trap_push() to push a trap on all displays.
2497 gdk_x11_display_error_trap_push (GdkDisplay *display)
2499 GdkDisplayX11 *display_x11;
2502 display_x11 = GDK_DISPLAY_X11 (display);
2504 delete_outdated_error_traps (display_x11);
2506 /* set up the Xlib callback to tell us about errors */
2507 _gdk_x11_error_handler_push ();
2509 trap = g_slice_new0 (GdkErrorTrap);
2511 trap->start_sequence = XNextRequest (display_x11->xdisplay);
2512 trap->error_code = Success;
2514 display_x11->error_traps =
2515 g_slist_prepend (display_x11->error_traps, trap);
2519 gdk_x11_display_error_trap_pop_internal (GdkDisplay *display,
2522 GdkDisplayX11 *display_x11;
2527 display_x11 = GDK_DISPLAY_X11 (display);
2529 g_return_val_if_fail (display_x11->error_traps != NULL, Success);
2531 /* Find the first trap that hasn't been popped already */
2532 trap = NULL; /* quiet gcc */
2533 for (tmp_list = display_x11->error_traps;
2535 tmp_list = tmp_list->next)
2537 trap = tmp_list->data;
2539 if (trap->end_sequence == 0)
2543 g_return_val_if_fail (trap != NULL, Success);
2544 g_assert (trap->end_sequence == 0);
2546 /* May need to sync to fill in trap->error_code if we care about
2547 * getting an error code.
2551 gulong processed_sequence;
2552 gulong next_sequence;
2554 next_sequence = XNextRequest (display_x11->xdisplay);
2555 processed_sequence = XLastKnownRequestProcessed (display_x11->xdisplay);
2557 /* If our last request was already processed, there is no point
2558 * in syncing. i.e. if last request was a round trip (or even if
2559 * we got an event with the serial of a non-round-trip)
2561 if ((next_sequence - 1) != processed_sequence)
2563 XSync (display_x11->xdisplay, False);
2566 result = trap->error_code;
2573 /* record end of trap, giving us a range of
2574 * error sequences we'll ignore.
2576 trap->end_sequence = XNextRequest (display_x11->xdisplay);
2578 /* remove the Xlib callback */
2579 _gdk_x11_error_handler_pop ();
2581 /* we may already be outdated */
2582 delete_outdated_error_traps (display_x11);
2588 * gdk_x11_display_error_trap_pop:
2589 * @display: the display
2591 * Pops the error trap pushed by gdk_x11_display_error_trap_push().
2592 * Will XSync() if necessary and will always block until
2593 * the error is known to have occurred or not occurred,
2594 * so the error code can be returned.
2596 * If you don't need to use the return value,
2597 * gdk_x11_display_error_trap_pop_ignored() would be more efficient.
2599 * See gdk_error_trap_pop() for the all-displays-at-once
2604 * Return value: X error code or 0 on success
2607 gdk_x11_display_error_trap_pop (GdkDisplay *display)
2609 g_return_val_if_fail (GDK_IS_DISPLAY_X11 (display), Success);
2611 return gdk_x11_display_error_trap_pop_internal (display, TRUE);
2615 * gdk_x11_display_error_trap_pop_ignored:
2616 * @display: the display
2618 * Pops the error trap pushed by gdk_x11_display_error_trap_push().
2619 * Does not block to see if an error occurred; merely records the
2620 * range of requests to ignore errors for, and ignores those errors
2621 * if they arrive asynchronously.
2623 * See gdk_error_trap_pop_ignored() for the all-displays-at-once
2629 gdk_x11_display_error_trap_pop_ignored (GdkDisplay *display)
2631 g_return_if_fail (GDK_IS_DISPLAY_X11 (display));
2633 gdk_x11_display_error_trap_pop_internal (display, FALSE);
2636 extern GdkAppLaunchContext *_gdk_x11_display_get_app_launch_context (GdkDisplay *display);
2637 extern GdkNativeWindow _gdk_x11_display_get_drag_protocol (GdkDisplay *display,
2638 GdkNativeWindow xid,
2639 GdkDragProtocol *protocol,
2644 * gdk_x11_set_sm_client_id:
2645 * @sm_client_id: the client id assigned by the session manager when the
2646 * connection was opened, or %NULL to remove the property.
2648 * Sets the <literal>SM_CLIENT_ID</literal> property on the application's leader window so that
2649 * the window manager can save the application's state using the X11R6 ICCCM
2650 * session management protocol.
2652 * See the X Session Management Library documentation for more information on
2653 * session management and the Inter-Client Communication Conventions Manual
2656 gdk_x11_set_sm_client_id (const gchar *sm_client_id)
2658 GSList *displays, *l;
2660 g_free (gdk_sm_client_id);
2661 gdk_sm_client_id = g_strdup (sm_client_id);
2663 displays = gdk_display_manager_list_displays (gdk_display_manager_get ());
2664 for (l = displays; l; l = l->next)
2665 set_sm_client_id (l->data, sm_client_id);
2667 g_slist_free (displays);
2671 gdk_x11_display_event_data_copy (GdkDisplay *display,
2672 const GdkEvent *src,
2678 gdk_x11_display_event_data_free (GdkDisplay *display,
2684 _gdk_display_x11_class_init (GdkDisplayX11Class * class)
2686 GObjectClass *object_class = G_OBJECT_CLASS (class);
2687 GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (class);
2689 object_class->dispose = gdk_display_x11_dispose;
2690 object_class->finalize = gdk_display_x11_finalize;
2692 display_class->get_name = gdk_x11_display_get_name;
2693 display_class->get_n_screens = gdk_x11_display_get_n_screens;
2694 display_class->get_screen = gdk_x11_display_get_screen;
2695 display_class->get_default_screen = gdk_x11_display_get_default_screen;
2696 display_class->beep = gdk_x11_display_beep;
2697 display_class->sync = gdk_x11_display_sync;
2698 display_class->flush = gdk_x11_display_flush;
2699 display_class->has_pending = gdk_x11_display_has_pending;
2700 display_class->queue_events = _gdk_x11_display_queue_events;
2701 display_class->get_default_group = gdk_x11_display_get_default_group;
2702 display_class->supports_selection_notification = gdk_x11_display_supports_selection_notification;
2703 display_class->request_selection_notification = gdk_x11_display_request_selection_notification;
2704 display_class->supports_clipboard_persistence = gdk_x11_display_supports_clipboard_persistence;
2705 display_class->store_clipboard = gdk_x11_display_store_clipboard;
2706 display_class->supports_shapes = gdk_x11_display_supports_shapes;
2707 display_class->supports_input_shapes = gdk_x11_display_supports_input_shapes;
2708 display_class->supports_composite = gdk_x11_display_supports_composite;
2709 display_class->list_devices = gdk_x11_display_list_devices;
2710 display_class->send_client_message = gdk_x11_display_send_client_message;
2711 display_class->add_client_message_filter = gdk_x11_display_add_client_message_filter;
2712 display_class->get_app_launch_context = _gdk_x11_display_get_app_launch_context;
2713 display_class->get_drag_protocol = _gdk_x11_display_get_drag_protocol;
2714 display_class->get_cursor_for_type = _gdk_x11_display_get_cursor_for_type;
2715 display_class->get_cursor_for_name = _gdk_x11_display_get_cursor_for_name;
2716 display_class->get_cursor_for_pixbuf = _gdk_x11_display_get_cursor_for_pixbuf;
2717 display_class->get_default_cursor_size = _gdk_x11_display_get_default_cursor_size;
2718 display_class->get_maximal_cursor_size = _gdk_x11_display_get_maximal_cursor_size;
2719 display_class->supports_cursor_alpha = _gdk_x11_display_supports_cursor_alpha;
2720 display_class->supports_cursor_color = _gdk_x11_display_supports_cursor_color;
2722 display_class->before_process_all_updates = _gdk_x11_display_before_process_all_updates;
2723 display_class->after_process_all_updates = _gdk_x11_display_after_process_all_updates;
2724 display_class->get_next_serial = gdk_x11_display_get_next_serial;
2725 display_class->notify_startup_complete = gdk_x11_display_notify_startup_complete;
2726 display_class->event_data_copy = gdk_x11_display_event_data_copy;
2727 display_class->event_data_free = gdk_x11_display_event_data_free;