Changeset 57344 in vbox for trunk/src/VBox/Additions/x11/VBoxClient
- Timestamp:
- Aug 14, 2015 9:22:27 AM (9 years ago)
- Location:
- trunk/src/VBox/Additions/x11/VBoxClient
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/seamless-x11.cpp
r57265 r57344 26 26 27 27 #include "seamless-x11.h" 28 #include "VBoxClient.h" 28 29 29 30 #include <X11/Xatom.h> … … 88 89 } 89 90 mHostCallback = pHostCallback; 91 unmonitorClientList(); 90 92 LogRelFlowFunc(("returning %Rrc\n", rc)); 91 93 return rc; … … 107 109 108 110 LogRelFlowFunc(("\n")); 111 if (mEnabled) 112 return VINF_SUCCESS; 109 113 mSupportsShape = XShapeQueryExtension(mDisplay, &event, &error); 110 114 mEnabled = true; … … 120 124 { 121 125 LogRelFlowFunc(("\n")); 126 if (!mEnabled) 127 return; 122 128 mEnabled = false; 123 129 unmonitorClientList(); … … 135 141 { 136 142 LogRelFlowFunc(("called\n")); 137 XSelectInput(mDisplay, DefaultRootWindow(mDisplay), 0);143 XSelectInput(mDisplay, DefaultRootWindow(mDisplay), PropertyChangeMask); 138 144 } 139 145 … … 270 276 Display *pDisplay = (Display *)pvParam; 271 277 278 XShapeSelectInput(pDisplay, pInfo->Core.Key, 0); 272 279 delete pInfo; 273 280 return VINF_SUCCESS; … … 491 498 { 492 499 bool rc = false; 493 494 LogRelFlowFunc(("\n")); 500 Display *pDisplay = XOpenDisplay(NULL); 501 502 LogRelFlowFunc(("\n")); 503 if (pDisplay == NULL) 504 VBClFatalError(("Failed to open X11 display.\n")); 495 505 /* Message contents set to zero. */ 496 506 XClientMessageEvent clientMessage = { ClientMessage, 0, 0, 0, 0, 0, 8 }; 497 507 498 if (XSendEvent(mDisplay, DefaultRootWindow(mDisplay), false, 499 SubstructureNotifyMask, (XEvent *)&clientMessage)) 500 { 501 XFlush(mDisplay); 508 if (XSendEvent(pDisplay, DefaultRootWindow(mDisplay), false, 509 PropertyChangeMask, (XEvent *)&clientMessage)) 502 510 rc = true; 503 }511 XCloseDisplay(pDisplay); 504 512 LogRelFlowFunc(("returning %RTbool\n", rc)); 505 513 return rc; -
trunk/src/VBox/Additions/x11/VBoxClient/seamless.cpp
r55401 r57344 41 41 mX11MonitorThreadStopping = false; 42 42 mMode = VMMDev_Seamless_Disabled; 43 mfPaused = false;43 mfPaused = true; 44 44 } 45 45 … … 87 87 if (RT_FAILURE(rc)) 88 88 break; 89 rc = startX11MonitorThread(); 90 if (RT_FAILURE(rc)) 91 break; 89 92 } while(0); 90 93 if (RT_FAILURE(rc)) 91 LogRel(("VBoxClient (seamless): failed to start. Stage: \"%s\" Error: %Rrc\n",94 VBClFatalError(("VBoxClient (seamless): failed to start. Stage: \"%s\" Error: %Rrc\n", 92 95 pcszStage, rc)); 93 96 return rc; … … 170 173 if (RT_SUCCESS(rc) || rc == VERR_TRY_AGAIN) 171 174 { 172 if (mMode == VMMDev_Seamless_Visible_Region && !mfPaused) 173 /* This does it's own logging on failure. */ 174 rc = startX11MonitorThread(); 175 if (mMode == VMMDev_Seamless_Visible_Region) 176 mfPaused = false; 175 177 else 176 /* This does it's own logging on failure. */177 rc = stopX11MonitorThread();178 mfPaused = true; 179 mX11Monitor.interruptEventWait(); 178 180 } 179 181 else … … 183 185 LogRelFlowFunc(("returning %Rrc\n", rc)); 184 186 return rc; 185 }186 187 int SeamlessMain::cancelEvent(void)188 {189 return VbglR3InterruptEventWaits();190 187 } 191 188 … … 199 196 200 197 LogRelFlowFunc(("\n")); 201 rc = pHost->mX11Monitor.start(); 202 if (RT_SUCCESS(rc)) 203 { 204 while (!pHost->mX11MonitorThreadStopping) 205 pHost->mX11Monitor.nextConfigurationEvent(); 206 pHost->mX11Monitor.stop(); 198 while (!pHost->mX11MonitorThreadStopping) 199 { 200 if (!pHost->mfPaused) 201 { 202 rc = pHost->mX11Monitor.start(); 203 if (RT_FAILURE(rc)) 204 VBClFatalError(("Failed to change the X11 seamless service state, mfPaused=%RTbool, rc=%Rrc\n", 205 pHost->mfPaused, rc)); 206 } 207 pHost->mX11Monitor.nextConfigurationEvent(); 208 if (pHost->mfPaused || pHost->mX11MonitorThreadStopping) 209 pHost->mX11Monitor.stop(); 207 210 } 208 211 LogRelFlowFunc(("returning %Rrc\n", rc)); … … 248 251 } 249 252 250 /** Pause the service loop. */251 int SeamlessMain::pause()252 {253 int rc;254 const char *pcszStage;255 256 LogRelFlowFunc(("\n"));257 mfPaused = true;258 do {259 pcszStage = "Reporting end of support for seamless capability";260 rc = VbglR3SeamlessSetCap(false);261 if (RT_FAILURE(rc))262 break;263 pcszStage = "Interrupting the event loop";264 rc = cancelEvent();265 if (RT_FAILURE(rc))266 break;267 } while (0);268 if (RT_FAILURE(rc))269 LogRelFunc(("Failure. Stage: \"%s\" Error: %Rrc (VBoxClient)\n",270 pcszStage, rc));271 return rc;272 }273 274 /** Resume after pausing. */275 int SeamlessMain::resume()276 {277 int rc;278 const char *pcszStage;279 280 LogRelFlowFunc(("\n"));281 mfPaused = false;282 do {283 pcszStage = "Reporting support for seamless capability";284 rc = VbglR3SeamlessSetCap(true);285 if (RT_FAILURE(rc))286 break;287 pcszStage = "Interrupting the event loop";288 rc = cancelEvent();289 if (RT_FAILURE(rc))290 break;291 } while (0);292 if (RT_FAILURE(rc))293 LogRelFunc(("Failure. Stage: \"%s\" Error: %Rrc (VBoxClient)\n",294 pcszStage, rc));295 return rc;296 }297 298 253 /** @todo Expand this? */ 299 254 int SeamlessMain::selfTest() … … 382 337 if (!pSelf->mIsInitialised) 383 338 return VERR_INTERNAL_ERROR; 384 rc = VBClStartVTMonitor();385 if (RT_FAILURE(rc))386 VBClFatalError(("Failed to start the VT monitor thread: %Rrc\n", rc));387 339 /* This only exits on error. */ 388 340 rc = pSelf->mSeamless.run(); … … 391 343 } 392 344 393 static int pause(struct VBCLSERVICE **ppInterface)394 {395 struct SEAMLESSSERVICE *pSelf = getClassFromInterface(ppInterface);396 397 return pSelf->mSeamless.pause();398 }399 400 static int resume(struct VBCLSERVICE **ppInterface)401 {402 struct SEAMLESSSERVICE *pSelf = getClassFromInterface(ppInterface);403 404 return pSelf->mSeamless.resume();405 }406 407 345 static void cleanup(struct VBCLSERVICE **ppInterface) 408 346 { … … 417 355 init, 418 356 run, 419 pause,420 resume,357 VBClServiceDefaultHandler, /* pause */ 358 VBClServiceDefaultHandler, /* resume */ 421 359 cleanup 422 360 }; -
trunk/src/VBox/Additions/x11/VBoxClient/seamless.h
r55401 r57344 59 59 int nextStateChangeEvent(void); 60 60 61 /**62 * Interrupt an event wait and cause the current or next63 * @a nextStateChangeEvent call to return immediately.64 */65 int cancelEvent(void);66 67 61 /** Thread function to monitor X11 window configuration changes. */ 68 62 static DECLCALLBACK(int) x11MonitorThread(RTTHREAD self, void *pvUser); -
trunk/src/VBox/Additions/x11/VBoxClient/testcase/tstSeamlessX11-auto.cpp
r55401 r57344 45 45 #define TEST_DISPLAY ((Display *)0xffff) 46 46 #define TEST_ROOT ((Window)1) 47 48 extern void vbclFatalError(char *psz) 49 { 50 RTPrintf("Fatal error: %s\n", psz); 51 exit(1); 52 } 47 53 48 54 extern "C" Display *XOpenDisplay(const char *display_name);
Note:
See TracChangeset
for help on using the changeset viewer.