Skip to content

Commit

Permalink
added primitive Xvnc-randr extension
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Richardson <mcr@xelerance.com>
  • Loading branch information
Michael Richardson committed Sep 9, 2007
1 parent e827fc4 commit 77b4197
Show file tree
Hide file tree
Showing 4 changed files with 257 additions and 1 deletion.
1 change: 1 addition & 0 deletions xorg-server/hw/vnc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ libvnccommon_la_SOURCES = \
vncExtInit.h \
vncHooks.cc \
vncHooks.h \
Xvnc-randr.c \
XserverDesktop.cc \
XserverDesktop.h

Expand Down
4 changes: 3 additions & 1 deletion xorg-server/hw/vnc/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ libvnc_la_OBJECTS = $(am_libvnc_la_OBJECTS)
libvnccommon_la_LIBADD =
am_libvnccommon_la_OBJECTS = buildtime.lo \
libvnccommon_la-vncExtInit.lo libvnccommon_la-vncHooks.lo \
libvnccommon_la-XserverDesktop.lo
Xvnc-randr.lo libvnccommon_la-XserverDesktop.lo
libvnccommon_la_OBJECTS = $(am_libvnccommon_la_OBJECTS)
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
Expand Down Expand Up @@ -586,6 +586,7 @@ libvnccommon_la_SOURCES = \
vncExtInit.h \
vncHooks.cc \
vncHooks.h \
Xvnc-randr.c \
XserverDesktop.cc \
XserverDesktop.h

