# include "Ximage.h"

/************** CreateWindow *************/
void
CreateWindow (graphic, parent, border, events)
Graphic       graphic[];
Window        parent;
int           border;
long          events;
{

  XSetWindowAttributes attributes;
  unsigned long attribute_mask;

  attributes.background_pixel = graphic[0].white;
  attributes.border_pixel     = graphic[0].black;
  attributes.event_mask       = events;
  attributes.colormap         = graphic[0].colormap;
  attribute_mask              = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap;

  graphic[0].window = XCreateWindow (graphic[0].display, parent, 
				     graphic[0].x, graphic[0].y, 
				     graphic[0].dx, graphic[0].dy, 
				     border, graphic[0].depth,
				     InputOutput, graphic[0].visual, 
				     attribute_mask, &attributes);

  if (graphic[0].window == (Window) None)
    QuitX (graphic[0].display, "", "error: could not open window");

  XSelectInput (graphic[0].display, graphic[0].window, events);
}

