Changeset 21923 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Jul 31, 2009 8:01:47 PM (15 years ago)
- Location:
- trunk/src/VBox/Additions/x11
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/display.cpp
r21922 r21923 28 28 29 29 #include <X11/Xlib.h> 30 #include <X11/cursorfont.h> 30 31 31 32 #include <iprt/assert.h> … … 42 43 int rc = VINF_SUCCESS; 43 44 int rcSystem, rcErrno; 45 uint32_t fMouseFeatures = 0; 44 46 45 47 LogFlowFunc(("\n")); … … 56 58 } 57 59 if (RT_SUCCESS(rc)) 58 rc = VbglR3CtlFilterMask( VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST 59 | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED, 0); 60 rc = VbglR3CtlFilterMask(VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, 0); 61 /* Enable support for switching between hardware and software cursors */ 62 rc = VbglR3CtlFilterMask(VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED, 0); 63 if (RT_SUCCESS(rc)) 64 { 65 rc = VbglR3GetMouseStatus(&fMouseFeatures, NULL, NULL); 66 if (RT_SUCCESS(rc)) 67 VbglR3SetMouseStatus( fMouseFeatures 68 & ~VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR); 69 } 60 70 LogFlowFunc(("returning %Rrc\n", rc)); 61 71 return rc; … … 64 74 void cleanupDisplay(void) 65 75 { 76 uint32_t fMouseFeatures = 0; 66 77 LogFlowFunc(("\n")); 67 78 VbglR3CtlFilterMask(0, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST 68 79 | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED); 80 int rc = VbglR3GetMouseStatus(&fMouseFeatures, NULL, NULL); 81 if (RT_SUCCESS(rc)) 82 VbglR3SetMouseStatus( fMouseFeatures 83 | VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR); 69 84 LogFlowFunc(("returning\n")); 70 85 } … … 91 106 LogFlowFunc(("\n")); 92 107 uint32_t cx0 = 0, cy0 = 0, cBits0 = 0, iDisplay0 = 0; 108 Display *pDisplay = XOpenDisplay(NULL); 109 if (pDisplay == NULL) 110 return VERR_NOT_FOUND; 111 Cursor hClockCursor = XCreateFontCursor(pDisplay, XC_watch); 112 Cursor hArrowCursor = XCreateFontCursor(pDisplay, XC_left_ptr); 93 113 int rc = RTThreadCreate(NULL, x11ConnectionMonitor, NULL, 0, 94 114 RTTHREADTYPE_INFREQUENT_POLLER, 0, "X11 monitor"); … … 99 119 { 100 120 uint32_t fEvents = 0, cx = 0, cy = 0, cBits = 0, iDisplay = 0; 101 rc = VbglR3WaitEvent(VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, 121 rc = VbglR3WaitEvent( VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST 122 | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED, 102 123 RT_INDEFINITE_WAIT, &fEvents); 103 124 if (RT_SUCCESS(rc) && (fEvents & VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST)) 104 125 { 105 rc = VbglR3GetDisplayChangeRequest(&cx, &cy, &cBits, &iDisplay,106 true);126 int rc2 = VbglR3GetDisplayChangeRequest(&cx, &cy, &cBits, 127 &iDisplay, true); 107 128 /* Ignore the request if it is stale */ 108 if ((cx != cx0) || (cy != cy0) || RT_FAILURE(rc ))129 if ((cx != cx0) || (cy != cy0) || RT_FAILURE(rc2)) 109 130 { 110 131 /* If we are not stopping, sleep for a bit to avoid using up 111 132 too much CPU while retrying. */ 112 if (RT_FAILURE(rc ))133 if (RT_FAILURE(rc2)) 113 134 RTThreadYield(); 114 135 else … … 119 140 } 120 141 } 142 } 143 if ( RT_SUCCESS(rc) 144 && (fEvents & VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED)) 145 { 146 XGrabPointer(pDisplay, 147 DefaultRootWindow(pDisplay), true, 0, GrabModeAsync, 148 GrabModeAsync, None, hClockCursor, CurrentTime); 149 XFlush(pDisplay); 150 XGrabPointer(pDisplay, 151 DefaultRootWindow(pDisplay), true, 0, GrabModeAsync, 152 GrabModeAsync, None, hArrowCursor, CurrentTime); 153 XFlush(pDisplay); 154 XUngrabPointer(pDisplay, CurrentTime); 155 XFlush(pDisplay); 121 156 } 122 157 } -
trunk/src/VBox/Additions/x11/vboxvideo/vboxutils.c
r21912 r21923 399 399 Bool rc = TRUE; 400 400 int vrc; 401 uint32_t fMouseFeatures = 0; 401 402 402 403 TRACE_ENTRY(); … … 411 412 } 412 413 pVBox->useDevice = rc; 414 /* We can't switch to a software cursor at will without help from 415 * VBoxClient. So tell that to the host and wait for VBoxClient to 416 * change this. */ 417 vrc = VbglR3GetMouseStatus(&fMouseFeatures, NULL, NULL); 418 if (RT_SUCCESS(vrc)) 419 VbglR3SetMouseStatus( fMouseFeatures 420 | VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR); 413 421 return rc; 414 422 } … … 531 539 } 532 540 533 /** 534 * This function is called to set the position of the hardware cursor. 535 * Since we already know the position (exactly where the host pointer is), 536 * we only use this function to poll for whether we need to switch from a 537 * hardware to a software cursor (that is, whether the user has disabled 538 * pointer integration). Sadly this doesn't work the other way round, 539 * as the server updates the software cursor itself without notifying us. 540 */ 541 541 542 static void 542 543 vbox_set_cursor_position(ScrnInfoPtr pScrn, int x, int y) 543 544 { 544 VBOXPtr pVBox = pScrn->driverPrivate; 545 546 if (pVBox->accessEnabled && !vbox_host_uses_hwcursor(pScrn)) 547 { 548 /* This triggers a cursor image reload, and before reloading, the X 549 * server will check whether we can "handle" the new cursor "in 550 * hardware". We can use this check to force a switch to a software 551 * cursor if we need to do so. */ 552 pScrn->EnableDisableFBAccess(pScrn->scrnIndex, FALSE); 553 pScrn->EnableDisableFBAccess(pScrn->scrnIndex, TRUE); 554 } 545 /* Nothing to do here, as we are telling the guest where the mouse is, 546 * not vice versa. */ 547 NOREF(pScrn); 548 NOREF(x); 549 NOREF(y); 555 550 } 556 551
Note:
See TracChangeset
for help on using the changeset viewer.