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