Back to index

kdeartwork  4.3.2
Functions
xs_visual.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Visual * get_visual (Screen *, const char *name, Bool, Bool)
Visual * get_visual_resource (Screen *, char *, char *, Bool)
int visual_depth (Screen *, Visual *)
int visual_class (Screen *, Visual *)
int visual_cells (Screen *, Visual *)
int screen_number (Screen *)
Visual * find_similar_visual (Screen *, Visual *old)
void describe_visual (FILE *f, Screen *, Visual *, Bool private_cmap_p)
Visual * get_overlay_visual (Screen *, unsigned long *pixel_return)
Bool has_writable_cells (Screen *screen, Visual *visual)

Function Documentation

void describe_visual ( FILE *  f,
Screen ,
Visual *  ,
Bool  private_cmap_p 
)

Definition at line 378 of file xs_visual.c.

{
  char n[10];
  Display *dpy = DisplayOfScreen (screen);
  XVisualInfo vi_in, *vi_out;
  int out_count;
  vi_in.screen = screen_number (screen);
  vi_in.visualid = XVisualIDFromVisual (visual);
  vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualIDMask),
                        &vi_in, &out_count);
  if (! vi_out) abort ();
  if (private_cmap_p)
    sprintf(n, "%3d", vi_out->colormap_size);
  else
    strcpy(n, "default");

  fprintf (f, "0x%02x (%s depth: %2d, cmap: %s)\n",
          (unsigned int) vi_out->visualid,
          (vi_out->class == StaticGray  ? "StaticGray, " :
           vi_out->class == StaticColor ? "StaticColor," :
           vi_out->class == TrueColor   ? "TrueColor,  " :
           vi_out->class == GrayScale   ? "GrayScale,  " :
           vi_out->class == PseudoColor ? "PseudoColor," :
           vi_out->class == DirectColor ? "DirectColor," :
                                      "UNKNOWN:    "),
          vi_out->depth, n);
  XFree ((char *) vi_out);
}

Here is the call graph for this function:

Visual* find_similar_visual ( Screen ,
Visual *  old 
)

Definition at line 435 of file xs_visual.c.

{
  Display *dpy = DisplayOfScreen (screen);
  XVisualInfo vi_in, *vi_out;
  Visual *result = 0;
  int out_count;

  vi_in.screen = screen_number (screen);
  vi_in.class  = visual_class (screen, old_visual);
  vi_in.depth  = visual_depth (screen, old_visual);

  /* Look for a visual of the same class and depth.
   */
  vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualClassMask |
                             VisualDepthMask),
                        &vi_in, &out_count);
  if (vi_out && out_count > 0)
    result = vi_out[0].visual;
  if (vi_out) XFree (vi_out);
  vi_out = 0;

  /* Failing that, look for a visual of the same class.
   */
  if (!result)
    {
      vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualClassMask),
                            &vi_in, &out_count);
      if (vi_out && out_count > 0)
       result = vi_out[0].visual;
      if (vi_out) XFree (vi_out);
      vi_out = 0;
    }

  /* Failing that, return the default visual. */
  if (!result)
    result = DefaultVisualOfScreen (screen);

  return result;
}

Here is the call graph for this function:

Visual* get_overlay_visual ( Screen ,
unsigned long *  pixel_return 
)
Visual* get_visual ( Screen ,
const char *  name,
Bool  ,
Bool   
)

Definition at line 50 of file xs_visual.c.

