From: John Hodge Date: Sat, 7 Sep 2013 15:00:12 +0000 (+0800) Subject: Usermode/AxWin3 - Fixed window destruction not working correctly X-Git-Tag: rel0.15~265 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=69597a188bf638485ea83b7608430f92080c1855;p=tpg%2Facess2.git Usermode/AxWin3 - Fixed window destruction not working correctly --- diff --git a/Usermode/Applications/axwin3_src/WM/include/lowlevel.h b/Usermode/Applications/axwin3_src/WM/include/lowlevel.h index 5b33fbf7..49d9720f 100644 --- a/Usermode/Applications/axwin3_src/WM/include/lowlevel.h +++ b/Usermode/Applications/axwin3_src/WM/include/lowlevel.h @@ -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 diff --git a/Usermode/Applications/axwin3_src/WM/ipc_acess.c b/Usermode/Applications/axwin3_src/WM/ipc_acess.c index 1d6e3446..26f60a24 100644 --- a/Usermode/Applications/axwin3_src/WM/ipc_acess.c +++ b/Usermode/Applications/axwin3_src/WM/ipc_acess.c @@ -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); + } } } diff --git a/Usermode/Applications/axwin3_src/WM/main.c b/Usermode/Applications/axwin3_src/WM/main.c index 5a2c3549..10503953 100644 --- a/Usermode/Applications/axwin3_src/WM/main.c +++ b/Usermode/Applications/axwin3_src/WM/main.c @@ -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; } diff --git a/Usermode/Applications/axwin3_src/WM/wm.c b/Usermode/Applications/axwin3_src/WM/wm.c index e2007000..342f4104 100644 --- a/Usermode/Applications/axwin3_src/WM/wm.c +++ b/Usermode/Applications/axwin3_src/WM/wm.c @@ -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)