* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
+#include "config.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
+#include "gdkx.h"
#include "gdkvisual.h"
#include "gdkprivate-x11.h"
#include "gdkscreen-x11.h"
#include "gdkinternals.h"
+
struct _GdkVisualClass
{
GObjectClass parent_class;
#ifdef G_ENABLE_DEBUG
-static const gchar* visual_names[] =
+static const gchar *const visual_names[] =
{
"static gray",
"grayscale",
#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)
{
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),
};
object_type = g_type_register_static (G_TYPE_OBJECT,
- "GdkVisual",
+ g_intern_static_string ("GdkVisual"),
&object_info, 0);
}
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,
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);
}
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)
/**
* 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)
* 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)
* 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)
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;
}
* 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)
*
* 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,
/**
* 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
/**
* 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.
*
* 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)
}
/**
- * gdk_x11_screen_lookup_visual
+ * gdk_x11_screen_lookup_visual:
* @screen: a #GdkScreen.
* @xvisualid: an X Visual ID.
*
*
* 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,
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);
}
*shift = 0;
*prec = 0;
+ if (mask == 0)
+ {
+ g_warning ("Mask is 0 in visual. Server bug ?");
+ return;
+ }
+
while (!(mask & 0x1))
{
(*shift)++;
*
* 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)