Usermode/AxWin3 - More WM IPC messages implemented
authorJohn Hodge <[email protected]>
Sat, 5 Nov 2011 05:10:08 +0000 (13:10 +0800)
committerJohn Hodge <[email protected]>
Sat, 5 Nov 2011 05:10:08 +0000 (13:10 +0800)
Usermode/Applications/axwin3_src/WM/include/wm.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 884fc81..89cedbd 100644 (file)
@@ -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);
index a47cc0a..94691cc 100644 (file)
@@ -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:
index 7a7a8d8..7031e37 100644 (file)
@@ -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;
index aad587b..e03c41c 100644 (file)
@@ -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
index e0cfcbe..29038ae 100644 (file)
@@ -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;
        

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