Changeset 36685 in vbox
- Timestamp:
- Apr 15, 2011 1:35:27 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 71192
- Location:
- trunk/src/VBox/Additions/x11/VBoxClient
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/seamless-x11.cpp
r36672 r36685 263 263 } 264 264 265 DECLCALLBACK(int) VBoxGuestWinFree(VBoxGuestWinInfo *pInfo, void *pvParam) 266 { 267 Display *pDisplay = (Display *)pvParam; 268 269 XShapeSelectInput(pDisplay, pInfo->Core.Key, 0); 270 delete pInfo; 271 return VINF_SUCCESS; 272 } 265 273 266 274 /** … … 271 279 /* We use post-increment in the operation to prevent the iterator from being invalidated. */ 272 280 LogRelFlowFunc(("\n")); 273 for (VBoxGuestWindowList::iterator it = mGuestWindows.begin(); it != mGuestWindows.end(); 274 mGuestWindows.removeWindow(it++)) 275 { 276 XShapeSelectInput(mDisplay, it->first, 0); 277 } 281 mGuestWindows.detachAll(VBoxGuestWinFree, mDisplay); 278 282 LogRelFlowFunc(("returning\n")); 279 283 } … … 325 329 { 326 330 LogRelFlowFunc(("\n")); 327 VBoxGuestWindowList::iterator iter; 328 329 iter = mGuestWindows.find(hWin); 330 if (iter != mGuestWindows.end()) 331 VBoxGuestWinInfo *pInfo = mGuestWindows.find(hWin); 332 if (pInfo) 331 333 { 332 334 XWindowAttributes winAttrib; … … 334 336 if (!XGetWindowAttributes(mDisplay, hWin, &winAttrib)) 335 337 return; 336 iter->second->mX = winAttrib.x;337 iter->second->mY = winAttrib.y;338 iter->second->mWidth = winAttrib.width;339 iter->second->mHeight = winAttrib.height;340 if ( iter->second->mhasShape)338 pInfo->mX = winAttrib.x; 339 pInfo->mY = winAttrib.y; 340 pInfo->mWidth = winAttrib.width; 341 pInfo->mHeight = winAttrib.height; 342 if (pInfo->mhasShape) 341 343 { 342 344 XRectangle *pRects; … … 347 349 if (!pRects) 348 350 cRects = 0; 349 if ( iter->second->mpRects)350 XFree( iter->second->mpRects);351 iter->second->mcRects = cRects;352 iter->second->mpRects = pRects;351 if (pInfo->mpRects) 352 XFree(pInfo->mpRects); 353 pInfo->mcRects = cRects; 354 pInfo->mpRects = pRects; 353 355 } 354 356 mChanged = true; … … 365 367 { 366 368 LogRelFlowFunc(("\n")); 367 VBoxGuestWindowList::iterator iter; 368 369 iter = mGuestWindows.find(hWin); 370 if (mGuestWindows.end() == iter) 369 VBoxGuestWinInfo *pInfo = mGuestWindows.find(hWin); 370 if (!pInfo) 371 371 { 372 372 addClientWindow(hWin); … … 385 385 { 386 386 LogRelFlowFunc(("\n")); 387 VBoxGuestWindowList::iterator iter; 388 389 iter = mGuestWindows.find(hWin); 390 if (iter != mGuestWindows.end()) 387 VBoxGuestWinInfo *pInfo = mGuestWindows.find(hWin); 388 if (pInfo) 391 389 { 392 390 XRectangle *pRects; … … 397 395 if (!pRects) 398 396 cRects = 0; 399 iter->second->mhasShape = true;400 if ( iter->second->mpRects)401 XFree( iter->second->mpRects);402 iter->second->mcRects = cRects;403 iter->second->mpRects = pRects;397 pInfo->mhasShape = true; 398 if (pInfo->mpRects) 399 XFree(pInfo->mpRects); 400 pInfo->mcRects = cRects; 401 pInfo->mpRects = pRects; 404 402 mChanged = true; 405 403 } … … 415 413 { 416 414 LogRelFlowFunc(("\n")); 417 VBoxGuestWindowList::iterator iter; 418 419 iter = mGuestWindows.find(hWin); 420 if (mGuestWindows.end() != iter) 421 { 422 mGuestWindows.removeWindow(iter); 423 mChanged = true; 424 } 425 LogRelFlowFunc(("returning\n")); 415 VBoxGuestWinFree(mGuestWindows.removeWindow(hWin), NULL); 416 LogRelFlowFunc(("returning\n")); 417 } 418 419 DECLCALLBACK(int) getRectsCallback(VBoxGuestWinInfo *pInfo, 420 std::vector<RTRECT> *pRects) 421 { 422 if (pInfo->mhasShape) 423 { 424 for (int i = 0; i < pInfo->mcRects; ++i) 425 { 426 RTRECT rect; 427 rect.xLeft = pInfo->mX 428 + pInfo->mpRects[i].x; 429 rect.yBottom = pInfo->mY 430 + pInfo->mpRects[i].y 431 + pInfo->mpRects[i].height; 432 rect.xRight = pInfo->mX 433 + pInfo->mpRects[i].x 434 + pInfo->mpRects[i].width; 435 rect.yTop = pInfo->mY 436 + pInfo->mpRects[i].y; 437 pRects->push_back(rect); 438 } 439 } 440 else 441 { 442 RTRECT rect; 443 rect.xLeft = pInfo->mX; 444 rect.yBottom = pInfo->mY 445 + pInfo->mHeight; 446 rect.xRight = pInfo->mX 447 + pInfo->mWidth; 448 rect.yTop = pInfo->mY; 449 pRects->push_back(rect); 450 } 451 return VINF_SUCCESS; 426 452 } 427 453 … … 437 463 if (0 != mcRects) 438 464 { 439 apRects.get()->reserve(mcRects * 2); 440 } 441 for (VBoxGuestWindowList::iterator it = mGuestWindows.begin(); 442 it != mGuestWindows.end(); ++it) 443 { 444 if (it->second->mhasShape) 445 { 446 for (int i = 0; i < it->second->mcRects; ++i) 447 { 448 RTRECT rect; 449 rect.xLeft = it->second->mX 450 + it->second->mpRects[i].x; 451 rect.yBottom = it->second->mY 452 + it->second->mpRects[i].y 453 + it->second->mpRects[i].height; 454 rect.xRight = it->second->mX 455 + it->second->mpRects[i].x 456 + it->second->mpRects[i].width; 457 rect.yTop = it->second->mY 458 + it->second->mpRects[i].y; 459 apRects.get()->push_back(rect); 460 } 461 cRects += it->second->mcRects; 462 } 463 else 464 { 465 RTRECT rect; 466 rect.xLeft = it->second->mX; 467 rect.yBottom = it->second->mY 468 + it->second->mHeight; 469 rect.xRight = it->second->mX 470 + it->second->mWidth; 471 rect.yTop = it->second->mY; 472 apRects.get()->push_back(rect); 473 ++cRects; 474 } 475 } 476 mcRects = cRects; 465 apRects.get()->reserve(mcRects * 2); 466 } 467 mGuestWindows.doWithAll((PVBOXGUESTWINCALLBACK)getRectsCallback, 468 apRects.get()); 469 mcRects = apRects->size(); 477 470 LogRelFlowFunc(("returning\n")); 478 471 return apRects; -
trunk/src/VBox/Additions/x11/VBoxClient/seamless-x11.h
r36662 r36685 21 21 22 22 #include <VBox/log.h> 23 #include <iprt/avl.h> 23 24 24 25 #include "seamless-guest.h" … … 28 29 #include <X11/extensions/shape.h> 29 30 30 #include <map>31 31 #include <vector> 32 32 … … 41 41 struct VBoxGuestWinInfo { 42 42 public: 43 /** Header structure for insertion into an AVL tree */ 44 AVLU32NODECORE Core; 43 45 /** Is the window currently mapped? */ 44 46 bool mhasShape; … … 72 74 }; 73 75 76 /** Callback type used for "DoWithAll" calls */ 77 typedef DECLCALLBACK(int) VBOXGUESTWINCALLBACK(VBoxGuestWinInfo *, void *); 78 /** Pointer to VBOXGUESTWINCALLBACK */ 79 typedef VBOXGUESTWINCALLBACK *PVBOXGUESTWINCALLBACK; 80 81 DECLCALLBACK(int) inline VBoxGuestWinCleanup(VBoxGuestWinInfo *pInfo, void *) 82 { 83 delete pInfo; 84 return VINF_SUCCESS; 85 } 86 74 87 /** 75 * This class is just a wrapper around a map of structures containing information about76 * the windows on the guest system. It has a function for adding a structure (see addWindow),77 * for removing it by window handle (see removeWindow) and an iterator for78 * going through the list.88 * This class is just a wrapper around a map of structures containing 89 * information about the windows on the guest system. It has a function for 90 * adding a structure (see addWindow) and one for removing it by window 91 * handle (see removeWindow). 79 92 */ 80 93 class VBoxGuestWindowList … … 86 99 87 100 // Private class members 88 std::map<Window, VBoxGuestWinInfo *>mWindows;101 AVLU32TREE mWindows; 89 102 90 103 public: 91 // Just proxy iterators to map::iterator92 typedef std::map<Window, VBoxGuestWinInfo *>::const_iterator const_iterator;93 typedef std::map<Window, VBoxGuestWinInfo *>::iterator iterator;94 95 104 // Constructor 96 VBoxGuestWindowList(void) {}105 VBoxGuestWindowList(void) : mWindows(NULL) {} 97 106 // Destructor 98 107 ~VBoxGuestWindowList() 99 108 { 100 /* We use post-increment in the operation to prevent the iterator from being invalidated. */ 101 try 102 { 103 for (iterator it = begin(); it != end(); removeWindow(it++)) 104 ; 105 } 106 catch(...) {} 109 /** @todo having this inside the container class hard codes that the 110 * elements have to be allocated with the "new" operator, and 111 * I don't see a need to require this. */ 112 doWithAll(VBoxGuestWinCleanup, NULL); 107 113 } 108 114 109 115 // Standard operations 110 const_iterator begin() const { return mWindows.begin(); } 111 iterator begin() { return mWindows.begin(); } 112 const_iterator end() const { return mWindows.end(); } 113 iterator end() { return mWindows.end(); } 114 const_iterator find(Window win) const { return mWindows.find(win); } 115 iterator find(Window win) { return mWindows.find(win); } 116 117 void addWindow(Window hWin, bool isMapped, int x, int y, int w, int h, int cRects, 116 VBoxGuestWinInfo *find(Window hWin) 117 { 118 return (VBoxGuestWinInfo *)RTAvlU32Get(&mWindows, hWin); 119 } 120 121 void detachAll(PVBOXGUESTWINCALLBACK pCallback, void *pvParam) 122 { 123 RTAvlU32Destroy(&mWindows, (PAVLU32CALLBACK)pCallback, pvParam); 124 } 125 126 int doWithAll(PVBOXGUESTWINCALLBACK pCallback, void *pvParam) 127 { 128 return RTAvlU32DoWithAll(&mWindows, 1, (PAVLU32CALLBACK)pCallback, 129 pvParam); 130 } 131 132 bool addWindow(Window hWin, bool isMapped, int x, int y, int w, int h, int cRects, 118 133 XRectangle *pRects) 119 134 { … … 121 136 VBoxGuestWinInfo *pInfo = new VBoxGuestWinInfo(isMapped, x, y, w, h, cRects, 122 137 pRects); 123 mWindows.insert(std::pair<Window, VBoxGuestWinInfo *>(hWin, pInfo));138 pInfo->Core.Key = hWin; 124 139 LogRelFlowFunc(("returning\n")); 125 } 126 127 void removeWindow(iterator it) 140 return RTAvlU32Insert(&mWindows, &pInfo->Core); 141 } 142 143 VBoxGuestWinInfo *removeWindow(Window hWin) 128 144 { 129 145 LogRelFlowFunc(("called\n")); 130 delete it->second; 131 mWindows.erase(it); 132 } 133 134 void removeWindow(Window hWin) 135 { 136 LogRelFlowFunc(("called\n")); 137 removeWindow(find(hWin)); 146 return (VBoxGuestWinInfo *)RTAvlU32Remove(&mWindows, hWin); 138 147 } 139 148 };
Note:
See TracChangeset
for help on using the changeset viewer.