Changeset 7234 in vbox for trunk/src/VBox/HostServices/SharedClipboard
- Timestamp:
- Mar 3, 2008 12:32:52 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/win32.cpp
r7165 r7234 36 36 HWND hwnd; 37 37 HWND hwndNextInChain; 38 38 39 39 RTTHREAD thread; 40 bool 40 bool volatile fTerminate; 41 41 42 42 HANDLE hRenderEvent; 43 43 44 44 VBOXCLIPBOARDCLIENTDATA *pClient; 45 45 }; … … 93 93 { 94 94 dprintf (("vboxClipboardGetData.\n")); 95 95 96 96 *pcbActualDst = cbSrc; 97 97 98 98 LogFlow(("vboxClipboardGetData cbSrc = %d, cbDst = %d\n", cbSrc, cbDst)); 99 99 100 100 if (cbSrc > cbDst) 101 101 { … … 103 103 return; 104 104 } 105 105 106 106 memcpy (pvDst, pvSrc, cbSrc); 107 107 108 108 vboxClipboardDump(pvDst, cbSrc, u32Format); 109 109 … … 115 115 Assert(pCtx->pClient); 116 116 Assert(pCtx->pClient->data.pv == NULL && pCtx->pClient->data.cb == 0 && pCtx->pClient->data.u32Format == 0); 117 117 118 118 LogFlow(("vboxClipboardReadDataFromClient u32Format = %02X\n", u32Format)); 119 119 120 120 ResetEvent (pCtx->hRenderEvent); 121 121 122 122 vboxSvcClipboardReportMsg (pCtx->pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA, u32Format); 123 123 124 124 WaitForSingleObject(pCtx->hRenderEvent, INFINITE); 125 125 126 126 LogFlow(("vboxClipboardReadDataFromClient wait completed\n")); 127 127 128 128 return VINF_SUCCESS; 129 129 } … … 132 132 { 133 133 LogFlow(("vboxClipboardChanged\n")); 134 134 135 135 if (pCtx->pClient == NULL) 136 136 { 137 137 return; 138 138 } 139 139 140 140 /* Query list of available formats and report to host. */ 141 141 if (OpenClipboard (pCtx->hwnd)) … … 166 166 167 167 int cActual = GetClipboardFormatName(format, szFormatName, sizeof(szFormatName)/sizeof (TCHAR)); 168 168 169 169 if (cActual) 170 170 { … … 180 180 181 181 CloseClipboard (); 182 182 183 183 LogFlow(("vboxClipboardChanged u32Formats %02X\n", u32Formats)); 184 184 185 185 vboxSvcClipboardReportMsg (pCtx->pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS, u32Formats); 186 186 } … … 190 190 { 191 191 LRESULT rc = 0; 192 192 193 193 VBOXCLIPBOARDCONTEXT *pCtx = &g_ctx; 194 194 195 195 switch (msg) 196 196 { … … 240 240 /* Do nothing. Ignore the message. */ 241 241 } break; 242 242 243 243 case WM_RENDERFORMAT: 244 244 { … … 249 249 250 250 Log(("WM_RENDERFORMAT %d\n", format)); 251 251 252 252 switch (format) 253 253 { … … 266 266 267 267 int cActual = GetClipboardFormatName(format, szFormatName, sizeof(szFormatName)/sizeof (TCHAR)); 268 268 269 269 if (cActual) 270 270 { … … 277 277 break; 278 278 } 279 279 280 280 if (u32Format == 0 || pCtx->pClient == NULL) 281 281 { … … 308 308 { 309 309 Log(("WM_RENDERFORMAT setting data\n")); 310 310 311 311 if (pCtx->pClient->data.pv) 312 312 { 313 313 memcpy (pMem, pCtx->pClient->data.pv, pCtx->pClient->data.cb); 314 314 315 315 RTMemFree (pCtx->pClient->data.pv); 316 316 pCtx->pClient->data.pv = NULL; … … 340 340 } 341 341 } 342 342 343 343 RTMemFree (pCtx->pClient->data.pv); 344 344 pCtx->pClient->data.pv = NULL; 345 345 pCtx->pClient->data.cb = 0; 346 346 pCtx->pClient->data.u32Format = 0; 347 347 348 348 /* Something went wrong. */ 349 349 EmptyClipboard (); … … 354 354 { 355 355 Log(("WM_RENDERALLFORMATS\n")); 356 356 357 357 /* Do nothing. The clipboard formats will be unavailable now, because the 358 358 * windows is to be destroyed and therefore the guest side becames inactive. … … 375 375 break; 376 376 } 377 377 378 378 /* Announce available formats. Do not insert data, they will be inserted in WM_RENDER*. */ 379 379 uint32_t u32Formats = (uint32_t)lParam; 380 380 381 381 Log(("WM_USER u32Formats = %02X\n", u32Formats)); 382 382 383 383 if (OpenClipboard (hwnd)) 384 384 { 385 385 EmptyClipboard(); 386 386 387 387 Log(("WM_USER emptied clipboard\n")); 388 388 389 389 HANDLE hClip = NULL; 390 390 … … 392 392 { 393 393 dprintf(("window proc WM_USER: VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT\n")); 394 394 395 395 hClip = SetClipboardData (CF_UNICODETEXT, NULL); 396 396 } … … 399 399 { 400 400 dprintf(("window proc WM_USER: VBOX_SHARED_CLIPBOARD_FMT_BITMAP\n")); 401 401 402 402 hClip = SetClipboardData (CF_DIB, NULL); 403 403 } … … 442 442 443 443 VBOXCLIPBOARDCONTEXT *pCtx = &g_ctx; 444 444 445 445 HINSTANCE hInstance = (HINSTANCE)GetModuleHandle (NULL); 446 446 … … 521 521 522 522 g_ctx.hRenderEvent = CreateEvent(NULL, TRUE, FALSE, NULL); 523 524 rc = RTThreadCreate (&g_ctx.thread, VBoxClipboardThread, NULL, 65536, 523 524 rc = RTThreadCreate (&g_ctx.thread, VBoxClipboardThread, NULL, 65536, 525 525 RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "SHCLIP"); 526 526 … … 538 538 539 539 /* Set the termination flag and ping the window thread. */ 540 g_ctx.fTerminate = true;541 540 ASMAtomicWriteBool (&g_ctx.fTerminate, true); 541 542 542 if (g_ctx.hwnd) 543 543 { … … 546 546 547 547 CloseHandle (g_ctx.hRenderEvent); 548 548 549 549 /* Wait for the window thread to terminate. */ 550 550 RTThreadWait (g_ctx.thread, RT_INDEFINITE_WAIT, NULL); … … 556 556 { 557 557 Log(("vboxClipboardConnect\n")); 558 558 559 559 if (g_ctx.pClient != NULL) 560 560 { … … 564 564 565 565 pClient->pCtx = &g_ctx; 566 566 567 567 pClient->pCtx->pClient = pClient; 568 568 569 569 /* Synch the host clipboard content with the client. */ 570 570 vboxClipboardSync (pClient); 571 571 572 572 return VINF_SUCCESS; 573 573 } … … 577 577 /* Synch the host clipboard content with the client. */ 578 578 vboxClipboardChanged (pClient->pCtx); 579 579 580 580 return VINF_SUCCESS; 581 581 } … … 584 584 { 585 585 Log(("vboxClipboardDisconnect\n")); 586 586 587 587 g_ctx.pClient = NULL; 588 588 } … … 599 599 { 600 600 LogFlow(("vboxClipboardReadData: u32Format = %02X\n", u32Format)); 601 601 602 602 HANDLE hClip = NULL; 603 603 604 604 /* 605 605 * The guest wants to read data in the given format. … … 608 608 { 609 609 dprintf(("Clipboard opened.\n")); 610 610 611 611 if (u32Format & VBOX_SHARED_CLIPBOARD_FMT_BITMAP) 612 612 { … … 643 643 { 644 644 dprintf(("CF_UNICODETEXT\n")); 645 645 646 646 vboxClipboardGetData (VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT, uniString, (lstrlenW (uniString) + 1) * 2, 647 647 pv, cb, pcbActual); … … 690 690 dprintf(("failed to open clipboard\n")); 691 691 } 692 692 693 693 if (hClip == NULL) 694 694 { … … 697 697 pv, cb, pcbActual); 698 698 } 699 699 700 700 return VINF_SUCCESS; 701 701 } … … 704 704 { 705 705 LogFlow(("vboxClipboardWriteData\n")); 706 706 707 707 /* 708 708 * The guest returns data that was requested in the WM_RENDERFORMAT handler. 709 709 */ 710 710 Assert(pClient->data.pv == NULL && pClient->data.cb == 0 && pClient->data.u32Format == 0); 711 711 712 712 vboxClipboardDump(pv, cb, u32Format); 713 713 … … 715 715 { 716 716 pClient->data.pv = RTMemAlloc (cb); 717 717 718 718 if (pClient->data.pv) 719 719 { … … 723 723 } 724 724 } 725 725 726 726 SetEvent(pClient->pCtx->hRenderEvent); 727 727 }
Note:
See TracChangeset
for help on using the changeset viewer.