AcessNative/nativefs - Fixed memory leak due to Close() not being bound
[tpg/acess2.git] / Usermode / Libraries / libaxwin2.so_src / windows.c
1 /*
2  * AxWin Window Manager Interface Library
3  * By John Hodge (thePowersGang)
4  * This file is published under the terms of the Acess Licence. See the
5  * file COPYING for details.
6  * 
7  * window.c - Window Control
8  */
9 #include "common.h"
10
11 // === TYPES & STRUCTURES ===
12 struct sAxWin_Window
13 {
14         struct sAxWin_Window    *Next;
15         uint32_t        WmHandle;
16         tAxWin_MessageCallback  *Callback;
17 };
18
19 // === PROTOTYPES ===
20 tAxWin_Window   *AxWin_CreateWindow(
21         int16_t X, int16_t Y, int16_t W, int16_t H,
22         uint32_t Flags, tAxWin_MessageCallback *Callback
23         );
24
25 // === GLOBALS ===
26 //mutex_t       glProcessWindows;
27 tAxWin_Window   *gProcessWindows;
28
29 // === CODE ===
30 tAxWin_Window   *AxWin_CreateWindow(
31         int16_t X, int16_t Y,
32         int16_t W, int16_t H,
33         uint32_t Flags, tAxWin_MessageCallback *Callback)
34 {
35         tAxWin_Message  req;
36         tAxWin_Message  *msg;
37         tAxWin_Window   *win;
38         
39         req.ID = MSG_SREQ_NEWWINDOW;
40         req.Size = 1 + sizeof(struct sAxWin_SReq_NewWindow)/4;
41         req.SReq_NewWindow.X = X;
42         req.SReq_NewWindow.Y = Y;
43         req.SReq_NewWindow.W = W;
44         req.SReq_NewWindow.H = H;
45         req.SReq_NewWindow.Flags = Flags;
46         
47         AxWin_SendMessage(&msg);
48         
49         for(;;)
50         {
51                 msg = AxWin_WaitForMessage();
52                 
53                 if(msg.ID == MSG_SRSP_WINDOW)
54                         break;
55                 
56                 AxWin_HandleMessage(msg);
57                 free(msg);
58         }
59         
60         win = malloc(sizeof(tAxWin_Window));
61         win->WmHandle = msg->SRsp_Window.Handle;
62         win->Callback = Callback;
63         
64         //mutex_acquire(glProcessWindows);
65         win->Next = gProcessWindows;
66         gProcessWindows = win;
67         //mutex_release(glProcessWindows);
68         
69         return 0;
70 }

UCC git Repository :: git.ucc.asn.au