VirtualBox

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

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

The Big Sun Rebranding Header Change

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/** $Id: VBoxGuestR3LibSeamless.cpp 8155 2008-04-18 15:16:47Z 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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#include <iprt/assert.h>
27#include <iprt/string.h>
28
29#include <VBox/VBoxGuest.h>
30#include <VBox/VBoxDev.h>
31#include <VBox/log.h>
32
33#include "VBGLR3Internal.h"
34
35/**
36 * Tell the host that we support (or no longer support) seamless mode.
37 *
38 * @returns IPRT status value
39 * @param fState whether or not we support seamless mode
40 *
41 * @todo Currently this will trample over any other capabilities the guest may have.
42 * This will have to be fixed when more capabilities are added at the latest.
43 */
44VBGLR3DECL(int) VbglR3SeamlessSetCap(bool fState)
45{
46 VMMDevReqGuestCapabilities vmmreqGuestCaps;
47 int rc = VINF_SUCCESS;
48
49 memset(&vmmreqGuestCaps, 0, sizeof(vmmreqGuestCaps));
50 vmmdevInitRequest(&vmmreqGuestCaps.header, VMMDevReq_ReportGuestCapabilities);
51 vmmreqGuestCaps.caps = fState ? VMMDEV_GUEST_SUPPORTS_SEAMLESS : 0;
52 rc = vbglR3GRPerform(&vmmreqGuestCaps.header);
53#ifdef DEBUG
54 if (RT_SUCCESS(rc))
55 LogRel(("Successfully set the seamless capability on the host.\n"));
56 else
57 LogRel(("Failed to set the seamless capability on the host, rc = %Rrc.\n", rc));
58#endif
59 return rc;
60}
61
62/**
63 * Wait for a seamless mode change event.
64 *
65 * @returns IPRT status value
66 * @retval pMode on success, the seamless mode to switch into (i.e. disabled, visible region
67 * or host window)
68 */
69VBGLR3DECL(int) VbglR3SeamlessWaitEvent(VMMDevSeamlessMode *pMode)
70{
71 VBoxGuestWaitEventInfo waitEvent;
72 int rc;
73
74 AssertPtrReturn(pMode, VERR_INVALID_PARAMETER);
75 waitEvent.u32TimeoutIn = RT_INDEFINITE_WAIT;
76 waitEvent.u32EventMaskIn = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
77 waitEvent.u32Result = VBOXGUEST_WAITEVENT_ERROR;
78 waitEvent.u32EventFlagsOut = 0;
79 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent));
80 if (RT_SUCCESS(rc))
81 {
82 /* did we get the right event? */
83 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST)
84 {
85 VMMDevSeamlessChangeRequest seamlessChangeRequest;
86
87 /* get the seamless change request */
88 vmmdevInitRequest(&seamlessChangeRequest.header, VMMDevReq_GetSeamlessChangeRequest);
89 seamlessChangeRequest.eventAck = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
90 rc = vbglR3GRPerform(&seamlessChangeRequest.header);
91 if (RT_SUCCESS(rc))
92 {
93 *pMode = seamlessChangeRequest.mode;
94 return VINF_SUCCESS;
95 }
96 }
97 else
98 rc = VERR_TRY_AGAIN;
99 }
100 return rc;
101}
102
103/**
104 * Inform the host about the visible region
105 *
106 * @returns IPRT status code
107 * @param cRects number of rectangles in the list of visible rectangles
108 * @param pRects list of visible rectangles on the guest display
109 *
110 * @todo A scatter-gather version of vbglR3GRPerform would be nice, so that we don't have
111 * to copy our rectangle and header data into a single structure and perform an
112 * additional allocation.
113 */
114VBGLR3DECL(int) VbglR3SeamlessSendRects(uint32_t cRects, PRTRECT pRects)
115{
116 VMMDevVideoSetVisibleRegion *pReq;
117 int rc;
118
119 if (!cRects || !pRects)
120 return VINF_SUCCESS;
121 rc = vbglR3GRAlloc((VMMDevRequestHeader **)&pReq,
122 sizeof(VMMDevVideoSetVisibleRegion) + (cRects - 1) * sizeof(RTRECT),
123 VMMDevReq_VideoSetVisibleRegion);
124 if (RT_SUCCESS(rc))
125 {
126 pReq->cRect = cRects;
127 memcpy(&pReq->Rect, pRects, cRects * sizeof(RTRECT));
128 rc = vbglR3GRPerform(&pReq->header);
129 if (RT_SUCCESS(rc))
130 rc = pReq->header.rc;
131 vbglR3GRFree(&pReq->header);
132 }
133 return rc;
134}
135
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