aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin/winclipboardxevents.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xwin/winclipboardxevents.c')
-rw-r--r--xorg-server/hw/xwin/winclipboardxevents.c65
1 files changed, 47 insertions, 18 deletions
diff --git a/xorg-server/hw/xwin/winclipboardxevents.c b/xorg-server/hw/xwin/winclipboardxevents.c
index d4c617bec..ec40814db 100644
--- a/xorg-server/hw/xwin/winclipboardxevents.c
+++ b/xorg-server/hw/xwin/winclipboardxevents.c
@@ -1,5 +1,6 @@
/*
*Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *Copyright (C) Colin Harrison 2005-2008
*
*Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -20,18 +21,20 @@
*CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
*WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
- *Except as contained in this notice, the name of Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
+ *Except as contained in this notice, the name of the copyright holder(s)
+ *and author(s) shall not be used in advertising or otherwise to promote
+ *the sale, use or other dealings in this Software without prior written
+ *authorization from the copyright holder(s) and author(s).
*
* Authors: Harold L Hunt II
+ * Colin Harrison
*/
#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
#include "winclipboard.h"
+#include "misc.h"
/*
@@ -51,18 +54,20 @@ winClipboardFlushXEvents (HWND hwnd,
Display *pDisplay,
Bool fUseUnicode)
{
- Atom atomLocalProperty = XInternAtom (pDisplay,
- WIN_LOCAL_PROPERTY,
- False);
- Atom atomUTF8String = XInternAtom (pDisplay,
- "UTF8_STRING",
- False);
- Atom atomCompoundText = XInternAtom (pDisplay,
- "COMPOUND_TEXT",
- False);
- Atom atomTargets = XInternAtom (pDisplay,
- "TARGETS",
- False);
+ static Atom atomLocalProperty;
+ static Atom atomCompoundText;
+ static Atom atomUTF8String;
+ static Atom atomTargets;
+ static int generation;
+
+ if (generation != serverGeneration)
+ {
+ generation = serverGeneration;
+ atomLocalProperty = XInternAtom (pDisplay, WIN_LOCAL_PROPERTY, False);
+ atomUTF8String = XInternAtom (pDisplay, "UTF8_STRING", False);
+ atomCompoundText = XInternAtom (pDisplay, "COMPOUND_TEXT", False);
+ atomTargets = XInternAtom (pDisplay, "TARGETS", False);
+ }
/* Process all pending events */
while (XPending (pDisplay))
@@ -186,8 +191,13 @@ winClipboardFlushXEvents (HWND hwnd,
if (fUseUnicode
&& !IsClipboardFormatAvailable (CF_UNICODETEXT))
{
- ErrorF ("winClipboardFlushXEvents - CF_UNICODETEXT is not "
- "available from Win32 clipboard. Aborting.\n");
+ static int count; /* Hack to stop acroread spamming the log */
+ static HWND lasthwnd; /* I've not seen any other client get here repeatedly? */
+ if (hwnd != lasthwnd) count = 0;
+ count++;
+ if (count < 6) ErrorF ("winClipboardFlushXEvents - CF_UNICODETEXT is not "
+ "available from Win32 clipboard. Aborting %d.\n", count);
+ lasthwnd = hwnd;
/* Abort */
fAbort = TRUE;
@@ -301,6 +311,7 @@ winClipboardFlushXEvents (HWND hwnd,
/* Initialize the text property */
xtpText.value = NULL;
+ xtpText.nitems = 0;
/* Create the text property from the text list */
if (fUseUnicode)
@@ -361,10 +372,13 @@ winClipboardFlushXEvents (HWND hwnd,
/* Release the clipboard data */
GlobalUnlock (hGlobal);
pszGlobalData = NULL;
+ fCloseClipboard = FALSE;
+ CloseClipboard ();
/* Clean up */
XFree (xtpText.value);
xtpText.value = NULL;
+ xtpText.nitems = 0;
/* Setup selection notify event */
eventSelection.type = SelectionNotify;
@@ -395,7 +409,11 @@ winClipboardFlushXEvents (HWND hwnd,
winClipboardFlushXEvents_SelectionRequest_Done:
/* Free allocated resources */
if (xtpText.value)
+ {
XFree (xtpText.value);
+ xtpText.value = NULL;
+ xtpText.nitems = 0;
+ }
if (pszConvertData)
free (pszConvertData);
if (hGlobal && pszGlobalData)
@@ -436,7 +454,10 @@ winClipboardFlushXEvents (HWND hwnd,
/* Close clipboard if it was opened */
if (fCloseClipboard)
+ {
+ fCloseClipboard = FALSE;
CloseClipboard ();
+ }
break;
@@ -618,6 +639,7 @@ winClipboardFlushXEvents (HWND hwnd,
/* Conversion succeeded or some unconvertible characters */
if (ppszTextList != NULL)
{
+ iReturnDataLen = 0;
for (i = 0; i < iCount; i++)
{
iReturnDataLen += strlen(ppszTextList[i]);
@@ -663,6 +685,7 @@ winClipboardFlushXEvents (HWND hwnd,
ppszTextList = NULL;
XFree (xtpText.value);
xtpText.value = NULL;
+ xtpText.nitems = 0;
/* Convert the X clipboard string to DOS format */
winClipboardUNIXtoDOS (&pszReturnData, strlen (pszReturnData));
@@ -711,6 +734,8 @@ winClipboardFlushXEvents (HWND hwnd,
hGlobal = GlobalAlloc (GMEM_MOVEABLE, iConvertDataLen);
}
+ free (pszReturnData);
+
/* Check that global memory was allocated */
if (!hGlobal)
{
@@ -774,7 +799,11 @@ winClipboardFlushXEvents (HWND hwnd,
if (ppszTextList)
XFreeStringList (ppszTextList);
if (xtpText.value)
+ {
XFree (xtpText.value);
+ xtpText.value = NULL;
+ xtpText.nitems = 0;
+ }
if (pszConvertData)
free (pszConvertData);
if (pwszUnicodeStr)