diff options
Diffstat (limited to 'xorg-server/hw/xwin/winclipboardxevents.c')
-rw-r--r-- | xorg-server/hw/xwin/winclipboardxevents.c | 108 |
1 files changed, 73 insertions, 35 deletions
diff --git a/xorg-server/hw/xwin/winclipboardxevents.c b/xorg-server/hw/xwin/winclipboardxevents.c index b0006a01f..53b4d7d77 100644 --- a/xorg-server/hw/xwin/winclipboardxevents.c +++ b/xorg-server/hw/xwin/winclipboardxevents.c @@ -35,13 +35,15 @@ #endif #include "winclipboard.h" #include "misc.h" - +#include "winmsg.h" +#include <unistd.h> /* * References to external symbols */ extern Bool g_fUnicodeSupport; +extern Bool g_fClipboardPrimary; /* @@ -52,7 +54,8 @@ int winClipboardFlushXEvents (HWND hwnd, int iWindow, Display *pDisplay, - Bool fUseUnicode) + Bool fUseUnicode, + Bool ClipboardOpened) { static Atom atomLocalProperty; static Atom atomCompoundText; @@ -97,6 +100,8 @@ winClipboardFlushXEvents (HWND hwnd, /* Get the next event - will not block because one is ready */ XNextEvent (pDisplay, &event); + winDebug ("Received event type %d\n",event.type); + /* Branch on the event type */ switch (event.type) { @@ -105,6 +110,7 @@ winClipboardFlushXEvents (HWND hwnd, */ case SelectionRequest: +#ifdef _DEBUG { char *pszAtomName = NULL; winDebug("SelectionRequest - target %d\n", @@ -115,7 +121,10 @@ winClipboardFlushXEvents (HWND hwnd, winDebug("SelectionRequest - Target atom name %s\n", pszAtomName); XFree (pszAtomName); pszAtomName = NULL; + winDebug ("SelectionRequest - owner %d\n", event.xselectionrequest.owner); + winDebug ("SelectionRequest - requestor %d\n", event.xselectionrequest.requestor); } +#endif /* Abort if invalid target type */ if (event.xselectionrequest.target != XA_STRING @@ -211,27 +220,23 @@ winClipboardFlushXEvents (HWND hwnd, goto winClipboardFlushXEvents_SelectionRequest_Done; } - /* Close clipboard if we have it open already */ - if (GetOpenClipboardWindow () == hwnd) - { - CloseClipboard (); - } - /* Access the clipboard */ - if (!OpenClipboard (hwnd)) - { - ErrorF ("winClipboardFlushXEvents - SelectionRequest - " - "OpenClipboard () failed: %08lx\n", - GetLastError ()); - - /* Abort */ - fAbort = TRUE; - goto winClipboardFlushXEvents_SelectionRequest_Done; - } + if (!ClipboardOpened) + { + if (!OpenClipboard (hwnd)) + { + ErrorF ("winClipboardFlushXEvents - SelectionRequest - " + "OpenClipboard () failed: %08lx\n", + GetLastError ()); + + /* Abort */ + fAbort = TRUE; + goto winClipboardFlushXEvents_SelectionRequest_Done; + } - /* Indicate that clipboard was opened */ - fCloseClipboard = TRUE; - + /* Indicate that clipboard was opened */ + fCloseClipboard = TRUE; + } /* Setup the string style */ if (event.xselectionrequest.target == XA_STRING) xiccesStyle = XStringStyle; @@ -261,7 +266,16 @@ winClipboardFlushXEvents (HWND hwnd, } if (!hGlobal) { - ErrorF ("winClipboardFlushXEvents - SelectionRequest - " + if (GetLastError()==ERROR_CLIPBOARD_NOT_OPEN && ClipboardOpened) + { + ErrorF("We should not have received a SelectionRequest????\n" + "The owner is the clipboard, but in reality it was" + "an X window\n"); + /* Set the owner to None */ + if (g_fClipboardPrimary) XSetSelectionOwner (pDisplay, XA_PRIMARY, None, CurrentTime); + XSetSelectionOwner (pDisplay, XInternAtom (pDisplay, "CLIPBOARD", False), None, CurrentTime); + } + ErrorF ("winClipboardFlushXEvents - SelectionRequest - " "GetClipboardData () failed: %08lx\n", GetLastError ()); @@ -369,9 +383,11 @@ winClipboardFlushXEvents (HWND hwnd, /* Release the clipboard data */ GlobalUnlock (hGlobal); pszGlobalData = NULL; - fCloseClipboard = FALSE; - CloseClipboard (); - + if (fCloseClipboard) + { + fCloseClipboard = FALSE; + CloseClipboard (); + } /* Clean up */ XFree (xtpText.value); xtpText.value = NULL; @@ -460,9 +476,8 @@ winClipboardFlushXEvents (HWND hwnd, /* * SelectionNotify */ - case SelectionNotify: - +#ifdef _DEBUG winDebug ("winClipboardFlushXEvents - SelectionNotify\n"); { char *pszAtomName; @@ -471,8 +486,11 @@ winClipboardFlushXEvents (HWND hwnd, winDebug("winClipboardFlushXEvents - SelectionNotify - ATOM: %s\n", pszAtomName); + winDebug ("SelectionNotify - requestor %d\n", event.xselectionrequest.requestor); XFree (pszAtomName); } +#endif + /* * Request conversion of UTF8 and CompoundText targets. @@ -574,6 +592,7 @@ winClipboardFlushXEvents (HWND hwnd, break; } +#ifdef WINDBG { char *pszAtomName = NULL; @@ -584,6 +603,7 @@ winClipboardFlushXEvents (HWND hwnd, XFree (pszAtomName); pszAtomName = NULL; } +#endif if (fUseUnicode) { @@ -612,7 +632,7 @@ winClipboardFlushXEvents (HWND hwnd, { iReturnDataLen += strlen(ppszTextList[i]); } - pszReturnData = malloc (iReturnDataLen + 1); + pszReturnData = (char *) malloc (iReturnDataLen + 1); pszReturnData[0] = '\0'; for (i = 0; i < iCount; i++) { @@ -623,7 +643,7 @@ winClipboardFlushXEvents (HWND hwnd, { ErrorF ("winClipboardFlushXEvents - SelectionNotify - " "X*TextPropertyToTextList list_return is NULL.\n"); - pszReturnData = malloc (1); + pszReturnData = (char *) malloc (1); pszReturnData[0] = '\0'; } } @@ -646,7 +666,7 @@ winClipboardFlushXEvents (HWND hwnd, ErrorF ("%d\n", iReturn); break; } - pszReturnData = malloc (1); + pszReturnData = (char *) malloc (1); pszReturnData[0] = '\0'; } @@ -659,7 +679,7 @@ winClipboardFlushXEvents (HWND hwnd, xtpText.nitems = 0; /* Convert the X clipboard string to DOS format */ - winClipboardUNIXtoDOS (&pszReturnData, strlen (pszReturnData)); + winClipboardUNIXtoDOS ((unsigned char **)&pszReturnData, strlen (pszReturnData)); if (fUseUnicode) { @@ -785,14 +805,32 @@ winClipboardFlushXEvents (HWND hwnd, SetClipboardData (CF_TEXT, NULL); return WIN_XEVENTS_NOTIFY; - case SelectionClear: - winDebug("SelectionClear - doing nothing\n"); - break; + /* + * SelectionClear + */ + case SelectionClear: +#ifdef _DEBUG + winDebug ("SelectionClear - doing nothing\n"); + { + char *pszAtomName; + + pszAtomName = XGetAtomName (pDisplay, + event.xselection.selection); + + winDebug ("SelectionClear - ATOM: %s\n", + pszAtomName); + winDebug ("SelectionClear - owner %d\n", event.xselectionrequest.owner); + + XFree (pszAtomName); + } +#endif + break; case PropertyNotify: break; - + case MappingNotify: + XRefreshKeyboardMapping((XMappingEvent *)&event); break; default: |