home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / XAP / XGAMES / SPIDER.TAR / spider / windows.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-28  |  3.2 KB  |  144 lines

  1. /*
  2.  *    Spider
  3.  *
  4.  *    (c) Copyright 1989, Donald R. Woods and Sun Microsystems, Inc.
  5.  *    (c) Copyright 1990, David Lemke and Network Computing Devices Inc.
  6.  *
  7.  *    See copyright.h for the terms of the copyright.
  8.  *
  9.  *    @(#)windows.c    2.1    90/04/25
  10.  *
  11.  */
  12.  
  13. /*
  14.  * spider window manipulation
  15.  */
  16.  
  17. #include    "defs.h"
  18. #include    "globals.h"
  19.  
  20. #ifdef KITLESS
  21. #include    "spider.bm"
  22.  
  23. window_init(ac, av, geom)
  24. int    ac;
  25. char    **av;
  26. char    *geom;
  27. {
  28. XSetWindowAttributes    winattr;
  29. long            winmask;
  30. XSizeHints        xsh;
  31. XWMHints        xwmh;
  32. int            mwin_h;
  33. int            x, y;
  34. Pixmap            icon_map;
  35.  
  36.     x = TABLE_X;
  37.     y = TABLE_Y;
  38.     table_width = TABLE_WIDTH;
  39.     table_height = TABLE_HEIGHT;
  40.  
  41.     xsh.min_width = TABLE_WIDTH;
  42.     xsh.min_height = TABLE_HEIGHT;
  43.  
  44.     xsh.flags = PPosition | PSize | PMinSize;
  45.  
  46.     if (geom)    {
  47.         int    flags;
  48.  
  49.         flags = XParseGeometry(geom, &x, &y, &table_width,
  50.             &table_height);
  51.         
  52.         /* don't let it start too short */
  53.         if (flags & HeightValue && table_height < TABLE_HEIGHT)
  54.             table_height = TABLE_HEIGHT;
  55.  
  56.         /* don't let it start too narrow */
  57.         if (flags & WidthValue && table_width < TABLE_WIDTH)
  58.             table_width = TABLE_WIDTH;
  59.  
  60.         if (flags & (WidthValue | HeightValue))
  61.             xsh.flags |= USSize;
  62.  
  63.         if (flags & (XValue | YValue))
  64.             xsh.flags |= USPosition;
  65.  
  66.         if (flags & XValue && flags & XNegative)    {
  67.             x = DisplayWidth(dpy, screen) - (table_width + x);
  68.         }
  69.  
  70.         if (flags & YValue && flags & YNegative)    {
  71.             y = DisplayHeight(dpy, screen) - (table_height + y);
  72.         }
  73.  
  74.     }
  75.  
  76.     winattr.backing_store = WhenMapped;
  77.     winattr.border_pixel = blackpixel;
  78.     winattr.event_mask = KeyPressMask | ExposureMask | ButtonPressMask | 
  79.         ButtonReleaseMask | StructureNotifyMask;
  80.     winmask = CWBorderPixel | CWEventMask | CWBackingStore;
  81.  
  82.     if (is_color)    {
  83.         winattr.background_pixel = greenpixel;
  84.         winmask |= CWBackPixel;
  85.     } else    {
  86.         winattr.background_pixmap = greenmap;
  87.         winmask |= CWBackPixmap;
  88.     }
  89.  
  90.     table = XCreateWindow(dpy, RootWindow(dpy, screen), 
  91.         x, y, table_width, table_height,
  92.         TABLE_BW, CopyFromParent, CopyFromParent, 
  93.         CopyFromParent, winmask, &winattr);
  94.  
  95.     xsh.x = x;
  96.     xsh.y = y;
  97.  
  98.     xsh.width = table_width;
  99.     xsh.height = table_height;
  100.  
  101.     icon_map = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
  102.         spider_bits, spider_width, spider_height);
  103.  
  104.     XSetStandardProperties(dpy, table, "Spider", "Spider", icon_map,
  105.         av, ac, &xsh);
  106.     xwmh.flags = InputHint | IconPixmapHint;
  107.     xwmh.input = True;
  108.     xwmh.icon_pixmap = icon_map;
  109.     XSetWMHints(dpy, table, &xwmh);
  110.  
  111.     mwin_h = message_font->ascent + message_font->descent;
  112.     message_win = XCreateSimpleWindow(dpy, table, 
  113.         0, table_height - 2 * TABLE_BW - mwin_h,
  114.         table_width - 2 * TABLE_BW, mwin_h,
  115.         TABLE_BW, borderpixel, whitepixel);
  116.     XMapWindow(dpy, message_win);
  117.     XMapWindow(dpy, table);
  118. }
  119. #endif KITLESS
  120.  
  121. #ifndef    KITLESS
  122. table_init(win)
  123. Window    win;
  124. {
  125. XSetWindowAttributes    winattr;
  126. long winmask;
  127.  
  128.     /* save this for later */
  129.     table = win;
  130.  
  131.         winattr.backing_store = WhenMapped;
  132.     winattr.bit_gravity = ForgetGravity;
  133.     winmask = CWBackingStore | CWBitGravity;
  134.         if (is_color)   {
  135.                 winattr.background_pixel = greenpixel;
  136.                 winmask |= CWBackPixel;
  137.         } else  {
  138.                 winattr.background_pixmap = greenmap;
  139.                 winmask |= CWBackPixmap;
  140.         }
  141.         XChangeWindowAttributes(dpy, table, winmask, &winattr);
  142. }
  143. #endif    KITLESS
  144.