Fix bug #7281, clipboard viewer should not

call SetClipboard viewer when bogus in Xming/CygwinX
(Colin Harrison)
This commit is contained in:
Alan Hourihane 2006-08-18 09:09:53 +01:00
parent a1a8e4f7f5
commit 1880defe4e

View File

@ -167,16 +167,19 @@ winClipboardWindowProc (HWND hwnd, UINT message,
case WM_CREATE: case WM_CREATE:
{ {
HWND first, next;
DWORD error_code = 0;
winDebug ("winClipboardWindowProc - WM_CREATE\n"); 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 */ /* Add ourselves to the clipboard viewer chain */
s_hwndNextViewer = SetClipboardViewer (hwnd); next = SetClipboardViewer (hwnd);
if (s_hwndNextViewer == hwnd) error_code = GetLastError();
{ if (SUCCEEDED(error_code) && (next == first)) /* SetClipboardViewer must have succeeded, and the handle */
s_hwndNextViewer = NULL; s_hwndNextViewer = next; /* it returned must have been the first window in the chain */
winErrorFVerb (1, "winClipboardWindowProc - WM_CREATE: " else
"attempted to set next window to ourselves."); s_fCBCInitialized = FALSE;
}
} }
return 0; return 0;
@ -220,28 +223,27 @@ winClipboardWindowProc (HWND hwnd, UINT message,
* expensive than just putting ourselves back into the chain. * expensive than just putting ourselves back into the chain.
*/ */
HWND first, next;
DWORD error_code = 0;
winDebug ("winClipboardWindowProc - WM_WM_REINIT: Enter\n"); winDebug ("winClipboardWindowProc - WM_WM_REINIT: Enter\n");
if (hwnd != GetClipboardViewer ())
{ first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
winDebug (" WM_WM_REINIT: Replacing us(%x) with %x at head " if (first == hwnd) return 0; /* Make sure it's not us! */
"of chain\n", hwnd, s_hwndNextViewer); winDebug (" WM_WM_REINIT: Replacing us(%x) with %x at head "
s_fCBCInitialized = FALSE; "of chain\n", hwnd, s_hwndNextViewer);
ChangeClipboardChain (hwnd, s_hwndNextViewer); s_fCBCInitialized = FALSE;
s_hwndNextViewer = NULL; ChangeClipboardChain (hwnd, s_hwndNextViewer);
s_fCBCInitialized = FALSE; s_hwndNextViewer = NULL;
winDebug (" WM_WM_REINIT: Putting us back at head of chain.\n"); s_fCBCInitialized = FALSE;
s_hwndNextViewer = SetClipboardViewer (hwnd); winDebug (" WM_WM_REINIT: Putting us back at head of chain.\n");
if (s_hwndNextViewer == hwnd) first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
{ if (first == hwnd) return 0; /* Make sure it's not us! */
s_hwndNextViewer = NULL; next = SetClipboardViewer (hwnd);
winErrorFVerb (1, "winClipboardWindowProc - WM_WM_REINIT: " error_code = GetLastError();
"attempted to set next window to ourselves.\n"); 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 else
{ s_fCBCInitialized = FALSE;
winDebug (" WM_WM_REINIT: already at head of viewer chain.\n");
}
} }
winDebug ("winClipboardWindowProc - WM_WM_REINIT: Exit\n"); winDebug ("winClipboardWindowProc - WM_WM_REINIT: Exit\n");
return 0; return 0;