{
  char *v = (string ? strdup(string) : 0);
  char c, *tmp;
  int vclass;
  unsigned long id;
  Visual *result = 0;

  if (v)
    for (tmp = v; *tmp; tmp++)
      if (isupper (*tmp)) *tmp = _tolower (*tmp);

  if (!v)                                   vclass = BEST_VISUAL;
  else if (!strcmp (v, "default"))          vclass = DEFAULT_VISUAL;
  else if (!strcmp (v, "best"))             vclass = BEST_VISUAL;
  else if (!strcmp (v, "mono"))             vclass = MONO_VISUAL;
  else if (!strcmp (v, "monochrome"))              vclass = MONO_VISUAL;
  else if (!strcmp (v, "gray"))             vclass = GRAY_VISUAL;
  else if (!strcmp (v, "grey"))             vclass = GRAY_VISUAL;
  else if (!strcmp (v, "color"))            vclass = COLOR_VISUAL;
  else if (!strcmp (v, "staticgray"))              vclass = StaticGray;
  else if (!strcmp (v, "staticcolor"))             vclass = StaticColor;
  else if (!strcmp (v, "truecolor"))               vclass = TrueColor;
  else if (!strcmp (v, "grayscale"))               vclass = GrayScale;
  else if (!strcmp (v, "greyscale"))               vclass = GrayScale;
  else if (!strcmp (v, "pseudocolor"))             vclass = PseudoColor;
  else if (!strcmp (v, "directcolor"))             vclass = DirectColor;
  else if (1 == sscanf (v, " %ld %c", &id, &c))    vclass = SPECIFIC_VISUAL;
  else if (1 == sscanf (v, " 0x%lx %c", &id, &c)) vclass = SPECIFIC_VISUAL;
  else
    {
      fprintf (stderr, "%s: unrecognized visual \"%s\".\n", "kscreensaver", v);
      vclass = DEFAULT_VISUAL;
    }

  if (vclass == DEFAULT_VISUAL)
    result = DefaultVisualOfScreen (screen);
  else if (vclass == BEST_VISUAL)
    result = pick_best_visual (screen, prefer_writable_cells, False);
  else if (vclass == MONO_VISUAL)
    {
      result = pick_mono_visual (screen);
      if (!result && verbose_p)
       fprintf (stderr, "%s: no monochrome visuals.\n", "kscreensaver");
    }
  else if (vclass == GRAY_VISUAL)
    {
      if (prefer_writable_cells)
       result = pick_best_visual_of_class (screen, GrayScale);
      if (!result)
       result = pick_best_visual_of_class (screen, StaticGray);
      if (!result)
       result = pick_best_visual_of_class (screen, GrayScale);
      if (!result && verbose_p)
       fprintf (stderr, "%s: no GrayScale or StaticGray visuals.\n",
               "kscreensaver");
    }
  else if (vclass == COLOR_VISUAL)
    {
      int class;
      /* First see if the default visual will do. */
      result = DefaultVisualOfScreen (screen);
      class = visual_class(screen, result);
      if (class != TrueColor &&
         class != PseudoColor &&
         class != DirectColor &&
         class != StaticColor)
       result = 0;
      if (result && visual_depth(screen, result) <= 1)
       result = 0;

      /* Else, find the best non-default color visual */
      if (!result)
       result = pick_best_visual (screen, prefer_writable_cells, True);

      if (!result && verbose_p)
       fprintf (stderr, "%s: no color visuals.\n", "kscreensaver");
    }
  else if (vclass == SPECIFIC_VISUAL)
    {
      result = id_to_visual (screen, id);
      if (!result && verbose_p)
       fprintf (stderr, "%s: no visual with id 0x%x.\n", "kscreensaver",
               (unsigned int) id);
    }
  else
    {
      Visual *visual = pick_best_visual_of_class (screen, vclass);
      if (visual)
       result = visual;
      else if (verbose_p)
       fprintf (stderr, "%s: no visual of class %s.\n", "kscreensaver", v);
    }

  if (v) free (v);
  return result;
}

Here is the call graph for this function:

Visual* get_visual_resource ( Screen ,
char *  ,
char *  ,
Bool   
)

Definition at line 150 of file xs_visual.c.

{
/*
  char *string = get_string_resource (name, class);
  Visual *v = get_visual (screen, string, prefer_writable_cells, True);
  if (string)
    free(string);
  if (v)
    return v;
  else
*/
    return DefaultVisualOfScreen (screen);
}
Bool has_writable_cells ( Screen screen,
Visual *  visual 
)

Definition at line 358 of file xs_visual.c.

{
  switch (visual_class (screen, visual))
    {
    case GrayScale:  /* Mappable grays. */
    case PseudoColor:       /* Mappable colors. */
      return True;
    case StaticGray: /* Fixed grays. */
    case TrueColor:  /* Fixed colors. */
    case StaticColor:       /* (What's the difference again?) */
    case DirectColor:       /* DirectColor visuals are like TrueColor, but have
                        three colormaps - one for each component of RGB.
                        Screw it. */
      return False;
    default:
      abort();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int screen_number ( Screen )

Definition at line 408 of file xs_visual.c.

{
  Display *dpy = DisplayOfScreen (screen);
  int i;
  for (i = 0; i < ScreenCount (dpy); i++)
    if (ScreenOfDisplay (dpy, i) == screen)
      return i;
  abort ();
}

Here is the caller graph for this function:

int visual_cells ( Screen ,
Visual *   
)

Definition at line 419 of file xs_visual.c.

{
  Display *dpy = DisplayOfScreen (screen);
  XVisualInfo vi_in, *vi_out;
  int out_count, c;
  vi_in.screen = screen_number (screen);
  vi_in.visualid = XVisualIDFromVisual (visual);
  vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask,
                        &vi_in, &out_count);
  if (! vi_out) abort ();
  c = vi_out [0].colormap_size;
  XFree ((char *) vi_out);
  return c;
}

Here is the call graph for this function:

int visual_class ( Screen ,
Visual *   
)

Definition at line 342 of file xs_visual.c.

{
  Display *dpy = DisplayOfScreen (screen);
  XVisualInfo vi_in, *vi_out;
  int out_count, c;
  vi_in.screen = screen_number (screen);
  vi_in.visualid = XVisualIDFromVisual (visual);
  vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask,
                        &vi_in, &out_count);
  if (! vi_out) abort ();
  c = vi_out [0].class;
  XFree ((char *) vi_out);
  return c;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int visual_depth ( Screen ,
Visual *   
)

Definition at line 292 of file xs_visual.c.

{
  Display *dpy = DisplayOfScreen (screen);
  XVisualInfo vi_in, *vi_out;
  int out_count, d;
  vi_in.screen = screen_number (screen);
  vi_in.visualid = XVisualIDFromVisual (visual);
  vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask,
                        &vi_in, &out_count);
  if (! vi_out) abort ();
  d = vi_out [0].depth;
  XFree ((char *) vi_out);
  return d;
}

Here is the call graph for this function:

Here is the caller graph for this function: