[Xorg-commit] xc/programs/Xserver/hw/xwin InitOutput.c,1.1.4.1.2.7,1.1.4.1.2.8 win.h,1.1.4.1.2.7,1.1.4.1.2.8 winclipboard.h,1.1.4.1.2.3,1.1.4.1.2.4 winclipboardinit.c,1.1.4.1.2.2,1.1.4.1.2.3 winclipboardthread.c,1.1.4.1.2.3,1.1.4.1.2.4 winclipboardwndproc.c,1.1.4.1.2.4,1.1.4.1.2.5 winclipboardwrappers.c,1.1.2.2,1.1.2.3 winglobals.c,1.1.2.1,1.1.2.2 winprocarg.c,1.1.2.2,1.1.2.3 winwndproc.c,1.1.4.1.2.5,1.1.4.1.2.6

Harold L Hunt II xorg-commit at pdx.freedesktop.org
Sat Jan 10 09:51:19 EET 2004


Committed by: harold

Update of /cvs/xorg/xc/programs/Xserver/hw/xwin
In directory pdx:/tmp/cvs-serv9713

Modified Files:
      Tag: CYGWIN
	InitOutput.c win.h winclipboard.h winclipboardinit.c 
	winclipboardthread.c winclipboardwndproc.c 
	winclipboardwrappers.c winglobals.c winprocarg.c winwndproc.c 
Log Message:
Synch with Cygwin/X release 4.3.0-34.  Major clipboard rework.  (Harold L Hunt II).

Index: InitOutput.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/InitOutput.c,v
retrieving revision 1.1.4.1.2.7
retrieving revision 1.1.4.1.2.8
diff -u -d -r1.1.4.1.2.7 -r1.1.4.1.2.8
--- InitOutput.c	8 Jan 2004 18:08:37 -0000	1.1.4.1.2.7
+++ InitOutput.c	10 Jan 2004 07:50:57 -0000	1.1.4.1.2.8
@@ -105,6 +105,10 @@
 const int NUMFORMATS = sizeof (g_PixmapFormats) / sizeof (g_PixmapFormats[0]);
 
 #if defined(DDXOSRESET)
+extern pthread_t		g_ptClipboardProc;
+extern HWND			g_hwndClipboard;
+extern Bool			g_fClipboard;
+
 /*
  * Called right before KillAllClients when the server is going to reset,
  * allows us to shutdown our seperate threads cleanly.
@@ -117,32 +121,17 @@
 
   ErrorF ("OsVendorReset - Hello\n");
 
-  /* Walk the list of screens */
-  for (i = 0; i < g_iNumScreens; i++)
+  /* Close down clipboard resources */
+  if (g_fClipboard)
     {
-      ScreenPtr		pScreen = g_ScreenInfo[i].pScreen;
-      winScreenPriv(pScreen);
-
-      /* Close down clipboard resources */
-      if (g_ScreenInfo[i].fClipboard)
-	{
-	  HWND		hwndClipboard = pScreenPriv->hwndClipboard;
-	  
-	  /* Prevent our wrapped SetSelectionOwner function from segfaulting */
-	  pScreenPriv->hwndClipboard = NULL;
-	  pScreenPriv->pClipboardDisplay = NULL;
-	  pScreenPriv->iClipboardWindow = 0;
-	  pScreenPriv->fCBCInitialized = FALSE;
-
-	  /* Synchronously destroy the clipboard window */
-	  if (hwndClipboard != NULL)
-	    SendMessage (hwndClipboard, WM_DESTROY, 0, 0);
+      /* Synchronously destroy the clipboard window */
+      if (g_hwndClipboard != NULL)
+	SendMessage (g_hwndClipboard, WM_DESTROY, 0, 0);
+      
+      /* Wait for the clipboard thread to exit */
+      pthread_join (g_ptClipboardProc, NULL);
 
-	  /* Wait for the clipboard thread to exit */
-	  pthread_join (pScreenPriv->ptClipboardProc, NULL);
-	  
-	  ErrorF ("OsVendorReset - Clipboard thread has exited.\n");
-	}
+      ErrorF ("OsVendorReset - Clipboard thread has exited.\n");
     }
 }
 #endif

Index: win.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/win.h,v
retrieving revision 1.1.4.1.2.7
retrieving revision 1.1.4.1.2.8
diff -u -d -r1.1.4.1.2.7 -r1.1.4.1.2.8
--- win.h	8 Jan 2004 05:10:32 -0000	1.1.4.1.2.7
+++ win.h	10 Jan 2004 07:50:57 -0000	1.1.4.1.2.8
@@ -402,7 +402,6 @@
   Bool			fPseudoRootless;
   Bool			fMultiWindow;
   Bool                  fMultipleMonitors;
-  Bool			fClipboard;
   Bool			fLessPointer;
   Bool			fScrollbars;
   Bool			fNoTrayIcon;
@@ -444,16 +443,6 @@
   /* Handle to icons that must be freed */
   HICON			hiconNotifyIcon;
 
-  /* Clipboard support */
-  pthread_t		ptClipboardProc;
-  Bool			fClipboardStarted;
-  HWND			hwndClipboard;
-  void			*pClipboardDisplay;
-  Window		iClipboardWindow;
-  HWND			hwndClipboardNextViewer;
-  Bool			fCBCInitialized;
-  Atom			atomLastOwnedSelection;
-
   /* Last width, height, and depth of the Windows display */
   DWORD			dwLastWindowsWidth;
   DWORD			dwLastWindowsHeight;
@@ -774,15 +763,8 @@
  */
 
 Bool
-winInitClipboard (pthread_t *ptClipboardProc,
-		  Bool *pfClipboardStarted,
-		  HWND *phwndClipboard,
-		  void **ppClipboardDisplay,
-		  Window *piClipboardWindow,
-		  HWND *phwndClipboardNextViewer,
-		  Bool *pfCBCInitialized,
-		  Atom *patomLastOwnedSelection,
-		  DWORD dwScreen);
+winInitClipboard ();
+
 
 /*
  * winclipboardthread.c
@@ -1209,6 +1191,14 @@
 
 
 /*
+ * winprocarg.c
+ */
+
+void
+winInitializeDefaultScreens (void);
+
+
+/*
  * winscrinit.c
  */
 

