X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin3_src%2Flibaxwin3.so_src%2Fmsg.c;h=17d089f9238babbda6375f9d35a3f776a1393a92;hb=2da16f7b05b8c3f17ac136128a849db332b067ad;hp=1059a0a2f37186aa58706d69a82527dc8da489ae;hpb=4fa95391e2ff812412d7229e0135efd49cd5f3ed;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c b/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c index 1059a0a2..17d089f9 100644 --- a/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c +++ b/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c @@ -11,6 +11,7 @@ #include #include // AxWin3 common #include "include/internal.h" +#include "include/ipc.h" // === CONSTANTS === enum eConnectionType @@ -69,6 +70,14 @@ tAxWin3_MessageCallback AxWin3_SetMessageCallback(tAxWin3_MessageCallback Callba return old; } +uint32_t AxWin3_int_GetWindowID(tHWND Window) +{ + if(Window) + return Window->ServerID; + else + return -1; +} + tAxWin_IPCMessage *AxWin3_int_AllocateIPCMessage(tHWND Window, int Message, int Flags, int ExtraBytes) { tAxWin_IPCMessage *ret; @@ -76,10 +85,7 @@ tAxWin_IPCMessage *AxWin3_int_AllocateIPCMessage(tHWND Window, int Message, int ret = malloc( sizeof(tAxWin_IPCMessage) + ExtraBytes ); ret->Flags = Flags; ret->ID = Message; - if(Window) - ret->Window = Window->ServerID; - else - ret->Window = -1; + ret->Window = AxWin3_int_GetWindowID(Window); ret->Size = ExtraBytes; return ret; } @@ -115,8 +121,7 @@ tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void) switch(giConnectionType) { case CONNTYPE_SENDMESSAGE: - // TODO: Less hack, I need a version of select for GetMessage etc - if(SysGetMessage(NULL, NULL) == 0) sleep(); + _SysWaitEvent(THREAD_EVENT_IPCMSG); while(SysGetMessage(NULL, NULL)) { pid_t tid; @@ -124,6 +129,7 @@ tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void) // Check if the message came from the server if(tid != giConnectionNum) { + _SysDebug("%i byte message from %i", len, tid); // If not, pass the buck (or ignore) if( gAxWin3_MessageCallback ) gAxWin3_MessageCallback(tid, len); @@ -134,7 +140,11 @@ tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void) // If it's from the server, allocate a buffer and return it ret = malloc(len); - if(ret == NULL) return NULL; + if(ret == NULL) { + _SysDebug("malloc() failed, ignoring message"); + SysGetMessage(NULL, GETMSG_IGNORE); + return NULL; + } SysGetMessage(NULL, ret); break; } @@ -154,3 +164,15 @@ tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void) return ret; } +tAxWin_IPCMessage *AxWin3_int_WaitIPCMessage(int WantedID) +{ + tAxWin_IPCMessage *msg; + for(;;) + { + msg = AxWin3_int_GetIPCMessage(); + if(msg->ID == WantedID) return msg; + AxWin3_int_HandleMessage( msg ); + free(msg); + } +} +