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",
161 static char *gdk_sm_client_id;
163 G_DEFINE_TYPE_WITH_CODE (GdkX11Display, gdk_x11_display, GDK_TYPE_DISPLAY,
164 G_IMPLEMENT_INTERFACE (GDK_TYPE_EVENT_TRANSLATOR,
165 gdk_x11_display_event_translator_init))
169 gdk_x11_display_init (GdkX11Display *display)
171 _gdk_x11_display_manager_add_display (gdk_display_manager_get (),
172 GDK_DISPLAY (display));
176 gdk_x11_display_event_translator_init (GdkEventTranslatorIface *iface)
178 iface->translate_event = gdk_x11_display_translate_event;
182 do_net_wm_state_changes (GdkWindow *window)
184 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
185 GdkWindowState old_state;
187 if (GDK_WINDOW_DESTROYED (window) ||
188 gdk_window_get_window_type (window) != GDK_WINDOW_TOPLEVEL)
191 old_state = gdk_window_get_state (window);
193 /* For found_sticky to remain TRUE, we have to also be on desktop
196 if (old_state & GDK_WINDOW_STATE_STICKY)
198 if (!(toplevel->have_sticky && toplevel->on_all_desktops))
199 gdk_synthesize_window_state (window,
200 GDK_WINDOW_STATE_STICKY,
205 if (toplevel->have_sticky || toplevel->on_all_desktops)
206 gdk_synthesize_window_state (window,
208 GDK_WINDOW_STATE_STICKY);
211 if (old_state & GDK_WINDOW_STATE_FULLSCREEN)
213 if (!toplevel->have_fullscreen)
214 gdk_synthesize_window_state (window,
215 GDK_WINDOW_STATE_FULLSCREEN,
220 if (toplevel->have_fullscreen)
221 gdk_synthesize_window_state (window,
223 GDK_WINDOW_STATE_FULLSCREEN);
226 /* Our "maximized" means both vertical and horizontal; if only one,
227 * we don't expose that via GDK
229 if (old_state & GDK_WINDOW_STATE_MAXIMIZED)
231 if (!(toplevel->have_maxvert && toplevel->have_maxhorz))
232 gdk_synthesize_window_state (window,
233 GDK_WINDOW_STATE_MAXIMIZED,
238 if (toplevel->have_maxvert && toplevel->have_maxhorz)
239 gdk_synthesize_window_state (window,
241 GDK_WINDOW_STATE_MAXIMIZED);
246 gdk_check_wm_desktop_changed (GdkWindow *window)
248 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
249 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
259 gdk_x11_display_error_trap_push (display);
260 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
261 GDK_WINDOW_XID (window),
262 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
263 0, G_MAXLONG, False, XA_CARDINAL, &type,
265 &bytes_after, &data);
266 gdk_x11_display_error_trap_pop_ignored (display);
270 desktop = (gulong *)data;
271 toplevel->on_all_desktops = (*desktop == 0xFFFFFFFF);
275 toplevel->on_all_desktops = FALSE;
277 do_net_wm_state_changes (window);
281 gdk_check_wm_state_changed (GdkWindow *window)
283 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
284 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
294 gboolean had_sticky = toplevel->have_sticky;
296 toplevel->have_sticky = FALSE;
297 toplevel->have_maxvert = FALSE;
298 toplevel->have_maxhorz = FALSE;
299 toplevel->have_fullscreen = FALSE;
302 gdk_x11_display_error_trap_push (display);
303 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
304 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"),
305 0, G_MAXLONG, False, XA_ATOM, &type, &format, &nitems,
306 &bytes_after, &data);
307 gdk_x11_display_error_trap_pop_ignored (display);
311 Atom sticky_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_STICKY");
312 Atom maxvert_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_MAXIMIZED_VERT");
313 Atom maxhorz_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_MAXIMIZED_HORZ");
314 Atom fullscreen_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_FULLSCREEN");
316 atoms = (Atom *)data;
321 if (atoms[i] == sticky_atom)
322 toplevel->have_sticky = TRUE;
323 else if (atoms[i] == maxvert_atom)
324 toplevel->have_maxvert = TRUE;
325 else if (atoms[i] == maxhorz_atom)
326 toplevel->have_maxhorz = TRUE;
327 else if (atoms[i] == fullscreen_atom)
328 toplevel->have_fullscreen = TRUE;
336 /* When have_sticky is turned on, we have to check the DESKTOP property
339 if (toplevel->have_sticky && !had_sticky)
340 gdk_check_wm_desktop_changed (window);
342 do_net_wm_state_changes (window);
346 get_event_window (GdkEventTranslator *translator,
352 display = (GdkDisplay *) translator;
354 switch (xevent->type)
357 xwindow = xevent->xdestroywindow.window;
360 xwindow = xevent->xunmap.window;
363 xwindow = xevent->xmap.window;
365 case ConfigureNotify:
366 xwindow = xevent->xconfigure.window;
369 xwindow = xevent->xany.window;
372 return gdk_x11_window_lookup_for_display (display, xwindow);
376 gdk_x11_display_translate_event (GdkEventTranslator *translator,
382 GdkWindowImplX11 *window_impl = NULL;
383 GdkScreen *screen = NULL;
384 GdkX11Screen *x11_screen = NULL;
385 GdkToplevelX11 *toplevel = NULL;
386 GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
388 Window xwindow = None;
390 /* Find the GdkWindow that this event relates to.
391 * Basically this means substructure events
392 * are reported same as structure events
394 window = get_event_window (translator, xevent);
398 /* We may receive events such as NoExpose/GraphicsExpose
399 * and ShmCompletion for pixmaps
401 if (!GDK_IS_WINDOW (window))
404 screen = GDK_WINDOW_SCREEN (window);
405 x11_screen = GDK_X11_SCREEN (screen);
406 toplevel = _gdk_x11_window_get_toplevel (window);
407 window_impl = GDK_WINDOW_IMPL_X11 (window->impl);
408 xwindow = GDK_WINDOW_XID (window);
410 g_object_ref (window);
413 event->any.window = window;
414 event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
416 if (window && GDK_WINDOW_DESTROYED (window))
418 if (xevent->type != DestroyNotify)
425 if (xevent->type == DestroyNotify)
429 n = gdk_display_get_n_screens (display);
430 for (i = 0; i < n; i++)
432 screen = gdk_display_get_screen (display, i);
433 x11_screen = GDK_X11_SCREEN (screen);
435 if (x11_screen->wmspec_check_window == xwindow)
437 x11_screen->wmspec_check_window = None;
438 x11_screen->last_wmspec_check_time = 0;
439 g_free (x11_screen->window_manager_name);
440 x11_screen->window_manager_name = g_strdup ("unknown");
442 /* careful, reentrancy */
443 _gdk_x11_screen_window_manager_changed (screen);
451 /* We do a "manual" conversion of the XEvent to a
452 * GdkEvent. The structures are mostly the same so
453 * the conversion is fairly straightforward. We also
454 * optionally print debugging info regarding events
460 switch (xevent->type)
464 g_message ("keymap notify"));
466 /* Not currently handled */
472 g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d%s",
473 xevent->xexpose.window, xevent->xexpose.count,
474 xevent->xexpose.x, xevent->xexpose.y,
475 xevent->xexpose.width, xevent->xexpose.height,
476 event->any.send_event ? " (send)" : ""));
485 GdkRectangle expose_rect;
487 expose_rect.x = xevent->xexpose.x;
488 expose_rect.y = xevent->xexpose.y;
489 expose_rect.width = xevent->xexpose.width;
490 expose_rect.height = xevent->xexpose.height;
492 _gdk_x11_window_process_expose (window, xevent->xexpose.serial, &expose_rect);
500 GdkRectangle expose_rect;
503 g_message ("graphics expose:\tdrawable: %ld",
504 xevent->xgraphicsexpose.drawable));
512 expose_rect.x = xevent->xgraphicsexpose.x;
513 expose_rect.y = xevent->xgraphicsexpose.y;
514 expose_rect.width = xevent->xgraphicsexpose.width;
515 expose_rect.height = xevent->xgraphicsexpose.height;
517 _gdk_x11_window_process_expose (window, xevent->xgraphicsexpose.serial, &expose_rect);
522 case VisibilityNotify:
523 #ifdef G_ENABLE_DEBUG
524 if (_gdk_debug_flags & GDK_DEBUG_EVENTS)
525 switch (xevent->xvisibility.state)
527 case VisibilityFullyObscured:
528 g_message ("visibility notify:\twindow: %ld none",
529 xevent->xvisibility.window);
531 case VisibilityPartiallyObscured:
532 g_message ("visibility notify:\twindow: %ld partial",
533 xevent->xvisibility.window);
535 case VisibilityUnobscured:
536 g_message ("visibility notify:\twindow: %ld full",
537 xevent->xvisibility.window);
540 #endif /* G_ENABLE_DEBUG */
548 event->visibility.type = GDK_VISIBILITY_NOTIFY;
549 event->visibility.window = window;
551 switch (xevent->xvisibility.state)
553 case VisibilityFullyObscured:
554 event->visibility.state = GDK_VISIBILITY_FULLY_OBSCURED;
557 case VisibilityPartiallyObscured:
558 event->visibility.state = GDK_VISIBILITY_PARTIAL;
561 case VisibilityUnobscured:
562 event->visibility.state = GDK_VISIBILITY_UNOBSCURED;
570 g_message ("create notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d parent: %ld ovr: %d",
571 xevent->xcreatewindow.window,
572 xevent->xcreatewindow.x,
573 xevent->xcreatewindow.y,
574 xevent->xcreatewindow.width,
575 xevent->xcreatewindow.height,
576 xevent->xcreatewindow.border_width,
577 xevent->xcreatewindow.parent,
578 xevent->xcreatewindow.override_redirect));
579 /* not really handled */
584 g_message ("destroy notify:\twindow: %ld",
585 xevent->xdestroywindow.window));
587 /* Ignore DestroyNotify from SubstructureNotifyMask */
588 if (xevent->xdestroywindow.window == xevent->xdestroywindow.event)
590 event->any.type = GDK_DESTROY;
591 event->any.window = window;
593 return_val = window && !GDK_WINDOW_DESTROYED (window);
595 if (window && GDK_WINDOW_XID (window) != x11_screen->xroot_window)
596 gdk_window_destroy_notify (window);
605 g_message ("unmap notify:\t\twindow: %ld",
606 xevent->xmap.window));
608 event->any.type = GDK_UNMAP;
609 event->any.window = window;
611 /* If we are shown (not withdrawn) and get an unmap, it means we
612 * were iconified in the X sense. If we are withdrawn, and get
613 * an unmap, it means we hid the window ourselves, so we
614 * will have already flipped the iconified bit off.
618 if (GDK_WINDOW_IS_MAPPED (window))
619 gdk_synthesize_window_state (window,
621 GDK_WINDOW_STATE_ICONIFIED);
623 _gdk_x11_window_grab_check_unmap (window, xevent->xany.serial);
630 g_message ("map notify:\t\twindow: %ld",
631 xevent->xmap.window));
633 event->any.type = GDK_MAP;
634 event->any.window = window;
636 /* Unset iconified if it was set */
637 if (window && (window->state & GDK_WINDOW_STATE_ICONIFIED))
638 gdk_synthesize_window_state (window,
639 GDK_WINDOW_STATE_ICONIFIED,
646 g_message ("reparent notify:\twindow: %ld x,y: %d %d parent: %ld ovr: %d",
647 xevent->xreparent.window,
650 xevent->xreparent.parent,
651 xevent->xreparent.override_redirect));
653 /* Not currently handled */
657 case ConfigureNotify:
659 g_message ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d%s",
660 xevent->xconfigure.window,
661 xevent->xconfigure.x,
662 xevent->xconfigure.y,
663 xevent->xconfigure.width,
664 xevent->xconfigure.height,
665 xevent->xconfigure.border_width,
666 xevent->xconfigure.above,
667 xevent->xconfigure.override_redirect,
670 : window->window_type == GDK_WINDOW_CHILD
671 ? " (discarding child)"
672 : xevent->xconfigure.event != xevent->xconfigure.window
673 ? " (discarding substructure)"
675 if (window && GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
677 window->width = xevent->xconfigure.width;
678 window->height = xevent->xconfigure.height;
680 _gdk_window_update_size (window);
681 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
682 _gdk_x11_screen_size_changed (screen, xevent);
686 if (toplevel && display_x11->use_sync && !XSyncValueIsZero (toplevel->pending_counter_value))
688 toplevel->current_counter_value = toplevel->pending_counter_value;
689 XSyncIntToValue (&toplevel->pending_counter_value, 0);
694 xevent->xconfigure.event != xevent->xconfigure.window ||
695 GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD ||
696 GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
700 event->configure.type = GDK_CONFIGURE;
701 event->configure.window = window;
702 event->configure.width = xevent->xconfigure.width;
703 event->configure.height = xevent->xconfigure.height;
705 if (!xevent->xconfigure.send_event &&
706 !xevent->xconfigure.override_redirect &&
707 !GDK_WINDOW_DESTROYED (window))
711 Window child_window = 0;
713 gdk_x11_display_error_trap_push (display);
714 if (XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
715 GDK_WINDOW_XID (window),
716 x11_screen->xroot_window,
721 event->configure.x = tx;
722 event->configure.y = ty;
724 gdk_x11_display_error_trap_pop_ignored (display);
728 event->configure.x = xevent->xconfigure.x;
729 event->configure.y = xevent->xconfigure.y;
731 window->x = event->configure.x;
732 window->y = event->configure.y;
733 window->width = xevent->xconfigure.width;
734 window->height = xevent->xconfigure.height;
736 _gdk_window_update_size (window);
737 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
739 if (window->resize_count >= 1)
741 window->resize_count -= 1;
743 if (window->resize_count == 0)
744 _gdk_x11_moveresize_configure_done (display, window);
751 g_message ("property notify:\twindow: %ld, atom(%ld): %s%s%s",
752 xevent->xproperty.window,
753 xevent->xproperty.atom,
755 gdk_x11_get_xatom_name_for_display (display, xevent->xproperty.atom),
764 /* We compare with the serial of the last time we mapped the
765 * window to avoid refetching properties that we set ourselves
768 xevent->xproperty.serial >= toplevel->map_serial)
770 if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"))
771 gdk_check_wm_state_changed (window);
773 if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"))
774 gdk_check_wm_desktop_changed (window);
777 if (window->event_mask & GDK_PROPERTY_CHANGE_MASK)
779 event->property.type = GDK_PROPERTY_NOTIFY;
780 event->property.window = window;
781 event->property.atom = gdk_x11_xatom_to_atom_for_display (display, xevent->xproperty.atom);
782 event->property.time = xevent->xproperty.time;
783 event->property.state = xevent->xproperty.state;
792 g_message ("selection clear:\twindow: %ld",
793 xevent->xproperty.window));
795 if (_gdk_x11_selection_filter_clear_event (&xevent->xselectionclear))
797 event->selection.type = GDK_SELECTION_CLEAR;
798 event->selection.window = window;
799 event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionclear.selection);
800 event->selection.time = xevent->xselectionclear.time;
807 case SelectionRequest:
809 g_message ("selection request:\twindow: %ld",
810 xevent->xproperty.window));
812 event->selection.type = GDK_SELECTION_REQUEST;
813 event->selection.window = window;
814 event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.selection);
815 event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.target);
816 event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.property);
817 if (xevent->xselectionrequest.requestor != None)
818 event->selection.requestor = gdk_x11_window_foreign_new_for_display (display,
819 xevent->xselectionrequest.requestor);
821 event->selection.requestor = NULL;
822 event->selection.time = xevent->xselectionrequest.time;
826 case SelectionNotify:
828 g_message ("selection notify:\twindow: %ld",
829 xevent->xproperty.window));
831 event->selection.type = GDK_SELECTION_NOTIFY;
832 event->selection.window = window;
833 event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.selection);
834 event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.target);
835 if (xevent->xselection.property == None)
836 event->selection.property = GDK_NONE;
838 event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.property);
839 event->selection.time = xevent->xselection.time;
845 g_message ("colormap notify:\twindow: %ld",
846 xevent->xcolormap.window));
848 /* Not currently handled */
854 g_message ("client message:\twindow: %ld",
855 xevent->xclient.window));
857 /* Not currently handled */
863 g_message ("mapping notify"));
865 /* Let XLib know that there is a new keyboard mapping.
867 XRefreshKeyboardMapping (&xevent->xmapping);
868 _gdk_x11_keymap_keys_changed (display);
874 if (xevent->type - display_x11->xfixes_event_base == XFixesSelectionNotify)
876 XFixesSelectionNotifyEvent *selection_notify = (XFixesSelectionNotifyEvent *)xevent;
878 _gdk_x11_screen_process_owner_change (screen, xevent);
880 event->owner_change.type = GDK_OWNER_CHANGE;
881 event->owner_change.window = window;
882 if (selection_notify->owner != None)
883 event->owner_change.owner = gdk_x11_window_foreign_new_for_display (display,
884 selection_notify->owner);
886 event->owner_change.owner = NULL;
887 event->owner_change.reason = selection_notify->subtype;
888 event->owner_change.selection =
889 gdk_x11_xatom_to_atom_for_display (display,
890 selection_notify->selection);
891 event->owner_change.time = selection_notify->timestamp;
892 event->owner_change.selection_time = selection_notify->selection_timestamp;
899 if (xevent->type - display_x11->xrandr_event_base == RRScreenChangeNotify ||
900 xevent->type - display_x11->xrandr_event_base == RRNotify)
903 _gdk_x11_screen_size_changed (screen, xevent);
907 #if defined(HAVE_XCOMPOSITE) && defined (HAVE_XDAMAGE) && defined (HAVE_XFIXES)
908 if (display_x11->have_xdamage && window && window->composited &&
909 xevent->type == display_x11->xdamage_event_base + XDamageNotify &&
910 ((XDamageNotifyEvent *) xevent)->damage == window_impl->damage)
912 XDamageNotifyEvent *damage_event = (XDamageNotifyEvent *) xevent;
913 XserverRegion repair;
916 rect.x = window->x + damage_event->area.x;
917 rect.y = window->y + damage_event->area.y;
918 rect.width = damage_event->area.width;
919 rect.height = damage_event->area.height;
921 repair = XFixesCreateRegion (display_x11->xdisplay,
922 &damage_event->area, 1);
923 XDamageSubtract (display_x11->xdisplay,
926 XFixesDestroyRegion (display_x11->xdisplay, repair);
928 if (window->parent != NULL)
929 _gdk_x11_window_process_expose (window->parent,
930 damage_event->serial, &rect);
937 if (xevent->type == display_x11->xkb_event_type)
939 XkbEvent *xkb_event = (XkbEvent *) xevent;
941 switch (xkb_event->any.xkb_type)
943 case XkbNewKeyboardNotify:
945 _gdk_x11_keymap_keys_changed (display);
951 _gdk_x11_keymap_state_changed (display, xevent);
963 if (event->any.window)
964 g_object_ref (event->any.window);
968 /* Mark this event as having no resources to be freed */
969 event->any.window = NULL;
970 event->any.type = GDK_NOTHING;
974 g_object_unref (window);
980 _gdk_wm_protocols_filter (GdkXEvent *xev,
984 XEvent *xevent = (XEvent *)xev;
985 GdkWindow *win = event->any.window;
989 if (!GDK_IS_X11_WINDOW (win))
990 return GDK_FILTER_CONTINUE;
992 if (xevent->type != ClientMessage)
993 return GDK_FILTER_CONTINUE;
995 display = GDK_WINDOW_DISPLAY (win);
997 if (xevent->xclient.message_type != gdk_x11_get_xatom_by_name_for_display (display, "WM_PROTOCOLS"))
998 return GDK_FILTER_CONTINUE;
1000 atom = (Atom) xevent->xclient.data.l[0];
1002 if (atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW"))
1004 /* The delete window request specifies a window
1005 * to delete. We don't actually destroy the
1006 * window because "it is only a request". (The
1007 * window might contain vital data that the
1008 * program does not want destroyed). Instead
1009 * the event is passed along to the program,
1010 * which should then destroy the window.
1013 g_message ("delete window:\t\twindow: %ld",
1014 xevent->xclient.window));
1016 event->any.type = GDK_DELETE;
1018 gdk_x11_window_set_user_time (win, xevent->xclient.data.l[1]);
1020 return GDK_FILTER_TRANSLATE;
1022 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS"))
1024 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (event->any.window);
1026 /* There is no way of knowing reliably whether we are viewable;
1027 * _gdk_x11_set_input_focus_safe() traps errors asynchronously.
1029 if (toplevel && win->accept_focus)
1030 _gdk_x11_set_input_focus_safe (display, toplevel->focus_window,
1032 xevent->xclient.data.l[1]);
1034 return GDK_FILTER_REMOVE;
1036 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PING") &&
1037 !_gdk_x11_display_is_root_window (display,
1038 xevent->xclient.window))
1040 XClientMessageEvent xclient = xevent->xclient;
1042 xclient.window = GDK_WINDOW_XROOTWIN (win);
1043 XSendEvent (GDK_WINDOW_XDISPLAY (win),
1046 SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&xclient);
1048 return GDK_FILTER_REMOVE;
1050 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_SYNC_REQUEST") &&
1051 GDK_X11_DISPLAY (display)->use_sync)
1053 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (event->any.window);
1057 XSyncIntsToValue (&toplevel->pending_counter_value,
1058 xevent->xclient.data.l[2],
1059 xevent->xclient.data.l[3]);
1062 return GDK_FILTER_REMOVE;
1065 return GDK_FILTER_CONTINUE;
1069 gdk_event_init (GdkDisplay *display)
1071 GdkX11Display *display_x11;
1072 GdkDeviceManager *device_manager;
1074 display_x11 = GDK_X11_DISPLAY (display);
1075 display_x11->event_source = gdk_x11_event_source_new (display);
1077 gdk_x11_event_source_add_translator ((GdkEventSource *) display_x11->event_source,
1078 GDK_EVENT_TRANSLATOR (display));
1080 device_manager = gdk_display_get_device_manager (display);
1081 gdk_x11_event_source_add_translator ((GdkEventSource *) display_x11->event_source,
1082 GDK_EVENT_TRANSLATOR (device_manager));
1086 gdk_x11_display_init_input (GdkDisplay *display)
1088 GdkX11Display *display_x11;
1089 GdkDeviceManager *device_manager;
1093 display_x11 = GDK_X11_DISPLAY (display);
1094 device_manager = gdk_display_get_device_manager (display);
1096 /* For backwards compatibility, just add
1097 * floating devices that are not keyboards.
1099 list = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_FLOATING);
1101 for (l = list; l; l = l->next)
1105 if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
1108 display_x11->input_devices = g_list_prepend (display_x11->input_devices,
1109 g_object_ref (l->data));
1114 /* Now set "core" pointer to the first
1115 * master device that is a pointer.
1117 list = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
1119 for (l = list; l; l = l->next)
1123 if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
1126 display->core_pointer = device;
1130 /* Add the core pointer to the devices list */
1131 display_x11->input_devices = g_list_prepend (display_x11->input_devices,
1132 g_object_ref (display->core_pointer));
1138 set_sm_client_id (GdkDisplay *display,
1139 const gchar *sm_client_id)
1141 GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
1143 if (gdk_display_is_closed (display))
1146 if (sm_client_id && strcmp (sm_client_id, ""))
1147 XChangeProperty (display_x11->xdisplay, display_x11->leader_window,
1148 gdk_x11_get_xatom_by_name_for_display (display, "SM_CLIENT_ID"),
1149 XA_STRING, 8, PropModeReplace, (guchar *)sm_client_id,
1150 strlen (sm_client_id));
1152 XDeleteProperty (display_x11->xdisplay, display_x11->leader_window,
1153 gdk_x11_get_xatom_by_name_for_display (display, "SM_CLIENT_ID"));
1157 _gdk_x11_display_open (const gchar *display_name)
1160 GdkDisplay *display;
1161 GdkX11Display *display_x11;
1166 XClassHint *class_hint;
1172 xdisplay = XOpenDisplay (display_name);
1176 display = g_object_new (GDK_TYPE_X11_DISPLAY, NULL);
1177 display_x11 = GDK_X11_DISPLAY (display);
1179 display_x11->xdisplay = xdisplay;
1182 /* Set up handlers for Xlib internal connections */
1183 XAddConnectionWatch (xdisplay, gdk_internal_connection_watch, NULL);
1184 #endif /* HAVE_X11R6 */
1186 _gdk_x11_precache_atoms (display, precache_atoms, G_N_ELEMENTS (precache_atoms));
1188 /* RandR must be initialized before we initialize the screens */
1189 display_x11->have_randr12 = FALSE;
1190 display_x11->have_randr13 = FALSE;
1192 if (XRRQueryExtension (display_x11->xdisplay,
1193 &display_x11->xrandr_event_base, &ignore))
1197 XRRQueryVersion (display_x11->xdisplay, &major, &minor);
1199 if ((major == 1 && minor >= 2) || major > 1) {
1200 display_x11->have_randr12 = TRUE;
1201 if (minor >= 3 || major > 1)
1202 display_x11->have_randr13 = TRUE;
1205 gdk_x11_register_standard_event_type (display, display_x11->xrandr_event_base, RRNumberEvents);
1209 /* initialize the display's screens */
1210 display_x11->screens = g_new (GdkScreen *, ScreenCount (display_x11->xdisplay));
1211 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1212 display_x11->screens[i] = _gdk_x11_screen_new (display, i);
1214 /* We need to initialize events after we have the screen
1215 * structures in places
1217 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1218 _gdk_x11_screen_init_events (display_x11->screens[i]);
1220 /*set the default screen */
1221 display_x11->default_screen = display_x11->screens[DefaultScreen (display_x11->xdisplay)];
1223 display->device_manager = _gdk_x11_device_manager_new (display);
1225 gdk_event_init (display);
1227 attr.window_type = GDK_WINDOW_TOPLEVEL;
1228 attr.wclass = GDK_INPUT_OUTPUT;
1233 attr.event_mask = 0;
1235 display_x11->leader_gdk_window = gdk_window_new (GDK_X11_SCREEN (display_x11->default_screen)->root_window,
1236 &attr, GDK_WA_X | GDK_WA_Y);
1237 (_gdk_x11_window_get_toplevel (display_x11->leader_gdk_window))->is_leader = TRUE;
1239 display_x11->leader_window = GDK_WINDOW_XID (display_x11->leader_gdk_window);
1241 display_x11->leader_window_title_set = FALSE;
1244 if (XFixesQueryExtension (display_x11->xdisplay,
1245 &display_x11->xfixes_event_base,
1248 display_x11->have_xfixes = TRUE;
1250 gdk_x11_register_standard_event_type (display,
1251 display_x11->xfixes_event_base,
1252 XFixesNumberEvents);
1256 display_x11->have_xfixes = FALSE;
1258 #ifdef HAVE_XCOMPOSITE
1259 if (XCompositeQueryExtension (display_x11->xdisplay,
1264 XCompositeQueryVersion (display_x11->xdisplay, &major, &minor);
1266 /* Prior to Composite version 0.4, composited windows clipped their
1267 * parents, so you had to use IncludeInferiors to draw to the parent
1268 * This isn't useful for our purposes, so require 0.4
1270 display_x11->have_xcomposite = major > 0 || (major == 0 && minor >= 4);
1274 display_x11->have_xcomposite = FALSE;
1277 if (XDamageQueryExtension (display_x11->xdisplay,
1278 &display_x11->xdamage_event_base,
1281 display_x11->have_xdamage = TRUE;
1283 gdk_x11_register_standard_event_type (display,
1284 display_x11->xdamage_event_base,
1285 XDamageNumberEvents);
1289 display_x11->have_xdamage = FALSE;
1291 display_x11->have_shapes = FALSE;
1292 display_x11->have_input_shapes = FALSE;
1294 if (XShapeQueryExtension (GDK_DISPLAY_XDISPLAY (display), &display_x11->shape_event_base, &ignore))
1296 display_x11->have_shapes = TRUE;
1298 if (XShapeQueryVersion (GDK_DISPLAY_XDISPLAY (display), &maj, &min))
1299 display_x11->have_input_shapes = (maj == 1 && min >= 1);
1303 display_x11->trusted_client = TRUE;
1306 int rootx, rooty, winx, winy;
1309 gdk_x11_display_error_trap_push (display);
1310 XQueryPointer (display_x11->xdisplay,
1311 GDK_X11_SCREEN (display_x11->default_screen)->xroot_window,
1312 &root, &child, &rootx, &rooty, &winx, &winy, &xmask);
1313 if (G_UNLIKELY (gdk_x11_display_error_trap_pop (display) == BadWindow))
1315 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));
1316 display_x11->trusted_client = FALSE;
1320 if (g_getenv ("GDK_SYNCHRONIZE"))
1321 XSynchronize (display_x11->xdisplay, True);
1323 class_hint = XAllocClassHint();
1324 class_hint->res_name = g_get_prgname ();
1326 class_hint->res_class = (char *)gdk_get_program_class ();
1328 /* XmbSetWMProperties sets the RESOURCE_NAME environment variable
1329 * from argv[0], so we just synthesize an argument array here.
1332 argv[0] = g_get_prgname ();
1334 XmbSetWMProperties (display_x11->xdisplay,
1335 display_x11->leader_window,
1336 NULL, NULL, argv, argc, NULL, NULL,
1340 if (gdk_sm_client_id)
1341 set_sm_client_id (display, gdk_sm_client_id);
1344 XChangeProperty (display_x11->xdisplay,
1345 display_x11->leader_window,
1346 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PID"),
1347 XA_CARDINAL, 32, PropModeReplace, (guchar *) & pid, 1);
1349 /* We don't yet know a valid time. */
1350 display_x11->user_time = 0;
1354 gint xkb_major = XkbMajorVersion;
1355 gint xkb_minor = XkbMinorVersion;
1356 if (XkbLibraryVersion (&xkb_major, &xkb_minor))
1358 xkb_major = XkbMajorVersion;
1359 xkb_minor = XkbMinorVersion;
1361 if (XkbQueryExtension (display_x11->xdisplay,
1362 NULL, &display_x11->xkb_event_type, NULL,
1363 &xkb_major, &xkb_minor))
1365 Bool detectable_autorepeat_supported;
1367 display_x11->use_xkb = TRUE;
1369 XkbSelectEvents (display_x11->xdisplay,
1371 XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask,
1372 XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask);
1374 /* keep this in sync with _gdk_x11_keymap_state_changed() */
1375 XkbSelectEventDetails (display_x11->xdisplay,
1376 XkbUseCoreKbd, XkbStateNotify,
1377 XkbAllStateComponentsMask,
1378 XkbGroupLockMask|XkbModifierLockMask);
1380 XkbSetDetectableAutoRepeat (display_x11->xdisplay,
1382 &detectable_autorepeat_supported);
1384 GDK_NOTE (MISC, g_message ("Detectable autorepeat %s.",
1385 detectable_autorepeat_supported ?
1386 "supported" : "not supported"));
1388 display_x11->have_xkb_autorepeat = detectable_autorepeat_supported;
1394 display_x11->use_sync = FALSE;
1398 int error_base, event_base;
1400 if (XSyncQueryExtension (display_x11->xdisplay,
1401 &event_base, &error_base) &&
1402 XSyncInitialize (display_x11->xdisplay,
1404 display_x11->use_sync = TRUE;
1408 gdk_x11_display_init_input (display);
1410 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1411 _gdk_x11_screen_setup (display_x11->screens[i]);
1413 g_signal_emit_by_name (display, "opened");
1414 g_signal_emit_by_name (gdk_display_manager_get (), "display-opened", display);
1421 * XLib internal connection handling
1423 typedef struct _GdkInternalConnection GdkInternalConnection;
1425 struct _GdkInternalConnection
1433 process_internal_connection (GIOChannel *gioc,
1437 GdkInternalConnection *connection = (GdkInternalConnection *)data;
1439 GDK_THREADS_ENTER ();
1441 XProcessInternalConnection ((Display*)connection->display, connection->fd);
1443 GDK_THREADS_LEAVE ();
1449 gdk_x11_display_get_next_serial (GdkDisplay *display)
1451 return NextRequest (GDK_DISPLAY_XDISPLAY (display));
1455 static GdkInternalConnection *
1456 gdk_add_connection_handler (Display *display,
1459 GIOChannel *io_channel;
1460 GdkInternalConnection *connection;
1462 connection = g_new (GdkInternalConnection, 1);
1464 connection->fd = fd;
1465 connection->display = display;
1467 io_channel = g_io_channel_unix_new (fd);
1469 connection->source = g_io_create_watch (io_channel, G_IO_IN);
1470 g_source_set_callback (connection->source,
1471 (GSourceFunc)process_internal_connection, connection, NULL);
1472 g_source_attach (connection->source, NULL);
1474 g_io_channel_unref (io_channel);
1480 gdk_remove_connection_handler (GdkInternalConnection *connection)
1482 g_source_destroy (connection->source);
1483 g_free (connection);
1487 gdk_internal_connection_watch (Display *display,
1491 XPointer *watch_data)
1494 *watch_data = (XPointer)gdk_add_connection_handler (display, fd);
1496 gdk_remove_connection_handler ((GdkInternalConnection *)*watch_data);
1498 #endif /* HAVE_X11R6 */
1500 static G_CONST_RETURN gchar *
1501 gdk_x11_display_get_name (GdkDisplay *display)
1503 return (gchar *) DisplayString (GDK_X11_DISPLAY (display)->xdisplay);
1507 gdk_x11_display_get_n_screens (GdkDisplay *display)
1509 return ScreenCount (GDK_X11_DISPLAY (display)->xdisplay);
1513 gdk_x11_display_get_screen (GdkDisplay *display,
1516 g_return_val_if_fail (ScreenCount (GDK_X11_DISPLAY (display)->xdisplay) > screen_num, NULL);
1518 return GDK_X11_DISPLAY (display)->screens[screen_num];
1522 gdk_x11_display_get_default_screen (GdkDisplay *display)
1524 return GDK_X11_DISPLAY (display)->default_screen;
1528 _gdk_x11_display_is_root_window (GdkDisplay *display,
1529 Window xroot_window)
1531 GdkX11Display *display_x11;
1534 display_x11 = GDK_X11_DISPLAY (display);
1536 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1538 if (GDK_SCREEN_XROOTWIN (display_x11->screens[i]) == xroot_window)
1544 struct XPointerUngrabInfo {
1545 GdkDisplay *display;
1550 device_grab_update_callback (GdkDisplay *display,
1554 GdkDevice *device = data;
1556 _gdk_display_device_grab_update (display, device, NULL, serial);
1559 #define XSERVER_TIME_IS_LATER(time1, time2) \
1560 ( (( time1 > time2 ) && ( time1 - time2 < ((guint32)-1)/2 )) || \
1561 (( time1 < time2 ) && ( time2 - time1 > ((guint32)-1)/2 )) \
1565 _gdk_x11_display_update_grab_info (GdkDisplay *display,
1569 if (status == GrabSuccess)
1570 _gdk_x11_roundtrip_async (display, device_grab_update_callback, device);
1574 _gdk_x11_display_update_grab_info_ungrab (GdkDisplay *display,
1579 GdkDeviceGrabInfo *grab;
1581 XFlush (GDK_DISPLAY_XDISPLAY (display));
1583 grab = _gdk_display_get_last_device_grab (display, device);
1585 (time == GDK_CURRENT_TIME ||
1586 grab->time == GDK_CURRENT_TIME ||
1587 !XSERVER_TIME_IS_LATER (grab->time, time)))
1589 grab->serial_end = serial;
1590 _gdk_x11_roundtrip_async (display, device_grab_update_callback, device);
1595 gdk_x11_display_beep (GdkDisplay *display)
1598 XkbBell (GDK_DISPLAY_XDISPLAY (display), None, 0, None);
1600 XBell (GDK_DISPLAY_XDISPLAY (display), 0);
1605 gdk_x11_display_sync (GdkDisplay *display)
1607 XSync (GDK_DISPLAY_XDISPLAY (display), False);
1611 gdk_x11_display_flush (GdkDisplay *display)
1613 if (!display->closed)
1614 XFlush (GDK_DISPLAY_XDISPLAY (display));
1618 gdk_x11_display_has_pending (GdkDisplay *display)
1620 return XPending (GDK_DISPLAY_XDISPLAY (display));
1624 gdk_x11_display_get_default_group (GdkDisplay *display)
1626 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1628 return GDK_X11_DISPLAY (display)->leader_gdk_window;
1632 * gdk_x11_display_grab:
1633 * @display: a #GdkDisplay
1635 * Call XGrabServer() on @display.
1636 * To ungrab the display again, use gdk_x11_display_ungrab().
1638 * gdk_x11_display_grab()/gdk_x11_display_ungrab() calls can be nested.
1643 gdk_x11_display_grab (GdkDisplay *display)
1645 GdkX11Display *display_x11;
1647 g_return_if_fail (GDK_IS_DISPLAY (display));
1649 display_x11 = GDK_X11_DISPLAY (display);
1651 if (display_x11->grab_count == 0)
1652 XGrabServer (display_x11->xdisplay);
1653 display_x11->grab_count++;
1657 * gdk_x11_display_ungrab:
1658 * @display: a #GdkDisplay
1660 * Ungrab @display after it has been grabbed with
1661 * gdk_x11_display_grab().
1666 gdk_x11_display_ungrab (GdkDisplay *display)
1668 GdkX11Display *display_x11;
1670 g_return_if_fail (GDK_IS_DISPLAY (display));
1672 display_x11 = GDK_X11_DISPLAY (display);;
1673 g_return_if_fail (display_x11->grab_count > 0);
1675 display_x11->grab_count--;
1676 if (display_x11->grab_count == 0)
1678 XUngrabServer (display_x11->xdisplay);
1679 XFlush (display_x11->xdisplay);
1684 gdk_x11_display_dispose (GObject *object)
1686 GdkDisplay *display = GDK_DISPLAY (object);
1687 GdkX11Display *display_x11 = GDK_X11_DISPLAY (object);
1690 _gdk_x11_display_manager_remove_display (gdk_display_manager_get (), display);
1692 g_list_foreach (display_x11->input_devices, (GFunc) g_object_run_dispose, NULL);
1694 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1695 _gdk_screen_close (display_x11->screens[i]);
1697 if (display_x11->event_source)
1699 g_source_destroy (display_x11->event_source);
1700 g_source_unref (display_x11->event_source);
1701 display_x11->event_source = NULL;
1704 G_OBJECT_CLASS (gdk_x11_display_parent_class)->dispose (object);
1708 gdk_x11_display_finalize (GObject *object)
1710 GdkX11Display *display_x11 = GDK_X11_DISPLAY (object);
1714 if (display_x11->keymap)
1715 g_object_unref (display_x11->keymap);
1717 /* Free motif Dnd */
1718 if (display_x11->motif_target_lists)
1720 for (i = 0; i < display_x11->motif_n_target_lists; i++)
1721 g_list_free (display_x11->motif_target_lists[i]);
1722 g_free (display_x11->motif_target_lists);
1725 _gdk_x11_cursor_display_finalize (GDK_DISPLAY (display_x11));
1727 /* Atom Hashtable */
1728 g_hash_table_destroy (display_x11->atom_from_virtual);
1729 g_hash_table_destroy (display_x11->atom_to_virtual);
1732 XDestroyWindow (display_x11->xdisplay, display_x11->leader_window);
1734 /* List of event window extraction functions */
1735 g_slist_foreach (display_x11->event_types, (GFunc)g_free, NULL);
1736 g_slist_free (display_x11->event_types);
1738 /* input GdkDevice list */
1739 g_list_foreach (display_x11->input_devices, (GFunc) g_object_unref, NULL);
1740 g_list_free (display_x11->input_devices);
1742 /* input GdkWindow list */
1743 g_list_foreach (display_x11->input_windows, (GFunc) g_free, NULL);
1744 g_list_free (display_x11->input_windows);
1746 /* Free all GdkScreens */
1747 for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
1748 g_object_unref (display_x11->screens[i]);
1749 g_free (display_x11->screens);
1751 g_free (display_x11->startup_notification_id);
1753 /* X ID hashtable */
1754 g_hash_table_destroy (display_x11->xid_ht);
1756 XCloseDisplay (display_x11->xdisplay);
1759 while (display_x11->error_traps != NULL)
1761 GdkErrorTrap *trap = display_x11->error_traps->data;
1763 display_x11->error_traps =
1764 g_slist_delete_link (display_x11->error_traps,
1765 display_x11->error_traps);
1767 if (trap->end_sequence == 0)
1768 g_warning ("Display finalized with an unpopped error trap");
1770 g_slice_free (GdkErrorTrap, trap);
1773 G_OBJECT_CLASS (gdk_x11_display_parent_class)->finalize (object);
1777 * gdk_x11_lookup_xdisplay:
1778 * @xdisplay: a pointer to an X Display
1780 * Find the #GdkDisplay corresponding to @display, if any exists.
1782 * Return value: (transfer none): the #GdkDisplay, if found, otherwise %NULL.
1787 gdk_x11_lookup_xdisplay (Display *xdisplay)
1790 GdkDisplay *display;
1794 list = gdk_display_manager_list_displays (gdk_display_manager_get ());
1796 for (l = list; l; l = l->next)
1798 if (GDK_DISPLAY_XDISPLAY (l->data) == xdisplay)
1805 g_slist_free (list);
1811 * _gdk_x11_display_screen_for_xrootwin:
1812 * @display: a #GdkDisplay
1813 * @xrootwin: window ID for one of of the screen's of the display.
1815 * Given the root window ID of one of the screen's of a #GdkDisplay,
1818 * Return value: (transfer none): the #GdkScreen corresponding to
1819 * @xrootwin, or %NULL.
1822 _gdk_x11_display_screen_for_xrootwin (GdkDisplay *display,
1827 for (i = 0; i < ScreenCount (GDK_X11_DISPLAY (display)->xdisplay); i++)
1829 GdkScreen *screen = gdk_display_get_screen (display, i);
1830 if (GDK_SCREEN_XROOTWIN (screen) == xrootwin)
1838 * gdk_x11_display_get_xdisplay: (skip)
1839 * @display: a #GdkDisplay
1840 * @returns: an X display.
1842 * Returns the X display of a #GdkDisplay.
1847 gdk_x11_display_get_xdisplay (GdkDisplay *display)
1849 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
1850 return GDK_X11_DISPLAY (display)->xdisplay;
1854 _gdk_x11_display_make_default (GdkDisplay *display)
1856 GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
1857 const gchar *startup_id;
1859 g_free (display_x11->startup_notification_id);
1860 display_x11->startup_notification_id = NULL;
1862 startup_id = g_getenv ("DESKTOP_STARTUP_ID");
1863 if (startup_id && *startup_id != '\0')
1865 if (!g_utf8_validate (startup_id, -1, NULL))
1866 g_warning ("DESKTOP_STARTUP_ID contains invalid UTF-8");
1868 gdk_x11_display_set_startup_notification_id (display, startup_id);
1870 /* Clear the environment variable so it won't be inherited by
1871 * child processes and confuse things.
1873 g_unsetenv ("DESKTOP_STARTUP_ID");
1878 broadcast_xmessage (GdkDisplay *display,
1879 const char *message_type,
1880 const char *message_type_begin,
1881 const char *message)
1883 Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
1884 GdkScreen *screen = gdk_display_get_default_screen (display);
1885 GdkWindow *root_window = gdk_screen_get_root_window (screen);
1886 Window xroot_window = GDK_WINDOW_XID (root_window);
1889 Atom type_atom_begin;
1892 if (!G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client))
1896 XSetWindowAttributes attrs;
1898 attrs.override_redirect = True;
1899 attrs.event_mask = PropertyChangeMask | StructureNotifyMask;
1902 XCreateWindow (xdisplay,
1908 (Visual *)CopyFromParent,
1909 CWOverrideRedirect | CWEventMask,
1913 type_atom = gdk_x11_get_xatom_by_name_for_display (display,
1915 type_atom_begin = gdk_x11_get_xatom_by_name_for_display (display,
1916 message_type_begin);
1919 XClientMessageEvent xclient;
1921 const char *src_end;
1925 memset(&xclient, 0, sizeof (xclient));
1926 xclient.type = ClientMessage;
1927 xclient.message_type = type_atom_begin;
1928 xclient.display =xdisplay;
1929 xclient.window = xwindow;
1933 src_end = message + strlen (message) + 1; /* +1 to include nul byte */
1935 while (src != src_end)
1937 dest = &xclient.data.b[0];
1938 dest_end = dest + 20;
1940 while (dest != dest_end &&
1948 while (dest != dest_end)
1954 XSendEvent (xdisplay,
1958 (XEvent *)&xclient);
1960 xclient.message_type = type_atom;
1964 XDestroyWindow (xdisplay, xwindow);
1969 * gdk_x11_display_broadcast_startup_message:
1970 * @display: a #GdkDisplay
1971 * @message_type: startup notification message type ("new", "change",
1973 * @...: a list of key/value pairs (as strings), terminated by a
1974 * %NULL key. (A %NULL value for a key will cause that key to be
1975 * skipped in the output.)
1977 * Sends a startup notification message of type @message_type to
1980 * This is a convenience function for use by code that implements the
1981 * freedesktop startup notification specification. Applications should
1982 * not normally need to call it directly. See the <ulink
1983 * url="http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">Startup
1984 * Notification Protocol specification</ulink> for
1985 * definitions of the message types and keys that can be used.
1990 gdk_x11_display_broadcast_startup_message (GdkDisplay *display,
1991 const char *message_type,
1996 const char *key, *value, *p;
1998 message = g_string_new (message_type);
1999 g_string_append_c (message, ':');
2001 va_start (ap, message_type);
2002 while ((key = va_arg (ap, const char *)))
2004 value = va_arg (ap, const char *);
2008 g_string_append_printf (message, " %s=\"", key);
2009 for (p = value; *p; p++)
2016 g_string_append_c (message, '\\');
2020 g_string_append_c (message, *p);
2022 g_string_append_c (message, '\"');
2026 broadcast_xmessage (display,
2027 "_NET_STARTUP_INFO",
2028 "_NET_STARTUP_INFO_BEGIN",
2031 g_string_free (message, TRUE);
2035 gdk_x11_display_notify_startup_complete (GdkDisplay *display,
2036 const gchar *startup_id)
2038 if (startup_id == NULL)
2040 startup_id = GDK_X11_DISPLAY (display)->startup_notification_id;
2041 if (startup_id == NULL)
2045 gdk_x11_display_broadcast_startup_message (display, "remove",
2051 gdk_x11_display_supports_selection_notification (GdkDisplay *display)
2053 GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
2055 return display_x11->have_xfixes;
2059 gdk_x11_display_request_selection_notification (GdkDisplay *display,
2064 GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
2067 if (display_x11->have_xfixes)
2069 atom = gdk_x11_atom_to_xatom_for_display (display,
2071 XFixesSelectSelectionInput (display_x11->xdisplay,
2072 display_x11->leader_window,
2074 XFixesSetSelectionOwnerNotifyMask |
2075 XFixesSelectionWindowDestroyNotifyMask |
2076 XFixesSelectionClientCloseNotifyMask);
2085 gdk_x11_display_supports_clipboard_persistence (GdkDisplay *display)
2087 Atom clipboard_manager;
2089 /* It might make sense to cache this */
2090 clipboard_manager = gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER");
2091 return XGetSelectionOwner (GDK_X11_DISPLAY (display)->xdisplay, clipboard_manager) != None;
2095 gdk_x11_display_store_clipboard (GdkDisplay *display,
2096 GdkWindow *clipboard_window,
2098 const GdkAtom *targets,
2101 GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
2102 Atom clipboard_manager, save_targets;
2104 g_return_if_fail (GDK_WINDOW_IS_X11 (clipboard_window));
2106 clipboard_manager = gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER");
2107 save_targets = gdk_x11_get_xatom_by_name_for_display (display, "SAVE_TARGETS");
2109 gdk_x11_display_error_trap_push (display);
2111 if (XGetSelectionOwner (display_x11->xdisplay, clipboard_manager) != None)
2113 Atom property_name = None;
2119 property_name = gdk_x11_get_xatom_by_name_for_display (display, "GDK_SELECTION");
2121 xatoms = g_new (Atom, n_targets);
2122 for (i = 0; i < n_targets; i++)
2123 xatoms[i] = gdk_x11_atom_to_xatom_for_display (display, targets[i]);
2125 XChangeProperty (display_x11->xdisplay, GDK_WINDOW_XID (clipboard_window),
2126 property_name, XA_ATOM,
2127 32, PropModeReplace, (guchar *)xatoms, n_targets);
2132 XConvertSelection (display_x11->xdisplay,
2133 clipboard_manager, save_targets, property_name,
2134 GDK_WINDOW_XID (clipboard_window), time_);
2137 gdk_x11_display_error_trap_pop_ignored (display);
2142 * gdk_x11_display_get_user_time:
2143 * @display: a #GdkDisplay
2145 * Returns the timestamp of the last user interaction on
2146 * @display. The timestamp is taken from events caused
2147 * by user interaction such as key presses or pointer
2148 * movements. See gdk_x11_window_set_user_time().
2150 * Returns: the timestamp of the last user interaction
2155 gdk_x11_display_get_user_time (GdkDisplay *display)
2157 return GDK_X11_DISPLAY (display)->user_time;
2161 gdk_x11_display_supports_shapes (GdkDisplay *display)
2163 return GDK_X11_DISPLAY (display)->have_shapes;
2167 gdk_x11_display_supports_input_shapes (GdkDisplay *display)
2169 return GDK_X11_DISPLAY (display)->have_input_shapes;
2174 * gdk_x11_display_get_startup_notification_id:
2175 * @display: a #GdkDisplay
2177 * Gets the startup notification ID for a display.
2179 * Returns: the startup notification ID for @display
2183 G_CONST_RETURN gchar *
2184 gdk_x11_display_get_startup_notification_id (GdkDisplay *display)
2186 return GDK_X11_DISPLAY (display)->startup_notification_id;
2190 * gdk_x11_display_set_startup_notification_id:
2191 * @display: a #GdkDisplay
2192 * @startup_id: the startup notification ID (must be valid utf8)
2194 * Sets the startup notification ID for a display.
2196 * This is usually taken from the value of the DESKTOP_STARTUP_ID
2197 * environment variable, but in some cases (such as the application not
2198 * being launched using exec()) it can come from other sources.
2200 * If the ID contains the string "_TIME" then the portion following that
2201 * string is taken to be the X11 timestamp of the event that triggered
2202 * the application to be launched and the GDK current event time is set
2205 * The startup ID is also what is used to signal that the startup is
2206 * complete (for example, when opening a window or when calling
2207 * gdk_notify_startup_complete()).
2212 gdk_x11_display_set_startup_notification_id (GdkDisplay *display,
2213 const gchar *startup_id)
2215 GdkX11Display *display_x11;
2218 display_x11 = GDK_X11_DISPLAY (display);
2220 g_free (display_x11->startup_notification_id);
2221 display_x11->startup_notification_id = g_strdup (startup_id);
2223 /* Find the launch time from the startup_id, if it's there. Newer spec
2224 * states that the startup_id is of the form <unique>_TIME<timestamp>
2226 time_str = g_strrstr (startup_id, "_TIME");
2227 if (time_str != NULL)
2233 /* Skip past the "_TIME" part */
2236 retval = strtoul (time_str, &end, 0);
2237 if (end != time_str && errno == 0)
2238 display_x11->user_time = retval;
2241 /* Set the startup id on the leader window so it
2242 * applies to all windows we create on this display
2244 XChangeProperty (display_x11->xdisplay,
2245 display_x11->leader_window,
2246 gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"),
2247 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
2249 (guchar *)startup_id, strlen (startup_id));
2253 gdk_x11_display_supports_composite (GdkDisplay *display)
2255 GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
2257 return x11_display->have_xcomposite &&
2258 x11_display->have_xdamage &&
2259 x11_display->have_xfixes;
2263 gdk_x11_display_list_devices (GdkDisplay *display)
2265 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
2267 return GDK_X11_DISPLAY (display)->input_devices;
2271 * gdk_x11_register_standard_event_type:
2272 * @display: a #GdkDisplay
2273 * @event_base: first event type code to register
2274 * @n_events: number of event type codes to register
2276 * Registers interest in receiving extension events with type codes
2277 * between @event_base and <literal>event_base + n_events - 1</literal>.
2278 * The registered events must have the window field in the same place
2279 * as core X events (this is not the case for e.g. XKB extension events).
2281 * If an event type is registered, events of this type will go through
2282 * global and window-specific filters (see gdk_window_add_filter()).
2283 * Unregistered events will only go through global filters.
2284 * GDK may register the events of some X extensions on its own.
2286 * This function should only be needed in unusual circumstances, e.g.
2287 * when filtering XInput extension events on the root window.
2292 gdk_x11_register_standard_event_type (GdkDisplay *display,
2296 GdkEventTypeX11 *event_type;
2297 GdkX11Display *display_x11;
2299 display_x11 = GDK_X11_DISPLAY (display);
2300 event_type = g_new (GdkEventTypeX11, 1);
2302 event_type->base = event_base;
2303 event_type->n_events = n_events;
2305 display_x11->event_types = g_slist_prepend (display_x11->event_types, event_type);
2308 /* compare X sequence numbers handling wraparound */
2309 #define SEQUENCE_COMPARE(a,op,b) (((long) (a) - (long) (b)) op 0)
2311 /* delivers an error event from the error handler in gdkmain-x11.c */
2313 _gdk_x11_display_error_event (GdkDisplay *display,
2316 GdkX11Display *display_x11;
2320 display_x11 = GDK_X11_DISPLAY (display);
2323 for (tmp_list = display_x11->error_traps;
2325 tmp_list = tmp_list->next)
2329 trap = tmp_list->data;
2331 if (SEQUENCE_COMPARE (trap->start_sequence, <=, error->serial) &&
2332 (trap->end_sequence == 0 ||
2333 SEQUENCE_COMPARE (trap->end_sequence, >, error->serial)))
2336 trap->error_code = error->error_code;
2337 break; /* only innermost trap gets the error code */
2346 XGetErrorText (display_x11->xdisplay, error->error_code, buf, 63);
2349 g_strdup_printf ("The program '%s' received an X Window System error.\n"
2350 "This probably reflects a bug in the program.\n"
2351 "The error was '%s'.\n"
2352 " (Details: serial %ld error_code %d request_code %d minor_code %d)\n"
2353 " (Note to programmers: normally, X errors are reported asynchronously;\n"
2354 " that is, you will receive the error a while after causing it.\n"
2355 " To debug your program, run it with the --sync command line\n"
2356 " option to change this behavior. You can then get a meaningful\n"
2357 " backtrace from your debugger if you break on the gdk_x_error() function.)",
2362 error->request_code,
2365 #ifdef G_ENABLE_DEBUG
2366 g_error ("%s", msg);
2367 #else /* !G_ENABLE_DEBUG */
2368 g_warning ("%s\n", msg);
2371 #endif /* G_ENABLE_DEBUG */
2376 delete_outdated_error_traps (GdkX11Display *display_x11)
2379 gulong processed_sequence;
2381 processed_sequence = XLastKnownRequestProcessed (display_x11->xdisplay);
2383 tmp_list = display_x11->error_traps;
2384 while (tmp_list != NULL)
2386 GdkErrorTrap *trap = tmp_list->data;
2388 if (trap->end_sequence != 0 &&
2389 SEQUENCE_COMPARE (trap->end_sequence, <=, processed_sequence))
2391 GSList *free_me = tmp_list;
2393 tmp_list = tmp_list->next;
2394 display_x11->error_traps =
2395 g_slist_delete_link (display_x11->error_traps, free_me);
2396 g_slice_free (GdkErrorTrap, trap);
2400 tmp_list = tmp_list->next;
2406 * gdk_x11_display_error_trap_push:
2407 * @display: a #GdkDisplay
2409 * Begins a range of X requests on @display for which X error events
2410 * will be ignored. Unignored errors (when no trap is pushed) will abort
2411 * the application. Use gdk_x11_display_error_trap_pop() or
2412 * gdk_x11_display_error_trap_pop_ignored()to lift a trap pushed
2413 * with this function.
2415 * See also gdk_error_trap_push() to push a trap on all displays.
2420 gdk_x11_display_error_trap_push (GdkDisplay *display)
2422 GdkX11Display *display_x11;
2425 display_x11 = GDK_X11_DISPLAY (display);
2427 delete_outdated_error_traps (display_x11);
2429 /* set up the Xlib callback to tell us about errors */
2430 _gdk_x11_error_handler_push ();
2432 trap = g_slice_new0 (GdkErrorTrap);
2434 trap->start_sequence = XNextRequest (display_x11->xdisplay);
2435 trap->error_code = Success;
2437 display_x11->error_traps =
2438 g_slist_prepend (display_x11->error_traps, trap);
2442 gdk_x11_display_error_trap_pop_internal (GdkDisplay *display,
2445 GdkX11Display *display_x11;
2450 display_x11 = GDK_X11_DISPLAY (display);
2452 g_return_val_if_fail (display_x11->error_traps != NULL, Success);
2454 /* Find the first trap that hasn't been popped already */
2455 trap = NULL; /* quiet gcc */
2456 for (tmp_list = display_x11->error_traps;
2458 tmp_list = tmp_list->next)
2460 trap = tmp_list->data;
2462 if (trap->end_sequence == 0)
2466 g_return_val_if_fail (trap != NULL, Success);
2467 g_assert (trap->end_sequence == 0);
2469 /* May need to sync to fill in trap->error_code if we care about
2470 * getting an error code.
2474 gulong processed_sequence;
2475 gulong next_sequence;
2477 next_sequence = XNextRequest (display_x11->xdisplay);
2478 processed_sequence = XLastKnownRequestProcessed (display_x11->xdisplay);
2480 /* If our last request was already processed, there is no point
2481 * in syncing. i.e. if last request was a round trip (or even if
2482 * we got an event with the serial of a non-round-trip)
2484 if ((next_sequence - 1) != processed_sequence)
2486 XSync (display_x11->xdisplay, False);
2489 result = trap->error_code;
2496 /* record end of trap, giving us a range of
2497 * error sequences we'll ignore.
2499 trap->end_sequence = XNextRequest (display_x11->xdisplay);
2501 /* remove the Xlib callback */
2502 _gdk_x11_error_handler_pop ();
2504 /* we may already be outdated */
2505 delete_outdated_error_traps (display_x11);
2511 * gdk_x11_display_error_trap_pop:
2512 * @display: the display
2514 * Pops the error trap pushed by gdk_x11_display_error_trap_push().
2515 * Will XSync() if necessary and will always block until
2516 * the error is known to have occurred or not occurred,
2517 * so the error code can be returned.
2519 * If you don't need to use the return value,
2520 * gdk_x11_display_error_trap_pop_ignored() would be more efficient.
2522 * See gdk_error_trap_pop() for the all-displays-at-once
2527 * Return value: X error code or 0 on success
2530 gdk_x11_display_error_trap_pop (GdkDisplay *display)
2532 g_return_val_if_fail (GDK_IS_X11_DISPLAY (display), Success);
2534 return gdk_x11_display_error_trap_pop_internal (display, TRUE);
2538 * gdk_x11_display_error_trap_pop_ignored:
2539 * @display: the display
2541 * Pops the error trap pushed by gdk_x11_display_error_trap_push().
2542 * Does not block to see if an error occurred; merely records the
2543 * range of requests to ignore errors for, and ignores those errors
2544 * if they arrive asynchronously.
2546 * See gdk_error_trap_pop_ignored() for the all-displays-at-once
2552 gdk_x11_display_error_trap_pop_ignored (GdkDisplay *display)
2554 g_return_if_fail (GDK_IS_X11_DISPLAY (display));
2556 gdk_x11_display_error_trap_pop_internal (display, FALSE);
2560 * gdk_x11_set_sm_client_id:
2561 * @sm_client_id: the client id assigned by the session manager when the
2562 * connection was opened, or %NULL to remove the property.
2564 * Sets the <literal>SM_CLIENT_ID</literal> property on the application's leader window so that
2565 * the window manager can save the application's state using the X11R6 ICCCM
2566 * session management protocol.
2568 * See the X Session Management Library documentation for more information on
2569 * session management and the Inter-Client Communication Conventions Manual
2574 gdk_x11_set_sm_client_id (const gchar *sm_client_id)
2576 GSList *displays, *l;
2578 g_free (gdk_sm_client_id);
2579 gdk_sm_client_id = g_strdup (sm_client_id);
2581 displays = gdk_display_manager_list_displays (gdk_display_manager_get ());
2582 for (l = displays; l; l = l->next)
2583 set_sm_client_id (l->data, sm_client_id);
2585 g_slist_free (displays);
2589 gdk_x11_display_event_data_copy (GdkDisplay *display,
2590 const GdkEvent *src,
2596 gdk_x11_display_event_data_free (GdkDisplay *display,
2602 pop_error_trap (GdkDisplay *display,
2607 gdk_x11_display_error_trap_pop_ignored (display);
2612 return gdk_x11_display_error_trap_pop (display);
2617 gdk_x11_display_get_keymap (GdkDisplay *display)
2619 GdkX11Display *display_x11;
2620 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
2621 display_x11 = GDK_X11_DISPLAY (display);
2623 if (!display_x11->keymap)
2624 display_x11->keymap = g_object_new (GDK_TYPE_X11_KEYMAP, NULL);
2626 display_x11->keymap->display = display;
2628 return display_x11->keymap;
2632 gdk_x11_display_class_init (GdkX11DisplayClass * class)
2634 GObjectClass *object_class = G_OBJECT_CLASS (class);
2635 GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (class);
2637 object_class->dispose = gdk_x11_display_dispose;
2638 object_class->finalize = gdk_x11_display_finalize;
2640 display_class->window_type = GDK_TYPE_X11_WINDOW;
2642 display_class->get_name = gdk_x11_display_get_name;
2643 display_class->get_n_screens = gdk_x11_display_get_n_screens;
2644 display_class->get_screen = gdk_x11_display_get_screen;
2645 display_class->get_default_screen = gdk_x11_display_get_default_screen;
2646 display_class->beep = gdk_x11_display_beep;
2647 display_class->sync = gdk_x11_display_sync;
2648 display_class->flush = gdk_x11_display_flush;
2649 display_class->has_pending = gdk_x11_display_has_pending;
2650 display_class->queue_events = _gdk_x11_display_queue_events;
2651 display_class->get_default_group = gdk_x11_display_get_default_group;
2652 display_class->supports_selection_notification = gdk_x11_display_supports_selection_notification;
2653 display_class->request_selection_notification = gdk_x11_display_request_selection_notification;
2654 display_class->supports_clipboard_persistence = gdk_x11_display_supports_clipboard_persistence;
2655 display_class->store_clipboard = gdk_x11_display_store_clipboard;
2656 display_class->supports_shapes = gdk_x11_display_supports_shapes;
2657 display_class->supports_input_shapes = gdk_x11_display_supports_input_shapes;
2658 display_class->supports_composite = gdk_x11_display_supports_composite;
2659 display_class->list_devices = gdk_x11_display_list_devices;
2660 display_class->get_app_launch_context = _gdk_x11_display_get_app_launch_context;
2661 display_class->get_cursor_for_type = _gdk_x11_display_get_cursor_for_type;
2662 display_class->get_cursor_for_name = _gdk_x11_display_get_cursor_for_name;
2663 display_class->get_cursor_for_pixbuf = _gdk_x11_display_get_cursor_for_pixbuf;
2664 display_class->get_default_cursor_size = _gdk_x11_display_get_default_cursor_size;
2665 display_class->get_maximal_cursor_size = _gdk_x11_display_get_maximal_cursor_size;
2666 display_class->supports_cursor_alpha = _gdk_x11_display_supports_cursor_alpha;
2667 display_class->supports_cursor_color = _gdk_x11_display_supports_cursor_color;
2669 display_class->before_process_all_updates = _gdk_x11_display_before_process_all_updates;
2670 display_class->after_process_all_updates = _gdk_x11_display_after_process_all_updates;
2671 display_class->get_next_serial = gdk_x11_display_get_next_serial;
2672 display_class->notify_startup_complete = gdk_x11_display_notify_startup_complete;
2673 display_class->event_data_copy = gdk_x11_display_event_data_copy;
2674 display_class->event_data_free = gdk_x11_display_event_data_free;
2675 display_class->create_window_impl = _gdk_x11_display_create_window_impl;
2676 display_class->get_keymap = gdk_x11_display_get_keymap;
2677 display_class->push_error_trap = gdk_x11_display_error_trap_push;
2678 display_class->pop_error_trap = pop_error_trap;
2679 display_class->get_selection_owner = _gdk_x11_display_get_selection_owner;
2680 display_class->set_selection_owner = _gdk_x11_display_set_selection_owner;
2681 display_class->send_selection_notify = _gdk_x11_display_send_selection_notify;
2682 display_class->get_selection_property = _gdk_x11_display_get_selection_property;
2683 display_class->convert_selection = _gdk_x11_display_convert_selection;
2684 display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list;
2685 display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target;