Index: winclipboard.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winclipboard.h,v
retrieving revision 1.1.4.1.2.3
retrieving revision 1.1.4.1.2.4
diff -u -d -r1.1.4.1.2.3 -r1.1.4.1.2.4
--- winclipboard.h	8 Jan 2004 07:14:48 -0000	1.1.4.1.2.3
+++ winclipboard.h	10 Jan 2004 07:50:57 -0000	1.1.4.1.2.4
@@ -76,35 +76,6 @@
 
 
 /*
- * Argument structure for Clipboard module main thread
- */
-
-typedef struct _ClipboardProcArgRec {
-  DWORD			dwScreen;
-  Bool			*pfClipboardStarted;
-  HWND			*phwndClipboard;
-  void			**ppClipboardDisplay;
-  Window		*piClipboardWindow;
-  HWND			*phwndClipboardNextViewer;
-  Bool			*pfCBCInitialized;
-  Atom			*patomLastOwnedSelection;
-} ClipboardProcArgRec, *ClipboardProcArgPtr;
-
-
-/*
- * Structure for messaging window properties
- */
-
-typedef struct _ClipboardWindowProp {
-  void			**ppClipboardDisplay;
-  Window		*piClipboardWindow;
-  HWND			*phwndClipboardNextViewer;
-  Bool			*pfCBCInitialized;
-  Atom			*patomLastOwnedSelection;
-} ClipboardWindowPropRec, *ClipboardWindowPropPtr;
-
-
-/*
  * References to external symbols
  */
 
@@ -117,18 +88,10 @@
  */
 
 Bool
-winInitClipboard (pthread_t *ptClipboardProc,
- 		  Bool *pfClipboardStarted,
- 		  HWND *phwndClipboard,
-		  void **ppClipboardDisplay,
- 		  Window *piClipboardWindow,
- 		  HWND *phwndClipboardNextViewer,
- 		  Bool *pfCBCInitialized,
- 		  Atom *patomLastOwnedSelection,
-		  DWORD dwScreen);
+winInitClipboard ();
 
 HWND
-winClipboardCreateMessagingWindow (ClipboardProcArgPtr pProcArg);
+winClipboardCreateMessagingWindow ();
 
 
 /*
@@ -147,7 +110,7 @@
  */
 
 void *
-winClipboardProc (void *pArg);
+winClipboardProc ();
 
 void
 winDeinitClipboard (void);

Index: winclipboardinit.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winclipboardinit.c,v
retrieving revision 1.1.4.1.2.2
retrieving revision 1.1.4.1.2.3
diff -u -d -r1.1.4.1.2.2 -r1.1.4.1.2.3
--- winclipboardinit.c	8 Jan 2004 05:10:32 -0000	1.1.4.1.2.2
+++ winclipboardinit.c	10 Jan 2004 07:50:57 -0000	1.1.4.1.2.3
@@ -30,9 +30,9 @@
 /* $XFree86: xc/programs/Xserver/hw/xwin/winclipboardinit.c,v 1.2 2003/07/29 21:25:16 dawes Exp $ */
 
 #include "dixstruct.h"
-
 #include "winclipboard.h"
 
+
 /*
  * Local typedefs
  */
@@ -41,6 +41,12 @@
 
 DISPATCH_PROC(winProcSetSelectionOwner);
 
+
+/*
+ * References to external symbols
+ */
+
+extern pthread_t		g_ptClipboardProc;
 extern winDispatchProcPtr	winProcSetSelectionOwnerOrig;
 
 
@@ -49,28 +55,10 @@
  */
 
 Bool
