2000-05-31 21:50:38 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
2000-05-31 21:50:38 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
2000-05-31 21:50:38 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2000-05-31 21:50:38 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
2000-05-31 21:50:38 +00:00
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gdkvisual.h"
|
|
|
|
#include "gdkprivate-fb.h"
|
|
|
|
#include "gdkinternals.h"
|
|
|
|
|
|
|
|
static GdkVisual *system_visual = NULL;
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_visual_init (void)
|
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
system_visual = g_new0 (GdkVisual, 1);
|
2000-05-31 21:50:38 +00:00
|
|
|
|
|
|
|
system_visual->depth = system_visual->bits_per_rgb = gdk_display->modeinfo.bits_per_pixel;
|
|
|
|
system_visual->byte_order = GDK_LSB_FIRST;
|
|
|
|
system_visual->colormap_size = 0;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
switch (gdk_display->sinfo.visual)
|
2000-05-31 21:50:38 +00:00
|
|
|
{
|
|
|
|
case FB_VISUAL_PSEUDOCOLOR:
|
|
|
|
system_visual->colormap_size = 1 << gdk_display->modeinfo.bits_per_pixel;
|
|
|
|
system_visual->type = GDK_VISUAL_PSEUDO_COLOR;
|
|
|
|
break;
|
|
|
|
case FB_VISUAL_DIRECTCOLOR:
|
2001-05-04 21:41:17 +00:00
|
|
|
/* TODO: Should load the colormap to ramps here, as they might be initialized to
|
|
|
|
some other garbage */
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
/* Fall through */
|
2000-05-31 21:50:38 +00:00
|
|
|
case FB_VISUAL_TRUECOLOR:
|
2001-05-04 21:41:17 +00:00
|
|
|
system_visual->type = GDK_VISUAL_TRUE_COLOR;
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2000-06-20 20:20:38 +00:00
|
|
|
system_visual->red_prec = gdk_display->modeinfo.red.length;
|
|
|
|
system_visual->red_shift = gdk_display->modeinfo.red.offset;
|
|
|
|
system_visual->red_mask = ((1 << (system_visual->red_prec)) - 1) << system_visual->red_shift;
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2000-06-20 20:20:38 +00:00
|
|
|
system_visual->green_prec = gdk_display->modeinfo.green.length;
|
|
|
|
system_visual->green_shift = gdk_display->modeinfo.green.offset;
|
|
|
|
system_visual->green_mask = ((1 << (system_visual->green_prec)) - 1) << system_visual->green_shift;
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2000-06-20 20:20:38 +00:00
|
|
|
system_visual->blue_prec = gdk_display->modeinfo.blue.length;
|
|
|
|
system_visual->blue_shift = gdk_display->modeinfo.blue.offset;
|
|
|
|
system_visual->blue_mask = ((1 << (system_visual->blue_prec)) - 1) << system_visual->blue_shift;
|
2000-05-31 21:50:38 +00:00
|
|
|
break;
|
|
|
|
case FB_VISUAL_STATIC_PSEUDOCOLOR:
|
|
|
|
system_visual->type = GDK_VISUAL_STATIC_COLOR;
|
|
|
|
system_visual->colormap_size = 1 << gdk_display->modeinfo.bits_per_pixel;
|
|
|
|
break;
|
|
|
|
default:
|
2000-11-13 17:40:23 +00:00
|
|
|
g_assert_not_reached ();
|
2000-05-31 21:50:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkVisual*
|
|
|
|
gdk_visual_ref (GdkVisual *visual)
|
|
|
|
{
|
|
|
|
return visual;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_visual_unref (GdkVisual *visual)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_visual_get_best_depth (void)
|
|
|
|
{
|
|
|
|
return system_visual->depth;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkVisualType
|
|
|
|
gdk_visual_get_best_type (void)
|
|
|
|
{
|
|
|
|
return system_visual->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkVisual*
|
|
|
|
gdk_visual_get_system (void)
|
|
|
|
{
|
|
|
|
return system_visual;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkVisual*
|
|
|
|
gdk_visual_get_best (void)
|
|
|
|
{
|
|
|
|
return system_visual;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkVisual*
|
|
|
|
gdk_visual_get_best_with_depth (gint depth)
|
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
if (system_visual->depth != depth)
|
2000-05-31 21:50:38 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return system_visual;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkVisual*
|
|
|
|
gdk_visual_get_best_with_type (GdkVisualType visual_type)
|
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
if (system_visual->type != visual_type)
|
2000-05-31 21:50:38 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return system_visual;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkVisual*
|
|
|
|
gdk_visual_get_best_with_both (gint depth,
|
|
|
|
GdkVisualType visual_type)
|
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
if (system_visual->depth != depth)
|
2000-05-31 21:50:38 +00:00
|
|
|
return NULL;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (system_visual->type != visual_type)
|
2000-05-31 21:50:38 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return system_visual;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_query_depths (gint **depths,
|
|
|
|
gint *count)
|
|
|
|
{
|
|
|
|
*count = 1;
|
|
|
|
*depths = &system_visual->depth;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_query_visual_types (GdkVisualType **visual_types,
|
|
|
|
gint *count)
|
|
|
|
{
|
|
|
|
*count = 1;
|
|
|
|
*visual_types = &system_visual->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
GList*
|
|
|
|
gdk_list_visuals (void)
|
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
return g_list_append (NULL, gdk_visual_get_system ());
|
2000-05-31 21:50:38 +00:00
|
|
|
}
|