Changeset 21912 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Jul 31, 2009 11:33:06 AM (15 years ago)
- Location:
- trunk/src/VBox/Additions
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp
r21211 r21912 28 28 29 29 #include "VBGLR3Internal.h" 30 31 32 /** 33 * Wait for the host to signal one or several of a set of events and return the 34 * events signalled. The events will only be delivered by the host if they 35 * have been enabled previously using @a VbglR3CtlFilterMask. If one or 36 * several of the events have already been signalled but not yet waited for, 37 * this function will return immediately and return those events. 38 * 39 * @returns iprt status code 40 * @param fMask the events we want to wait for, or-ed together 41 * @param u32Timeout how long to wait before giving up and returning. Use 42 * RT_INDEFINITE_WAIT to wait until we are interrupted or 43 * one of the events is signalled. 44 * @param pfEvents where to store the events signalled 45 */ 46 VBGLR3DECL(int) VbglR3WaitEvent(uint32_t fMask, uint32_t u32Timeout, 47 uint32_t *pfEvents) 48 { 49 LogFlowFunc(("fMask=0x%x, u32Timeout=%u, pfEvents=%p\n", fMask, u32Timeout, 50 pfEvents)); 51 AssertReturn((fMask & ~VMMDEV_EVENT_VALID_EVENT_MASK) == 0, 52 VERR_INVALID_PARAMETER); 53 /* Does pfEvents == NULL make sense? */ 54 AssertReturn(VALID_PTR(pfEvents) || pfEvents == NULL, 55 VERR_INVALID_POINTER); 56 57 VBoxGuestWaitEventInfo waitEvent; 58 int rc; 59 60 waitEvent.u32TimeoutIn = u32Timeout; 61 waitEvent.u32EventMaskIn = fMask; 62 waitEvent.u32Result = VBOXGUEST_WAITEVENT_ERROR; 63 waitEvent.u32EventFlagsOut = 0; 64 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent)); 65 if (RT_SUCCESS(rc) && (pfEvents) != NULL) 66 *pfEvents = waitEvent.u32EventFlagsOut; 67 LogFlowFunc(("rc=%Rrc, waitEvent.u32EventFlagsOut=0x%x\n", rc, 68 waitEvent.u32EventFlagsOut)); 69 return rc; 70 } 30 71 31 72 -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibVideo.cpp
r21211 r21912 120 120 121 121 /** 122 * Query the last display change request .122 * Query the last display change request sent from the host to the guest. 123 123 * 124 124 * @returns iprt status value 125 * @param pcx Where to store the horizontal pixel resolution (0 = do not change). 126 * @param pcy Where to store the vertical pixel resolution (0 = do not change). 127 * @param pcBits Where to store the bits per pixel (0 = do not change). 128 * @param iDisplay Where to store the display number the request was for - 0 for the 129 * primary display, 1 for the first secondary, etc. 130 */ 131 VBGLR3DECL(int) VbglR3GetLastDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits, uint32_t *piDisplay) 125 * @param pcx Where to store the horizontal pixel resolution 126 * requested (a value of zero means do not change). 127 * @param pcy Where to store the vertical pixel resolution 128 * requested (a value of zero means do not change). 129 * @param pcBits Where to store the bits per pixel requested (a value 130 * of zero means do not change). 131 * @param iDisplay Where to store the display number the request was for 132 * - 0 for the primary display, 1 for the first 133 * secondary display, etc. 134 * @param fAck whether or not to acknowlege the newest request sent by 135 * the host. If this is set, the function will return the 136 * most recent host request, otherwise it will return the 137 * last request to be acknowleged. 138 * 139 */ 140 VBGLR3DECL(int) VbglR3GetDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits, uint32_t *piDisplay, bool fAck) 132 141 { 133 142 VMMDevDisplayChangeRequest2 Req = { { 0 } }; … … 139 148 AssertPtrReturn(piDisplay, VERR_INVALID_PARAMETER); 140 149 #endif 141 vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequest2); 150 vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequest2); 151 if (fAck) 152 Req.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST; 142 153 int rc = vbglR3GRPerform(&Req.header); 143 154 if (RT_SUCCESS(rc)) … … 153 164 } 154 165 155 /**156 * Wait for a display change request event from the host. These events must have been157 * activated previously using VbglR3CtlFilterMask.158 *159 * @returns IPRT status value160 * @param pcx On success, where to return the requested display width.161 * 0 means no change.162 * @param pcy On success, where to return the requested display height.163 * 0 means no change.164 * @param pcBits On success, where to return the requested bits per pixel.165 * 0 means no change.166 * @param piDisplay On success, where to return the index of the display to be changed.167 */168 VBGLR3DECL(int) VbglR3DisplayChangeWaitEvent(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits, uint32_t *piDisplay)169 {170 VBoxGuestWaitEventInfo waitEvent;171 int rc;172 173 #ifndef VBOX_VBGLR3_XFREE86174 AssertPtrReturn(pcx, VERR_INVALID_PARAMETER);175 AssertPtrReturn(pcy, VERR_INVALID_PARAMETER);176 AssertPtrReturn(pcBits, VERR_INVALID_PARAMETER);177 AssertPtrReturn(piDisplay, VERR_INVALID_PARAMETER);178 #endif179 waitEvent.u32TimeoutIn = RT_INDEFINITE_WAIT;180 waitEvent.u32EventMaskIn = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;181 waitEvent.u32Result = VBOXGUEST_WAITEVENT_ERROR;182 waitEvent.u32EventFlagsOut = 0;183 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent));184 if (RT_SUCCESS(rc))185 {186 /* did we get the right event? */187 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST)188 {189 VMMDevDisplayChangeRequest2 Req = { { 0 } };190 vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequest2);191 Req.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;192 int rc = vbglR3GRPerform(&Req.header);193 if (RT_SUCCESS(rc))194 rc = Req.header.rc;195 if (RT_SUCCESS(rc))196 {197 *pcx = Req.xres;198 *pcy = Req.yres;199 *pcBits = Req.bpp;200 *piDisplay = Req.display;201 }202 }203 else204 rc = VERR_TRY_AGAIN;205 }206 return rc;207 }208 166 209 167 /** -
trunk/src/VBox/Additions/x11/VBoxClient/autoresize.cpp
r21227 r21912 56 56 } 57 57 if (RT_SUCCESS(rc)) 58 rc = VbglR3CtlFilterMask(VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, 0); 58 rc = VbglR3CtlFilterMask( VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST 59 | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED, 0); 59 60 LogFlowFunc(("returning %Rrc\n", rc)); 60 61 return rc; … … 64 65 { 65 66 LogFlowFunc(("\n")); 66 VbglR3CtlFilterMask(0, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST); 67 VbglR3CtlFilterMask(0, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST 68 | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED); 67 69 LogFlowFunc(("returning\n")); 68 70 } … … 93 95 if (RT_FAILURE(rc)) 94 96 return rc; 95 VbglR3Get LastDisplayChangeRequest(&cx0, &cy0, &cBits0, &iDisplay0);97 VbglR3GetDisplayChangeRequest(&cx0, &cy0, &cBits0, &iDisplay0, false); 96 98 while (true) 97 99 { 98 uint32_t cx = 0, cy = 0, cBits = 0, iDisplay = 0;99 rc = VbglR3 DisplayChangeWaitEvent(&cx, &cy, &cBits, &iDisplay);100 /* Ignore the request if it is stale */101 if ( (cx != cx0) || (cy != cy0) || RT_FAILURE(rc))100 uint32_t fEvents = 0, cx = 0, cy = 0, cBits = 0, iDisplay = 0; 101 rc = VbglR3WaitEvent(VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, 102 RT_INDEFINITE_WAIT, &fEvents); 103 if (RT_SUCCESS(rc) && (fEvents & VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST)) 102 104 { 103 /* If we are not stopping, sleep for a bit to avoid using up too 104 much CPU while retrying. */ 105 if (RT_FAILURE(rc)) 106 RTThreadYield(); 107 else 108 system("VBoxRandR"); 105 rc = VbglR3GetDisplayChangeRequest(&cx, &cy, &cBits, &iDisplay, 106 true); 107 /* Ignore the request if it is stale */ 108 if ((cx != cx0) || (cy != cy0) || RT_FAILURE(rc)) 109 { 110 /* If we are not stopping, sleep for a bit to avoid using up 111 too much CPU while retrying. */ 112 if (RT_FAILURE(rc)) 113 RTThreadYield(); 114 else 115 { 116 system("VBoxRandR"); 117 cx0 = cx; 118 cy0 = cy; 119 } 120 } 109 121 } 110 /* We do not want to ignore any further requests. */111 cx0 = 0;112 cy0 = 0;113 122 } 114 123 LogFlowFunc(("returning VINF_SUCCESS\n")); -
trunk/src/VBox/Additions/x11/vboxvideo/vboxutils.c
r21867 r21912 998 998 if (!pVBox->useDevice) 999 999 return FALSE; 1000 int rc = VbglR3Get LastDisplayChangeRequest(pcx, pcy, pcBits, piDisplay);1000 int rc = VbglR3GetDisplayChangeRequest(pcx, pcy, pcBits, piDisplay, false); 1001 1001 if (RT_SUCCESS(rc)) 1002 1002 return TRUE;
Note:
See TracChangeset
for help on using the changeset viewer.