VirtualBox

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

Last change on this file since 27119 was 26425, checked in by vboxsync, 15 years ago

alternative license for VBoxGuestLib is CDDL

  • 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 26425 2010-02-11 11:37:08Z 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 * @retval pMode on success, the seamless mode to switch into (i.e. disabled, visible region
62 * or host window)
63 */
64VBGLR3DECL(int) VbglR3SeamlessWaitEvent(VMMDevSeamlessMode *pMode)
65{
66 VBoxGuestWaitEventInfo waitEvent;
67 int rc;
68
69 AssertPtrReturn(pMode, VERR_INVALID_PARAMETER);
70 waitEvent.u32TimeoutIn = RT_INDEFINITE_WAIT;
71 waitEvent.u32EventMaskIn = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
72 waitEvent.u32Result = VBOXGUEST_WAITEVENT_ERROR;
73 waitEvent.u32EventFlagsOut = 0;
74 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent));
75 if (RT_SUCCESS(rc))
76 {
77 /* did we get the right event? */
78 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST)
79 {
80 VMMDevSeamlessChangeRequest seamlessChangeRequest;
81
82 /* get the seamless change request */
83 vmmdevInitRequest(&seamlessChangeRequest.header, VMMDevReq_GetSeamlessChangeRequest);
84 seamlessChangeRequest.eventAck = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
85 rc = vbglR3GRPerform(&seamlessChangeRequest.header);
86 if (RT_SUCCESS(rc))
87 {
88 *pMode = seamlessChangeRequest.mode;
89 return VINF_SUCCESS;
90 }
91 }
92 else
93 rc = VERR_TRY_AGAIN;
94 }
95 return rc;
96}
97
98/**
99 * Inform the host about the visible region
100 *
101 * @returns IPRT status code
102 * @param cRects number of rectangles in the list of visible rectangles
103 * @param pRects list of visible rectangles on the guest display
104 *
105 * @todo A scatter-gather version of vbglR3GRPerform would be nice, so that we don't have
106 * to copy our rectangle and header data into a single structure and perform an
107 * additional allocation.
108 */
109VBGLR3DECL(int) VbglR3SeamlessSendRects(uint32_t cRects, PRTRECT pRects)
110{
111 VMMDevVideoSetVisibleRegion *pReq;
112 int rc;
113
114 if (!cRects || !pRects)
115 return VINF_SUCCESS;
116 rc = vbglR3GRAlloc((VMMDevRequestHeader **)&pReq,
117 sizeof(VMMDevVideoSetVisibleRegion) + (cRects - 1) * sizeof(RTRECT),
118 VMMDevReq_VideoSetVisibleRegion);
119 if (RT_SUCCESS(rc))
120 {
121 pReq->cRect = cRects;
122 memcpy(&pReq->Rect, pRects, cRects * sizeof(RTRECT));
123 rc = vbglR3GRPerform(&pReq->header);
124 if (RT_SUCCESS(rc))
125 rc = pReq->header.rc;
126 vbglR3GRFree(&pReq->header);
127 }
128 return rc;
129}
130
Note: See TracBrowser for help on using the repository browser.

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