-winInitClipboard (pthread_t *ptClipboardProc,
-		  Bool *pfClipboardStarted,
-		  HWND *phwndClipboard,
-		  void **ppClipboardDisplay,
-		  Window *piClipboardWindow,
-		  HWND *phwndClipboardNextViewer,
-		  Bool *pfCBCInitialized,
-		  Atom *patomLastOwnedSelection,
-		  DWORD dwScreen)
+winInitClipboard ()
 {
-  ClipboardProcArgPtr		pArg;
-
   ErrorF ("winInitClipboard ()\n");
 
-  /* Allocate the parameter structure */
-  pArg = (ClipboardProcArgPtr) malloc (sizeof (ClipboardProcArgRec));
-  if (pArg == NULL)
-    {
-      ErrorF ("winInitClipboard - malloc for ClipboardProcArgRec failed.\n");
-      return FALSE;
-    }
-
   /* Wrap some internal server functions */
   if (ProcVector[X_SetSelectionOwner] != winProcSetSelectionOwner)
     {
@@ -78,18 +66,11 @@
       ProcVector[X_SetSelectionOwner] = winProcSetSelectionOwner;
     }
   
-  /* Setup the argument structure for the thread function */
-  pArg->dwScreen = dwScreen;
-  pArg->pfClipboardStarted = pfClipboardStarted;
-  pArg->phwndClipboard = phwndClipboard;
-  pArg->ppClipboardDisplay = ppClipboardDisplay;
-  pArg->piClipboardWindow = piClipboardWindow;
-  pArg->phwndClipboardNextViewer = phwndClipboardNextViewer;
-  pArg->patomLastOwnedSelection = patomLastOwnedSelection;
-  pArg->pfCBCInitialized = pfCBCInitialized;
-
   /* Spawn a thread for the Clipboard module */
-  if (pthread_create (ptClipboardProc, NULL, winClipboardProc, pArg))
+  if (pthread_create (&g_ptClipboardProc,
+		      NULL,
+		      winClipboardProc,
+		      NULL))
     {
       /* Bail if thread creation failed */
       ErrorF ("winInitClipboard - pthread_create failed.\n");
@@ -105,11 +86,10 @@
  */
 
 HWND
-winClipboardCreateMessagingWindow (ClipboardProcArgPtr pProcArg)
+winClipboardCreateMessagingWindow ()
 {
   WNDCLASS			wc;
   HWND				hwnd;
-  ClipboardWindowPropPtr	pWindowProp = NULL;
 
   /* Setup our window class */
   wc.style = CS_HREDRAW | CS_VREDRAW;
@@ -124,19 +104,6 @@
   wc.lpszClassName = WIN_CLIPBOARD_WINDOW_CLASS;
   RegisterClass (&wc);
 
-  /* Allocate and setup window property structure */
-  pWindowProp = malloc (sizeof (ClipboardWindowPropRec));
-  if (pWindowProp == NULL)
-    {
-      ErrorF ("winClipboardCreateMessagingWindow - malloc failed!\n");
-      pthread_exit (NULL);
-    }
-  pWindowProp->ppClipboardDisplay = pProcArg->ppClipboardDisplay;
-  pWindowProp->piClipboardWindow = pProcArg->piClipboardWindow;
-  pWindowProp->phwndClipboardNextViewer = pProcArg->phwndClipboardNextViewer;
-  pWindowProp->pfCBCInitialized = pProcArg->pfCBCInitialized;
-  pWindowProp->patomLastOwnedSelection = pProcArg->patomLastOwnedSelection;
-
   /* Create the window */
   hwnd = CreateWindowExA (0,			/* Extended styles */
 			  WIN_CLIPBOARD_WINDOW_CLASS,/* Class name */
@@ -149,7 +116,7 @@
 			  (HWND) NULL,		/* No parent or owner window */
 			  (HMENU) NULL,		/* No menu */
 			  GetModuleHandle (NULL),/* Instance handle */
-			  pWindowProp);		/* Creation data */
+			  NULL);		/* Creation data */
   assert (hwnd != NULL);
 
   /* I'm not sure, but we may need to call this to start message processing */

Index: winclipboardthread.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winclipboardthread.c,v
retrieving revision 1.1.4.1.2.3
retrieving revision 1.1.4.1.2.4
diff -u -d -r1.1.4.1.2.3 -r1.1.4.1.2.4
--- winclipboardthread.c	8 Jan 2004 07:14:48 -0000	1.1.4.1.2.3
+++ winclipboardthread.c	10 Jan 2004 07:50:57 -0000	1.1.4.1.2.4
@@ -32,6 +32,7 @@
 #include "winclipboard.h"
 #include "Xauth.h"
 
+
 /*
  * Constants
  */
@@ -48,6 +49,10 @@
 extern unsigned long	serverGeneration;
 extern unsigned int	g_uiAuthDataLen;
 extern char		*g_pAuthData;
+extern Bool		g_fClipboardStarted;
+extern HWND		g_hwndClipboard;
+extern void		*g_pClipboardDisplay;
+extern Window		g_iClipboardWindow;
 
 
 /*
@@ -74,7 +79,7 @@
  */
 
 void *
-winClipboardProc (void *pArg)
+winClipboardProc ()
 {
   Atom			atomClipboard, atomClipboardManager;
   int			iReturn;
@@ -85,21 +90,12 @@
   int			iMaxDescriptor;
   Display		*pDisplay;
   Window		iWindow;
-  Bool			fReturn;
   int			iRetries;
   Bool			fUnicodeSupport;
   char			szDisplay[512];
-  ClipboardProcArgPtr	pProcArg = (ClipboardProcArgPtr) pArg;
 
   ErrorF ("winClipboardProc - Hello\n");
 
-  /* Check that argument pointer is not invalid */
-  if (pArg == NULL)
-    {
-      ErrorF ("winClipboardProc - pArg is NULL, bailing.\n");
-      pthread_exit (NULL);
-    }
-
   /* Do we have Unicode support? */
   fUnicodeSupport = g_fUnicodeClipboard && winClipboardDetectUnicodeSupport ();
 
@@ -170,11 +166,17 @@
   iRetries = 0;
 
   /* Setup the display connection string x */
+  /*
+   * NOTE: Always connect to screen 0 since we require that screen
+   * numbers start at 0 and increase without gaps.  We only need
+   * to connect to one screen on the display to get events
+   * for all screens on the display.  That is why there is only
+   * one clipboard client thread.
+   */
   snprintf (szDisplay,
 	    512,
-	    "127.0.0.1:%s.%d",
-	    display,
-	    (int) pProcArg->dwScreen);
+	    "127.0.0.1:%s.0",
+	    display);
 
   /* Print the display connection string */
   ErrorF ("winClipboardProc - DISPLAY=%s\n", szDisplay);
@@ -205,7 +207,7 @@
     }
 
   /* Save the display in the screen privates */
-  *(pProcArg->ppClipboardDisplay) = pDisplay;
+  g_pClipboardDisplay = pDisplay;
 
   ErrorF ("winClipboardProc - XOpenDisplay () returned and "
 	  "successfully opened the display.\n");
@@ -255,13 +257,13 @@
     }
 
   /* Save the window in the screen privates */
-  *(pProcArg->piClipboardWindow) = iWindow;
+  g_iClipboardWindow = iWindow;
 
   /* Create Windows messaging window */
-  hwnd = winClipboardCreateMessagingWindow (pProcArg);
+  hwnd = winClipboardCreateMessagingWindow ();
   
   /* Save copy of HWND in screen privates */
-  *(pProcArg->phwndClipboard) = hwnd;
+  g_hwndClipboard = hwnd;
 
 #if 0
   /* Assert ownership of CLIPBOARD_MANAGER */
@@ -312,7 +314,7 @@
     return 0;
 
   /* Signal that the clipboard client has started */
-  *(pProcArg->pfClipboardStarted) = TRUE;
+  g_fClipboardStarted = TRUE;
 
   /* Loop for X events */
   while (1)

Index: winclipboardwndproc.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winclipboardwndproc.c,v
retrieving revision 1.1.4.1.2.4
retrieving revision 1.1.4.1.2.5
diff -u -d -r1.1.4.1.2.4 -r1.1.4.1.2.5
--- winclipboardwndproc.c	9 Jan 2004 06:49:46 -0000	1.1.4.1.2.4
+++ winclipboardwndproc.c	10 Jan 2004 07:50:57 -0000	1.1.4.1.2.5
@@ -44,6 +44,9 @@
  */
 
 extern Bool		g_fUnicodeSupport;
+extern void		*g_pClipboardDisplay;
+extern Window		g_iClipboardWindow;
+extern Atom		g_atomLastOwnedSelection;
 
 
 /* 
@@ -76,8 +79,8 @@
 winClipboardWindowProc (HWND hwnd, UINT message, 
 			WPARAM wParam, LPARAM lParam)
 {
-  ClipboardWindowPropPtr	pWindowProp = GetProp (hwnd,
-						       WIN_CLIPBOARD_PROP);
+  static HWND		s_hwndNextViewer;
+  static Bool		s_fCBCInitialized;
 
   /* Branch on message type */
   switch (message)
@@ -86,17 +89,10 @@
       {
 	ErrorF ("winClipboardWindowProc - WM_DESTROY\n");
 
-	HWND	*phwndNextViewer = pWindowProp->phwndClipboardNextViewer;
-	
 	/* Remove ourselves from the clipboard chain */
-	ChangeClipboardChain (hwnd, *phwndNextViewer);
-	
-	*phwndNextViewer = NULL;
+	ChangeClipboardChain (hwnd, s_hwndNextViewer);
 	
-	/* Free the window property data */
-	free (pWindowProp);
-	pWindowProp = NULL;
-	SetProp (hwnd, WIN_CLIPBOARD_PROP, NULL);
+	s_hwndNextViewer = NULL;
 
 	PostQuitMessage (0);
       }
