Changeset 78168 in vbox for trunk/src/VBox/HostServices/SharedClipboard
- Timestamp:
- Apr 17, 2019 2:59:59 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp
r78164 r78168 174 174 LRESULT rc = 0; 175 175 176 PVBOXCLIPBOARDCONTEXT pCtx = &g_ctx; 176 const PVBOXCLIPBOARDCONTEXT pCtx = &g_ctx; 177 const PVBOXCLIPBOARDWINCTX pWinCtx = &pCtx->Win; 177 178 178 179 switch (msg) … … 194 195 Log(("WM_CHANGECBCHAIN\n")); 195 196 196 if (VBoxClipboardWinIsNewAPI(&p Ctx->Win.newAPI))197 if (VBoxClipboardWinIsNewAPI(&pWinCtx->newAPI)) 197 198 { 198 199 rc = DefWindowProc(hwnd, msg, wParam, lParam); … … 203 204 HWND hwndNext = (HWND)lParam; 204 205 205 if (hwndRemoved == p Ctx->Win.hWndNextInChain)206 if (hwndRemoved == pWinCtx->hWndNextInChain) 206 207 { 207 208 /* The window that was next to our in the chain is being removed. 208 209 * Relink to the new next window. 209 210 */ 210 p Ctx->Win.hWndNextInChain = hwndNext;211 pWinCtx->hWndNextInChain = hwndNext; 211 212 } 212 213 else 213 214 { 214 if (p Ctx->Win.hWndNextInChain)215 if (pWinCtx->hWndNextInChain) 215 216 { 216 217 /* Pass the message further. */ 217 218 DWORD_PTR dwResult; 218 rc = SendMessageTimeout(p Ctx->Win.hWndNextInChain, WM_CHANGECBCHAIN, wParam, lParam, 0,219 rc = SendMessageTimeout(pWinCtx->hWndNextInChain, WM_CHANGECBCHAIN, wParam, lParam, 0, 219 220 VBOX_CLIPBOARD_CBCHAIN_TIMEOUT_MS, 220 221 &dwResult); … … 236 237 } 237 238 238 if (p Ctx->Win.hWndNextInChain)239 { 240 Log(("WM_DRAWCLIPBOARD next %p\n", p Ctx->Win.hWndNextInChain));239 if (pWinCtx->hWndNextInChain) 240 { 241 Log(("WM_DRAWCLIPBOARD next %p\n", pWinCtx->hWndNextInChain)); 241 242 /* Pass the message to next windows in the clipboard chain. */ 242 243 DWORD_PTR dwResult; 243 rc = SendMessageTimeout(p Ctx->Win.hWndNextInChain, msg, wParam, lParam, 0, VBOX_CLIPBOARD_CBCHAIN_TIMEOUT_MS,244 rc = SendMessageTimeout(pWinCtx->hWndNextInChain, msg, wParam, lParam, 0, VBOX_CLIPBOARD_CBCHAIN_TIMEOUT_MS, 244 245 &dwResult); 245 246 if (!rc) … … 250 251 case WM_TIMER: 251 252 { 252 if (VBoxClipboardWinIsNewAPI(&p Ctx->Win.newAPI))253 if (VBoxClipboardWinIsNewAPI(&pWinCtx->newAPI)) 253 254 break; 254 255 … … 257 258 /* Re-register ourselves in the clipboard chain if our last ping 258 259 * timed out or there seems to be no valid chain. */ 259 if (!hViewer || p Ctx->Win.oldAPI.fCBChainPingInProcess)260 if (!hViewer || pWinCtx->oldAPI.fCBChainPingInProcess) 260 261 { 261 262 VBoxClipboardWinRemoveFromCBChain(&pCtx->Win); … … 265 266 /* Start a new ping by passing a dummy WM_CHANGECBCHAIN to be 266 267 * processed by ourselves to the chain. */ 267 p Ctx->Win.oldAPI.fCBChainPingInProcess = TRUE;268 pWinCtx->oldAPI.fCBChainPingInProcess = TRUE; 268 269 269 270 hViewer = GetClipboardViewer(); 270 271 if (hViewer) 271 272 SendMessageCallback(hViewer, WM_CHANGECBCHAIN, 272 (WPARAM)p Ctx->Win.hWndNextInChain, (LPARAM)pCtx->Win.hWndNextInChain,273 VBoxClipboardWinChainPingProc, (ULONG_PTR)p Ctx);273 (WPARAM)pWinCtx->hWndNextInChain, (LPARAM)pWinCtx->hWndNextInChain, 274 VBoxClipboardWinChainPingProc, (ULONG_PTR)pWinCtx); 274 275 } break; 275 276 … … 454 455 /* MS recommends to remove from Clipboard chain in this callback. */ 455 456 VBoxClipboardWinRemoveFromCBChain(&pCtx->Win); 456 if (p Ctx->Win.oldAPI.timerRefresh)457 { 458 Assert(p Ctx->Win.hWnd);459 KillTimer(p Ctx->Win.hWnd, 0);457 if (pWinCtx->oldAPI.timerRefresh) 458 { 459 Assert(pWinCtx->hWnd); 460 KillTimer(pWinCtx->hWnd, 0); 460 461 } 461 462 PostQuitMessage(0); … … 481 482 LogFlow(("VBoxClipboardThread\n")); 482 483 483 const PVBOXCLIPBOARDCONTEXT pCtx = &g_ctx; 484 const PVBOXCLIPBOARDCONTEXT pCtx = &g_ctx; 485 const PVBOXCLIPBOARDWINCTX pWinCtx = &pCtx->Win; 484 486 485 487 HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL); … … 505 507 { 506 508 /* Create the window. */ 507 p Ctx->Win.hWnd = CreateWindowEx (WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT | WS_EX_TOPMOST,508 509 510 511 if (p Ctx->Win.hWnd == NULL)509 pWinCtx->hWnd = CreateWindowEx (WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT | WS_EX_TOPMOST, 510 s_szClipWndClassName, s_szClipWndClassName, 511 WS_POPUPWINDOW, 512 -200, -200, 100, 100, NULL, NULL, hInstance, NULL); 513 if (pWinCtx->hWnd == NULL) 512 514 { 513 515 Log(("Failed to create window\n")); … … 516 518 else 517 519 { 518 SetWindowPos(p Ctx->Win.hWnd, HWND_TOPMOST, -200, -200, 0, 0,520 SetWindowPos(pWinCtx->hWnd, HWND_TOPMOST, -200, -200, 0, 0, 519 521 SWP_NOACTIVATE | SWP_HIDEWINDOW | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOSIZE); 520 522 521 523 VBoxClipboardWinAddToCBChain(&pCtx->Win); 522 if (!VBoxClipboardWinIsNewAPI(&p Ctx->Win.newAPI))523 p Ctx->Win.oldAPI.timerRefresh = SetTimer(pCtx->Win.hWnd, 0, 10 * 1000, NULL);524 if (!VBoxClipboardWinIsNewAPI(&pWinCtx->newAPI)) 525 pWinCtx->oldAPI.timerRefresh = SetTimer(pWinCtx->hWnd, 0, 10 * 1000, NULL); 524 526 525 527 MSG msg; … … 540 542 } 541 543 542 p Ctx->Win.hWnd = NULL;544 pWinCtx->hWnd = NULL; 543 545 544 546 if (atomWindowClass != 0) … … 652 654 void vboxClipboardFormatAnnounce (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t u32Formats) 653 655 { 656 AssertPtrReturnVoid(pClient); 657 AssertPtrReturnVoid(pClient->pCtx); 658 654 659 /* 655 660 * The guest announces formats. Forward to the window thread. … … 690 695 int vboxClipboardReadData (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t u32Format, void *pv, uint32_t cb, uint32_t *pcbActual) 691 696 { 697 AssertPtrReturn(pClient, VERR_INVALID_POINTER); 698 AssertPtrReturn(pClient->pCtx, VERR_INVALID_POINTER); 699 692 700 LogFlow(("vboxClipboardReadData: u32Format = %02X\n", u32Format)); 693 701 694 702 HANDLE hClip = NULL; 703 704 const PVBOXCLIPBOARDWINCTX pWinCtx = &pClient->pCtx->Win; 695 705 696 706 /* 697 707 * The guest wants to read data in the given format. 698 708 */ 699 int rc = VBoxClipboardWinOpen(p Client->pCtx->Win.hWnd);709 int rc = VBoxClipboardWinOpen(pWinCtx->hWnd); 700 710 if (RT_SUCCESS(rc)) 701 711 {
Note:
See TracChangeset
for help on using the changeset viewer.