[xorg-commit-diffs] xc/programs/Xserver/hw/xwin winclipboard.h, 1.1.4.1.2.11, 1.1.4.1.2.12 winclipboardwndproc.c, 1.1.4.1.2.14, 1.1.4.1.2.15 winclipboardxevents.c, 1.1.4.1.2.15, 1.1.4.1.2.16

Harold L Hunt II xorg-commit at pdx.freedesktop.org
Tue Mar 30 06:56:51 PST 2004


Committed by: harold

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

Modified Files:
      Tag: CYGWIN
	winclipboard.h winclipboardwndproc.c winclipboardxevents.c 
Log Message:
Missed changes from 4.3.0-60 to 4.3.0-61

Index: winclipboard.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winclipboard.h,v
retrieving revision 1.1.4.1.2.11
retrieving revision 1.1.4.1.2.12
diff -u -d -r1.1.4.1.2.11 -r1.1.4.1.2.12
--- a/winclipboard.h	26 Mar 2004 20:07:03 -0000	1.1.4.1.2.11
+++ b/winclipboard.h	30 Mar 2004 14:56:46 -0000	1.1.4.1.2.12
@@ -74,6 +74,7 @@
 #define WIN_XEVENTS_SUCCESS			0
 #define WIN_XEVENTS_SHUTDOWN			1
 #define WIN_XEVENTS_CONVERT			2
+#define WIN_XEVENTS_NOTIFY			3
 
 
 /*

Index: winclipboardwndproc.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winclipboardwndproc.c,v
retrieving revision 1.1.4.1.2.14
retrieving revision 1.1.4.1.2.15
diff -u -d -r1.1.4.1.2.14 -r1.1.4.1.2.15
--- a/winclipboardwndproc.c	27 Mar 2004 19:54:22 -0000	1.1.4.1.2.14
+++ b/winclipboardwndproc.c	30 Mar 2004 14:56:46 -0000	1.1.4.1.2.15
@@ -36,6 +36,7 @@
  */
 
 #define WIN_CLIPBOARD_PROP	"cyg_clipboard_prop"
+#define WIN_POLL_TIMEOUT	2
 
 
 /*
@@ -53,20 +54,78 @@
  */
 
 static Bool
-winLookForSelectionNotify (Display *pDisplay, XEvent *pEvent, XPointer pArg);
+winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
+			  Bool fUnicodeSupport, int iTimeoutSec);
 
 
 /*
- * Signal that we found a SelectionNotify event
+ * Process X events up to specified timeout
  */
 
-static Bool
-winLookForSelectionNotify (Display *pDisplay, XEvent *pEvent, XPointer pArg)
+static int
+winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
+			  Bool fUnicodeSupport, int iTimeoutSec)
 {
-  if (pEvent->type == SelectionNotify)
-    return TRUE;
-  
-  return FALSE;
+  int			iConnNumber;
+  struct timeval	tv;
+  int			iReturn;
+  DWORD			dwStopTime = (GetTickCount () / 1000) + iTimeoutSec;
+
+  /* We need to ensure that all pending events are processed */
+  XSync (pDisplay, FALSE);
+
+  /* Get our connection number */
+  iConnNumber = ConnectionNumber (pDisplay);
+
+  /* Loop for X events */
+  while (1)
+    {
+      fd_set		fdsRead;
+
+      /* Setup the file descriptor set */
+      FD_ZERO (&fdsRead);
+      FD_SET (iConnNumber, &fdsRead);
+
+      /* Adjust timeout */
+      tv.tv_sec = dwStopTime - (GetTickCount () / 1000);
+      tv.tv_usec = 0;
+
+      /* Break out if no time left */
+      if (tv.tv_sec < 0)
+	return WIN_XEVENTS_SUCCESS;
+
+      /* Wait for a Windows event or an X event */
+      iReturn = select (iConnNumber + 1,/* Highest fds number */
+			&fdsRead,	/* Read mask */
+			NULL,		/* No write mask */
+			NULL,		/* No exception mask */
+			&tv);		/* No timeout */
+      if (iReturn <= 0)
+	{
+	  ErrorF ("winProcessXEventsTimeout - Call to select () failed: %d.  "
+		  "Bailing.\n", iReturn);
+	  break;
+	}
+
+      /* Branch on which descriptor became active */
+      if (FD_ISSET (iConnNumber, &fdsRead))
+	{
+	  /* Process X events */
+	  /* Exit when we see that server is shutting down */
+	  iReturn = winClipboardFlushXEvents (hwnd,
+					      iWindow,
+					      pDisplay,
+					      fUnicodeSupport);
+	  if (WIN_XEVENTS_NOTIFY == iReturn
+	      || WIN_XEVENTS_CONVERT == iReturn)
+	    {
+	      /* Bail out if convert or notify processed */
+	      return iReturn;
+	    }
+	}
+    }
+
+  return WIN_XEVENTS_SUCCESS;
 }
 
 
