Usermode/AxWin3 - Implemented passing messages to the client
authorJohn Hodge <[email protected]>
Tue, 8 Nov 2011 05:52:26 +0000 (13:52 +0800)
committerJohn Hodge <[email protected]>
Tue, 8 Nov 2011 05:52:26 +0000 (13:52 +0800)
Usermode/Applications/axwin3_src/WM/include/wm.h
Usermode/Applications/axwin3_src/WM/include/wm_internals.h
Usermode/Applications/axwin3_src/WM/ipc.c
Usermode/Applications/axwin3_src/WM/wm.c
Usermode/Applications/axwin3_src/include/ipcmessages.h
Usermode/Applications/axwin3_src/libaxwin3.so_src/wm.c

index 19994ae..86008be 100644 (file)
@@ -33,10 +33,11 @@ typedef struct sWindow      tWindow;
 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);
index aada720..ea0826c 100644 (file)
@@ -19,7 +19,9 @@ struct sWindow
 
        tWindow *FirstChild;
        tWindow *LastChild;
-       
+
+       tIPC_Client     *Client;
+       uint32_t        ID;     //!< Client assigned ID
        tWMRenderer     *Renderer;
 
         int    Flags;
index 22482af..a21c783 100644 (file)
@@ -20,7 +20,6 @@
 
 // === TYPES ===
 typedef struct sIPC_Type       tIPC_Type;
-typedef struct sIPC_Client     tIPC_Client;
 
 struct sIPC_Type
 {
@@ -270,7 +269,7 @@ int IPC_Msg_SendMsg(tIPC_Client *Client, tAxWin_IPCMessage *Msg)
        
        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);  
@@ -298,7 +297,7 @@ int IPC_Msg_CreateWin(tIPC_Client *Client, tAxWin_IPCMessage *Msg)
                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;
@@ -401,3 +400,26 @@ void IPC_Handle(const tIPC_Type *IPCType, const void *Ident, size_t MsgLen, tAxW
                _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);
+}
+
index e160229..bfa86b1 100644 (file)
@@ -12,6 +12,9 @@
 #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;
@@ -19,7 +22,7 @@ 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;
@@ -33,7 +36,7 @@ void WM_RegisterRenderer(tWMRenderer *Renderer)
 }
 
 // --- 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;
@@ -52,6 +55,8 @@ tWindow *WM_CreateWindow(tWindow *Parent, int RendererArg, const char *RendererN
 
        // - 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
@@ -141,10 +146,26 @@ int WM_SendMessage(tWindow *Source, tWindow *Dest, int Message, int Length, void
                // 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;
 }
 
@@ -153,17 +174,12 @@ void WM_Invalidate(tWindow *Window)
        // 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
index aa69d34..bd2072a 100644 (file)
@@ -51,7 +51,7 @@ struct sIPCMsg_CreateWin
 
 struct sIPCMsg_SendMsg
 {
-       uint32_t        Dest;
+       uint32_t        Remote; // Dest/Source for Server/Client bound
        uint16_t        ID;
        uint16_t        Length;
        char    Data[];
index 55eec69..8b27966 100644 (file)
@@ -132,7 +132,7 @@ void AxWin3_SendMessage(tHWND Window, tHWND Destination, int Message, int Length
        
        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);

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