@@ -107,58 +103,49 @@
       {
 	ErrorF ("winClipboardWindowProc - WM_CREATE\n");
 	
-	/* Fetch window data from creation data */
-	pWindowProp = ((LPCREATESTRUCT) lParam)->lpCreateParams;
-	
-	/* Save data as a window property */
-	SetProp (hwnd, WIN_CLIPBOARD_PROP, pWindowProp);
-
 	/* Add ourselves to the clipboard viewer chain */
-	*(pWindowProp->phwndClipboardNextViewer) = SetClipboardViewer (hwnd);
+	s_hwndNextViewer = SetClipboardViewer (hwnd);
       }
       return 0;
 
 
     case WM_CHANGECBCHAIN:
       {
-	HWND	*phwndNextViewer = pWindowProp->phwndClipboardNextViewer;
-
-	if ((HWND) wParam == *phwndNextViewer)
-	  *phwndNextViewer = (HWND) lParam;
-	else if (*phwndNextViewer)
-	  SendMessage (*phwndNextViewer, message, wParam, lParam);
+	if ((HWND) wParam == s_hwndNextViewer)
+	  s_hwndNextViewer = (HWND) lParam;
+	else if (s_hwndNextViewer)
+	  SendMessage (s_hwndNextViewer, message,
+		       wParam, lParam);
       }
       return 0;
 
 
     case WM_DRAWCLIPBOARD:
       {
-	HWND	*phwndNextViewer = pWindowProp->phwndClipboardNextViewer;
-	Bool	*pfCBCInitialized = pWindowProp->pfCBCInitialized;
-	Display *pDisplay = *(pWindowProp->ppClipboardDisplay);
-	Window	iWindow = *(pWindowProp->piClipboardWindow);
+	Display	*pDisplay = g_pClipboardDisplay;
+	Window	iWindow = g_iClipboardWindow;
 	int	iReturn;
 
 	/* Pass the message on the next window in the clipboard viewer chain */
-	if (*phwndNextViewer)
-	  SendMessage (*phwndNextViewer, message, 0, 0);
+	if (s_hwndNextViewer)
+	  SendMessage (s_hwndNextViewer, message, 0, 0);
 	
 	/* Bail on first message */
-	if (!*pfCBCInitialized)
+	if (!s_fCBCInitialized)
 	  {
 	    ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
 		    "Initializing - Returning.\n");
-	    *pfCBCInitialized = TRUE;
-	    return 0;
-	  }
-	
-	/* Bail when clipboard is unowned */
-	if (NULL == GetClipboardOwner ())
-	  {
-	    ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
-		    "Clipboard is unowned.\n");
+	    s_fCBCInitialized = TRUE;
 	    return 0;
 	  }
+
+	/*
+	 * NOTE: We cannot bail out when NULL == GetClipboardOwner ()
+	 * because some applications deal with the clipboard in a manner
+	 * that causes the clipboard owner to be NULL when they are in
+	 * fact taking ownership.  One example of this is the Win32
+	 * native compile of emacs.
+	 */
 	
 	/* Bail when we still own the clipboard */
 	if (hwnd == GetClipboardOwner ())
@@ -208,13 +195,66 @@
       return 0;
 
 