@@ -283,7 +342,6 @@
     case WM_RENDERFORMAT:
     case WM_RENDERALLFORMATS:
       {
-	XEvent	event;
 	int	iReturn;
 	Display *pDisplay = g_pClipboardDisplay;
 	Window	iWindow = g_iClipboardWindow;
@@ -315,9 +373,6 @@
 	    break;
 	  }
 
-	/* Wait for the SelectionNotify event */
-	XPeekIfEvent (pDisplay, &event, winLookForSelectionNotify, NULL);
-
 	/* Special handling for WM_RENDERALLFORMATS */
 	if (message == WM_RENDERALLFORMATS)
 	  {
@@ -345,12 +400,13 @@
 		break;
 	      }
 	  }
-	
+
 	/* Process the SelectionNotify event */
-	iReturn = winClipboardFlushXEvents (hwnd,
+	iReturn = winProcessXEventsTimeout (hwnd,
 					    iWindow,
 					    pDisplay,
-					    fConvertToUnicode);
+					    fConvertToUnicode,
+					    WIN_POLL_TIMEOUT);
 	if (WIN_XEVENTS_CONVERT == iReturn)
 	  {
 	    /*
@@ -358,14 +414,27 @@
 	     * to process a second SelectionNotify event to get the actual
 	     * data in the selection.
 	     */
-	    
-	    /* Wait for the second SelectionNotify event */
-	    XPeekIfEvent (pDisplay, &event, winLookForSelectionNotify, NULL);
-	    
-	    winClipboardFlushXEvents (hwnd,
-				      iWindow,
-				      pDisplay,
-				      fConvertToUnicode);
+	    iReturn = winProcessXEventsTimeout (hwnd,
+						iWindow,
+						pDisplay,
+						fConvertToUnicode,
+						WIN_POLL_TIMEOUT);
+	  }
+	
+	/*
+	 * The last of the up-to two calls to winProcessXEventsTimeout
+	 * from above had better have seen a notify event, or else we
+	 * are dealing with a buggy or old X11 app.  In these cases we
+	 * have to paste some fake data to the Win32 clipboard to
+	 * satisfy the requirement that we write something to it.
+	 */
+	if (WIN_XEVENTS_NOTIFY != iReturn)
+	  {
+	    /* Paste no data, to satisfy required call to SetClipboardData */
+	    if (fConvertToUnicode)
+	      SetClipboardData (CF_UNICODETEXT, NULL);
+	    else
+	      SetClipboardData (CF_TEXT, NULL);
 	  }
 
 	/* Special handling for WM_RENDERALLFORMATS */

Index: winclipboardxevents.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winclipboardxevents.c,v
retrieving revision 1.1.4.1.2.15
retrieving revision 1.1.4.1.2.16
diff -u -d -r1.1.4.1.2.15 -r1.1.4.1.2.16
--- a/winclipboardxevents.c	26 Mar 2004 19:45:21 -0000	1.1.4.1.2.15
+++ b/winclipboardxevents.c	30 Mar 2004 14:56:46 -0000	1.1.4.1.2.16
@@ -461,7 +461,7 @@
 		  ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
 			  "XA_STRING\n");
 #endif
-		  break;
+		  return WIN_XEVENTS_CONVERT;
 		}
 	      else if (event.xselection.target == atomUTF8String)
 		{
@@ -478,7 +478,8 @@
 		  if (iReturn != Success)
 		    {
 		      ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
-			      "XConvertSelection () failed, aborting: %d\n",
+			      "XConvertSelection () failed for UTF8String, "
+			      "aborting: %d\n",
 			      iReturn);
 		      break;
 		    }
@@ -503,7 +504,8 @@
 		  if (iReturn != Success)
 		    {
 		      ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
-			      "XConvertSelection () failed, aborting: %d\n",
+			      "XConvertSelection () failed for CompoundText, "
+			      "aborting: %d\n",
 			      iReturn);
 		      break;
 		    }
@@ -772,7 +774,7 @@
 	    SetClipboardData (CF_UNICODETEXT, NULL);
 	  if (fSetClipboardData && !fUnicodeSupport)
 	    SetClipboardData (CF_TEXT, NULL);
-	  break;
+	  return WIN_XEVENTS_NOTIFY;
 
 	default:
 	  break;




More information about the xorg-commit-diffs mailing list