[Xorg-commit] xc/programs/Xserver/hw/xwin InitOutput.c,1.1.4.1.2.9,1.1.4.1.2.10 winclipboardthread.c,1.1.4.1.2.6,1.1.4.1.2.7 winclipboardwrappers.c,1.1.2.6,1.1.2.7 winglobals.c,1.1.2.2,1.1.2.3 winmultiwindowwindow.c,1.1.4.1.2.3,1.1.4.1.2.4 winmultiwindowwm.c,1.1.4.1.2.2,1.1.4.1.2.3

Harold L Hunt II xorg-commit at pdx.freedesktop.org
Tue Jan 13 03:08:40 EET 2004


Committed by: harold

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

Modified Files:
      Tag: CYGWIN
	InitOutput.c winclipboardthread.c winclipboardwrappers.c 
	winglobals.c winmultiwindowwindow.c winmultiwindowwm.c 
Log Message:
XWin Server - Sync with 4.3.0-40 release.  Simplify setlocale() handling, fix crashes in clipboard code, fix crash on startup when using -clipboard and -multiwindow.

Index: InitOutput.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/InitOutput.c,v
retrieving revision 1.1.4.1.2.9
retrieving revision 1.1.4.1.2.10
diff -u -d -r1.1.4.1.2.9 -r1.1.4.1.2.10
--- InitOutput.c	11 Jan 2004 07:39:03 -0000	1.1.4.1.2.9
+++ InitOutput.c	13 Jan 2004 01:08:37 -0000	1.1.4.1.2.10
@@ -32,6 +32,7 @@
 #include "winmsg.h"
 #include "winconfig.h"
 #include "winprefs.h"
+#include "Xlocale.h"
 
 
 /*
@@ -117,8 +118,6 @@
 void
 OsVendorReset ()
 {
-  int			i;
-
   ErrorF ("OsVendorReset - Hello\n");
 
   /* Close down clipboard resources */
@@ -454,6 +453,16 @@
   if (g_fXdmcpEnabled)
     winGenerateAuthorization ();
 
+  /* Perform some one time initialization */
+  if (1 == serverGeneration)
+    {
+      /*
+       * setlocale applies to all threads in the current process.
+       * Apply locale specified in LANG environment variable.
+       */
+      setlocale (LC_ALL, "");
+    }
+
 #if CYGDEBUG || YES
   winErrorFVerb (2, "InitOutput - Returning.\n");
 #endif

Index: winclipboardthread.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winclipboardthread.c,v
retrieving revision 1.1.4.1.2.6
retrieving revision 1.1.4.1.2.7
diff -u -d -r1.1.4.1.2.6 -r1.1.4.1.2.7
--- winclipboardthread.c	12 Jan 2004 01:10:50 -0000	1.1.4.1.2.6
+++ winclipboardthread.c	13 Jan 2004 01:08:37 -0000	1.1.4.1.2.7
@@ -44,7 +44,6 @@
  * References to external symbols
  */
 
-extern Bool		g_fCalledSetLocale;
 extern Bool		g_fUnicodeClipboard;
 extern unsigned long	serverGeneration;
 extern unsigned int	g_uiAuthDataLen;
@@ -102,28 +101,6 @@
   /* Save the Unicode support flag in a global */
   g_fUnicodeSupport = fUnicodeSupport;
 
-  /* Set the current locale?  What does this do? */
-  if (!g_fCalledSetLocale)
-    {
-      ErrorF ("winClipboardProc - Calling setlocale ()\n");
-      if (!setlocale (LC_ALL, ""))
-	{
-	  ErrorF ("winClipboardProc - setlocale () error\n");
-	  pthread_exit (NULL);
-	}
-      ErrorF ("winClipboardProc - setlocale () returned\n");
-
-      /* See if X supports the current locale */
-      if (XSupportsLocale () == False)
-	{
-	  ErrorF ("winClipboardProc - Locale not supported by X\n");
-	  pthread_exit (NULL);
-	}
-    }
-
-  /* Flag that we have called setlocale */
-  g_fCalledSetLocale = TRUE;
-
   /* Allow multiple threads to access Xlib */
   if (XInitThreads () == 0)
     {
@@ -131,7 +108,12 @@
       pthread_exit (NULL);
     }
 
-  ErrorF ("winClipboardProc - XInitThreads () returned.\n");
+  /* See if X supports the current locale */
+  if (XSupportsLocale () == False)
+    {
+      ErrorF ("winClipboardProc - Locale not supported by X.  Exiting.\n");
+      pthread_exit (NULL);
+    }
 
   /* Set jump point for Error exits */
   iReturn = setjmp (g_jmpEntry);

