+
+int IPC_Msg_GetDisplayDims(tIPC_Client *Client, tAxWin_IPCMessage *Msg)
+{
+ tIPCMsg_GetDisplayDims *info;
+ tAxWin_IPCMessage *ret_hdr;
+ tIPCMsg_RetDisplayDims *ret;
+ char buf[sizeof(*ret_hdr)+sizeof(*ret)];
+
+ if( !(Msg->Flags & IPCMSG_FLAG_RETURN) ) return 0;
+
+ info = (void*)Msg->Data;
+
+ ret_hdr = (void*)buf;
+ ret_hdr->ID = IPCMSG_GETDISPLAYDIMS;
+ ret_hdr->Flags = 0;
+ ret_hdr->Window = -1;
+ ret_hdr->Size = sizeof(*ret);
+ ret = (void*)ret_hdr->Data;
+
+ // HARD CODE! Only one display supported
+ if( info->DisplayID == 0 )
+ {
+ ret->X = 0;
+ ret->Y = 0;
+ ret->W = giScreenWidth;
+ ret->H = giScreenHeight;
+ }
+ else
+ {
+ ret->X = 0; ret->Y = 0;
+ ret->W = 0; ret->H = 0;
+ }
+
+ Client->IPCType->SendMessage(Client->Ident, sizeof(buf), buf);
+ return 0;
+}
+
+void IPC_Handle(const tIPC_Type *IPCType, const void *Ident, size_t MsgLen, tAxWin_IPCMessage *Msg)
+{
+ tIPC_Client *client;
+ int rv = 0;
+
+ _SysDebug("IPC_Handle: (IPCType=%p, Ident=%p, MsgLen=%i, Msg=%p)",
+ IPCType, Ident, MsgLen, Msg);
+
+ if( MsgLen < sizeof(tAxWin_IPCMessage) )
+ return ;
+ if( MsgLen < sizeof(tAxWin_IPCMessage) + Msg->Size )
+ return ;
+
+ client = IPC_int_GetClient(IPCType, Ident);
+
+ switch((enum eAxWin_IPCMessageTypes) Msg->ID)
+ {
+ // --- Ping message (reset timeout and get server version)
+ case IPCMSG_PING:
+ _SysDebug(" IPC_Handle: IPCMSG_PING");
+ if( Msg->Size < 4 ) return;
+ if( Msg->Flags & IPCMSG_FLAG_RETURN )
+ {
+ tIPCMsg_ReturnInt *ret = (void*)Msg->Data;
+ Msg->ID = IPCMSG_PING;
+ Msg->Size = sizeof(*ret);
+ ret->Value = AXWIN_VERSION;
+ IPCType->SendMessage(Ident, sizeof(*Msg)+sizeof(*ret), Msg);
+ }
+ break;
+
+ // -- Get display count
+ case IPCMSG_GETDISPLAYCOUNT:
+ rv = IPC_Msg_GetDisplayCount(client, Msg);
+ break;
+
+ // --- Get display dimensions
+ case IPCMSG_GETDISPLAYDIMS:
+ rv = IPC_Msg_GetDisplayDims(client, Msg);
+ break;
+
+ // --- Send a message
+ case IPCMSG_SENDMSG:
+ _SysDebug(" IPC_Handle: IPCMSG_SENDMSG %i", ((tIPCMsg_SendMsg*)Msg->Data)->ID);
+ rv = IPC_Msg_SendMsg(client, Msg);
+ break;
+
+ // --- Create window
+ case IPCMSG_CREATEWIN:
+ _SysDebug(" IPC_Handle: IPCMSG_CREATEWIN");
+ rv = IPC_Msg_CreateWin(client, Msg);
+ break;
+ // TODO: Destroy window
+
+ // --- Set window title
+ case IPCMSG_SETWINTITLE:
+ _SysDebug(" IPC_Handle: IPCMSG_SETWINTITLE");
+ rv = IPC_Msg_SetWindowTitle(client, Msg);
+ break;
+
+ // --- Give a window focus
+ case IPCMSG_FOCUSWINDOW:
+ _SysDebug(" IPC_Handle: IPCMSG_FOCUSWINDOW");
+ rv = IPC_Msg_FocusWindow(client, Msg);
+ break;
+ // --- Show/Hide a window
+ case IPCMSG_SHOWWINDOW:
+ _SysDebug(" IPC_Handle: IPCMSG_SHOWWINDOW");
+ rv = IPC_Msg_ShowWindow(client, Msg);
+ break;
+ case IPCMSG_DECORATEWINDOW:
+ _SysDebug(" IPC_Handle: IPCMSG_DECORATEWINDOW");
+ rv = IPC_Msg_DecorateWindow(client, Msg);
+ break;
+ // --- Move/Resize a window
+ case IPCMSG_SETWINPOS:
+ _SysDebug(" IPC_Handle: IPCMSG_SETWINPOS");
+ rv = IPC_Msg_SetWinPos(client, Msg);
+ break;
+
+ // --- Unknown message
+ default:
+ fprintf(stderr, "WARNING: Unknown message %i (%p)\n", Msg->ID, IPCType);
+ _SysDebug("WARNING: Unknown message %i (%p)", Msg->ID, IPCType);
+ break;
+ }
+ if(rv)
+ _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);
+}
+