+    case WM_DESTROYCLIPBOARD:
+#if 0
+      {
+	int	iReturn;
+	Display *pDisplay = g_pClipboardDisplay;
+
+	/* Do nothing if winProcSetSelectionOwner called EmptyClipboard */
+	if (hwnd == GetClipboardOwner ())
+	  {
+	    ErrorF ("winClipboardWindowProc - WM_DESTROYCLIPBOARD - "
+		    "winProcSetSelectionOwner called EmptyClipboard, "
+		    "doing nothing.\n");
+	    return 0;
+	  }
+
+	/* Release ownership of PRIMARY */	  
+	iReturn = XSetSelectionOwner (pDisplay,
+				      XA_PRIMARY,
+				      None,
+				      CurrentTime);
+	if (iReturn == BadAtom || iReturn == BadWindow)
+	  {
+	    ErrorF ("winClipboardWindowProc - WM_DESTROYCLIPBOARD - "
+		    "Could not release ownership of PRIMARY\n");
+	  }
+	else
+	  {
+	    ErrorF ("winClipboardWindowProc - WM_DESTROYCLIPBOARD - "
+		    "Released ownership of PRIMARY\n");
+	  }
+	
+	/* Release ownership of the CLIPBOARD */	  
+	iReturn = XSetSelectionOwner (pDisplay,
+				      XInternAtom (pDisplay,
+						   "CLIPBOARD",
+						   FALSE),
+				      None,
+				      CurrentTime);
+	if (iReturn == BadAtom || iReturn == BadWindow)
+	  {
+	    ErrorF ("winClipboardWindowProc - WM_DESTROYCLIPBOARD - "
+		    "Could not release ownership of CLIPBOARD\n");
+	  }
+	else
+	  {
+	    ErrorF ("winClipboardWindowProc - WM_DESTROYCLIPBOARD - "
+		    "Released ownership of CLIPBOARD\n");
+	  }
+      }
+#endif
+      return 0;
+
+
     case WM_RENDERFORMAT:
     case WM_RENDERALLFORMATS:
       {
 	XEvent	event;
 	int	iReturn;
-	Display *pDisplay = *(pWindowProp->ppClipboardDisplay);
-	Window	iWindow = *(pWindowProp->piClipboardWindow);
+	Display *pDisplay = g_pClipboardDisplay;
+	Window	iWindow = g_iClipboardWindow;
 	Bool	fConvertToUnicode;
 
 #if 0
@@ -225,11 +265,11 @@
 	if (message == WM_RENDERALLFORMATS)
 	  fConvertToUnicode = FALSE;
 	else
-	  fConvertToUnicode = (CF_UNICODETEXT == wParam);
-	
+	  fConvertToUnicode = g_fUnicodeSupport && (CF_UNICODETEXT == wParam);
+
 	/* Request the selection contents */
 	iReturn = XConvertSelection (pDisplay,
-				     *(pWindowProp->patomLastOwnedSelection),
+				     g_atomLastOwnedSelection,
 				     XInternAtom (pDisplay,
 						  "COMPOUND_TEXT", False),
 				     XInternAtom (pDisplay,

Index: winclipboardwrappers.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/Attic/winclipboardwrappers.c,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -d -r1.1.2.2 -r1.1.2.3
--- winclipboardwrappers.c	9 Jan 2004 06:24:25 -0000	1.1.2.2
+++ winclipboardwrappers.c	10 Jan 2004 07:50:57 -0000	1.1.2.3
@@ -30,6 +30,23 @@
 
 #include "win.h"
 #include "dixstruct.h"
+#include "Xatom.h"
+
+
+/*
+ * Constants
+ */
+
+#define CLIP_NUM_SELECTIONS		2
+#define CLIP_OWN_PRIMARY		0
+#define CLIP_OWN_CLIPBOARD		1
+
+
+/*
+ * Globals
+ */
+
+static Window		g_iOwners[CLIP_NUM_SELECTIONS];
 
 
 /*
@@ -40,6 +57,7 @@
 DISPATCH_PROC(winProcQueryTree);
 DISPATCH_PROC(winProcSetSelectionOwner);
 
+
 /*
  * References to external symbols
  */
@@ -50,13 +68,17 @@
 extern char		*g_pAuthData;
 extern Bool		g_fXdmcpEnabled;
 extern Bool		g_fClipboardLaunched;
+extern Bool		g_fClipboardStarted;
+extern Bool		g_fClipboard;
+extern Window		g_iClipboardWindow;
+extern Atom		g_atomLastOwnedSelection;
+extern HWND		g_hwndClipboard;
 
 extern winDispatchProcPtr	winProcEstablishConnectionOrig;
 extern winDispatchProcPtr	winProcQueryTreeOrig;
 extern winDispatchProcPtr	winProcSetSelectionOwnerOrig;
 
 
-
 /*
  * Wrapper for internal QueryTree function.
  * Hides the clipboard client when it is the only client remaining.
@@ -65,7 +87,6 @@
 int
 winProcQueryTree (ClientPtr client)
 {
-  int			i;
   int			iReturn;
 
   /*
@@ -96,62 +117,46 @@
       return iReturn;
     }
 
-  /* Walk the list of screens */
-  for (i = 0; i < g_iNumScreens; i++)
+  /* Startup the clipboard client if clipboard mode is being used */
+  if (g_fXdmcpEnabled && g_fClipboard)
     {
-      ScreenPtr		pScreen = g_ScreenInfo[i].pScreen;
-      winScreenPriv(pScreen);
-
-      /* Startup the clipboard client if clipboard mode is being used */
-      if (g_fXdmcpEnabled
-	  && g_ScreenInfo[i].fClipboard)
+      /*
+       * NOTE: The clipboard client is started here for a reason:
+       * 1) Assume you are using XDMCP (e.g. XWin -query %hostname%)
+       * 2) If the clipboard client attaches during X Server startup,
+       *    then it becomes the "magic client" that causes the X Server
+       *    to reset if it exits.
+       * 3) XDMCP calls KillAllClients when it starts up.
+       * 4) The clipboard client is a client, so it is killed.
+       * 5) The clipboard client is the "magic client", so the X Server
+       *    resets itself.
+       * 6) This repeats ad infinitum.
+       * 7) We avoid this by waiting until at least one client (could
+       *    be XDM, could be another client) connects, which makes it
+       *    almost certain that the clipboard client will not connect
+       *    until after XDM when using XDMCP.
+       * 8) Unfortunately, there is another problem.
+       * 9) XDM walks the list of windows with XQueryTree,
+       *    killing any client it finds with a window.
+       * 10)Thus, when using XDMCP we wait until the first call
+       *    to ProcQueryTree before we startup the clipboard client.
+       *    This should prevent XDM from finding the clipboard client,
+       *    since it has not yet created a window.
+       * 11)Startup when not using XDMCP is handled in
+       *    winProcEstablishConnection.
+       */
+      
+      /* Create the clipboard client thread */
+      if (!winInitClipboard ())
 	{
-	  /*
-	   * NOTE: The clipboard client is started here for a reason:
-	   * 1) Assume you are using XDMCP (e.g. XWin -query %hostname%)
-	   * 2) If the clipboard client attaches during X Server startup,
-	   *    then it becomes the "magic client" that causes the X Server
-	   *    to reset if it exits.
-	   * 3) XDMCP calls KillAllClients when it starts up.
-	   * 4) The clipboard client is a client, so it is killed.
-	   * 5) The clipboard client is the "magic client", so the X Server
-	   *    resets itself.
-	   * 6) This repeats ad infinitum.
-	   * 7) We avoid this by waiting until at least one client (could
-	   *    be XDM, could be another client) connects, which makes it
-	   *    almost certain that the clipboard client will not connect
-	   *    until after XDM when using XDMCP.
-	   * 8) Unfortunately, there is another problem.
-	   * 9) XDM walks the list of windows with XQueryTree,
-	   *    killing any client it finds with a window.
-	   * 10)Thus, when using XDMCP we wait until the first call
-	   *    to ProcQueryTree before we startup the clipboard client.
-	   *    This should prevent XDM from finding the clipboard client,
-	   *    since it has not yet created a window.
-	   * 11)Startup when not using XDMCP is handled in
-	   *    winProcEstablishConnection.
-	   */
-	  
-	  /* Create the clipboard client thread */
-	  if (!winInitClipboard (&pScreenPriv->ptClipboardProc,
-				 &pScreenPriv->fClipboardStarted,
-				 &pScreenPriv->hwndClipboard,
-				 &pScreenPriv->pClipboardDisplay,
-				 &pScreenPriv->iClipboardWindow,
-				 &pScreenPriv->hwndClipboardNextViewer,
-				 &pScreenPriv->fCBCInitialized,
-				 &pScreenPriv->atomLastOwnedSelection,
-				 g_ScreenInfo[i].dwScreen))
-	    {
-	      ErrorF ("winProcQueryTree - winClipboardInit "
-		      "failed.\n");
-	      return iReturn;
-	    }
-
-	  ErrorF ("winProcQueryTree - winInitClipboard returned.\n");
+	  ErrorF ("winProcQueryTree - winClipboardInit "
+		  "failed.\n");
+	  return iReturn;
 	}
+      
+      ErrorF ("winProcQueryTree - winInitClipboard returned.\n");
     }
-
+  
   /* Flag that clipboard client has been launched */
   g_fClipboardLaunched = TRUE;
 
@@ -168,7 +173,6 @@
 int
 winProcEstablishConnection (ClientPtr client)
 {
-  int			i;
   int			iReturn;
   static int		s_iCallCount = 0;
   static unsigned long	s_ulServerGeneration = 0;
@@ -191,10 +195,10 @@
   /* Wait for second call when Xdmcp is enabled */
   if (g_fXdmcpEnabled
       && !g_fClipboardLaunched
-      && s_iCallCount < 3)
+      && s_iCallCount < 4)
     {
       ErrorF ("winProcEstablishConnection - Xdmcp enabled, waiting to "
-	      "start clipboard client until third call.\n");
+	      "start clipboard client until fourth call.\n");
       return (*winProcEstablishConnectionOrig) (client);
     }
 
@@ -230,59 +234,44 @@
       return iReturn;
     }
 
-  /* Walk the list of screens */
-  for (i = 0; i < g_iNumScreens; i++)
+  /* Startup the clipboard client if clipboard mode is being used */
+  if (g_fClipboard)
     {
-      ScreenPtr		pScreen = g_ScreenInfo[i].pScreen;
-      winScreenPriv(pScreen);
-
-      /* Startup the clipboard client if clipboard mode is being used */
-      if (g_ScreenInfo[i].fClipboard)
+      /*
+       * NOTE: The clipboard client is started here for a reason:
+       * 1) Assume you are using XDMCP (e.g. XWin -query %hostname%)
+       * 2) If the clipboard client attaches during X Server startup,
+       *    then it becomes the "magic client" that causes the X Server
+       *    to reset if it exits.
+       * 3) XDMCP calls KillAllClients when it starts up.
+       * 4) The clipboard client is a client, so it is killed.
+       * 5) The clipboard client is the "magic client", so the X Server
+       *    resets itself.
+       * 6) This repeats ad infinitum.
+       * 7) We avoid this by waiting until at least one client (could
+       *    be XDM, could be another client) connects, which makes it
+       *    almost certain that the clipboard client will not connect
+       *    until after XDM when using XDMCP.
+       * 8) Unfortunately, there is another problem.
+       * 9) XDM walks the list of windows with XQueryTree,
+       *    killing any client it finds with a window.
+       * 10)Thus, when using XDMCP we wait until the second call
+       *    to ProcEstablishCeonnection before we startup the clipboard
+       *    client.  This should prevent XDM from finding the clipboard
+       *    client, since it has not yet created a window.
+       */
+      
+      /* Create the clipboard client thread */
+      if (!winInitClipboard ())
 	{
-	  /*
-	   * NOTE: The clipboard client is started here for a reason:
-	   * 1) Assume you are using XDMCP (e.g. XWin -query %hostname%)
-	   * 2) If the clipboard client attaches during X Server startup,
-	   *    then it becomes the "magic client" that causes the X Server
-	   *    to reset if it exits.
-	   * 3) XDMCP calls KillAllClients when it starts up.
-	   * 4) The clipboard client is a client, so it is killed.
-	   * 5) The clipboard client is the "magic client", so the X Server
-	   *    resets itself.
-	   * 6) This repeats ad infinitum.
-	   * 7) We avoid this by waiting until at least one client (could
-	   *    be XDM, could be another client) connects, which makes it
-	   *    almost certain that the clipboard client will not connect
-	   *    until after XDM when using XDMCP.
-	   * 8) Unfortunately, there is another problem.
-	   * 9) XDM walks the list of windows with XQueryTree,
-	   *    killing any client it finds with a window.
-	   * 10)Thus, when using XDMCP we wait until the second call
-	   *    to ProcEstablishCeonnection before we startup the clipboard
-	   *    client.  This should prevent XDM from finding the clipboard
-	   *    client, since it has not yet created a window.
-	   */
-	  
-	  /* Create the clipboard client thread */
-	  if (!winInitClipboard (&pScreenPriv->ptClipboardProc,
-				 &pScreenPriv->fClipboardStarted,
-				 &pScreenPriv->hwndClipboard,
-				 &pScreenPriv->pClipboardDisplay,
-				 &pScreenPriv->iClipboardWindow,
-				 &pScreenPriv->hwndClipboardNextViewer,
-				 &pScreenPriv->fCBCInitialized,
-				 &pScreenPriv->atomLastOwnedSelection,
-				 g_ScreenInfo[i].dwScreen))
-	    {
-	      ErrorF ("winProcEstablishConnection - winClipboardInit "
-		      "failed.\n");
-	      return iReturn;
-	    }
-
-	  ErrorF ("winProcEstablishConnection - winInitClipboard returned.\n");
+	  ErrorF ("winProcEstablishConnection - winClipboardInit "
+		  "failed.\n");
+	  return iReturn;
 	}
+      
+      ErrorF ("winProcEstablishConnection - winInitClipboard returned.\n");
     }
-
+  
   /* Flag that clipboard client has been launched */
   g_fClipboardLaunched = TRUE;
 
@@ -299,10 +288,8 @@
 winProcSetSelectionOwner (ClientPtr client)
 {
   DrawablePtr		pDrawable;
-  ScreenPtr		pScreen = NULL;
-  winPrivScreenPtr	pScreenPriv = NULL;
-  HWND			hwndClipboard = NULL;
   WindowPtr		pWindow = None;
+  Bool			fOwnedToNotOwned = FALSE;
   REQUEST(xSetSelectionOwnerReq);
   
   REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
@@ -311,77 +298,93 @@
   ErrorF ("winProcSetSelectionOwner - Hello.\n");
 #endif
 
-  /* Grab the Window from the request */
-  if (stuff->window != None)
+  /* Abort if clipboard not completely initialized yet */
+  if (!g_fClipboardStarted)
     {
+      ErrorF ("winProcSetSelectionOwner - Clipboard not yet started, "
+	      "aborting.\n");
+      goto winProcSetSelectionOwner_Done;
+    }
+  
+  /* Grab window if we have one */
+  if (None != stuff->window)
+    {
+      /* Grab the Window from the request */
       pWindow = (WindowPtr) SecurityLookupWindow (stuff->window, client,
 						  SecurityReadAccess);
-      
       if (!pWindow)
 	{
 	  ErrorF ("winProcSetSelectionOwner - Found BadWindow, aborting.\n");
 	  goto winProcSetSelectionOwner_Done;
 	}
     }
-  else
-    {
-#if 0
-      ErrorF ("winProcSetSelectionOwner - No window specified, aborting.\n");
-#endif
-
-      /* Abort if we don't have a drawable for the client */
-      if ((pDrawable = client->lastDrawable) == NULL)
-	{
-	  ErrorF ("winProcSetSelectionOwner - Client has no "
-		  "lastDrawable, aborting.\n");
-	  goto winProcSetSelectionOwner_Done;
-	}
-      
-      /* Abort if we don't have a screen for the drawable */
-      if ((pScreen = pDrawable->pScreen) == NULL)
-	{
-	  ErrorF ("winProcSetSelectionOwner - Drawable has no screen, "
-		  "aborting.\n");
-	  goto winProcSetSelectionOwner_Done;
-	}
-
-      /* Abort if no screen privates */
-      if ((pScreenPriv = winGetScreenPriv (pScreen)) == NULL)
-	{
-	  ErrorF ("winProcSetSelectionOwner - Screen has no privates, "
-		  "aborting.\n");
-	  goto winProcSetSelectionOwner_Done;
-	}
 
-      /* Abort if clipboard not completely initialized yet */
-      if (!pScreenPriv->fClipboardStarted)
-	{
-	  ErrorF ("winProcSetSelectionOwner - Clipboard not yet started, "
-		  "aborting.\n");
-	  goto winProcSetSelectionOwner_Done;
-	}
+  /* Now we either have a valid window or None */
 
-      /* Abort if WM_DRAWCLIPBOARD disowned the selection */
-      if (pScreenPriv->iClipboardWindow == client->lastDrawableID)
+  /* Save selection owners for monitored selections, ignore other selections */
+  if (XA_PRIMARY == stuff->selection)
+    {
+      /* Look for owned -> not owned transition */
+      if (None == stuff->window
+	  && None != g_iOwners[CLIP_OWN_PRIMARY])
 	{
-	  ErrorF ("winProcSetSelectionOwner - WM_DRAWCLIPBOARD disowned "
-		  "the selection, aborting.\n");
-	  goto winProcSetSelectionOwner_Done;
+	  fOwnedToNotOwned = TRUE;
+	  
+	  /* Adjust last owned selection */
+	  if (None != g_iOwners[CLIP_OWN_CLIPBOARD])
+	    g_atomLastOwnedSelection = MakeAtom ("CLIPBOARD", 10, FALSE);
+	  else
+	    g_atomLastOwnedSelection = None;
 	}
-
-      /* Check if we own the clipboard */
-      if (pScreenPriv->hwndClipboard != NULL
-	  && pScreenPriv->hwndClipboard == GetClipboardOwner ())
+      
+      /* Save new selection owner or None */
+      g_iOwners[CLIP_OWN_PRIMARY] = stuff->window;
+    }
+  else if (MakeAtom ("CLIPBOARD", 10, FALSE) == stuff->selection)
+    {
+      /* Look for owned -> not owned transition */
+      if (None == stuff->window
+	  && None != g_iOwners[CLIP_OWN_CLIPBOARD])
 	{
-	  ErrorF ("winProcSetSelectionOwner - We currently own the "
-		  "clipboard, releasing ownership.\n");
-
-	  /* Release ownership of the Windows clipboard */
-	  OpenClipboard (NULL);
-	  EmptyClipboard ();
-	  CloseClipboard ();
+	  fOwnedToNotOwned = TRUE;
+	  
+	   /* Adjust last owned selection */
+	  if (None != g_iOwners[CLIP_OWN_PRIMARY])
+	    g_atomLastOwnedSelection = XA_PRIMARY;
+	  else
+	    g_atomLastOwnedSelection = None;
 	}
+      
+      g_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window;
+    }
+  else
+    goto winProcSetSelectionOwner_Done;
 
+  /*
+   * Handle case when selection is being disowned,
+   * WM_DRAWCLIPBOARD did not do the disowning,
+   * both monitored selections are no longer owned,
+   * an owned to not owned transition was detected,
+   * and we currently own the Win32 clipboard.
+   */
+  if (None == stuff->window
+      && g_iClipboardWindow != client->lastDrawableID
+      && None == g_iOwners[CLIP_OWN_PRIMARY]
+      && None == g_iOwners[CLIP_OWN_CLIPBOARD]
+      && fOwnedToNotOwned
+      && g_hwndClipboard != NULL
+      && g_hwndClipboard == GetClipboardOwner ())
+    {
+      ErrorF ("winProcSetSelectionOwner - We currently own the "
+	      "clipboard and neither the PRIMARY nor the CLIPBOARD "
+	      "selections are owned, releasing ownership of Win32 "
+	      "clipboard.\n");
+      
+      /* Release ownership of the Windows clipboard */
+      OpenClipboard (NULL);
+      EmptyClipboard ();
+      CloseClipboard ();
+      
       goto winProcSetSelectionOwner_Done;
     }
 
@@ -394,48 +397,9 @@
 
   /* Cast Window to Drawable */
   pDrawable = (DrawablePtr) pWindow;
-
-
-  /*
-   * Get the screen pointer from the client pointer
-   */
-
-  /* Abort if we don't have a screen for the window */
-  if ((pScreen = pDrawable->pScreen) == NULL)
-    {
-      ErrorF ("winProcSetSelectionOwner - Window has no screen.\n");
-      goto winProcSetSelectionOwner_Done;
-    }
-
-  /* Abort if no screen privates */
-  if ((pScreenPriv = winGetScreenPriv (pScreen)) == NULL)
-    {
-      ErrorF ("winProcSetSelectionOwner - Screen has no privates.\n");
-      goto winProcSetSelectionOwner_Done;
-    }
-
-  /* Abort if clipboard not completely initialized yet */
-  if (!pScreenPriv->fClipboardStarted)
-    {
-      ErrorF ("\nwinProcSetSelectionOwner - Clipboard not yet started.\n\n");
-      goto winProcSetSelectionOwner_Done;
-    }
-
-#if 0
-  ErrorF ("winProcSetSelectionOwner - "
-	  "iWindow: %d client->lastDrawableID: %d target: %d\n",
-	  pScreenPriv->iClipboardWindow, pDrawable->id, stuff->selection);
-#endif
-
-  /* Abort if no clipboard manager window */
-  if (pScreenPriv->iClipboardWindow == 0)
-    {
-      ErrorF ("winProcSetSelectionOwner - No X clipboard window.\n");
-      goto winProcSetSelectionOwner_Done;
-    }
-
+  
   /* Abort if clipboard manager is owning the selection */
-  if (pDrawable->id == pScreenPriv->iClipboardWindow)
+  if (pDrawable->id == g_iClipboardWindow)
     {
       ErrorF ("winProcSetSelectionOwner - We changed ownership, "
 	      "aborting.\n");
@@ -450,20 +414,11 @@
       goto winProcSetSelectionOwner_Done;
     }
 
-  /* Abort if no clipboard window */
-  if ((hwndClipboard = pScreenPriv->hwndClipboard) == NULL
-      || !IsWindow (hwndClipboard))
-    {
-      ErrorF ("winProcSetSelectionOwner - No valid clipboard window "
-	      "handle.\n");
-      goto winProcSetSelectionOwner_Done;
-    }
-
   /* Access the Windows clipboard */
-  if (!OpenClipboard (hwndClipboard))
+  if (!OpenClipboard (g_hwndClipboard))
     {
       ErrorF ("winProcSetSelectionOwner - OpenClipboard () failed: %08x\n",
-	      (int) GetLastError ());
+	      GetLastError ());
       goto winProcSetSelectionOwner_Done;
     }
 
@@ -471,7 +426,7 @@
   if (!EmptyClipboard ())
     {
       ErrorF ("winProcSetSelectionOwner - EmptyClipboard () failed: %08x\n",
-	      (int) GetLastError ());
+	      GetLastError ());
       goto winProcSetSelectionOwner_Done;
     }
 
@@ -483,14 +438,14 @@
   SetClipboardData (CF_TEXT, NULL);
 
   /* Save handle to last owned selection */
-  pScreenPriv->atomLastOwnedSelection = stuff->selection;
+  g_atomLastOwnedSelection = stuff->selection;
 
   /* Release the clipboard */
   if (!CloseClipboard ())
     {
       ErrorF ("winProcSetSelectionOwner - CloseClipboard () failed: "
 	      "%08x\n",
-	      (int) GetLastError ());
+	      GetLastError ());
       goto winProcSetSelectionOwner_Done;
     }
 

