Missed changes from 4.3.0-60 to 4.3.0-61

This commit is contained in:
Harold L Hunt II 2004-03-30 14:56:46 +00:00
parent 2d1d9f32e0
commit 4c9a5fab69
3 changed files with 99 additions and 27 deletions

View file

@ -74,6 +74,7 @@
#define WIN_XEVENTS_SUCCESS 0
#define WIN_XEVENTS_SHUTDOWN 1
#define WIN_XEVENTS_CONVERT 2
#define WIN_XEVENTS_NOTIFY 3
/*

View file

@ -36,6 +36,7 @@
*/
#define WIN_CLIPBOARD_PROP "cyg_clipboard_prop"
#define WIN_POLL_TIMEOUT 2
/*
@ -53,20 +54,78 @@ extern Atom g_atomLastOwnedSelection;
*/
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 @@ winClipboardWindowProc (HWND hwnd, UINT message,
case WM_RENDERFORMAT:
case WM_RENDERALLFORMATS:
{
XEvent event;
int iReturn;
Display *pDisplay = g_pClipboardDisplay;
Window iWindow = g_iClipboardWindow;
@ -315,9 +373,6 @@ winClipboardWindowProc (HWND hwnd, UINT message,
break;
}
/* Wait for the SelectionNotify event */
XPeekIfEvent (pDisplay, &event, winLookForSelectionNotify, NULL);
/* Special handling for WM_RENDERALLFORMATS */
if (message == WM_RENDERALLFORMATS)
{
@ -345,12 +400,13 @@ winClipboardWindowProc (HWND hwnd, UINT message,
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 @@ winClipboardWindowProc (HWND hwnd, UINT message,
* 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 */

View file

@ -461,7 +461,7 @@ winClipboardFlushXEvents (HWND hwnd,
ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
"XA_STRING\n");
#endif
break;
return WIN_XEVENTS_CONVERT;
}
else if (event.xselection.target == atomUTF8String)
{
@ -478,7 +478,8 @@ winClipboardFlushXEvents (HWND hwnd,
if (iReturn != Success)
{
ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
"XConvertSelection () failed, aborting: %d\n",
"XConvertSelection () failed for UTF8String, "
"aborting: %d\n",
iReturn);
break;
}
@ -503,7 +504,8 @@ winClipboardFlushXEvents (HWND hwnd,
if (iReturn != Success)
{
ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
"XConvertSelection () failed, aborting: %d\n",
"XConvertSelection () failed for CompoundText, "
"aborting: %d\n",
iReturn);
break;
}
@ -772,7 +774,7 @@ winClipboardFlushXEvents (HWND hwnd,
SetClipboardData (CF_UNICODETEXT, NULL);
if (fSetClipboardData && !fUnicodeSupport)
SetClipboardData (CF_TEXT, NULL);
break;
return WIN_XEVENTS_NOTIFY;
default:
break;