Usermode/AxWin3 - Fixed window destruction not working correctly
authorJohn Hodge <[email protected]>
Sat, 7 Sep 2013 15:00:12 +0000 (23:00 +0800)
committerJohn Hodge <[email protected]>
Sat, 7 Sep 2013 15:00:12 +0000 (23:00 +0800)
Usermode/Applications/axwin3_src/WM/include/lowlevel.h
Usermode/Applications/axwin3_src/WM/ipc_acess.c
Usermode/Applications/axwin3_src/WM/main.c
Usermode/Applications/axwin3_src/WM/wm.c

index 5b33fbf..49d9720 100644 (file)
@@ -21,8 +21,8 @@ extern void   Input_FillSelect(int *nfds, fd_set *set);
 extern void    Input_HandleSelect(fd_set *set);
 // --- IPC ---
 extern void    IPC_Init(void);
-extern void    IPC_FillSelect(int *nfds, fd_set *set);
-extern void    IPC_HandleSelect(fd_set *set);
+extern void    IPC_FillSelect(int *nfds, fd_set *set, fd_set *err_set);
+extern void    IPC_HandleSelect(fd_set *set, fd_set *err_set);
 
 #endif
 
index 1d6e344..26f60a2 100644 (file)
@@ -17,8 +17,8 @@
 
 // === PROTOTYPES ===
 void   IPC_Init(void);
-void   IPC_FillSelect(int *nfds, fd_set *set);
-void   IPC_HandleSelect(fd_set *set);
+void   IPC_FillSelect(int *nfds, fd_set *set, fd_set *err_set);
+void   IPC_HandleSelect(fd_set *set, fd_set *err_set);
  int   IPC_Type_Datagram_GetSize(const void *Ident);
  int   IPC_Type_Datagram_Compare(const void *Ident1, const void *Ident2);
 void   IPC_Type_Datagram_Send(const void *Ident, size_t Length, const void *Data);
@@ -75,18 +75,20 @@ void _setfd(int fd, int *nfds, fd_set *set)
        }
 }
 
-void IPC_FillSelect(int *nfds, fd_set *set)
+void IPC_FillSelect(int *nfds, fd_set *set, fd_set *err_set)
 {
        _setfd(giNetworkFileHandle, nfds, set);
        _setfd(giIPCPipeHandle, nfds, set);
        for( int i = 0; i < giIPC_ClientCount; i ++ )
        {
-               if( gIPC_Clients[i] && gIPC_Clients[i]->IPCType == &gIPC_Type_IPCPipe )
+               if( gIPC_Clients[i] && gIPC_Clients[i]->IPCType == &gIPC_Type_IPCPipe ) {
                        _setfd( *(int*)(gIPC_Clients[i]->Ident), nfds, set );
+                       _setfd( *(int*)(gIPC_Clients[i]->Ident), nfds, err_set );
+               }
        }
 }
 
-void IPC_HandleSelect(fd_set *set)
+void IPC_HandleSelect(fd_set *set, fd_set *err_set)
 {
        if( giNetworkFileHandle != -1 && FD_ISSET(giNetworkFileHandle, set) )
        {
@@ -127,6 +129,12 @@ void IPC_HandleSelect(fd_set *set)
                                }
                                IPC_Handle( gIPC_Clients[i], len, (void*)staticBuf );
                        }
+                       if( FD_ISSET(fd, err_set) )
+                       {
+                               // Client disconnected
+                               IPC_int_DropClient(gIPC_Clients[i]);
+                               _SysClose(fd);
+                       }
                }
        }
 
index 5a2c354..1050395 100644 (file)
@@ -79,22 +79,24 @@ int main(int argc, char *argv[])
        for(;;)
        {
                fd_set  fds;
+               fd_set  efds;
                 int    nfds = 0;
                FD_ZERO(&fds);
+               FD_ZERO(&efds);
        
                WM_Update();
 
                Input_FillSelect(&nfds, &fds);
-               IPC_FillSelect(&nfds, &fds);
+               IPC_FillSelect(&nfds, &fds, &efds);
                
                nfds ++;
-               if( _SysSelect(nfds, &fds, NULL, NULL, NULL, THREAD_EVENT_IPCMSG) == -1 ) {
+               if( _SysSelect(nfds, &fds, NULL, &efds, NULL, THREAD_EVENT_IPCMSG) == -1 ) {
                        _SysDebug("ERROR: select() returned -1");
                        return -1;
                }
 
                Input_HandleSelect(&fds);
-               IPC_HandleSelect(&fds);
+               IPC_HandleSelect(&fds, &efds);
        }
        return 0;
 }
index e200700..342f410 100644 (file)
@@ -24,6 +24,7 @@ extern int    Renderer_RichText_Init(void);
 extern void    IPC_SendWMMessage(tIPC_Client *Client, uint32_t Src, uint32_t Dst, int Msg, int Len, const void *Data);
 extern void    IPC_SendReply(tIPC_Client *Client, uint32_t WinID, int MsgID, size_t Len, const void *Data);
 extern tWindow *IPC_int_GetWindow(tIPC_Client *Client, uint32_t ID);
+extern void    IPC_int_SetWindow(tIPC_Client *Client, uint32_t ID, tWindow *Window);
 
 // === GLOBALS ===
 tWMRenderer    *gpWM_Renderers;
@@ -145,7 +146,8 @@ void WM_DestroyWindow(tWindow *Window)
                        Window->Parent->LastChild = prev;
        }
        // - Full invalidate
-       WM_Invalidate(Window, 1);
+       WM_Invalidate(Window, 0);
+       Window->Parent->Flags &= ~WINFLAG_CLEAN;        // Mark parent as unclean, forcing redraw
        
        // - Remove from inheritance tree?
        
@@ -176,6 +178,7 @@ void WM_DestroyWindow(tWindow *Window)
        free(Window->Title);
        free(Window->RenderBuffer);
        free(Window);
+       IPC_int_SetWindow(Window->Client, Window->ID, NULL);
 }
 
 tWindow *WM_GetWindowByID(tWindow *Requester, uint32_t ID)

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