Fix bug #7281, clipboard viewer should not
call SetClipboard viewer when bogus in Xming/CygwinX (Colin Harrison)
This commit is contained in:
parent
a1a8e4f7f5
commit
1880defe4e
|
@ -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,9 +223,12 @@ 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. */
|
||||||
|
if (first == hwnd) return 0; /* Make sure it's not us! */
|
||||||
winDebug (" WM_WM_REINIT: Replacing us(%x) with %x at head "
|
winDebug (" WM_WM_REINIT: Replacing us(%x) with %x at head "
|
||||||
"of chain\n", hwnd, s_hwndNextViewer);
|
"of chain\n", hwnd, s_hwndNextViewer);
|
||||||
s_fCBCInitialized = FALSE;
|
s_fCBCInitialized = FALSE;
|
||||||
|
@ -230,18 +236,14 @@ winClipboardWindowProc (HWND hwnd, UINT message,
|
||||||
s_hwndNextViewer = NULL;
|
s_hwndNextViewer = NULL;
|
||||||
s_fCBCInitialized = FALSE;
|
s_fCBCInitialized = FALSE;
|
||||||
winDebug (" WM_WM_REINIT: Putting us back at head of chain.\n");
|
winDebug (" WM_WM_REINIT: Putting us back at head of chain.\n");
|
||||||
s_hwndNextViewer = SetClipboardViewer (hwnd);
|
first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
|
||||||
if (s_hwndNextViewer == hwnd)
|
if (first == hwnd) return 0; /* Make sure it's not us! */
|
||||||
{
|
next = SetClipboardViewer (hwnd);
|
||||||
s_hwndNextViewer = NULL;
|
error_code = GetLastError();
|
||||||
winErrorFVerb (1, "winClipboardWindowProc - WM_WM_REINIT: "
|
if (SUCCEEDED(error_code) && (next == first)) /* SetClipboardViewer must have succeeded, and the handle */
|
||||||
"attempted to set next window to ourselves.\n");
|
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;
|
||||||
|
|
Loading…
Reference in New Issue