VirtualBox

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

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

Guest Additions: update for the Linux seamless additions

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