Index: winclipboardwrappers.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/Attic/winclipboardwrappers.c,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -d -r1.1.2.6 -r1.1.2.7
--- winclipboardwrappers.c	13 Jan 2004 01:05:52 -0000	1.1.2.6
+++ winclipboardwrappers.c	13 Jan 2004 01:08:37 -0000	1.1.2.7
@@ -279,10 +279,12 @@
 int
 winProcSetSelectionOwner (ClientPtr client)
 {
+  int			i;
   DrawablePtr		pDrawable;
   WindowPtr		pWindow = None;
   Bool			fOwnedToNotOwned = FALSE;
-  static Window		g_iOwners[CLIP_NUM_SELECTIONS] = {None};
+  static Window		s_iOwners[CLIP_NUM_SELECTIONS] = {None};
+  static unsigned long	s_ulServerGeneration = 0;
   REQUEST(xSetSelectionOwnerReq);
   
   REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
@@ -291,6 +293,17 @@
   ErrorF ("winProcSetSelectionOwner - Hello.\n");
 #endif
 
+  /* Watch for server reset */
+  if (s_ulServerGeneration != serverGeneration)
+    {
+      /* Save new generation number */
+      s_ulServerGeneration = serverGeneration;
+
+      /* Initialize static variables */
+      for (i = 0; i < CLIP_NUM_SELECTIONS; ++i)
+	s_iOwners[i] = None;
+    }
+
   /* Abort if clipboard not completely initialized yet */
   if (!g_fClipboardStarted)
     {
@@ -319,37 +332,37 @@
     {
       /* Look for owned -> not owned transition */
       if (None == stuff->window
-	  && None != g_iOwners[CLIP_OWN_PRIMARY])
+	  && None != s_iOwners[CLIP_OWN_PRIMARY])
 	{
 	  fOwnedToNotOwned = TRUE;
 	  
 	  /* Adjust last owned selection */
-	  if (None != g_iOwners[CLIP_OWN_CLIPBOARD])
+	  if (None != s_iOwners[CLIP_OWN_CLIPBOARD])
 	    g_atomLastOwnedSelection = MakeAtom ("CLIPBOARD", 9, FALSE);
 	  else
 	    g_atomLastOwnedSelection = None;
 	}
       
       /* Save new selection owner or None */
-      g_iOwners[CLIP_OWN_PRIMARY] = stuff->window;
+      s_iOwners[CLIP_OWN_PRIMARY] = stuff->window;
     }
   else if (MakeAtom ("CLIPBOARD", 9, FALSE) == stuff->selection)
     {
       /* Look for owned -> not owned transition */
       if (None == stuff->window
-	  && None != g_iOwners[CLIP_OWN_CLIPBOARD])
+	  && None != s_iOwners[CLIP_OWN_CLIPBOARD])
 	{
 	  fOwnedToNotOwned = TRUE;
 	  
 	   /* Adjust last owned selection */
-	  if (None != g_iOwners[CLIP_OWN_PRIMARY])
+	  if (None != s_iOwners[CLIP_OWN_PRIMARY])
 	    g_atomLastOwnedSelection = XA_PRIMARY;
 	  else
 	    g_atomLastOwnedSelection = None;
 	}
       
       /* Save new selection owner or None */
-      g_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window;
+      s_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window;
     }
   else
     goto winProcSetSelectionOwner_Done;
@@ -363,8 +376,8 @@
    */
   if (None == stuff->window
       && g_iClipboardWindow != client->lastDrawableID
-      && None == g_iOwners[CLIP_OWN_PRIMARY]
-      && None == g_iOwners[CLIP_OWN_CLIPBOARD]
+      && None == s_iOwners[CLIP_OWN_PRIMARY]
+      && None == s_iOwners[CLIP_OWN_CLIPBOARD]
       && fOwnedToNotOwned
       && g_hwndClipboard != NULL
       && g_hwndClipboard == GetClipboardOwner ())

Index: winglobals.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/Attic/winglobals.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
--- winglobals.c	10 Jan 2004 07:50:57 -0000	1.1.2.2
+++ winglobals.c	13 Jan 2004 01:08:37 -0000	1.1.2.3
@@ -51,7 +51,6 @@
 HINSTANCE	g_hInstance = 0;
 HWND		g_hDlgDepthChange = NULL;
 HWND		g_hDlgExit = NULL;
