Changeset 7106 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Feb 25, 2008 1:20:19 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 28353
- Location:
- trunk/src/VBox/Additions/x11/xclient
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/xclient/seamless-x11.cpp
r7080 r7106 30 30 #include <X11/Xatom.h> 31 31 #include <X11/Xmu/WinUtil.h> 32 33 /* This is defined wrong in my X11 header files! */ 34 #define VBoxShapeNotify 64 32 35 33 36 /***************************************************************************** … … 154 157 phChildren = phChildrenRaw; 155 158 for (unsigned i = 0; i < cChildren; ++i) 156 { 157 Window hClient = XmuClientWindow(mDisplay.get(), phChildren.get()[i]); 158 if (!isVirtualRoot(hClient)) 159 addClientWindow(phChildren.get()[i]); 159 addClientWindow(phChildren.get()[i]); 160 } 161 162 163 void VBoxGuestSeamlessX11::addClientWindow(const Window hWin) 164 { 165 XWindowAttributes winAttrib; 166 bool fAddWin = true; 167 char *pszWinName = NULL; 168 Window hClient = XmuClientWindow(mDisplay, hWin); 169 170 if (isVirtualRoot(hClient)) 171 fAddWin = false; 172 if (fAddWin && !XGetWindowAttributes(mDisplay, hWin, &winAttrib)) 173 { 174 LogRelFunc(("VBoxClient: Failed to get the window attributes for window %d\n", hWin)); 175 fAddWin = false; 176 } 177 if (fAddWin && (winAttrib.map_state == IsUnmapped)) 178 fAddWin = false; 179 if (fAddWin && (XFetchName(mDisplay, hClient, &pszWinName) != 0) && (pszWinName != NULL)) 180 XFree(pszWinName); 181 else 182 /* kwin sometimes creates temporary fullscreen windows with no name. */ 183 fAddWin = false; 184 if (fAddWin) 185 { 186 VBoxGuestX11Pointer<XRectangle> rects; 187 int cRects = 0, iOrdering; 188 bool hasShape = false; 189 190 if (mSupportsShape) 191 { 192 XShapeSelectInput(mDisplay, hWin, ShapeNotifyMask); 193 rects = XShapeGetRectangles(mDisplay, hWin, ShapeBounding, &cRects, &iOrdering); 194 if (0 == rects.get()) 195 cRects = 0; 196 else 197 { 198 if ( (cRects > 1) 199 || (rects.get()[0].x != 0) 200 || (rects.get()[0].y != 0) 201 || (rects.get()[0].width != winAttrib.width) 202 || (rects.get()[0].height != winAttrib.height) 203 ) 204 hasShape = true; 205 } 206 } 207 mGuestWindows.addWindow(hWin, hasShape, winAttrib.x, winAttrib.y, 208 winAttrib.width, winAttrib.height, cRects, rects); 160 209 } 161 210 } … … 183 232 184 233 185 void VBoxGuestSeamlessX11::addClientWindow(const Window hWin)186 {187 XWindowAttributes winAttrib;188 VBoxGuestX11Pointer<XRectangle> rects;189 int cRects = 0, iOrdering;190 191 if (!XGetWindowAttributes(mDisplay, hWin, &winAttrib))192 {193 LogRelFunc(("VBoxClient: Failed to get the window attributes for window %d\n", hWin));194 return;195 }196 if (mSupportsShape)197 {198 XShapeSelectInput(mDisplay, hWin, ShapeNotify);199 rects = XShapeGetRectangles(mDisplay, hWin, ShapeClip, &cRects, &iOrdering);200 if (0 == rects.get())201 {202 cRects = 0;203 }204 }205 mGuestWindows.addWindow(hWin, winAttrib.map_state != IsUnmapped, winAttrib.x, winAttrib.y,206 winAttrib.width, winAttrib.height, cRects, rects);207 }208 209 234 /** 210 235 * Free all information in the tree of visible windows … … 219 244 } 220 245 } 246 221 247 222 248 /** … … 241 267 doMapEvent(&event.xmap); 242 268 break; 243 case ShapeNotify:269 case VBoxShapeNotify: /* This is defined wrong in my X11 header files! */ 244 270 doShapeEvent(reinterpret_cast<XShapeEvent *>(&event)); 245 271 break; … … 264 290 if (iter != mGuestWindows.end()) 265 291 { 266 iter->second->mX = event->x; 267 iter->second->mY = event->y; 268 iter->second->mWidth = event->width; 269 iter->second->mHeight = event->height; 292 XWindowAttributes winAttrib; 293 294 if (XGetWindowAttributes(mDisplay, event->window, &winAttrib)) 295 { 296 iter->second->mX = winAttrib.x; 297 iter->second->mY = winAttrib.y; 298 iter->second->mWidth = winAttrib.width; 299 iter->second->mHeight = winAttrib.height; 300 } 270 301 } 271 302 } … … 287 318 } 288 319 320 289 321 /** 290 322 * Handle a window shape change event in the seamless event thread. … … 295 327 { 296 328 VBoxGuestWindowList::iterator iter; 297 VBoxGuestX11Pointer<XRectangle> rects;298 int cRects, iOrdering;299 329 300 330 iter = mGuestWindows.find(event->window); 301 331 if (iter != mGuestWindows.end()) 302 332 { 303 rects = XShapeGetRectangles(mDisplay, iter->first, ShapeClip, &cRects, &iOrdering); 304 if (0 == rects.get()) 305 { 306 cRects = 0; 307 } 333 VBoxGuestX11Pointer<XRectangle> rects; 334 int cRects = 0, iOrdering; 335 336 rects = XShapeGetRectangles(mDisplay, event->window, ShapeBounding, &cRects, &iOrdering); 337 iter->second->mhasShape = true; 338 iter->second->mcRects = cRects; 308 339 iter->second->mapRects = rects; 309 iter->second->mcRects = cRects;310 340 } 311 341 } … … 342 372 it != mGuestWindows.end(); ++it) 343 373 { 344 if (it->second->m Mapped)374 if (it->second->mhasShape) 345 375 { 346 if (it->second->mcRects > 0) 347 { 348 for (int i = 0; i < it->second->mcRects; ++i) 349 { 350 RTRECT rect; 351 rect.xLeft = it->second->mX 352 + it->second->mapRects.get()[i].x; 353 rect.yBottom = it->second->mY 354 + it->second->mapRects.get()[i].y 355 + it->second->mapRects.get()[i].height; 356 rect.xRight = it->second->mX 357 + it->second->mapRects.get()[i].x 358 + it->second->mapRects.get()[i].width; 359 rect.yTop = it->second->mY 360 + it->second->mapRects.get()[i].y; 361 apRects.get()->push_back(rect); 362 } 363 cRects += it->second->mcRects; 364 } 365 else 376 for (int i = 0; i < it->second->mcRects; ++i) 366 377 { 367 378 RTRECT rect; 368 rect.xLeft = it->second->mX; 369 rect.yBottom = it->second->mY 370 + it->second->mHeight; 371 rect.xRight = it->second->mX 372 + it->second->mWidth; 373 rect.yTop = it->second->mY; 379 rect.xLeft = it->second->mX 380 + it->second->mapRects.get()[i].x; 381 rect.yBottom = it->second->mY 382 + it->second->mapRects.get()[i].y 383 + it->second->mapRects.get()[i].height; 384 rect.xRight = it->second->mX 385 + it->second->mapRects.get()[i].x 386 + it->second->mapRects.get()[i].width; 387 rect.yTop = it->second->mY 388 + it->second->mapRects.get()[i].y; 374 389 apRects.get()->push_back(rect); 375 ++cRects;376 390 } 391 cRects += it->second->mcRects; 392 } 393 else 394 { 395 RTRECT rect; 396 rect.xLeft = it->second->mX; 397 rect.yBottom = it->second->mY 398 + it->second->mHeight; 399 rect.xRight = it->second->mX 400 + it->second->mWidth; 401 rect.yTop = it->second->mY; 402 apRects.get()->push_back(rect); 403 ++cRects; 377 404 } 378 405 } -
trunk/src/VBox/Additions/x11/xclient/seamless-x11.h
r7080 r7106 160 160 public: 161 161 /** Is the window currently mapped? */ 162 bool m Mapped;162 bool mhasShape; 163 163 /** Co-ordinates in the guest screen. */ 164 164 int mX, mY; … … 171 171 VBoxGuestX11Pointer<XRectangle> mapRects; 172 172 /** Constructor. */ 173 VBoxGuestWinInfo(bool isMapped, int x, int y, int w, int h, int cRects,173 VBoxGuestWinInfo(bool hasShape, int x, int y, int w, int h, int cRects, 174 174 VBoxGuestX11Pointer<XRectangle> rects) 175 175 : mapRects(rects) 176 176 { 177 m Mapped = isMapped, mX = x; mY = y; mWidth = w; mHeight = h; mcRects = cRects;177 mhasShape = hasShape, mX = x; mY = y; mWidth = w; mHeight = h; mcRects = cRects; 178 178 } 179 179
Note:
See TracChangeset
for help on using the changeset viewer.