Index: winglobals.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/Attic/winglobals.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- winglobals.c	8 Jan 2004 05:10:32 -0000	1.1.2.1
+++ winglobals.c	10 Jan 2004 07:50:57 -0000	1.1.2.2
@@ -54,8 +54,8 @@
 Bool		g_fCalledSetLocale = FALSE;
 const char *	g_pszQueryHost = NULL;
 Bool		g_fUnicodeClipboard = TRUE;
+Bool		g_fClipboard = FALSE;
 Bool		g_fXdmcpEnabled = FALSE;
-Bool		g_fClipboardLaunched = FALSE;
 
 
 /*
@@ -80,6 +80,23 @@
 
 
 /*
+ * Clipboard variables
+ */
+
+Bool			g_fClipboardLaunched = FALSE;
+Bool			g_fClipboardStarted = FALSE;
+pthread_t		g_ptClipboardProc;
+Bool			g_fClipboardStarted;
+HWND			g_hwndClipboard;
+void			*g_pClipboardDisplay;
+Window			g_iClipboardWindow;
+Atom			g_atomLastOwnedSelection;
+#if 0
+Window			g_iClipboardOwner[CLIP_NUM_SELECTIONS];
+#endif
+
+
+/*
  * Re-initialize global variables that are invalidated
  * by a server reset.
  */

