Changeset 18793 in vbox for trunk/src/VBox
- Timestamp:
- Apr 6, 2009 8:04:49 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r18788 r18793 187 187 static BOOL gfGuestScrollLockPressed = FALSE; 188 188 static BOOL gfACPITerm = FALSE; 189 static BOOL gfXCursorEnabled = TRUE; 189 190 static int gcGuestNumLockAdaptions = 2; 190 191 static int gcGuestCapsLockAdaptions = 2; … … 2143 2144 if (!SDL_GetWMInfo(&gSdlInfo)) 2144 2145 { 2145 RTPrintf("Error: could not get SDL Window Manager info !\n");2146 g oto leave;2146 RTPrintf("Error: could not get SDL Window Manager info -- no Xcursor support!\n"); 2147 gfXCursorEnabled = FALSE; 2147 2148 } 2148 2149 … … 2150 2151 /* SDL uses its own (plain) default cursor. Use the left arrow cursor instead which might look 2151 2152 * much better if a mouse cursor theme is installed. */ 2152 gpDefaultOrigX11Cursor = *(Cursor*)gpDefaultCursor->wm_cursor; 2153 *(Cursor*)gpDefaultCursor->wm_cursor = XCreateFontCursor(gSdlInfo.info.x11.display, XC_left_ptr); 2154 SDL_SetCursor(gpDefaultCursor); 2153 if (gfXCursorEnabled) 2154 { 2155 gpDefaultOrigX11Cursor = *(Cursor*)gpDefaultCursor->wm_cursor; 2156 *(Cursor*)gpDefaultCursor->wm_cursor = XCreateFontCursor(gSdlInfo.info.x11.display, XC_left_ptr); 2157 SDL_SetCursor(gpDefaultCursor); 2158 } 2155 2159 # endif 2156 2160 #endif /* VBOXSDL_WITH_X11 */ … … 2847 2851 SDL_SetCursor(gpDefaultCursor); 2848 2852 #if defined(VBOXSDL_WITH_X11) && !defined(VBOX_WITHOUT_XCURSOR) 2849 XFreeCursor(gSdlInfo.info.x11.display, pDefaultTempX11Cursor); 2850 #endif /* VBOXSDL_WITH_X11 */ 2853 if (gfXCursorEnabled) 2854 XFreeCursor(gSdlInfo.info.x11.display, pDefaultTempX11Cursor); 2855 #endif /* VBOXSDL_WITH_X11 && !VBOX_WITHOUT_XCURSOR */ 2851 2856 } 2852 2857 … … 2861 2866 ::DestroyCursor(*(HCURSOR *) pCustomTempWMCursor); 2862 2867 #elif defined (VBOXSDL_WITH_X11) && !defined (VBOX_WITHOUT_XCURSOR) 2863 XFreeCursor(gSdlInfo.info.x11.display, *(Cursor *) pCustomTempWMCursor); 2864 #endif 2868 if (gfXCursorEnabled) 2869 XFreeCursor(gSdlInfo.info.x11.display, *(Cursor *) pCustomTempWMCursor); 2870 #endif /* VBOXSDL_WITH_X11 && !VBOX_WITHOUT_XCURSOR */ 2865 2871 free(pCustomTempWMCursor); 2866 2872 } … … 4458 4464 #elif defined (VBOXSDL_WITH_X11) && !defined (VBOX_WITHOUT_XCURSOR) 4459 4465 4460 XcursorImage *img = XcursorImageCreate (data->width, data->height); 4461 Assert (img); 4462 if (img) 4463 { 4464 img->xhot = data->xHot; 4465 img->yhot = data->yHot; 4466 4467 XcursorPixel *dstShapePtr = img->pixels; 4468 4469 for (uint32_t y = 0; y < data->height; y ++) 4470 { 4471 memcpy (dstShapePtr, srcShapePtr, srcShapePtrScan); 4472 4473 if (!data->alpha) 4466 if (gfXCursorEnabled) 4467 { 4468 XcursorImage *img = XcursorImageCreate (data->width, data->height); 4469 Assert (img); 4470 if (img) 4471 { 4472 img->xhot = data->xHot; 4473 img->yhot = data->yHot; 4474 4475 XcursorPixel *dstShapePtr = img->pixels; 4476 4477 for (uint32_t y = 0; y < data->height; y ++) 4474 4478 { 4475 // convert AND mask to the alpha channel4476 uint8_t byte = 0; 4477 for (uint32_t x = 0; x < data->width; x ++)4479 memcpy (dstShapePtr, srcShapePtr, srcShapePtrScan); 4480 4481 if (!data->alpha) 4478 4482 { 4479 if (!(x % 8)) 4480 byte = *(srcAndMaskPtr ++); 4481 else 4482 byte <<= 1; 4483 4484 if (byte & 0x80) 4483 // convert AND mask to the alpha channel 4484 uint8_t byte = 0; 4485 for (uint32_t x = 0; x < data->width; x ++) 4485 4486 { 4486 // Linux doesn't support inverted pixels (XOR ops, 4487 // to be exact) in cursor shapes, so we detect such 4488 // pixels and always replace them with black ones to 4489 // make them visible at least over light colors 4490 if (dstShapePtr [x] & 0x00FFFFFF) 4491 dstShapePtr [x] = 0xFF000000; 4487 if (!(x % 8)) 4488 byte = *(srcAndMaskPtr ++); 4492 4489 else 4493 dstShapePtr [x] = 0x00000000; 4490 byte <<= 1; 4491 4492 if (byte & 0x80) 4493 { 4494 // Linux doesn't support inverted pixels (XOR ops, 4495 // to be exact) in cursor shapes, so we detect such 4496 // pixels and always replace them with black ones to 4497 // make them visible at least over light colors 4498 if (dstShapePtr [x] & 0x00FFFFFF) 4499 dstShapePtr [x] = 0xFF000000; 4500 else 4501 dstShapePtr [x] = 0x00000000; 4502 } 4503 else 4504 dstShapePtr [x] |= 0xFF000000; 4494 4505 } 4495 else4496 dstShapePtr [x] |= 0xFF000000;4497 4506 } 4507 4508 srcShapePtr += srcShapePtrScan; 4509 dstShapePtr += data->width; 4498 4510 } 4499 4511 4500 srcShapePtr += srcShapePtrScan; 4501 dstShapePtr += data->width; 4502 } 4503 4504 Cursor cur = XcursorImageLoadCursor (gSdlInfo.info.x11.display, img); 4505 Assert (cur); 4506 if (cur) 4507 { 4508 // here we do a dirty trick by substituting a Window Manager's 4509 // cursor handle with the handle we created 4510 4511 WMcursor *pCustomTempWMCursor = gpCustomCursor->wm_cursor; 4512 4513 // see SDL12/src/video/x11/SDL_x11mouse.c 4514 void *wm_cursor = malloc (sizeof (Cursor)); 4515 *(Cursor *) wm_cursor = cur; 4516 4517 gpCustomCursor->wm_cursor = (WMcursor *) wm_cursor; 4518 SDL_SetCursor (gpCustomCursor); 4519 SDL_ShowCursor (SDL_ENABLE); 4520 4521 if (pCustomTempWMCursor) 4512 Cursor cur = XcursorImageLoadCursor (gSdlInfo.info.x11.display, img); 4513 Assert (cur); 4514 if (cur) 4522 4515 { 4523 XFreeCursor (gSdlInfo.info.x11.display, *(Cursor *) pCustomTempWMCursor); 4524 free (pCustomTempWMCursor); 4516 // here we do a dirty trick by substituting a Window Manager's 4517 // cursor handle with the handle we created 4518 4519 WMcursor *pCustomTempWMCursor = gpCustomCursor->wm_cursor; 4520 4521 // see SDL12/src/video/x11/SDL_x11mouse.c 4522 void *wm_cursor = malloc (sizeof (Cursor)); 4523 *(Cursor *) wm_cursor = cur; 4524 4525 gpCustomCursor->wm_cursor = (WMcursor *) wm_cursor; 4526 SDL_SetCursor (gpCustomCursor); 4527 SDL_ShowCursor (SDL_ENABLE); 4528 4529 if (pCustomTempWMCursor) 4530 { 4531 XFreeCursor (gSdlInfo.info.x11.display, *(Cursor *) pCustomTempWMCursor); 4532 free (pCustomTempWMCursor); 4533 } 4534 4535 ok = true; 4525 4536 } 4526 4527 ok = true; 4528 } 4529 4537 } 4530 4538 XcursorImageDestroy (img); 4531 4539 } 4532 4540 4533 #endif 4541 #endif /* VBOXSDL_WITH_X11 && !VBOX_WITHOUT_XCURSOR */ 4534 4542 4535 4543 if (!ok)
Note:
See TracChangeset
for help on using the changeset viewer.