VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibSeamless.cpp@ 5872

Last change on this file since 5872 was 5872, checked in by vboxsync, 17 years ago

Guest Additions (common userspace library): missing return statement

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/** $Id: VBoxGuestR3LibSeamless.cpp 5872 2007-11-28 18:46:35Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Seamless mode.
4 */
5
6/*
7 * Copyright (C) 2007 innotek GmbH
8 *
9 * innotek GmbH confidential
10 * All rights reserved
11 */
12
13
14/*******************************************************************************
15* Header Files *
16*******************************************************************************/
17#include <iprt/assert.h>
18
19#include <VBox/VBoxGuest.h>
20#include <VBox/VBoxDev.h>
21#include <VBox/log.h>
22
23#include <string.h>
24
25/* Move this to a header { */
26
27extern int vbglR3DoIOCtl(unsigned iFunction, void *pvData, size_t cbData);
28
29/* } */
30
31/**
32 * Tell the host that we support (or no longer support) seamless mode.
33 *
34 * @returns IPRT status value
35 * @param bState whether or not we support seamless mode
36 *
37 * @todo Currently this will trample over any other capabilities the guest may have.
38 * This will have to be fixed when more capabilities are added at the latest.
39 */
40VBGLR3DECL(int) VbglR3SeamlessSetCap(bool bState)
41{
42 VMMDevReqGuestCapabilities vmmreqGuestCaps = { {0} };
43 int rc = VINF_SUCCESS;
44
45 vmmdevInitRequest(&vmmreqGuestCaps.header, VMMDevReq_ReportGuestCapabilities);
46 vmmreqGuestCaps.caps = bState ? VMMDEV_GUEST_SUPPORTS_SEAMLESS : 0;
47 rc = VbglR3GRPerform(&vmmreqGuestCaps.header);
48#ifdef DEBUG
49 if (RT_SUCCESS(rc))
50 {
51 LogRel(("Successfully enabled seamless mode on the host.\n"));
52 }
53 else
54 {
55 LogRel(("Failed to enabled seamless mode on the host, rc = %Vrc.\n", rc));
56 }
57#endif
58 return rc;
59}
60
61/**
62 * Wait for a seamless mode change event.
63 *
64 * @returns IPRT status value
65 * @retval pMode on success, the seamless mode to switch into (i.e. disabled, visible region
66 * or host window)
67 */
68VBGLR3DECL(int) VbglR3SeamlessWaitEvent(VMMDevSeamlessMode *pMode)
69{
70 VBoxGuestWaitEventInfo waitEvent;
71 int rc;
72
73 AssertReturn(pMode != 0, VERR_INVALID_PARAMETER);
74 waitEvent.u32TimeoutIn = 0;
75 waitEvent.u32EventMaskIn = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
76 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent));
77 if (RT_SUCCESS(rc))
78 {
79 /* did we get the right event? */
80 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST)
81 {
82 VMMDevSeamlessChangeRequest seamlessChangeRequest;
83
84 /* get the seamless change request */
85 vmmdevInitRequest(&seamlessChangeRequest.header, VMMDevReq_GetSeamlessChangeRequest);
86 seamlessChangeRequest.eventAck = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
87 rc = VbglR3GRPerform(&seamlessChangeRequest.header);
88 if (RT_SUCCESS(rc))
89 {
90 *pMode = seamlessChangeRequest.mode;
91 return VINF_SUCCESS;
92 }
93 }
94 else
95 rc = VERR_TRY_AGAIN;
96 }
97 return rc;
98}
99
100/**
101 * Inform the host about the visible region
102 *
103 * @returns IPRT status code
104 * @param cRects number of rectangles in the list of visible rectangles
105 * @param pRects list of visible rectangles on the guest display
106 *
107 * @todo A scatter-gather version of VbglR3GRPerform would be nice, so that we don't have
108 * to copy our rectangle and header data into a single structure and perform an
109 * additional allocation.
110 */
111VBGLR3DECL(int) VbglR3SeamlessSendRects(uint32_t cRects, PRTRECT pRects)
112{
113 VMMDevVideoSetVisibleRegion *req;
114 int rc;
115
116 rc = VbglR3GRAlloc ((VMMDevRequestHeader **)&req,
117 sizeof (VMMDevVideoSetVisibleRegion) + (cRects-1)*sizeof(RTRECT),
118 VMMDevReq_VideoSetVisibleRegion);
119 if (RT_SUCCESS(rc))
120 {
121 req->cRect = cRects;
122 memcpy(&req->Rect, pRects, cRects*sizeof(RTRECT));
123 rc = VbglR3GRPerform (&req->header);
124 VbglR3GRFree(&req->header);
125 if (RT_SUCCESS(rc))
126 {
127 if (RT_SUCCESS(req->header.rc))
128 {
129 return VINF_SUCCESS;
130 }
131 else
132 rc = req->header.rc;
133 }
134 }
135 return rc;
136}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette