]> Pileus Git - ~andy/gtk/blob - gdk/gdkscreen.c
Merge branch 'master' into broadway2
[~andy/gtk] / gdk / gdkscreen.c
1 /*
2  * gdkscreen.c
3  * 
4  * Copyright 2001 Sun Microsystems Inc. 
5  *
6  * Erwann Chenede <erwann.chenede@sun.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #include "config.h"
25
26 #include "gdkscreenprivate.h"
27 #include "gdkrectangle.h"
28 #include "gdkwindow.h"
29 #include "gdkintl.h"
30
31
32 /**
33  * SECTION:gdkscreen
34  * @Short_description: Object representing a physical screen
35  * @Title: GdkScreen
36  *
37  * #GdkScreen objects are the GDK representation of a physical screen. It is used
38  * throughout GDK and GTK+ to specify which screen the top level windows
39  * are to be displayed on.
40  * It is also used to query the screen specification and default settings such as
41  * the screen width (gdk_screen_get_width()), etc.
42  *
43  * Note that a screen may consist of multiple monitors which are merged to
44  * form a large screen area.
45  */
46
47
48 static void gdk_screen_finalize     (GObject        *object);
49 static void gdk_screen_set_property (GObject        *object,
50                                      guint           prop_id,
51                                      const GValue   *value,
52                                      GParamSpec     *pspec);
53 static void gdk_screen_get_property (GObject        *object,
54                                      guint           prop_id,
55                                      GValue         *value,
56                                      GParamSpec     *pspec);
57
58 enum
59 {
60   PROP_0,
61   PROP_FONT_OPTIONS,
62   PROP_RESOLUTION
63 };
64
65 enum
66 {
67   SIZE_CHANGED,
68   COMPOSITED_CHANGED,
69   MONITORS_CHANGED,
70   LAST_SIGNAL
71 };
72
73 static guint signals[LAST_SIGNAL] = { 0 };
74
75 G_DEFINE_TYPE (GdkScreen, gdk_screen, G_TYPE_OBJECT)
76
77 static void
78 gdk_screen_class_init (GdkScreenClass *klass)
79 {
80   GObjectClass *object_class = G_OBJECT_CLASS (klass);
81
82   object_class->finalize = gdk_screen_finalize;
83   object_class->set_property = gdk_screen_set_property;
84   object_class->get_property = gdk_screen_get_property;
85   
86   g_object_class_install_property (object_class,
87                                    PROP_FONT_OPTIONS,
88                                    g_param_spec_pointer ("font-options",
89                                                          P_("Font options"),
90                                                          P_("The default font options for the screen"),
91                                                          G_PARAM_READWRITE|G_PARAM_STATIC_NAME|
92                                                         G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
93
94   g_object_class_install_property (object_class,
95                                    PROP_RESOLUTION,
96                                    g_param_spec_double ("resolution",
97                                                         P_("Font resolution"),
98                                                         P_("The resolution for fonts on the screen"),
99                                                         -G_MAXDOUBLE,
100                                                         G_MAXDOUBLE,
101                                                         -1.0,
102                                                         G_PARAM_READWRITE|G_PARAM_STATIC_NAME|
103                                                         G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
104
105   /**
106    * GdkScreen::size-changed:
107    * @screen: the object on which the signal is emitted
108    * 
109    * The ::size-changed signal is emitted when the pixel width or 
110    * height of a screen changes.
111    *
112    * Since: 2.2
113    */
114   signals[SIZE_CHANGED] =
115     g_signal_new (g_intern_static_string ("size-changed"),
116                   G_OBJECT_CLASS_TYPE (klass),
117                   G_SIGNAL_RUN_LAST,
118                   G_STRUCT_OFFSET (GdkScreenClass, size_changed),
119                   NULL, NULL,
120                   g_cclosure_marshal_VOID__VOID,
121                   G_TYPE_NONE,
122                   0);
123
124   /**
125    * GdkScreen::composited-changed:
126    * @screen: the object on which the signal is emitted
127    *
128    * The ::composited-changed signal is emitted when the composited
129    * status of the screen changes
130    *
131    * Since: 2.10
132    */
133   signals[COMPOSITED_CHANGED] =
134     g_signal_new (g_intern_static_string ("composited-changed"),
135                   G_OBJECT_CLASS_TYPE (klass),
136                   G_SIGNAL_RUN_LAST,
137                   G_STRUCT_OFFSET (GdkScreenClass, composited_changed),
138                   NULL, NULL,
139                   g_cclosure_marshal_VOID__VOID,
140                   G_TYPE_NONE,
141                   0);
142         
143   /**
144    * GdkScreen::monitors-changed:
145    * @screen: the object on which the signal is emitted
146    *
147    * The ::monitors-changed signal is emitted when the number, size
148    * or position of the monitors attached to the screen change. 
149    *
150    * Only for X11 and OS X for now. A future implementation for Win32
151    * may be a possibility.
152    *
153    * Since: 2.14
154    */
155   signals[MONITORS_CHANGED] =
156     g_signal_new (g_intern_static_string ("monitors-changed"),
157                   G_OBJECT_CLASS_TYPE (klass),
158                   G_SIGNAL_RUN_LAST,
159                   G_STRUCT_OFFSET (GdkScreenClass, monitors_changed),
160                   NULL, NULL,
161                   g_cclosure_marshal_VOID__VOID,
162                   G_TYPE_NONE,
163                   0);
164 }
165
166 static void
167 gdk_screen_init (GdkScreen *screen)
168 {
169   screen->resolution = -1.;
170 }
171
172 static void
173 gdk_screen_finalize (GObject *object)
174 {
175   GdkScreen *screen = GDK_SCREEN (object);
176
177   if (screen->font_options)
178       cairo_font_options_destroy (screen->font_options);
179
180   G_OBJECT_CLASS (gdk_screen_parent_class)->finalize (object);
181 }
182
183 void 
184 _gdk_screen_close (GdkScreen *screen)
185 {
186   g_return_if_fail (GDK_IS_SCREEN (screen));
187
188   if (!screen->closed)
189     {
190       screen->closed = TRUE;
191       g_object_run_dispose (G_OBJECT (screen));
192     }
193 }
194
195 /* Fallback used when the monitor "at" a point or window
196  * doesn't exist.
197  */
198 static gint
199 get_nearest_monitor (GdkScreen *screen,
200                      gint       x,
201                      gint       y)
202 {
203   gint num_monitors, i;
204   gint nearest_dist = G_MAXINT;
205   gint nearest_monitor = 0;
206
207   g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
208
209   num_monitors = gdk_screen_get_n_monitors (screen);
210   
211   for (i = 0; i < num_monitors; i++)
212     {
213       GdkRectangle monitor;
214       gint dist_x, dist_y, dist;
215       
216       gdk_screen_get_monitor_geometry (screen, i, &monitor);
217
218       if (x < monitor.x)
219         dist_x = monitor.x - x;
220       else if (x >= monitor.x + monitor.width)
221         dist_x = x - (monitor.x + monitor.width) + 1;
222       else
223         dist_x = 0;
224
225       if (y < monitor.y)
226         dist_y = monitor.y - y;
227       else if (y >= monitor.y + monitor.height)
228         dist_y = y - (monitor.y + monitor.height) + 1;
229       else
230         dist_y = 0;
231
232       dist = dist_x + dist_y;
233       if (dist < nearest_dist)
234         {
235           nearest_dist = dist;
236           nearest_monitor = i;
237         }
238     }
239
240   return nearest_monitor;
241 }
242
243 /**
244  * gdk_screen_get_monitor_at_point:
245  * @screen: a #GdkScreen.
246  * @x: the x coordinate in the virtual screen.
247  * @y: the y coordinate in the virtual screen.
248  *
249  * Returns the monitor number in which the point (@x,@y) is located.
250  *
251  * Returns: the monitor number in which the point (@x,@y) lies, or
252  *   a monitor close to (@x,@y) if the point is not in any monitor.
253  *
254  * Since: 2.2
255  **/
256 gint 
257 gdk_screen_get_monitor_at_point (GdkScreen *screen,
258                                  gint       x,
259                                  gint       y)
260 {
261   gint num_monitors, i;
262   
263   g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
264
265   num_monitors = gdk_screen_get_n_monitors (screen);
266   
267   for (i=0;i<num_monitors;i++)
268     {
269       GdkRectangle monitor;
270       
271       gdk_screen_get_monitor_geometry (screen, i, &monitor);
272
273       if (x >= monitor.x &&
274           x < monitor.x + monitor.width &&
275           y >= monitor.y &&
276           y < (monitor.y + monitor.height))
277         return i;
278     }
279
280   return get_nearest_monitor (screen, x, y);
281 }
282
283 /**
284  * gdk_screen_get_monitor_at_window:
285  * @screen: a #GdkScreen.
286  * @window: a #GdkWindow
287  * @returns: the monitor number in which most of @window is located,
288  *           or if @window does not intersect any monitors, a monitor,
289  *           close to @window.
290  *
291  * Returns the number of the monitor in which the largest area of the 
292  * bounding rectangle of @window resides.
293  *
294  * Since: 2.2
295  **/
296 gint 
297 gdk_screen_get_monitor_at_window (GdkScreen      *screen,
298                                   GdkWindow      *window)
299 {
300   gint num_monitors, i, area = 0, screen_num = -1;
301   GdkRectangle win_rect;
302
303   g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
304
305   gdk_window_get_geometry (window, &win_rect.x, &win_rect.y, &win_rect.width,
306                            &win_rect.height);
307   gdk_window_get_origin (window, &win_rect.x, &win_rect.y);
308   num_monitors = gdk_screen_get_n_monitors (screen);
309   
310   for (i=0;i<num_monitors;i++)
311     {
312       GdkRectangle tmp_monitor, intersect;
313       
314       gdk_screen_get_monitor_geometry (screen, i, &tmp_monitor);
315       gdk_rectangle_intersect (&win_rect, &tmp_monitor, &intersect);
316       
317       if (intersect.width * intersect.height > area)
318         { 
319           area = intersect.width * intersect.height;
320           screen_num = i;
321         }
322     }
323   if (screen_num >= 0)
324     return screen_num;
325   else
326     return get_nearest_monitor (screen,
327                                 win_rect.x + win_rect.width / 2,
328                                 win_rect.y + win_rect.height / 2);
329 }
330
331 /**
332  * gdk_screen_width:
333  * 
334  * Returns the width of the default screen in pixels.
335  * 
336  * Return value: the width of the default screen in pixels.
337  **/
338 gint
339 gdk_screen_width (void)
340 {
341   return gdk_screen_get_width (gdk_screen_get_default ());
342 }
343
344 /**
345  * gdk_screen_height:
346  * 
347  * Returns the height of the default screen in pixels.
348  * 
349  * Return value: the height of the default screen in pixels.
350  **/
351 gint
352 gdk_screen_height (void)
353 {
354   return gdk_screen_get_height (gdk_screen_get_default ());
355 }
356
357 /**
358  * gdk_screen_width_mm:
359  * 
360  * Returns the width of the default screen in millimeters.
361  * Note that on many X servers this value will not be correct.
362  * 
363  * Return value: the width of the default screen in millimeters,
364  * though it is not always correct.
365  **/
366 gint
367 gdk_screen_width_mm (void)
368 {
369   return gdk_screen_get_width_mm (gdk_screen_get_default ());
370 }
371
372 /**
373  * gdk_screen_height_mm:
374  * 
375  * Returns the height of the default screen in millimeters.
376  * Note that on many X servers this value will not be correct.
377  * 
378  * Return value: the height of the default screen in millimeters,
379  * though it is not always correct.
380  **/
381 gint
382 gdk_screen_height_mm (void)
383 {
384   return gdk_screen_get_height_mm (gdk_screen_get_default ());
385 }
386
387 /**
388  * gdk_screen_set_font_options:
389  * @screen: a #GdkScreen
390  * @options: (allow-none): a #cairo_font_options_t, or %NULL to unset any
391  *   previously set default font options.
392  *
393  * Sets the default font options for the screen. These
394  * options will be set on any #PangoContext's newly created
395  * with gdk_pango_context_get_for_screen(). Changing the
396  * default set of font options does not affect contexts that
397  * have already been created.
398  *
399  * Since: 2.10
400  **/
401 void
402 gdk_screen_set_font_options (GdkScreen                  *screen,
403                              const cairo_font_options_t *options)
404 {
405   g_return_if_fail (GDK_IS_SCREEN (screen));
406
407   if (screen->font_options != options)
408     {
409       if (screen->font_options)
410         cairo_font_options_destroy (screen->font_options);
411
412       if (options)
413         screen->font_options = cairo_font_options_copy (options);
414       else
415         screen->font_options = NULL;
416
417       g_object_notify (G_OBJECT (screen), "font-options");
418     }
419 }
420
421 /**
422  * gdk_screen_get_font_options:
423  * @screen: a #GdkScreen
424  * 
425  * Gets any options previously set with gdk_screen_set_font_options().
426  * 
427  * Return value: the current font options, or %NULL if no default
428  *  font options have been set.
429  *
430  * Since: 2.10
431  **/
432 const cairo_font_options_t *
433 gdk_screen_get_font_options (GdkScreen *screen)
434 {
435   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
436
437   return screen->font_options;
438 }
439
440 /**
441  * gdk_screen_set_resolution:
442  * @screen: a #GdkScreen
443  * @dpi: the resolution in "dots per inch". (Physical inches aren't actually
444  *   involved; the terminology is conventional.)
445  
446  * Sets the resolution for font handling on the screen. This is a
447  * scale factor between points specified in a #PangoFontDescription
448  * and cairo units. The default value is 96, meaning that a 10 point
449  * font will be 13 units high. (10 * 96. / 72. = 13.3).
450  *
451  * Since: 2.10
452  **/
453 void
454 gdk_screen_set_resolution (GdkScreen *screen,
455                            gdouble    dpi)
456 {
457   g_return_if_fail (GDK_IS_SCREEN (screen));
458
459   if (dpi < 0)
460     dpi = -1.0;
461
462   if (screen->resolution != dpi)
463     {
464       screen->resolution = dpi;
465
466       g_object_notify (G_OBJECT (screen), "resolution");
467     }
468 }
469
470 /**
471  * gdk_screen_get_resolution:
472  * @screen: a #GdkScreen
473  * 
474  * Gets the resolution for font handling on the screen; see
475  * gdk_screen_set_resolution() for full details.
476  * 
477  * Return value: the current resolution, or -1 if no resolution
478  * has been set.
479  *
480  * Since: 2.10
481  **/
482 gdouble
483 gdk_screen_get_resolution (GdkScreen *screen)
484 {
485   g_return_val_if_fail (GDK_IS_SCREEN (screen), -1.0);
486
487   return screen->resolution;
488 }
489
490 static void
491 gdk_screen_get_property (GObject      *object,
492                          guint         prop_id,
493                          GValue       *value,
494                          GParamSpec   *pspec)
495 {
496   GdkScreen *screen = GDK_SCREEN (object);
497
498   switch (prop_id)
499     {
500     case PROP_FONT_OPTIONS:
501       g_value_set_pointer (value, (gpointer) gdk_screen_get_font_options (screen));
502       break;
503     case PROP_RESOLUTION:
504       g_value_set_double (value, gdk_screen_get_resolution (screen));
505       break;
506     default:
507       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
508       break;
509     }
510 }
511
512 static void
513 gdk_screen_set_property (GObject      *object,
514                          guint         prop_id,
515                          const GValue *value,
516                          GParamSpec   *pspec)
517 {
518   GdkScreen *screen = GDK_SCREEN (object);
519
520   switch (prop_id)
521     {
522     case PROP_FONT_OPTIONS:
523       gdk_screen_set_font_options (screen, g_value_get_pointer (value));
524       break;
525     case PROP_RESOLUTION:
526       gdk_screen_set_resolution (screen, g_value_get_double (value));
527       break;
528     default:
529       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
530       break;
531     }
532 }
533
534 /**
535  * gdk_screen_get_display:
536  * @screen: a #GdkScreen
537  *
538  * Gets the display to which the @screen belongs.
539  *
540  * Returns: (transfer none): the display to which @screen belongs
541  *
542  * Since: 2.2
543  **/
544 GdkDisplay *
545 gdk_screen_get_display (GdkScreen *screen)
546 {
547   return GDK_SCREEN_GET_CLASS(screen)->get_display (screen);
548 }
549
550
551 /**
552  * gdk_screen_get_width:
553  * @screen: a #GdkScreen
554  *
555  * Gets the width of @screen in pixels
556  *
557  * Returns: the width of @screen in pixels.
558  *
559  * Since: 2.2
560  **/
561 gint
562 gdk_screen_get_width (GdkScreen *screen)
563 {
564   return GDK_SCREEN_GET_CLASS(screen)->get_width (screen);
565 }
566
567 /**
568  * gdk_screen_get_height:
569  * @screen: a #GdkScreen
570  *
571  * Gets the height of @screen in pixels
572  *
573  * Returns: the height of @screen in pixels.
574  *
575  * Since: 2.2
576  **/
577 gint
578 gdk_screen_get_height (GdkScreen *screen)
579 {
580   return GDK_SCREEN_GET_CLASS(screen)->get_height (screen);
581 }
582
583 /**
584  * gdk_screen_get_width_mm:
585  * @screen: a #GdkScreen
586  *
587  * Gets the width of @screen in millimeters.
588  * Note that on some X servers this value will not be correct.
589  *
590  * Returns: the width of @screen in millimeters.
591  *
592  * Since: 2.2
593  **/
594 gint
595 gdk_screen_get_width_mm (GdkScreen *screen)
596 {
597   return GDK_SCREEN_GET_CLASS(screen)->get_width_mm (screen);
598 }
599
600 /**
601  * gdk_screen_get_height_mm:
602  * @screen: a #GdkScreen
603  *
604  * Returns the height of @screen in millimeters.
605  * Note that on some X servers this value will not be correct.
606  *
607  * Returns: the heigth of @screen in millimeters.
608  *
609  * Since: 2.2
610  **/
611 gint
612 gdk_screen_get_height_mm (GdkScreen *screen)
613 {
614   return GDK_SCREEN_GET_CLASS(screen)->get_height_mm (screen);
615 }
616
617 /**
618  * gdk_screen_get_number:
619  * @screen: a #GdkScreen
620  *
621  * Gets the index of @screen among the screens in the display
622  * to which it belongs. (See gdk_screen_get_display())
623  *
624  * Returns: the index
625  *
626  * Since: 2.2
627  **/
628 gint
629 gdk_screen_get_number (GdkScreen *screen)
630 {
631   return GDK_SCREEN_GET_CLASS(screen)->get_number (screen);
632 }
633
634 /**
635  * gdk_screen_get_root_window:
636  * @screen: a #GdkScreen
637  *
638  * Gets the root window of @screen.
639  *
640  * Returns: (transfer none): the root window
641  *
642  * Since: 2.2
643  **/
644 GdkWindow *
645 gdk_screen_get_root_window (GdkScreen *screen)
646 {
647   return GDK_SCREEN_GET_CLASS(screen)->get_root_window (screen);
648 }
649
650 /**
651  * gdk_screen_get_n_monitors:
652  * @screen: a #GdkScreen
653  *
654  * Returns the number of monitors which @screen consists of.
655  *
656  * Returns: number of monitors which @screen consists of
657  *
658  * Since: 2.2
659  */
660 gint
661 gdk_screen_get_n_monitors (GdkScreen *screen)
662 {
663   return GDK_SCREEN_GET_CLASS(screen)->get_n_monitors (screen);
664 }
665
666 /**
667  * gdk_screen_get_primary_monitor:
668  * @screen: a #GdkScreen.
669  *
670  * Gets the primary monitor for @screen.  The primary monitor
671  * is considered the monitor where the 'main desktop' lives.
672  * While normal application windows typically allow the window
673  * manager to place the windows, specialized desktop applications
674  * such as panels should place themselves on the primary monitor.
675  *
676  * If no primary monitor is configured by the user, the return value
677  * will be 0, defaulting to the first monitor.
678  *
679  * Returns: An integer index for the primary monitor, or 0 if none is configured.
680  *
681  * Since: 2.20
682  */
683 gint
684 gdk_screen_get_primary_monitor (GdkScreen *screen)
685 {
686   return GDK_SCREEN_GET_CLASS(screen)->get_primary_monitor (screen);
687 }
688
689 /**
690  * gdk_screen_get_monitor_width_mm:
691  * @screen: a #GdkScreen
692  * @monitor_num: number of the monitor, between 0 and gdk_screen_get_n_monitors (screen)
693  *
694  * Gets the width in millimeters of the specified monitor, if available.
695  *
696  * Returns: the width of the monitor, or -1 if not available
697  *
698  * Since: 2.14
699  */
700 gint
701 gdk_screen_get_monitor_width_mm (GdkScreen *screen,
702                                  gint       monitor_num)
703 {
704   return GDK_SCREEN_GET_CLASS(screen)->get_monitor_width_mm (screen, monitor_num);
705 }
706
707 /**
708  * gdk_screen_get_monitor_height_mm:
709  * @screen: a #GdkScreen
710  * @monitor_num: number of the monitor, between 0 and gdk_screen_get_n_monitors (screen)
711  *
712  * Gets the height in millimeters of the specified monitor.
713  *
714  * Returns: the height of the monitor, or -1 if not available
715  *
716  * Since: 2.14
717  */
718 gint
719 gdk_screen_get_monitor_height_mm (GdkScreen *screen,
720                                   gint       monitor_num)
721 {
722   return GDK_SCREEN_GET_CLASS(screen)->get_monitor_height_mm (screen, monitor_num);
723 }
724
725 /**
726  * gdk_screen_get_monitor_plug_name:
727  * @screen: a #GdkScreen
728  * @monitor_num: number of the monitor, between 0 and gdk_screen_get_n_monitors (screen)
729  *
730  * Returns the output name of the specified monitor.
731  * Usually something like VGA, DVI, or TV, not the actual
732  * product name of the display device.
733  *
734  * Returns: a newly-allocated string containing the name of the monitor,
735  *   or %NULL if the name cannot be determined
736  *
737  * Since: 2.14
738  */
739 gchar *
740 gdk_screen_get_monitor_plug_name (GdkScreen *screen,
741                                   gint       monitor_num)
742 {
743   return GDK_SCREEN_GET_CLASS(screen)->get_monitor_plug_name (screen, monitor_num);
744 }
745
746 /**
747  * gdk_screen_get_monitor_geometry:
748  * @screen: a #GdkScreen
749  * @monitor_num: the monitor number, between 0 and gdk_screen_get_n_monitors (screen)
750  * @dest: (out) (allow-none): a #GdkRectangle to be filled with the monitor geometry
751  *
752  * Retrieves the #GdkRectangle representing the size and position of
753  * the individual monitor within the entire screen area.
754  *
755  * Note that the size of the entire screen area can be retrieved via
756  * gdk_screen_get_width() and gdk_screen_get_height().
757  *
758  * Since: 2.2
759  */
760 void
761 gdk_screen_get_monitor_geometry (GdkScreen    *screen,
762                                  gint          monitor_num,
763                                  GdkRectangle *dest)
764 {
765   GDK_SCREEN_GET_CLASS(screen)->get_monitor_geometry (screen, monitor_num, dest);
766 }
767
768 /**
769  * gdk_screen_list_visuals:
770  * @screen: the relevant #GdkScreen.
771  *
772  * Lists the available visuals for the specified @screen.
773  * A visual describes a hardware image data format.
774  * For example, a visual might support 24-bit color, or 8-bit color,
775  * and might expect pixels to be in a certain format.
776  *
777  * Call g_list_free() on the return value when you're finished with it.
778  *
779  * Return value: (transfer container) (element-type GdkVisual):
780  *     a list of visuals; the list must be freed, but not its contents
781  *
782  * Since: 2.2
783  **/
784 GList *
785 gdk_screen_list_visuals (GdkScreen *screen)
786 {
787   return GDK_SCREEN_GET_CLASS(screen)->list_visuals (screen);
788 }
789
790 /**
791  * gdk_screen_get_system_visual:
792  * @screen: a #GdkScreen.
793  *
794  * Get the system's default visual for @screen.
795  * This is the visual for the root window of the display.
796  * The return value should not be freed.
797  *
798  * Return value: (transfer none): the system visual
799  *
800  * Since: 2.2
801  **/
802 GdkVisual *
803 gdk_screen_get_system_visual (GdkScreen * screen)
804 {
805   return GDK_SCREEN_GET_CLASS(screen)->get_system_visual (screen);
806 }
807
808 /**
809  * gdk_screen_get_rgba_visual:
810  * @screen: a #GdkScreen
811  *
812  * Gets a visual to use for creating windows with an alpha channel.
813  * The windowing system on which GTK+ is running
814  * may not support this capability, in which case %NULL will
815  * be returned. Even if a non-%NULL value is returned, its
816  * possible that the window's alpha channel won't be honored
817  * when displaying the window on the screen: in particular, for
818  * X an appropriate windowing manager and compositing manager
819  * must be running to provide appropriate display.
820  *
821  * This functionality is not implemented in the Windows backend.
822  *
823  * For setting an overall opacity for a top-level window, see
824  * gdk_window_set_opacity().
825  *
826  * Return value: (transfer none): a visual to use for windows with an
827  *     alpha channel or %NULL if the capability is not available.
828  *
829  * Since: 2.8
830  **/
831 GdkVisual *
832 gdk_screen_get_rgba_visual (GdkScreen *screen)
833 {
834   return GDK_SCREEN_GET_CLASS(screen)->get_rgba_visual (screen);
835 }
836
837 /**
838  * gdk_screen_is_composited:
839  * @screen: a #GdkScreen
840  *
841  * Returns whether windows with an RGBA visual can reasonably
842  * be expected to have their alpha channel drawn correctly on
843  * the screen.
844  *
845  * On X11 this function returns whether a compositing manager is
846  * compositing @screen.
847  *
848  * Return value: Whether windows with RGBA visuals can reasonably be
849  * expected to have their alpha channels drawn correctly on the screen.
850  *
851  * Since: 2.10
852  **/
853 gboolean
854 gdk_screen_is_composited (GdkScreen *screen)
855 {
856   return GDK_SCREEN_GET_CLASS(screen)->is_composited (screen);
857 }
858
859 /**
860  * gdk_screen_make_display_name:
861  * @screen: a #GdkScreen
862  *
863  * Determines the name to pass to gdk_display_open() to get
864  * a #GdkDisplay with this screen as the default screen.
865  *
866  * Return value: a newly allocated string, free with g_free()
867  *
868  * Since: 2.2
869  **/
870 gchar *
871 gdk_screen_make_display_name (GdkScreen *screen)
872 {
873   return GDK_SCREEN_GET_CLASS(screen)->make_display_name (screen);
874 }
875
876 /**
877  * gdk_screen_get_active_window:
878  * @screen: a #GdkScreen
879  *
880  * Returns the screen's currently active window.
881  *
882  * On X11, this is done by inspecting the _NET_ACTIVE_WINDOW property
883  * on the root window, as described in the <ulink
884  * url="http://www.freedesktop.org/Standards/wm-spec">Extended Window
885  * Manager Hints</ulink>. If there is no currently currently active
886  * window, or the window manager does not support the
887  * _NET_ACTIVE_WINDOW hint, this function returns %NULL.
888  *
889  * On other platforms, this function may return %NULL, depending on whether
890  * it is implementable on that platform.
891  *
892  * The returned window should be unrefed using g_object_unref() when
893  * no longer needed.
894  *
895  * Return value: (transfer full): the currently active window, or %NULL.
896  *
897  * Since: 2.10
898  **/
899 GdkWindow *
900 gdk_screen_get_active_window (GdkScreen *screen)
901 {
902   return GDK_SCREEN_GET_CLASS(screen)->get_active_window (screen);
903 }
904
905 /**
906  * gdk_screen_get_window_stack:
907  * @screen: a #GdkScreen
908  *
909  * Returns a #GList of #GdkWindow<!-- -->s representing the current
910  * window stack.
911  *
912  * On X11, this is done by inspecting the _NET_CLIENT_LIST_STACKING
913  * property on the root window, as described in the <ulink
914  * url="http://www.freedesktop.org/Standards/wm-spec">Extended Window
915  * Manager Hints</ulink>. If the window manager does not support the
916  * _NET_CLIENT_LIST_STACKING hint, this function returns %NULL.
917  *
918  * On other platforms, this function may return %NULL, depending on whether
919  * it is implementable on that platform.
920  *
921  * The returned list is newly allocated and owns references to the
922  * windows it contains, so it should be freed using g_list_free() and
923  * its windows unrefed using g_object_unref() when no longer needed.
924  *
925  * Return value: (transfer full) (element-type GdkWindow):
926  *     a list of #GdkWindow<!-- -->s for the current window stack,
927  *               or %NULL.
928  *
929  * Since: 2.10
930  **/
931 GList *
932 gdk_screen_get_window_stack (GdkScreen *screen)
933 {
934   return GDK_SCREEN_GET_CLASS(screen)->get_window_stack (screen);
935 }
936
937 /**
938  * gdk_screen_broadcast_client_message:
939  * @screen: the #GdkScreen where the event will be broadcasted.
940  * @event: the #GdkEvent.
941  *
942  * On X11, sends an X ClientMessage event to all toplevel windows on
943  * @screen.
944  *
945  * Toplevel windows are determined by checking for the WM_STATE property,
946  * as described in the Inter-Client Communication Conventions Manual (ICCCM).
947  * If no windows are found with the WM_STATE property set, the message is
948  * sent to all children of the root window.
949  *
950  * On Windows, broadcasts a message registered with the name
951  * GDK_WIN32_CLIENT_MESSAGE to all top-level windows. The amount of
952  * data is limited to one long, i.e. four bytes.
953  *
954  * Since: 2.2
955  */
956 void
957 gdk_screen_broadcast_client_message (GdkScreen *screen,
958                                      GdkEvent  *event)
959 {
960   return GDK_SCREEN_GET_CLASS(screen)->broadcast_client_message (screen, event);
961 }
962
963 /**
964  * gdk_screen_get_setting:
965  * @screen: the #GdkScreen where the setting is located
966  * @name: the name of the setting
967  * @value: location to store the value of the setting
968  *
969  * Retrieves a desktop-wide setting such as double-click time
970  * for the #GdkScreen @screen.
971  *
972  * FIXME needs a list of valid settings here, or a link to
973  * more information.
974  *
975  * Returns: %TRUE if the setting existed and a value was stored
976  *   in @value, %FALSE otherwise.
977  *
978  * Since: 2.2
979  **/
980 gboolean
981 gdk_screen_get_setting (GdkScreen   *screen,
982                         const gchar *name,
983                         GValue      *value)
984 {
985   return GDK_SCREEN_GET_CLASS(screen)->get_setting (screen, name, value);
986 }