VirtualBox

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

Last change on this file since 29543 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1/* $Id: VBoxGuestR3LibSeamless.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Seamless mode.
4 */
5
6/*
7 * Copyright (C) 2007 Oracle Corporation
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
27
28/*******************************************************************************
29* Header Files *
30*******************************************************************************/
31#include <iprt/assert.h>
32#include <iprt/string.h>
33
34#include <VBox/VMMDev.h>
35#include <VBox/log.h>
36
37#include "VBGLR3Internal.h"
38
39
40/**
41 * Tell the host that we support (or no longer support) seamless mode.
42 *
43 * @returns IPRT status value
44 * @param fState whether or not we support seamless mode
45 */
46VBGLR3DECL(int) VbglR3SeamlessSetCap(bool fState)
47{
48 if (fState)
49 return VbglR3SetGuestCaps(VMMDEV_GUEST_SUPPORTS_SEAMLESS, 0);
50 return VbglR3SetGuestCaps(0, VMMDEV_GUEST_SUPPORTS_SEAMLESS);
51}
52
53/**
54 * Wait for a seamless mode change event.
55 *
56 * @returns IPRT status value.
57 * @param[out] pMode On success, the seamless mode to switch into (i.e.
58 * disabled, visible region or host window).
59 */
60VBGLR3DECL(int) VbglR3SeamlessWaitEvent(VMMDevSeamlessMode *pMode)
61{
62 VBoxGuestWaitEventInfo waitEvent;
63 int rc;
64
65 AssertPtrReturn(pMode, VERR_INVALID_PARAMETER);
66 waitEvent.u32TimeoutIn = RT_INDEFINITE_WAIT;
67 waitEvent.u32EventMaskIn = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
68 waitEvent.u32Result = VBOXGUEST_WAITEVENT_ERROR;
69 waitEvent.u32EventFlagsOut = 0;
70 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent));
71 if (RT_SUCCESS(rc))
72 {
73 /* did we get the right event? */
74 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST)
75 {
76 VMMDevSeamlessChangeRequest seamlessChangeRequest;
77
78 /* get the seamless change request */
79 vmmdevInitRequest(&seamlessChangeRequest.header, VMMDevReq_GetSeamlessChangeRequest);
80 seamlessChangeRequest.mode = (VMMDevSeamlessMode)-1;
81 seamlessChangeRequest.eventAck = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
82 rc = vbglR3GRPerform(&seamlessChangeRequest.header);
83 if (RT_SUCCESS(rc))
84 {
85 *pMode = seamlessChangeRequest.mode;
86 return VINF_SUCCESS;
87 }
88 }
89 else
90 rc = VERR_TRY_AGAIN;
91 }
92 return rc;
93}
94
95/**
96 * Request the last seamless mode switch from the host again.
97 *
98 * @returns IPRT status value.
99 * @param[out] pMode On success, the seamless mode that was switched
100 * into (i.e. disabled, visible region or host window).
101 */
102VBGLR3DECL(int) VbglR3SeamlessGetLastEvent(VMMDevSeamlessMode *pMode)
103{
104 VMMDevSeamlessChangeRequest seamlessChangeRequest;
105 int rc;
106
107 AssertPtrReturn(pMode, VERR_INVALID_PARAMETER);
108
109 /* get the seamless change request */
110 vmmdevInitRequest(&seamlessChangeRequest.header, VMMDevReq_GetSeamlessChangeRequest);
111 seamlessChangeRequest.mode = (VMMDevSeamlessMode)-1;
112 seamlessChangeRequest.eventAck = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
113 rc = vbglR3GRPerform(&seamlessChangeRequest.header);
114 if (RT_SUCCESS(rc))
115 {
116 *pMode = seamlessChangeRequest.mode;
117 return VINF_SUCCESS;
118 }
119 return rc;
120}
121
122/**
123 * Inform the host about the visible region
124 *
125 * @returns IPRT status code
126 * @param cRects number of rectangles in the list of visible rectangles
127 * @param pRects list of visible rectangles on the guest display
128 *
129 * @todo A scatter-gather version of vbglR3GRPerform would be nice, so that we don't have
130 * to copy our rectangle and header data into a single structure and perform an
131 * additional allocation.
132 */
133VBGLR3DECL(int) VbglR3SeamlessSendRects(uint32_t cRects, PRTRECT pRects)
134{
135 VMMDevVideoSetVisibleRegion *pReq;
136 int rc;
137
138 if (!cRects || !pRects)
139 return VINF_SUCCESS;
140 rc = vbglR3GRAlloc((VMMDevRequestHeader **)&pReq,
141 sizeof(VMMDevVideoSetVisibleRegion) + (cRects - 1) * sizeof(RTRECT),
142 VMMDevReq_VideoSetVisibleRegion);
143 if (RT_SUCCESS(rc))
144 {
145 pReq->cRect = cRects;
146 memcpy(&pReq->Rect, pRects, cRects * sizeof(RTRECT));
147 rc = vbglR3GRPerform(&pReq->header);
148 if (RT_SUCCESS(rc))
149 rc = pReq->header.rc;
150 vbglR3GRFree(&pReq->header);
151 }
152 return rc;
153}
154
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