/*
    ####             #    #     # #
    #   #            #    #       #          The FreeWare C library for 
    #   #  ##   ###  #  # #     # ###             RISC OS machines
    #   # #  # #     # #  #     # #  #   ___________________________________
    #   # ####  ###  ##   #     # #  #                                      
    #   # #        # # #  #     # #  #    Please refer to the accompanying
    ####   ### ####  #  # ##### # ###    documentation for conditions of use
    ________________________________________________________________________

    File:    Window.GetInfo.c
    Author:  Copyright  1992 Jason Williams
    Version: 1.00 (19 Mar 1992)
    Purpose: High-level window management functions: Get Window info
*/



#include <string.h>

#include "Desk.WimpSWIs.h"
#include "Desk.Window.h"


extern void Desk_Window_GetInfo(Desk_window_handle window, Desk_window_info *result)
/* Returns just the window part of the Desk_window_info block (strips icon defn.s)
 * The real solution would be to find out how many icons were in the window
 * and then get a flex block big enough for the whole thing and then do it,
 * but you can't read the number of icons until you have read the Desk_window_info
 * so it's a bit difficult! As a result, I just use a 4kB block to hold
 * the window definition in.
 *
 *      NOTE THAT THIS WILL CRASH IF A WINDOW HAS TOO MANY ICONS!!!!!
 *      (anything more than about 120 icons will cause undefined results)
 *
 * SeeAlso: Desk_Window_GetInfo3()
 */
{

  int         block[1024];           /* 4096 bytes for winfo return block */
  Desk_window_info *winfo = (Desk_window_info *) &block[0];

  winfo->window = window;
  Desk_Wimp_eGetWindowInfo(winfo);
  memcpy(result, winfo, sizeof(Desk_window_info));
}
