From: John Hodge Date: Sat, 5 Nov 2011 05:10:08 +0000 (+0800) Subject: Usermode/AxWin3 - More WM IPC messages implemented X-Git-Tag: rel0.14~146 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=e7dd0e094f0c23bb20ddb0025f41d1c0c28f5ab2;p=tpg%2Facess2.git Usermode/AxWin3 - More WM IPC messages implemented --- diff --git a/Usermode/Applications/axwin3_src/WM/include/wm.h b/Usermode/Applications/axwin3_src/WM/include/wm.h index 884fc812..89cedbd9 100644 --- a/Usermode/Applications/axwin3_src/WM/include/wm.h +++ b/Usermode/Applications/axwin3_src/WM/include/wm.h @@ -32,8 +32,9 @@ typedef uint32_t tColour; // === FUNCTIONS === // --- Management extern tWindow *WM_CreateWindow(tWindow *Parent, int Flags, const char *Renderer); -extern int WM_Reposition(tWindow *Window, int X, int Y, int W, int H); -extern int WM_SetFlags(tWindow *Window, int Flags); +extern void WM_ShowWindow(tWindow *Window, int bShow); +extern int WM_ResizeWindow(tWindow *Window, int W, int H); +extern int WM_MoveWindow(tWindow *Window, int X, int Y); extern int WM_SendMessage(tWindow *Window, int MessageID, int Length, void *Data); // --- Rendering extern void WM_Render_FilledRect(tWindow *Window, tColour Colour, int X, int Y, int W, int H); diff --git a/Usermode/Applications/axwin3_src/WM/ipc.c b/Usermode/Applications/axwin3_src/WM/ipc.c index a47cc0ab..94691ccf 100644 --- a/Usermode/Applications/axwin3_src/WM/ipc.c +++ b/Usermode/Applications/axwin3_src/WM/ipc.c @@ -276,6 +276,39 @@ int IPC_Msg_CreateWin(tIPC_Client *Client, tAxWin_IPCMessage *Msg) return 0; } +int IPC_Msg_ShowWindow(tIPC_Client *Client, tAxWin_IPCMessage *Msg) +{ + tIPCMsg_ShowWindow *info = (void*)Msg->Data; + tWindow *win; + + if( Msg->Size < sizeof(*info) ) return -1; + + win = IPC_int_GetWindow(Client, Msg->Window); + if(!win) return 1; + + WM_ShowWindow(win, !!info->bShow); + + return 0; +} + +int IPC_Msg_SetWinPos(tIPC_Client *Client, tAxWin_IPCMessage *Msg) +{ + tIPCMsg_SetWindowPos *info = (void*)Msg->Data; + tWindow *win; + + if(Msg->Size < sizeof(*info)) return -1; + + win = IPC_int_GetWindow(Client, Msg->Window); + if(!win) return 1; + + if(info->bSetPos) + WM_MoveWindow(win, info->X, info->Y); + if(info->bSetDims) + WM_ResizeWindow(win, info->W, info->H); + + return 0; +} + void IPC_Handle(const tIPC_Type *IPCType, const void *Ident, size_t MsgLen, tAxWin_IPCMessage *Msg) { tIPC_Client *client; @@ -305,13 +338,21 @@ void IPC_Handle(const tIPC_Type *IPCType, const void *Ident, size_t MsgLen, tAxW } break; - // --- Create window + // --- Create window case IPCMSG_CREATEWIN: _SysDebug(" IPC_Handle: IPCMSG_CREATEWIN"); IPC_Msg_CreateWin(client, Msg); break; - -// case IPCMSG_SHOWWINDOW: + // --- Show/Hide a window + case IPCMSG_SHOWWINDOW: + _SysDebug(" IPC_Handle: IPCMSG_SHOWWINDOW"); + IPC_Msg_ShowWindow(client, Msg); + break; + // --- Move/Resize a window + case IPCMSG_SETWINPOS: + _SysDebug(" IPC_Handle: IPCMSG_SETWINPOS"); + IPC_Msg_SetWinPos(client, Msg); + break; // --- Unknown message default: diff --git a/Usermode/Applications/axwin3_src/WM/wm.c b/Usermode/Applications/axwin3_src/WM/wm.c index 7a7a8d8e..7031e379 100644 --- a/Usermode/Applications/axwin3_src/WM/wm.c +++ b/Usermode/Applications/axwin3_src/WM/wm.c @@ -31,6 +31,7 @@ void WM_RegisterRenderer(tWMRenderer *Renderer) gpWM_Renderers = Renderer; } +// --- Manipulation tWindow *WM_CreateWindow(tWindow *Parent, int RendererArg, const char *RendererName) { tWMRenderer *renderer; @@ -82,6 +83,40 @@ tWindow *WM_CreateWindowStruct(size_t ExtraSize) return ret; } +void WM_ShowWindow(tWindow *Window, int bShow) +{ + // TODO: Message window + if(bShow) + Window->Flags |= WINFLAG_SHOW; + else + Window->Flags &= ~WINFLAG_SHOW; +} + +int WM_MoveWindow(tWindow *Window, int X, int Y) +{ + // Clip coordinates + if(X + Window->W < 0) X = -Window->W + 1; + if(Y + Window->H < 0) Y = -Window->H + 1; + if(X >= giScreenWidth) X = giScreenWidth - 1; + if(Y >= giScreenHeight) Y = giScreenHeight - 1; + + Window->X = X; Window->Y = Y; + + return 0; +} + +int WM_ResizeWindow(tWindow *Window, int W, int H) +{ + if(W <= 0 || H <= 0 ) return 1; + if(Window->X + W < 0) Window->X = -W + 1; + if(Window->Y + H < 0) Window->Y = -H + 1; + + Window->W = W; Window->H = H; + + return 0; +} + +// --- Rendering / Update void WM_int_UpdateWindow(tWindow *Window) { tWindow *child; diff --git a/Usermode/Applications/axwin3_src/include/ipcmessages.h b/Usermode/Applications/axwin3_src/include/ipcmessages.h index aad587bc..e03c41c4 100644 --- a/Usermode/Applications/axwin3_src/include/ipcmessages.h +++ b/Usermode/Applications/axwin3_src/include/ipcmessages.h @@ -55,11 +55,10 @@ struct sIPCMsg_ShowWindow struct sIPCMsg_SetWindowPos { - int16_t X; - int16_t Y; - uint16_t W; - uint16_t H; - uint8_t Fields; + int16_t X, Y; + uint16_t W, H; + uint8_t bSetPos; + uint8_t bSetDims; }; enum eAxWin_IPCMessageTypes diff --git a/Usermode/Applications/axwin3_src/libaxwin3.so_src/wm.c b/Usermode/Applications/axwin3_src/libaxwin3.so_src/wm.c index e0cfcbe4..29038ae3 100644 --- a/Usermode/Applications/axwin3_src/libaxwin3.so_src/wm.c +++ b/Usermode/Applications/axwin3_src/libaxwin3.so_src/wm.c @@ -147,7 +147,8 @@ void AxWin3_SetWindowPos(tHWND Window, short X, short Y, short W, short H) msg = AxWin3_int_AllocateIPCMessage(Window, IPCMSG_SETWINPOS, 0, sizeof(*info)); info = (void*)msg->Data; - info->Fields = 0xF; + info->bSetPos = 1; + info->bSetDims = 1; info->X = X; info->Y = Y; info->W = W; info->H = H; @@ -163,7 +164,8 @@ void AxWin3_MoveWindow(tHWND Window, short X, short Y) msg = AxWin3_int_AllocateIPCMessage(Window, IPCMSG_SETWINPOS, 0, sizeof(*info)); info = (void*)msg->Data; - info->Fields = 0x3; + info->bSetPos = 1; + info->bSetDims = 0; info->X = X; info->Y = Y; @@ -180,7 +182,8 @@ void AxWin3_ResizeWindow(tHWND Window, short W, short H) msg = AxWin3_int_AllocateIPCMessage(Window, IPCMSG_SETWINPOS, 0, sizeof(*info)); info = (void*)msg->Data; - info->Fields = 0xC; + info->bSetPos = 0; + info->bSetDims = 1; info->W = W; info->H = H;