typedef struct sWMRenderer tWMRenderer;
typedef uint32_t tColour;
typedef struct sFont tFont;
+typedef struct sIPC_Client tIPC_Client;
// === FUNCTIONS ===
// --- Management
-extern tWindow *WM_CreateWindow(tWindow *Parent, int Flags, const char *Renderer);
+extern tWindow *WM_CreateWindow(tWindow *Parent, tIPC_Client *Client, uint32_t ID, int Flags, const char *Renderer);
extern void WM_Invalidate(tWindow *Window);
extern void WM_ShowWindow(tWindow *Window, int bShow);
extern int WM_ResizeWindow(tWindow *Window, int W, int H);
tWindow *FirstChild;
tWindow *LastChild;
-
+
+ tIPC_Client *Client;
+ uint32_t ID; //!< Client assigned ID
tWMRenderer *Renderer;
int Flags;
// === TYPES ===
typedef struct sIPC_Type tIPC_Type;
-typedef struct sIPC_Client tIPC_Client;
struct sIPC_Type
{
src = IPC_int_GetWindow(Client, Msg->Window);
if(!src) return 1;
- dest = IPC_int_GetWindow(Client, info->Dest);
+ dest = IPC_int_GetWindow(Client, info->Remote);
if(!dest) return 1;
WM_SendMessage(src, dest, info->ID, info->Length, info->Data);
return 1;
// - Create the new window, and save its pointer
- newwin = WM_CreateWindow(parent, info->RendererArg, info->Renderer);
+ newwin = WM_CreateWindow(parent, Client, info->NewWinID, info->RendererArg, info->Renderer);
IPC_int_SetWindow(Client, info->NewWinID, newwin);
return 0;
_SysDebug("IPC_Handle: rv = %i", rv);
}
+// --- Server->Client replies
+void IPC_SendWMMessage(tIPC_Client *Client, uint32_t Src, uint32_t Dst, int MsgID, int Len, void *Data)
+{
+ tAxWin_IPCMessage *hdr;
+ tIPCMsg_SendMsg *msg;
+ char buf[sizeof(*hdr)+sizeof(*msg)+Len];
+
+ hdr = (void*)buf;
+ msg = (void*)hdr->Data;
+
+ hdr->ID = IPCMSG_SENDMSG;
+ hdr->Flags = 0;
+ hdr->Size = sizeof(*msg) + Len;
+ hdr->Window = Dst;
+
+ msg->Remote = Src;
+ msg->ID = MsgID;
+ msg->Length = Len;
+ memcpy(msg->Data, Data, Len);
+
+ Client->IPCType->SendMessage(Client->Ident, sizeof(buf), buf);
+}
+
#include <video.h>
#include <wm_messages.h>
+// === IMPORTS ===
+extern void IPC_SendWMMessage(tIPC_Client *Client, uint32_t Src, uint32_t Dst, int Msg, int Len, void *Data);
+
// === GLOBALS ===
tWMRenderer *gpWM_Renderers;
tWindow *gpWM_RootWindow;
// === CODE ===
void WM_Initialise(void)
{
- WM_CreateWindow(NULL, 0x0088FF, "Background");
+ WM_CreateWindow(NULL, NULL, 0, 0x0088FF, "Background");
gpWM_RootWindow->W = giScreenWidth;
gpWM_RootWindow->H = giScreenHeight;
gpWM_RootWindow->Flags = WINFLAG_SHOW;
}
// --- Manipulation
-tWindow *WM_CreateWindow(tWindow *Parent, int RendererArg, const char *RendererName)
+tWindow *WM_CreateWindow(tWindow *Parent, tIPC_Client *Client, uint32_t ID, int RendererArg, const char *RendererName)
{
tWMRenderer *renderer;
tWindow *ret;
// - Call create window function
ret = renderer->CreateWindow(RendererArg);
+ ret->Client = Client;
+ ret->ID = ID;
ret->Parent = Parent;
ret->Renderer = renderer;
ret->Flags = WINFLAG_CLEAN; // Needed to stop invaildate early exiting
// TODO: Catch errors from ->HandleMessage
return 0;
}
-
- // TODO: Pass on to user
- _SysDebug("WM_SendMessage: TODO - Implement sending to client application");
-
+
+ // TODO: Implement message masking
+
+ if(Dest->Client)
+ {
+ uint32_t src_id;
+ if(!Source)
+ src_id = -1;
+ else if(Source->Client != Dest->Client) {
+ // TODO: Support different client source windows
+ _SysDebug("WM_SendMessage: TODO - Support inter-client messages");
+ return -1;
+ }
+ else {
+ src_id = Source->ID;
+ }
+
+ IPC_SendWMMessage(Dest->Client, src_id, Dest->ID, Message, Length, Data);
+ }
+
return 1;
}
// Don't invalidate twice (speedup)
if( !(Window->Flags & WINFLAG_CLEAN) ) return;
-// _SysDebug("Invalidating %p");
-
// Mark for re-render
Window->Flags &= ~WINFLAG_CLEAN;
// Mark up the tree that a child window has changed
while( (Window = Window->Parent) )
- {
-// _SysDebug("Childclean removed from %p", Window);
Window->Flags &= ~WINFLAG_CHILDCLEAN;
- }
}
// --- Rendering / Update
struct sIPCMsg_SendMsg
{
- uint32_t Dest;
+ uint32_t Remote; // Dest/Source for Server/Client bound
uint16_t ID;
uint16_t Length;
char Data[];
msg = AxWin3_int_AllocateIPCMessage(Window, IPCMSG_SENDMSG, 0, sizeof(*info)+Length);
info = (void*)msg->Data;
- info->Dest = AxWin3_int_GetWindowID(Destination);
+ info->Remote = AxWin3_int_GetWindowID(Destination);
info->ID = Message;
info->Length = Length;
memcpy(info->Data, Data, Length);