getmode.c revision a3ffc09029b04bb6e4b1c7feab1d750eb23b70f4
/* $Id$ */
/** @file
* VirtualBox X11 Additions graphics driver utility functions
*/
/*
* Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include "vboxvideo.h"
#define NEED_XF86_TYPES
#include "xf86.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include "windowstr.h"
#ifdef XORG_7X
# include <stdio.h>
# include <stdlib.h>
#endif
/**************************************************************************
* Main functions *
**************************************************************************/
/**
* Fills a display mode M with a built-in mode of name pszName and dimensions
* cx and cy.
*/
{
char szName[256];
if (!pszName)
{
}
if (m->name)
memset(m, '\0', sizeof(*m));
m->type = M_T_BUILTIN;
/* Older versions of VBox only support screen widths which are a multiple
* of 8 */
else
}
/** vboxvideo's list of standard video modes */
struct
{
/** mode width */
/** mode height */
} vboxStandardModes[] =
{
{ 1600, 1200 },
{ 1440, 1050 },
{ 1280, 960 },
{ 1024, 768 },
{ 800, 600 },
{ 640, 480 },
{ 0, 0 }
};
enum
{
};
/**
* Returns a standard mode which the host likes. Can be called multiple
* times with the index returned by the previous call to get a list of modes.
* @returns the index of the mode in the list, or 0 if no more modes are
* available
* @param pScrn the screen information structure
* @param pScrn->bitsPerPixel
* if this is non-null, only modes with this BPP will be
* returned
* @param cIndex the index of the last mode queried, or 0 to query the
* first mode available. Note: the first index is 1
* @param pcx where to store the mode's width
* @param pcy where to store the mode's height
* @param pcBits where to store the mode's BPP
*/
{
unsigned i;
("cIndex = %d, vboxNumStdModes = %d\n", cIndex,
{
if (pcx)
if (pcy)
return i + 1;
}
return 0;
}
/**
* Allocates an empty display mode and links it into the doubly linked list of
* modes pointed to by pScrn->modes. Returns a pointer to the newly allocated
* memory.
*/
{
TRACE_ENTRY();
{
}
else
{
}
return pMode;
}
/**
* Create display mode entries in the screen information structure for each
* of the graphics modes that we wish to support, that is:
* - A dynamic mode in first place which will be updated by the RandR code.
* - Several standard modes.
* - Any modes that the user requested in xorg.conf/XFree86Config.
*/
{
unsigned i;
/* Add two dynamic mode entries. When we receive a new size hint we will
* update whichever of these is not current. */
/* Add standard modes supported by the host */
for ( ; ; )
{
if (cIndex == 0)
break;
}
/* And finally any modes specified by the user. We assume here that
* the mode names reflect the mode sizes. */
{
{
}
}
}
/** Set the initial values for the guest screen size hints by reading saved
* values from files. */
/** @todo Actually read the files instead of setting dummies. */
{
unsigned i;
{
}
/* Set up the first mode correctly to match the requested initial mode. */
/* RandR 1.1 quirk: make sure that the initial resolution is always present
* in the mode list as RandR will always advertise a mode of the initial
* virtual resolution via GetScreenInfo. */
}
# define SIZE_HINTS_PROPERTY "VBOX_SIZE_HINTS"
/** Read in information about the most recent size hints requested for the
* guest screens. A client application sets the hint information as a root
* window property. */
{
FALSE);
unsigned i;
/* We can get called early, before the root window is created. */
if (!ROOT_WINDOW(pScrn))
return;
if (atom != BAD_RESOURCE)
{
}
{
{
}
else
{
}
}
}
#ifndef VBOXVIDEO_13
/** The RandR "proc" vector, which we wrap with our own in order to notice
* when a client sends a GetScreenInfo request. */
/** The swapped RandR "proc" vector. */
{
return;
if (!pWin)
return;
}
{
return g_pfnVBoxRandRProc(pClient);
}
{
return g_pfnVBoxRandRSwappedProc(pClient);
}
{
return FALSE;
/* I doubt we can be loaded twice - should I fail here? */
if (g_pfnVBoxRandRProc)
return TRUE;
if (!pExt)
{
"RandR extension not found, disabling dynamic resizing.\n");
return TRUE;
}
#if !defined(XF86_VERSION_CURRENT) \
/* SwappedProcVector is not exported in XFree86, so we will not support
* swapped byte order clients. I doubt this is a big issue. */
#endif
)
FatalError("RandR \"proc\" vector not initialised\n");
#if !defined(XF86_VERSION_CURRENT) \
#endif
return TRUE;
}
/** Install our private RandR hook procedure, so that we can detect
* GetScreenInfo requests from clients to update our dynamic mode. This works
* by installing a wrapper around CreateScreenResources(), which will be called
* after RandR is initialised. The wrapper then in turn wraps the RandR "proc"
* vectors with its own handlers which will get called on any client RandR
* request. This should not be used in conjunction with RandR 1.2 or later.
* A couple of points of interest in our RandR 1.1 support:
* * We use the first two screen modes as dynamic modes. When a new mode hint
* arrives we update the first of the two which is not the current mode with
* the new size.
* * RandR 1.1 always advertises a mode of the size of the initial virtual
* resolution via GetScreenInfo(), so we make sure that a mode of that size
* is always present in the list.
* * RandR adds each new mode it sees to an internal array, but never removes
* entries. This array might end up getting rather long given that we can
* report a lot more modes than physical hardware.
*/
{
if (!pScreen->CreateScreenResources)
FatalError("called to early: CreateScreenResources not yet initialised\n");
}
#endif /* !VBOXVIDEO_13 */