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