VirtualBox

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

Last change on this file since 27433 was 27318, checked in by vboxsync, 15 years ago

VBoxGuestR3LibSeamless.cpp: Initialize (poison) the output members of the request structure. Doxygen @retval is for explaining @returns.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/* $Id: VBoxGuestR3LibSeamless.cpp 27318 2010-03-12 10:27:04Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Seamless mode.
4 */
5
6/*
7 * Copyright (C) 2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31
32/*******************************************************************************
33* Header Files *
34*******************************************************************************/
35#include <iprt/assert.h>
36#include <iprt/string.h>
37
38#include <VBox/VMMDev.h>
39#include <VBox/log.h>
40
41#include "VBGLR3Internal.h"
42
43
44/**
45 * Tell the host that we support (or no longer support) seamless mode.
46 *
47 * @returns IPRT status value
48 * @param fState whether or not we support seamless mode
49 */
50VBGLR3DECL(int) VbglR3SeamlessSetCap(bool fState)
51{
52 if (fState)
53 return VbglR3SetGuestCaps(VMMDEV_GUEST_SUPPORTS_SEAMLESS, 0);
54 return VbglR3SetGuestCaps(0, VMMDEV_GUEST_SUPPORTS_SEAMLESS);
55}
56
57/**
58 * Wait for a seamless mode change event.
59 *
60 * @returns IPRT status value.
61 * @param[out] pMode On success, the seamless mode to switch into (i.e.
62 * disabled, visible region or host window).
63 */
64VBGLR3DECL(int) VbglR3SeamlessWaitEvent(VMMDevSeamlessMode *pMode)
65{
66 VBoxGuestWaitEventInfo waitEvent;
67 int rc;
68
69#if !defined(VBOX_VBGLR3_XFREE86)
70 AssertPtrReturn(pMode, VERR_INVALID_PARAMETER);
71#endif
72 waitEvent.u32TimeoutIn = RT_INDEFINITE_WAIT;
73 waitEvent.u32EventMaskIn = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
74 waitEvent.u32Result = VBOXGUEST_WAITEVENT_ERROR;
75 waitEvent.u32EventFlagsOut = 0;
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.mode = (VMMDevSeamlessMode)-1;
87 seamlessChangeRequest.eventAck = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
88 rc = vbglR3GRPerform(&seamlessChangeRequest.header);
89 if (RT_SUCCESS(rc))
90 {
91 *pMode = seamlessChangeRequest.mode;
92 return VINF_SUCCESS;
93 }
94 }
95 else
96 rc = VERR_TRY_AGAIN;
97 }
98 return rc;
99}
100
101/**
102 * Request the last seamless mode switch from the host again.
103 *
104 * @returns IPRT status value.
105 * @param[out] pMode On success, the seamless mode that was switched
106 * into (i.e. disabled, visible region or host window).
107 */
108VBGLR3DECL(int) VbglR3SeamlessGetLastEvent(VMMDevSeamlessMode *pMode)
109{
110 VMMDevSeamlessChangeRequest seamlessChangeRequest;
111 int rc;
112
113#if !defined(VBOX_VBGLR3_XFREE86)
114 AssertPtrReturn(pMode, VERR_INVALID_PARAMETER);
115#endif
116
117 /* get the seamless change request */
118 vmmdevInitRequest(&seamlessChangeRequest.header, VMMDevReq_GetSeamlessChangeRequest);
119 seamlessChangeRequest.mode = (VMMDevSeamlessMode)-1;
120 seamlessChangeRequest.eventAck = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
121 rc = vbglR3GRPerform(&seamlessChangeRequest.header);
122 if (RT_SUCCESS(rc))
123 {
124 *pMode = seamlessChangeRequest.mode;
125 return VINF_SUCCESS;
126 }
127 return rc;
128}
129
130/**
131 * Inform the host about the visible region
132 *
133 * @returns IPRT status code
134 * @param cRects number of rectangles in the list of visible rectangles
135 * @param pRects list of visible rectangles on the guest display
136 *
137 * @todo A scatter-gather version of vbglR3GRPerform would be nice, so that we don't have
138 * to copy our rectangle and header data into a single structure and perform an
139 * additional allocation.
140 */
141VBGLR3DECL(int) VbglR3SeamlessSendRects(uint32_t cRects, PRTRECT pRects)
142{
143 VMMDevVideoSetVisibleRegion *pReq;
144 int rc;
145
146 if (!cRects || !pRects)
147 return VINF_SUCCESS;
148 rc = vbglR3GRAlloc((VMMDevRequestHeader **)&pReq,
149 sizeof(VMMDevVideoSetVisibleRegion) + (cRects - 1) * sizeof(RTRECT),
150 VMMDevReq_VideoSetVisibleRegion);
151 if (RT_SUCCESS(rc))
152 {
153 pReq->cRect = cRects;
154 memcpy(&pReq->Rect, pRects, cRects * sizeof(RTRECT));
155 rc = vbglR3GRPerform(&pReq->header);
156 if (RT_SUCCESS(rc))
157 rc = pReq->header.rc;
158 vbglR3GRFree(&pReq->header);
159 }
160 return rc;
161}
162
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