Expand Down Expand Up @@ -785,6 +786,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xvnc-dpmsstubs.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xvnc-fbcmap.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xvnc-miinitext.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xvnc-randr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xvnc-stubs.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xvnc-xvnc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buildtime.Plo@am__quote@
Expand Down
249 changes: 249 additions & 0 deletions xorg-server/hw/vnc/Xvnc-randr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
/* Copyright (C) 2007 XDS Canada Inc. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xrandr.h>
#include <X11/cursorfont.h>

#include "xorg-config.h"
#include "inputstr.h"
#include "cursorstr.h"
#include "mipointer.h"

#ifdef RANDR
#include "randrstr.h"
#endif

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <math.h>

#ifdef RANDR

static Bool
vndRandRGetInfo (ScreenPtr pScreen,
Rotation *rotations)
{
RRScreenSizePtr pSize;

*rotations = RR_Rotate_0;

#if 0
if (randrExtension)
{
XRRScreenConfiguration *xconfig;
XRRScreenSize *sizes;
int nSizes, currentSize = 0;
short *rates, currentRate;
int nRates, i, j;

XGLX_SCREEN_PRIV (pScreen);

xconfig = XRRGetScreenInfo (xdisplay, pScreenPriv->root);
sizes = XRRConfigSizes (xconfig, &nSizes);
currentRate = XRRConfigCurrentRate (xconfig);

if (pScreenPriv->fullscreen)
{
Rotation rotation;

currentSize = XRRConfigCurrentConfiguration (xconfig, &rotation);

for (i = 0; i < nSizes; i++)
{
pSize = RRRegisterSize (pScreen,
sizes[i].width,
sizes[i].height,
sizes[i].mwidth,
sizes[i].mheight);

rates = XRRConfigRates (xconfig, i, &nRates);

for (j = 0; j < nRates; j++)
{
RRRegisterRate (pScreen, pSize, rates[j]);

if (i == currentSize && rates[j] == currentRate)
RRSetCurrentConfig (pScreen, RR_Rotate_0, currentRate,
pSize);
}
}
}
else
{
pSize = RRRegisterSize (pScreen,
pScreen->width,
pScreen->height,
pScreen->mmWidth,
pScreen->mmHeight);

for (i = 0; i < nSizes; i++)
{
rates = XRRConfigRates (xconfig, i, &nRates);

for (j = 0; j < nRates; j++)
{
RRRegisterRate (pScreen, pSize, rates[j]);

if (rates[j] == currentRate)
RRSetCurrentConfig (pScreen, RR_Rotate_0, currentRate,
pSize);
}
}
}

XRRFreeScreenConfigInfo (xconfig);
}
else
{
pSize = RRRegisterSize (pScreen,
pScreen->width,
pScreen->height,
pScreen->mmWidth,
pScreen->mmHeight);

RRRegisterRate (pScreen, pSize, DEFAULT_REFRESH_RATE);
RRSetCurrentConfig (pScreen, RR_Rotate_0, DEFAULT_REFRESH_RATE, pSize);
}

#endif

return TRUE;
}

static Bool
vncRandRSetConfig (ScreenPtr pScreen,
Rotation rotations,
int rate,
RRScreenSizePtr pSize)
{
if (randrExtension)
{
XRRScreenConfiguration *xconfig;
XRRScreenSize *sizes;
int nSizes, currentSize;
int i, size = -1;
int status = RRSetConfigFailed;
Rotation rotation;

XGLX_SCREEN_PRIV (pScreen);

xconfig = XRRGetScreenInfo (xdisplay, pScreenPriv->root);
sizes = XRRConfigSizes (xconfig, &nSizes);
currentSize = XRRConfigCurrentConfiguration (xconfig, &rotation);

for (i = 0; i < nSizes; i++)
{
if (pScreenPriv->fullscreen)
{
if (sizes[i].width == pSize->width &&
sizes[i].height == pSize->height &&
sizes[i].mwidth == pSize->mmWidth &&
sizes[i].mheight == pSize->mmHeight)
{
size = i;
break;
}
}
else
{
short *rates;
int nRates, j;

rates = XRRConfigRates (xconfig, i, &nRates);

for (j = 0; j < nRates; j++)
{
if (rates[j] == rate)
{
size = i;
if (i >= currentSize)
break;
}
}
}
}

if (size >= 0)
status = XRRSetScreenConfigAndRate (xdisplay,
xconfig,
pScreenPriv->root,
size,
RR_Rotate_0,
rate,
CurrentTime);

XRRFreeScreenConfigInfo (xconfig);

if (status == RRSetConfigSuccess)
{
PixmapPtr pPixmap;

pPixmap = (*pScreen->GetScreenPixmap) (pScreen);

if (pScreenPriv->fullscreen)
{
XGL_PIXMAP_PRIV (pPixmap);

xglSetRootClip (pScreen, FALSE);

XResizeWindow (xdisplay, pScreenPriv->win,
pSize->width, pSize->height);

glitz_drawable_update_size (pPixmapPriv->drawable,
pSize->width, pSize->height);

pScreen->width = pSize->width;
pScreen->height = pSize->height;
pScreen->mmWidth = pSize->mmWidth;
pScreen->mmHeight = pSize->mmHeight;

(*pScreen->ModifyPixmapHeader) (pPixmap,
pScreen->width,
pScreen->height,
pPixmap->drawable.depth,
pPixmap->drawable.bitsPerPixel,
0, 0);

xglSetRootClip (pScreen, TRUE);
}

return TRUE;
}
}

return FALSE;
}

Bool vncRandRInit (ScreenPtr pScreen)
{
rrScrPrivPtr pScrPriv;

if (!RRScreenInit (pScreen))
return FALSE;

pScrPriv = rrGetScrPriv (pScreen);
pScrPriv->rrGetInfo = vncRandRGetInfo;
pScrPriv->rrSetConfig = vncRandRSetConfig;

return TRUE;
}

#endif
4 changes: 4 additions & 0 deletions xorg-server/hw/vnc/xvnc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ extern "C" {
unsigned long, char*);
extern void cfb32GetImage(DrawablePtr, int, int, int, int, unsigned int,
unsigned long, char*);
extern Bool vncRandRInit (ScreenPtr pScreen);

}

#define XVNCVERSION "Free Edition 4.1.2"
Expand Down Expand Up @@ -895,6 +897,8 @@ static Bool vfbScreenInit(int index, ScreenPtr pScreen, int argc, char** argv)
pScreen->backingStoreSupport = Always;
#endif

vncRandRInit(pScreen);

return ret;

} /* end vfbScreenInit */
Expand Down

0 comments on commit 77b4197

Please sign in to comment.