1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
27 #include "gdkvisual.h"
28 #include "gdkprivate-fb.h"
29 #include "gdkinternals.h"
31 static GdkVisual *system_visual = NULL;
34 gdk_visual_init (void)
36 system_visual = g_new0 (GdkVisual, 1);
38 system_visual->depth = system_visual->bits_per_rgb = gdk_display->modeinfo.bits_per_pixel;
39 system_visual->byte_order = GDK_LSB_FIRST;
40 system_visual->colormap_size = 0;
42 switch (gdk_display->sinfo.visual)
44 case FB_VISUAL_PSEUDOCOLOR:
45 system_visual->colormap_size = 1 << gdk_display->modeinfo.bits_per_pixel;
46 system_visual->type = GDK_VISUAL_PSEUDO_COLOR;
48 case FB_VISUAL_DIRECTCOLOR:
49 system_visual->colormap_size = 1 << gdk_display->modeinfo.bits_per_pixel;
50 system_visual->type = GDK_VISUAL_DIRECT_COLOR;
52 case FB_VISUAL_TRUECOLOR:
53 if (gdk_display->sinfo.visual == FB_VISUAL_TRUECOLOR)
54 system_visual->type = GDK_VISUAL_TRUE_COLOR;
56 system_visual->red_prec = gdk_display->modeinfo.red.length;
57 system_visual->red_shift = gdk_display->modeinfo.red.offset;
58 system_visual->red_mask = ((1 << (system_visual->red_prec)) - 1) << system_visual->red_shift;
60 system_visual->green_prec = gdk_display->modeinfo.green.length;
61 system_visual->green_shift = gdk_display->modeinfo.green.offset;
62 system_visual->green_mask = ((1 << (system_visual->green_prec)) - 1) << system_visual->green_shift;
64 system_visual->blue_prec = gdk_display->modeinfo.blue.length;
65 system_visual->blue_shift = gdk_display->modeinfo.blue.offset;
66 system_visual->blue_mask = ((1 << (system_visual->blue_prec)) - 1) << system_visual->blue_shift;
68 case FB_VISUAL_STATIC_PSEUDOCOLOR:
69 system_visual->type = GDK_VISUAL_STATIC_COLOR;
70 system_visual->colormap_size = 1 << gdk_display->modeinfo.bits_per_pixel;
73 g_assert_not_reached ();
79 gdk_visual_ref (GdkVisual *visual)
85 gdk_visual_unref (GdkVisual *visual)
90 gdk_visual_get_best_depth (void)
92 return system_visual->depth;
96 gdk_visual_get_best_type (void)
98 return system_visual->type;
102 gdk_visual_get_system (void)
104 return system_visual;
108 gdk_visual_get_best (void)
110 return system_visual;
114 gdk_visual_get_best_with_depth (gint depth)
116 if (system_visual->depth != depth)
119 return system_visual;
123 gdk_visual_get_best_with_type (GdkVisualType visual_type)
125 if (system_visual->type != visual_type)
128 return system_visual;
132 gdk_visual_get_best_with_both (gint depth,
133 GdkVisualType visual_type)
135 if (system_visual->depth != depth)
138 if (system_visual->type != visual_type)
141 return system_visual;
145 gdk_query_depths (gint **depths,
149 *depths = &system_visual->depth;
153 gdk_query_visual_types (GdkVisualType **visual_types,
157 *visual_types = &system_visual->type;
161 gdk_list_visuals (void)
163 return g_list_append (NULL, gdk_visual_get_system ());