Module: wine Branch: master Commit: dd573925e5bbfad0a19470c0462d5f23bcbc201d URL: http://source.winehq.org/git/wine.git/?a=commit;h=dd573925e5bbfad0a19470c046...
Author: Piotr Caban piotr@codeweavers.com Date: Wed May 15 15:04:58 2013 +0200
user32: Use SendNotifyMessage to send WM_DRAWCLIPBOARD.
---
dlls/user32/clipboard.c | 4 +- dlls/user32/tests/clipboard.c | 78 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/clipboard.c b/dlls/user32/clipboard.c index 0985e6f..e6fda2e 100644 --- a/dlls/user32/clipboard.c +++ b/dlls/user32/clipboard.c @@ -287,7 +287,7 @@ BOOL WINAPI CloseClipboard(void) bCBHasChanged = FALSE;
if (hWndViewer) - SendMessageW(hWndViewer, WM_DRAWCLIPBOARD, (WPARAM) GetClipboardOwner(), 0); + SendNotifyMessageW(hWndViewer, WM_DRAWCLIPBOARD, (WPARAM) GetClipboardOwner(), 0); }
bRet = TRUE; @@ -393,7 +393,7 @@ HWND WINAPI SetClipboardViewer( HWND hWnd ) HWND hwndPrev = CLIPBOARD_SetClipboardViewer(hWnd);
if (hWnd) - SendMessageW(hWnd, WM_DRAWCLIPBOARD, (WPARAM) GetClipboardOwner(), 0); + SendNotifyMessageW(hWnd, WM_DRAWCLIPBOARD, (WPARAM) GetClipboardOwner(), 0); TRACE("(%p): returning %p\n", hWnd, hwndPrev);
return hwndPrev; diff --git a/dlls/user32/tests/clipboard.c b/dlls/user32/tests/clipboard.c index 655d158..e2e727c 100644 --- a/dlls/user32/tests/clipboard.c +++ b/dlls/user32/tests/clipboard.c @@ -269,6 +269,83 @@ static void test_synthesized(void) ok(r, "gle %d\n", GetLastError()); }
+static CRITICAL_SECTION clipboard_cs; +static LRESULT CALLBACK clipboard_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) +{ + switch(msg) { + case WM_DRAWCLIPBOARD: + EnterCriticalSection(&clipboard_cs); + LeaveCriticalSection(&clipboard_cs); + break; + case WM_USER: + PostQuitMessage(0); + break; + } + + return DefWindowProc(hwnd, msg, wp, lp); +} + +static DWORD WINAPI clipboard_thread(void *param) +{ + HWND win = param; + BOOL r; + + EnterCriticalSection(&clipboard_cs); + SetLastError(0xdeadbeef); + SetClipboardViewer(win); + ok(GetLastError() == 0xdeadbeef, "GetLastError = %d\n", GetLastError()); + LeaveCriticalSection(&clipboard_cs); + + r = OpenClipboard(win); + ok(r, "OpenClipboard failed: %d\n", GetLastError()); + + r = EmptyClipboard(); + ok(r, "EmptyClipboard failed: %d\n", GetLastError()); + + EnterCriticalSection(&clipboard_cs); + r = CloseClipboard(); + ok(r, "CloseClipboard failed: %d\n", GetLastError()); + LeaveCriticalSection(&clipboard_cs); + + r = PostMessage(win, WM_USER, 0, 0); + ok(r, "PostMessage failed: %d\n", GetLastError()); + return 0; +} + +static void test_messages(void) +{ + WNDCLASS cls; + HWND win; + MSG msg; + HANDLE thread; + DWORD tid; + + InitializeCriticalSection(&clipboard_cs); + + memset(&cls, 0, sizeof(cls)); + cls.lpfnWndProc = clipboard_wnd_proc; + cls.hInstance = GetModuleHandle(0); + cls.lpszClassName = "clipboard_test"; + RegisterClass(&cls); + + win = CreateWindow("clipboard_test", NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0); + ok(win != NULL, "CreateWindow failed: %d\n", GetLastError()); + + thread = CreateThread(NULL, 0, clipboard_thread, (void*)win, 0, &tid); + ok(thread != NULL, "CreateThread failed: %d\n", GetLastError()); + + while(GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + ok(WaitForSingleObject(thread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n"); + CloseHandle(thread); + + UnregisterClass("clipboard_test", GetModuleHandle(0)); + DeleteCriticalSection(&clipboard_cs); +} + START_TEST(clipboard) { SetLastError(0xdeadbeef); @@ -278,4 +355,5 @@ START_TEST(clipboard) test_RegisterClipboardFormatA(); test_ClipboardOwner(); test_synthesized(); + test_messages(); }