Implemented WaitForInputIdle.

diff --git a/windows/user.c b/windows/user.c
index fc3e1b6..68f380e 100644
--- a/windows/user.c
+++ b/windows/user.c
@@ -207,7 +207,9 @@
 WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
                             DWORD dwFlags, HMODULE16 hModule )
 {
+    static HANDLE win16_idle_event;
     HINSTANCE16 hInst;
+    PDB * pdb;
 
     /* FIXME: Proper reaction to most signals still missing. */
 
@@ -234,18 +236,48 @@
         break;
 
     case USIG_PROCESS_CREATE:
+      pdb = PROCESS_IdToPDB( dwThreadOrProcessID );
+
+      /* Create the idle event for the process. We have just one idle_event for all
+	 win16 processes, while each win32 process has its own */
+
+      if ( pdb->flags & PDB32_WIN16_PROC )
+      {
+          if (!win16_idle_event)
+          {
+              win16_idle_event = CreateEventA ( NULL, TRUE, FALSE, NULL );
+              win16_idle_event = ConvertToGlobalHandle ( win16_idle_event );
+          }
+          pdb->idle_event = win16_idle_event;
+      }
+      else { /* win32 process */
+	pdb->idle_event = CreateEventA ( NULL, TRUE, FALSE, NULL );
+        pdb->idle_event = ConvertToGlobalHandle ( pdb->idle_event );
+	TRACE_(win)("created win32 idle event: %x\n", pdb->idle_event );
+      }
+      break;
+
     case USIG_PROCESS_INIT:
     case USIG_PROCESS_LOADED:
+      break;
     case USIG_PROCESS_RUNNING:
+        pdb = PROCESS_IdToPDB ( dwThreadOrProcessID );
+	SetEvent ( pdb->idle_event );
         break;
 
     case USIG_PROCESS_EXIT:
         break;
 
-    case USIG_PROCESS_DESTROY:
-        hInst = GetProcessDword( dwThreadOrProcessID, GPD_HINSTANCE16 );
-        USER_AppExit( hInst );
-        break;
+    case USIG_PROCESS_DESTROY:      
+      hInst = GetProcessDword( dwThreadOrProcessID, GPD_HINSTANCE16 );
+      USER_AppExit( hInst );
+
+      pdb = PROCESS_IdToPDB( dwThreadOrProcessID );
+      if ( ! (pdb->flags & PDB32_WIN16_PROC) ) {
+	TRACE_(win)("destroying win32 idle event: %x\n", pdb->idle_event );
+	CloseHandle ( pdb->idle_event );	
+      }
+      break;
 
     default:
         FIXME_(win)("(%04x, %08lx, %04lx, %04x)\n",