home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / anim / players / mpeg_src.lha / amiga / util32.c < prev    next >
C/C++ Source or Header  |  1993-02-11  |  2KB  |  81 lines

  1. #include <stdio.h>
  2. #include <X11/Xlib.h>
  3. #include <X11/Xutil.h>
  4. #include "video.h"
  5. #include "proto.h"
  6.  
  7. #ifdef AMIGA
  8. #include "amiga.h"
  9. #endif
  10.  
  11. /*
  12.  * Return a pointer to a full color bit visual on the dpy
  13.  */
  14. Visual *
  15. FindFullColorVisual (dpy, depth)
  16.     Display *dpy;
  17.     int *depth;
  18. {
  19. #ifdef AMIGA
  20.     *depth = 24;
  21.     return (Visual *) 1L;
  22. #else
  23.   XVisualInfo vinfo;
  24.   XVisualInfo *vinfo_ret;
  25.   int numitems, maxdepth;
  26.   
  27.   vinfo.class = TrueColor;
  28.   
  29.   vinfo_ret = XGetVisualInfo(dpy, VisualClassMask, &vinfo, &numitems);
  30.   
  31.   if (numitems == 0) return NULL;
  32.  
  33.   maxdepth = 0;
  34.   while(numitems > 0) {
  35.     if (vinfo_ret[numitems-1].depth > maxdepth) {
  36.       maxdepth = vinfo_ret[numitems-1 ].depth;
  37.     }
  38.     numitems--;
  39.   }
  40.   XFree(vinfo_ret);
  41.  
  42.   if (maxdepth < 24) return NULL;
  43.  
  44.   if (XMatchVisualInfo(dpy, DefaultScreen(dpy), maxdepth, 
  45.                TrueColor, &vinfo)) {
  46.     *depth = maxdepth;
  47.     return vinfo.visual;
  48.   }
  49.   
  50.   return NULL;
  51. #endif
  52. }
  53.  
  54. Window
  55. CreateFullColorWindow (dpy, x, y, w, h)
  56.     Display *dpy;
  57.     int x, y, w, h;
  58. {
  59.     int depth;
  60.     Visual *visual;
  61.     XSetWindowAttributes xswa;
  62.     unsigned int mask;
  63.     unsigned int class;
  64.     int screen;
  65.  
  66.     screen = XDefaultScreen(dpy);
  67.     class = InputOutput;    /* Could be InputOnly */
  68.     visual = FindFullColorVisual (dpy, &depth);
  69.     if (visual == NULL) {
  70.     return 0;
  71.     }
  72.     mask = CWBackPixel | CWColormap | CWBorderPixel;
  73.     xswa.colormap = XCreateColormap(dpy, XRootWindow(dpy, screen),
  74.             visual, AllocNone);
  75.     xswa.background_pixel = BlackPixel(dpy, DefaultScreen(dpy));
  76.     xswa.border_pixel = WhitePixel(dpy, DefaultScreen(dpy));
  77.  
  78.     return XCreateWindow(dpy, RootWindow(dpy, screen), x, y, w, h,
  79.     1, depth, class, visual, mask, &xswa);
  80. }
  81.