-Bool		g_fCalledSetLocale = FALSE;
 const char *	g_pszQueryHost = NULL;
 Bool		g_fUnicodeClipboard = TRUE;
 Bool		g_fClipboard = FALSE;
@@ -91,9 +90,6 @@
 void			*g_pClipboardDisplay;
 Window			g_iClipboardWindow;
 Atom			g_atomLastOwnedSelection;
-#if 0
-Window			g_iClipboardOwner[CLIP_NUM_SELECTIONS];
-#endif
 
 
 /*
@@ -104,6 +100,5 @@
 void
 winInitializeGlobals ()
 {
-  g_fCalledSetLocale = FALSE;
   g_fClipboardLaunched = FALSE;
 }

Index: winmultiwindowwindow.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winmultiwindowwindow.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
--- winmultiwindowwindow.c	29 Dec 2003 05:56:44 -0000	1.1.4.1.2.3
+++ winmultiwindowwindow.c	13 Jan 2004 01:08:37 -0000	1.1.4.1.2.4
@@ -60,11 +60,6 @@
 static void
 winFindWindow (pointer value, XID id, pointer cdata);
 
-#if 0
-static void
-winRestackXWindow (WindowPtr pWin, int smode);
-#endif
-
 
 /*
  * Constant defines
@@ -756,37 +751,6 @@
 }
 
 
-#if 0
-/*
- * winRestackXWindow - 
- */
-
-static void
-winRestackXWindow (WindowPtr pWin, int smode)
-{
-  XID *vlist = malloc(sizeof(unsigned long));
-
-  if (vlist == NULL)
-    {
-      ErrorF ("winRestackXWindow - malloc () failed\n");
-      return;
-    }
-
-  if (pWin == NULL)
-    {
-      ErrorF ("winRestackXWindow - NULL window\n");
-      free(vlist);
-      return;
-    }
-
-  *((unsigned long*)vlist) = smode;
-  ConfigureWindow (pWin, CWStackMode, vlist, wClient(pWin));
-
-  free(vlist);
-}
-#endif
-
-
 /*
  * winReorderWindowsMultiWindow - 
  */

Index: winmultiwindowwm.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winmultiwindowwm.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
--- winmultiwindowwm.c	8 Jan 2004 05:10:33 -0000	1.1.4.1.2.2
+++ winmultiwindowwm.c	13 Jan 2004 01:08:37 -0000	1.1.4.1.2.3
@@ -84,6 +84,7 @@
   struct _WMMsgNodeRec	*pTail;
   pthread_mutex_t	pmMutex;
   pthread_cond_t	pcNotEmpty;
+  int			nQueueSize;
 } WMMsgQueueRec, *WMMsgQueuePtr;
 
 typedef struct _WMInfo {
@@ -101,9 +102,9 @@
 } WMProcArgRec, *WMProcArgPtr;
 
 typedef struct _XMsgProcArgRec {
-  Display      *pDisplay;
-  DWORD        dwScreen;
-  WMInfoPtr    pWMInfo;
+  Display		*pDisplay;
+  DWORD			dwScreen;
+  WMInfoPtr		pWMInfo;
   pthread_mutex_t	*ppmServerStarted;
 } XMsgProcArgRec, *XMsgProcArgPtr;
 
@@ -114,7 +115,6 @@
 
 extern char *display;
 extern void ErrorF (const char* /*f*/, ...);
-extern Bool g_fCalledSetLocale;
 
 
 /*
@@ -165,13 +165,11 @@
  * Local globals
  */
 
-static int			g_nQueueSize;
 static jmp_buf			g_jmpWMEntry;
 static jmp_buf			g_jmpXMsgProcEntry;
 static Bool                     g_shutdown = FALSE;
 
 
-
 /*
  * PushMessage - Push a message onto the queue
  */
@@ -225,7 +223,7 @@
 #endif
 
   /* Increase the count of elements in the queue by one */
-  ++g_nQueueSize;
+  ++(pQueue->nQueueSize);
 
   /* Release the queue mutex */
   pthread_mutex_unlock (&pQueue->pmMutex);
@@ -285,10 +283,10 @@
     }
 
   /* Drop the number of elements in the queue by one */
-  --g_nQueueSize;
+  --(pQueue->nQueueSize);
 
 #if CYGMULTIWINDOW_DEBUG
-  ErrorF ("Queue Size %d %d\n", g_nQueueSize, QueueSize(pQueue));
+  ErrorF ("Queue Size %d %d\n", pQueue->nQueueSize, QueueSize(pQueue));
 #endif
   
   /* Release the queue mutex */
