VirtualBox

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

Last change on this file since 26131 was 24968, checked in by vboxsync, 15 years ago

Additions/common/VBoxGuestLib: don't accidentally re-enable the graphics capability when disabling seamless

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/* $Id: VBoxGuestR3LibSeamless.cpp 24968 2009-11-25 16:53:42Z 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/VMMDev.h>
30#include <VBox/log.h>
31
32#include "VBGLR3Internal.h"
33
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 */
41VBGLR3DECL(int) VbglR3SeamlessSetCap(bool fState)
42{
43 if (fState)
44 return VbglR3SetGuestCaps(VMMDEV_GUEST_SUPPORTS_SEAMLESS, 0);
45 return VbglR3SetGuestCaps(0, VMMDEV_GUEST_SUPPORTS_SEAMLESS);
46}
47
48/**
49 * Wait for a seamless mode change event.
50 *
51 * @returns IPRT status value
52 * @retval pMode on success, the seamless mode to switch into (i.e. disabled, visible region
53 * or host window)
54 */
55VBGLR3DECL(int) VbglR3SeamlessWaitEvent(VMMDevSeamlessMode *pMode)
56{
57 VBoxGuestWaitEventInfo waitEvent;
58 int rc;
59
60 AssertPtrReturn(pMode, VERR_INVALID_PARAMETER);
61 waitEvent.u32TimeoutIn = RT_INDEFINITE_WAIT;
62 waitEvent.u32EventMaskIn = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
63 waitEvent.u32Result = VBOXGUEST_WAITEVENT_ERROR;
64 waitEvent.u32EventFlagsOut = 0;
65 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent));
66 if (RT_SUCCESS(rc))
67 {
68 /* did we get the right event? */
69 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST)
70 {
71 VMMDevSeamlessChangeRequest seamlessChangeRequest;
72
73 /* get the seamless change request */
74 vmmdevInitRequest(&seamlessChangeRequest.header, VMMDevReq_GetSeamlessChangeRequest);
75 seamlessChangeRequest.eventAck = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
76 rc = vbglR3GRPerform(&seamlessChangeRequest.header);
77 if (RT_SUCCESS(rc))
78 {
79 *pMode = seamlessChangeRequest.mode;
80 return VINF_SUCCESS;
81 }
82 }
83 else
84 rc = VERR_TRY_AGAIN;
85 }
86 return rc;
87}
88
89/**
90 * Inform the host about the visible region
91 *
92 * @returns IPRT status code
93 * @param cRects number of rectangles in the list of visible rectangles
94 * @param pRects list of visible rectangles on the guest display
95 *
96 * @todo A scatter-gather version of vbglR3GRPerform would be nice, so that we don't have
97 * to copy our rectangle and header data into a single structure and perform an
98 * additional allocation.
99 */
100VBGLR3DECL(int) VbglR3SeamlessSendRects(uint32_t cRects, PRTRECT pRects)
101{
102 VMMDevVideoSetVisibleRegion *pReq;
103 int rc;
104
105 if (!cRects || !pRects)
106 return VINF_SUCCESS;
107 rc = vbglR3GRAlloc((VMMDevRequestHeader **)&pReq,
108 sizeof(VMMDevVideoSetVisibleRegion) + (cRects - 1) * sizeof(RTRECT),
109 VMMDevReq_VideoSetVisibleRegion);
110 if (RT_SUCCESS(rc))
111 {
112 pReq->cRect = cRects;
113 memcpy(&pReq->Rect, pRects, cRects * sizeof(RTRECT));
114 rc = vbglR3GRPerform(&pReq->header);
115 if (RT_SUCCESS(rc))
116 rc = pReq->header.rc;
117 vbglR3GRFree(&pReq->header);
118 }
119 return rc;
120}
121
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