]> Pileus Git - ~andy/gtk/blob - gdk/x11/gdkdisplay-x11.c
Bug 107000 – Add signals to GdkKeymap for monitoring caps_lock, etc.
[~andy/gtk] / gdk / x11 / gdkdisplay-x11.c
1 /* GDK - The GIMP Drawing Kit
2  * gdkdisplay-x11.c
3  * 
4  * Copyright 2001 Sun Microsystems Inc.
5  * Copyright (C) 2004 Nokia Corporation
6  *
7  * Erwann Chenede <erwann.chenede@sun.com>
8  *
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.
13  *
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.
18  *
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.
23  */
24
25 #include "config.h"
26
27 #include <stdlib.h>
28 #include <string.h>
29 #include <errno.h>
30 #include <unistd.h>
31
32 #include <glib.h>
33 #include "gdkx.h"
34 #include "gdkdisplay.h"
35 #include "gdkdisplay-x11.h"
36 #include "gdkscreen.h"
37 #include "gdkscreen-x11.h"
38 #include "gdkinternals.h"
39 #include "gdkinputprivate.h"
40 #include "xsettings-client.h"
41 #include "gdkalias.h"
42
43 #include <X11/Xatom.h>
44
45 #ifdef HAVE_XKB
46 #include <X11/XKBlib.h>
47 #endif
48
49 #ifdef HAVE_XFIXES
50 #include <X11/extensions/Xfixes.h>
51 #endif
52
53 #ifdef HAVE_SHAPE_EXT
54 #include <X11/extensions/shape.h>
55 #endif
56
57 #ifdef HAVE_XCOMPOSITE
58 #include <X11/extensions/Xcomposite.h>
59 #endif
60
61 #ifdef HAVE_XDAMAGE
62 #include <X11/extensions/Xdamage.h>
63 #endif
64
65 #ifdef HAVE_RANDR
66 #include <X11/extensions/Xrandr.h>
67 #endif
68
69
70 static void   gdk_display_x11_dispose            (GObject            *object);
71 static void   gdk_display_x11_finalize           (GObject            *object);
72
73 #ifdef HAVE_X11R6
74 static void gdk_internal_connection_watch (Display  *display,
75                                            XPointer  arg,
76                                            gint      fd,
77                                            gboolean  opening,
78                                            XPointer *watch_data);
79 #endif /* HAVE_X11R6 */
80
81 /* Note that we never *directly* use WM_LOCALE_NAME, WM_PROTOCOLS,
82  * but including them here has the side-effect of getting them
83  * into the internal Xlib cache
84  */
85 static const char *const precache_atoms[] = {
86   "UTF8_STRING",
87   "WM_CLIENT_LEADER",
88   "WM_DELETE_WINDOW",
89   "WM_LOCALE_NAME",
90   "WM_PROTOCOLS",
91   "WM_TAKE_FOCUS",
92   "_NET_WM_CM_S0",
93   "_NET_WM_DESKTOP",
94   "_NET_WM_ICON",
95   "_NET_WM_ICON_NAME",
96   "_NET_WM_NAME",
97   "_NET_WM_PID",
98   "_NET_WM_PING",
99   "_NET_WM_STATE",
100   "_NET_WM_STATE_STICKY",
101   "_NET_WM_STATE_MAXIMIZED_VERT",
102   "_NET_WM_STATE_MAXIMIZED_HORZ",
103   "_NET_WM_STATE_FULLSCREEN",
104   "_NET_WM_SYNC_REQUEST",
105   "_NET_WM_SYNC_REQUEST_COUNTER",
106   "_NET_WM_WINDOW_TYPE",
107   "_NET_WM_WINDOW_TYPE_NORMAL",
108   "_NET_WM_USER_TIME",
109   "_NET_VIRTUAL_ROOTS"
110 };
111
112 G_DEFINE_TYPE (GdkDisplayX11, _gdk_display_x11, GDK_TYPE_DISPLAY)
113
114 static void
115 _gdk_display_x11_class_init (GdkDisplayX11Class * class)
116 {
117   GObjectClass *object_class = G_OBJECT_CLASS (class);
118   
119   object_class->dispose = gdk_display_x11_dispose;
120   object_class->finalize = gdk_display_x11_finalize;
121 }
122
123 static void
124 _gdk_display_x11_init (GdkDisplayX11 *display)
125 {
126 }
127
128 /**
129  * gdk_display_open:
130  * @display_name: the name of the display to open
131  * @returns: a #GdkDisplay, or %NULL if the display
132  *  could not be opened.
133  *
134  * Opens a display.
135  *
136  * Since: 2.2
137  */
138 GdkDisplay *
139 gdk_display_open (const gchar *display_name)
140 {
141   Display *xdisplay;
142   GdkDisplay *display;
143   GdkDisplayX11 *display_x11;
144   GdkWindowAttr attr;
145   gint argc;
146   gchar *argv[1];
147   const char *sm_client_id;
148   
149   XClassHint *class_hint;
150   gulong pid;
151   gint i;
152 #if defined(HAVE_XFIXES) || defined(HAVE_SHAPE_EXT)
153   gint ignore;
154   gint maj, min;
155 #endif
156
157   xdisplay = XOpenDisplay (display_name);
158   if (!xdisplay)
159     return NULL;
160   
161   display = g_object_new (GDK_TYPE_DISPLAY_X11, NULL);
162   display_x11 = GDK_DISPLAY_X11 (display);
163
164   display_x11->use_xshm = TRUE;
165   display_x11->xdisplay = xdisplay;
166
167 #ifdef HAVE_X11R6  
168   /* Set up handlers for Xlib internal connections */
169   XAddConnectionWatch (xdisplay, gdk_internal_connection_watch, NULL);
170 #endif /* HAVE_X11R6 */
171   
172   /* RandR must be initialized before we initialize the screens */
173   display_x11->have_randr12 = FALSE;
174 #ifdef HAVE_RANDR
175   if (XRRQueryExtension (display_x11->xdisplay,
176                          &display_x11->xrandr_event_base, &ignore))
177   {
178       int major, minor;
179       
180       XRRQueryVersion (display_x11->xdisplay, &major, &minor);
181
182       if ((major == 1 && minor >= 2) || major > 1)
183           display_x11->have_randr12 = TRUE;
184   }
185 #endif
186   
187   /* initialize the display's screens */ 
188   display_x11->screens = g_new (GdkScreen *, ScreenCount (display_x11->xdisplay));
189   for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
190     display_x11->screens[i] = _gdk_x11_screen_new (display, i);
191
192   /* We need to initialize events after we have the screen
193    * structures in places
194    */
195   for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
196     _gdk_x11_events_init_screen (display_x11->screens[i]);
197   
198   /*set the default screen */
199   display_x11->default_screen = display_x11->screens[DefaultScreen (display_x11->xdisplay)];
200
201   attr.window_type = GDK_WINDOW_TOPLEVEL;
202   attr.wclass = GDK_INPUT_OUTPUT;
203   attr.x = 10;
204   attr.y = 10;
205   attr.width = 10;
206   attr.height = 10;
207   attr.event_mask = 0;
208
209   _gdk_x11_precache_atoms (display, precache_atoms, G_N_ELEMENTS (precache_atoms));
210
211   display_x11->leader_gdk_window = gdk_window_new (GDK_SCREEN_X11 (display_x11->default_screen)->root_window, 
212                                                    &attr, GDK_WA_X | GDK_WA_Y);
213   (_gdk_x11_window_get_toplevel (display_x11->leader_gdk_window))->is_leader = TRUE;
214
215   display_x11->leader_window = GDK_WINDOW_XID (display_x11->leader_gdk_window);
216
217   display_x11->leader_window_title_set = FALSE;
218
219   display_x11->have_render = GDK_UNKNOWN;
220
221 #ifdef HAVE_XFIXES
222   if (XFixesQueryExtension (display_x11->xdisplay, 
223                             &display_x11->xfixes_event_base, 
224                             &ignore))
225     {
226       display_x11->have_xfixes = TRUE;
227
228       gdk_x11_register_standard_event_type (display,
229                                             display_x11->xfixes_event_base, 
230                                             XFixesNumberEvents);
231     }
232   else
233 #endif
234     display_x11->have_xfixes = FALSE;
235
236 #ifdef HAVE_XCOMPOSITE
237   if (XCompositeQueryExtension (display_x11->xdisplay,
238                                 &ignore, &ignore))
239     {
240       int major, minor;
241
242       XCompositeQueryVersion (display_x11->xdisplay, &major, &minor);
243
244       /* Prior to Composite version 0.4, composited windows clipped their
245        * parents, so you had to use IncludeInferiors to draw to the parent
246        * This isn't useful for our purposes, so require 0.4
247        */
248       display_x11->have_xcomposite = major > 0 || (major == 0 && minor >= 4);
249     }
250   else
251 #endif
252     display_x11->have_xcomposite = FALSE;
253
254 #ifdef HAVE_XDAMAGE
255   if (XDamageQueryExtension (display_x11->xdisplay,
256                              &display_x11->xdamage_event_base,
257                              &ignore))
258     {
259       display_x11->have_xdamage = TRUE;
260
261       gdk_x11_register_standard_event_type (display,
262                                             display_x11->xdamage_event_base,
263                                             XDamageNumberEvents);
264     }
265   else
266 #endif
267     display_x11->have_xdamage = FALSE;
268
269   display_x11->have_shapes = FALSE;
270   display_x11->have_input_shapes = FALSE;
271 #ifdef HAVE_SHAPE_EXT
272   if (XShapeQueryExtension (GDK_DISPLAY_XDISPLAY (display), &ignore, &ignore))
273     {
274       display_x11->have_shapes = TRUE;
275 #ifdef ShapeInput             
276       if (XShapeQueryVersion (GDK_DISPLAY_XDISPLAY (display), &maj, &min))
277         display_x11->have_input_shapes = (maj == 1 && min >= 1);
278 #endif
279     }
280 #endif
281
282   display_x11->trusted_client = TRUE;
283   {
284     Window root, child;
285     int rootx, rooty, winx, winy;
286     unsigned int xmask;
287
288     gdk_error_trap_push ();
289     XQueryPointer (display_x11->xdisplay, 
290                    GDK_SCREEN_X11 (display_x11->default_screen)->xroot_window,
291                    &root, &child, &rootx, &rooty, &winx, &winy, &xmask);
292     gdk_flush ();
293     if (G_UNLIKELY (gdk_error_trap_pop () == BadWindow)) 
294       {
295         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));
296         display_x11->trusted_client = FALSE;
297       }
298   }
299
300   if (_gdk_synchronize)
301     XSynchronize (display_x11->xdisplay, True);
302   
303   class_hint = XAllocClassHint();
304   class_hint->res_name = g_get_prgname ();
305   
306   class_hint->res_class = (char *)gdk_get_program_class ();
307
308   /* XmbSetWMProperties sets the RESOURCE_NAME environment variable
309    * from argv[0], so we just synthesize an argument array here.
310    */
311   argc = 1;
312   argv[0] = g_get_prgname ();
313   
314   XmbSetWMProperties (display_x11->xdisplay,
315                       display_x11->leader_window,
316                       NULL, NULL, argv, argc, NULL, NULL,
317                       class_hint);
318   XFree (class_hint);
319
320   sm_client_id = _gdk_get_sm_client_id ();
321   if (sm_client_id)
322     _gdk_windowing_display_set_sm_client_id (display, sm_client_id);
323
324   pid = getpid ();
325   XChangeProperty (display_x11->xdisplay,
326                    display_x11->leader_window,
327                    gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PID"),
328                    XA_CARDINAL, 32, PropModeReplace, (guchar *) & pid, 1);
329
330   /* We don't yet know a valid time. */
331   display_x11->user_time = 0;
332   
333 #ifdef HAVE_XKB
334   {
335     gint xkb_major = XkbMajorVersion;
336     gint xkb_minor = XkbMinorVersion;
337     if (XkbLibraryVersion (&xkb_major, &xkb_minor))
338       {
339         xkb_major = XkbMajorVersion;
340         xkb_minor = XkbMinorVersion;
341             
342         if (XkbQueryExtension (display_x11->xdisplay, 
343                                NULL, &display_x11->xkb_event_type, NULL,
344                                &xkb_major, &xkb_minor))
345           {
346             Bool detectable_autorepeat_supported;
347             
348             display_x11->use_xkb = TRUE;
349
350             XkbSelectEvents (display_x11->xdisplay,
351                              XkbUseCoreKbd,
352                              XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask,
353                              XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask);
354
355             /* keep this in sync with _gdk_keymap_state_changed() */ 
356             XkbSelectEventDetails (display_x11->xdisplay,
357                                    XkbUseCoreKbd, XkbStateNotify,
358                                    XkbAllStateComponentsMask,
359                                    XkbGroupLockMask|XkbModifierLockMask);
360
361             XkbSetDetectableAutoRepeat (display_x11->xdisplay,
362                                         True,
363                                         &detectable_autorepeat_supported);
364
365             GDK_NOTE (MISC, g_message ("Detectable autorepeat %s.",
366                                        detectable_autorepeat_supported ? 
367                                        "supported" : "not supported"));
368             
369             display_x11->have_xkb_autorepeat = detectable_autorepeat_supported;
370           }
371       }
372   }
373 #endif
374
375   display_x11->use_sync = FALSE;
376 #ifdef HAVE_XSYNC
377   {
378     int major, minor;
379     int error_base, event_base;
380     
381     if (XSyncQueryExtension (display_x11->xdisplay,
382                              &event_base, &error_base) &&
383         XSyncInitialize (display_x11->xdisplay,
384                          &major, &minor))
385       display_x11->use_sync = TRUE;
386   }
387 #endif
388   
389   _gdk_windowing_image_init (display);
390   _gdk_events_init (display);
391   _gdk_input_init (display);
392   _gdk_dnd_init (display);
393
394   for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
395     gdk_display_request_selection_notification (display, 
396                                                 GDK_SCREEN_X11 (display_x11->screens[i])->cm_selection_atom);
397
398   g_signal_emit_by_name (gdk_display_manager_get(),
399                          "display_opened", display);
400
401   return display;
402 }
403
404 #ifdef HAVE_X11R6
405 /*
406  * XLib internal connection handling
407  */
408 typedef struct _GdkInternalConnection GdkInternalConnection;
409
410 struct _GdkInternalConnection
411 {
412   gint           fd;
413   GSource       *source;
414   Display       *display;
415 };
416
417 static gboolean
418 process_internal_connection (GIOChannel  *gioc,
419                              GIOCondition cond,
420                              gpointer     data)
421 {
422   GdkInternalConnection *connection = (GdkInternalConnection *)data;
423
424   GDK_THREADS_ENTER ();
425
426   XProcessInternalConnection ((Display*)connection->display, connection->fd);
427
428   GDK_THREADS_LEAVE ();
429
430   return TRUE;
431 }
432
433 static GdkInternalConnection *
434 gdk_add_connection_handler (Display *display,
435                             guint    fd)
436 {
437   GIOChannel *io_channel;
438   GdkInternalConnection *connection;
439
440   connection = g_new (GdkInternalConnection, 1);
441
442   connection->fd = fd;
443   connection->display = display;
444   
445   io_channel = g_io_channel_unix_new (fd);
446   
447   connection->source = g_io_create_watch (io_channel, G_IO_IN);
448   g_source_set_callback (connection->source,
449                          (GSourceFunc)process_internal_connection, connection, NULL);
450   g_source_attach (connection->source, NULL);
451   
452   g_io_channel_unref (io_channel);
453   
454   return connection;
455 }
456
457 static void
458 gdk_remove_connection_handler (GdkInternalConnection *connection)
459 {
460   g_source_destroy (connection->source);
461   g_free (connection);
462 }
463
464 static void
465 gdk_internal_connection_watch (Display  *display,
466                                XPointer  arg,
467                                gint      fd,
468                                gboolean  opening,
469                                XPointer *watch_data)
470 {
471   if (opening)
472     *watch_data = (XPointer)gdk_add_connection_handler (display, fd);
473   else
474     gdk_remove_connection_handler ((GdkInternalConnection *)*watch_data);
475 }
476 #endif /* HAVE_X11R6 */
477
478 /**
479  * gdk_display_get_name:
480  * @display: a #GdkDisplay
481  *
482  * Gets the name of the display.
483  * 
484  * Returns: a string representing the display name. This string is owned
485  * by GDK and should not be modified or freed.
486  * 
487  * Since: 2.2
488  */
489 G_CONST_RETURN gchar *
490 gdk_display_get_name (GdkDisplay *display)
491 {
492   g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
493   
494   return (gchar *) DisplayString (GDK_DISPLAY_X11 (display)->xdisplay);
495 }
496
497 /**
498  * gdk_display_get_n_screens:
499  * @display: a #GdkDisplay
500  *
501  * Gets the number of screen managed by the @display.
502  * 
503  * Returns: number of screens.
504  * 
505  * Since: 2.2
506  */
507 gint
508 gdk_display_get_n_screens (GdkDisplay *display)
509 {
510   g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
511   
512   return ScreenCount (GDK_DISPLAY_X11 (display)->xdisplay);
513 }
514
515 /**
516  * gdk_display_get_screen:
517  * @display: a #GdkDisplay
518  * @screen_num: the screen number
519  *
520  * Returns a screen object for one of the screens of the display.
521  *
522  * Returns: the #GdkScreen object
523  *
524  * Since: 2.2
525  */
526 GdkScreen *
527 gdk_display_get_screen (GdkDisplay *display, 
528                         gint        screen_num)
529 {
530   g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
531   g_return_val_if_fail (ScreenCount (GDK_DISPLAY_X11 (display)->xdisplay) > screen_num, NULL);
532   
533   return GDK_DISPLAY_X11 (display)->screens[screen_num];
534 }
535
536 /**
537  * gdk_display_get_default_screen:
538  * @display: a #GdkDisplay
539  *
540  * Get the default #GdkScreen for @display.
541  * 
542  * Returns: the default #GdkScreen object for @display
543  *
544  * Since: 2.2
545  */
546 GdkScreen *
547 gdk_display_get_default_screen (GdkDisplay *display)
548 {
549   g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
550   
551   return GDK_DISPLAY_X11 (display)->default_screen;
552 }
553
554 gboolean
555 _gdk_x11_display_is_root_window (GdkDisplay *display,
556                                  Window      xroot_window)
557 {
558   GdkDisplayX11 *display_x11;
559   gint i;
560   
561   g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
562   
563   display_x11 = GDK_DISPLAY_X11 (display);
564   
565   for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
566     {
567       if (GDK_SCREEN_XROOTWIN (display_x11->screens[i]) == xroot_window)
568         return TRUE;
569     }
570   return FALSE;
571 }
572
573 #define XSERVER_TIME_IS_LATER(time1, time2)                        \
574   ( (( time1 > time2 ) && ( time1 - time2 < ((guint32)-1)/2 )) ||  \
575     (( time1 < time2 ) && ( time2 - time1 > ((guint32)-1)/2 ))     \
576   )
577
578 /**
579  * gdk_display_pointer_ungrab:
580  * @display: a #GdkDisplay.
581  * @time_: a timestap (e.g. %GDK_CURRENT_TIME).
582  *
583  * Release any pointer grab.
584  *
585  * Since: 2.2
586  */
587 void
588 gdk_display_pointer_ungrab (GdkDisplay *display,
589                             guint32     time)
590 {
591   Display *xdisplay;
592   GdkDisplayX11 *display_x11;
593
594   g_return_if_fail (GDK_IS_DISPLAY (display));
595
596   display_x11 = GDK_DISPLAY_X11 (display);
597   xdisplay = GDK_DISPLAY_XDISPLAY (display);
598   
599   _gdk_input_ungrab_pointer (display, time);
600   XUngrabPointer (xdisplay, time);
601   XFlush (xdisplay);
602
603   if (time == GDK_CURRENT_TIME || 
604       display_x11->pointer_xgrab_time == GDK_CURRENT_TIME ||
605       !XSERVER_TIME_IS_LATER (display_x11->pointer_xgrab_time, time))
606     display_x11->pointer_xgrab_window = NULL;
607 }
608
609 /**
610  * gdk_display_pointer_is_grabbed:
611  * @display: a #GdkDisplay
612  *
613  * Test if the pointer is grabbed.
614  *
615  * Returns: %TRUE if an active X pointer grab is in effect
616  *
617  * Since: 2.2
618  */
619 gboolean
620 gdk_display_pointer_is_grabbed (GdkDisplay *display)
621 {
622   g_return_val_if_fail (GDK_IS_DISPLAY (display), TRUE);
623   
624   return (GDK_DISPLAY_X11 (display)->pointer_xgrab_window != NULL &&
625           !GDK_DISPLAY_X11 (display)->pointer_xgrab_implicit);
626 }
627
628 /**
629  * gdk_display_keyboard_ungrab:
630  * @display: a #GdkDisplay.
631  * @time_: a timestap (e.g #GDK_CURRENT_TIME).
632  *
633  * Release any keyboard grab
634  *
635  * Since: 2.2
636  */
637 void
638 gdk_display_keyboard_ungrab (GdkDisplay *display,
639                              guint32     time)
640 {
641   Display *xdisplay;
642   GdkDisplayX11 *display_x11;
643   
644   g_return_if_fail (GDK_IS_DISPLAY (display));
645
646   display_x11 = GDK_DISPLAY_X11 (display);
647   xdisplay = GDK_DISPLAY_XDISPLAY (display);
648   
649   XUngrabKeyboard (xdisplay, time);
650   XFlush (xdisplay);
651   
652   if (time == GDK_CURRENT_TIME || 
653       display_x11->keyboard_xgrab_time == GDK_CURRENT_TIME ||
654       !XSERVER_TIME_IS_LATER (display_x11->keyboard_xgrab_time, time))
655     display_x11->keyboard_xgrab_window = NULL;
656 }
657
658 /**
659  * gdk_display_beep:
660  * @display: a #GdkDisplay
661  *
662  * Emits a short beep on @display
663  *
664  * Since: 2.2
665  */
666 void
667 gdk_display_beep (GdkDisplay *display)
668 {
669   g_return_if_fail (GDK_IS_DISPLAY (display));
670   
671   XBell (GDK_DISPLAY_XDISPLAY (display), 0);
672 }
673
674 /**
675  * gdk_display_sync:
676  * @display: a #GdkDisplay
677  *
678  * Flushes any requests queued for the windowing system and waits until all
679  * requests have been handled. This is often used for making sure that the
680  * display is synchronized with the current state of the program. Calling
681  * gdk_display_sync() before gdk_error_trap_pop() makes sure that any errors
682  * generated from earlier requests are handled before the error trap is 
683  * removed.
684  *
685  * This is most useful for X11. On windowing systems where requests are
686  * handled synchronously, this function will do nothing.
687  *
688  * Since: 2.2
689  */
690 void
691 gdk_display_sync (GdkDisplay *display)
692 {
693   g_return_if_fail (GDK_IS_DISPLAY (display));
694   
695   XSync (GDK_DISPLAY_XDISPLAY (display), False);
696 }
697
698 /**
699  * gdk_display_flush:
700  * @display: a #GdkDisplay
701  *
702  * Flushes any requests queued for the windowing system; this happens automatically
703  * when the main loop blocks waiting for new events, but if your application
704  * is drawing without returning control to the main loop, you may need
705  * to call this function explicitely. A common case where this function
706  * needs to be called is when an application is executing drawing commands
707  * from a thread other than the thread where the main loop is running.
708  *
709  * This is most useful for X11. On windowing systems where requests are
710  * handled synchronously, this function will do nothing.
711  *
712  * Since: 2.4
713  */
714 void 
715 gdk_display_flush (GdkDisplay *display)
716 {
717   g_return_if_fail (GDK_IS_DISPLAY (display));
718
719   if (!display->closed)
720     XFlush (GDK_DISPLAY_XDISPLAY (display));
721 }
722
723 /**
724  * gdk_display_get_default_group:
725  * @display: a #GdkDisplay
726  * 
727  * Returns the default group leader window for all toplevel windows
728  * on @display. This window is implicitly created by GDK. 
729  * See gdk_window_set_group().
730  * 
731  * Return value: The default group leader window for @display
732  *
733  * Since: 2.4
734  **/
735 GdkWindow *
736 gdk_display_get_default_group (GdkDisplay *display)
737 {
738   g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
739
740   return GDK_DISPLAY_X11 (display)->leader_gdk_window;
741 }
742
743 /**
744  * gdk_x11_display_grab:
745  * @display: a #GdkDisplay 
746  * 
747  * Call XGrabServer() on @display. 
748  * To ungrab the display again, use gdk_x11_display_ungrab(). 
749  *
750  * gdk_x11_display_grab()/gdk_x11_display_ungrab() calls can be nested.
751  *
752  * Since: 2.2
753  **/
754 void
755 gdk_x11_display_grab (GdkDisplay *display)
756 {
757   GdkDisplayX11 *display_x11;
758   
759   g_return_if_fail (GDK_IS_DISPLAY (display));
760   
761   display_x11 = GDK_DISPLAY_X11 (display);
762   
763   if (display_x11->grab_count == 0)
764     XGrabServer (display_x11->xdisplay);
765   display_x11->grab_count++;
766 }
767
768 /**
769  * gdk_x11_display_ungrab:
770  * @display: a #GdkDisplay
771  * 
772  * Ungrab @display after it has been grabbed with 
773  * gdk_x11_display_grab(). 
774  *
775  * Since: 2.2
776  **/
777 void
778 gdk_x11_display_ungrab (GdkDisplay *display)
779 {
780   GdkDisplayX11 *display_x11;
781   
782   g_return_if_fail (GDK_IS_DISPLAY (display));
783   
784   display_x11 = GDK_DISPLAY_X11 (display);;
785   g_return_if_fail (display_x11->grab_count > 0);
786   
787   display_x11->grab_count--;
788   if (display_x11->grab_count == 0)
789     {
790       XUngrabServer (display_x11->xdisplay);
791       XFlush (display_x11->xdisplay);
792     }
793 }
794
795 static void
796 gdk_display_x11_dispose (GObject *object)
797 {
798   GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (object);
799   gint           i;
800
801   for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
802     _gdk_screen_close (display_x11->screens[i]);
803
804   _gdk_events_uninit (GDK_DISPLAY_OBJECT (object));
805
806   G_OBJECT_CLASS (_gdk_display_x11_parent_class)->dispose (object);
807 }
808
809 static void
810 gdk_display_x11_finalize (GObject *object)
811 {
812   GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (object);
813   gint           i;
814
815   /* Keymap */
816   if (display_x11->keymap)
817     g_object_unref (display_x11->keymap);
818
819   /* Free motif Dnd */
820   if (display_x11->motif_target_lists)
821     {
822       for (i = 0; i < display_x11->motif_n_target_lists; i++)
823         g_list_free (display_x11->motif_target_lists[i]);
824       g_free (display_x11->motif_target_lists);
825     }
826
827   /* Atom Hashtable */
828   g_hash_table_destroy (display_x11->atom_from_virtual);
829   g_hash_table_destroy (display_x11->atom_to_virtual);
830
831   /* Leader Window */
832   XDestroyWindow (display_x11->xdisplay, display_x11->leader_window);
833
834   /* list of filters for client messages */
835   g_list_foreach (display_x11->client_filters, (GFunc) g_free, NULL);
836   g_list_free (display_x11->client_filters);
837
838   /* List of event window extraction functions */
839   g_slist_foreach (display_x11->event_types, (GFunc)g_free, NULL);
840   g_slist_free (display_x11->event_types);
841
842   /* input GdkDevice list */
843   g_list_foreach (display_x11->input_devices, (GFunc) g_object_unref, NULL);
844   g_list_free (display_x11->input_devices);
845
846   /* input GdkWindow list */
847   g_list_foreach (display_x11->input_windows, (GFunc) g_free, NULL);
848   g_list_free (display_x11->input_windows);
849
850   /* Free all GdkScreens */
851   for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
852     g_object_unref (display_x11->screens[i]);
853   g_free (display_x11->screens);
854
855   g_free (display_x11->startup_notification_id);
856
857   /* X ID hashtable */
858   g_hash_table_destroy (display_x11->xid_ht);
859
860   XCloseDisplay (display_x11->xdisplay);
861
862   G_OBJECT_CLASS (_gdk_display_x11_parent_class)->finalize (object);
863 }
864
865 /**
866  * gdk_x11_lookup_xdisplay:
867  * @xdisplay: a pointer to an X Display
868  * 
869  * Find the #GdkDisplay corresponding to @display, if any exists.
870  * 
871  * Return value: the #GdkDisplay, if found, otherwise %NULL.
872  *
873  * Since: 2.2
874  **/
875 GdkDisplay *
876 gdk_x11_lookup_xdisplay (Display *xdisplay)
877 {
878   GSList *tmp_list;
879
880   for (tmp_list = _gdk_displays; tmp_list; tmp_list = tmp_list->next)
881     {
882       if (GDK_DISPLAY_XDISPLAY (tmp_list->data) == xdisplay)
883         return tmp_list->data;
884     }
885   
886   return NULL;
887 }
888
889 /**
890  * _gdk_x11_display_screen_for_xrootwin:
891  * @display: a #GdkDisplay
892  * @xrootwin: window ID for one of of the screen's of the display.
893  * 
894  * Given the root window ID of one of the screen's of a #GdkDisplay,
895  * finds the screen.
896  * 
897  * Return value: the #GdkScreen corresponding to @xrootwin, or %NULL.
898  **/
899 GdkScreen *
900 _gdk_x11_display_screen_for_xrootwin (GdkDisplay *display,
901                                       Window      xrootwin)
902 {
903   gint i;
904
905   for (i = 0; i < ScreenCount (GDK_DISPLAY_X11 (display)->xdisplay); i++)
906     {
907       GdkScreen *screen = gdk_display_get_screen (display, i);
908       if (GDK_SCREEN_XROOTWIN (screen) == xrootwin)
909         return screen;
910     }
911
912   return NULL;
913 }
914
915 /**
916  * gdk_x11_display_get_xdisplay:
917  * @display: a #GdkDisplay
918  * @returns: an X display.
919  *
920  * Returns the X display of a #GdkDisplay.
921  *
922  * Since: 2.2
923  */
924 Display *
925 gdk_x11_display_get_xdisplay (GdkDisplay *display)
926 {
927   g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
928   return GDK_DISPLAY_X11 (display)->xdisplay;
929 }
930
931 void
932 _gdk_windowing_set_default_display (GdkDisplay *display)
933 {
934   GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
935   const gchar *startup_id;
936   
937   if (!display)
938     {
939       gdk_display = NULL;
940       return;
941     }
942
943   gdk_display = GDK_DISPLAY_XDISPLAY (display);
944
945   g_free (display_x11->startup_notification_id);
946   display_x11->startup_notification_id = NULL;
947   
948   startup_id = g_getenv ("DESKTOP_STARTUP_ID");
949   if (startup_id && *startup_id != '\0')
950     {
951       gchar *time_str;
952
953       if (!g_utf8_validate (startup_id, -1, NULL))
954         g_warning ("DESKTOP_STARTUP_ID contains invalid UTF-8");
955       else
956         display_x11->startup_notification_id = g_strdup (startup_id);
957
958       /* Find the launch time from the startup_id, if it's there.  Newer spec
959        * states that the startup_id is of the form <unique>_TIME<timestamp>
960        */
961       time_str = g_strrstr (startup_id, "_TIME");
962       if (time_str != NULL)
963         {
964           gulong retval;
965           gchar *end;
966           errno = 0;
967
968           /* Skip past the "_TIME" part */
969           time_str += 5;
970
971           retval = strtoul (time_str, &end, 0);
972           if (end != time_str && errno == 0)
973             display_x11->user_time = retval;
974         }
975       
976       /* Clear the environment variable so it won't be inherited by
977        * child processes and confuse things.  
978        */
979       g_unsetenv ("DESKTOP_STARTUP_ID");
980
981       /* Set the startup id on the leader window so it
982        * applies to all windows we create on this display
983        */
984       XChangeProperty (display_x11->xdisplay,
985                        display_x11->leader_window,
986                        gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"),
987                        gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
988                        PropModeReplace,
989                        (guchar *)startup_id, strlen (startup_id));
990     }
991 }
992
993 static void
994 broadcast_xmessage (GdkDisplay *display,
995                     const char *message_type,
996                     const char *message_type_begin,
997                     const char *message)
998 {
999   Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
1000   GdkScreen *screen = gdk_display_get_default_screen (display);
1001   GdkWindow *root_window = gdk_screen_get_root_window (screen);
1002   Window xroot_window = GDK_WINDOW_XID (root_window);
1003   
1004   Atom type_atom;
1005   Atom type_atom_begin;
1006   Window xwindow;
1007
1008   if (!G_LIKELY (GDK_DISPLAY_X11 (display)->trusted_client))
1009     return;
1010
1011   {
1012     XSetWindowAttributes attrs;
1013
1014     attrs.override_redirect = True;
1015     attrs.event_mask = PropertyChangeMask | StructureNotifyMask;
1016
1017     xwindow =
1018       XCreateWindow (xdisplay,
1019                      xroot_window,
1020                      -100, -100, 1, 1,
1021                      0,
1022                      CopyFromParent,
1023                      CopyFromParent,
1024                      (Visual *)CopyFromParent,
1025                      CWOverrideRedirect | CWEventMask,
1026                      &attrs);
1027   }
1028
1029   type_atom = gdk_x11_get_xatom_by_name_for_display (display,
1030                                                      message_type);
1031   type_atom_begin = gdk_x11_get_xatom_by_name_for_display (display,
1032                                                            message_type_begin);
1033   
1034   {
1035     XClientMessageEvent xclient;
1036     const char *src;
1037     const char *src_end;
1038     char *dest;
1039     char *dest_end;
1040     
1041                 memset(&xclient, 0, sizeof (xclient));
1042     xclient.type = ClientMessage;
1043     xclient.message_type = type_atom_begin;
1044     xclient.display =xdisplay;
1045     xclient.window = xwindow;
1046     xclient.format = 8;
1047
1048     src = message;
1049     src_end = message + strlen (message) + 1; /* +1 to include nul byte */
1050     
1051     while (src != src_end)
1052       {
1053         dest = &xclient.data.b[0];
1054         dest_end = dest + 20;        
1055         
1056         while (dest != dest_end &&
1057                src != src_end)
1058           {
1059             *dest = *src;
1060             ++dest;
1061             ++src;
1062           }
1063
1064         while (dest != dest_end)
1065           {
1066             *dest = 0;
1067             ++dest;
1068           }
1069         
1070         XSendEvent (xdisplay,
1071                     xroot_window,
1072                     False,
1073                     PropertyChangeMask,
1074                     (XEvent *)&xclient);
1075
1076         xclient.message_type = type_atom;
1077       }
1078   }
1079
1080   XDestroyWindow (xdisplay, xwindow);
1081   XFlush (xdisplay);
1082 }
1083
1084 /**
1085  * gdk_x11_display_broadcast_startup_message:
1086  * @display: a #GdkDisplay
1087  * @message_type: startup notification message type ("new", "change",
1088  * or "remove")
1089  * @...: a list of key/value pairs (as strings), terminated by a
1090  * %NULL key. (A %NULL value for a key will cause that key to be
1091  * skipped in the output.)
1092  *
1093  * Sends a startup notification message of type @message_type to
1094  * @display. 
1095  *
1096  * This is a convenience function for use by code that implements the
1097  * freedesktop startup notification specification. Applications should
1098  * not normally need to call it directly. See the <ulink
1099  * url="http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">Startup
1100  * Notification Protocol specification</ulink> for
1101  * definitions of the message types and keys that can be used.
1102  *
1103  * Since: 2.12
1104  **/
1105 void
1106 gdk_x11_display_broadcast_startup_message (GdkDisplay *display,
1107                                            const char *message_type,
1108                                            ...)
1109 {
1110   GString *message;
1111   va_list ap;
1112   const char *key, *value, *p;
1113
1114   message = g_string_new (message_type);
1115   g_string_append_c (message, ':');
1116
1117   va_start (ap, message_type);
1118   while ((key = va_arg (ap, const char *)))
1119     {
1120       value = va_arg (ap, const char *);
1121       if (!value)
1122         continue;
1123
1124       g_string_append_printf (message, " %s=\"", key);
1125       for (p = value; *p; p++)
1126         {
1127           switch (*p)
1128             {
1129             case ' ':
1130             case '"':
1131             case '\\':
1132               g_string_append_c (message, '\\');
1133               break;
1134             }
1135
1136           g_string_append_c (message, *p);
1137         }
1138       g_string_append_c (message, '\"');
1139     }
1140   va_end (ap);
1141
1142   broadcast_xmessage (display,
1143                       "_NET_STARTUP_INFO",
1144                       "_NET_STARTUP_INFO_BEGIN",
1145                       message->str);
1146
1147   g_string_free (message, TRUE);
1148 }
1149
1150 /**
1151  * gdk_notify_startup_complete:
1152  * 
1153  * Indicates to the GUI environment that the application has finished
1154  * loading. If the applications opens windows, this function is
1155  * normally called after opening the application's initial set of
1156  * windows.
1157  * 
1158  * GTK+ will call this function automatically after opening the first
1159  * #GtkWindow unless gtk_window_set_auto_startup_notification() is called 
1160  * to disable that feature.
1161  *
1162  * Since: 2.2
1163  **/
1164 void
1165 gdk_notify_startup_complete (void)
1166 {
1167   GdkDisplay *display;
1168   GdkDisplayX11 *display_x11;
1169
1170   display = gdk_display_get_default ();
1171   if (!display)
1172     return;
1173   
1174   display_x11 = GDK_DISPLAY_X11 (display);
1175
1176   if (display_x11->startup_notification_id == NULL)
1177     return;
1178
1179   gdk_notify_startup_complete_with_id (display_x11->startup_notification_id);
1180 }
1181
1182 /**
1183  * gdk_notify_startup_complete_with_id:
1184  * @startup_id: a startup-notification identifier, for which notification
1185  *              process should be completed
1186  * 
1187  * Indicates to the GUI environment that the application has finished
1188  * loading, using a given identifier.
1189  * 
1190  * GTK+ will call this function automatically for #GtkWindow with custom
1191  * startup-notification identifier unless
1192  * gtk_window_set_auto_startup_notification() is called to disable
1193  * that feature.
1194  *
1195  * Since: 2.12
1196  **/
1197 void
1198 gdk_notify_startup_complete_with_id (const gchar* startup_id)
1199 {
1200   GdkDisplay *display;
1201
1202   display = gdk_display_get_default ();
1203   if (!display)
1204     return;
1205
1206   gdk_x11_display_broadcast_startup_message (display, "remove",
1207                                              "ID", startup_id,
1208                                              NULL);
1209 }
1210
1211 /**
1212  * gdk_display_supports_selection_notification:
1213  * @display: a #GdkDisplay
1214  * 
1215  * Returns whether #GdkEventOwnerChange events will be 
1216  * sent when the owner of a selection changes.
1217  * 
1218  * Return value: whether #GdkEventOwnerChange events will 
1219  *               be sent.
1220  *
1221  * Since: 2.6
1222  **/
1223 gboolean 
1224 gdk_display_supports_selection_notification (GdkDisplay *display)
1225 {
1226   GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
1227
1228   return display_x11->have_xfixes;
1229 }
1230
1231 /**
1232  * gdk_display_request_selection_notification:
1233  * @display: a #GdkDisplay
1234  * @selection: the #GdkAtom naming the selection for which
1235  *             ownership change notification is requested
1236  * 
1237  * Request #GdkEventOwnerChange events for ownership changes
1238  * of the selection named by the given atom.
1239  * 
1240  * Return value: whether #GdkEventOwnerChange events will 
1241  *               be sent.
1242  *
1243  * Since: 2.6
1244  **/
1245 gboolean
1246 gdk_display_request_selection_notification (GdkDisplay *display,
1247                                             GdkAtom     selection)
1248
1249 {
1250 #ifdef HAVE_XFIXES
1251   GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
1252   Atom atom;
1253
1254   if (display_x11->have_xfixes)
1255     {
1256       atom = gdk_x11_atom_to_xatom_for_display (display, 
1257                                                 selection);
1258       XFixesSelectSelectionInput (display_x11->xdisplay, 
1259                                   display_x11->leader_window,
1260                                   atom,
1261                                   XFixesSetSelectionOwnerNotifyMask |
1262                                   XFixesSelectionWindowDestroyNotifyMask |
1263                                   XFixesSelectionClientCloseNotifyMask);
1264       return TRUE;
1265     }
1266   else
1267 #endif
1268     return FALSE;
1269 }
1270
1271 /**
1272  * gdk_display_supports_clipboard_persistence
1273  * @display: a #GdkDisplay
1274  *
1275  * Returns whether the speicifed display supports clipboard
1276  * persistance; i.e. if it's possible to store the clipboard data after an
1277  * application has quit. On X11 this checks if a clipboard daemon is
1278  * running.
1279  *
1280  * Returns: %TRUE if the display supports clipboard persistance.
1281  *
1282  * Since: 2.6
1283  */
1284 gboolean
1285 gdk_display_supports_clipboard_persistence (GdkDisplay *display)
1286 {
1287   Atom clipboard_manager;
1288
1289   /* It might make sense to cache this */
1290   clipboard_manager = gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER");
1291   return XGetSelectionOwner (GDK_DISPLAY_X11 (display)->xdisplay, clipboard_manager) != None;
1292 }
1293
1294 /**
1295  * gdk_display_store_clipboard
1296  * @display:          a #GdkDisplay
1297  * @clipboard_window: a #GdkWindow belonging to the clipboard owner
1298  * @time_:            a timestamp
1299  * @targets:          an array of targets that should be saved, or %NULL 
1300  *                    if all available targets should be saved.
1301  * @n_targets:        length of the @targets array
1302  *
1303  * Issues a request to the clipboard manager to store the
1304  * clipboard data. On X11, this is a special program that works
1305  * according to the freedesktop clipboard specification, available at
1306  * <ulink url="http://www.freedesktop.org/Standards/clipboard-manager-spec">
1307  * http://www.freedesktop.org/Standards/clipboard-manager-spec</ulink>.
1308  *
1309  * Since: 2.6
1310  */
1311 void
1312 gdk_display_store_clipboard (GdkDisplay    *display,
1313                              GdkWindow     *clipboard_window,
1314                              guint32        time_,
1315                              const GdkAtom *targets,
1316                              gint           n_targets)
1317 {
1318   GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
1319   Atom clipboard_manager, save_targets;
1320   
1321   clipboard_manager = gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER");
1322   save_targets = gdk_x11_get_xatom_by_name_for_display (display, "SAVE_TARGETS");
1323
1324   gdk_error_trap_push ();
1325
1326   if (XGetSelectionOwner (display_x11->xdisplay, clipboard_manager) != None)
1327     {
1328       Atom property_name = None;
1329       Atom *xatoms;
1330       int i;
1331       
1332       if (n_targets > 0)
1333         {
1334           property_name = gdk_x11_atom_to_xatom_for_display (display, _gdk_selection_property);
1335
1336           xatoms = g_new (Atom, n_targets);
1337           for (i = 0; i < n_targets; i++)
1338             xatoms[i] = gdk_x11_atom_to_xatom_for_display (display, targets[i]);
1339
1340           XChangeProperty (display_x11->xdisplay, GDK_WINDOW_XID (clipboard_window),
1341                            property_name, XA_ATOM,
1342                            32, PropModeReplace, (guchar *)xatoms, n_targets);
1343           g_free (xatoms);
1344
1345         }
1346       
1347       XConvertSelection (display_x11->xdisplay,
1348                          clipboard_manager, save_targets, property_name,
1349                          GDK_WINDOW_XID (clipboard_window), time_);
1350       
1351     }
1352   gdk_error_trap_pop ();
1353
1354 }
1355
1356 /**
1357  * gdk_x11_display_get_user_time:
1358  * @display: a #GdkDisplay
1359  *
1360  * Returns the timestamp of the last user interaction on 
1361  * @display. The timestamp is taken from events caused
1362  * by user interaction such as key presses or pointer 
1363  * movements. See gdk_x11_window_set_user_time().
1364  *
1365  * Returns: the timestamp of the last user interaction 
1366  *
1367  * Since: 2.8
1368  */
1369 guint32
1370 gdk_x11_display_get_user_time (GdkDisplay *display)
1371 {
1372   return GDK_DISPLAY_X11 (display)->user_time;
1373 }
1374
1375 /**
1376  * gdk_display_supports_shapes:
1377  * @display: a #GdkDisplay
1378  *
1379  * Returns %TRUE if gdk_window_shape_combine_mask() can
1380  * be used to create shaped windows on @display.
1381  *
1382  * Returns: %TRUE if shaped windows are supported 
1383  *
1384  * Since: 2.10
1385  */
1386 gboolean 
1387 gdk_display_supports_shapes (GdkDisplay *display)
1388 {
1389   return GDK_DISPLAY_X11 (display)->have_shapes;
1390 }
1391
1392 /**
1393  * gdk_display_supports_input_shapes:
1394  * @display: a #GdkDisplay
1395  *
1396  * Returns %TRUE if gdk_window_input_shape_combine_mask() can
1397  * be used to modify the input shape of windows on @display.
1398  *
1399  * Returns: %TRUE if windows with modified input shape are supported 
1400  *
1401  * Since: 2.10
1402  */
1403 gboolean 
1404 gdk_display_supports_input_shapes (GdkDisplay *display)
1405 {
1406   return GDK_DISPLAY_X11 (display)->have_input_shapes;
1407 }
1408
1409
1410 /**
1411  * gdk_x11_display_get_startup_notification_id:
1412  * @display: a #GdkDisplay
1413  *
1414  * Gets the startup notification ID for a display.
1415  * 
1416  * Returns: the startup notification ID for @display
1417  *
1418  * Since: 2.12
1419  */
1420 G_CONST_RETURN gchar *
1421 gdk_x11_display_get_startup_notification_id (GdkDisplay *display)
1422 {
1423   return GDK_DISPLAY_X11 (display)->startup_notification_id;
1424 }
1425
1426 /**
1427  * gdk_display_supports_composite:
1428  * @display: a #GdkDisplay
1429  *
1430  * Returns %TRUE if gdk_window_set_composited() can be used
1431  * to redirect drawing on the window using compositing.
1432  *
1433  * Currently this only works on X11 with XComposite and
1434  * XDamage extensions available.
1435  *
1436  * Returns: %TRUE if windows may be composited.
1437  *
1438  * Since: 2.12
1439  */
1440 gboolean
1441 gdk_display_supports_composite (GdkDisplay *display)
1442 {
1443   GdkDisplayX11 *x11_display = GDK_DISPLAY_X11 (display);
1444
1445   return x11_display->have_xcomposite &&
1446          x11_display->have_xdamage &&
1447          x11_display->have_xfixes;
1448 }
1449
1450
1451 #define __GDK_DISPLAY_X11_C__
1452 #include "gdkaliasdef.c"