Index: winprocarg.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/Attic/winprocarg.c,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -d -r1.1.2.2 -r1.1.2.3
--- winprocarg.c	8 Jan 2004 19:24:09 -0000	1.1.2.2
+++ winprocarg.c	10 Jan 2004 07:50:57 -0000	1.1.2.3
@@ -42,6 +42,7 @@
 extern Bool			g_fInitializedDefaultScreens;
 extern Bool			g_fUnicodeClipboard;
 extern Bool			g_fXdmcpEnabled;
+extern Bool			g_fClipboard;
 extern int			g_iLogVerbose;
 extern char *			g_pszLogFile;
 
@@ -107,7 +108,6 @@
       g_ScreenInfo[i].fPseudoRootless = FALSE;
       g_ScreenInfo[i].fMultiWindow = FALSE;
       g_ScreenInfo[i].fMultipleMonitors = FALSE;
-      g_ScreenInfo[i].fClipboard = FALSE;
       g_ScreenInfo[i].fLessPointer = FALSE;
       g_ScreenInfo[i].fScrollbars = FALSE;
       g_ScreenInfo[i].fNoTrayIcon = FALSE;
@@ -564,22 +564,7 @@
    */
   if (IS_OPTION ("-clipboard"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].fClipboard = TRUE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  g_ScreenInfo[g_iLastScreen].fClipboard = TRUE;
-	}
+      g_fClipboard = TRUE;
 
       /* Indicate that we have processed this argument */
       return 1;

