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 G_DEFINE_TYPE_WITH_CODE (GdkDisplayX11, _gdk_display_x11, GDK_TYPE_DISPLAY,
161 G_IMPLEMENT_INTERFACE (GDK_TYPE_EVENT_TRANSLATOR,
162 gdk_display_x11_event_translator_init))
166 _gdk_display_x11_init (GdkDisplayX11 *display)
168 _gdk_x11_display_manager_add_display (gdk_display_manager_get (),
169 GDK_DISPLAY_OBJECT (display));
173 gdk_display_x11_event_translator_init (GdkEventTranslatorIface *iface)
175 iface->translate_event = gdk_display_x11_translate_event;
179 do_net_wm_state_changes (GdkWindow *window)
181 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
182 GdkWindowState old_state;
184 if (GDK_WINDOW_DESTROYED (window) ||
185 gdk_window_get_window_type (window) != GDK_WINDOW_TOPLEVEL)
188 old_state = gdk_window_get_state (window);
190 /* For found_sticky to remain TRUE, we have to also be on desktop
193 if (old_state & GDK_WINDOW_STATE_STICKY)
195 if (!(toplevel->have_sticky && toplevel->on_all_desktops))
196 gdk_synthesize_window_state (window,
197 GDK_WINDOW_STATE_STICKY,
202 if (toplevel->have_sticky || toplevel->on_all_desktops)
203 gdk_synthesize_window_state (window,
205 GDK_WINDOW_STATE_STICKY);
208 if (old_state & GDK_WINDOW_STATE_FULLSCREEN)
210 if (!toplevel->have_fullscreen)
211 gdk_synthesize_window_state (window,
212 GDK_WINDOW_STATE_FULLSCREEN,
217 if (toplevel->have_fullscreen)
218 gdk_synthesize_window_state (window,
220 GDK_WINDOW_STATE_FULLSCREEN);
223 /* Our "maximized" means both vertical and horizontal; if only one,
224 * we don't expose that via GDK
226 if (old_state & GDK_WINDOW_STATE_MAXIMIZED)
228 if (!(toplevel->have_maxvert && toplevel->have_maxhorz))
229 gdk_synthesize_window_state (window,
230 GDK_WINDOW_STATE_MAXIMIZED,
235 if (toplevel->have_maxvert && toplevel->have_maxhorz)
236 gdk_synthesize_window_state (window,
238 GDK_WINDOW_STATE_MAXIMIZED);
243 gdk_check_wm_desktop_changed (GdkWindow *window)
245 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
246 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
256 gdk_error_trap_push ();
257 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
258 GDK_WINDOW_XID (window),
259 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
260 0, G_MAXLONG, False, XA_CARDINAL, &type,
262 &bytes_after, &data);
263 gdk_error_trap_pop_ignored ();
267 desktop = (gulong *)data;
268 toplevel->on_all_desktops = (*desktop == 0xFFFFFFFF);
272 toplevel->on_all_desktops = FALSE;
274 do_net_wm_state_changes (window);
278 gdk_check_wm_state_changed (GdkWindow *window)
280 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
281 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
291 gboolean had_sticky = toplevel->have_sticky;
293 toplevel->have_sticky = FALSE;
294 toplevel->have_maxvert = FALSE;
295 toplevel->have_maxhorz = FALSE;
296 toplevel->have_fullscreen = FALSE;
299 gdk_error_trap_push ();
300 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
301 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"),
302 0, G_MAXLONG, False, XA_ATOM, &type, &format, &nitems,
303 &bytes_after, &data);
304 gdk_error_trap_pop_ignored ();
308 Atom sticky_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_STICKY");
309 Atom maxvert_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_MAXIMIZED_VERT");
310 Atom maxhorz_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_MAXIMIZED_HORZ");
311 Atom fullscreen_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_FULLSCREEN");
313 atoms = (Atom *)data;
318 if (atoms[i] == sticky_atom)
319 toplevel->have_sticky = TRUE;
320 else if (atoms[i] == maxvert_atom)
321 toplevel->have_maxvert = TRUE;
322 else if (atoms[i] == maxhorz_atom)
323 toplevel->have_maxhorz = TRUE;
324 else if (atoms[i] == fullscreen_atom)
325 toplevel->have_fullscreen = TRUE;
333 /* When have_sticky is turned on, we have to check the DESKTOP property
336 if (toplevel->have_sticky && !had_sticky)
337 gdk_check_wm_desktop_changed (window);
339 do_net_wm_state_changes (window);
343 get_event_window (GdkEventTranslator *translator,
349 display = (GdkDisplay *) translator;
351 switch (xevent->type)
354 xwindow = xevent->xdestroywindow.window;
357 xwindow = xevent->xunmap.window;
360 xwindow = xevent->xmap.window;
362 case ConfigureNotify:
363 xwindow = xevent->xconfigure.window;
366 xwindow = xevent->xany.window;
369 return gdk_window_lookup_for_display (display, xwindow);
373 gdk_display_x11_translate_event (GdkEventTranslator *translator,
379 GdkWindowImplX11 *window_impl = NULL;
380 GdkScreen *screen = NULL;
381 GdkScreenX11 *screen_x11 = NULL;
382 GdkToplevelX11 *toplevel = NULL;
383 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
385 Window xwindow = None;
387 /* Find the GdkWindow that this event relates to.
388 * Basically this means substructure events
389 * are reported same as structure events
391 window = get_event_window (translator, xevent);
395 /* We may receive events such as NoExpose/GraphicsExpose
396 * and ShmCompletion for pixmaps
398 if (!GDK_IS_WINDOW (window))
401 screen = GDK_WINDOW_SCREEN (window);
402 screen_x11 = GDK_SCREEN_X11 (screen);
403 toplevel = _gdk_x11_window_get_toplevel (window);
404 window_impl = GDK_WINDOW_IMPL_X11 (window->impl);
405 xwindow = GDK_WINDOW_XID (window);
407 g_object_ref (window);
410 event->any.window = window;
411 event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
413 if (window && GDK_WINDOW_DESTROYED (window))
415 if (xevent->type != DestroyNotify)
422 if (xevent->type == DestroyNotify)
426 n = gdk_display_get_n_screens (display);
427 for (i = 0; i < n; i++)
429 screen = gdk_display_get_screen (display, i);
430 screen_x11 = GDK_SCREEN_X11 (screen);
432 if (screen_x11->wmspec_check_window == xwindow)
434 screen_x11->wmspec_check_window = None;
435 screen_x11->last_wmspec_check_time = 0;
436 g_free (screen_x11->window_manager_name);
437 screen_x11->window_manager_name = g_strdup ("unknown");
439 /* careful, reentrancy */
440 _gdk_x11_screen_window_manager_changed (screen);
448 /* We do a "manual" conversion of the XEvent to a
449 * GdkEvent. The structures are mostly the same so
450 * the conversion is fairly straightforward. We also
451 * optionally print debugging info regarding events
457 switch (xevent->type)
461 g_message ("keymap notify"));
463 /* Not currently handled */
469 g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d%s",
470 xevent->xexpose.window, xevent->xexpose.count,
471 xevent->xexpose.x, xevent->xexpose.y,
472 xevent->xexpose.width, xevent->xexpose.height,
473 event->any.send_event ? " (send)" : ""));
482 GdkRectangle expose_rect;
484 expose_rect.x = xevent->xexpose.x;
485 expose_rect.y = xevent->xexpose.y;
486 expose_rect.width = xevent->xexpose.width;
487 expose_rect.height = xevent->xexpose.height;
489 _gdk_window_process_expose (window, xevent->xexpose.serial, &expose_rect);
497 GdkRectangle expose_rect;
500 g_message ("graphics expose:\tdrawable: %ld",
501 xevent->xgraphicsexpose.drawable));
509 expose_rect.x = xevent->xgraphicsexpose.x;
510 expose_rect.y = xevent->xgraphicsexpose.y;
511 expose_rect.width = xevent->xgraphicsexpose.width;
512 expose_rect.height = xevent->xgraphicsexpose.height;
514 _gdk_window_process_expose (window, xevent->xgraphicsexpose.serial, &expose_rect);
519 case VisibilityNotify:
520 #ifdef G_ENABLE_DEBUG
521 if (_gdk_debug_flags & GDK_DEBUG_EVENTS)
522 switch (xevent->xvisibility.state)
524 case VisibilityFullyObscured:
525 g_message ("visibility notify:\twindow: %ld none",
526 xevent->xvisibility.window);
528 case VisibilityPartiallyObscured:
529 g_message ("visibility notify:\twindow: %ld partial",
530 xevent->xvisibility.window);
532 case VisibilityUnobscured:
533 g_message ("visibility notify:\twindow: %ld full",
534 xevent->xvisibility.window);
537 #endif /* G_ENABLE_DEBUG */
545 event->visibility.type = GDK_VISIBILITY_NOTIFY;
546 event->visibility.window = window;
548 switch (xevent->xvisibility.state)
550 case VisibilityFullyObscured:
551 event->visibility.state = GDK_VISIBILITY_FULLY_OBSCURED;
554 case VisibilityPartiallyObscured:
555 event->visibility.state = GDK_VISIBILITY_PARTIAL;
558 case VisibilityUnobscured:
559 event->visibility.state = GDK_VISIBILITY_UNOBSCURED;
567 g_message ("create notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d parent: %ld ovr: %d",
568 xevent->xcreatewindow.window,
569 xevent->xcreatewindow.x,
570 xevent->xcreatewindow.y,
571 xevent->xcreatewindow.width,
572 xevent->xcreatewindow.height,
573 xevent->xcreatewindow.border_width,
574 xevent->xcreatewindow.parent,
575 xevent->xcreatewindow.override_redirect));
576 /* not really handled */
581 g_message ("destroy notify:\twindow: %ld",
582 xevent->xdestroywindow.window));
584 /* Ignore DestroyNotify from SubstructureNotifyMask */
585 if (xevent->xdestroywindow.window == xevent->xdestroywindow.event)
587 event->any.type = GDK_DESTROY;
588 event->any.window = window;
590 return_val = window && !GDK_WINDOW_DESTROYED (window);
592 if (window && GDK_WINDOW_XID (window) != screen_x11->xroot_window)
593 gdk_window_destroy_notify (window);
602 g_message ("unmap notify:\t\twindow: %ld",
603 xevent->xmap.window));
605 event->any.type = GDK_UNMAP;
606 event->any.window = window;
608 /* If we are shown (not withdrawn) and get an unmap, it means we
609 * were iconified in the X sense. If we are withdrawn, and get
610 * an unmap, it means we hid the window ourselves, so we
611 * will have already flipped the iconified bit off.
615 if (GDK_WINDOW_IS_MAPPED (window))
616 gdk_synthesize_window_state (window,
618 GDK_WINDOW_STATE_ICONIFIED);
620 _gdk_xgrab_check_unmap (window, xevent->xany.serial);
627 g_message ("map notify:\t\twindow: %ld",
628 xevent->xmap.window));
630 event->any.type = GDK_MAP;
631 event->any.window = window;
633 /* Unset iconified if it was set */
634 if (window && (window->state & GDK_WINDOW_STATE_ICONIFIED))
635 gdk_synthesize_window_state (window,
636 GDK_WINDOW_STATE_ICONIFIED,
643 g_message ("reparent notify:\twindow: %ld x,y: %d %d parent: %ld ovr: %d",
644 xevent->xreparent.window,
647 xevent->xreparent.parent,
648 xevent->xreparent.override_redirect));
650 /* Not currently handled */
654 case ConfigureNotify:
656 g_message ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d%s",
657 xevent->xconfigure.window,
658 xevent->xconfigure.x,
659 xevent->xconfigure.y,
660 xevent->xconfigure.width,
661 xevent->xconfigure.height,
662 xevent->xconfigure.border_width,
663 xevent->xconfigure.above,
664 xevent->xconfigure.override_redirect,
667 : window->window_type == GDK_WINDOW_CHILD
668 ? " (discarding child)"
669 : xevent->xconfigure.event != xevent->xconfigure.window
670 ? " (discarding substructure)"
672 if (window && GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
674 window->width = xevent->xconfigure.width;
675 window->height = xevent->xconfigure.height;
677 _gdk_window_update_size (window);
678 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
679 _gdk_x11_screen_size_changed (screen, xevent);
683 if (toplevel && display_x11->use_sync && !XSyncValueIsZero (toplevel->pending_counter_value))
685 toplevel->current_counter_value = toplevel->pending_counter_value;
686 XSyncIntToValue (&toplevel->pending_counter_value, 0);
691 xevent->xconfigure.event != xevent->xconfigure.window ||
692 GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD ||
693 GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
697 event->configure.type = GDK_CONFIGURE;
698 event->configure.window = window;
699 event->configure.width = xevent->xconfigure.width;
700 event->configure.height = xevent->xconfigure.height;
702 if (!xevent->xconfigure.send_event &&
703 !xevent->xconfigure.override_redirect &&
704 !GDK_WINDOW_DESTROYED (window))
708 Window child_window = 0;
710 gdk_error_trap_push ();
711 if (XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
712 GDK_WINDOW_XID (window),
713 screen_x11->xroot_window,
718 event->configure.x = tx;
719 event->configure.y = ty;
721 gdk_error_trap_pop_ignored ();
725 event->configure.x = xevent->xconfigure.x;
726 event->configure.y = xevent->xconfigure.y;
728 window->x = event->configure.x;
729 window->y = event->configure.y;
730 window->width = xevent->xconfigure.width;
731 window->height = xevent->xconfigure.height;
733 _gdk_window_update_size (window);
734 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
736 if (window->resize_count >= 1)
738 window->resize_count -= 1;
740 if (window->resize_count == 0)
741 _gdk_moveresize_configure_done (display, window);
748 g_message ("property notify:\twindow: %ld, atom(%ld): %s%s%s",
749 xevent->xproperty.window,
750 xevent->xproperty.atom,
752 gdk_x11_get_xatom_name_for_display (display, xevent->xproperty.atom),
761 /* We compare with the serial of the last time we mapped the
762 * window to avoid refetching properties that we set ourselves
765 xevent->xproperty.serial >= toplevel->map_serial)
767 if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"))
768 gdk_check_wm_state_changed (window);
770 if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"))
771 gdk_check_wm_desktop_changed (window);
774 if (window->event_mask & GDK_PROPERTY_CHANGE_MASK)
776 event->property.type = GDK_PROPERTY_NOTIFY;
777 event->property.window = window;
778 event->property.atom = gdk_x11_xatom_to_atom_for_display (display, xevent->xproperty.atom);
779 event->property.time = xevent->xproperty.time;
780 event->property.state = xevent->xproperty.state;
789 g_message ("selection clear:\twindow: %ld",
790 xevent->xproperty.window));
792 if (_gdk_selection_filter_clear_event (&xevent->xselectionclear))
794 event->selection.type = GDK_SELECTION_CLEAR;
795 event->selection.window = window;
796 event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionclear.selection);
797 event->selection.time = xevent->xselectionclear.time;
804 case SelectionRequest:
806 g_message ("selection request:\twindow: %ld",
807 xevent->xproperty.window));
809 event->selection.type = GDK_SELECTION_REQUEST;
810 event->selection.window = window;
811 event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.selection);
812 event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.target);
813 event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.property);
814 event->selection.requestor = xevent->xselectionrequest.requestor;
815 event->selection.time = xevent->xselectionrequest.time;
819 case SelectionNotify:
821 g_message ("selection notify:\twindow: %ld",
822 xevent->xproperty.window));
824 event->selection.type = GDK_SELECTION_NOTIFY;
825 event->selection.window = window;
826 event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.selection);
827 event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.target);
828 if (xevent->xselection.property == None)
829 event->selection.property = GDK_NONE;
831 event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.property);
832 event->selection.time = xevent->xselection.time;
838 g_message ("colormap notify:\twindow: %ld",
839 xevent->xcolormap.window));
841 /* Not currently handled */
848 GdkFilterReturn result = GDK_FILTER_CONTINUE;
849 GdkAtom message_type = gdk_x11_xatom_to_atom_for_display (display, xevent->xclient.message_type);
852 g_message ("client message:\twindow: %ld",
853 xevent->xclient.window));
855 tmp_list = display_x11->client_filters;
858 GdkClientFilter *filter = tmp_list->data;
859 tmp_list = tmp_list->next;
861 if (filter->type == message_type)
863 result = (*filter->function) (xevent, event, filter->data);
864 if (result != GDK_FILTER_CONTINUE)
871 case GDK_FILTER_REMOVE:
874 case GDK_FILTER_TRANSLATE:
877 case GDK_FILTER_CONTINUE:
878 /* Send unknown ClientMessage's on to Gtk for it to use */
885 event->client.type = GDK_CLIENT_EVENT;
886 event->client.window = window;
887 event->client.message_type = message_type;
888 event->client.data_format = xevent->xclient.format;
889 memcpy(&event->client.data, &xevent->xclient.data,
890 sizeof(event->client.data));
900 g_message ("mapping notify"));
902 /* Let XLib know that there is a new keyboard mapping.
904 XRefreshKeyboardMapping (&xevent->xmapping);
905 _gdk_keymap_keys_changed (display);
911 if (xevent->type - display_x11->xfixes_event_base == XFixesSelectionNotify)
913 XFixesSelectionNotifyEvent *selection_notify = (XFixesSelectionNotifyEvent *)xevent;
915 _gdk_x11_screen_process_owner_change (screen, xevent);
917 event->owner_change.type = GDK_OWNER_CHANGE;
918 event->owner_change.window = window;
919 event->owner_change.owner = selection_notify->owner;
920 event->owner_change.reason = selection_notify->subtype;
921 event->owner_change.selection =
922 gdk_x11_xatom_to_atom_for_display (display,
923 selection_notify->selection);
924 event->owner_change.time = selection_notify->timestamp;
925 event->owner_change.selection_time = selection_notify->selection_timestamp;
932 if (xevent->type - display_x11->xrandr_event_base == RRScreenChangeNotify ||
933 xevent->type - display_x11->xrandr_event_base == RRNotify)
936 _gdk_x11_screen_size_changed (screen, xevent);
940 #if defined(HAVE_XCOMPOSITE) && defined (HAVE_XDAMAGE) && defined (HAVE_XFIXES)
941 if (display_x11->have_xdamage && window && window->composited &&
942 xevent->type == display_x11->xdamage_event_base + XDamageNotify &&
943 ((XDamageNotifyEvent *) xevent)->damage == window_impl->damage)
945 XDamageNotifyEvent *damage_event = (XDamageNotifyEvent *) xevent;
946 XserverRegion repair;
949 rect.x = window->x + damage_event->area.x;
950 rect.y = window->y + damage_event->area.y;
951 rect.width = damage_event->area.width;
952 rect.height = damage_event->area.height;
954 repair = XFixesCreateRegion (display_x11->xdisplay,
955 &damage_event->area, 1);
956 XDamageSubtract (display_x11->xdisplay,
959 XFixesDestroyRegion (display_x11->xdisplay, repair);
961 if (window->parent != NULL)
962 _gdk_window_process_expose (window->parent,
963 damage_event->serial, &rect);
970 if (xevent->type == display_x11->xkb_event_type)
972 XkbEvent *xkb_event = (XkbEvent *) xevent;
974 switch (xkb_event->any.xkb_type)
976 case XkbNewKeyboardNotify:
978 _gdk_keymap_keys_changed (display);
984 _gdk_keymap_state_changed (display, xevent);
996 if (event->any.window)
997 g_object_ref (event->any.window);
1001 /* Mark this event as having no resources to be freed */
1002 event->any.window = NULL;
1003 event->any.type = GDK_NOTHING;
1007 g_object_unref (window);
1012 static GdkFilterReturn
1013 gdk_wm_protocols_filter (GdkXEvent *xev,
1017 XEvent *xevent = (XEvent *)xev;
1018 GdkWindow *win = event->any.window;
1019 GdkDisplay *display;
1023 return GDK_FILTER_REMOVE;
1025 display = GDK_WINDOW_DISPLAY (win);
1026 atom = (Atom)xevent->xclient.data.l[0];
1028 if (atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW"))
1030 /* The delete window request specifies a window
1031 * to delete. We don't actually destroy the
1032 * window because "it is only a request". (The
1033 * window might contain vital data that the
1034 * program does not want destroyed). Instead
1035 * the event is passed along to the program,
1036 * which should then destroy the window.
1039 g_message ("delete window:\t\twindow: %ld",
1040 xevent->xclient.window));
1042 event->any.type = GDK_DELETE;
1044 gdk_x11_window_set_user_time (win, xevent->xclient.data.l[1]);
1046 return GDK_FILTER_TRANSLATE;
1048 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS"))
1050 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (event->any.window);
1052 /* There is no way of knowing reliably whether we are viewable;
1053 * _gdk_x11_set_input_focus_safe() traps errors asynchronously.
1055 if (toplevel && win->accept_focus)
1056 _gdk_x11_set_input_focus_safe (display, toplevel->focus_window,
1058 xevent->xclient.data.l[1]);
1060 return GDK_FILTER_REMOVE;
1062 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PING") &&
1063 !_gdk_x11_display_is_root_window (display,
1064 xevent->xclient.window))
1066 XClientMessageEvent xclient = xevent->xclient;
1068 xclient.window = GDK_WINDOW_XROOTWIN (win);
1069 XSendEvent (GDK_WINDOW_XDISPLAY (win),
1072 SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&xclient);
1074 return GDK_FILTER_REMOVE;
1076 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_SYNC_REQUEST") &&
1077 GDK_DISPLAY_X11 (display)->use_sync)
1079 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (event->any.window);
1083 XSyncIntsToValue (&toplevel->pending_counter_value,
1084 xevent->xclient.data.l[2],
1085 xevent->xclient.data.l[3]);
1088 return GDK_FILTER_REMOVE;
1091 return GDK_FILTER_CONTINUE;
1095 gdk_event_init (GdkDisplay *display)
1097 GdkDisplayX11 *display_x11;
1098 GdkDeviceManager *device_manager;
1100 display_x11 = GDK_DISPLAY_X11 (display);
1101 display_x11->event_source = gdk_event_source_new (display);
1103 gdk_event_source_add_translator ((GdkEventSource *) display_x11->event_source,
1104 GDK_EVENT_TRANSLATOR (display));
1106 device_manager = gdk_display_get_device_manager (display);
1107 gdk_event_source_add_translator ((GdkEventSource *) display_x11->event_source,
1108 GDK_EVENT_TRANSLATOR (device_manager));
1110 gdk_display_add_client_message_filter (display,
1111 gdk_atom_intern_static_string ("WM_PROTOCOLS"),
1112 gdk_wm_protocols_filter,
1117 gdk_input_init (GdkDisplay *display)
1119 GdkDisplayX11 *display_x11;
1120 GdkDeviceManager *device_manager;
1124 display_x11 = GDK_DISPLAY_X11 (display);
1125 device_manager = gdk_display_get_device_manager (display);
1127 /* For backwards compatibility, just add
1128 * floating devices that are not keyboards.
1130 list = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_FLOATING);
1132 for (l = list; l; l = l->next)
1136 if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
1139 display_x11->input_devices = g_list_prepend (display_x11->input_devices,
1140 g_object_ref (l->data));
1145 /* Now set "core" pointer to the first
1146 * master device that is a pointer.
1148 list = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
1150 for (l = list; l; l = l->next)
1152 device = list->data;
1154 if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
1157 display->core_pointer = device;
1161 /* Add the core pointer to the devices list */
1162 display_x11->input_devices = g_list_prepend (display_x11->input_devices,
1163 g_object_ref (display->core_pointer));
1170 * @display_name: the name of the display to open
1174 * Return value: (transfer none): a #GdkDisplay, or %NULL if the display
1175 * could not be opened.
1180 _gdk_x11_display_open (const gchar *display_name)
1183 GdkDisplay *display;
1184 GdkDisplayX11 *display_x11;
1188 const char *sm_client_id;
1190 XClassHint *class_hint;
1196 xdisplay = XOpenDisplay (display_name);
1200 display = g_object_new (GDK_TYPE_DISPLAY_X11, NULL);
1201 display_x11 = GDK_DISPLAY_X11 (display);
1203 display_x11->xdisplay = xdisplay;
1206 /* Set up handlers for Xlib internal connections */
1207 XAddConnectionWatch (xdisplay, gdk_internal_connection_watch, NULL);
1208 #endif /* HAVE_X11R6 */
1210 _gdk_x11_precache_atoms (display, precache_atoms, G_N_ELEMENTS (precache_atoms));
1212 /* RandR must be initialized before we initialize the screens */
1213 display_x11->have_randr13 = FALSE;
1215 if (XRRQueryExtension (display_x11->xdisplay,
1216 &display_x11->xrandr_event_base, &ignore))
1220 XRRQueryVersion (display_x11->xdisplay, &major, &minor);
1222 if ((major == 1 && minor >= 3) || major > 1)
1223 display_x11->have_randr13 = TRUE;
1225 gdk_x11_register_standard_event_type (display, display_x11->xrandr_event_base, RRNumberEvents);
1229 /* initialize the display's screens */
1230 display_x11->screens = g_new (GdkScreen *, ScreenCount (display_x11->xdisplay));
1231 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1232 display_x11->screens[i] = _gdk_x11_screen_new (display, i);
1234 /* We need to initialize events after we have the screen
1235 * structures in places
1237 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1238 _gdk_screen_x11_events_init (display_x11->screens[i]);
1240 /*set the default screen */
1241 display_x11->default_screen = display_x11->screens[DefaultScreen (display_x11->xdisplay)];
1243 display->device_manager = _gdk_device_manager_new (display);
1245 gdk_event_init (display);
1247 attr.window_type = GDK_WINDOW_TOPLEVEL;
1248 attr.wclass = GDK_INPUT_OUTPUT;
1253 attr.event_mask = 0;
1255 display_x11->leader_gdk_window = gdk_window_new (GDK_SCREEN_X11 (display_x11->default_screen)->root_window,
1256 &attr, GDK_WA_X | GDK_WA_Y);
1257 (_gdk_x11_window_get_toplevel (display_x11->leader_gdk_window))->is_leader = TRUE;
1259 display_x11->leader_window = GDK_WINDOW_XID (display_x11->leader_gdk_window);
1261 display_x11->leader_window_title_set = FALSE;
1264 if (XFixesQueryExtension (display_x11->xdisplay,
1265 &display_x11->xfixes_event_base,
1268 display_x11->have_xfixes = TRUE;
1270 gdk_x11_register_standard_event_type (display,
1271 display_x11->xfixes_event_base,
1272 XFixesNumberEvents);
1276 display_x11->have_xfixes = FALSE;
1278 #ifdef HAVE_XCOMPOSITE
1279 if (XCompositeQueryExtension (display_x11->xdisplay,
1284 XCompositeQueryVersion (display_x11->xdisplay, &major, &minor);
1286 /* Prior to Composite version 0.4, composited windows clipped their
1287 * parents, so you had to use IncludeInferiors to draw to the parent
1288 * This isn't useful for our purposes, so require 0.4
1290 display_x11->have_xcomposite = major > 0 || (major == 0 && minor >= 4);
1294 display_x11->have_xcomposite = FALSE;
1297 if (XDamageQueryExtension (display_x11->xdisplay,
1298 &display_x11->xdamage_event_base,
1301 display_x11->have_xdamage = TRUE;
1303 gdk_x11_register_standard_event_type (display,
1304 display_x11->xdamage_event_base,
1305 XDamageNumberEvents);
1309 display_x11->have_xdamage = FALSE;
1311 display_x11->have_shapes = FALSE;
1312 display_x11->have_input_shapes = FALSE;
1314 if (XShapeQueryExtension (GDK_DISPLAY_XDISPLAY (display), &display_x11->shape_event_base, &ignore))
1316 display_x11->have_shapes = TRUE;
1318 if (XShapeQueryVersion (GDK_DISPLAY_XDISPLAY (display), &maj, &min))
1319 display_x11->have_input_shapes = (maj == 1 && min >= 1);
1323 display_x11->trusted_client = TRUE;
1326 int rootx, rooty, winx, winy;
1329 gdk_error_trap_push ();
1330 XQueryPointer (display_x11->xdisplay,
1331 GDK_SCREEN_X11 (display_x11->default_screen)->xroot_window,
1332 &root, &child, &rootx, &rooty, &winx, &winy, &xmask);
1333 if (G_UNLIKELY (gdk_error_trap_pop () == BadWindow))
1335 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));
1336 display_x11->trusted_client = FALSE;
1340 if (_gdk_synchronize)
1341 XSynchronize (display_x11->xdisplay, True);
1343 class_hint = XAllocClassHint();
1344 class_hint->res_name = g_get_prgname ();
1346 class_hint->res_class = (char *)gdk_get_program_class ();
1348 /* XmbSetWMProperties sets the RESOURCE_NAME environment variable
1349 * from argv[0], so we just synthesize an argument array here.
1352 argv[0] = g_get_prgname ();
1354 XmbSetWMProperties (display_x11->xdisplay,
1355 display_x11->leader_window,
1356 NULL, NULL, argv, argc, NULL, NULL,
1360 sm_client_id = _gdk_get_sm_client_id ();
1362 _gdk_windowing_display_set_sm_client_id (display, sm_client_id);
1365 XChangeProperty (display_x11->xdisplay,
1366 display_x11->leader_window,
1367 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PID"),
1368 XA_CARDINAL, 32, PropModeReplace, (guchar *) & pid, 1);
1370 /* We don't yet know a valid time. */
1371 display_x11->user_time = 0;
1375 gint xkb_major = XkbMajorVersion;
1376 gint xkb_minor = XkbMinorVersion;
1377 if (XkbLibraryVersion (&xkb_major, &xkb_minor))
1379 xkb_major = XkbMajorVersion;
1380 xkb_minor = XkbMinorVersion;
1382 if (XkbQueryExtension (display_x11->xdisplay,
1383 NULL, &display_x11->xkb_event_type, NULL,
1384 &xkb_major, &xkb_minor))
1386 Bool detectable_autorepeat_supported;
1388 display_x11->use_xkb = TRUE;
1390 XkbSelectEvents (display_x11->xdisplay,
1392 XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask,
1393 XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask);
1395 /* keep this in sync with _gdk_keymap_state_changed() */
1396 XkbSelectEventDetails (display_x11->xdisplay,
1397 XkbUseCoreKbd, XkbStateNotify,
1398 XkbAllStateComponentsMask,
1399 XkbGroupLockMask|XkbModifierLockMask);
1401 XkbSetDetectableAutoRepeat (display_x11->xdisplay,
1403 &detectable_autorepeat_supported);
1405 GDK_NOTE (MISC, g_message ("Detectable autorepeat %s.",
1406 detectable_autorepeat_supported ?
1407 "supported" : "not supported"));
1409 display_x11->have_xkb_autorepeat = detectable_autorepeat_supported;
1415 display_x11->use_sync = FALSE;
1419 int error_base, event_base;
1421 if (XSyncQueryExtension (display_x11->xdisplay,
1422 &event_base, &error_base) &&
1423 XSyncInitialize (display_x11->xdisplay,
1425 display_x11->use_sync = TRUE;
1429 gdk_input_init (display);
1430 _gdk_x11_dnd_init (display);
1432 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1433 _gdk_x11_screen_setup (display_x11->screens[i]);
1435 g_signal_emit_by_name (display, "opened");
1436 g_signal_emit_by_name (gdk_display_manager_get (), "display-opened", display);
1443 * XLib internal connection handling
1445 typedef struct _GdkInternalConnection GdkInternalConnection;
1447 struct _GdkInternalConnection
1455 process_internal_connection (GIOChannel *gioc,
1459 GdkInternalConnection *connection = (GdkInternalConnection *)data;
1461 GDK_THREADS_ENTER ();
1463 XProcessInternalConnection ((Display*)connection->display, connection->fd);
1465 GDK_THREADS_LEAVE ();
1471 _gdk_windowing_window_get_next_serial (GdkDisplay *display)
1473 return NextRequest (GDK_DISPLAY_XDISPLAY (display));
1477 static GdkInternalConnection *
1478 gdk_add_connection_handler (Display *display,
1481 GIOChannel *io_channel;
1482 GdkInternalConnection *connection;
1484 connection = g_new (GdkInternalConnection, 1);
1486 connection->fd = fd;
1487 connection->display = display;
1489 io_channel = g_io_channel_unix_new (fd);
1491 connection->source = g_io_create_watch (io_channel, G_IO_IN);
1492 g_source_set_callback (connection->source,
1493 (GSourceFunc)process_internal_connection, connection, NULL);
1494 g_source_attach (connection->source, NULL);
1496 g_io_channel_unref (io_channel);
1502 gdk_remove_connection_handler (GdkInternalConnection *connection)
1504 g_source_destroy (connection->source);
1505 g_free (connection);
1509 gdk_internal_connection_watch (Display *display,
1513 XPointer *watch_data)
1516 *watch_data = (XPointer)gdk_add_connection_handler (display, fd);
1518 gdk_remove_connection_handler ((GdkInternalConnection *)*watch_data);
1520 #endif /* HAVE_X11R6 */
1522 static G_CONST_RETURN gchar *
1523 gdk_x11_display_get_name (GdkDisplay *display)
1525 return (gchar *) DisplayString (GDK_DISPLAY_X11 (display)->xdisplay);
1529 gdk_x11_display_get_n_screens (GdkDisplay *display)
1531 return ScreenCount (GDK_DISPLAY_X11 (display)->xdisplay);
1535 gdk_x11_display_get_screen (GdkDisplay *display,
1538 g_return_val_if_fail (ScreenCount (GDK_DISPLAY_X11 (display)->xdisplay) > screen_num, NULL);
1540 return GDK_DISPLAY_X11 (display)->screens[screen_num];
1544 gdk_x11_display_get_default_screen (GdkDisplay *display)
1546 return GDK_DISPLAY_X11 (display)->default_screen;
1550 _gdk_x11_display_is_root_window (GdkDisplay *display,
1551 Window xroot_window)
1553 GdkDisplayX11 *display_x11;
1556 display_x11 = GDK_DISPLAY_X11 (display);
1558 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1560 if (GDK_SCREEN_XROOTWIN (display_x11->screens[i]) == xroot_window)
1566 struct XPointerUngrabInfo {
1567 GdkDisplay *display;
1571 #define XSERVER_TIME_IS_LATER(time1, time2) \
1572 ( (( time1 > time2 ) && ( time1 - time2 < ((guint32)-1)/2 )) || \
1573 (( time1 < time2 ) && ( time2 - time1 > ((guint32)-1)/2 )) \
1577 _gdk_x11_display_update_grab_info (GdkDisplay *display,
1581 if (status == GrabSuccess)
1582 _gdk_x11_roundtrip_async (display,
1583 (GdkRoundTripCallback)_gdk_display_device_grab_update,
1588 _gdk_x11_display_update_grab_info_ungrab (GdkDisplay *display,
1593 GdkDeviceGrabInfo *grab;
1595 XFlush (GDK_DISPLAY_XDISPLAY (display));
1597 grab = _gdk_display_get_last_device_grab (display, device);
1599 (time == GDK_CURRENT_TIME ||
1600 grab->time == GDK_CURRENT_TIME ||
1601 !XSERVER_TIME_IS_LATER (grab->time, time)))
1603 grab->serial_end = serial;
1604 _gdk_x11_roundtrip_async (display,
1605 (GdkRoundTripCallback)_gdk_display_device_grab_update,
1611 gdk_x11_display_beep (GdkDisplay *display)
1614 XkbBell (GDK_DISPLAY_XDISPLAY (display), None, 0, None);
1616 XBell (GDK_DISPLAY_XDISPLAY (display), 0);
1621 gdk_x11_display_sync (GdkDisplay *display)
1623 XSync (GDK_DISPLAY_XDISPLAY (display), False);
1627 gdk_x11_display_flush (GdkDisplay *display)
1629 if (!display->closed)
1630 XFlush (GDK_DISPLAY_XDISPLAY (display));
1634 gdk_x11_display_has_pending (GdkDisplay *display)
1636 return XPending (GDK_DISPLAY_XDISPLAY (display));
1640 gdk_x11_display_get_default_group (GdkDisplay *display)
1642 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1644 return GDK_DISPLAY_X11 (display)->leader_gdk_window;
1648 * gdk_x11_display_grab:
1649 * @display: a #GdkDisplay
1651 * Call XGrabServer() on @display.
1652 * To ungrab the display again, use gdk_x11_display_ungrab().
1654 * gdk_x11_display_grab()/gdk_x11_display_ungrab() calls can be nested.
1659 gdk_x11_display_grab (GdkDisplay *display)
1661 GdkDisplayX11 *display_x11;
1663 g_return_if_fail (GDK_IS_DISPLAY (display));
1665 display_x11 = GDK_DISPLAY_X11 (display);
1667 if (display_x11->grab_count == 0)
1668 XGrabServer (display_x11->xdisplay);
1669 display_x11->grab_count++;
1673 * gdk_x11_display_ungrab:
1674 * @display: a #GdkDisplay
1676 * Ungrab @display after it has been grabbed with
1677 * gdk_x11_display_grab().
1682 gdk_x11_display_ungrab (GdkDisplay *display)
1684 GdkDisplayX11 *display_x11;
1686 g_return_if_fail (GDK_IS_DISPLAY (display));
1688 display_x11 = GDK_DISPLAY_X11 (display);;
1689 g_return_if_fail (display_x11->grab_count > 0);
1691 display_x11->grab_count--;
1692 if (display_x11->grab_count == 0)
1694 XUngrabServer (display_x11->xdisplay);
1695 XFlush (display_x11->xdisplay);
1700 gdk_display_x11_dispose (GObject *object)
1702 GdkDisplay *display = GDK_DISPLAY_OBJECT (object);
1703 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (object);
1706 _gdk_x11_display_manager_remove_display (gdk_display_manager_get (), display);
1708 g_list_foreach (display_x11->input_devices, (GFunc) g_object_run_dispose, NULL);
1710 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1711 _gdk_screen_close (display_x11->screens[i]);
1713 if (display_x11->event_source)
1715 g_source_destroy (display_x11->event_source);
1716 g_source_unref (display_x11->event_source);
1717 display_x11->event_source = NULL;
1720 G_OBJECT_CLASS (_gdk_display_x11_parent_class)->dispose (object);
1724 gdk_display_x11_finalize (GObject *object)
1726 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (object);
1730 if (display_x11->keymap)
1731 g_object_unref (display_x11->keymap);
1733 /* Free motif Dnd */
1734 if (display_x11->motif_target_lists)
1736 for (i = 0; i < display_x11->motif_n_target_lists; i++)
1737 g_list_free (display_x11->motif_target_lists[i]);
1738 g_free (display_x11->motif_target_lists);
1741 _gdk_x11_cursor_display_finalize (GDK_DISPLAY_OBJECT(display_x11));
1743 /* Atom Hashtable */
1744 g_hash_table_destroy (display_x11->atom_from_virtual);
1745 g_hash_table_destroy (display_x11->atom_to_virtual);
1748 XDestroyWindow (display_x11->xdisplay, display_x11->leader_window);
1750 /* list of filters for client messages */
1751 g_list_foreach (display_x11->client_filters, (GFunc) g_free, NULL);
1752 g_list_free (display_x11->client_filters);
1754 /* List of event window extraction functions */
1755 g_slist_foreach (display_x11->event_types, (GFunc)g_free, NULL);
1756 g_slist_free (display_x11->event_types);
1758 /* input GdkDevice list */
1759 g_list_foreach (display_x11->input_devices, (GFunc) g_object_unref, NULL);
1760 g_list_free (display_x11->input_devices);
1762 /* input GdkWindow list */
1763 g_list_foreach (display_x11->input_windows, (GFunc) g_free, NULL);
1764 g_list_free (display_x11->input_windows);
1766 /* Free all GdkScreens */
1767 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1768 g_object_unref (display_x11->screens[i]);
1769 g_free (display_x11->screens);
1771 g_free (display_x11->startup_notification_id);
1773 /* X ID hashtable */
1774 g_hash_table_destroy (display_x11->xid_ht);
1776 XCloseDisplay (display_x11->xdisplay);
1779 while (display_x11->error_traps != NULL)
1781 GdkErrorTrap *trap = display_x11->error_traps->data;
1783 display_x11->error_traps =
1784 g_slist_delete_link (display_x11->error_traps,
1785 display_x11->error_traps);
1787 if (trap->end_sequence == 0)
1788 g_warning ("Display finalized with an unpopped error trap");
1790 g_slice_free (GdkErrorTrap, trap);
1793 G_OBJECT_CLASS (_gdk_display_x11_parent_class)->finalize (object);
1797 * gdk_x11_lookup_xdisplay:
1798 * @xdisplay: a pointer to an X Display
1800 * Find the #GdkDisplay corresponding to @display, if any exists.
1802 * Return value: (transfer none): the #GdkDisplay, if found, otherwise %NULL.
1807 gdk_x11_lookup_xdisplay (Display *xdisplay)
1810 GdkDisplay *display;
1814 list = gdk_display_manager_list_displays (gdk_display_manager_get ());
1816 for (l = list; l; l = l->next)
1818 if (GDK_DISPLAY_XDISPLAY (l->data) == xdisplay)
1825 g_slist_free (list);
1831 * _gdk_x11_display_screen_for_xrootwin:
1832 * @display: a #GdkDisplay
1833 * @xrootwin: window ID for one of of the screen's of the display.
1835 * Given the root window ID of one of the screen's of a #GdkDisplay,
1838 * Return value: the #GdkScreen corresponding to @xrootwin, or %NULL.
1841 _gdk_x11_display_screen_for_xrootwin (GdkDisplay *display,
1846 for (i = 0; i < ScreenCount (GDK_DISPLAY_X11 (display)->xdisplay); i++)
1848 GdkScreen *screen = gdk_display_get_screen (display, i);
1849 if (GDK_SCREEN_XROOTWIN (screen) == xrootwin)
1857 * gdk_x11_display_get_xdisplay:
1858 * @display: a #GdkDisplay
1859 * @returns: an X display.
1861 * Returns the X display of a #GdkDisplay.
1866 gdk_x11_display_get_xdisplay (GdkDisplay *display)
1868 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1869 return GDK_DISPLAY_X11 (display)->xdisplay;
1873 _gdk_x11_display_make_default (GdkDisplay *display)
1875 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
1876 const gchar *startup_id;
1878 g_free (display_x11->startup_notification_id);
1879 display_x11->startup_notification_id = NULL;
1881 startup_id = g_getenv ("DESKTOP_STARTUP_ID");
1882 if (startup_id && *startup_id != '\0')
1884 if (!g_utf8_validate (startup_id, -1, NULL))
1885 g_warning ("DESKTOP_STARTUP_ID contains invalid UTF-8");
1887 gdk_x11_display_set_startup_notification_id (display, startup_id);
1889 /* Clear the environment variable so it won't be inherited by
1890 * child processes and confuse things.
1892 g_unsetenv ("DESKTOP_STARTUP_ID");
1897 broadcast_xmessage (GdkDisplay *display,
1898 const char *message_type,
1899 const char *message_type_begin,
1900 const char *message)
1902 Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
1903 GdkScreen *screen = gdk_display_get_default_screen (display);
1904 GdkWindow *root_window = gdk_screen_get_root_window (screen);
1905 Window xroot_window = GDK_WINDOW_XID (root_window);
1908 Atom type_atom_begin;
1911 if (!G_LIKELY (GDK_DISPLAY_X11 (display)->trusted_client))
1915 XSetWindowAttributes attrs;
1917 attrs.override_redirect = True;
1918 attrs.event_mask = PropertyChangeMask | StructureNotifyMask;
1921 XCreateWindow (xdisplay,
1927 (Visual *)CopyFromParent,
1928 CWOverrideRedirect | CWEventMask,
1932 type_atom = gdk_x11_get_xatom_by_name_for_display (display,
1934 type_atom_begin = gdk_x11_get_xatom_by_name_for_display (display,
1935 message_type_begin);
1938 XClientMessageEvent xclient;
1940 const char *src_end;
1944 memset(&xclient, 0, sizeof (xclient));
1945 xclient.type = ClientMessage;
1946 xclient.message_type = type_atom_begin;
1947 xclient.display =xdisplay;
1948 xclient.window = xwindow;
1952 src_end = message + strlen (message) + 1; /* +1 to include nul byte */
1954 while (src != src_end)
1956 dest = &xclient.data.b[0];
1957 dest_end = dest + 20;
1959 while (dest != dest_end &&
1967 while (dest != dest_end)
1973 XSendEvent (xdisplay,
1977 (XEvent *)&xclient);
1979 xclient.message_type = type_atom;
1983 XDestroyWindow (xdisplay, xwindow);
1988 * gdk_x11_display_broadcast_startup_message:
1989 * @display: a #GdkDisplay
1990 * @message_type: startup notification message type ("new", "change",
1992 * @...: a list of key/value pairs (as strings), terminated by a
1993 * %NULL key. (A %NULL value for a key will cause that key to be
1994 * skipped in the output.)
1996 * Sends a startup notification message of type @message_type to
1999 * This is a convenience function for use by code that implements the
2000 * freedesktop startup notification specification. Applications should
2001 * not normally need to call it directly. See the <ulink
2002 * url="http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">Startup
2003 * Notification Protocol specification</ulink> for
2004 * definitions of the message types and keys that can be used.
2009 gdk_x11_display_broadcast_startup_message (GdkDisplay *display,
2010 const char *message_type,
2015 const char *key, *value, *p;
2017 message = g_string_new (message_type);
2018 g_string_append_c (message, ':');
2020 va_start (ap, message_type);
2021 while ((key = va_arg (ap, const char *)))
2023 value = va_arg (ap, const char *);
2027 g_string_append_printf (message, " %s=\"", key);
2028 for (p = value; *p; p++)
2035 g_string_append_c (message, '\\');
2039 g_string_append_c (message, *p);
2041 g_string_append_c (message, '\"');
2045 broadcast_xmessage (display,
2046 "_NET_STARTUP_INFO",
2047 "_NET_STARTUP_INFO_BEGIN",
2050 g_string_free (message, TRUE);
2054 * gdk_notify_startup_complete:
2056 * Indicates to the GUI environment that the application has finished
2057 * loading. If the applications opens windows, this function is
2058 * normally called after opening the application's initial set of
2061 * GTK+ will call this function automatically after opening the first
2062 * #GtkWindow unless gtk_window_set_auto_startup_notification() is called
2063 * to disable that feature.
2068 gdk_notify_startup_complete (void)
2070 GdkDisplay *display;
2071 GdkDisplayX11 *display_x11;
2073 display = gdk_display_get_default ();
2077 display_x11 = GDK_DISPLAY_X11 (display);
2079 if (display_x11->startup_notification_id == NULL)
2082 gdk_notify_startup_complete_with_id (display_x11->startup_notification_id);
2086 * gdk_notify_startup_complete_with_id:
2087 * @startup_id: a startup-notification identifier, for which notification
2088 * process should be completed
2090 * Indicates to the GUI environment that the application has finished
2091 * loading, using a given identifier.
2093 * GTK+ will call this function automatically for #GtkWindow with custom
2094 * startup-notification identifier unless
2095 * gtk_window_set_auto_startup_notification() is called to disable
2101 gdk_notify_startup_complete_with_id (const gchar* startup_id)
2103 GdkDisplay *display;
2105 display = gdk_display_get_default ();
2109 gdk_x11_display_broadcast_startup_message (display, "remove",
2115 gdk_x11_display_supports_selection_notification (GdkDisplay *display)
2117 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
2119 return display_x11->have_xfixes;
2123 gdk_x11_display_request_selection_notification (GdkDisplay *display,
2128 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
2131 if (display_x11->have_xfixes)
2133 atom = gdk_x11_atom_to_xatom_for_display (display,
2135 XFixesSelectSelectionInput (display_x11->xdisplay,
2136 display_x11->leader_window,
2138 XFixesSetSelectionOwnerNotifyMask |
2139 XFixesSelectionWindowDestroyNotifyMask |
2140 XFixesSelectionClientCloseNotifyMask);
2149 gdk_x11_display_supports_clipboard_persistence (GdkDisplay *display)
2151 Atom clipboard_manager;
2153 /* It might make sense to cache this */
2154 clipboard_manager = gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER");
2155 return XGetSelectionOwner (GDK_DISPLAY_X11 (display)->xdisplay, clipboard_manager) != None;
2159 gdk_x11_display_store_clipboard (GdkDisplay *display,
2160 GdkWindow *clipboard_window,
2162 const GdkAtom *targets,
2165 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
2166 Atom clipboard_manager, save_targets;
2168 g_return_if_fail (GDK_WINDOW_IS_X11 (clipboard_window));
2170 clipboard_manager = gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER");
2171 save_targets = gdk_x11_get_xatom_by_name_for_display (display, "SAVE_TARGETS");
2173 gdk_error_trap_push ();
2175 if (XGetSelectionOwner (display_x11->xdisplay, clipboard_manager) != None)
2177 Atom property_name = None;
2183 property_name = gdk_x11_atom_to_xatom_for_display (display, _gdk_selection_property);
2185 xatoms = g_new (Atom, n_targets);
2186 for (i = 0; i < n_targets; i++)
2187 xatoms[i] = gdk_x11_atom_to_xatom_for_display (display, targets[i]);
2189 XChangeProperty (display_x11->xdisplay, GDK_WINDOW_XID (clipboard_window),
2190 property_name, XA_ATOM,
2191 32, PropModeReplace, (guchar *)xatoms, n_targets);
2196 XConvertSelection (display_x11->xdisplay,
2197 clipboard_manager, save_targets, property_name,
2198 GDK_WINDOW_XID (clipboard_window), time_);
2201 gdk_error_trap_pop_ignored ();
2206 * gdk_x11_display_get_user_time:
2207 * @display: a #GdkDisplay
2209 * Returns the timestamp of the last user interaction on
2210 * @display. The timestamp is taken from events caused
2211 * by user interaction such as key presses or pointer
2212 * movements. See gdk_x11_window_set_user_time().
2214 * Returns: the timestamp of the last user interaction
2219 gdk_x11_display_get_user_time (GdkDisplay *display)
2221 return GDK_DISPLAY_X11 (display)->user_time;
2225 gdk_x11_display_supports_shapes (GdkDisplay *display)
2227 return GDK_DISPLAY_X11 (display)->have_shapes;
2231 gdk_x11_display_supports_input_shapes (GdkDisplay *display)
2233 return GDK_DISPLAY_X11 (display)->have_input_shapes;
2238 * gdk_x11_display_get_startup_notification_id:
2239 * @display: a #GdkDisplay
2241 * Gets the startup notification ID for a display.
2243 * Returns: the startup notification ID for @display
2247 G_CONST_RETURN gchar *
2248 gdk_x11_display_get_startup_notification_id (GdkDisplay *display)
2250 return GDK_DISPLAY_X11 (display)->startup_notification_id;
2254 * gdk_x11_display_set_startup_notification_id:
2255 * @display: a #GdkDisplay
2256 * @startup_id: the startup notification ID (must be valid utf8)
2258 * Sets the startup notification ID for a display.
2260 * This is usually taken from the value of the DESKTOP_STARTUP_ID
2261 * environment variable, but in some cases (such as the application not
2262 * being launched using exec()) it can come from other sources.
2264 * If the ID contains the string "_TIME" then the portion following that
2265 * string is taken to be the X11 timestamp of the event that triggered
2266 * the application to be launched and the GDK current event time is set
2269 * The startup ID is also what is used to signal that the startup is
2270 * complete (for example, when opening a window or when calling
2271 * gdk_notify_startup_complete()).
2276 gdk_x11_display_set_startup_notification_id (GdkDisplay *display,
2277 const gchar *startup_id)
2279 GdkDisplayX11 *display_x11;
2282 display_x11 = GDK_DISPLAY_X11 (display);
2284 g_free (display_x11->startup_notification_id);
2285 display_x11->startup_notification_id = g_strdup (startup_id);
2287 /* Find the launch time from the startup_id, if it's there. Newer spec
2288 * states that the startup_id is of the form <unique>_TIME<timestamp>
2290 time_str = g_strrstr (startup_id, "_TIME");
2291 if (time_str != NULL)
2297 /* Skip past the "_TIME" part */
2300 retval = strtoul (time_str, &end, 0);
2301 if (end != time_str && errno == 0)
2302 display_x11->user_time = retval;
2305 /* Set the startup id on the leader window so it
2306 * applies to all windows we create on this display
2308 XChangeProperty (display_x11->xdisplay,
2309 display_x11->leader_window,
2310 gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"),
2311 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
2313 (guchar *)startup_id, strlen (startup_id));
2317 gdk_x11_display_supports_composite (GdkDisplay *display)
2319 GdkDisplayX11 *x11_display = GDK_DISPLAY_X11 (display);
2321 return x11_display->have_xcomposite &&
2322 x11_display->have_xdamage &&
2323 x11_display->have_xfixes;
2327 gdk_x11_display_list_devices (GdkDisplay *display)
2329 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
2331 return GDK_DISPLAY_X11 (display)->input_devices;
2335 gdk_x11_display_send_client_message (GdkDisplay *display,
2337 GdkNativeWindow winid)
2341 g_return_val_if_fail(event != NULL, FALSE);
2343 /* Set up our event to send, with the exception of its target window */
2344 sev.xclient.type = ClientMessage;
2345 sev.xclient.display = GDK_DISPLAY_XDISPLAY (display);
2346 sev.xclient.format = event->client.data_format;
2347 sev.xclient.window = winid;
2348 memcpy(&sev.xclient.data, &event->client.data, sizeof (sev.xclient.data));
2349 sev.xclient.message_type = gdk_x11_atom_to_xatom_for_display (display, event->client.message_type);
2351 return _gdk_send_xevent (display, winid, False, NoEventMask, &sev);
2355 gdk_x11_display_add_client_message_filter (GdkDisplay *display,
2356 GdkAtom message_type,
2360 GdkClientFilter *filter;
2361 g_return_if_fail (GDK_IS_DISPLAY (display));
2362 filter = g_new (GdkClientFilter, 1);
2364 filter->type = message_type;
2365 filter->function = func;
2366 filter->data = data;
2368 GDK_DISPLAY_X11(display)->client_filters =
2369 g_list_append (GDK_DISPLAY_X11 (display)->client_filters,
2374 * gdk_x11_register_standard_event_type:
2375 * @display: a #GdkDisplay
2376 * @event_base: first event type code to register
2377 * @n_events: number of event type codes to register
2379 * Registers interest in receiving extension events with type codes
2380 * between @event_base and <literal>event_base + n_events - 1</literal>.
2381 * The registered events must have the window field in the same place
2382 * as core X events (this is not the case for e.g. XKB extension events).
2384 * If an event type is registered, events of this type will go through
2385 * global and window-specific filters (see gdk_window_add_filter()).
2386 * Unregistered events will only go through global filters.
2387 * GDK may register the events of some X extensions on its own.
2389 * This function should only be needed in unusual circumstances, e.g.
2390 * when filtering XInput extension events on the root window.
2395 gdk_x11_register_standard_event_type (GdkDisplay *display,
2399 GdkEventTypeX11 *event_type;
2400 GdkDisplayX11 *display_x11;
2402 display_x11 = GDK_DISPLAY_X11 (display);
2403 event_type = g_new (GdkEventTypeX11, 1);
2405 event_type->base = event_base;
2406 event_type->n_events = n_events;
2408 display_x11->event_types = g_slist_prepend (display_x11->event_types, event_type);
2411 /* compare X sequence numbers handling wraparound */
2412 #define SEQUENCE_COMPARE(a,op,b) (((long) (a) - (long) (b)) op 0)
2414 /* delivers an error event from the error handler in gdkmain-x11.c */
2416 _gdk_x11_display_error_event (GdkDisplay *display,
2419 GdkDisplayX11 *display_x11;
2423 display_x11 = GDK_DISPLAY_X11 (display);
2426 for (tmp_list = display_x11->error_traps;
2428 tmp_list = tmp_list->next)
2432 trap = tmp_list->data;
2434 if (SEQUENCE_COMPARE (trap->start_sequence, <=, error->serial) &&
2435 (trap->end_sequence == 0 ||
2436 SEQUENCE_COMPARE (trap->end_sequence, >, error->serial)))
2439 trap->error_code = error->error_code;
2440 break; /* only innermost trap gets the error code */
2449 XGetErrorText (display_x11->xdisplay, error->error_code, buf, 63);
2452 g_strdup_printf ("The program '%s' received an X Window System error.\n"
2453 "This probably reflects a bug in the program.\n"
2454 "The error was '%s'.\n"
2455 " (Details: serial %ld error_code %d request_code %d minor_code %d)\n"
2456 " (Note to programmers: normally, X errors are reported asynchronously;\n"
2457 " that is, you will receive the error a while after causing it.\n"
2458 " To debug your program, run it with the --sync command line\n"
2459 " option to change this behavior. You can then get a meaningful\n"
2460 " backtrace from your debugger if you break on the gdk_x_error() function.)",
2465 error->request_code,
2468 #ifdef G_ENABLE_DEBUG
2469 g_error ("%s", msg);
2470 #else /* !G_ENABLE_DEBUG */
2471 g_warning ("%s\n", msg);
2474 #endif /* G_ENABLE_DEBUG */
2479 delete_outdated_error_traps (GdkDisplayX11 *display_x11)
2482 gulong processed_sequence;
2484 processed_sequence = XLastKnownRequestProcessed (display_x11->xdisplay);
2486 tmp_list = display_x11->error_traps;
2487 while (tmp_list != NULL)
2489 GdkErrorTrap *trap = tmp_list->data;
2491 if (trap->end_sequence != 0 &&
2492 SEQUENCE_COMPARE (trap->end_sequence, <=, processed_sequence))
2494 GSList *free_me = tmp_list;
2496 tmp_list = tmp_list->next;
2497 display_x11->error_traps =
2498 g_slist_delete_link (display_x11->error_traps, free_me);
2499 g_slice_free (GdkErrorTrap, trap);
2503 tmp_list = tmp_list->next;
2509 * gdk_x11_display_error_trap_push:
2510 * @display: a #GdkDisplay
2512 * Begins a range of X requests on @display for which X error events
2513 * will be ignored. Unignored errors (when no trap is pushed) will abort
2514 * the application. Use gdk_x11_display_error_trap_pop() or
2515 * gdk_x11_display_error_trap_pop_ignored()to lift a trap pushed
2516 * with this function.
2518 * See also gdk_error_trap_push() to push a trap on all displays.
2523 gdk_x11_display_error_trap_push (GdkDisplay *display)
2525 GdkDisplayX11 *display_x11;
2528 display_x11 = GDK_DISPLAY_X11 (display);
2530 delete_outdated_error_traps (display_x11);
2532 /* set up the Xlib callback to tell us about errors */
2533 _gdk_x11_error_handler_push ();
2535 trap = g_slice_new0 (GdkErrorTrap);
2537 trap->start_sequence = XNextRequest (display_x11->xdisplay);
2538 trap->error_code = Success;
2540 display_x11->error_traps =
2541 g_slist_prepend (display_x11->error_traps, trap);
2545 gdk_x11_display_error_trap_pop_internal (GdkDisplay *display,
2548 GdkDisplayX11 *display_x11;
2553 display_x11 = GDK_DISPLAY_X11 (display);
2555 g_return_val_if_fail (display_x11->error_traps != NULL, Success);
2557 /* Find the first trap that hasn't been popped already */
2558 trap = NULL; /* quiet gcc */
2559 for (tmp_list = display_x11->error_traps;
2561 tmp_list = tmp_list->next)
2563 trap = tmp_list->data;
2565 if (trap->end_sequence == 0)
2569 g_return_val_if_fail (trap != NULL, Success);
2570 g_assert (trap->end_sequence == 0);
2572 /* May need to sync to fill in trap->error_code if we care about
2573 * getting an error code.
2577 gulong processed_sequence;
2578 gulong next_sequence;
2580 next_sequence = XNextRequest (display_x11->xdisplay);
2581 processed_sequence = XLastKnownRequestProcessed (display_x11->xdisplay);
2583 /* If our last request was already processed, there is no point
2584 * in syncing. i.e. if last request was a round trip (or even if
2585 * we got an event with the serial of a non-round-trip)
2587 if ((next_sequence - 1) != processed_sequence)
2589 XSync (display_x11->xdisplay, False);
2592 result = trap->error_code;
2599 /* record end of trap, giving us a range of
2600 * error sequences we'll ignore.
2602 trap->end_sequence = XNextRequest (display_x11->xdisplay);
2604 /* remove the Xlib callback */
2605 _gdk_x11_error_handler_pop ();
2607 /* we may already be outdated */
2608 delete_outdated_error_traps (display_x11);
2614 * gdk_x11_display_error_trap_pop:
2615 * @display: the display
2617 * Pops the error trap pushed by gdk_x11_display_error_trap_push().
2618 * Will XSync() if necessary and will always block until
2619 * the error is known to have occurred or not occurred,
2620 * so the error code can be returned.
2622 * If you don't need to use the return value,
2623 * gdk_x11_display_error_trap_pop_ignored() would be more efficient.
2625 * See gdk_error_trap_pop() for the all-displays-at-once
2630 * Return value: X error code or 0 on success
2633 gdk_x11_display_error_trap_pop (GdkDisplay *display)
2635 g_return_val_if_fail (GDK_IS_DISPLAY_X11 (display), Success);
2637 return gdk_x11_display_error_trap_pop_internal (display, TRUE);
2641 * gdk_x11_display_error_trap_pop_ignored:
2642 * @display: the display
2644 * Pops the error trap pushed by gdk_x11_display_error_trap_push().
2645 * Does not block to see if an error occurred; merely records the
2646 * range of requests to ignore errors for, and ignores those errors
2647 * if they arrive asynchronously.
2649 * See gdk_error_trap_pop_ignored() for the all-displays-at-once
2655 gdk_x11_display_error_trap_pop_ignored (GdkDisplay *display)
2657 g_return_if_fail (GDK_IS_DISPLAY_X11 (display));
2659 gdk_x11_display_error_trap_pop_internal (display, FALSE);
2662 extern GdkAppLaunchContext *_gdk_x11_display_get_app_launch_context (GdkDisplay *display);
2663 extern GdkNativeWindow _gdk_x11_display_get_drag_protocol (GdkDisplay *display,
2664 GdkNativeWindow xid,
2665 GdkDragProtocol *protocol,
2669 _gdk_display_x11_class_init (GdkDisplayX11Class * class)
2671 GObjectClass *object_class = G_OBJECT_CLASS (class);
2672 GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (class);
2674 object_class->dispose = gdk_display_x11_dispose;
2675 object_class->finalize = gdk_display_x11_finalize;
2677 display_class->get_name = gdk_x11_display_get_name;
2678 display_class->get_n_screens = gdk_x11_display_get_n_screens;
2679 display_class->get_screen = gdk_x11_display_get_screen;
2680 display_class->get_default_screen = gdk_x11_display_get_default_screen;
2681 display_class->beep = gdk_x11_display_beep;
2682 display_class->sync = gdk_x11_display_sync;
2683 display_class->flush = gdk_x11_display_flush;
2684 display_class->has_pending = gdk_x11_display_has_pending;
2685 display_class->queue_events = _gdk_x11_display_queue_events;
2686 display_class->get_default_group = gdk_x11_display_get_default_group;
2687 display_class->supports_selection_notification = gdk_x11_display_supports_selection_notification;
2688 display_class->request_selection_notification = gdk_x11_display_request_selection_notification;
2689 display_class->supports_clipboard_persistence = gdk_x11_display_supports_clipboard_persistence;
2690 display_class->store_clipboard = gdk_x11_display_store_clipboard;
2691 display_class->supports_shapes = gdk_x11_display_supports_shapes;
2692 display_class->supports_input_shapes = gdk_x11_display_supports_input_shapes;
2693 display_class->supports_composite = gdk_x11_display_supports_composite;
2694 display_class->list_devices = gdk_x11_display_list_devices;
2695 display_class->send_client_message = gdk_x11_display_send_client_message;
2696 display_class->add_client_message_filter = gdk_x11_display_add_client_message_filter;
2697 display_class->get_app_launch_context = _gdk_x11_display_get_app_launch_context;
2698 display_class->get_drag_protocol = _gdk_x11_display_get_drag_protocol;
2699 display_class->get_cursor_for_type = _gdk_x11_display_get_cursor_for_type;
2700 display_class->get_cursor_for_name = _gdk_x11_display_get_cursor_for_name;
2701 display_class->get_cursor_for_pixbuf = _gdk_x11_display_get_cursor_for_pixbuf;
2702 display_class->get_default_cursor_size = _gdk_x11_display_get_default_cursor_size;
2703 display_class->get_maximal_cursor_size = _gdk_x11_display_get_maximal_cursor_size;
2704 display_class->supports_cursor_alpha = _gdk_x11_display_supports_cursor_alpha;
2705 display_class->supports_cursor_color = _gdk_x11_display_supports_cursor_color;
2707 display_class->before_process_all_updates = _gdk_x11_display_before_process_all_updates;
2708 display_class->after_process_all_updates = _gdk_x11_display_after_process_all_updates;