X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gdk%2Fx11%2Fgdkvisual-x11.c;h=2183294bdbbb2928f930511b01c3411f11e6e411;hb=404e7d0e0013355549578db5c3981943f536c2b9;hp=7de7912216360dc22bc63ebcb7653dfa591a4cb0;hpb=f900039c8f0562119aa7e66105155449a07ab721;p=~andy%2Fgtk diff --git a/gdk/x11/gdkvisual-x11.c b/gdk/x11/gdkvisual-x11.c index 7de791221..2183294bd 100644 --- a/gdk/x11/gdkvisual-x11.c +++ b/gdk/x11/gdkvisual-x11.c @@ -24,14 +24,17 @@ * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ +#include "config.h" #include #include +#include "gdkx.h" #include "gdkvisual.h" #include "gdkprivate-x11.h" #include "gdkscreen-x11.h" #include "gdkinternals.h" + struct _GdkVisualClass { GObjectClass parent_class; @@ -48,7 +51,7 @@ static gboolean gdk_visual_equal (Visual *a, #ifdef G_ENABLE_DEBUG -static const gchar* visual_names[] = +static const gchar *const visual_names[] = { "static gray", "grayscale", @@ -60,19 +63,6 @@ static const gchar* visual_names[] = #endif /* G_ENABLE_DEBUG */ -static void -gdk_visual_finalize (GObject *object) -{ - g_error ("A GdkVisual object was finalized. This should not happen"); -} - -static void -gdk_visual_class_init (GObjectClass *class) -{ - class->finalize = gdk_visual_finalize; -} - - GType gdk_visual_get_type (void) { @@ -80,12 +70,12 @@ gdk_visual_get_type (void) if (!object_type) { - static const GTypeInfo object_info = + const GTypeInfo object_info = { sizeof (GdkVisualClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gdk_visual_class_init, + (GClassInitFunc) NULL, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (GdkVisualPrivate), @@ -94,7 +84,7 @@ gdk_visual_get_type (void) }; object_type = g_type_register_static (G_TYPE_OBJECT, - "GdkVisual", + g_intern_static_string ("GdkVisual"), &object_info, 0); } @@ -105,7 +95,7 @@ gdk_visual_get_type (void) void _gdk_visual_init (GdkScreen *screen) { - static const gint possible_depths[7] = { 32, 24, 16, 15, 8, 4, 1 }; + static const gint possible_depths[8] = { 32, 30, 24, 16, 15, 8, 4, 1 }; static const GdkVisualType possible_types[6] = { GDK_VISUAL_DIRECT_COLOR, @@ -129,6 +119,7 @@ _gdk_visual_init (GdkScreen *screen) g_return_if_fail (GDK_IS_SCREEN (screen)); screen_x11 = GDK_SCREEN_X11 (screen); + nxvisuals = 0; visual_template.screen = screen_x11->screen_num; visual_list = XGetVisualInfo (screen_x11->xdisplay, VisualScreenMask, &visual_template, &nxvisuals); @@ -254,11 +245,22 @@ _gdk_visual_init (GdkScreen *screen) } for (i = 0; i < nvisuals; i++) - if (default_xvisual->visualid == visuals[i]->xvisual->visualid) - { + { + if (default_xvisual->visualid == visuals[i]->xvisual->visualid) screen_x11->system_visual = visuals[i]; - break; - } + + /* For now, we only support 8888 ARGB for the "rgba visual". + * Additional formats (like ABGR) could be added later if they + * turn up. + */ + if (visuals[i]->visual.depth == 32 && + (visuals[i]->visual.red_mask == 0xff0000 && + visuals[i]->visual.green_mask == 0x00ff00 && + visuals[i]->visual.blue_mask == 0x0000ff)) + { + screen_x11->rgba_visual = GDK_VISUAL (visuals[i]); + } + } #ifdef G_ENABLE_DEBUG if (_gdk_debug_flags & GDK_DEBUG_MISC) @@ -341,13 +343,15 @@ gdk_visual_get_best_type (void) /** * gdk_screen_get_system_visual: - * @screen : a #GdkScreen. + * @screen: a #GdkScreen. * * Get the system's default visual for @screen. * This is the visual for the root window of the display. * The return value should not be freed. * - * Return value: system visual + * Return value: (transfer none): the system visual + * + * Since: 2.2 **/ GdkVisual * gdk_screen_get_system_visual (GdkScreen * screen) @@ -363,7 +367,7 @@ gdk_screen_get_system_visual (GdkScreen * screen) * Get the visual with the most available colors for the default * GDK screen. The return value should not be freed. * - * Return value: best visual + * Return value: (transfer none): best visual **/ GdkVisual* gdk_visual_get_best (void) @@ -382,7 +386,7 @@ gdk_visual_get_best (void) * over grayscale or fixed-colormap visuals. The return value should not * be freed. %NULL may be returned if no visual supports @depth. * - * Return value: best visual for the given depth + * Return value: (transfer none): best visual for the given depth **/ GdkVisual* gdk_visual_get_best_with_depth (gint depth) @@ -395,7 +399,7 @@ gdk_visual_get_best_with_depth (gint depth) for (i = 0; i < screen_x11->nvisuals; i++) if (depth == screen_x11->visuals[i]->visual.depth) { - return_val = (GdkVisual *) & (screen_x11->visuals[i]); + return_val = (GdkVisual *) screen_x11->visuals[i]; break; } @@ -411,7 +415,7 @@ gdk_visual_get_best_with_depth (gint depth) * should not be freed. %NULL may be returned if no visual has type * @visual_type. * - * Return value: best visual of the given type + * Return value: (transfer none): best visual of the given type **/ GdkVisual* gdk_visual_get_best_with_type (GdkVisualType visual_type) @@ -438,7 +442,8 @@ gdk_visual_get_best_with_type (GdkVisualType visual_type) * * Combines gdk_visual_get_best_with_depth() and gdk_visual_get_best_with_type(). * - * Return value: best visual with both @depth and @visual_type, or %NULL if none + * Return value: (transfer none): best visual with both @depth and + * @visual_type, or %NULL if none **/ GdkVisual* gdk_visual_get_best_with_both (gint depth, @@ -462,8 +467,8 @@ gdk_visual_get_best_with_both (gint depth, /** * gdk_query_depths: - * @depths: return location for available depths - * @count: return location for number of available depths + * @depths: (out) (array): return location for available depths + * @count: (out): return location for number of available depths * * This function returns the available bit depths for the default * screen. It's equivalent to listing the visuals @@ -507,7 +512,7 @@ gdk_query_visual_types (GdkVisualType **visual_types, /** * gdk_screen_list_visuals: - * @screen : the relevant #GdkScreen. + * @screen: the relevant #GdkScreen. * * Lists the available visuals for the specified @screen. * A visual describes a hardware image data format. @@ -516,7 +521,10 @@ gdk_query_visual_types (GdkVisualType **visual_types, * * Call g_list_free() on the return value when you're finished with it. * - * Return value: a list of visuals; the list must be freed, but not its contents + * Return value: a list of visuals; the list must be freed, but not its + * contents + * + * Since: 2.2 **/ GList * gdk_screen_list_visuals (GdkScreen *screen) @@ -537,7 +545,7 @@ gdk_screen_list_visuals (GdkScreen *screen) } /** - * gdk_x11_screen_lookup_visual + * gdk_x11_screen_lookup_visual: * @screen: a #GdkScreen. * @xvisualid: an X Visual ID. * @@ -545,6 +553,8 @@ gdk_screen_list_visuals (GdkScreen *screen) * * Returns: the #GdkVisual (owned by the screen object), or %NULL * if the visual ID wasn't found. + * + * Since: 2.2 */ GdkVisual * gdk_x11_screen_lookup_visual (GdkScreen *screen, @@ -584,7 +594,7 @@ gdk_visual_add (GdkVisual *visual) if (!screen_x11->visual_hash) screen_x11->visual_hash = g_hash_table_new ((GHashFunc) gdk_visual_hash, - (GEqualFunc) gdk_visual_equal); + (GEqualFunc) gdk_visual_equal); g_hash_table_insert (screen_x11->visual_hash, private->xvisual, visual); } @@ -597,6 +607,12 @@ gdk_visual_decompose_mask (gulong mask, *shift = 0; *prec = 0; + if (mask == 0) + { + g_warning ("Mask is 0 in visual. Server bug ?"); + return; + } + while (!(mask & 0x1)) { (*shift)++; @@ -645,7 +661,9 @@ gdk_x11_visual_get_xvisual (GdkVisual *visual) * * Gets the screen to which this visual belongs * - * Return value: the screen to which this visual belongs. + * Return value: (transfer none): the screen to which this visual belongs. + * + * Since: 2.2 **/ GdkScreen * gdk_visual_get_screen (GdkVisual *visual)