diff options
author | marha <marha@users.sourceforge.net> | 2009-09-13 20:22:38 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-09-13 20:22:38 +0000 |
commit | 48bfb28bba3c19eeeb667581b9d9686eba070e98 (patch) | |
tree | 9de3ab3b1ef67d672ceb77dc9576505fb82f92ad | |
parent | de33a8e7273592eefd303a94e87a8b38592099a1 (diff) | |
download | vcxsrv-48bfb28bba3c19eeeb667581b9d9686eba070e98.tar.gz vcxsrv-48bfb28bba3c19eeeb667581b9d9686eba070e98.tar.bz2 vcxsrv-48bfb28bba3c19eeeb667581b9d9686eba070e98.zip |
Some clipboard rewrite. Clipboard seems to work now accept
for some socket shutdowns at startup (still under investigation)
-rw-r--r-- | xorg-server/hw/xwin/winclipboard.h | 3 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winclipboardthread.c | 23 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winclipboardwndproc.c | 203 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winclipboardwrappers.c | 48 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winclipboardxevents.c | 95 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winmsg.c | 2 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winmsg.h | 5 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winmultiwindowwm.c | 1 | ||||
-rw-r--r-- | xorg-server/miext/damage/damage.c | 2 | ||||
-rw-r--r-- | xorg-server/os/connection.c | 4 |
10 files changed, 194 insertions, 192 deletions
diff --git a/xorg-server/hw/xwin/winclipboard.h b/xorg-server/hw/xwin/winclipboard.h index 52675d45b..730f57920 100644 --- a/xorg-server/hw/xwin/winclipboard.h +++ b/xorg-server/hw/xwin/winclipboard.h @@ -150,5 +150,6 @@ int winClipboardFlushXEvents (HWND hwnd, int iWindow, Display *pDisplay, - Bool fUnicodeSupport); + Bool fUnicodeSupport, + Bool ClipboardOpened); #endif diff --git a/xorg-server/hw/xwin/winclipboardthread.c b/xorg-server/hw/xwin/winclipboardthread.c index 7912506e5..f243bae3c 100644 --- a/xorg-server/hw/xwin/winclipboardthread.c +++ b/xorg-server/hw/xwin/winclipboardthread.c @@ -40,6 +40,7 @@ #endif #include "X11/Xauth.h" #include "misc.h" +#include "winmsg.h" #ifdef _MSC_VER #define snprintf _snprintf @@ -216,6 +217,8 @@ winClipboardProc (void *pvNotUsed) /* Get our connection number */ iConnectionNumber = ConnectionNumber (pDisplay); + winDebug("Clipboard is using socket %d\n",iConnectionNumber); + #ifdef HAS_DEVWINDOWS /* Open a file descriptor for the windows message queue */ fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, _O_RDONLY); @@ -234,6 +237,10 @@ winClipboardProc (void *pvNotUsed) /* Create atoms */ atomClipboard = XInternAtom (pDisplay, "CLIPBOARD", False); atomClipboardManager = XInternAtom (pDisplay, "CLIPBOARD_MANAGER", False); + XInternAtom (pDisplay, WIN_LOCAL_PROPERTY, False); + XInternAtom (pDisplay, "UTF8_STRING", False); + XInternAtom (pDisplay, "COMPOUND_TEXT", False); + XInternAtom (pDisplay, "TARGETS", False); /* Create a messaging window */ iWindow = XCreateSimpleWindow (pDisplay, @@ -269,6 +276,7 @@ winClipboardProc (void *pvNotUsed) if (NULL != GetClipboardOwner ()) { /* PRIMARY */ + winDebug("winClipboardProc - asserted ownership.\n"); iReturn = XSetSelectionOwner (pDisplay, XA_PRIMARY, iWindow, CurrentTime); if (iReturn == BadAtom || iReturn == BadWindow /*|| @@ -288,7 +296,6 @@ winClipboardProc (void *pvNotUsed) goto thread_errorexit; } } - /* Pre-flush X events */ /* * NOTE: Apparently you'll freeze if you don't do this, @@ -301,6 +308,7 @@ winClipboardProc (void *pvNotUsed) fUseUnicode); */ /* Pre-flush Windows messages */ + winDebug ("Start flushing \n"); if (!winClipboardFlushWindowsMessageQueue (hwnd)) { ErrorF ("winClipboardFlushWindowsMessageQueue - returned 0\n"); @@ -362,21 +370,24 @@ winClipboardProc (void *pvNotUsed) } /* Branch on which descriptor became active */ - if (FD_ISSET (iConnectionNumber, &fdsRead)) - { +// if (FD_ISSET (iConnectionNumber, &fdsRead)) +// { Also do it when no read since winClipboardFlushXEvents +// is sending the output. /* Process X events */ /* Exit when we see that server is shutting down */ iReturn = winClipboardFlushXEvents (hwnd, iWindow, pDisplay, - fUseUnicode); + fUseUnicode, + FALSE + ); if (WIN_XEVENTS_SHUTDOWN == iReturn) { ErrorF ("winClipboardProc - winClipboardFlushXEvents " "trapped shutdown event, exiting main loop.\n"); break; } - } +// } #ifdef HAS_DEVWINDOWS /* Check for Windows event ready */ @@ -436,7 +447,6 @@ winClipboardProc (void *pvNotUsed) g_iClipboardWindow = None; g_pClipboardDisplay = NULL; - g_hwndClipboard = NULL; g_fClipboardLaunched = FALSE; g_fClipboardStarted = FALSE; @@ -452,7 +462,6 @@ thread_errorexit: } g_iClipboardWindow = None; g_pClipboardDisplay = NULL; - g_hwndClipboard = NULL; g_fClipboardLaunched = FALSE; g_fClipboardStarted = FALSE; //pthread_exit (NULL); diff --git a/xorg-server/hw/xwin/winclipboardwndproc.c b/xorg-server/hw/xwin/winclipboardwndproc.c index 40c1e9a5c..5c6410aa6 100644 --- a/xorg-server/hw/xwin/winclipboardwndproc.c +++ b/xorg-server/hw/xwin/winclipboardwndproc.c @@ -37,6 +37,7 @@ #include <sys/time.h>
#include "winclipboard.h"
#include "misc.h"
+#include "winmsg.h"
/*
* Constants
@@ -45,7 +46,6 @@ #define WIN_CLIPBOARD_PROP "cyg_clipboard_prop"
#define WIN_POLL_TIMEOUT 1
-
/*
* References to external symbols
*/
@@ -55,7 +55,7 @@ extern Bool g_fUnicodeSupport; extern void *g_pClipboardDisplay;
extern Window g_iClipboardWindow;
extern Atom g_atomLastOwnedSelection;
-
+extern Bool g_fClipboardStarted;
/* BPS - g_hwndClipboard needed for X app->Windows paste fix */
extern HWND g_hwndClipboard;
@@ -81,8 +81,17 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay, int iReturn;
DWORD dwStopTime = (GetTickCount () / 1000) + iTimeoutSec;
- /* We need to ensure that all pending events are processed */
- XSync (pDisplay, FALSE);
+ /* Make sure the output messages are sent before waiting on a response. */
+ iReturn = winClipboardFlushXEvents (hwnd,
+ iWindow,
+ pDisplay,
+ fUseUnicode,
+ TRUE);
+ if (WIN_XEVENTS_NOTIFY == iReturn || WIN_XEVENTS_CONVERT == iReturn)
+ {
+ /* Bail out if convert or notify processed */
+ return iReturn;
+ }
/* Get our connection number */
iConnNumber = ConnectionNumber (pDisplay);
@@ -125,7 +134,8 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay, iReturn = winClipboardFlushXEvents (hwnd,
iWindow,
pDisplay,
- fUseUnicode);
+ fUseUnicode,
+ TRUE);
if (WIN_XEVENTS_NOTIFY == iReturn
|| WIN_XEVENTS_CONVERT == iReturn)
{
@@ -138,7 +148,6 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay, return WIN_XEVENTS_SUCCESS;
}
-
/*
* Process a given Windows message
*/
@@ -148,7 +157,6 @@ winClipboardWindowProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND s_hwndNextViewer;
- static Bool s_fCBCInitialized;
/* Branch on message type */
switch (message)
@@ -161,7 +169,7 @@ winClipboardWindowProc (HWND hwnd, UINT message, ChangeClipboardChain (hwnd, s_hwndNextViewer);
s_hwndNextViewer = NULL;
-
+ g_hwndClipboard = NULL;
PostQuitMessage (0);
}
return 0;
@@ -173,15 +181,8 @@ winClipboardWindowProc (HWND hwnd, UINT message, DWORD error_code = 0;
winDebug ("winClipboardWindowProc - WM_CREATE\n");
- first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
- if (first == hwnd) return 0; /* Make sure it's not us! */
/* Add ourselves to the clipboard viewer chain */
- next = SetClipboardViewer (hwnd);
- error_code = GetLastError();
- if (SUCCEEDED(error_code) && (next == first)) /* SetClipboardViewer must have succeeded, and the handle */
- s_hwndNextViewer = next; /* it returned must have been the first window in the chain */
- else
- s_fCBCInitialized = FALSE;
+ s_hwndNextViewer = SetClipboardViewer (hwnd);
}
return 0;
@@ -195,12 +196,6 @@ winClipboardWindowProc (HWND hwnd, UINT message, if ((HWND) wParam == s_hwndNextViewer)
{
s_hwndNextViewer = (HWND) lParam;
- if (s_hwndNextViewer == hwnd)
- {
- s_hwndNextViewer = NULL;
- winErrorFVerb (1, "winClipboardWindowProc - WM_CHANGECBCHAIN: "
- "attempted to set next window to ourselves.");
- }
}
else if (s_hwndNextViewer)
SendMessage (s_hwndNextViewer, message,
@@ -227,27 +222,21 @@ winClipboardWindowProc (HWND hwnd, UINT message, HWND first, next;
DWORD error_code = 0;
+ if (!g_hwndClipboard)
+ return 0;
winDebug ("winClipboardWindowProc - WM_WM_REINIT: Enter\n");
first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
- if (first == hwnd) return 0; /* Make sure it's not us! */
- winDebug (" WM_WM_REINIT: Replacing us(%x) with %x at head "
- "of chain\n", hwnd, s_hwndNextViewer);
- s_fCBCInitialized = FALSE;
- ChangeClipboardChain (hwnd, s_hwndNextViewer);
- s_hwndNextViewer = NULL;
- s_fCBCInitialized = FALSE;
- winDebug (" WM_WM_REINIT: Putting us back at head of chain.\n");
- first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
- if (first == hwnd) return 0; /* Make sure it's not us! */
- next = SetClipboardViewer (hwnd);
- error_code = GetLastError();
- if (SUCCEEDED(error_code) && (next == first)) /* SetClipboardViewer must have succeeded, and the handle */
- s_hwndNextViewer = next; /* it returned must have been the first window in the chain */
- else
- s_fCBCInitialized = FALSE;
+ if (first != hwnd)
+ {
+ winDebug (" WM_WM_REINIT: Replacing us(%x) with %x at head "
+ "of chain\n", hwnd, s_hwndNextViewer);
+ ChangeClipboardChain (hwnd, s_hwndNextViewer);
+ winDebug (" WM_WM_REINIT: Putting us back at head of chain.\n");
+ s_hwndNextViewer = SetClipboardViewer (hwnd);
+ }
+ winDebug ("winClipboardWindowProc - WM_WM_REINIT: Exit\n");
}
- winDebug ("winClipboardWindowProc - WM_WM_REINIT: Exit\n");
return 0;
@@ -260,7 +249,15 @@ winClipboardWindowProc (HWND hwnd, UINT message, Window iWindow = g_iClipboardWindow;
int iReturn;
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Enter\n");
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD 0x%x 0x%x 0x%x: Enter\n",hwnd,wParam,lParam);
+
+ if (!g_fClipboardStarted)
+ {
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit with no processing\n");
+ if (s_hwndNextViewer)
+ SendMessage (s_hwndNextViewer, message, wParam, lParam);
+ return 0;
+ }
if (generation != serverGeneration)
{
@@ -279,7 +276,6 @@ winClipboardWindowProc (HWND hwnd, UINT message, else
{
/* Attempt to break the nesting by getting out of the chain, twice?, and then fix and bail */
- s_fCBCInitialized = FALSE;
ChangeClipboardChain (hwnd, s_hwndNextViewer);
winFixClipboardChain();
winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
@@ -289,36 +285,6 @@ winClipboardWindowProc (HWND hwnd, UINT message, return 0;
}
- /* Bail on first message */
- if (!s_fCBCInitialized)
- {
- s_fCBCInitialized = TRUE;
- s_fProcessingDrawClipboard = FALSE;
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
- return 0;
- }
-
- /*
- * NOTE: We cannot bail out when NULL == GetClipboardOwner ()
- * because some applications deal with the clipboard in a manner
- * that causes the clipboard owner to be NULL when they are in
- * fact taking ownership. One example of this is the Win32
- * native compile of emacs.
- */
-
- /* Bail when we still own the clipboard */
- if (hwnd == GetClipboardOwner ())
- {
-
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "We own the clipboard, returning.\n");
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
- s_fProcessingDrawClipboard = FALSE;
- if (s_hwndNextViewer)
- SendMessage (s_hwndNextViewer, message, wParam, lParam);
- return 0;
- }
-
/*
* Do not take ownership of the X11 selections when something
* other than CF_TEXT or CF_UNICODETEXT has been copied
@@ -375,53 +341,56 @@ winClipboardWindowProc (HWND hwnd, UINT message, SendMessage (s_hwndNextViewer, message, wParam, lParam);
return 0;
}
-
- /* Reassert ownership of PRIMARY */
- iReturn = XSetSelectionOwner (pDisplay,
- XA_PRIMARY,
- iWindow,
- CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow ||
- XGetSelectionOwner (pDisplay, XA_PRIMARY) != iWindow)
- {
- winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Could not reassert ownership of PRIMARY\n");
- }
- else
- {
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Reasserted ownership of PRIMARY\n");
- }
+ /* Only reassert ownership when we did not change the clipboard ourselves */
+ if (hwnd!=(HWND)wParam)
+ {
+ /* Reassert ownership of PRIMARY */
+ iReturn = XSetSelectionOwner (pDisplay,
+ XA_PRIMARY,
+ iWindow,
+ CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow ||
+ XGetSelectionOwner (pDisplay, XA_PRIMARY) != iWindow)
+ {
+ winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Could not reassert ownership of PRIMARY\n");
+ }
+ else
+ {
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Reasserted ownership of PRIMARY\n");
+ }
- /* Reassert ownership of the CLIPBOARD */
- iReturn = XSetSelectionOwner (pDisplay,
- atomClipboard,
- iWindow,
- CurrentTime);
-
- if (iReturn == BadAtom || iReturn == BadWindow ||
- XGetSelectionOwner (pDisplay, atomClipboard) != iWindow)
- {
- winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Could not reassert ownership of CLIPBOARD\n");
- }
- else
- {
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Reasserted ownership of CLIPBOARD\n");
- }
+ /* Reassert ownership of the CLIPBOARD */
+ iReturn = XSetSelectionOwner (pDisplay,
+ atomClipboard,
+ iWindow,
+ CurrentTime);
+
+ if (iReturn == BadAtom || iReturn == BadWindow ||
+ XGetSelectionOwner (pDisplay, atomClipboard) != iWindow)
+ {
+ winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Could not reassert ownership of CLIPBOARD\n");
+ }
+ else
+ {
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Reasserted ownership of CLIPBOARD\n");
+ }
- /* Flush the pending SetSelectionOwner event now */
- XFlush (pDisplay);
-
- s_fProcessingDrawClipboard = FALSE;
- }
+ /* Flush the pending SetSelectionOwner event now */
+ XFlush (pDisplay);
+ }
+
+ s_fProcessingDrawClipboard = FALSE;
winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
/* Pass the message on the next window in the clipboard viewer chain */
if (s_hwndNextViewer)
SendMessage (s_hwndNextViewer, message, wParam, lParam);
return 0;
+ }
case WM_DESTROYCLIPBOARD:
/*
@@ -459,7 +428,7 @@ winClipboardWindowProc (HWND hwnd, UINT message, XInternAtom (pDisplay,
"COMPOUND_TEXT", False),
XInternAtom (pDisplay,
- "CYGX_CUT_BUFFER", False),
+ WIN_LOCAL_PROPERTY, False),
iWindow,
CurrentTime);
if (iReturn == BadAtom || iReturn == BadWindow)
@@ -473,13 +442,6 @@ winClipboardWindowProc (HWND hwnd, UINT message, if (message == WM_RENDERALLFORMATS)
{
/* We must open and empty the clipboard */
-
- /* Close clipboard if we have it open already */
- if (GetOpenClipboardWindow () == hwnd)
- {
- CloseClipboard ();
- }
-
if (!OpenClipboard (hwnd))
{
winErrorFVerb (1, "winClipboardWindowProc - WM_RENDER*FORMATS - "
@@ -493,6 +455,7 @@ winClipboardWindowProc (HWND hwnd, UINT message, winErrorFVerb (1, "winClipboardWindowProc - WM_RENDER*FORMATS - "
"EmptyClipboard () failed: %08x\n",
GetLastError ());
+ CloseClipboard ();
break;
}
}
@@ -503,13 +466,14 @@ winClipboardWindowProc (HWND hwnd, UINT message, pDisplay,
fConvertToUnicode,
WIN_POLL_TIMEOUT);
- if (WIN_XEVENTS_CONVERT == iReturn)
+ while (WIN_XEVENTS_CONVERT == iReturn)
{
/*
* The selection was offered for conversion first, so we have
* to process a second SelectionNotify event to get the actual
* data in the selection.
*/
+ winDebug("winClipboardWindowProc - Previous winProcessXEventsTimeout returned WIN_XEVENTS_CONVERT, calling it again\n");
iReturn = winProcessXEventsTimeout (hwnd,
iWindow,
pDisplay,
@@ -526,6 +490,7 @@ winClipboardWindowProc (HWND hwnd, UINT message, */
if (WIN_XEVENTS_NOTIFY != iReturn)
{
+ ErrorF("winClipboardWindowProc - winProcessXEventsTimeout should have returned WIN_XEVENTS_NOTIFY was %d\n",iReturn);
/* Paste no data, to satisfy required call to SetClipboardData */
if (g_fUnicodeSupport)
SetClipboardData (CF_UNICODETEXT, NULL);
diff --git a/xorg-server/hw/xwin/winclipboardwrappers.c b/xorg-server/hw/xwin/winclipboardwrappers.c index 3d5323cc7..8470ca6c9 100644 --- a/xorg-server/hw/xwin/winclipboardwrappers.c +++ b/xorg-server/hw/xwin/winclipboardwrappers.c @@ -310,7 +310,6 @@ winProcEstablishConnection (ClientPtr client) * Wrapper for internal SetSelectionOwner function. * Grabs ownership of Windows clipboard when X11 clipboard owner changes. */ - int winProcSetSelectionOwner (ClientPtr client) { @@ -324,16 +323,14 @@ winProcSetSelectionOwner (ClientPtr client) REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); -#if 0 - ErrorF ("winProcSetSelectionOwner - Hello.\n"); -#endif + winDebug ("winProcSetSelectionOwner - Hello.\n"); /* 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; @@ -369,10 +366,8 @@ winProcSetSelectionOwner (ClientPtr client) { fOwnedToNotOwned = TRUE; -#if 0 - ErrorF ("winProcSetSelectionOwner - PRIMARY - Going from " + winDebug ("winProcSetSelectionOwner - PRIMARY - Going from " "owned to not owned.\n"); -#endif /* Adjust last owned selection */ if (None != s_iOwners[CLIP_OWN_CLIPBOARD]) @@ -384,10 +379,8 @@ winProcSetSelectionOwner (ClientPtr client) /* Save new selection owner or None */ s_iOwners[CLIP_OWN_PRIMARY] = stuff->window; -#if 0 - ErrorF ("winProcSetSelectionOwner - PRIMARY - Now owned by: %d\n", - stuff->window); -#endif + winDebug ("winProcSetSelectionOwner - PRIMARY - Now owned by: %d (clipboard is %d)\n", + stuff->window,g_iClipboardWindow); } else if (MakeAtom ("CLIPBOARD", 9, TRUE) == stuff->selection) { @@ -397,10 +390,8 @@ winProcSetSelectionOwner (ClientPtr client) { fOwnedToNotOwned = TRUE; -#if 0 - ErrorF ("winProcSetSelectionOwner - CLIPBOARD - Going from " + winDebug ("winProcSetSelectionOwner - CLIPBOARD - Going from " "owned to not owned.\n"); -#endif /* Adjust last owned selection */ if (None != s_iOwners[CLIP_OWN_PRIMARY]) @@ -412,10 +403,8 @@ winProcSetSelectionOwner (ClientPtr client) /* Save new selection owner or None */ s_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window; -#if 0 - ErrorF ("winProcSetSelectionOwner - CLIPBOARD - Now owned by: %d\n", - stuff->window); -#endif + winDebug ("winProcSetSelectionOwner - CLIPBOARD - Now owned by: %d, clipboard is %d\n", + stuff->window,g_iClipboardWindow); } else goto winProcSetSelectionOwner_Done; @@ -444,12 +433,10 @@ winProcSetSelectionOwner (ClientPtr client) && g_hwndClipboard != NULL && g_hwndClipboard == GetClipboardOwner ()) { -#if 0 - ErrorF ("winProcSetSelectionOwner - We currently own the " + winDebug ("winProcSetSelectionOwner - We currently own the " "clipboard and neither the PRIMARY nor the CLIPBOARD " "selections are owned, releasing ownership of Win32 " "clipboard.\n"); -#endif /* Release ownership of the Windows clipboard */ OpenClipboard (NULL); @@ -462,9 +449,7 @@ winProcSetSelectionOwner (ClientPtr client) /* Abort if no window at this point */ if (None == stuff->window) { -#if 0 - ErrorF ("winProcSetSelectionOwner - No window, returning.\n"); -#endif + winDebug ("winProcSetSelectionOwner - No window, returning.\n"); goto winProcSetSelectionOwner_Done; } @@ -481,10 +466,8 @@ winProcSetSelectionOwner (ClientPtr client) /* Abort if clipboard manager is owning the selection */ if (pDrawable->id == g_iClipboardWindow) { -#if 0 ErrorF ("winProcSetSelectionOwner - We changed ownership, " "aborting.\n"); -#endif goto winProcSetSelectionOwner_Done; } @@ -496,12 +479,6 @@ winProcSetSelectionOwner (ClientPtr client) goto winProcSetSelectionOwner_Done; } - /* Close clipboard if we have it open already */ - if (GetOpenClipboardWindow () == g_hwndClipboard) - { - CloseClipboard (); - } - /* Access the Windows clipboard */ if (!OpenClipboard (g_hwndClipboard)) { @@ -515,9 +492,12 @@ winProcSetSelectionOwner (ClientPtr client) { ErrorF ("winProcSetSelectionOwner - EmptyClipboard () failed: %08x\n", (int) GetLastError ()); + CloseClipboard (); goto winProcSetSelectionOwner_Done; } + winDebug("winProcSetSelectionOwner - SetClipboardData NULL\n"); + /* Advertise Unicode if we support it */ if (g_fUnicodeSupport) SetClipboardData (CF_UNICODETEXT, NULL); @@ -537,6 +517,6 @@ winProcSetSelectionOwner (ClientPtr client) goto winProcSetSelectionOwner_Done; } - winProcSetSelectionOwner_Done: +winProcSetSelectionOwner_Done: return (*winProcSetSelectionOwnerOrig) (client); } diff --git a/xorg-server/hw/xwin/winclipboardxevents.c b/xorg-server/hw/xwin/winclipboardxevents.c index 615a2cb65..4bd0f2c98 100644 --- a/xorg-server/hw/xwin/winclipboardxevents.c +++ b/xorg-server/hw/xwin/winclipboardxevents.c @@ -35,6 +35,7 @@ #endif
#include "winclipboard.h"
#include "misc.h"
+#include "winmsg.h"
/*
@@ -52,7 +53,8 @@ int winClipboardFlushXEvents (HWND hwnd,
int iWindow,
Display *pDisplay,
- Bool fUseUnicode)
+ Bool fUseUnicode,
+ Bool ClipboardOpened)
{
static Atom atomLocalProperty;
static Atom atomCompoundText;
@@ -97,6 +99,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,18 +109,20 @@ winClipboardFlushXEvents (HWND hwnd, */
case SelectionRequest:
-#if 0
+#ifdef _DEBUG
{
char *pszAtomName = NULL;
- ErrorF ("SelectionRequest - target %d\n",
+ winDebug ("SelectionRequest - target %d\n",
event.xselectionrequest.target);
pszAtomName = XGetAtomName (pDisplay,
event.xselectionrequest.target);
- ErrorF ("SelectionRequest - Target atom name %s\n", pszAtomName);
+ 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
@@ -214,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: %08x\n",
- GetLastError ());
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
+ if (!ClipboardOpened)
+ {
+ if (!OpenClipboard (hwnd))
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "OpenClipboard () failed: %08x\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;
@@ -264,6 +266,15 @@ winClipboardFlushXEvents (HWND hwnd, }
if (!hGlobal)
{
+ 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 */
+ XSetSelectionOwner (pDisplay, XA_PRIMARY, None, CurrentTime);
+ XSetSelectionOwner (pDisplay, XInternAtom (pDisplay, "CLIPBOARD", False), None, CurrentTime);
+ }
ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
"GetClipboardData () failed: %08x\n",
GetLastError ());
@@ -372,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;
@@ -462,20 +475,42 @@ winClipboardFlushXEvents (HWND hwnd, /*
- * SelectionNotify
+ * SelectionClear
*/
+ case SelectionClear:
+#ifdef _DEBUG
+ winDebug ("winClipboardFlushXEvents - SelectionClear\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
+ return WIN_XEVENTS_CONVERT;
+ break;
+
+ /*
+ * SelectionNotify
+ */
case SelectionNotify:
-#if 0
- ErrorF ("winClipboardFlushXEvents - SelectionNotify\n");
+#ifdef _DEBUG
+ winDebug ("winClipboardFlushXEvents - SelectionNotify\n");
{
char *pszAtomName;
pszAtomName = XGetAtomName (pDisplay,
event.xselection.selection);
- ErrorF ("winClipboardFlushXEvents - SelectionNotify - ATOM: %s\n",
+ winDebug ("SelectionNotify - ATOM: %s\n",
pszAtomName);
+ winDebug ("SelectionNotify - requestor %d\n", event.xselectionrequest.requestor);
XFree (pszAtomName);
}
diff --git a/xorg-server/hw/xwin/winmsg.c b/xorg-server/hw/xwin/winmsg.c index d0464f71b..ded641b77 100644 --- a/xorg-server/hw/xwin/winmsg.c +++ b/xorg-server/hw/xwin/winmsg.c @@ -98,6 +98,7 @@ winErrorFVerb (int verb, const char *format, ...) va_end (ap); } +#if !defined(_MSC_VER) || defined(_DEBUG) void winDebug (const char *format, ...) { @@ -106,6 +107,7 @@ winDebug (const char *format, ...) LogVMessageVerb(X_NONE, 3, format, ap); va_end (ap); } +#endif void winTrace (const char *format, ...) diff --git a/xorg-server/hw/xwin/winmsg.h b/xorg-server/hw/xwin/winmsg.h index 611dd6962..91da7ab1f 100644 --- a/xorg-server/hw/xwin/winmsg.h +++ b/xorg-server/hw/xwin/winmsg.h @@ -39,7 +39,12 @@ void winDrvMsgVerb (int scrnIndex, void winDrvMsg (int scrnIndex, MessageType type, const char *format, ...); void winMsgVerb (MessageType type, int verb, const char *format, ...); void winMsg (MessageType type, const char *format, ...); +#if !defined(_MSC_VER) || defined(_DEBUG) void winDebug (const char *format, ...); +#else +#define winDebug(...) +#endif + void winTrace (const char *format, ...); void winErrorFVerb (int verb, const char *format, ...); diff --git a/xorg-server/hw/xwin/winmultiwindowwm.c b/xorg-server/hw/xwin/winmultiwindowwm.c index 2ce248c63..7d29fc5c2 100644 --- a/xorg-server/hw/xwin/winmultiwindowwm.c +++ b/xorg-server/hw/xwin/winmultiwindowwm.c @@ -66,6 +66,7 @@ typedef int pid_t; #include "winprefs.h" #include "window.h" #include "pixmapstr.h" +#include "winmsg.h" #include "windowstr.h" #ifdef XWIN_MULTIWINDOWEXTWM diff --git a/xorg-server/miext/damage/damage.c b/xorg-server/miext/damage/damage.c index b7ec92a5b..c2317178e 100644 --- a/xorg-server/miext/damage/damage.c +++ b/xorg-server/miext/damage/damage.c @@ -2140,7 +2140,7 @@ DamageRegionRendered (DrawablePtr pDrawable, DamagePtr pDamage, RegionPtr pOldDa /* This call is very odd, i'm leaving it intact for API sake, but please don't use it. */ void DamageDamageRegion (DrawablePtr pDrawable, - RegionPtr pRegion) + const RegionPtr pRegion) { damageRegionAppend (pDrawable, pRegion, FALSE, -1); diff --git a/xorg-server/os/connection.c b/xorg-server/os/connection.c index eabfdaee0..1bbc8807d 100644 --- a/xorg-server/os/connection.c +++ b/xorg-server/os/connection.c @@ -1037,6 +1037,10 @@ CloseDownConnection(ClientPtr client) { OsCommPtr oc = (OsCommPtr)client->osPrivate; +#ifdef DEBUG + ErrorF("CloseDownConnection: client index = %d, socket fd = %d\n", + client->index, oc->fd); +#endif if (oc->output && oc->output->count) FlushClient(client, oc, (char *)NULL, 0); #ifdef XDMCP |