Index: windialogs.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/windialogs.c,v
retrieving revision 1.1.6.2
diff -u -r1.1.6.2 windialogs.c
--- windialogs.c	27 Jan 2004 05:39:29 -0000	1.1.6.2
+++ windialogs.c	1 Feb 2004 13:36:43 -0000
@@ -32,6 +32,7 @@
 #include "win.h"
 
 extern Bool			g_fCursor;
+extern Bool                     g_fClipboardStarted;
 
 BOOL CALLBACK
 winExitDlgProc (HWND hDialog, UINT message,
@@ -79,6 +80,31 @@
 void
 winDisplayExitDialog (winPrivScreenPtr pScreenPriv)
 {
+  int i;
+  int liveClients = 0;
+
+  /* Count up running clinets (clients[0] is serverClient) */
+  for (i = 1; i < currentMaxClients; i++)
+    if (clients[i] != NullClient)	
+      liveClients++;
+  /* Count down server internal clients */
+  if (pScreenPriv->pScreenInfo->fMultiWindow)
+    liveClients -= 2; /* multiwindow window manager & XMsgProc  */
+  if (g_fClipboardStarted)
+    liveClients--; /* clipboard manager */
+
+  if (liveClients <= 0)
+    {
+      /* Don't confirm exit since no client runs */  
+      if (g_hDlgExit != NULL)
+	{
+	  DestroyWindow (g_hDlgExit);
+	  g_hDlgExit = NULL;
+	}
+      PostMessage (pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
+      return;
+    }
+  
   /* Check if dialog already exists */
   if (g_hDlgExit != NULL)
     {
