3 * Copyright (C) 2005 Imendio AB
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
23 #include "gdkvisual.h"
24 #include "gdkprivate-quartz.h"
26 /* FIXME: We might want to include the rgba visual in the query functions */
28 static GdkVisual *system_visual;
29 static GdkVisual *rgba_visual;
32 gdk_visual_finalize (GObject *object)
34 g_error ("A GdkVisual object was finalized. This should not happen");
38 gdk_visual_class_init (GObjectClass *class)
40 class->finalize = gdk_visual_finalize;
44 gdk_visual_get_type (void)
46 static GType object_type = 0;
50 const GTypeInfo object_info =
52 sizeof (GdkVisualClass),
54 (GBaseFinalizeFunc) NULL,
55 (GClassInitFunc) gdk_visual_class_init,
56 NULL, /* class_finalize */
57 NULL, /* class_data */
60 (GInstanceInitFunc) NULL,
63 object_type = g_type_register_static (G_TYPE_OBJECT,
72 gdk_visual_decompose_mask (gulong mask,
93 create_standard_visual (gint depth)
95 GdkVisual *visual = g_object_new (GDK_TYPE_VISUAL, NULL);
97 visual->depth = depth;
98 visual->byte_order = GDK_MSB_FIRST; /* FIXME: Should this be different on intel macs? */
99 visual->colormap_size = 0;
101 visual->type = GDK_VISUAL_TRUE_COLOR;
103 visual->red_mask = 0xff0000;
104 visual->green_mask = 0xff00;
105 visual->blue_mask = 0xff;
107 gdk_visual_decompose_mask (visual->red_mask,
110 gdk_visual_decompose_mask (visual->green_mask,
111 &visual->green_shift,
112 &visual->green_prec);
113 gdk_visual_decompose_mask (visual->blue_mask,
121 _gdk_visual_init (void)
123 system_visual = create_standard_visual (24);
124 rgba_visual = create_standard_visual (32);
128 gdk_visual_get_best_depth (void)
130 return system_visual->depth;
134 gdk_visual_get_best_type (void)
136 return system_visual->type;
140 gdk_screen_get_rgba_visual (GdkScreen *screen)
142 g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
148 gdk_screen_get_system_visual (GdkScreen *screen)
150 return system_visual;
154 gdk_visual_get_best (void)
156 return system_visual;
160 gdk_visual_get_best_with_depth (gint depth)
162 if (system_visual->depth != depth)
165 return system_visual;
169 gdk_visual_get_best_with_type (GdkVisualType visual_type)
171 if (system_visual->type != visual_type)
174 return system_visual;
178 gdk_visual_get_best_with_both (gint depth,
179 GdkVisualType visual_type)
181 if (system_visual->depth != depth)
184 if (system_visual->type != visual_type)
187 return system_visual;
191 gdk_query_depths (gint **depths,
195 *depths = &system_visual->depth;
199 gdk_query_visual_types (GdkVisualType **visual_types,
203 *visual_types = &system_visual->type;
207 gdk_screen_list_visuals (GdkScreen *screen)
209 return g_list_append (NULL, gdk_visual_get_system ());
213 gdk_visual_get_screen (GdkVisual *visual)
215 g_return_val_if_fail (GDK_IS_VISUAL (visual), NULL);
217 return gdk_screen_get_default ();