52f16f53a955f5b24bc2132c418a5fffb700f089vboxsync/* $Id$ */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/** @file
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Video.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/*
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2007-2012 Oracle Corporation
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * available from http://www.virtualbox.org. This file is free software;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * General Public License (GPL) as published by the Free Software
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync *
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * The contents of this file may alternatively be used under the terms
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * of the Common Development and Distribution License Version 1.0
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * VirtualBox OSE distribution, in which case the provisions of the
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * CDDL are applicable instead of those of the GPL.
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync *
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * You may elect to license modified versions of this file under the
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * terms and conditions of either the GPL or the CDDL or both.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/*******************************************************************************
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync* Header Files *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync*******************************************************************************/
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync#include "VBGLR3Internal.h"
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync#include <VBox/log.h>
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync#include <VBox/HostServices/GuestPropertySvc.h> /* For Save and RetrieveVideoMode */
64e0c74b525c440a571ce06f3eb6234d75913d76vboxsync#include <iprt/assert.h>
95f49f3cab4060d4c9b53703d32f51a7f1a3ece6vboxsync#if !defined(VBOX_VBGLR3_XFREE86) && !defined(VBOX_VBGLR3_XORG)
64241796dca8fa36d3fca205e01b4320193a36b7vboxsync# include <iprt/mem.h>
64241796dca8fa36d3fca205e01b4320193a36b7vboxsync#endif
d6aa6429f99fb7648883eb612f8a52b9aaf3bff4vboxsync#include <iprt/string.h>
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync#include <stdio.h>
c312e1b81dffe42e0fb766020fb8defaeade05d6vboxsync
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync#ifdef VBOX_VBGLR3_XFREE86
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync/* Rather than try to resolve all the header file conflicts, I will just
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync prototype what we need here. */
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsyncextern "C" void* xf86memcpy(void*,const void*,xf86size_t);
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync# undef memcpy
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync# define memcpy xf86memcpy
64241796dca8fa36d3fca205e01b4320193a36b7vboxsyncextern "C" void* xf86memset(const void*,int,xf86size_t);
64241796dca8fa36d3fca205e01b4320193a36b7vboxsync# undef memset
64241796dca8fa36d3fca205e01b4320193a36b7vboxsync# define memset xf86memset
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync#endif /* VBOX_VBGLR3_XFREE86 */
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync#define VIDEO_PROP_PREFIX "/VirtualBox/GuestAdd/Vbgl/Video/"
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/**
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * Enable or disable video acceleration.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @returns VBox status code.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @param fEnable Pass zero to disable, any other value to enable.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
50f0e2e83362e100d306a411980d555d46aa00a8vboxsyncVBGLR3DECL(int) VbglR3VideoAccelEnable(bool fEnable)
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync{
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync VMMDevVideoAccelEnable Req;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync vmmdevInitRequest(&Req.header, VMMDevReq_VideoAccelEnable);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync Req.u32Enable = fEnable;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync Req.cbRingBuffer = VBVA_RING_BUFFER_SIZE;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync Req.fu32Status = 0;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync return vbglR3GRPerform(&Req.header);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync}
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/**
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * Flush the video buffer.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @returns VBox status code.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsyncVBGLR3DECL(int) VbglR3VideoAccelFlush(void)
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync{
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync VMMDevVideoAccelFlush Req;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync vmmdevInitRequest(&Req.header, VMMDevReq_VideoAccelFlush);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync return vbglR3GRPerform(&Req.header);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync}
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/**
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * Send mouse pointer shape information to the host.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @returns VBox status code.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @param fFlags Mouse pointer flags.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @param xHot X coordinate of hot spot.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @param yHot Y coordinate of hot spot.
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync * @param cx Pointer width.
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync * @param cy Pointer height.
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync * @param pvImg Pointer to the image data (can be NULL).
54828795a553ed0731f308ebda81675ad2c39d58vboxsync * @param cbImg Size of the image data pointed to by pvImg.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
54828795a553ed0731f308ebda81675ad2c39d58vboxsyncVBGLR3DECL(int) VbglR3SetPointerShape(uint32_t fFlags, uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, const void *pvImg, size_t cbImg)
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync{
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync VMMDevReqMousePointer *pReq;
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync size_t cbReq = vmmdevGetMousePointerReqSize(cx, cy);
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync AssertReturn( !pvImg
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync || cbReq == RT_OFFSETOF(VMMDevReqMousePointer, pointerData) + cbImg,
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync VERR_INVALID_PARAMETER);
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync int rc = vbglR3GRAlloc((VMMDevRequestHeader **)&pReq, cbReq,
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync VMMDevReq_SetPointerShape);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync if (RT_SUCCESS(rc))
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync {
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync pReq->fFlags = fFlags;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync pReq->xHot = xHot;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync pReq->yHot = yHot;
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync pReq->width = cx;
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync pReq->height = cy;
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync if (pvImg)
54828795a553ed0731f308ebda81675ad2c39d58vboxsync memcpy(pReq->pointerData, pvImg, cbImg);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync rc = vbglR3GRPerform(&pReq->header);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync if (RT_SUCCESS(rc))
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync rc = pReq->header.rc;
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync vbglR3GRFree(&pReq->header);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync }
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync return rc;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync}
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync/**
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * Send mouse pointer shape information to the host.
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * This version of the function accepts a request for clients that
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * already allocate and manipulate the request structure directly.
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync *
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * @returns VBox status code.
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync *
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * @param pReq Pointer to the VMMDevReqMousePointer structure.
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync */
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsyncVBGLR3DECL(int) VbglR3SetPointerShapeReq(VMMDevReqMousePointer *pReq)
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync{
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync int rc = vbglR3GRPerform(&pReq->header);
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync if (RT_SUCCESS(rc))
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync rc = pReq->header.rc;
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync return rc;
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync}
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync/**
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * Query the last display change request sent from the host to the guest.
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync *
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * @returns iprt status value
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * @param pcx Where to store the horizontal pixel resolution
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * @param pcy Where to store the vertical pixel resolution
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * requested (a value of zero means do not change).
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * @param pcBits Where to store the bits per pixel requested (a value
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * of zero means do not change).
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * @param iDisplay Where to store the display number the request was for
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * - 0 for the primary display, 1 for the first
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * secondary display, etc.
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * @param fAck whether or not to acknowledge the newest request sent by
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * the host. If this is set, the function will return the
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * most recent host request, otherwise it will return the
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * last request to be acknowledged.
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync *
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync */
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsyncstatic int getDisplayChangeRequest2(uint32_t *pcx, uint32_t *pcy,
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync uint32_t *pcBits, uint32_t *piDisplay,
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync bool fAck)
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync{
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync VMMDevDisplayChangeRequest2 Req;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync AssertPtrReturn(pcx, VERR_INVALID_PARAMETER);
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync AssertPtrReturn(pcy, VERR_INVALID_PARAMETER);
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync AssertPtrReturn(pcBits, VERR_INVALID_PARAMETER);
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync AssertPtrReturn(piDisplay, VERR_INVALID_PARAMETER);
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync RT_ZERO(Req);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequest2);
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync if (fAck)
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync Req.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync int rc = vbglR3GRPerform(&Req.header);
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync if (RT_SUCCESS(rc))
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync rc = Req.header.rc;
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync if (RT_SUCCESS(rc))
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync {
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync *pcx = Req.xres;
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync *pcy = Req.yres;
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync *pcBits = Req.bpp;
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync *piDisplay = Req.display;
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync }
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync return rc;
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync}
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync/**
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * Query the last display change request sent from the host to the guest.
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync *
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync * @returns iprt status value
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * @param pcx Where to store the horizontal pixel resolution
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * requested (a value of zero means do not change).
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * @param pcy Where to store the vertical pixel resolution
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * requested (a value of zero means do not change).
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * @param pcBits Where to store the bits per pixel requested (a value
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * of zero means do not change).
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * @param piDisplay Where to store the display number the request was for
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * - 0 for the primary display, 1 for the first
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * secondary display, etc.
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * @param fAck whether or not to acknowledge the newest request sent by
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * the host. If this is set, the function will return the
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * most recent host request, otherwise it will return the
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * last request to be acknowledged.
2084a447d1acb619df7c393fac41b79d517e4b3dvboxsync *
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * @param pdx New horizontal position of the secondary monitor.
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * Optional.
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * @param pdy New vertical position of the secondary monitor.
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * Optional.
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * param pfEnabled Secondary monitor is enabled or not.
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * Optional.
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * param pfChangeOrigin Whether the mode hint retrieved included information
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * about origin/display offset inside the frame-buffer.
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * Optional.
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync *
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync */
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsyncVBGLR3DECL(int) VbglR3GetDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy,
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync uint32_t *pcBits,
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync uint32_t *piDisplay,
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync uint32_t *pdx, uint32_t *pdy,
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync bool *pfEnabled,
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync bool *pfChangeOrigin,
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync bool fAck)
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync{
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync VMMDevDisplayChangeRequestEx Req;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync int rc = VINF_SUCCESS;
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync AssertPtrReturn(pcx, VERR_INVALID_PARAMETER);
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync AssertPtrReturn(pcy, VERR_INVALID_PARAMETER);
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync AssertPtrReturn(pcBits, VERR_INVALID_PARAMETER);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync AssertPtrNullReturn(pdx, VERR_INVALID_PARAMETER);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync AssertPtrNullReturn(pdy, VERR_INVALID_PARAMETER);
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync AssertPtrReturn(piDisplay, VERR_INVALID_PARAMETER);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync AssertPtrNullReturn(pfEnabled, VERR_INVALID_PARAMETER);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync AssertPtrNullReturn(pfChangeOrigin, VERR_INVALID_PARAMETER);
5c320d1b52e5e4ae280cd680c2c64de5f5f13d22vboxsync RT_ZERO(Req);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync rc = vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequestEx);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync AssertRCReturn(rc, rc);
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync if (fAck)
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync Req.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync rc = vbglR3GRPerform(&Req.header);
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync if (RT_SUCCESS(rc))
b60e4b0625949fd68ed97f1353e2174c5b3192e5vboxsync rc = Req.header.rc;
b60e4b0625949fd68ed97f1353e2174c5b3192e5vboxsync if (RT_SUCCESS(rc))
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync {
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync *pcx = Req.xres;
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync *pcy = Req.yres;
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync *pcBits = Req.bpp;
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync *piDisplay = Req.display;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync if (pdx)
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync *pdx = Req.cxOrigin;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync if (pdy)
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync *pdy = Req.cyOrigin;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync if (pfEnabled)
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync *pfEnabled = Req.fEnabled;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync if (pfChangeOrigin)
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync *pfChangeOrigin = Req.fChangeOrigin;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync }
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync /* NEEDS TESTING: test below with current Additions on VBox 4.1 or older. */
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync /** @todo Can we find some standard grep-able string for "NEEDS TESTING"? */
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync if (rc == VERR_NOT_IMPLEMENTED) /* Fall back to the old API. */
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync {
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync if (pfEnabled)
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync *pfEnabled = true;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync if (pfChangeOrigin)
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync *pfChangeOrigin = false;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync return getDisplayChangeRequest2(pcx, pcy, pcBits, piDisplay, fAck);
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync }
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync return rc;
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync}
64e0c74b525c440a571ce06f3eb6234d75913d76vboxsync
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync/**
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync * Query the host as to whether it likes a specific video mode.
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync *
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync * @returns the result of the query
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync * @param cx the width of the mode being queried
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync * @param cy the height of the mode being queried
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync * @param cBits the bpp of the mode being queried
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync */
052deaa01d8fcd5cec4dff857833538940b751c3vboxsyncVBGLR3DECL(bool) VbglR3HostLikesVideoMode(uint32_t cx, uint32_t cy, uint32_t cBits)
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync{
39a628c9e979cb2355caa57eb099b13cb922783cvboxsync bool fRc = true; /* If for some reason we can't contact the host then
39a628c9e979cb2355caa57eb099b13cb922783cvboxsync * we like everything. */
26bef2fb65df80a28b9972e0a43a92be367417d9vboxsync int rc;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync VMMDevVideoModeSupportedRequest req;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync vmmdevInitRequest(&req.header, VMMDevReq_VideoModeSupported);
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync req.width = cx;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync req.height = cy;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync req.bpp = cBits;
39a628c9e979cb2355caa57eb099b13cb922783cvboxsync req.fSupported = true;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync rc = vbglR3GRPerform(&req.header);
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync if (RT_SUCCESS(rc) && RT_SUCCESS(req.header.rc))
d308e8fdb9e4d827ed10d26d1581d265602f6f46vboxsync fRc = req.fSupported;
d308e8fdb9e4d827ed10d26d1581d265602f6f46vboxsync return fRc;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync}
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync/**
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync * Get the highest screen number for which there is a saved video mode or "0"
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync * if there are no saved modes.
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync *
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync * @returns iprt status value
16055a5d4275e7b50ed0a51b37cce77ac07e2c57vboxsync * @returns VERR_NOT_SUPPORTED if the guest property service is not available.
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync * @param pcScreen where to store the virtual screen number
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync */
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsyncVBGLR3DECL(int) VbglR3VideoModeGetHighestSavedScreen(unsigned *pcScreen)
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync{
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync#if defined(VBOX_WITH_GUEST_PROPS)
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync using namespace guestProp;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync int rc, rc2 = VERR_UNRESOLVED_ERROR;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync uint32_t u32ClientId = 0;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync const char *pszPattern = VIDEO_PROP_PREFIX"*";
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync PVBGLR3GUESTPROPENUM pHandle = NULL;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync const char *pszName;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync unsigned cHighestScreen = 0;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync AssertPtrReturn(pcScreen, VERR_INVALID_POINTER);
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc = VbglR3GuestPropConnect(&u32ClientId);
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync if (RT_SUCCESS(rc))
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc = VbglR3GuestPropEnum(u32ClientId, &pszPattern, 1, &pHandle,
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync &pszName, NULL, NULL, NULL);
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync if (u32ClientId != 0)
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc2 = VbglR3GuestPropDisconnect(u32ClientId);
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync if (RT_SUCCESS(rc))
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc = rc2;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync while (pszName != NULL && RT_SUCCESS(rc))
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync {
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync uint32_t cScreen;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc = RTStrToUInt32Full(pszName + sizeof(VIDEO_PROP_PREFIX) - 1, 10,
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync &cScreen);
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync if (RT_SUCCESS(rc)) /* There may be similar properties with text. */
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync cHighestScreen = RT_MAX(cHighestScreen, cScreen);
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc = VbglR3GuestPropEnumNext(pHandle, &pszName, NULL, NULL, NULL);
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync }
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync VbglR3GuestPropEnumFree(pHandle);
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync if (RT_SUCCESS(rc))
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync *pcScreen = cHighestScreen;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync return rc;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync#else /* !VBOX_WITH_GUEST_PROPS */
16055a5d4275e7b50ed0a51b37cce77ac07e2c57vboxsync return VERR_NOT_SUPPORTED;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync#endif /* !VBOX_WITH_GUEST_PROPS */
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync}
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync/**
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * Save video mode parameters to the guest property store.
7dbde0174637fbfd00c50b383f654e46878eaa8evboxsync *
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync * @returns iprt status value
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * @param cScreen virtual screen number
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * @param cx mode width
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * @param cy mode height
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * @param cBits bits per pixel for the mode
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * @param x virtual screen X offset
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * @param y virtual screen Y offset
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * @param fEnabled is this virtual screen enabled?
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync */
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsyncVBGLR3DECL(int) VbglR3SaveVideoMode(unsigned cScreen, unsigned cx, unsigned cy,
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync unsigned cBits, unsigned x, unsigned y,
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync bool fEnabled)
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync{
208aaecb51db539a2f7f3d25f38dd2efd0f014a3vboxsync#if defined(VBOX_WITH_GUEST_PROPS)
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync using namespace guestProp;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync
2673f120424ba2bb67c6da0eb851b65b22b0cba4vboxsync char szModeName[MAX_NAME_LEN];
2673f120424ba2bb67c6da0eb851b65b22b0cba4vboxsync char szModeParms[MAX_VALUE_LEN];
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync uint32_t u32ClientId = 0;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync unsigned cx2, cy2, cBits2, x2, y2, cHighestScreen, cHighestScreen2;
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync bool fEnabled2;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync int rc, rc2 = VERR_UNRESOLVED_ERROR;
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc = VbglR3VideoModeGetHighestSavedScreen(&cHighestScreen);
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync RTStrPrintf(szModeName, sizeof(szModeName), VIDEO_PROP_PREFIX"%u", cScreen);
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync RTStrPrintf(szModeParms, sizeof(szModeParms), "%ux%ux%u,%ux%u,%u", cx, cy,
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync cBits, x, y, (unsigned) fEnabled);
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync if (RT_SUCCESS(rc))
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc = VbglR3GuestPropConnect(&u32ClientId);
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync if (RT_SUCCESS(rc))
599b7569e4b78b89660cae635ec3e97ffb61eb08vboxsync {
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync rc = VbglR3GuestPropWriteValue(u32ClientId, szModeName, szModeParms);
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync /* Write out the mode using the legacy name too, in case the user
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync * re-installs older Additions. */
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync if (cScreen == 0)
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync {
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync RTStrPrintf(szModeParms, sizeof(szModeParms), "%ux%ux%u", cx, cy,
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync cBits);
599b7569e4b78b89660cae635ec3e97ffb61eb08vboxsync VbglR3GuestPropWriteValue(u32ClientId, VIDEO_PROP_PREFIX"SavedMode",
599b7569e4b78b89660cae635ec3e97ffb61eb08vboxsync szModeParms);
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync }
599b7569e4b78b89660cae635ec3e97ffb61eb08vboxsync }
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync if (u32ClientId != 0)
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc2 = VbglR3GuestPropDisconnect(u32ClientId);
36443478b3adac6ad45655c052e758aa7766b22fvboxsync if (rc == VINF_PERMISSION_DENIED)
36443478b3adac6ad45655c052e758aa7766b22fvboxsync return rc;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync if (RT_SUCCESS(rc))
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc = rc2;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync /* Sanity check 1. We do not try to make allowance for someone else
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync * changing saved settings at the same time as us. */
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync if (RT_SUCCESS(rc))
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync {
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync rc = VbglR3RetrieveVideoMode(cScreen, &cx2, &cy2, &cBits2, &x2, &y2,
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync &fEnabled2);
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync if ( RT_SUCCESS(rc)
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync && ( cx != cx2 || cy != cy2 || cBits != cBits2
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync || x != x2 || y != y2 || fEnabled != fEnabled2))
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync rc = VERR_WRITE_ERROR;
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync }
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync /* Sanity check 2. Same comment. */
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync if (RT_SUCCESS(rc))
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc = VbglR3VideoModeGetHighestSavedScreen(&cHighestScreen2);
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync if (RT_SUCCESS(rc))
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync if (cHighestScreen2 != RT_MAX(cHighestScreen, cScreen))
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc = VERR_INTERNAL_ERROR;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync return rc;
208aaecb51db539a2f7f3d25f38dd2efd0f014a3vboxsync#else /* !VBOX_WITH_GUEST_PROPS */
16055a5d4275e7b50ed0a51b37cce77ac07e2c57vboxsync return VERR_NOT_SUPPORTED;
208aaecb51db539a2f7f3d25f38dd2efd0f014a3vboxsync#endif /* !VBOX_WITH_GUEST_PROPS */
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync}
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync/**
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync * Retrieve video mode parameters from the guest property store.
7dbde0174637fbfd00c50b383f654e46878eaa8evboxsync *
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync * @returns iprt status value
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * @param cScreen the virtual screen number
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * @param pcx where to store the mode width
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * @param pcy where to store the mode height
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * @param pcBits where to store the bits per pixel for the mode
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * @param px where to store the virtual screen X offset
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * @param py where to store the virtual screen Y offset
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync * @param pfEnabled where to store whether this virtual screen is enabled
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync */
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsyncVBGLR3DECL(int) VbglR3RetrieveVideoMode(unsigned cScreen,
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync unsigned *pcx, unsigned *pcy,
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync unsigned *pcBits,
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync unsigned *px, unsigned *py,
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync bool *pfEnabled)
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync{
208aaecb51db539a2f7f3d25f38dd2efd0f014a3vboxsync#if defined(VBOX_WITH_GUEST_PROPS)
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync using namespace guestProp;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync/*
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * First we retrieve the video mode which is saved as a string in the
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync * guest property store.
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync */
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync /* The buffer for VbglR3GuestPropReadValue. If this is too small then
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync * something is wrong with the data stored in the property. */
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync char szModeName[MAX_NAME_LEN];
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync char szModeParms[1024];
6c09ee027ad80a5fe6b70ad652253ae6edd09121vboxsync uint32_t u32ClientId = 0;
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync int cMatches;
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync unsigned cx, cy, cBits;
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync unsigned x = 0;
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync unsigned y = 0;
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync unsigned fEnabled = 1;
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync int rc;
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync int rc2 = VERR_UNRESOLVED_ERROR;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync /** @todo add a VbglR3GuestPropReadValueF/FV that does the RTStrPrintf for you. */
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync RTStrPrintf(szModeName, sizeof(szModeName), VIDEO_PROP_PREFIX"%u", cScreen);
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc = VbglR3GuestPropConnect(&u32ClientId);
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync if (RT_SUCCESS(rc))
599b7569e4b78b89660cae635ec3e97ffb61eb08vboxsync {
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync rc = VbglR3GuestPropReadValue(u32ClientId, szModeName, szModeParms,
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync sizeof(szModeParms), NULL);
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync /* Try legacy single screen name. */
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync if (rc == VERR_NOT_FOUND && cScreen == 0)
599b7569e4b78b89660cae635ec3e97ffb61eb08vboxsync rc = VbglR3GuestPropReadValue(u32ClientId,
599b7569e4b78b89660cae635ec3e97ffb61eb08vboxsync VIDEO_PROP_PREFIX"SavedMode",
599b7569e4b78b89660cae635ec3e97ffb61eb08vboxsync szModeParms, sizeof(szModeParms),
599b7569e4b78b89660cae635ec3e97ffb61eb08vboxsync NULL);
599b7569e4b78b89660cae635ec3e97ffb61eb08vboxsync }
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync if (u32ClientId != 0)
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc2 = VbglR3GuestPropDisconnect(u32ClientId);
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync if (RT_SUCCESS(rc))
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync rc = rc2;
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync/*
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync * Now we convert the string returned to numeric values.
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync */
4e32d3f1b090e772094a26a8605a205a798925bavboxsync if (RT_SUCCESS(rc))
4e32d3f1b090e772094a26a8605a205a798925bavboxsync {
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync char c1, c2;
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync cMatches = sscanf(szModeParms, "%ux%ux%u%c%ux%u,%u%c", &cx, &cy, &cBits,
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync &c1, &x, &y, &fEnabled, &c2);
2b4afb8fb52455af86dd07f49409085babff82e6vboxsync if ((cMatches == 7 && c1 == ',') || cMatches == 3)
4e32d3f1b090e772094a26a8605a205a798925bavboxsync rc = VINF_SUCCESS;
4e32d3f1b090e772094a26a8605a205a798925bavboxsync else if (cMatches < 0)
4e32d3f1b090e772094a26a8605a205a798925bavboxsync rc = VERR_READ_ERROR;
4e32d3f1b090e772094a26a8605a205a798925bavboxsync else
4e32d3f1b090e772094a26a8605a205a798925bavboxsync rc = VERR_PARSE_ERROR;
4e32d3f1b090e772094a26a8605a205a798925bavboxsync }
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync/*
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync * And clean up and return the values if we successfully obtained them.
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync */
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync if (RT_SUCCESS(rc))
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync {
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync if (pcx)
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync *pcx = cx;
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync if (pcy)
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync *pcy = cy;
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync if (pcBits)
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync *pcBits = cBits;
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync if (px)
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync *px = x;
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync if (py)
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync *py = y;
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync if (pfEnabled)
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync *pfEnabled = RT_BOOL(fEnabled);
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync }
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync return rc;
208aaecb51db539a2f7f3d25f38dd2efd0f014a3vboxsync#else /* !VBOX_WITH_GUEST_PROPS */
16055a5d4275e7b50ed0a51b37cce77ac07e2c57vboxsync return VERR_NOT_SUPPORTED;
208aaecb51db539a2f7f3d25f38dd2efd0f014a3vboxsync#endif /* !VBOX_WITH_GUEST_PROPS */
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync}