Changeset 86717 in vbox for trunk/src/VBox/GuestHost/SharedClipboard
- Timestamp:
- Oct 27, 2020 9:10:35 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 141102
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp
r86713 r86717 405 405 406 406 #ifndef TESTCASE 407 XtAppAddTimeOut(pCtx-> appContext, 0, (XtTimerCallbackProc)proc,407 XtAppAddTimeOut(pCtx->pAppContext, 0, (XtTimerCallbackProc)proc, 408 408 (XtPointer)client_data); 409 409 ssize_t cbWritten = write(pCtx->wakeupPipeWrite, WAKE_UP_STRING, WAKE_UP_STRING_LEN); … … 824 824 } event = { { 0 } }; 825 825 826 if (XtAppPeekEvent(pCtx-> appContext, &event.event))826 if (XtAppPeekEvent(pCtx->pAppContext, &event.event)) 827 827 { 828 828 if ( (event.event.type == pCtx->fixesEventBase) … … 847 847 static DECLCALLBACK(int) clipThreadMain(RTTHREAD hThreadSelf, void *pvUser) 848 848 { 849 RT_NOREF(hThreadSelf); 850 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 851 852 LogRel2(("Shared Clipboard: Starting X11 event thread\n")); 853 854 PSHCLX11CTX pCtx = (SHCLX11CTX *)pvUser; 855 856 clipInitInternal(pCtx); 857 858 if (pCtx->fGrabClipboardOnStart) 859 clipQueryX11Formats(pCtx); 860 861 /* We're now ready to run, tell parent. */ 862 int rc2 = RTThreadUserSignal(hThreadSelf); 863 AssertRC(rc2); 864 865 while (XtAppGetExitFlag(pCtx->appContext) == FALSE) 866 { 867 clipPeekEventAndDoXFixesHandling(pCtx); 868 XtAppProcessEvent(pCtx->appContext, XtIMAll); 869 } 870 871 clipUninitInternal(pCtx); 872 873 LogRel2(("Shared Clipboard: X11 event thread terminated successfully\n")); 874 return VINF_SUCCESS; 849 PSHCLX11CTX pCtx = (PSHCLX11CTX)pvUser; 850 AssertPtr(pCtx); 851 852 LogFlowFunc(("pCtx=%p\n", pCtx)); 853 854 bool fSignalled = false; /* Whether we have signalled the parent already or not. */ 855 856 int rc = clipInitInternal(pCtx); 857 if (RT_SUCCESS(rc)) 858 { 859 rc = clipRegisterContext(pCtx); 860 if (RT_SUCCESS(rc)) 861 { 862 if (pCtx->fGrabClipboardOnStart) 863 clipQueryX11Formats(pCtx); 864 865 pCtx->fThreadStarted = true; 866 867 /* We're now ready to run, tell parent. */ 868 int rc2 = RTThreadUserSignal(hThreadSelf); 869 AssertRC(rc2); 870 871 fSignalled = true; 872 873 while (XtAppGetExitFlag(pCtx->pAppContext) == FALSE) 874 { 875 clipPeekEventAndDoXFixesHandling(pCtx); 876 XtAppProcessEvent(pCtx->pAppContext, XtIMAll); 877 } 878 879 clipUnregisterContext(pCtx); 880 } 881 882 clipUninitInternal(pCtx); 883 } 884 885 if (!fSignalled) /* Signal parent if we didn't do so yet. */ 886 { 887 int rc2 = RTThreadUserSignal(hThreadSelf); 888 AssertRC(rc2); 889 } 890 891 LogFlowFuncLeaveRC(rc); 892 return rc; 875 893 } 876 894 … … 891 909 * reiterate that any outstanding requests from the X11 event loop to 892 910 * the VBox part *must* have returned before we do this. */ 893 XtAppSetExitFlag(pCtx-> appContext);911 XtAppSetExitFlag(pCtx->pAppContext); 894 912 } 895 913 … … 990 1008 int rc = VINF_SUCCESS; 991 1009 992 Assert(pCtx-> appContext == NULL); /* No nested initialization. */993 pCtx-> appContext = XtCreateApplicationContext();994 if (pCtx-> appContext == NULL)1010 Assert(pCtx->pAppContext == NULL); /* No nested initialization. */ 1011 pCtx->pAppContext = XtCreateApplicationContext(); 1012 if (pCtx->pAppContext == NULL) 995 1013 { 996 1014 LogRel(("Shared Clipboard: Failed to create Xt application context\n")); … … 1001 1019 int cArgc = 0; 1002 1020 char *pcArgv = 0; 1003 Display *pDisplay = XtOpenDisplay(pCtx-> appContext, 0, 0, "VBoxShCl", 0, 0, &cArgc, &pcArgv);1021 Display *pDisplay = XtOpenDisplay(pCtx->pAppContext, 0, 0, "VBoxShCl", 0, 0, &cArgc, &pcArgv); 1004 1022 if (pDisplay == NULL) 1005 1023 { … … 1025 1043 if (pCtx->pWidget == NULL) 1026 1044 { 1027 LogRel(("Shared Clipboard: Failed to c onstruct the X11 window\n"));1045 LogRel(("Shared Clipboard: Failed to create Xt app shell\n")); 1028 1046 rc = VERR_NO_MEMORY; /** @todo r=andy Improve this. */ 1029 1047 } 1030 1048 else 1031 rc = clipRegisterContext(pCtx); 1049 { 1050 #ifndef TESTCASE 1051 if (!XtAppAddInput(pCtx->pAppContext, pCtx->wakeupPipeRead, 1052 (XtPointer) XtInputReadMask, 1053 clipThreadDrainWakeupPipe, (XtPointer) pCtx)) 1054 { 1055 LogRel(("Shared Clipboard: Failed to add input to Xt app context\n")); 1056 rc = VERR_ACCESS_DENIED; /** @todo r=andy Improve this. */ 1057 } 1058 #endif 1059 } 1032 1060 } 1033 1061 … … 1071 1099 { 1072 1100 /* Valid widget + invalid appcontext = bug. But don't return yet. */ 1073 AssertPtr(pCtx->appContext); 1074 clipUnregisterContext(pCtx); 1101 AssertPtr(pCtx->pAppContext); 1075 1102 1076 1103 XtDestroyWidget(pCtx->pWidget); … … 1078 1105 } 1079 1106 1080 if (pCtx-> appContext)1081 { 1082 XtDestroyApplicationContext(pCtx-> appContext);1083 pCtx-> appContext = NULL;1107 if (pCtx->pAppContext) 1108 { 1109 XtDestroyApplicationContext(pCtx->pAppContext); 1110 pCtx->pAppContext = NULL; 1084 1111 } 1085 1112 … … 1133 1160 /** @todo The testcases currently do not utilize the threading code. So init stuff here. */ 1134 1161 rc = clipInitInternal(pCtx); 1162 if (RT_SUCCESS(rc)) 1163 rc = clipRegisterContext(pCtx); 1135 1164 } 1136 1165 #endif … … 1155 1184 /** @todo The testcases currently do not utilize the threading code. So uninit stuff here. */ 1156 1185 clipUninitInternal(pCtx); 1186 clipUnregisterContext(pCtx); 1157 1187 #endif 1158 1188 … … 1197 1227 if (!pipe(pipes)) 1198 1228 { 1199 pCtx->wakeupPipeRead = pipes[0];1229 pCtx->wakeupPipeRead = pipes[0]; 1200 1230 pCtx->wakeupPipeWrite = pipes[1]; 1201 if (!XtAppAddInput(pCtx->appContext, pCtx->wakeupPipeRead, 1202 (XtPointer) XtInputReadMask,1203 clipThreadDrainWakeupPipe, (XtPointer) pCtx))1204 rc = V ERR_NO_MEMORY; /* What failure means is not doc'ed. */1205 if ( RT_SUCCESS(rc)1206 && (fcntl(pCtx->wakeupPipeRead, F_SETFL, O_NONBLOCK) != 0))1231 1232 if (!fcntl(pCtx->wakeupPipeRead, F_SETFL, O_NONBLOCK)) 1233 { 1234 rc = VINF_SUCCESS; 1235 } 1236 else 1207 1237 rc = RTErrConvertFromErrno(errno); 1208 if (RT_FAILURE(rc))1209 LogRel(("Shared Clipboard: Failed to setup the termination mechanism\n"));1210 1238 } 1211 1239 else … … 1227 1255 } 1228 1256 else 1229 LogRel2(("Shared Clipboard: X11 event thread started\n")); 1257 { 1258 if (!pCtx->fThreadStarted) 1259 { 1260 LogRel(("Shared Clipboard: X11 event thread reported an error while starting\n")); 1261 } 1262 else 1263 LogRel2(("Shared Clipboard: X11 event thread started\n")); 1264 } 1230 1265 } 1231 1266
Note:
See TracChangeset
for help on using the changeset viewer.