⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 visual.c

📁 编译后直接运行的MP3播放器全部C语言源代码 一个包含FAT文件系统、系统引导 Boot、FLASH Driver等内容的
💻 C
📖 第 1 页 / 共 2 页
字号:
      visual = (best < out_count ? vi_out [best].visual : 0);      XFree ((char *) vi_out);      return visual;    }  else    return 0;}static Visual *pick_best_gl_visual (Screen *screen){  /* The best visual for GL is a TrueColor visual that is half as deep as     the screen.  If such a thing doesn't exist, then TrueColor is best.     Failing that, the deepest available color visual is best.     Compare this function to get_gl_visual() in visual-gl.c.     This function tries to find the best GL visual using Xlib calls,     whereas that function does the same thing using GLX calls.   */  Display *dpy = DisplayOfScreen (screen);  XVisualInfo vi_in, *vi_out;  int out_count;  Visual *result = 0;  int ndepths = 0;  int *depths = XListDepths (dpy, screen_number (screen), &ndepths);  int screen_depth = depths[ndepths];  XFree (depths);  vi_in.class = TrueColor;  vi_in.screen = screen_number (screen);  vi_in.depth = screen_depth / 2;  vi_out = XGetVisualInfo (dpy, (VisualClassMask | VisualScreenMask |                                 VisualDepthMask),			   &vi_in, &out_count);  if (out_count > 0)    result = vi_out[0].visual;  if (vi_out)    XFree ((char *) vi_out);  if (!result && screen_depth > 24)    {      /* If it's a 32-deep screen and we didn't find a depth-16 visual,         see if there's a depth-12 visual. */      vi_in.class = TrueColor;      vi_in.screen = screen_number (screen);      vi_in.depth = 12;      vi_out = XGetVisualInfo (dpy, (VisualClassMask | VisualScreenMask |                                     VisualDepthMask),                               &vi_in, &out_count);      if (out_count > 0)        result = vi_out[0].visual;    }  if (!result)    /* No half-depth TrueColor?  Ok, try for any TrueColor (the deepest.) */    result = pick_best_visual_of_class (screen, TrueColor);  if (!result)    /* No TrueColor?  Ok, try for anything. */    result = pick_best_visual (screen, False, False);  return result;}static Visual *id_to_visual (Screen *screen, int id){  Display *dpy = DisplayOfScreen (screen);  XVisualInfo vi_in, *vi_out;  int out_count;  vi_in.screen = screen_number (screen);  vi_in.visualid = id;  vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualIDMask),			   &vi_in, &out_count);  if (vi_out)    {      Visual *v = vi_out[0].visual;      XFree ((char *) vi_out);      return v;    }  return 0;}intvisual_depth (Screen *screen, Visual *visual){  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;}#if 0/* You very probably don't want to be using this.   Pixmap depth doesn't refer to the depths of pixmaps, but rather, to   the depth of protocol-level on-the-wire pixmap data, that is, XImages.   To get this info, you should be looking at XImage->bits_per_pixel   instead.  (And allocating the data for your XImage structures by   multiplying ximage->bytes_per_line by ximage->height.) */intvisual_pixmap_depth (Screen *screen, Visual *visual){  Display *dpy = DisplayOfScreen (screen);  int vdepth = visual_depth (screen, visual);  int pdepth = vdepth;  int i, pfvc = 0;  XPixmapFormatValues *pfv = XListPixmapFormats (dpy, &pfvc);  /* Return the first matching depth in the pixmap formats.  If there are no     matching pixmap formats (which shouldn't be able to happen at all) then     return the visual depth instead. */  for (i = 0; i < pfvc; i++)    if (pfv[i].depth == vdepth)      {	pdepth = pfv[i].bits_per_pixel;	break;      }  if (pfv)    XFree (pfv);  return pdepth;}#endif /* 0 */intvisual_class (Screen *screen, Visual *visual){  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;}Boolhas_writable_cells (Screen *screen, Visual *visual){  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();      return False;    }}voiddescribe_visual (FILE *f, Screen *screen, Visual *visual, Bool private_cmap_p){  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);}intscreen_number (Screen *screen){  Display *dpy = DisplayOfScreen (screen);  int i;  for (i = 0; i < ScreenCount (dpy); i++)    if (ScreenOfDisplay (dpy, i) == screen)      return i;  abort ();  return 0;}intvisual_cells (Screen *screen, Visual *visual){  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;}Visual *find_similar_visual(Screen *screen, Visual *old_visual){  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;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -