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.
28 #include "gdkdisplay.h"
29 #include "gdkeventsource.h"
30 #include "gdkeventtranslator.h"
31 #include "gdkinternals.h"
32 #include "gdkscreen.h"
33 #include "gdkinternals.h"
34 #include "gdkdeviceprivate.h"
35 #include "gdkkeysprivate.h"
36 #include "gdkdevicemanager.h"
37 #include "xsettings-client.h"
38 #include "gdkdisplay-x11.h"
39 #include "gdkprivate-x11.h"
40 #include "gdkscreen-x11.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_x11_display_dispose (GObject *object);
92 static void gdk_x11_display_finalize (GObject *object);
94 static void gdk_x11_display_event_translator_init (GdkEventTranslatorIface *iface);
96 static gboolean gdk_x11_display_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",
157 "_NET_VIRTUAL_ROOTS",
159 "_NET_WM_STATE_FOCUSED"
162 static char *gdk_sm_client_id;
164 G_DEFINE_TYPE_WITH_CODE (GdkX11Display, gdk_x11_display, GDK_TYPE_DISPLAY,
165 G_IMPLEMENT_INTERFACE (GDK_TYPE_EVENT_TRANSLATOR,
166 gdk_x11_display_event_translator_init))
170 gdk_x11_display_init (GdkX11Display *display)
172 _gdk_x11_display_manager_add_display (gdk_display_manager_get (),
173 GDK_DISPLAY (display));
177 gdk_x11_display_event_translator_init (GdkEventTranslatorIface *iface)
179 iface->translate_event = gdk_x11_display_translate_event;
183 do_net_wm_state_changes (GdkWindow *window)
185 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
186 GdkWindowState old_state;
188 if (GDK_WINDOW_DESTROYED (window) ||
189 gdk_window_get_window_type (window) != GDK_WINDOW_TOPLEVEL)
192 old_state = gdk_window_get_state (window);
194 /* For found_sticky to remain TRUE, we have to also be on desktop
197 if (old_state & GDK_WINDOW_STATE_STICKY)
199 if (!(toplevel->have_sticky && toplevel->on_all_desktops))
200 gdk_synthesize_window_state (window,
201 GDK_WINDOW_STATE_STICKY,
206 if (toplevel->have_sticky && toplevel->on_all_desktops)
207 gdk_synthesize_window_state (window,
209 GDK_WINDOW_STATE_STICKY);
212 if (old_state & GDK_WINDOW_STATE_FULLSCREEN)
214 if (!toplevel->have_fullscreen)
215 gdk_synthesize_window_state (window,
216 GDK_WINDOW_STATE_FULLSCREEN,
221 if (toplevel->have_fullscreen)
222 gdk_synthesize_window_state (window,
224 GDK_WINDOW_STATE_FULLSCREEN);
227 /* Our "maximized" means both vertical and horizontal; if only one,
228 * we don't expose that via GDK
230 if (old_state & GDK_WINDOW_STATE_MAXIMIZED)
232 if (!(toplevel->have_maxvert && toplevel->have_maxhorz))
233 gdk_synthesize_window_state (window,
234 GDK_WINDOW_STATE_MAXIMIZED,
239 if (toplevel->have_maxvert && toplevel->have_maxhorz)
240 gdk_synthesize_window_state (window,
242 GDK_WINDOW_STATE_MAXIMIZED);
245 if (old_state & GDK_WINDOW_STATE_FOCUSED)
247 if (!toplevel->have_focused)
248 gdk_synthesize_window_state (window,
249 GDK_WINDOW_STATE_FOCUSED,
254 if (toplevel->have_focused)
255 gdk_synthesize_window_state (window,
257 GDK_WINDOW_STATE_FOCUSED);
262 gdk_check_wm_desktop_changed (GdkWindow *window)
264 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
265 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
275 gdk_x11_display_error_trap_push (display);
276 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
277 GDK_WINDOW_XID (window),
278 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
279 0, G_MAXLONG, False, XA_CARDINAL, &type,
281 &bytes_after, &data);
282 gdk_x11_display_error_trap_pop_ignored (display);
286 desktop = (gulong *)data;
287 toplevel->on_all_desktops = ((*desktop & 0xFFFFFFFF) == 0xFFFFFFFF);
291 toplevel->on_all_desktops = FALSE;
293 do_net_wm_state_changes (window);
297 gdk_check_wm_state_changed (GdkWindow *window)
299 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
300 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
301 GdkScreen *screen = GDK_WINDOW_SCREEN (window);
311 gboolean had_sticky = toplevel->have_sticky;
313 toplevel->have_sticky = FALSE;
314 toplevel->have_maxvert = FALSE;
315 toplevel->have_maxhorz = FALSE;
316 toplevel->have_fullscreen = FALSE;
317 toplevel->have_focused = FALSE;
320 gdk_x11_display_error_trap_push (display);
321 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
322 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"),
323 0, G_MAXLONG, False, XA_ATOM, &type, &format, &nitems,
324 &bytes_after, &data);
325 gdk_x11_display_error_trap_pop_ignored (display);
329 Atom sticky_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_STICKY");
330 Atom maxvert_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_MAXIMIZED_VERT");
331 Atom maxhorz_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_MAXIMIZED_HORZ");
332 Atom fullscreen_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_FULLSCREEN");
333 Atom focused_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_FOCUSED");
335 atoms = (Atom *)data;
340 if (atoms[i] == sticky_atom)
341 toplevel->have_sticky = TRUE;
342 else if (atoms[i] == maxvert_atom)
343 toplevel->have_maxvert = TRUE;
344 else if (atoms[i] == maxhorz_atom)
345 toplevel->have_maxhorz = TRUE;
346 else if (atoms[i] == fullscreen_atom)
347 toplevel->have_fullscreen = TRUE;
348 else if (atoms[i] == focused_atom)
349 toplevel->have_focused = TRUE;
357 if (!gdk_x11_screen_supports_net_wm_hint (screen,
358 gdk_atom_intern_static_string ("_NET_WM_STATE_FOCUSED")))
359 toplevel->have_focused = TRUE;
361 /* When have_sticky is turned on, we have to check the DESKTOP property
364 if (toplevel->have_sticky && !had_sticky)
365 gdk_check_wm_desktop_changed (window);
367 do_net_wm_state_changes (window);
371 get_event_window (GdkEventTranslator *translator,
377 display = (GdkDisplay *) translator;
379 switch (xevent->type)
382 xwindow = xevent->xdestroywindow.window;
385 xwindow = xevent->xunmap.window;
388 xwindow = xevent->xmap.window;
390 case ConfigureNotify:
391 xwindow = xevent->xconfigure.window;
394 xwindow = xevent->xany.window;
397 return gdk_x11_window_lookup_for_display (display, xwindow);
401 gdk_x11_display_translate_event (GdkEventTranslator *translator,
407 GdkWindowImplX11 *window_impl = NULL;
408 GdkScreen *screen = NULL;
409 GdkX11Screen *x11_screen = NULL;
410 GdkToplevelX11 *toplevel = NULL;
411 GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
414 /* Find the GdkWindow that this event relates to.
415 * Basically this means substructure events
416 * are reported same as structure events
418 window = get_event_window (translator, xevent);
422 /* We may receive events such as NoExpose/GraphicsExpose
423 * and ShmCompletion for pixmaps
425 if (!GDK_IS_WINDOW (window))
428 screen = GDK_WINDOW_SCREEN (window);
429 x11_screen = GDK_X11_SCREEN (screen);
430 toplevel = _gdk_x11_window_get_toplevel (window);
431 window_impl = GDK_WINDOW_IMPL_X11 (window->impl);
433 g_object_ref (window);
436 event->any.window = window;
437 event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
439 if (window && GDK_WINDOW_DESTROYED (window))
441 if (xevent->type != DestroyNotify)
448 if (xevent->type == DestroyNotify)
452 n = gdk_display_get_n_screens (display);
453 for (i = 0; i < n; i++)
455 screen = gdk_display_get_screen (display, i);
456 x11_screen = GDK_X11_SCREEN (screen);
458 if (x11_screen->wmspec_check_window == xevent->xdestroywindow.window)
460 x11_screen->wmspec_check_window = None;
461 x11_screen->last_wmspec_check_time = 0;
462 g_free (x11_screen->window_manager_name);
463 x11_screen->window_manager_name = g_strdup ("unknown");
465 /* careful, reentrancy */
466 _gdk_x11_screen_window_manager_changed (screen);
474 /* We do a "manual" conversion of the XEvent to a
475 * GdkEvent. The structures are mostly the same so
476 * the conversion is fairly straightforward. We also
477 * optionally print debugging info regarding events
483 switch (xevent->type)
487 g_message ("keymap notify"));
489 /* Not currently handled */
495 g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d%s",
496 xevent->xexpose.window, xevent->xexpose.count,
497 xevent->xexpose.x, xevent->xexpose.y,
498 xevent->xexpose.width, xevent->xexpose.height,
499 event->any.send_event ? " (send)" : ""));
508 GdkRectangle expose_rect;
510 expose_rect.x = xevent->xexpose.x;
511 expose_rect.y = xevent->xexpose.y;
512 expose_rect.width = xevent->xexpose.width;
513 expose_rect.height = xevent->xexpose.height;
515 _gdk_x11_window_process_expose (window, xevent->xexpose.serial, &expose_rect);
523 GdkRectangle expose_rect;
526 g_message ("graphics expose:\tdrawable: %ld",
527 xevent->xgraphicsexpose.drawable));
535 expose_rect.x = xevent->xgraphicsexpose.x;
536 expose_rect.y = xevent->xgraphicsexpose.y;
537 expose_rect.width = xevent->xgraphicsexpose.width;
538 expose_rect.height = xevent->xgraphicsexpose.height;
540 _gdk_x11_window_process_expose (window, xevent->xgraphicsexpose.serial, &expose_rect);
545 case VisibilityNotify:
546 #ifdef G_ENABLE_DEBUG
547 if (_gdk_debug_flags & GDK_DEBUG_EVENTS)
548 switch (xevent->xvisibility.state)
550 case VisibilityFullyObscured:
551 g_message ("visibility notify:\twindow: %ld none",
552 xevent->xvisibility.window);
554 case VisibilityPartiallyObscured:
555 g_message ("visibility notify:\twindow: %ld partial",
556 xevent->xvisibility.window);
558 case VisibilityUnobscured:
559 g_message ("visibility notify:\twindow: %ld full",
560 xevent->xvisibility.window);
563 #endif /* G_ENABLE_DEBUG */
571 event->visibility.type = GDK_VISIBILITY_NOTIFY;
572 event->visibility.window = window;
574 switch (xevent->xvisibility.state)
576 case VisibilityFullyObscured:
577 event->visibility.state = GDK_VISIBILITY_FULLY_OBSCURED;
580 case VisibilityPartiallyObscured:
581 event->visibility.state = GDK_VISIBILITY_PARTIAL;
584 case VisibilityUnobscured:
585 event->visibility.state = GDK_VISIBILITY_UNOBSCURED;
593 g_message ("create notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d parent: %ld ovr: %d",
594 xevent->xcreatewindow.window,
595 xevent->xcreatewindow.x,
596 xevent->xcreatewindow.y,
597 xevent->xcreatewindow.width,
598 xevent->xcreatewindow.height,
599 xevent->xcreatewindow.border_width,
600 xevent->xcreatewindow.parent,
601 xevent->xcreatewindow.override_redirect));
602 /* not really handled */
607 g_message ("destroy notify:\twindow: %ld",
608 xevent->xdestroywindow.window));
610 /* Ignore DestroyNotify from SubstructureNotifyMask */
611 if (xevent->xdestroywindow.window == xevent->xdestroywindow.event)
613 event->any.type = GDK_DESTROY;
614 event->any.window = window;
616 return_val = window && !GDK_WINDOW_DESTROYED (window);
618 if (window && GDK_WINDOW_XID (window) != x11_screen->xroot_window)
619 gdk_window_destroy_notify (window);
628 g_message ("unmap notify:\t\twindow: %ld",
629 xevent->xmap.window));
631 event->any.type = GDK_UNMAP;
632 event->any.window = window;
634 /* If we are shown (not withdrawn) and get an unmap, it means we
635 * were iconified in the X sense. If we are withdrawn, and get
636 * an unmap, it means we hid the window ourselves, so we
637 * will have already flipped the iconified bit off.
641 if (GDK_WINDOW_IS_MAPPED (window))
642 gdk_synthesize_window_state (window,
644 GDK_WINDOW_STATE_ICONIFIED);
646 _gdk_x11_window_grab_check_unmap (window, xevent->xany.serial);
653 g_message ("map notify:\t\twindow: %ld",
654 xevent->xmap.window));
656 event->any.type = GDK_MAP;
657 event->any.window = window;
659 /* Unset iconified if it was set */
660 if (window && (window->state & GDK_WINDOW_STATE_ICONIFIED))
661 gdk_synthesize_window_state (window,
662 GDK_WINDOW_STATE_ICONIFIED,
669 g_message ("reparent notify:\twindow: %ld x,y: %d %d parent: %ld ovr: %d",
670 xevent->xreparent.window,
673 xevent->xreparent.parent,
674 xevent->xreparent.override_redirect));
676 /* Not currently handled */
680 case ConfigureNotify:
682 g_message ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d%s",
683 xevent->xconfigure.window,
684 xevent->xconfigure.x,
685 xevent->xconfigure.y,
686 xevent->xconfigure.width,
687 xevent->xconfigure.height,
688 xevent->xconfigure.border_width,
689 xevent->xconfigure.above,
690 xevent->xconfigure.override_redirect,
693 : window->window_type == GDK_WINDOW_CHILD
694 ? " (discarding child)"
695 : xevent->xconfigure.event != xevent->xconfigure.window
696 ? " (discarding substructure)"
698 if (window && GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
700 window->width = xevent->xconfigure.width;
701 window->height = xevent->xconfigure.height;
703 _gdk_window_update_size (window);
704 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
705 _gdk_x11_screen_size_changed (screen, xevent);
709 if (toplevel && display_x11->use_sync && !XSyncValueIsZero (toplevel->pending_counter_value))
711 toplevel->current_counter_value = toplevel->pending_counter_value;
712 XSyncIntToValue (&toplevel->pending_counter_value, 0);
717 xevent->xconfigure.event != xevent->xconfigure.window ||
718 GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD ||
719 GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
723 event->configure.type = GDK_CONFIGURE;
724 event->configure.window = window;
725 event->configure.width = xevent->xconfigure.width;
726 event->configure.height = xevent->xconfigure.height;
728 if (!xevent->xconfigure.send_event &&
729 !xevent->xconfigure.override_redirect &&
730 !GDK_WINDOW_DESTROYED (window))
734 Window child_window = 0;
736 gdk_x11_display_error_trap_push (display);
737 if (XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
738 GDK_WINDOW_XID (window),
739 x11_screen->xroot_window,
744 event->configure.x = tx;
745 event->configure.y = ty;
747 gdk_x11_display_error_trap_pop_ignored (display);
751 event->configure.x = xevent->xconfigure.x;
752 event->configure.y = xevent->xconfigure.y;
754 window->x = event->configure.x;
755 window->y = event->configure.y;
756 window->width = xevent->xconfigure.width;
757 window->height = xevent->xconfigure.height;
759 _gdk_window_update_size (window);
760 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
762 if (window->resize_count >= 1)
764 window->resize_count -= 1;
766 if (window->resize_count == 0)
767 _gdk_x11_moveresize_configure_done (display, window);
774 g_message ("property notify:\twindow: %ld, atom(%ld): %s%s%s",
775 xevent->xproperty.window,
776 xevent->xproperty.atom,
778 gdk_x11_get_xatom_name_for_display (display, xevent->xproperty.atom),
787 /* We compare with the serial of the last time we mapped the
788 * window to avoid refetching properties that we set ourselves
791 xevent->xproperty.serial >= toplevel->map_serial)
793 if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"))
794 gdk_check_wm_state_changed (window);
796 if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"))
797 gdk_check_wm_desktop_changed (window);
800 if (window->event_mask & GDK_PROPERTY_CHANGE_MASK)
802 event->property.type = GDK_PROPERTY_NOTIFY;
803 event->property.window = window;
804 event->property.atom = gdk_x11_xatom_to_atom_for_display (display, xevent->xproperty.atom);
805 event->property.time = xevent->xproperty.time;
806 event->property.state = xevent->xproperty.state;
815 g_message ("selection clear:\twindow: %ld",
816 xevent->xproperty.window));
818 if (_gdk_x11_selection_filter_clear_event (&xevent->xselectionclear))
820 event->selection.type = GDK_SELECTION_CLEAR;
821 event->selection.window = window;
822 event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionclear.selection);
823 event->selection.time = xevent->xselectionclear.time;
830 case SelectionRequest:
832 g_message ("selection request:\twindow: %ld",
833 xevent->xproperty.window));
835 event->selection.type = GDK_SELECTION_REQUEST;
836 event->selection.window = window;
837 event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.selection);
838 event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.target);
839 event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.property);
840 if (xevent->xselectionrequest.requestor != None)
841 event->selection.requestor = gdk_x11_window_foreign_new_for_display (display,
842 xevent->xselectionrequest.requestor);
844 event->selection.requestor = NULL;
845 event->selection.time = xevent->xselectionrequest.time;
849 case SelectionNotify:
851 g_message ("selection notify:\twindow: %ld",
852 xevent->xproperty.window));
854 event->selection.type = GDK_SELECTION_NOTIFY;
855 event->selection.window = window;
856 event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.selection);
857 event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.target);
858 if (xevent->xselection.property == None)
859 event->selection.property = GDK_NONE;
861 event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.property);
862 event->selection.time = xevent->xselection.time;
868 g_message ("colormap notify:\twindow: %ld",
869 xevent->xcolormap.window));
871 /* Not currently handled */
877 g_message ("client message:\twindow: %ld",
878 xevent->xclient.window));
880 /* Not currently handled */
886 g_message ("mapping notify"));
888 /* Let XLib know that there is a new keyboard mapping.
890 XRefreshKeyboardMapping (&xevent->xmapping);
891 _gdk_x11_keymap_keys_changed (display);
897 if (xevent->type - display_x11->xfixes_event_base == XFixesSelectionNotify)
899 XFixesSelectionNotifyEvent *selection_notify = (XFixesSelectionNotifyEvent *)xevent;
901 _gdk_x11_screen_process_owner_change (screen, xevent);
903 event->owner_change.type = GDK_OWNER_CHANGE;
904 event->owner_change.window = window;
905 if (selection_notify->owner != None)
906 event->owner_change.owner = gdk_x11_window_foreign_new_for_display (display,
907 selection_notify->owner);
909 event->owner_change.owner = NULL;
910 event->owner_change.reason = selection_notify->subtype;
911 event->owner_change.selection =
912 gdk_x11_xatom_to_atom_for_display (display,
913 selection_notify->selection);
914 event->owner_change.time = selection_notify->timestamp;
915 event->owner_change.selection_time = selection_notify->selection_timestamp;
922 if (xevent->type - display_x11->xrandr_event_base == RRScreenChangeNotify ||
923 xevent->type - display_x11->xrandr_event_base == RRNotify)
926 _gdk_x11_screen_size_changed (screen, xevent);
930 #if defined(HAVE_XCOMPOSITE) && defined (HAVE_XDAMAGE) && defined (HAVE_XFIXES)
931 if (display_x11->have_xdamage && window && window->composited &&
932 xevent->type == display_x11->xdamage_event_base + XDamageNotify &&
933 ((XDamageNotifyEvent *) xevent)->damage == window_impl->damage)
935 XDamageNotifyEvent *damage_event = (XDamageNotifyEvent *) xevent;
936 XserverRegion repair;
939 rect.x = window->x + damage_event->area.x;
940 rect.y = window->y + damage_event->area.y;
941 rect.width = damage_event->area.width;
942 rect.height = damage_event->area.height;
944 repair = XFixesCreateRegion (display_x11->xdisplay,
945 &damage_event->area, 1);
946 XDamageSubtract (display_x11->xdisplay,
949 XFixesDestroyRegion (display_x11->xdisplay, repair);
951 if (window->parent != NULL)
952 _gdk_x11_window_process_expose (window->parent,
953 damage_event->serial, &rect);
960 if (xevent->type == display_x11->xkb_event_type)
962 XkbEvent *xkb_event = (XkbEvent *) xevent;
964 switch (xkb_event->any.xkb_type)
966 case XkbNewKeyboardNotify:
968 _gdk_x11_keymap_keys_changed (display);
974 _gdk_x11_keymap_state_changed (display, xevent);
986 if (event->any.window)
987 g_object_ref (event->any.window);
991 /* Mark this event as having no resources to be freed */
992 event->any.window = NULL;
993 event->any.type = GDK_NOTHING;
997 g_object_unref (window);
1003 _gdk_wm_protocols_filter (GdkXEvent *xev,
1007 XEvent *xevent = (XEvent *)xev;
1008 GdkWindow *win = event->any.window;
1009 GdkDisplay *display;
1012 if (!GDK_IS_X11_WINDOW (win))
1013 return GDK_FILTER_CONTINUE;
1015 if (xevent->type != ClientMessage)
1016 return GDK_FILTER_CONTINUE;
1018 display = GDK_WINDOW_DISPLAY (win);
1020 if (xevent->xclient.message_type != gdk_x11_get_xatom_by_name_for_display (display, "WM_PROTOCOLS"))
1021 return GDK_FILTER_CONTINUE;
1023 atom = (Atom) xevent->xclient.data.l[0];
1025 if (atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW"))
1027 /* The delete window request specifies a window
1028 * to delete. We don't actually destroy the
1029 * window because "it is only a request". (The
1030 * window might contain vital data that the
1031 * program does not want destroyed). Instead
1032 * the event is passed along to the program,
1033 * which should then destroy the window.
1036 g_message ("delete window:\t\twindow: %ld",
1037 xevent->xclient.window));
1039 event->any.type = GDK_DELETE;
1041 gdk_x11_window_set_user_time (win, xevent->xclient.data.l[1]);
1043 return GDK_FILTER_TRANSLATE;
1045 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS"))
1047 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (event->any.window);
1049 /* There is no way of knowing reliably whether we are viewable;
1050 * so trap errors asynchronously around the XSetInputFocus call
1052 if (toplevel && win->accept_focus)
1054 gdk_x11_display_error_trap_push (display);
1055 XSetInputFocus (GDK_DISPLAY_XDISPLAY (display),
1056 toplevel->focus_window,
1058 xevent->xclient.data.l[1]);
1059 gdk_x11_display_error_trap_pop_ignored (display);
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_X11_DISPLAY (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 GdkX11Display *display_x11;
1100 GdkDeviceManager *device_manager;
1102 display_x11 = GDK_X11_DISPLAY (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));
1114 gdk_x11_display_init_input (GdkDisplay *display)
1116 GdkX11Display *display_x11;
1117 GdkDeviceManager *device_manager;
1121 display_x11 = GDK_X11_DISPLAY (display);
1122 device_manager = gdk_display_get_device_manager (display);
1124 /* For backwards compatibility, just add
1125 * floating devices that are not keyboards.
1127 list = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_FLOATING);
1129 for (l = list; l; l = l->next)
1133 if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
1136 display_x11->input_devices = g_list_prepend (display_x11->input_devices,
1137 g_object_ref (l->data));
1142 /* Now set "core" pointer to the first
1143 * master device that is a pointer.
1145 list = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
1147 for (l = list; l; l = l->next)
1151 if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
1154 display->core_pointer = device;
1158 /* Add the core pointer to the devices list */
1159 display_x11->input_devices = g_list_prepend (display_x11->input_devices,
1160 g_object_ref (display->core_pointer));
1166 set_sm_client_id (GdkDisplay *display,
1167 const gchar *sm_client_id)
1169 GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
1171 if (gdk_display_is_closed (display))
1174 if (sm_client_id && strcmp (sm_client_id, ""))
1175 XChangeProperty (display_x11->xdisplay, display_x11->leader_window,
1176 gdk_x11_get_xatom_by_name_for_display (display, "SM_CLIENT_ID"),
1177 XA_STRING, 8, PropModeReplace, (guchar *)sm_client_id,
1178 strlen (sm_client_id));
1180 XDeleteProperty (display_x11->xdisplay, display_x11->leader_window,
1181 gdk_x11_get_xatom_by_name_for_display (display, "SM_CLIENT_ID"));
1185 _gdk_x11_display_open (const gchar *display_name)
1188 GdkDisplay *display;
1189 GdkX11Display *display_x11;
1194 XClassHint *class_hint;
1200 xdisplay = XOpenDisplay (display_name);
1204 display = g_object_new (GDK_TYPE_X11_DISPLAY, NULL);
1205 display_x11 = GDK_X11_DISPLAY (display);
1207 display_x11->xdisplay = xdisplay;
1210 /* Set up handlers for Xlib internal connections */
1211 XAddConnectionWatch (xdisplay, gdk_internal_connection_watch, NULL);
1212 #endif /* HAVE_X11R6 */
1214 _gdk_x11_precache_atoms (display, precache_atoms, G_N_ELEMENTS (precache_atoms));
1216 /* RandR must be initialized before we initialize the screens */
1217 display_x11->have_randr12 = FALSE;
1218 display_x11->have_randr13 = FALSE;
1220 if (XRRQueryExtension (display_x11->xdisplay,
1221 &display_x11->xrandr_event_base, &ignore))
1225 XRRQueryVersion (display_x11->xdisplay, &major, &minor);
1227 if ((major == 1 && minor >= 2) || major > 1) {
1228 display_x11->have_randr12 = TRUE;
1229 if (minor >= 3 || major > 1)
1230 display_x11->have_randr13 = TRUE;
1233 gdk_x11_register_standard_event_type (display, display_x11->xrandr_event_base, RRNumberEvents);
1237 /* initialize the display's screens */
1238 display_x11->screens = g_new (GdkScreen *, ScreenCount (display_x11->xdisplay));
1239 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1240 display_x11->screens[i] = _gdk_x11_screen_new (display, i);
1242 /* We need to initialize events after we have the screen
1243 * structures in places
1245 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1246 _gdk_x11_screen_init_events (display_x11->screens[i]);
1248 /*set the default screen */
1249 display_x11->default_screen = display_x11->screens[DefaultScreen (display_x11->xdisplay)];
1251 display->device_manager = _gdk_x11_device_manager_new (display);
1253 gdk_event_init (display);
1255 attr.window_type = GDK_WINDOW_TOPLEVEL;
1256 attr.wclass = GDK_INPUT_OUTPUT;
1261 attr.event_mask = 0;
1263 display_x11->leader_gdk_window = gdk_window_new (GDK_X11_SCREEN (display_x11->default_screen)->root_window,
1264 &attr, GDK_WA_X | GDK_WA_Y);
1265 (_gdk_x11_window_get_toplevel (display_x11->leader_gdk_window))->is_leader = TRUE;
1267 display_x11->leader_window = GDK_WINDOW_XID (display_x11->leader_gdk_window);
1269 display_x11->leader_window_title_set = FALSE;
1272 if (XFixesQueryExtension (display_x11->xdisplay,
1273 &display_x11->xfixes_event_base,
1276 display_x11->have_xfixes = TRUE;
1278 gdk_x11_register_standard_event_type (display,
1279 display_x11->xfixes_event_base,
1280 XFixesNumberEvents);
1284 display_x11->have_xfixes = FALSE;
1286 #ifdef HAVE_XCOMPOSITE
1287 if (XCompositeQueryExtension (display_x11->xdisplay,
1292 XCompositeQueryVersion (display_x11->xdisplay, &major, &minor);
1294 /* Prior to Composite version 0.4, composited windows clipped their
1295 * parents, so you had to use IncludeInferiors to draw to the parent
1296 * This isn't useful for our purposes, so require 0.4
1298 display_x11->have_xcomposite = major > 0 || (major == 0 && minor >= 4);
1302 display_x11->have_xcomposite = FALSE;
1305 if (XDamageQueryExtension (display_x11->xdisplay,
1306 &display_x11->xdamage_event_base,
1309 display_x11->have_xdamage = TRUE;
1311 gdk_x11_register_standard_event_type (display,
1312 display_x11->xdamage_event_base,
1313 XDamageNumberEvents);
1317 display_x11->have_xdamage = FALSE;
1319 display_x11->have_shapes = FALSE;
1320 display_x11->have_input_shapes = FALSE;
1322 if (XShapeQueryExtension (GDK_DISPLAY_XDISPLAY (display), &display_x11->shape_event_base, &ignore))
1324 display_x11->have_shapes = TRUE;
1326 if (XShapeQueryVersion (GDK_DISPLAY_XDISPLAY (display), &maj, &min))
1327 display_x11->have_input_shapes = (maj == 1 && min >= 1);
1331 display_x11->trusted_client = TRUE;
1334 int rootx, rooty, winx, winy;
1337 gdk_x11_display_error_trap_push (display);
1338 XQueryPointer (display_x11->xdisplay,
1339 GDK_X11_SCREEN (display_x11->default_screen)->xroot_window,
1340 &root, &child, &rootx, &rooty, &winx, &winy, &xmask);
1341 if (G_UNLIKELY (gdk_x11_display_error_trap_pop (display) == BadWindow))
1343 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));
1344 display_x11->trusted_client = FALSE;
1348 if (g_getenv ("GDK_SYNCHRONIZE"))
1349 XSynchronize (display_x11->xdisplay, True);
1351 class_hint = XAllocClassHint();
1352 class_hint->res_name = g_get_prgname ();
1354 class_hint->res_class = (char *)gdk_get_program_class ();
1356 /* XmbSetWMProperties sets the RESOURCE_NAME environment variable
1357 * from argv[0], so we just synthesize an argument array here.
1360 argv[0] = g_get_prgname ();
1362 XmbSetWMProperties (display_x11->xdisplay,
1363 display_x11->leader_window,
1364 NULL, NULL, argv, argc, NULL, NULL,
1368 if (gdk_sm_client_id)
1369 set_sm_client_id (display, gdk_sm_client_id);
1372 XChangeProperty (display_x11->xdisplay,
1373 display_x11->leader_window,
1374 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PID"),
1375 XA_CARDINAL, 32, PropModeReplace, (guchar *) & pid, 1);
1377 /* We don't yet know a valid time. */
1378 display_x11->user_time = 0;
1382 gint xkb_major = XkbMajorVersion;
1383 gint xkb_minor = XkbMinorVersion;
1384 if (XkbLibraryVersion (&xkb_major, &xkb_minor))
1386 xkb_major = XkbMajorVersion;
1387 xkb_minor = XkbMinorVersion;
1389 if (XkbQueryExtension (display_x11->xdisplay,
1390 NULL, &display_x11->xkb_event_type, NULL,
1391 &xkb_major, &xkb_minor))
1393 Bool detectable_autorepeat_supported;
1395 display_x11->use_xkb = TRUE;
1397 XkbSelectEvents (display_x11->xdisplay,
1399 XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask,
1400 XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask);
1402 /* keep this in sync with _gdk_x11_keymap_state_changed() */
1403 XkbSelectEventDetails (display_x11->xdisplay,
1404 XkbUseCoreKbd, XkbStateNotify,
1405 XkbAllStateComponentsMask,
1406 XkbGroupLockMask|XkbModifierLockMask);
1408 XkbSetDetectableAutoRepeat (display_x11->xdisplay,
1410 &detectable_autorepeat_supported);
1412 GDK_NOTE (MISC, g_message ("Detectable autorepeat %s.",
1413 detectable_autorepeat_supported ?
1414 "supported" : "not supported"));
1416 display_x11->have_xkb_autorepeat = detectable_autorepeat_supported;
1422 display_x11->use_sync = FALSE;
1426 int error_base, event_base;
1428 if (XSyncQueryExtension (display_x11->xdisplay,
1429 &event_base, &error_base) &&
1430 XSyncInitialize (display_x11->xdisplay,
1432 display_x11->use_sync = TRUE;
1436 gdk_x11_display_init_input (display);
1438 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1439 _gdk_x11_screen_setup (display_x11->screens[i]);
1441 g_signal_emit_by_name (display, "opened");
1442 g_signal_emit_by_name (gdk_display_manager_get (), "display-opened", display);
1449 * XLib internal connection handling
1451 typedef struct _GdkInternalConnection GdkInternalConnection;
1453 struct _GdkInternalConnection
1461 process_internal_connection (GIOChannel *gioc,
1465 GdkInternalConnection *connection = (GdkInternalConnection *)data;
1467 GDK_THREADS_ENTER ();
1469 XProcessInternalConnection ((Display*)connection->display, connection->fd);
1471 GDK_THREADS_LEAVE ();
1477 gdk_x11_display_get_next_serial (GdkDisplay *display)
1479 return NextRequest (GDK_DISPLAY_XDISPLAY (display));
1483 static GdkInternalConnection *
1484 gdk_add_connection_handler (Display *display,
1487 GIOChannel *io_channel;
1488 GdkInternalConnection *connection;
1490 connection = g_new (GdkInternalConnection, 1);
1492 connection->fd = fd;
1493 connection->display = display;
1495 io_channel = g_io_channel_unix_new (fd);
1497 connection->source = g_io_create_watch (io_channel, G_IO_IN);
1498 g_source_set_callback (connection->source,
1499 (GSourceFunc)process_internal_connection, connection, NULL);
1500 g_source_attach (connection->source, NULL);
1502 g_io_channel_unref (io_channel);
1508 gdk_remove_connection_handler (GdkInternalConnection *connection)
1510 g_source_destroy (connection->source);
1511 g_free (connection);
1515 gdk_internal_connection_watch (Display *display,
1519 XPointer *watch_data)
1522 *watch_data = (XPointer)gdk_add_connection_handler (display, fd);
1524 gdk_remove_connection_handler ((GdkInternalConnection *)*watch_data);
1526 #endif /* HAVE_X11R6 */
1528 static const gchar *
1529 gdk_x11_display_get_name (GdkDisplay *display)
1531 return (gchar *) DisplayString (GDK_X11_DISPLAY (display)->xdisplay);
1535 gdk_x11_display_get_n_screens (GdkDisplay *display)
1537 return ScreenCount (GDK_X11_DISPLAY (display)->xdisplay);
1541 gdk_x11_display_get_screen (GdkDisplay *display,
1544 g_return_val_if_fail (ScreenCount (GDK_X11_DISPLAY (display)->xdisplay) > screen_num, NULL);
1546 return GDK_X11_DISPLAY (display)->screens[screen_num];
1550 gdk_x11_display_get_default_screen (GdkDisplay *display)
1552 return GDK_X11_DISPLAY (display)->default_screen;
1556 _gdk_x11_display_is_root_window (GdkDisplay *display,
1557 Window xroot_window)
1559 GdkX11Display *display_x11;
1562 display_x11 = GDK_X11_DISPLAY (display);
1564 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1566 if (GDK_SCREEN_XROOTWIN (display_x11->screens[i]) == xroot_window)
1572 struct XPointerUngrabInfo {
1573 GdkDisplay *display;
1578 device_grab_update_callback (GdkDisplay *display,
1582 GdkDevice *device = data;
1584 _gdk_display_device_grab_update (display, device, NULL, serial);
1587 #define XSERVER_TIME_IS_LATER(time1, time2) \
1588 ( (( time1 > time2 ) && ( time1 - time2 < ((guint32)-1)/2 )) || \
1589 (( time1 < time2 ) && ( time2 - time1 > ((guint32)-1)/2 )) \
1593 _gdk_x11_display_update_grab_info (GdkDisplay *display,
1597 if (status == GrabSuccess)
1598 _gdk_x11_roundtrip_async (display, device_grab_update_callback, device);
1602 _gdk_x11_display_update_grab_info_ungrab (GdkDisplay *display,
1607 GdkDeviceGrabInfo *grab;
1609 XFlush (GDK_DISPLAY_XDISPLAY (display));
1611 grab = _gdk_display_get_last_device_grab (display, device);
1613 (time == GDK_CURRENT_TIME ||
1614 grab->time == GDK_CURRENT_TIME ||
1615 !XSERVER_TIME_IS_LATER (grab->time, time)))
1617 grab->serial_end = serial;
1618 _gdk_x11_roundtrip_async (display, device_grab_update_callback, device);
1623 gdk_x11_display_beep (GdkDisplay *display)
1626 XkbBell (GDK_DISPLAY_XDISPLAY (display), None, 0, None);
1628 XBell (GDK_DISPLAY_XDISPLAY (display), 0);
1633 gdk_x11_display_sync (GdkDisplay *display)
1635 XSync (GDK_DISPLAY_XDISPLAY (display), False);
1639 gdk_x11_display_flush (GdkDisplay *display)
1641 if (!display->closed)
1642 XFlush (GDK_DISPLAY_XDISPLAY (display));
1646 gdk_x11_display_has_pending (GdkDisplay *display)
1648 return XPending (GDK_DISPLAY_XDISPLAY (display));
1652 gdk_x11_display_get_default_group (GdkDisplay *display)
1654 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1656 return GDK_X11_DISPLAY (display)->leader_gdk_window;
1660 * gdk_x11_display_grab:
1661 * @display: (type GdkX11Display): a #GdkDisplay
1663 * Call XGrabServer() on @display.
1664 * To ungrab the display again, use gdk_x11_display_ungrab().
1666 * gdk_x11_display_grab()/gdk_x11_display_ungrab() calls can be nested.
1671 gdk_x11_display_grab (GdkDisplay *display)
1673 GdkX11Display *display_x11;
1675 g_return_if_fail (GDK_IS_DISPLAY (display));
1677 display_x11 = GDK_X11_DISPLAY (display);
1679 if (display_x11->grab_count == 0)
1680 XGrabServer (display_x11->xdisplay);
1681 display_x11->grab_count++;
1685 * gdk_x11_display_ungrab:
1686 * @display: (type GdkX11Display): a #GdkDisplay
1688 * Ungrab @display after it has been grabbed with
1689 * gdk_x11_display_grab().
1694 gdk_x11_display_ungrab (GdkDisplay *display)
1696 GdkX11Display *display_x11;
1698 g_return_if_fail (GDK_IS_DISPLAY (display));
1700 display_x11 = GDK_X11_DISPLAY (display);;
1701 g_return_if_fail (display_x11->grab_count > 0);
1703 display_x11->grab_count--;
1704 if (display_x11->grab_count == 0)
1706 XUngrabServer (display_x11->xdisplay);
1707 XFlush (display_x11->xdisplay);
1712 gdk_x11_display_dispose (GObject *object)
1714 GdkDisplay *display = GDK_DISPLAY (object);
1715 GdkX11Display *display_x11 = GDK_X11_DISPLAY (object);
1718 _gdk_x11_display_manager_remove_display (gdk_display_manager_get (), display);
1720 g_list_foreach (display_x11->input_devices, (GFunc) g_object_run_dispose, NULL);
1722 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1723 _gdk_screen_close (display_x11->screens[i]);
1725 if (display_x11->event_source)
1727 g_source_destroy (display_x11->event_source);
1728 g_source_unref (display_x11->event_source);
1729 display_x11->event_source = NULL;
1732 G_OBJECT_CLASS (gdk_x11_display_parent_class)->dispose (object);
1736 gdk_x11_display_finalize (GObject *object)
1738 GdkX11Display *display_x11 = GDK_X11_DISPLAY (object);
1742 if (display_x11->keymap)
1743 g_object_unref (display_x11->keymap);
1745 /* Free motif Dnd */
1746 if (display_x11->motif_target_lists)
1748 for (i = 0; i < display_x11->motif_n_target_lists; i++)
1749 g_list_free (display_x11->motif_target_lists[i]);
1750 g_free (display_x11->motif_target_lists);
1753 _gdk_x11_cursor_display_finalize (GDK_DISPLAY (display_x11));
1755 /* Empty the event queue */
1756 _gdk_x11_display_free_translate_queue (GDK_DISPLAY (display_x11));
1758 /* Atom Hashtable */
1759 g_hash_table_destroy (display_x11->atom_from_virtual);
1760 g_hash_table_destroy (display_x11->atom_to_virtual);
1763 XDestroyWindow (display_x11->xdisplay, display_x11->leader_window);
1765 /* List of event window extraction functions */
1766 g_slist_foreach (display_x11->event_types, (GFunc)g_free, NULL);
1767 g_slist_free (display_x11->event_types);
1769 /* input GdkDevice list */
1770 g_list_free_full (display_x11->input_devices, g_object_unref);
1772 /* input GdkWindow list */
1773 g_list_free_full (display_x11->input_windows, g_free);
1775 /* Free all GdkScreens */
1776 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1777 g_object_unref (display_x11->screens[i]);
1778 g_free (display_x11->screens);
1780 g_free (display_x11->startup_notification_id);
1782 /* X ID hashtable */
1783 g_hash_table_destroy (display_x11->xid_ht);
1785 XCloseDisplay (display_x11->xdisplay);
1788 while (display_x11->error_traps != NULL)
1790 GdkErrorTrap *trap = display_x11->error_traps->data;
1792 display_x11->error_traps =
1793 g_slist_delete_link (display_x11->error_traps,
1794 display_x11->error_traps);
1796 if (trap->end_sequence == 0)
1797 g_warning ("Display finalized with an unpopped error trap");
1799 g_slice_free (GdkErrorTrap, trap);
1802 G_OBJECT_CLASS (gdk_x11_display_parent_class)->finalize (object);
1806 * gdk_x11_lookup_xdisplay:
1807 * @xdisplay: a pointer to an X Display
1809 * Find the #GdkDisplay corresponding to @display, if any exists.
1811 * Return value: (transfer none): the #GdkDisplay, if found, otherwise %NULL.
1816 gdk_x11_lookup_xdisplay (Display *xdisplay)
1819 GdkDisplay *display;
1823 list = gdk_display_manager_list_displays (gdk_display_manager_get ());
1825 for (l = list; l; l = l->next)
1827 if (GDK_DISPLAY_XDISPLAY (l->data) == xdisplay)
1834 g_slist_free (list);
1840 * _gdk_x11_display_screen_for_xrootwin:
1841 * @display: a #GdkDisplay
1842 * @xrootwin: window ID for one of of the screen's of the display.
1844 * Given the root window ID of one of the screen's of a #GdkDisplay,
1847 * Return value: (transfer none): the #GdkScreen corresponding to
1848 * @xrootwin, or %NULL.
1851 _gdk_x11_display_screen_for_xrootwin (GdkDisplay *display,
1856 for (i = 0; i < ScreenCount (GDK_X11_DISPLAY (display)->xdisplay); i++)
1858 GdkScreen *screen = gdk_display_get_screen (display, i);
1859 if (GDK_SCREEN_XROOTWIN (screen) == xrootwin)
1867 * gdk_x11_display_get_xdisplay:
1868 * @display: (type GdkX11Display): a #GdkDisplay
1870 * Returns the X display of a #GdkDisplay.
1872 * Returns: (transfer none): an X display
1877 gdk_x11_display_get_xdisplay (GdkDisplay *display)
1879 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1880 return GDK_X11_DISPLAY (display)->xdisplay;
1884 _gdk_x11_display_make_default (GdkDisplay *display)
1886 GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
1887 const gchar *startup_id;
1889 g_free (display_x11->startup_notification_id);
1890 display_x11->startup_notification_id = NULL;
1892 startup_id = g_getenv ("DESKTOP_STARTUP_ID");
1893 if (startup_id && *startup_id != '\0')
1895 if (!g_utf8_validate (startup_id, -1, NULL))
1896 g_warning ("DESKTOP_STARTUP_ID contains invalid UTF-8");
1898 gdk_x11_display_set_startup_notification_id (display, startup_id);
1900 /* Clear the environment variable so it won't be inherited by
1901 * child processes and confuse things.
1903 g_unsetenv ("DESKTOP_STARTUP_ID");
1908 broadcast_xmessage (GdkDisplay *display,
1909 const char *message_type,
1910 const char *message_type_begin,
1911 const char *message)
1913 Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
1914 GdkScreen *screen = gdk_display_get_default_screen (display);
1915 GdkWindow *root_window = gdk_screen_get_root_window (screen);
1916 Window xroot_window = GDK_WINDOW_XID (root_window);
1919 Atom type_atom_begin;
1922 if (!G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client))
1926 XSetWindowAttributes attrs;
1928 attrs.override_redirect = True;
1929 attrs.event_mask = PropertyChangeMask | StructureNotifyMask;
1932 XCreateWindow (xdisplay,
1938 (Visual *)CopyFromParent,
1939 CWOverrideRedirect | CWEventMask,
1943 type_atom = gdk_x11_get_xatom_by_name_for_display (display,
1945 type_atom_begin = gdk_x11_get_xatom_by_name_for_display (display,
1946 message_type_begin);
1949 XClientMessageEvent xclient;
1951 const char *src_end;
1955 memset(&xclient, 0, sizeof (xclient));
1956 xclient.type = ClientMessage;
1957 xclient.message_type = type_atom_begin;
1958 xclient.display =xdisplay;
1959 xclient.window = xwindow;
1963 src_end = message + strlen (message) + 1; /* +1 to include nul byte */
1965 while (src != src_end)
1967 dest = &xclient.data.b[0];
1968 dest_end = dest + 20;
1970 while (dest != dest_end &&
1978 while (dest != dest_end)
1984 XSendEvent (xdisplay,
1988 (XEvent *)&xclient);
1990 xclient.message_type = type_atom;
1994 XDestroyWindow (xdisplay, xwindow);
1999 * gdk_x11_display_broadcast_startup_message:
2000 * @display: (type GdkX11Display): a #GdkDisplay
2001 * @message_type: startup notification message type ("new", "change",
2003 * @...: a list of key/value pairs (as strings), terminated by a
2004 * %NULL key. (A %NULL value for a key will cause that key to be
2005 * skipped in the output.)
2007 * Sends a startup notification message of type @message_type to
2010 * This is a convenience function for use by code that implements the
2011 * freedesktop startup notification specification. Applications should
2012 * not normally need to call it directly. See the <ulink
2013 * url="http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">Startup
2014 * Notification Protocol specification</ulink> for
2015 * definitions of the message types and keys that can be used.
2020 gdk_x11_display_broadcast_startup_message (GdkDisplay *display,
2021 const char *message_type,
2026 const char *key, *value, *p;
2028 message = g_string_new (message_type);
2029 g_string_append_c (message, ':');
2031 va_start (ap, message_type);
2032 while ((key = va_arg (ap, const char *)))
2034 value = va_arg (ap, const char *);
2038 g_string_append_printf (message, " %s=\"", key);
2039 for (p = value; *p; p++)
2046 g_string_append_c (message, '\\');
2050 g_string_append_c (message, *p);
2052 g_string_append_c (message, '\"');
2056 broadcast_xmessage (display,
2057 "_NET_STARTUP_INFO",
2058 "_NET_STARTUP_INFO_BEGIN",
2061 g_string_free (message, TRUE);
2065 gdk_x11_display_notify_startup_complete (GdkDisplay *display,
2066 const gchar *startup_id)
2068 if (startup_id == NULL)
2070 startup_id = GDK_X11_DISPLAY (display)->startup_notification_id;
2071 if (startup_id == NULL)
2075 gdk_x11_display_broadcast_startup_message (display, "remove",
2081 gdk_x11_display_supports_selection_notification (GdkDisplay *display)
2083 GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
2085 return display_x11->have_xfixes;
2089 gdk_x11_display_request_selection_notification (GdkDisplay *display,
2094 GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
2097 if (display_x11->have_xfixes)
2099 atom = gdk_x11_atom_to_xatom_for_display (display,
2101 XFixesSelectSelectionInput (display_x11->xdisplay,
2102 display_x11->leader_window,
2104 XFixesSetSelectionOwnerNotifyMask |
2105 XFixesSelectionWindowDestroyNotifyMask |
2106 XFixesSelectionClientCloseNotifyMask);
2115 gdk_x11_display_supports_clipboard_persistence (GdkDisplay *display)
2117 Atom clipboard_manager;
2119 /* It might make sense to cache this */
2120 clipboard_manager = gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER");
2121 return XGetSelectionOwner (GDK_X11_DISPLAY (display)->xdisplay, clipboard_manager) != None;
2125 gdk_x11_display_store_clipboard (GdkDisplay *display,
2126 GdkWindow *clipboard_window,
2128 const GdkAtom *targets,
2131 GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
2132 Atom clipboard_manager, save_targets;
2134 g_return_if_fail (GDK_WINDOW_IS_X11 (clipboard_window));
2136 clipboard_manager = gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER");
2137 save_targets = gdk_x11_get_xatom_by_name_for_display (display, "SAVE_TARGETS");
2139 gdk_x11_display_error_trap_push (display);
2141 if (XGetSelectionOwner (display_x11->xdisplay, clipboard_manager) != None)
2143 Atom property_name = None;
2149 property_name = gdk_x11_get_xatom_by_name_for_display (display, "GDK_SELECTION");
2151 xatoms = g_new (Atom, n_targets);
2152 for (i = 0; i < n_targets; i++)
2153 xatoms[i] = gdk_x11_atom_to_xatom_for_display (display, targets[i]);
2155 XChangeProperty (display_x11->xdisplay, GDK_WINDOW_XID (clipboard_window),
2156 property_name, XA_ATOM,
2157 32, PropModeReplace, (guchar *)xatoms, n_targets);
2162 XConvertSelection (display_x11->xdisplay,
2163 clipboard_manager, save_targets, property_name,
2164 GDK_WINDOW_XID (clipboard_window), time_);
2167 gdk_x11_display_error_trap_pop_ignored (display);
2172 * gdk_x11_display_get_user_time:
2173 * @display: (type GdkX11Display): a #GdkDisplay
2175 * Returns the timestamp of the last user interaction on
2176 * @display. The timestamp is taken from events caused
2177 * by user interaction such as key presses or pointer
2178 * movements. See gdk_x11_window_set_user_time().
2180 * Returns: the timestamp of the last user interaction
2185 gdk_x11_display_get_user_time (GdkDisplay *display)
2187 return GDK_X11_DISPLAY (display)->user_time;
2191 gdk_x11_display_supports_shapes (GdkDisplay *display)
2193 return GDK_X11_DISPLAY (display)->have_shapes;
2197 gdk_x11_display_supports_input_shapes (GdkDisplay *display)
2199 return GDK_X11_DISPLAY (display)->have_input_shapes;
2204 * gdk_x11_display_get_startup_notification_id:
2205 * @display: (type GdkX11Display): a #GdkDisplay
2207 * Gets the startup notification ID for a display.
2209 * Returns: the startup notification ID for @display
2214 gdk_x11_display_get_startup_notification_id (GdkDisplay *display)
2216 return GDK_X11_DISPLAY (display)->startup_notification_id;
2220 * gdk_x11_display_set_startup_notification_id:
2221 * @display: (type GdkX11Display): a #GdkDisplay
2222 * @startup_id: the startup notification ID (must be valid utf8)
2224 * Sets the startup notification ID for a display.
2226 * This is usually taken from the value of the DESKTOP_STARTUP_ID
2227 * environment variable, but in some cases (such as the application not
2228 * being launched using exec()) it can come from other sources.
2230 * If the ID contains the string "_TIME" then the portion following that
2231 * string is taken to be the X11 timestamp of the event that triggered
2232 * the application to be launched and the GDK current event time is set
2235 * The startup ID is also what is used to signal that the startup is
2236 * complete (for example, when opening a window or when calling
2237 * gdk_notify_startup_complete()).
2242 gdk_x11_display_set_startup_notification_id (GdkDisplay *display,
2243 const gchar *startup_id)
2245 GdkX11Display *display_x11;
2248 display_x11 = GDK_X11_DISPLAY (display);
2250 g_free (display_x11->startup_notification_id);
2251 display_x11->startup_notification_id = g_strdup (startup_id);
2253 /* Find the launch time from the startup_id, if it's there. Newer spec
2254 * states that the startup_id is of the form <unique>_TIME<timestamp>
2256 time_str = g_strrstr (startup_id, "_TIME");
2257 if (time_str != NULL)
2263 /* Skip past the "_TIME" part */
2266 retval = strtoul (time_str, &end, 0);
2267 if (end != time_str && errno == 0)
2268 display_x11->user_time = retval;
2271 /* Set the startup id on the leader window so it
2272 * applies to all windows we create on this display
2274 XChangeProperty (display_x11->xdisplay,
2275 display_x11->leader_window,
2276 gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"),
2277 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
2279 (guchar *)startup_id, strlen (startup_id));
2283 gdk_x11_display_supports_composite (GdkDisplay *display)
2285 GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
2287 return x11_display->have_xcomposite &&
2288 x11_display->have_xdamage &&
2289 x11_display->have_xfixes;
2293 gdk_x11_display_list_devices (GdkDisplay *display)
2295 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
2297 return GDK_X11_DISPLAY (display)->input_devices;
2301 * gdk_x11_register_standard_event_type:
2302 * @display: a #GdkDisplay
2303 * @event_base: first event type code to register
2304 * @n_events: number of event type codes to register
2306 * Registers interest in receiving extension events with type codes
2307 * between @event_base and <literal>event_base + n_events - 1</literal>.
2308 * The registered events must have the window field in the same place
2309 * as core X events (this is not the case for e.g. XKB extension events).
2311 * If an event type is registered, events of this type will go through
2312 * global and window-specific filters (see gdk_window_add_filter()).
2313 * Unregistered events will only go through global filters.
2314 * GDK may register the events of some X extensions on its own.
2316 * This function should only be needed in unusual circumstances, e.g.
2317 * when filtering XInput extension events on the root window.
2322 gdk_x11_register_standard_event_type (GdkDisplay *display,
2326 GdkEventTypeX11 *event_type;
2327 GdkX11Display *display_x11;
2329 display_x11 = GDK_X11_DISPLAY (display);
2330 event_type = g_new (GdkEventTypeX11, 1);
2332 event_type->base = event_base;
2333 event_type->n_events = n_events;
2335 display_x11->event_types = g_slist_prepend (display_x11->event_types, event_type);
2338 /* compare X sequence numbers handling wraparound */
2339 #define SEQUENCE_COMPARE(a,op,b) (((long) (a) - (long) (b)) op 0)
2341 /* delivers an error event from the error handler in gdkmain-x11.c */
2343 _gdk_x11_display_error_event (GdkDisplay *display,
2346 GdkX11Display *display_x11;
2350 display_x11 = GDK_X11_DISPLAY (display);
2353 for (tmp_list = display_x11->error_traps;
2355 tmp_list = tmp_list->next)
2359 trap = tmp_list->data;
2361 if (SEQUENCE_COMPARE (trap->start_sequence, <=, error->serial) &&
2362 (trap->end_sequence == 0 ||
2363 SEQUENCE_COMPARE (trap->end_sequence, >, error->serial)))
2366 trap->error_code = error->error_code;
2367 break; /* only innermost trap gets the error code */
2376 XGetErrorText (display_x11->xdisplay, error->error_code, buf, 63);
2379 g_strdup_printf ("The program '%s' received an X Window System error.\n"
2380 "This probably reflects a bug in the program.\n"
2381 "The error was '%s'.\n"
2382 " (Details: serial %ld error_code %d request_code %d minor_code %d)\n"
2383 " (Note to programmers: normally, X errors are reported asynchronously;\n"
2384 " that is, you will receive the error a while after causing it.\n"
2385 " To debug your program, run it with the GDK_SYNCHRONIZE environment\n"
2386 " variable to change this behavior. You can then get a meaningful\n"
2387 " backtrace from your debugger if you break on the gdk_x_error() function.)",
2392 error->request_code,
2395 #ifdef G_ENABLE_DEBUG
2396 g_error ("%s", msg);
2397 #else /* !G_ENABLE_DEBUG */
2398 g_warning ("%s\n", msg);
2401 #endif /* G_ENABLE_DEBUG */
2406 delete_outdated_error_traps (GdkX11Display *display_x11)
2409 gulong processed_sequence;
2411 processed_sequence = XLastKnownRequestProcessed (display_x11->xdisplay);
2413 tmp_list = display_x11->error_traps;
2414 while (tmp_list != NULL)
2416 GdkErrorTrap *trap = tmp_list->data;
2418 if (trap->end_sequence != 0 &&
2419 SEQUENCE_COMPARE (trap->end_sequence, <=, processed_sequence))
2421 GSList *free_me = tmp_list;
2423 tmp_list = tmp_list->next;
2424 display_x11->error_traps =
2425 g_slist_delete_link (display_x11->error_traps, free_me);
2426 g_slice_free (GdkErrorTrap, trap);
2430 tmp_list = tmp_list->next;
2436 * gdk_x11_display_error_trap_push:
2437 * @display: (type GdkX11Display): a #GdkDisplay
2439 * Begins a range of X requests on @display for which X error events
2440 * will be ignored. Unignored errors (when no trap is pushed) will abort
2441 * the application. Use gdk_x11_display_error_trap_pop() or
2442 * gdk_x11_display_error_trap_pop_ignored()to lift a trap pushed
2443 * with this function.
2445 * See also gdk_error_trap_push() to push a trap on all displays.
2450 gdk_x11_display_error_trap_push (GdkDisplay *display)
2452 GdkX11Display *display_x11;
2455 display_x11 = GDK_X11_DISPLAY (display);
2457 delete_outdated_error_traps (display_x11);
2459 /* set up the Xlib callback to tell us about errors */
2460 _gdk_x11_error_handler_push ();
2462 trap = g_slice_new0 (GdkErrorTrap);
2464 trap->start_sequence = XNextRequest (display_x11->xdisplay);
2465 trap->error_code = Success;
2467 display_x11->error_traps =
2468 g_slist_prepend (display_x11->error_traps, trap);
2472 gdk_x11_display_error_trap_pop_internal (GdkDisplay *display,
2475 GdkX11Display *display_x11;
2480 display_x11 = GDK_X11_DISPLAY (display);
2482 g_return_val_if_fail (display_x11->error_traps != NULL, Success);
2484 /* Find the first trap that hasn't been popped already */
2485 trap = NULL; /* quiet gcc */
2486 for (tmp_list = display_x11->error_traps;
2488 tmp_list = tmp_list->next)
2490 trap = tmp_list->data;
2492 if (trap->end_sequence == 0)
2496 g_return_val_if_fail (trap != NULL, Success);
2497 g_assert (trap->end_sequence == 0);
2499 /* May need to sync to fill in trap->error_code if we care about
2500 * getting an error code.
2504 gulong processed_sequence;
2505 gulong next_sequence;
2507 next_sequence = XNextRequest (display_x11->xdisplay);
2508 processed_sequence = XLastKnownRequestProcessed (display_x11->xdisplay);
2510 /* If our last request was already processed, there is no point
2511 * in syncing. i.e. if last request was a round trip (or even if
2512 * we got an event with the serial of a non-round-trip)
2514 if ((next_sequence - 1) != processed_sequence)
2516 XSync (display_x11->xdisplay, False);
2519 result = trap->error_code;
2526 /* record end of trap, giving us a range of
2527 * error sequences we'll ignore.
2529 trap->end_sequence = XNextRequest (display_x11->xdisplay);
2531 /* remove the Xlib callback */
2532 _gdk_x11_error_handler_pop ();
2534 /* we may already be outdated */
2535 delete_outdated_error_traps (display_x11);
2541 * gdk_x11_display_error_trap_pop:
2542 * @display: (type GdkX11Display): the display
2544 * Pops the error trap pushed by gdk_x11_display_error_trap_push().
2545 * Will XSync() if necessary and will always block until
2546 * the error is known to have occurred or not occurred,
2547 * so the error code can be returned.
2549 * If you don't need to use the return value,
2550 * gdk_x11_display_error_trap_pop_ignored() would be more efficient.
2552 * See gdk_error_trap_pop() for the all-displays-at-once
2557 * Return value: X error code or 0 on success
2560 gdk_x11_display_error_trap_pop (GdkDisplay *display)
2562 g_return_val_if_fail (GDK_IS_X11_DISPLAY (display), Success);
2564 return gdk_x11_display_error_trap_pop_internal (display, TRUE);
2568 * gdk_x11_display_error_trap_pop_ignored:
2569 * @display: (type GdkX11Display): the display
2571 * Pops the error trap pushed by gdk_x11_display_error_trap_push().
2572 * Does not block to see if an error occurred; merely records the
2573 * range of requests to ignore errors for, and ignores those errors
2574 * if they arrive asynchronously.
2576 * See gdk_error_trap_pop_ignored() for the all-displays-at-once
2582 gdk_x11_display_error_trap_pop_ignored (GdkDisplay *display)
2584 g_return_if_fail (GDK_IS_X11_DISPLAY (display));
2586 gdk_x11_display_error_trap_pop_internal (display, FALSE);
2590 * gdk_x11_set_sm_client_id:
2591 * @sm_client_id: the client id assigned by the session manager when the
2592 * connection was opened, or %NULL to remove the property.
2594 * Sets the <literal>SM_CLIENT_ID</literal> property on the application's leader window so that
2595 * the window manager can save the application's state using the X11R6 ICCCM
2596 * session management protocol.
2598 * See the X Session Management Library documentation for more information on
2599 * session management and the Inter-Client Communication Conventions Manual
2604 gdk_x11_set_sm_client_id (const gchar *sm_client_id)
2606 GSList *displays, *l;
2608 g_free (gdk_sm_client_id);
2609 gdk_sm_client_id = g_strdup (sm_client_id);
2611 displays = gdk_display_manager_list_displays (gdk_display_manager_get ());
2612 for (l = displays; l; l = l->next)
2613 set_sm_client_id (l->data, sm_client_id);
2615 g_slist_free (displays);
2619 gdk_x11_display_event_data_copy (GdkDisplay *display,
2620 const GdkEvent *src,
2626 gdk_x11_display_event_data_free (GdkDisplay *display,
2632 pop_error_trap (GdkDisplay *display,
2637 gdk_x11_display_error_trap_pop_ignored (display);
2642 return gdk_x11_display_error_trap_pop (display);
2647 gdk_x11_display_get_keymap (GdkDisplay *display)
2649 GdkX11Display *display_x11;
2650 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
2651 display_x11 = GDK_X11_DISPLAY (display);
2653 if (!display_x11->keymap)
2654 display_x11->keymap = g_object_new (GDK_TYPE_X11_KEYMAP, NULL);
2656 display_x11->keymap->display = display;
2658 return display_x11->keymap;
2662 gdk_x11_display_class_init (GdkX11DisplayClass * class)
2664 GObjectClass *object_class = G_OBJECT_CLASS (class);
2665 GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (class);
2667 object_class->dispose = gdk_x11_display_dispose;
2668 object_class->finalize = gdk_x11_display_finalize;
2670 display_class->window_type = GDK_TYPE_X11_WINDOW;
2672 display_class->get_name = gdk_x11_display_get_name;
2673 display_class->get_n_screens = gdk_x11_display_get_n_screens;
2674 display_class->get_screen = gdk_x11_display_get_screen;
2675 display_class->get_default_screen = gdk_x11_display_get_default_screen;
2676 display_class->beep = gdk_x11_display_beep;
2677 display_class->sync = gdk_x11_display_sync;
2678 display_class->flush = gdk_x11_display_flush;
2679 display_class->has_pending = gdk_x11_display_has_pending;
2680 display_class->queue_events = _gdk_x11_display_queue_events;
2681 display_class->get_default_group = gdk_x11_display_get_default_group;
2682 display_class->supports_selection_notification = gdk_x11_display_supports_selection_notification;
2683 display_class->request_selection_notification = gdk_x11_display_request_selection_notification;
2684 display_class->supports_clipboard_persistence = gdk_x11_display_supports_clipboard_persistence;
2685 display_class->store_clipboard = gdk_x11_display_store_clipboard;
2686 display_class->supports_shapes = gdk_x11_display_supports_shapes;
2687 display_class->supports_input_shapes = gdk_x11_display_supports_input_shapes;
2688 display_class->supports_composite = gdk_x11_display_supports_composite;
2689 display_class->list_devices = gdk_x11_display_list_devices;
2690 display_class->get_app_launch_context = _gdk_x11_display_get_app_launch_context;
2691 display_class->get_cursor_for_type = _gdk_x11_display_get_cursor_for_type;
2692 display_class->get_cursor_for_name = _gdk_x11_display_get_cursor_for_name;
2693 display_class->get_cursor_for_pixbuf = _gdk_x11_display_get_cursor_for_pixbuf;
2694 display_class->get_default_cursor_size = _gdk_x11_display_get_default_cursor_size;
2695 display_class->get_maximal_cursor_size = _gdk_x11_display_get_maximal_cursor_size;
2696 display_class->supports_cursor_alpha = _gdk_x11_display_supports_cursor_alpha;
2697 display_class->supports_cursor_color = _gdk_x11_display_supports_cursor_color;
2699 display_class->before_process_all_updates = _gdk_x11_display_before_process_all_updates;
2700 display_class->after_process_all_updates = _gdk_x11_display_after_process_all_updates;
2701 display_class->get_next_serial = gdk_x11_display_get_next_serial;
2702 display_class->notify_startup_complete = gdk_x11_display_notify_startup_complete;
2703 display_class->event_data_copy = gdk_x11_display_event_data_copy;
2704 display_class->event_data_free = gdk_x11_display_event_data_free;
2705 display_class->create_window_impl = _gdk_x11_display_create_window_impl;
2706 display_class->get_keymap = gdk_x11_display_get_keymap;
2707 display_class->push_error_trap = gdk_x11_display_error_trap_push;
2708 display_class->pop_error_trap = pop_error_trap;
2709 display_class->get_selection_owner = _gdk_x11_display_get_selection_owner;
2710 display_class->set_selection_owner = _gdk_x11_display_set_selection_owner;
2711 display_class->send_selection_notify = _gdk_x11_display_send_selection_notify;
2712 display_class->get_selection_property = _gdk_x11_display_get_selection_property;
2713 display_class->convert_selection = _gdk_x11_display_convert_selection;
2714 display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list;
2715 display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target;