home *** CD-ROM | disk | FTP | other *** search
/ PC Shareware 1999 March / PCShareware-3-99.iso / IMPLE / DJGPP.RAR / DJGPP2 / XLIB-SR0.ZIP / SRC / XLIBEMU / WINDOW.C < prev    next >
C/C++ Source or Header  |  1994-02-20  |  2KB  |  74 lines

  1. /* $Id: window.c 1.3 1994/02/20 18:01:05 ulrich Exp $ */
  2. /*
  3.  * X library function XCreateWindow.
  4.  */
  5. #include "Xlibemu.h"
  6.  
  7. Window
  8. XCreateWindow (Display*        dpy,
  9.            Window        parent,
  10.            int        x,
  11.            int        y,
  12.            unsigned int    width,
  13.            unsigned int    height,
  14.            unsigned int    border_width,
  15.            int        depth,
  16.            unsigned int    class,
  17.            Visual*        visual,
  18.            unsigned long    valuemask,
  19.            XSetWindowAttributes* attributes)
  20. {
  21.   Window window;
  22.   XEvent xe;
  23.   
  24.   if (dpy == None) return None;
  25.  
  26.   if (parent == None) {
  27.     parent = DefaultRootWindow (dpy);
  28.   }
  29.  
  30.   window = (Window) Xcalloc (1, sizeof (*window));
  31.   if (window == None) {
  32.     return None;
  33.   }
  34.   window->type        = 2;    /* 0 = bitmap, 1 = pixmap */
  35.   window->parent    = parent;
  36.   window->x        = x;
  37.   window->y        = y;
  38.   window->width        = width;
  39.   window->height    = height;
  40.   window->border_width    = border_width;
  41.   window->depth        = (depth == CopyFromParent) ? parent->depth : depth;
  42.   window->class        = (class == CopyFromParent) ? parent->class : class;
  43.   window->visual    = (visual == CopyFromParent) ? parent->visual : visual;
  44.   window->visible_region = XCreateRegion();
  45.  
  46.   _WTreeInsertTop (parent, window);
  47.   /* Needs parent, x, y, width, height and border_width initialized */
  48.   _WNewWindowContext (window);
  49.  
  50.   /* Set default functions for border and background */
  51.  
  52.   window->border.fillBox = _WDummyFilledBox;
  53.   window->background.fillBox = _WDummyFilledBox;
  54.  
  55.   XChangeWindowAttributes (dpy, window, valuemask, attributes);
  56.  
  57.   if (window->parent &&
  58.       window->parent->event_mask & SubstructureNotifyMask) {
  59.     xe.xcreatewindow.type = CreateNotify;
  60.     xe.xcreatewindow.send_event = 0;
  61.     xe.xcreatewindow.display = dpy;
  62.     xe.xcreatewindow.parent = parent;
  63.     xe.xcreatewindow.window = window;
  64.     xe.xcreatewindow.x = x;
  65.     xe.xcreatewindow.y = y;
  66.     xe.xcreatewindow.width = width;
  67.     xe.xcreatewindow.height = height;
  68.     xe.xcreatewindow.border_width = border_width;
  69.     xe.xcreatewindow.override_redirect = window->override_redirect;
  70.     _WDispatchEvent (&xe);
  71.   }
  72.   return window;
  73. }
  74.