#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