# include "Ximage.h"

// XXX Should there be a base command + KiiMessage command?
int Resize (int sock) {
 
  int i, Nsection;
  unsigned int NX, NY;
  Graphic *graphic;
  Section *section;

  graphic = GetGraphic();

  KiiScanMessage (sock, "%d %d", &NX, &NY);

  // XXX keep this min limit (or modify for !USE_XWINDOW)?
  NX = MAX(NX, MIN_WIDTH); 
  NY = MAX(NY, MIN_HEIGHT); 

  // if the new size is the same as the old size, do nothing.
  if ((graphic->dx == NX) && (graphic->dy == NY)) return (TRUE);

  // set the new window size
  graphic->dx = NX; 
  graphic->dy = NY; 

  if (USE_XWINDOW) XResizeWindow (graphic->display, graphic->window, NX, NY);

  // reset the sizes for all sections
  Nsection = GetNumberOfSections ();
  for (i = 0; i < Nsection; i++) {
      section = GetSectionByNumber (i);
      SetSectionSizes (section);
  }

  if (USE_XWINDOW) XClearWindow (graphic->display, graphic->window);
  Refresh (1);

  return (TRUE);
}