Index: winwndproc.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winwndproc.c,v
retrieving revision 1.1.4.1.2.5
retrieving revision 1.1.4.1.2.6
diff -u -d -r1.1.4.1.2.5 -r1.1.4.1.2.6
--- winwndproc.c	8 Jan 2004 05:10:33 -0000	1.1.4.1.2.5
+++ winwndproc.c	10 Jan 2004 07:50:57 -0000	1.1.4.1.2.6
@@ -47,6 +47,13 @@
 
 
 /*
+ * References to external symbols
+ */
+
+extern Bool		g_fClipboard;
+
+
+/*
  * Called by winWakeupHandler
  * Processes current Windows message
  */
@@ -271,8 +278,20 @@
 	}
 
       /* Store the new display dimensions and depth */
-      s_pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXSCREEN);
-      s_pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYSCREEN);
+      if (s_pScreenInfo->fMultipleMonitors)
+	{
+	  s_pScreenPriv->dwLastWindowsWidth
+	    = GetSystemMetrics (SM_CXVIRTUALSCREEN);
+	  s_pScreenPriv->dwLastWindowsHeight
+	    = GetSystemMetrics (SM_CYVIRTUALSCREEN);
+	}
+      else
+	{
+	  s_pScreenPriv->dwLastWindowsWidth
+	    = GetSystemMetrics (SM_CXSCREEN);
+	  s_pScreenPriv->dwLastWindowsHeight
+	    = GetSystemMetrics (SM_CYSCREEN);
+	}
       s_pScreenPriv->dwLastWindowsBitsPixel
 	= GetDeviceCaps (s_pScreenPriv->hdcScreen, BITSPIXEL);
       break;
@@ -1057,7 +1076,7 @@
     case WM_ENDSESSION:
     case WM_GIVEUP:
       /* Tell X that we are giving up */
-      if (s_pScreenInfo->fClipboard)
+      if (g_fClipboard)
 	winDeinitClipboard ();
       if (s_pScreenInfo->fMultiWindow)
 	winDeinitMultiWindowWM ();





More information about the xorg-commit mailing list