]> Pileus Git - ~andy/gtk/blob - gdk/gdkscreen.c
stylecontext: Do invalidation on first resize container
[~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, see <http://www.gnu.org/licenses/>.
20  */
21
22 #include "config.h"
23
24 #include "gdkinternals.h"
25 #include "gdkscreenprivate.h"
26 #include "gdkrectangle.h"
27 #include "gdkwindow.h"
28 #include "gdkintl.h"
29
30
31 /**
32  * SECTION:gdkscreen
33  * @Short_description: Object representing a physical screen
34  * @Title: GdkScreen
35  *
36  * #GdkScreen objects are the GDK representation of the screen on
37  * which windows can be displayed and on which the pointer moves.
38  * X originally identified screens with physical screens, but
39  * nowadays it is more common to have a single #GdkScreen which
40  * combines several physical monitors (see gdk_screen_get_n_monitors()).
41  *
42  * GdkScreen is used throughout GDK and GTK+ to specify which screen
43  * the top level windows are to be displayed on. it is also used to
44  * query the screen specification and default settings such as
45  * the default visual (gdk_screen_get_system_visual()), the dimensions
46  * of the physical monitors (gdk_screen_get_monitor_geometry()), etc.
47  */
48
49
50 static void gdk_screen_finalize     (GObject        *object);
51 static void gdk_screen_set_property (GObject        *object,
52                                      guint           prop_id,
53                                      const GValue   *value,
54                                      GParamSpec     *pspec);
55 static void gdk_screen_get_property (GObject        *object,
56                                      guint           prop_id,
57                                      GValue         *value,
58                                      GParamSpec     *pspec);
59
60 enum
61 {
62   PROP_0,
63   PROP_FONT_OPTIONS,
64   PROP_RESOLUTION
65 };
66
67 enum
68 {
69   SIZE_CHANGED,
70   COMPOSITED_CHANGED,
71   MONITORS_CHANGED,
72   LAST_SIGNAL
73 };
74
75 static guint signals[LAST_SIGNAL] = { 0 };
76
77 G_DEFINE_TYPE (GdkScreen, gdk_screen, G_TYPE_OBJECT)
78
79 static void
80 gdk_screen_class_init (GdkScreenClass *klass)
81 {
82   GObjectClass *object_class = G_OBJECT_CLASS (klass);
83
84   object_class->finalize = gdk_screen_finalize;
85   object_class->set_property = gdk_screen_set_property;
86   object_class->get_property = gdk_screen_get_property;
87   
88   g_object_class_install_property (object_class,
89                                    PROP_FONT_OPTIONS,
90                                    g_param_spec_pointer ("font-options",
91                                                          P_("Font options"),
92                                                          P_("The default font options for the screen"),
93                                                          G_PARAM_READWRITE|G_PARAM_STATIC_NAME|
94                                                         G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
95
96   g_object_class_install_property (object_class,
97                                    PROP_RESOLUTION,
98                                    g_param_spec_double ("resolution",
99                                                         P_("Font resolution"),
100                                                         P_("The resolution for fonts on the screen"),
101                                                         -G_MAXDOUBLE,
102                                                         G_MAXDOUBLE,
103                                                         -1.0,
104                                                         G_PARAM_READWRITE|G_PARAM_STATIC_NAME|
105                                                         G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
106
107   /**
108    * GdkScreen::size-changed:
109    * @screen: the object on which the signal is emitted
110    * 
111    * The ::size-changed signal is emitted when the pixel width or 
112    * height of a screen changes.
113    *
114    * Since: 2.2
115    */
116   signals[SIZE_CHANGED] =
117     g_signal_new (g_intern_static_string ("size-changed"),
118                   G_OBJECT_CLASS_TYPE (klass),
119                   G_SIGNAL_RUN_LAST,
120                   G_STRUCT_OFFSET (GdkScreenClass, size_changed),
121                   NULL, NULL,
122                   g_cclosure_marshal_VOID__VOID,
123                   G_TYPE_NONE,
124                   0);
125
126   /**
127    * GdkScreen::composited-changed:
128    * @screen: the object on which the signal is emitted
129    *
130    * The ::composited-changed signal is emitted when the composited
131    * status of the screen changes
132    *
133    * Since: 2.10
134    */
135   signals[COMPOSITED_CHANGED] =
136     g_signal_new (g_intern_static_string ("composited-changed"),
137                   G_OBJECT_CLASS_TYPE (klass),
138                   G_SIGNAL_RUN_LAST,
139                   G_STRUCT_OFFSET (GdkScreenClass, composited_changed),
140                   NULL, NULL,
141                   g_cclosure_marshal_VOID__VOID,
142                   G_TYPE_NONE,
143                   0);
144         
145   /**
146    * GdkScreen::monitors-changed:
147    * @screen: the object on which the signal is emitted
148    *
149    * The ::monitors-changed signal is emitted when the number, size
150    * or position of the monitors attached to the screen change. 
151    *
152    * Only for X11 and OS X for now. A future implementation for Win32
153    * may be a possibility.
154    *
155    * Since: 2.14
156    */
157   signals[MONITORS_CHANGED] =
158     g_signal_new (g_intern_static_string ("monitors-changed"),
159                   G_OBJECT_CLASS_TYPE (klass),
160                   G_SIGNAL_RUN_LAST,
161                   G_STRUCT_OFFSET (GdkScreenClass, monitors_changed),
162                   NULL, NULL,
163                   g_cclosure_marshal_VOID__VOID,
164                   G_TYPE_NONE,
165                   0);
166 }
167
168 static void
169 gdk_screen_init (GdkScreen *screen)
170 {
171   screen->resolution = -1.;
172 }
173
174 static void
175 gdk_screen_finalize (GObject *object)
176 {
177   GdkScreen *screen = GDK_SCREEN (object);
178
179   if (screen->font_options)
180       cairo_font_options_destroy (screen->font_options);
181
182   G_OBJECT_CLASS (gdk_screen_parent_class)->finalize (object);
183 }
184
185 void 
186 _gdk_screen_close (GdkScreen *screen)
187 {
188   g_return_if_fail (GDK_IS_SCREEN (screen));
189
190   if (!screen->closed)
191     {
192       screen->closed = TRUE;
193       g_object_run_dispose (G_OBJECT (screen));
194     }
195 }
196
197 /* Fallback used when the monitor "at" a point or window
198  * doesn't exist.
199  */
200 static gint
201 get_nearest_monitor (GdkScreen *screen,
202                      gint       x,
203                      gint       y)
204 {
205   gint num_monitors, i;
206   gint nearest_dist = G_MAXINT;
207   gint nearest_monitor = 0;
208
209   g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
210
211   num_monitors = gdk_screen_get_n_monitors (screen);
212   
213   for (i = 0; i < num_monitors; i++)
214     {
215       GdkRectangle monitor;
216       gint dist_x, dist_y, dist;
217       
218       gdk_screen_get_monitor_geometry (screen, i, &monitor);
219
220       if (x < monitor.x)
221         dist_x = monitor.x - x;
222       else if (x >= monitor.x + monitor.width)
223         dist_x = x - (monitor.x + monitor.width) + 1;
224       else
225         dist_x = 0;
226
227       if (y < monitor.y)
228         dist_y = monitor.y - y;
229       else if (y >= monitor.y + monitor.height)
230         dist_y = y - (monitor.y + monitor.height) + 1;
231       else
232         dist_y = 0;
233
234       dist = dist_x + dist_y;
235       if (dist < nearest_dist)
236         {
237           nearest_dist = dist;
238           nearest_monitor = i;
239         }
240     }
241
242   return nearest_monitor;
243 }
244
245 /**
246  * gdk_screen_get_monitor_at_point:
247  * @screen: a #GdkScreen.
248  * @x: the x coordinate in the virtual screen.
249  * @y: the y coordinate in the virtual screen.
250  *
251  * Returns the monitor number in which the point (@x,@y) is located.
252  *
253  * Returns: the monitor number in which the point (@x,@y) lies, or
254  *   a monitor close to (@x,@y) if the point is not in any monitor.
255  *
256  * Since: 2.2
257  **/
258 gint 
259 gdk_screen_get_monitor_at_point (GdkScreen *screen,
260                                  gint       x,
261                                  gint       y)
262 {
263   gint num_monitors, i;
264   
265   g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
266
267   num_monitors = gdk_screen_get_n_monitors (screen);
268   
269   for (i=0;i<num_monitors;i++)
270     {
271       GdkRectangle monitor;
272       
273       gdk_screen_get_monitor_geometry (screen, i, &monitor);
274
275       if (x >= monitor.x &&
276           x < monitor.x + monitor.width &&
277           y >= monitor.y &&
278           y < (monitor.y + monitor.height))
279         return i;
280     }
281
282   return get_nearest_monitor (screen, x, y);
283 }
284
285 /**
286  * gdk_screen_get_monitor_at_window:
287  * @screen: a #GdkScreen.
288  * @window: a #GdkWindow
289  *
290  * Returns the number of the monitor in which the largest area of the
291  * bounding rectangle of @window resides.
292  *
293  * Returns: the monitor number in which most of @window is located,
294  *     or if @window does not intersect any monitors, a monitor,
295  *     close to @window.
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   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
551
552   return GDK_SCREEN_GET_CLASS (screen)->get_display (screen);
553 }
554
555
556 /**
557  * gdk_screen_get_width:
558  * @screen: a #GdkScreen
559  *
560  * Gets the width of @screen in pixels
561  *
562  * Returns: the width of @screen in pixels.
563  *
564  * Since: 2.2
565  **/
566 gint
567 gdk_screen_get_width (GdkScreen *screen)
568 {
569   g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
570
571   return GDK_SCREEN_GET_CLASS (screen)->get_width (screen);
572 }
573
574 /**
575  * gdk_screen_get_height:
576  * @screen: a #GdkScreen
577  *
578  * Gets the height of @screen in pixels
579  *
580  * Returns: the height of @screen in pixels.
581  *
582  * Since: 2.2
583  **/
584 gint
585 gdk_screen_get_height (GdkScreen *screen)
586 {
587   g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
588
589   return GDK_SCREEN_GET_CLASS (screen)->get_height (screen);
590 }
591
592 /**
593  * gdk_screen_get_width_mm:
594  * @screen: a #GdkScreen
595  *
596  * Gets the width of @screen in millimeters.
597  * Note that on some X servers this value will not be correct.
598  *
599  * Returns: the width of @screen in millimeters.
600  *
601  * Since: 2.2
602  **/
603 gint
604 gdk_screen_get_width_mm (GdkScreen *screen)
605 {
606   g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
607
608   return GDK_SCREEN_GET_CLASS (screen)->get_width_mm (screen);
609 }
610
611 /**
612  * gdk_screen_get_height_mm:
613  * @screen: a #GdkScreen
614  *
615  * Returns the height of @screen in millimeters.
616  * Note that on some X servers this value will not be correct.
617  *
618  * Returns: the heigth of @screen in millimeters.
619  *
620  * Since: 2.2
621  **/
622 gint
623 gdk_screen_get_height_mm (GdkScreen *screen)
624 {
625   g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
626
627   return GDK_SCREEN_GET_CLASS (screen)->get_height_mm (screen);
628 }
629
630 /**
631  * gdk_screen_get_number:
632  * @screen: a #GdkScreen
633  *
634  * Gets the index of @screen among the screens in the display
635  * to which it belongs. (See gdk_screen_get_display())
636  *
637  * Returns: the index
638  *
639  * Since: 2.2
640  **/
641 gint
642 gdk_screen_get_number (GdkScreen *screen)
643 {
644   g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
645
646   return GDK_SCREEN_GET_CLASS (screen)->get_number (screen);
647 }
648
649 /**
650  * gdk_screen_get_root_window:
651  * @screen: a #GdkScreen
652  *
653  * Gets the root window of @screen.
654  *
655  * Returns: (transfer none): the root window
656  *
657  * Since: 2.2
658  **/
659 GdkWindow *
660 gdk_screen_get_root_window (GdkScreen *screen)
661 {
662   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
663
664   return GDK_SCREEN_GET_CLASS (screen)->get_root_window (screen);
665 }
666
667 /**
668  * gdk_screen_get_n_monitors:
669  * @screen: a #GdkScreen
670  *
671  * Returns the number of monitors which @screen consists of.
672  *
673  * Returns: number of monitors which @screen consists of
674  *
675  * Since: 2.2
676  */
677 gint
678 gdk_screen_get_n_monitors (GdkScreen *screen)
679 {
680   g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
681
682   return GDK_SCREEN_GET_CLASS (screen)->get_n_monitors (screen);
683 }
684
685 /**
686  * gdk_screen_get_primary_monitor:
687  * @screen: a #GdkScreen.
688  *
689  * Gets the primary monitor for @screen.  The primary monitor
690  * is considered the monitor where the 'main desktop' lives.
691  * While normal application windows typically allow the window
692  * manager to place the windows, specialized desktop applications
693  * such as panels should place themselves on the primary monitor.
694  *
695  * If no primary monitor is configured by the user, the return value
696  * will be 0, defaulting to the first monitor.
697  *
698  * Returns: An integer index for the primary monitor, or 0 if none is configured.
699  *
700  * Since: 2.20
701  */
702 gint
703 gdk_screen_get_primary_monitor (GdkScreen *screen)
704 {
705   g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
706
707   return GDK_SCREEN_GET_CLASS (screen)->get_primary_monitor (screen);
708 }
709
710 /**
711  * gdk_screen_get_monitor_width_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 width in millimeters of the specified monitor, if available.
716  *
717  * Returns: the width of the monitor, or -1 if not available
718  *
719  * Since: 2.14
720  */
721 gint
722 gdk_screen_get_monitor_width_mm (GdkScreen *screen,
723                                  gint       monitor_num)
724 {
725   g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
726   g_return_val_if_fail (monitor_num >= 0, -1);
727   g_return_val_if_fail (monitor_num < gdk_screen_get_n_monitors (screen), -1);
728
729   return GDK_SCREEN_GET_CLASS (screen)->get_monitor_width_mm (screen, monitor_num);
730 }
731
732 /**
733  * gdk_screen_get_monitor_height_mm:
734  * @screen: a #GdkScreen
735  * @monitor_num: number of the monitor, between 0 and gdk_screen_get_n_monitors (screen)
736  *
737  * Gets the height in millimeters of the specified monitor.
738  *
739  * Returns: the height of the monitor, or -1 if not available
740  *
741  * Since: 2.14
742  */
743 gint
744 gdk_screen_get_monitor_height_mm (GdkScreen *screen,
745                                   gint       monitor_num)
746 {
747   g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
748   g_return_val_if_fail (monitor_num >= 0, -1);
749   g_return_val_if_fail (monitor_num < gdk_screen_get_n_monitors (screen), -1);
750
751   return GDK_SCREEN_GET_CLASS (screen)->get_monitor_height_mm (screen, monitor_num);
752 }
753
754 /**
755  * gdk_screen_get_monitor_plug_name:
756  * @screen: a #GdkScreen
757  * @monitor_num: number of the monitor, between 0 and gdk_screen_get_n_monitors (screen)
758  *
759  * Returns the output name of the specified monitor.
760  * Usually something like VGA, DVI, or TV, not the actual
761  * product name of the display device.
762  *
763  * Returns: a newly-allocated string containing the name of the monitor,
764  *   or %NULL if the name cannot be determined
765  *
766  * Since: 2.14
767  */
768 gchar *
769 gdk_screen_get_monitor_plug_name (GdkScreen *screen,
770                                   gint       monitor_num)
771 {
772   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
773   g_return_val_if_fail (monitor_num >= 0, NULL);
774   g_return_val_if_fail (monitor_num < gdk_screen_get_n_monitors (screen), NULL);
775
776   return GDK_SCREEN_GET_CLASS (screen)->get_monitor_plug_name (screen, monitor_num);
777 }
778
779 /**
780  * gdk_screen_get_monitor_geometry:
781  * @screen: a #GdkScreen
782  * @monitor_num: the monitor number
783  * @dest: (out) (allow-none): a #GdkRectangle to be filled with
784  *     the monitor geometry
785  *
786  * Retrieves the #GdkRectangle representing the size and position of
787  * the individual monitor within the entire screen area.
788  *
789  * Monitor numbers start at 0. To obtain the number of monitors of
790  * @screen, use gdk_screen_get_n_monitors().
791  *
792  * Note that the size of the entire screen area can be retrieved via
793  * gdk_screen_get_width() and gdk_screen_get_height().
794  *
795  * Since: 2.2
796  */
797 void
798 gdk_screen_get_monitor_geometry (GdkScreen    *screen,
799                                  gint          monitor_num,
800                                  GdkRectangle *dest)
801 {
802   g_return_if_fail (GDK_IS_SCREEN (screen));
803   g_return_if_fail (monitor_num >= 0);
804   g_return_if_fail (monitor_num < gdk_screen_get_n_monitors (screen));
805
806   GDK_SCREEN_GET_CLASS(screen)->get_monitor_geometry (screen, monitor_num, dest);
807 }
808
809 /**
810  * gdk_screen_get_monitor_workarea:
811  * @screen: a #GdkScreen
812  * @monitor_num: the monitor number
813  * @dest: (out) (allow-none): a #GdkRectangle to be filled with
814  *     the monitor workarea
815  *
816  * Retrieves the #GdkRectangle representing the size and position of
817  * the "work area" on a monitor within the entire screen area.
818  *
819  * The work area should be considered when positioning menus and
820  * similar popups, to avoid placing them below panels, docks or other
821  * desktop components.
822  *
823  * Monitor numbers start at 0. To obtain the number of monitors of
824  * @screen, use gdk_screen_get_n_monitors().
825  *
826  * Since: 3.4
827  */
828 void
829 gdk_screen_get_monitor_workarea (GdkScreen    *screen,
830                                  gint          monitor_num,
831                                  GdkRectangle *dest)
832 {
833   g_return_if_fail (GDK_IS_SCREEN (screen));
834   g_return_if_fail (monitor_num >= 0);
835   g_return_if_fail (monitor_num < gdk_screen_get_n_monitors (screen));
836
837   GDK_SCREEN_GET_CLASS (screen)->get_monitor_workarea (screen, monitor_num, dest);
838 }
839
840 /**
841  * gdk_screen_list_visuals:
842  * @screen: the relevant #GdkScreen.
843  *
844  * Lists the available visuals for the specified @screen.
845  * A visual describes a hardware image data format.
846  * For example, a visual might support 24-bit color, or 8-bit color,
847  * and might expect pixels to be in a certain format.
848  *
849  * Call g_list_free() on the return value when you're finished with it.
850  *
851  * Return value: (transfer container) (element-type GdkVisual):
852  *     a list of visuals; the list must be freed, but not its contents
853  *
854  * Since: 2.2
855  **/
856 GList *
857 gdk_screen_list_visuals (GdkScreen *screen)
858 {
859   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
860
861   return GDK_SCREEN_GET_CLASS (screen)->list_visuals (screen);
862 }
863
864 /**
865  * gdk_screen_get_system_visual:
866  * @screen: a #GdkScreen.
867  *
868  * Get the system's default visual for @screen.
869  * This is the visual for the root window of the display.
870  * The return value should not be freed.
871  *
872  * Return value: (transfer none): the system visual
873  *
874  * Since: 2.2
875  **/
876 GdkVisual *
877 gdk_screen_get_system_visual (GdkScreen * screen)
878 {
879   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
880
881   return GDK_SCREEN_GET_CLASS (screen)->get_system_visual (screen);
882 }
883
884 /**
885  * gdk_screen_get_rgba_visual:
886  * @screen: a #GdkScreen
887  *
888  * Gets a visual to use for creating windows with an alpha channel.
889  * The windowing system on which GTK+ is running
890  * may not support this capability, in which case %NULL will
891  * be returned. Even if a non-%NULL value is returned, its
892  * possible that the window's alpha channel won't be honored
893  * when displaying the window on the screen: in particular, for
894  * X an appropriate windowing manager and compositing manager
895  * must be running to provide appropriate display.
896  *
897  * This functionality is not implemented in the Windows backend.
898  *
899  * For setting an overall opacity for a top-level window, see
900  * gdk_window_set_opacity().
901  *
902  * Return value: (transfer none): a visual to use for windows with an
903  *     alpha channel or %NULL if the capability is not available.
904  *
905  * Since: 2.8
906  **/
907 GdkVisual *
908 gdk_screen_get_rgba_visual (GdkScreen *screen)
909 {
910   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
911
912   return GDK_SCREEN_GET_CLASS (screen)->get_rgba_visual (screen);
913 }
914
915 /**
916  * gdk_screen_is_composited:
917  * @screen: a #GdkScreen
918  *
919  * Returns whether windows with an RGBA visual can reasonably
920  * be expected to have their alpha channel drawn correctly on
921  * the screen.
922  *
923  * On X11 this function returns whether a compositing manager is
924  * compositing @screen.
925  *
926  * Return value: Whether windows with RGBA visuals can reasonably be
927  * expected to have their alpha channels drawn correctly on the screen.
928  *
929  * Since: 2.10
930  **/
931 gboolean
932 gdk_screen_is_composited (GdkScreen *screen)
933 {
934   g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
935
936   return GDK_SCREEN_GET_CLASS (screen)->is_composited (screen);
937 }
938
939 /**
940  * gdk_screen_make_display_name:
941  * @screen: a #GdkScreen
942  *
943  * Determines the name to pass to gdk_display_open() to get
944  * a #GdkDisplay with this screen as the default screen.
945  *
946  * Return value: a newly allocated string, free with g_free()
947  *
948  * Since: 2.2
949  **/
950 gchar *
951 gdk_screen_make_display_name (GdkScreen *screen)
952 {
953   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
954
955   return GDK_SCREEN_GET_CLASS (screen)->make_display_name (screen);
956 }
957
958 /**
959  * gdk_screen_get_active_window:
960  * @screen: a #GdkScreen
961  *
962  * Returns the screen's currently active window.
963  *
964  * On X11, this is done by inspecting the _NET_ACTIVE_WINDOW property
965  * on the root window, as described in the <ulink
966  * url="http://www.freedesktop.org/Standards/wm-spec">Extended Window
967  * Manager Hints</ulink>. If there is no currently currently active
968  * window, or the window manager does not support the
969  * _NET_ACTIVE_WINDOW hint, this function returns %NULL.
970  *
971  * On other platforms, this function may return %NULL, depending on whether
972  * it is implementable on that platform.
973  *
974  * The returned window should be unrefed using g_object_unref() when
975  * no longer needed.
976  *
977  * Return value: (transfer full): the currently active window, or %NULL.
978  *
979  * Since: 2.10
980  **/
981 GdkWindow *
982 gdk_screen_get_active_window (GdkScreen *screen)
983 {
984   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
985
986   return GDK_SCREEN_GET_CLASS (screen)->get_active_window (screen);
987 }
988
989 /**
990  * gdk_screen_get_window_stack:
991  * @screen: a #GdkScreen
992  *
993  * Returns a #GList of #GdkWindow<!-- -->s representing the current
994  * window stack.
995  *
996  * On X11, this is done by inspecting the _NET_CLIENT_LIST_STACKING
997  * property on the root window, as described in the <ulink
998  * url="http://www.freedesktop.org/Standards/wm-spec">Extended Window
999  * Manager Hints</ulink>. If the window manager does not support the
1000  * _NET_CLIENT_LIST_STACKING hint, this function returns %NULL.
1001  *
1002  * On other platforms, this function may return %NULL, depending on whether
1003  * it is implementable on that platform.
1004  *
1005  * The returned list is newly allocated and owns references to the
1006  * windows it contains, so it should be freed using g_list_free() and
1007  * its windows unrefed using g_object_unref() when no longer needed.
1008  *
1009  * Return value: (transfer full) (element-type GdkWindow):
1010  *     a list of #GdkWindow<!-- -->s for the current window stack,
1011  *               or %NULL.
1012  *
1013  * Since: 2.10
1014  **/
1015 GList *
1016 gdk_screen_get_window_stack (GdkScreen *screen)
1017 {
1018   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
1019
1020   return GDK_SCREEN_GET_CLASS (screen)->get_window_stack (screen);
1021 }
1022
1023 /**
1024  * gdk_screen_get_setting:
1025  * @screen: the #GdkScreen where the setting is located
1026  * @name: the name of the setting
1027  * @value: location to store the value of the setting
1028  *
1029  * Retrieves a desktop-wide setting such as double-click time
1030  * for the #GdkScreen @screen.
1031  *
1032  * FIXME needs a list of valid settings here, or a link to
1033  * more information.
1034  *
1035  * Returns: %TRUE if the setting existed and a value was stored
1036  *   in @value, %FALSE otherwise.
1037  *
1038  * Since: 2.2
1039  **/
1040 gboolean
1041 gdk_screen_get_setting (GdkScreen   *screen,
1042                         const gchar *name,
1043                         GValue      *value)
1044 {
1045   g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
1046   g_return_val_if_fail (name != NULL, FALSE);
1047   g_return_val_if_fail (value != NULL, FALSE);
1048
1049   return GDK_SCREEN_GET_CLASS (screen)->get_setting (screen, name, value);
1050 }