# include "Ximage.h"

/************** CheckGeometry *************/
void CheckGeometry (int *argc, char **argv) {

  int status, x, y, N;
  unsigned int dx, dy;
  int X, Y, dX, dY;
  char *temp_name;
  
  temp_name = XGetDefault (graphic.display, argv[0], "geometry");
  if ((N = get_argument (*argc, argv, "-geom"))) {
    if (N + 1 < *argc) {
      temp_name = argv[N+1];
    } else {
      fprintf (stderr, "error: usage is -geom DisplayName\n");
      exit (0);
    }
  }

  X = 10;
  Y = 10;
  dX = 512;
  dY = 512;
  if (temp_name != (char *)NULL) {  
    status = XParseGeometry (temp_name, &x, &y, &dx, &dy);
    if (status & XValue) X = x;
    if (status & YValue) Y = y;
    if (status & WidthValue) {
      dX = dx;
    }
    if (status & HeightValue) {
      dY = dy;
    }
    if (status & XNegative) X  = DisplayWidth  (graphic.display, graphic.screen) - dX + X;
    if (status & YNegative) Y  = DisplayHeight (graphic.display, graphic.screen) - dY + Y;
  }

  graphic.x = X;
  graphic.y = Y;
  graphic.dx = dX;
  graphic.dy = dY; 
  
}
