- Timestamp:
- Apr 6, 2009 1:53:45 PM (16 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/x11-clipboard.cpp
r18708 r18756 762 762 return; 763 763 764 /* We set this to NULL when the event thread exits. It really should 765 * have exited at this point, when we are about to unload the code from 766 * memory. */ 767 Assert(pCtx->widget == NULL); 764 768 RTSemEventDestroy(pCtx->waitForData); 765 769 } … … 823 827 * Shut down the shared clipboard X11 backend. 824 828 * @note X11 backend code 829 * @note Any requests from this object to get clipboard data from VBox 830 * *must* have completed or aborted before we are called, as 831 * otherwise the X11 event loop will still be waiting for the request 832 * to return and will not be able to terminate. 825 833 */ 826 834 int VBoxX11ClipboardStopX11(VBOXCLIPBOARDCONTEXTX11 *pCtx) … … 835 843 return VINF_SUCCESS; 836 844 845 /* This might mean that we are getting stopped twice. */ 846 AssertReturn(pCtx->widget != NULL, VERR_WRONG_ORDER); 837 847 pCtx->eOwner = NONE; 838 848 pCtx->X11TextFormat = INVALID; … … 840 850 LogRelFunc(("stopping the shared clipboard X11 backend\n")); 841 851 842 /* Set the termination flag . This has been observed to block if it was set843 * during a request for clipboard data coming from X11, so only we do it844 * after releasing any such requests. */852 /* Set the termination flag to tell the Xt event loop to exit. We 853 * reiterate that any outstanding requests from the X11 event loop to 854 * the VBox part *must* have returned before we do this. */ 845 855 XtAppSetExitFlag(pCtx->appContext); 846 856 /* Wake up the event loop */ … … 861 871 LogRelFunc(("rc=%Rrc\n", rc)); 862 872 XtCloseDisplay(XtDisplay(pCtx->widget)); 873 pCtx->widget = NULL; /* For sanity assertions. */ 863 874 LogFlowFunc(("returning %Rrc.\n", rc)); 864 875 return rc; -
trunk/src/VBox/HostServices/SharedClipboard/x11-clipboard.cpp
r18708 r18756 185 185 int rc = VINF_SUCCESS; 186 186 LogRelFunc(("shutting down host clipboard\n")); 187 VBoxX11ClipboardDestructX11(g_ctxHost.pBackend); 188 /* We can safely destroy these as the backend has exited 189 * successfully and no other calls from the host code should be 190 * forthcoming. */ 191 RTSemEventDestroy(g_ctxHost.waitForData); 192 RTSemMutexDestroy(g_ctxHost.clipboardMutex); 193 } 194 195 /** 196 * Connect a guest to the shared clipboard. 197 * @note host glue code 198 * @note on the host, we assume that some other application already owns 199 * the clipboard and leave ownership to X11. 200 */ 201 int vboxClipboardConnect (VBOXCLIPBOARDCLIENTDATA *pClient) 202 { 203 int rc = VINF_SUCCESS; 204 LogFlowFunc(("\n")); 205 /* Only one client is supported for now */ 206 AssertLogRelReturn(g_ctxHost.pClient == 0, VERR_NOT_SUPPORTED); 207 pClient->pCtx = &g_ctxHost; 208 pClient->pCtx->pClient = pClient; 209 /** The pClient pointer is a dummy anyway, as we only support a single 210 * client at a time. */ 211 rc = VBoxX11ClipboardStartX11(g_ctxHost.pBackend, 212 true /* fOwnClipboard */); 213 return rc; 214 } 215 216 /** 217 * Synchronise the contents of the host clipboard with the guest, called 218 * after a save and restore of the guest. 219 * @note Host glue code 220 */ 221 int vboxClipboardSync (VBOXCLIPBOARDCLIENTDATA *pClient) 222 { 223 224 /* On a Linux host, the guest should never synchronise/cache its 225 * clipboard contents, as we have no way of reliably telling when the 226 * host clipboard data changes. So instead of synchronising, we tell 227 * the guest to empty its clipboard, and we set the cached flag so that 228 * we report formats to the guest next time we poll for them. */ 229 /** @note This has been changed so that the message is sent even if 230 * X11 is not available. */ 231 vboxSvcClipboardReportMsg (g_ctxHost.pClient, 232 VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS, 0); 233 VBoxX11ClipboardRequestSyncX11(g_ctxHost.pBackend); 234 235 return VINF_SUCCESS; 236 } 237 238 /** 239 * Shut down the shared clipboard service and "disconnect" the guest. 240 * @note Host glue code 241 */ 242 void vboxClipboardDisconnect (VBOXCLIPBOARDCLIENTDATA *) 243 { 244 LogFlow(("vboxClipboardDisconnect\n")); 245 246 RTSemMutexRequest(g_ctxHost.clipboardMutex, RT_INDEFINITE_WAIT); 187 247 /* Drop the reference to the client, in case it is still there. This 188 248 * will cause any outstanding clipboard data requests from X11 to fail … … 199 259 * even if we are not waiting. */ 200 260 RTSemEventSignal(g_ctxHost.waitForData); 201 VBoxX11ClipboardDestructX11(g_ctxHost.pBackend); 202 /* We can safely destroy these as the backend has exited 203 * successfully and no other calls from the host code should be 204 * forthcoming. */ 205 RTSemEventDestroy(g_ctxHost.waitForData); 206 RTSemMutexDestroy(g_ctxHost.clipboardMutex); 207 } 208 209 /** 210 * Connect a guest to the shared clipboard. 211 * @note host glue code 212 * @note on the host, we assume that some other application already owns 213 * the clipboard and leave ownership to X11. 214 */ 215 int vboxClipboardConnect (VBOXCLIPBOARDCLIENTDATA *pClient) 216 { 217 int rc = VINF_SUCCESS; 218 LogFlowFunc(("\n")); 219 /* Only one client is supported for now */ 220 AssertLogRelReturn(g_ctxHost.pClient == 0, VERR_NOT_SUPPORTED); 221 pClient->pCtx = &g_ctxHost; 222 pClient->pCtx->pClient = pClient; 223 /** The pClient pointer is a dummy anyway, as we only support a single 224 * client at a time. */ 225 rc = VBoxX11ClipboardStartX11(g_ctxHost.pBackend, 226 true /* fOwnClipboard */); 227 return rc; 228 } 229 230 /** 231 * Synchronise the contents of the host clipboard with the guest, called 232 * after a save and restore of the guest. 233 * @note Host glue code 234 */ 235 int vboxClipboardSync (VBOXCLIPBOARDCLIENTDATA *pClient) 236 { 237 238 /* On a Linux host, the guest should never synchronise/cache its 239 * clipboard contents, as we have no way of reliably telling when the 240 * host clipboard data changes. So instead of synchronising, we tell 241 * the guest to empty its clipboard, and we set the cached flag so that 242 * we report formats to the guest next time we poll for them. */ 243 /** @note This has been changed so that the message is sent even if 244 * X11 is not available. */ 245 vboxSvcClipboardReportMsg (g_ctxHost.pClient, 246 VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS, 0); 247 VBoxX11ClipboardRequestSyncX11(g_ctxHost.pBackend); 248 249 return VINF_SUCCESS; 250 } 251 252 /** 253 * Shut down the shared clipboard service and "disconnect" the guest. 254 * @note Host glue code 255 */ 256 void vboxClipboardDisconnect (VBOXCLIPBOARDCLIENTDATA *) 257 { 258 LogFlow(("vboxClipboardDisconnect\n")); 259 260 RTSemMutexRequest(g_ctxHost.clipboardMutex, RT_INDEFINITE_WAIT); 261 g_ctxHost.pClient = NULL; 261 int rc = VBoxX11ClipboardStopX11(g_ctxHost.pBackend); 262 262 /** @todo handle this slightly more reasonably, or be really sure 263 263 * it won't go wrong. */ 264 AssertRC( VBoxX11ClipboardStopX11(g_ctxHost.pBackend));264 AssertRC(rc); 265 265 RTSemMutexRelease(g_ctxHost.clipboardMutex); 266 266 }
Note:
See TracChangeset
for help on using the changeset viewer.