@@ -339,10 +337,11 @@
   pQueue->pTail = NULL;
 
   /* There are no elements initially */
-  g_nQueueSize = 0;
+  pQueue->nQueueSize = 0;
 
 #if CYGMULTIWINDOW_DEBUG
-  ErrorF ("InitQueue - Queue Size %d %d\n", g_nQueueSize, QueueSize(pQueue));
+  ErrorF ("InitQueue - Queue Size %d %d\n", pQueue->nQueueSize,
+	  QueueSize(pQueue));
 #endif
 
   ErrorF ("InitQueue - Calling pthread_mutex_init\n");
@@ -421,7 +420,6 @@
 #endif
     }
 
-
 #if CYGMULTIWINDOW_DEBUG
   ErrorF ("GetWindowName - Returning\n");
 #endif
@@ -538,7 +536,7 @@
 	{
 	  /* Bail if PopMessage returns without a message */
 	  /* NOTE: Remember that PopMessage is a blocking function. */
-	  ErrorF ("winMultiWindowWMProc - Queue is Empty?\n");
+	  ErrorF ("winMultiWindowWMProc - Queue is Empty?  Exiting.\n");
 	  pthread_exit (NULL);
 	}
 
@@ -737,7 +735,15 @@
       ErrorF ("winMultiWindowXMsgProc - XInitThreads () failed.\n");
       pthread_exit (NULL);
     }
-  
+
+  /* See if X supports the current locale */
+  if (XSupportsLocale () == False)
+    {
+      ErrorF ("winMultiWindowXMsgProc - Locale not supported by X.  "
+	      "Exiting.\n");
+      pthread_exit (NULL);
+    }
+
   /* Release the server started mutex */
   pthread_mutex_unlock (pProcArg->ppmServerStarted);
 
@@ -797,7 +803,7 @@
   /* Make sure that the display opened */
   if (pProcArg->pDisplay == NULL)
     {
-      ErrorF ("winMultiWindowXMsgProcwinInitMultiWindowWM - "
+      ErrorF ("winMultiWindowXMsgProc - "
 	      "Failed opening the display, giving up.\n\f");
       pthread_exit (NULL);
     }
@@ -905,10 +911,15 @@
   /* Bail if the input parameters are bad */
   if (pArg == NULL || pWMInfo == NULL)
     {
-      ErrorF ("winInitWM - malloc fail.\n");
+      ErrorF ("winInitWM - malloc failed.\n");
       return FALSE;
     }
   
+  /* Zero the allocated memory */
+  ZeroMemory (pArg, sizeof (WMProcArgRec));
+  ZeroMemory (pWMInfo, sizeof (WMInfoRec));
+  ZeroMemory (pXMsgArg, sizeof (XMsgProcArgRec));
+
   /* Set a return pointer to the Window Manager info structure */
   *ppWMInfo = pWMInfo;
 
@@ -984,28 +995,6 @@
 
   ErrorF ("winInitMultiWindowWM - pthread_mutex_lock () returned.\n");
 
-  /* Set the current locale?  What does this do? */
-  if (!g_fCalledSetLocale)
-    {
-      ErrorF ("winInitMultiWindowWM - Calling setlocale ()\n");
-      if (!setlocale (LC_ALL, ""))
-	{
-	  ErrorF ("winInitMultiWindowWM - setlocale () error\n");
-	  pthread_exit (NULL);
-	}
-      ErrorF ("winInitMultiWindowWM - setlocale () returned\n");
-      
-      /* See if X supports the current locale */
-      if (XSupportsLocale () == False)
-	{
-	  ErrorF ("winInitMultiWindowWM - Locale not supported by X\n");
-	  pthread_exit (NULL);
-	}
-    }
-
-  /* Flag that we have called setlocale */
-  g_fCalledSetLocale = TRUE;
-  
   /* Allow multiple threads to access Xlib */
   if (XInitThreads () == 0)
     {
@@ -1013,6 +1002,13 @@
       pthread_exit (NULL);
     }
 
+  /* See if X supports the current locale */
+  if (XSupportsLocale () == False)
+    {
+      ErrorF ("winInitMultiWindowWM - Locale not supported by X.  Exiting.\n");
+      pthread_exit (NULL);
+    }
+
   /* Release the server started mutex */
   pthread_mutex_unlock (pProcArg->ppmServerStarted);
 





More information about the xorg-commit mailing list