Merge branch 'randr-1.2'
Conflicts: dix/events.c dix/getevents.c hw/xfree86/common/xf86Mode.c hw/xfree86/dri/Makefile.am hw/xfree86/os-support/drm/xf86drm.c hw/xfree86/os-support/xf86drm.h
This commit is contained in:
commit
b4b0d901d9
|
@ -655,6 +655,9 @@ if test "x$DRI" = xyes; then
|
|||
PKG_CHECK_MODULES([DRIPROTO], [xf86driproto])
|
||||
PKG_CHECK_MODULES([LIBDRM], [libdrm >= 2.3.0])
|
||||
PKG_CHECK_MODULES([GL], [glproto >= 1.4.1])
|
||||
PKG_CHECK_EXISTS(libdrm >= 2.2.0,
|
||||
[AC_DEFINE([HAVE_LIBDRM_2_2], 1,
|
||||
[Has version 2.2 (or newer) of the drm library])])
|
||||
AC_SUBST(DRIPROTO_CFLAGS)
|
||||
AC_SUBST(LIBDRM_CFLAGS)
|
||||
AC_SUBST(LIBDRM_LIBS)
|
||||
|
@ -1759,13 +1762,11 @@ AM_CONDITIONAL(BUILD_KBD_MODE, [test x$BUILD_KBD_MODE = xyes])
|
|||
AM_CONDITIONAL(BSD_KBD_MODE, [test x$KBD_MODE_TYPE = xbsd])
|
||||
AM_CONDITIONAL(SUN_KBD_MODE, [test x$KBD_MODE_TYPE = xsun])
|
||||
|
||||
CFLAGS="$XSERVER_CFLAGS $CFLAGS"
|
||||
AC_SUBST([CFLAGS])
|
||||
|
||||
BUILD_DATE="$(date +'%Y%m%d')"
|
||||
AC_SUBST([BUILD_DATE])
|
||||
|
||||
DIX_CFLAGS="-DHAVE_DIX_CONFIG_H"
|
||||
DIX_CFLAGS="-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS"
|
||||
|
||||
AC_SUBST([DIX_CFLAGS])
|
||||
|
||||
AC_SUBST([libdir exec_prefix prefix])
|
||||
|
|
|
@ -330,8 +330,7 @@ static void ConfineToShape(RegionPtr shape, int *px, int *py);
|
|||
static void PostNewCursor(void);
|
||||
|
||||
#define SyntheticMotion(x, y) \
|
||||
PostSyntheticMotion(x, y, noPanoramiXExtension ? 0 : \
|
||||
sprite.screen->myNum, \
|
||||
PostSyntheticMotion(x, y, sprite.screen, \
|
||||
syncEvents.playingEvents ? \
|
||||
syncEvents.time.milliseconds : \
|
||||
currentTime.milliseconds);
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "cursorstr.h"
|
||||
#include "dixstruct.h"
|
||||
#include "globals.h"
|
||||
#include "dixevents.h"
|
||||
#include "mipointer.h"
|
||||
|
||||
#ifdef XKB
|
||||
|
@ -761,7 +762,7 @@ SwitchCorePointer(DeviceIntPtr pDev)
|
|||
* to shift the pointer to get it inside the new bounds.
|
||||
*/
|
||||
void
|
||||
PostSyntheticMotion(int x, int y, int screenNum, unsigned long time)
|
||||
PostSyntheticMotion(int x, int y, ScreenPtr pScreen, unsigned long time)
|
||||
{
|
||||
xEvent xE;
|
||||
|
||||
|
@ -770,8 +771,8 @@ PostSyntheticMotion(int x, int y, int screenNum, unsigned long time)
|
|||
will translate from sprite screen to screen 0 upon reentry
|
||||
to the DIX layer. */
|
||||
if (!noPanoramiXExtension) {
|
||||
x += panoramiXdataPtr[0].x - panoramiXdataPtr[screenNum].x;
|
||||
y += panoramiXdataPtr[0].y - panoramiXdataPtr[screenNum].y;
|
||||
x += panoramiXdataPtr[0].x - panoramiXdataPtr[pScreen->myNum].x;
|
||||
y += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -779,6 +780,7 @@ PostSyntheticMotion(int x, int y, int screenNum, unsigned long time)
|
|||
xE.u.u.type = MotionNotify;
|
||||
xE.u.keyButtonPointer.rootX = x;
|
||||
xE.u.keyButtonPointer.rootY = y;
|
||||
xE.u.keyButtonPointer.time = time;
|
||||
|
||||
(*inputInfo.pointer->public.processInputProc)(&xE, inputInfo.pointer, 1);
|
||||
}
|
||||
|
|
3
fb/fb.h
3
fb/fb.h
|
@ -1341,6 +1341,9 @@ fbCreateDefColormap(ScreenPtr pScreen);
|
|||
void
|
||||
fbClearVisualTypes(void);
|
||||
|
||||
Bool
|
||||
fbHasVisualTypes (int depth);
|
||||
|
||||
Bool
|
||||
fbSetVisualTypes (int depth, int visuals, int bitsPerRGB);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ endif
|
|||
|
||||
AM_YFLAGS = -d
|
||||
AM_CFLAGS = \
|
||||
\
|
||||
$(DIX_CFLAGS) \
|
||||
-I$(top_srcdir)/hw/dmx \
|
||||
$(GLX_INCS) \
|
||||
-DHAVE_DMX_CONFIG_H \
|
||||
|
|
|
@ -32,7 +32,7 @@ libglxproxy_a_SOURCES = compsize.c \
|
|||
unpack.h
|
||||
|
||||
AM_CFLAGS = \
|
||||
\
|
||||
$(DIX_CFLAGS) \
|
||||
-I$(top_srcdir)/hw/dmx \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/GL/include \
|
||||
|
|
|
@ -60,7 +60,7 @@ GLX_DEFS = @GL_CFLAGS@
|
|||
GLX_INCS = -I@MESA_SOURCE@/include
|
||||
endif
|
||||
|
||||
AM_CFLAGS = \
|
||||
AM_CFLAGS = $(DIX_CFLAGS) \
|
||||
-I$(top_srcdir)/hw/dmx \
|
||||
-I$(top_srcdir)/hw/xfree86/common \
|
||||
$(GLX_INCS) \
|
||||
|
|
|
@ -21,8 +21,8 @@ Xvfb_LDFLAGS =
|
|||
AM_CFLAGS = -DHAVE_DIX_CONFIG_H \
|
||||
-DNO_HW_ONLY_EXTS \
|
||||
-DNO_MODULE_EXTS \
|
||||
\
|
||||
$(XVFBMODULES_CFLAGS)
|
||||
$(XVFBMODULES_CFLAGS) \
|
||||
$(DIX_CFLAGS)
|
||||
|
||||
# Man page
|
||||
include $(top_srcdir)/cpprules.in
|
||||
|
|
|
@ -22,7 +22,7 @@ DIST_SUBDIRS = common ddc dummylib i2c x86emu int10 fbdevhw os-support \
|
|||
|
||||
bin_PROGRAMS = Xorg
|
||||
|
||||
AM_CFLAGS = @XORG_CFLAGS@
|
||||
AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
|
||||
INCLUDES = @XORG_INCS@
|
||||
|
||||
Xorg_SOURCES = xorg.c
|
||||
|
|
|
@ -94,4 +94,4 @@ if LNXACPI
|
|||
XORG_CFLAGS += -DHAVE_ACPI
|
||||
endif
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
|
|
@ -418,6 +418,14 @@ void xf86PruneDriverModes(ScrnInfoPtr scrp);
|
|||
void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
|
||||
void xf86PrintModes(ScrnInfoPtr scrp);
|
||||
void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges);
|
||||
double xf86ModeHSync(DisplayModePtr mode);
|
||||
double xf86ModeVRefresh(DisplayModePtr mode);
|
||||
void xf86SetModeDefaultName(DisplayModePtr mode);
|
||||
void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags);
|
||||
DisplayModePtr xf86DuplicateMode(DisplayModePtr pMode);
|
||||
DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList);
|
||||
Bool xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2);
|
||||
void xf86PrintModeline(int scrnIndex,DisplayModePtr mode);
|
||||
|
||||
/* xf86Option.c */
|
||||
|
||||
|
|
|
@ -368,8 +368,9 @@ xf86HandleBuiltinMode(ScrnInfoPtr scrp,
|
|||
return MODE_OK;
|
||||
}
|
||||
|
||||
static double
|
||||
ModeHSync(DisplayModePtr mode)
|
||||
/** Calculates the horizontal sync rate of a mode */
|
||||
_X_EXPORT double
|
||||
xf86ModeHSync(DisplayModePtr mode)
|
||||
{
|
||||
double hsync = 0.0;
|
||||
|
||||
|
@ -381,8 +382,9 @@ ModeHSync(DisplayModePtr mode)
|
|||
return hsync;
|
||||
}
|
||||
|
||||
static double
|
||||
ModeVRefresh(DisplayModePtr mode)
|
||||
/** Calculates the vertical refresh rate of a mode */
|
||||
_X_EXPORT double
|
||||
xf86ModeVRefresh(DisplayModePtr mode)
|
||||
{
|
||||
double refresh = 0.0;
|
||||
|
||||
|
@ -400,6 +402,16 @@ ModeVRefresh(DisplayModePtr mode)
|
|||
return refresh;
|
||||
}
|
||||
|
||||
/** Sets a default mode name of <width>x<height> on a mode. */
|
||||
_X_EXPORT void
|
||||
xf86SetModeDefaultName(DisplayModePtr mode)
|
||||
{
|
||||
if (mode->name != NULL)
|
||||
xfree(mode->name);
|
||||
|
||||
mode->name = XNFprintf("%dx%d", mode->HDisplay, mode->VDisplay);
|
||||
}
|
||||
|
||||
/*
|
||||
* xf86LookupMode
|
||||
*
|
||||
|
@ -529,7 +541,7 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
|
|||
ModePrivFlags = cp->PrivFlags;
|
||||
break;
|
||||
}
|
||||
refresh = ModeVRefresh(p);
|
||||
refresh = xf86ModeVRefresh(p);
|
||||
if (p->Flags & V_INTERLACE)
|
||||
refresh /= INTERLACE_REFRESH_WEIGHT;
|
||||
if (refresh > bestRefresh) {
|
||||
|
@ -570,7 +582,7 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
|
|||
found = TRUE;
|
||||
|
||||
if (strategy == LOOKUP_BEST_REFRESH) {
|
||||
refresh = ModeVRefresh(p);
|
||||
refresh = xf86ModeVRefresh(p);
|
||||
if (p->Flags & V_INTERLACE)
|
||||
refresh /= INTERLACE_REFRESH_WEIGHT;
|
||||
if (refresh > bestRefresh) {
|
||||
|
@ -674,7 +686,7 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
|
|||
* Initialises the Crtc parameters for a mode. The initialisation includes
|
||||
* adjustments for interlaced and double scan modes.
|
||||
*/
|
||||
static void
|
||||
_X_EXPORT void
|
||||
xf86SetModeCrtc(DisplayModePtr p, int adjustFlags)
|
||||
{
|
||||
if ((p == NULL) || ((p->type & M_T_CRTC_C) == M_T_BUILTIN))
|
||||
|
@ -756,6 +768,87 @@ xf86SetModeCrtc(DisplayModePtr p, int adjustFlags)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates and returns a copy of pMode, including pointers within pMode.
|
||||
*/
|
||||
_X_EXPORT DisplayModePtr
|
||||
xf86DuplicateMode(DisplayModePtr pMode)
|
||||
{
|
||||
DisplayModePtr pNew;
|
||||
|
||||
pNew = xnfalloc(sizeof(DisplayModeRec));
|
||||
*pNew = *pMode;
|
||||
pNew->next = NULL;
|
||||
pNew->prev = NULL;
|
||||
if (pNew->name == NULL) {
|
||||
xf86SetModeDefaultName(pMode);
|
||||
} else {
|
||||
pNew->name = xnfstrdup(pMode->name);
|
||||
}
|
||||
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicates every mode in the given list and returns a pointer to the first
|
||||
* mode.
|
||||
*
|
||||
* \param modeList doubly-linked mode list
|
||||
*/
|
||||
_X_EXPORT DisplayModePtr
|
||||
xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList)
|
||||
{
|
||||
DisplayModePtr first = NULL, last = NULL;
|
||||
DisplayModePtr mode;
|
||||
|
||||
for (mode = modeList; mode != NULL; mode = mode->next) {
|
||||
DisplayModePtr new;
|
||||
|
||||
new = xf86DuplicateMode(mode);
|
||||
|
||||
/* Insert pNew into modeList */
|
||||
if (last) {
|
||||
last->next = new;
|
||||
new->prev = last;
|
||||
} else {
|
||||
first = new;
|
||||
new->prev = NULL;
|
||||
}
|
||||
new->next = NULL;
|
||||
last = new;
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given modes should program to the same timings.
|
||||
*
|
||||
* This doesn't use Crtc values, as it might be used on ModeRecs without the
|
||||
* Crtc values set. So, it's assumed that the other numbers are enough.
|
||||
*/
|
||||
_X_EXPORT Bool
|
||||
xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2)
|
||||
{
|
||||
if (pMode1->Clock == pMode2->Clock &&
|
||||
pMode1->HDisplay == pMode2->HDisplay &&
|
||||
pMode1->HSyncStart == pMode2->HSyncStart &&
|
||||
pMode1->HSyncEnd == pMode2->HSyncEnd &&
|
||||
pMode1->HTotal == pMode2->HTotal &&
|
||||
pMode1->HSkew == pMode2->HSkew &&
|
||||
pMode1->VDisplay == pMode2->VDisplay &&
|
||||
pMode1->VSyncStart == pMode2->VSyncStart &&
|
||||
pMode1->VSyncEnd == pMode2->VSyncEnd &&
|
||||
pMode1->VTotal == pMode2->VTotal &&
|
||||
pMode1->VScan == pMode2->VScan &&
|
||||
pMode1->Flags == pMode2->Flags)
|
||||
{
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* xf86CheckModeForMonitor
|
||||
*
|
||||
|
@ -789,7 +882,7 @@ xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
|
|||
|
||||
if (monitor->nHsync > 0) {
|
||||
/* Check hsync against the allowed ranges */
|
||||
float hsync = ModeHSync(mode);
|
||||
float hsync = xf86ModeHSync(mode);
|
||||
for (i = 0; i < monitor->nHsync; i++)
|
||||
if ((hsync > monitor->hsync[i].lo * (1.0 - SYNC_TOLERANCE)) &&
|
||||
(hsync < monitor->hsync[i].hi * (1.0 + SYNC_TOLERANCE)))
|
||||
|
@ -802,7 +895,7 @@ xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
|
|||
|
||||
if (monitor->nVrefresh > 0) {
|
||||
/* Check vrefresh against the allowed ranges */
|
||||
float vrefrsh = ModeVRefresh(mode);
|
||||
float vrefrsh = xf86ModeVRefresh(mode);
|
||||
for (i = 0; i < monitor->nVrefresh; i++)
|
||||
if ((vrefrsh > monitor->vrefresh[i].lo * (1.0 - SYNC_TOLERANCE)) &&
|
||||
(vrefrsh < monitor->vrefresh[i].hi * (1.0 + SYNC_TOLERANCE)))
|
||||
|
@ -1033,8 +1126,8 @@ xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
|
|||
/ (mode->CrtcHTotal * mode->CrtcVTotal);
|
||||
}
|
||||
|
||||
mode->HSync = ModeHSync(mode);
|
||||
mode->VRefresh = ModeVRefresh(mode);
|
||||
mode->HSync = xf86ModeHSync(mode);
|
||||
mode->VRefresh = xf86ModeVRefresh(mode);
|
||||
|
||||
/* Assume it is OK */
|
||||
return MODE_OK;
|
||||
|
@ -1572,7 +1665,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
|
|||
"TargetRefresh", 0.0);
|
||||
if (targetRefresh > 0.0) {
|
||||
for (p = scrp->modePool; p != NULL; p = p->next) {
|
||||
if (ModeVRefresh(p) > targetRefresh * (1.0 - SYNC_TOLERANCE))
|
||||
if (xf86ModeVRefresh(p) > targetRefresh * (1.0 - SYNC_TOLERANCE))
|
||||
break;
|
||||
}
|
||||
if (!p)
|
||||
|
@ -1661,7 +1754,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
|
|||
* If there is a target refresh rate, skip modes that
|
||||
* don't match up.
|
||||
*/
|
||||
if (ModeVRefresh(q) <
|
||||
if (xf86ModeVRefresh(q) <
|
||||
(1.0 - SYNC_TOLERANCE) * targetRefresh)
|
||||
continue;
|
||||
|
||||
|
@ -1981,8 +2074,8 @@ add(char **p, char *new)
|
|||
strcat(*p, new);
|
||||
}
|
||||
|
||||
static void
|
||||
PrintModeline(int scrnIndex,DisplayModePtr mode)
|
||||
_X_EXPORT void
|
||||
xf86PrintModeline(int scrnIndex,DisplayModePtr mode)
|
||||
{
|
||||
char tmp[256];
|
||||
char *flags = xnfcalloc(1, 1);
|
||||
|
@ -2037,8 +2130,8 @@ xf86PrintModes(ScrnInfoPtr scrp)
|
|||
|
||||
do {
|
||||
desc = desc2 = "";
|
||||
hsync = ModeHSync(p);
|
||||
refresh = ModeVRefresh(p);
|
||||
hsync = xf86ModeHSync(p);
|
||||
refresh = xf86ModeVRefresh(p);
|
||||
if (p->Flags & V_INTERLACE) {
|
||||
desc = " (I)";
|
||||
}
|
||||
|
@ -2081,7 +2174,7 @@ xf86PrintModes(ScrnInfoPtr scrp)
|
|||
p->SynthClock / 1000.0, hsync, refresh, desc, desc2);
|
||||
}
|
||||
if (hsync != 0 && refresh != 0)
|
||||
PrintModeline(scrp->scrnIndex,p);
|
||||
xf86PrintModeline(scrp->scrnIndex,p);
|
||||
p = p->next;
|
||||
} while (p != NULL && p != scrp->modes);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,6 @@ libddc_la_SOURCES = xf86DDC.c edid.c interpret_edid.c print_edid.c \
|
|||
|
||||
INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
||||
EXTRA_DIST = ddcPriv.h DDC.HOWTO
|
||||
|
|
|
@ -11,7 +11,7 @@ if XV
|
|||
XV_SRCS = xvmod.c xvmodproc.h
|
||||
endif
|
||||
|
||||
AM_CFLAGS = @XORG_CFLAGS@
|
||||
AM_CFLAGS = @DIX_CFLAGS@ @XORG_CFLAGS@
|
||||
INCLUDES = @XORG_INCS@ \
|
||||
-I$(top_srcdir)/afb \
|
||||
-I$(top_srcdir)/mfb \
|
||||
|
|
|
@ -7,7 +7,7 @@ libdri_la_CFLAGS = -I$(top_srcdir)/hw/xfree86/common \
|
|||
-I$(top_builddir)/GL/include \
|
||||
-I@MESA_SOURCE@/include \
|
||||
-DHAVE_XORG_CONFIG_H \
|
||||
@DRIPROTO_CFLAGS@ \
|
||||
@DIX_CFLAGS@ @DRIPROTO_CFLAGS@ \
|
||||
@LIBDRM_CFLAGS@ \
|
||||
@GL_CFLAGS@
|
||||
libdri_la_LDFLAGS = -module -avoid-version @LIBDRM_LIBS@
|
||||
|
|
|
@ -6,7 +6,7 @@ noinst_LIBRARIES = libdummy-nonserver.a
|
|||
|
||||
INCLUDES = $(XORG_INCS)
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
||||
if NEED_STRLCAT
|
||||
STRL_SRCS = $(top_srcdir)/os/strlcat.c $(top_srcdir)/os/strlcpy.c
|
||||
|
|
|
@ -7,7 +7,7 @@ INCLUDES = \
|
|||
-I$(srcdir)/../../../exa \
|
||||
-I$(srcdir)/../../../miext/cw
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
||||
libexa_la_SOURCES = \
|
||||
examodule.c
|
||||
|
|
|
@ -11,7 +11,7 @@ endif
|
|||
|
||||
INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
||||
sdk_HEADERS = fbdevhw.h
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ libi2c_la_SOURCES = xf86i2c.c xf86i2cmodule.c
|
|||
|
||||
INCLUDES = $(XORG_INCS)
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
||||
sdk_HEADERS = xf86i2c.h bt829.h fi1236.h msp3430.h tda8425.h tda9850.h tda9885.h uda1380.h i2c_def.h
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ I386_VIDEO_CFLAGS = -D_PC
|
|||
endif
|
||||
|
||||
if INT10_VM86
|
||||
AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(XORG_CFLAGS) $(EXTRA_CFLAGS)
|
||||
AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS)
|
||||
INCLUDES = $(XORG_INCS)
|
||||
libint10_la_SOURCES = \
|
||||
$(COMMON_SOURCES) \
|
||||
|
@ -28,7 +28,7 @@ endif
|
|||
|
||||
if INT10_X86EMU
|
||||
AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_X86EMU -DNO_SYS_HEADERS \
|
||||
$(XORG_CFLAGS) $(EXTRA_CFLAGS)
|
||||
$(XORG_CFLAGS) $(EXTRA_CFLAGS) $(DIX_CFLAGS)
|
||||
INCLUDES = $(XORG_INCS) -I$(srcdir)/../x86emu
|
||||
libint10_la_SOURCES = \
|
||||
$(COMMON_SOURCES) \
|
||||
|
@ -38,7 +38,7 @@ libint10_la_SOURCES = \
|
|||
endif
|
||||
|
||||
if INT10_STUB
|
||||
AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(XORG_CFLAGS) $(EXTRA_CFLAGS)
|
||||
AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS)
|
||||
libint10_la_SOURCES = stub.c xf86int10module.c
|
||||
endif
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(srcdir)/../dixmods/extmod \
|
|||
-I$(srcdir)/../ddc -I$(srcdir)/../i2c
|
||||
|
||||
#AM_LDFLAGS = -r
|
||||
AM_CFLAGS = -DIN_LOADER $(XORG_CFLAGS)
|
||||
AM_CFLAGS = -DIN_LOADER $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
||||
if XORG_LOADER_SPARC
|
||||
SPARC_SOURCES = SparcMulDiv.S
|
||||
|
|
|
@ -15,6 +15,8 @@ libxorgos_la_LIBADD = @XORG_OS_SUBDIR@/lib@XORG_OS_SUBDIR@.la \
|
|||
bus/libbus.la \
|
||||
misc/libmisc.la
|
||||
|
||||
AM_CFLAGS = $(DIX_CFLAGS)
|
||||
|
||||
xorgos.c:
|
||||
touch $@
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ ARCH_SOURCES = \
|
|||
endif
|
||||
|
||||
# FIXME: NetBSD Aperture defines (configure.ac)
|
||||
AM_CFLAGS = -DUSESTDRES $(XORG_CFLAGS)
|
||||
AM_CFLAGS = -DUSESTDRES $(XORG_CFLAGS) $(DIX_CFLAGS)
|
||||
|
||||
INCLUDES = $(XORG_INCS)
|
||||
|
||||
|
|
|
@ -53,6 +53,6 @@ libbus_la_SOURCES = Pci.c Pci.h $(PCI_SOURCES) $(PLATFORM_PCI_SOURCES) \
|
|||
|
||||
INCLUDES = $(XORG_INCS)
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
|
||||
|
||||
EXTRA_DIST = $(sdk_HEADERS)
|
||||
|
|
|
@ -12,6 +12,6 @@ libhurd_la_SOURCES = hurd_bell.c hurd_init.c hurd_mmap.c \
|
|||
$(srcdir)/../shared/kmod_noop.c \
|
||||
$(srcdir)/../shared/agp_noop.c
|
||||
|
||||
AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS)
|
||||
AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(DIX_CFLAGS)
|
||||
|
||||
INCLUDES = $(XORG_INCS)
|
||||
|
|
|
@ -34,7 +34,7 @@ liblinux_la_SOURCES = lnx_init.c lnx_video.c lnx_mouse.c \
|
|||
$(APM_SRCS) \
|
||||
$(PLATFORM_PCI_SUPPORT)
|
||||
|
||||
AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(PLATFORM_DEFINES)
|
||||
AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(DIX_CFLAGS) $(XORG_CFLAGS) $(PLATFORM_DEFINES)
|
||||
|
||||
INCLUDES = $(XORG_INCS) $(PLATFORM_INCLUDES) -I/usr/include/drm # FIXME this last part is crack
|
||||
|
||||
|
|
|
@ -18,6 +18,6 @@ libmisc_la_SOURCES = xf86_Util.c Delay.c $(ARCH_SRCS)
|
|||
|
||||
INCLUDES = $(XORG_INCS)
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
|
||||
|
||||
EXTRA_DIST = $(I386_SRCS) $(PORTIO_SRCS) $(ILHACK_SRCS)
|
||||
|
|
|
@ -30,7 +30,7 @@ nodist_libsolaris_la_SOURCES = $(SOLARIS_INOUT_SRC)
|
|||
sdk_HEADERS = agpgart.h
|
||||
nodist_sdk_HEADERS = solaris-$(SOLARIS_INOUT_ARCH).il
|
||||
|
||||
AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS)
|
||||
AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(DIX_CFLAGS)
|
||||
|
||||
INCLUDES = $(XORG_INCS)
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ libxf86config_a_SOURCES = \
|
|||
DRI.c \
|
||||
Extensions.c
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
||||
EXTRA_DIST = \
|
||||
Configint.h \
|
||||
|
|
|
@ -5,4 +5,4 @@ sdk_HEADERS = xf86RAC.h
|
|||
|
||||
INCLUDES = $(XORG_INCS)
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
|
|
@ -13,7 +13,7 @@ EXTRA_DIST = BTPriv.h IBMPriv.h TIPriv.h xf86CursorPriv.h xf86RamDacPriv.h \
|
|||
CURSOR.NOTES
|
||||
|
||||
AM_CFLAGS = -DXAAReverseBitOrder=xf86ReverseBitOrder -DRAMDAC_MODULE \
|
||||
$(XORG_CFLAGS)
|
||||
$(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
INCLUDES = $(XORG_INCS)
|
||||
|
||||
xf86BitOrder.c:
|
||||
|
|
|
@ -8,7 +8,7 @@ libscanpci_la_SOURCES = xf86ScanPci.c
|
|||
|
||||
INCLUDES = $(XORG_INCS)
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
||||
BUILT_SOURCES = xf86PciIds.h
|
||||
|
||||
|
|
|
@ -6,4 +6,4 @@ sdk_HEADERS = shadowfb.h
|
|||
|
||||
INCLUDES = $(XORG_INCS)
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
|
|
@ -4,7 +4,7 @@ libvbe_la_SOURCES = vbe.c vbeModes.c vbe_module.c
|
|||
|
||||
sdk_HEADERS = vbe.h vbeModes.h
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
||||
INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \
|
||||
-I$(srcdir)/../int10
|
||||
|
|
|
@ -2,7 +2,7 @@ module_LTLIBRARIES = libvgahw.la
|
|||
libvgahw_la_LDFLAGS = -avoid-version
|
||||
libvgahw_la_SOURCES = vgaHW.c vgaHWmodule.c
|
||||
INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
||||
sdk_HEADERS = vgaHW.h
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ libx86emu_a_SOURCES = debug.c \
|
|||
|
||||
INCLUDES =
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
||||
EXTRA_DIST = validate.c \
|
||||
x86emu/debug.h \
|
||||
|
|
|
@ -68,4 +68,4 @@ EXTRA_DIST = xaacexp.h xaawrap.h xaaLine.c xaaDashLine.c \
|
|||
|
||||
INCLUDES = $(XORG_INCS)
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
|
|
@ -59,4 +59,4 @@ mfbseg.c:
|
|||
|
||||
INCLUDES = $(XORG_INCS) -I$(srcdir)/../xf1bpp -I$(top_srcdir)/mfb
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
|
|
@ -4,7 +4,7 @@ sdk_HEADERS = cfb8_16.h
|
|||
|
||||
INCLUDES = $(XORG_INCS) -I$(top_srcdir)/fb
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
||||
libxf8_16bpp_la_LDFLAGS = -avoid-version
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ sdk_HEADERS = cfb8_32.h
|
|||
|
||||
INCLUDES = $(XORG_INCS) -I$(top_srcdir)/mfb -I$(top_srcdir)/cfb
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS)
|
||||
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
|
||||
|
||||
libxf8_32bpp_la_LDFLAGS = -avoid-version
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ SUBDIRS = \
|
|||
$(XEGL_SUBDIRS)
|
||||
|
||||
AM_CFLAGS = \
|
||||
\
|
||||
$(DIX_CFLAGS) \
|
||||
-DHAVE_XGL_CONFIG_H \
|
||||
-DHAVE_DIX_CONFIG_H \
|
||||
-I$(top_srcdir)/GL/glx \
|
||||
|
|
|
@ -9,7 +9,7 @@ SUBDIRS = \
|
|||
$(XGL_MODULE_DIRS)
|
||||
|
||||
AM_CFLAGS = \
|
||||
\
|
||||
$(DIX_CFLAGS) \
|
||||
-DHAVE_XGL_CONFIG_H \
|
||||
-DHAVE_DIX_CONFIG_H \
|
||||
$(XEGLMODULES_CFLAGS)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
AM_CFLAGS = \
|
||||
$(DIX_CFLAGS) \
|
||||
-I$(srcdir)/.. \
|
||||
-I$(srcdir)/../.. \
|
||||
$(XEGLMODULES_CFLAGS)
|
||||
|
|
|
@ -15,7 +15,7 @@ AM_CFLAGS = \
|
|||
-I$(top_srcdir)/GL/include \
|
||||
-I@MESA_SOURCE@/include \
|
||||
-I@MESA_SOURCE@/src/mesa/glapi \
|
||||
\
|
||||
$(DIX_CFLAGS) \
|
||||
-DHAVE_XGL_CONFIG_H \
|
||||
-DHAVE_DIX_CONFIG_H \
|
||||
$(XGLXMODULES_CFLAGS)
|
||||
|
|
|
@ -2,7 +2,7 @@ if GLX
|
|||
GLX_LIB = $(top_builddir)/hw/xgl/glxext/libxglglxext.la
|
||||
endif
|
||||
|
||||
AM_CFLAGS = \
|
||||
AM_CFLAGS = $(DIX_CFLAGS) \
|
||||
-I$(srcdir)/.. \
|
||||
-I$(srcdir)/../.. \
|
||||
$(XGLXMODULES_CFLAGS)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
SUBDIRS = module
|
||||
|
||||
AM_CFLAGS = \
|
||||
\
|
||||
$(DIX_CFLAGS) \
|
||||
-DHAVE_XGL_CONFIG_H \
|
||||
-DHAVE_DIX_CONFIG_H \
|
||||
$(XGLMODULES_CFLAGS) \
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
AM_CFLAGS = \
|
||||
\
|
||||
$(DIX_CFLAGS) \
|
||||
-DHAVE_XGL_CONFIG_H \
|
||||
-DHAVE_DIX_CONFIG_H \
|
||||
$(XGLMODULES_CFLAGS) \
|
||||
|
|
|
@ -161,7 +161,7 @@ CLEANFILES = $(BUILT_SOURCES)
|
|||
|
||||
AM_YFLAGS = -d
|
||||
AM_LFLAGS = -i
|
||||
AM_CFLAGS = -DHAVE_XWIN_CONFIG_H \
|
||||
AM_CFLAGS = -DHAVE_XWIN_CONFIG_H $(DIX_CFLAGS) \
|
||||
$(XWINMODULES_CFLAGS)
|
||||
|
||||
dist_man1_MANS = XWin.man XWinrc.man
|
||||
|
|
|
@ -127,6 +127,9 @@
|
|||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have version 2.2 (or newer) of the drm library */
|
||||
#undef HAVE_LIBDRM_2_2
|
||||
|
||||
/* Define to 1 if you have the `m' library (-lm). */
|
||||
#undef HAVE_LIBM
|
||||
|
||||
|
|
|
@ -102,4 +102,8 @@ extern int ProcUngrabButton(ClientPtr /* client */);
|
|||
|
||||
extern int ProcRecolorCursor(ClientPtr /* client */);
|
||||
|
||||
#ifdef PANORAMIX
|
||||
extern void PostSyntheticMotion(int x, int y, ScreenPtr pScreen, unsigned long time);
|
||||
#endif
|
||||
|
||||
#endif /* DIXEVENTS_H */
|
||||
|
|
|
@ -421,7 +421,7 @@ extern int GetProximityEvents(
|
|||
extern void PostSyntheticMotion(
|
||||
int x,
|
||||
int y,
|
||||
int screenNum,
|
||||
ScreenPtr pScreen,
|
||||
unsigned long time);
|
||||
|
||||
extern int GetMotionHistorySize(
|
||||
|
|
|
@ -9,4 +9,14 @@ endif
|
|||
librandr_la_SOURCES = \
|
||||
mirandr.c \
|
||||
randr.c \
|
||||
randrstr.h
|
||||
randrstr.h \
|
||||
rrcrtc.c \
|
||||
rrdispatch.c \
|
||||
rrinfo.c \
|
||||
rrmode.c \
|
||||
rroutput.c \
|
||||
rrpointer.c \
|
||||
rrproperty.c \
|
||||
rrscreen.c \
|
||||
rrsdispatch.c \
|
||||
rrxinerama.c
|
||||
|
|
178
randr/mirandr.c
178
randr/mirandr.c
|
@ -1,39 +1,77 @@
|
|||
/*
|
||||
*
|
||||
* Copyright © 2000, Compaq Computer Corporation,
|
||||
* Copyright © 2002, Hewlett Packard, Inc.
|
||||
* Copyright © 2000 Compaq Computer Corporation
|
||||
* Copyright © 2002 Hewlett-Packard Company
|
||||
* Copyright © 2006 Intel Corporation
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Compaq or HP not be used in advertising
|
||||
* or publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. HP makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP
|
||||
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: Jim Gettys, HP Labs, Hewlett-Packard, Inc.
|
||||
* Author: Jim Gettys, Hewlett-Packard Company, Inc.
|
||||
* Keith Packard, Intel Corporation
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include "scrnintstr.h"
|
||||
#include "mi.h"
|
||||
#include <X11/extensions/randr.h>
|
||||
#include "randrstr.h"
|
||||
#include <stdio.h>
|
||||
|
||||
Bool
|
||||
miRRGetInfo (ScreenPtr pScreen, Rotation *rotations)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Any hardware that can actually change anything will need something
|
||||
* different here
|
||||
*/
|
||||
Bool
|
||||
miRRCrtcSet (ScreenPtr pScreen,
|
||||
RRCrtcPtr crtc,
|
||||
RRModePtr mode,
|
||||
int x,
|
||||
int y,
|
||||
Rotation rotation,
|
||||
int numOutput,
|
||||
RROutputPtr *outputs)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
miRRCrtcSetGamma (ScreenPtr pScreen,
|
||||
RRCrtcPtr crtc)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
miRROutputSetProperty (ScreenPtr pScreen,
|
||||
RROutputPtr output,
|
||||
Atom property)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function assumes that only a single depth can be
|
||||
* displayed at a time, but that all visuals of that depth
|
||||
|
@ -43,59 +81,65 @@
|
|||
* XXX what to do here....
|
||||
*/
|
||||
|
||||
Bool
|
||||
miRRGetInfo (ScreenPtr pScreen, Rotation *rotations)
|
||||
{
|
||||
int i;
|
||||
Bool setConfig = FALSE;
|
||||
|
||||
*rotations = RR_Rotate_0;
|
||||
for (i = 0; i < pScreen->numDepths; i++)
|
||||
{
|
||||
if (pScreen->allowedDepths[i].numVids)
|
||||
{
|
||||
RRScreenSizePtr pSize;
|
||||
|
||||
pSize = RRRegisterSize (pScreen,
|
||||
pScreen->width,
|
||||
pScreen->height,
|
||||
pScreen->mmWidth,
|
||||
pScreen->mmHeight);
|
||||
if (!pSize)
|
||||
return FALSE;
|
||||
if (!setConfig)
|
||||
{
|
||||
RRSetCurrentConfig (pScreen, RR_Rotate_0, 0, pSize);
|
||||
setConfig = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Any hardware that can actually change anything will need something
|
||||
* different here
|
||||
*/
|
||||
Bool
|
||||
miRRSetConfig (ScreenPtr pScreen,
|
||||
Rotation rotation,
|
||||
int rate,
|
||||
RRScreenSizePtr pSize)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
miRandRInit (ScreenPtr pScreen)
|
||||
{
|
||||
rrScrPrivPtr rp;
|
||||
rrScrPrivPtr pScrPriv;
|
||||
#if RANDR_12_INTERFACE
|
||||
RRModePtr mode;
|
||||
RRCrtcPtr crtc;
|
||||
RROutputPtr output;
|
||||
xRRModeInfo modeInfo;
|
||||
char name[64];
|
||||
#endif
|
||||
|
||||
if (!RRScreenInit (pScreen))
|
||||
return FALSE;
|
||||
rp = rrGetScrPriv(pScreen);
|
||||
rp->rrGetInfo = miRRGetInfo;
|
||||
rp->rrSetConfig = miRRSetConfig;
|
||||
pScrPriv = rrGetScrPriv(pScreen);
|
||||
pScrPriv->rrGetInfo = miRRGetInfo;
|
||||
#if RANDR_12_INTERFACE
|
||||
pScrPriv->rrCrtcSet = miRRCrtcSet;
|
||||
pScrPriv->rrCrtcSetGamma = miRRCrtcSetGamma;
|
||||
pScrPriv->rrOutputSetProperty = miRROutputSetProperty;
|
||||
|
||||
|
||||
RRScreenSetSizeRange (pScreen,
|
||||
pScreen->width, pScreen->height,
|
||||
pScreen->width, pScreen->height);
|
||||
|
||||
sprintf (name, "%dx%d", pScreen->width, pScreen->height);
|
||||
memset (&modeInfo, '\0', sizeof (modeInfo));
|
||||
modeInfo.width = pScreen->width;
|
||||
modeInfo.height = pScreen->height;
|
||||
modeInfo.nameLength = strlen (name);
|
||||
|
||||
mode = RRModeGet (&modeInfo, name);
|
||||
if (!mode)
|
||||
return FALSE;
|
||||
|
||||
crtc = RRCrtcCreate (NULL);
|
||||
if (!crtc)
|
||||
return FALSE;
|
||||
if (!RRCrtcAttachScreen (crtc, pScreen))
|
||||
{
|
||||
RRCrtcDestroy (crtc);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
output = RROutputCreate ("screen", 6, NULL);
|
||||
if (!output)
|
||||
return FALSE;
|
||||
if (!RROutputAttachScreen (output, pScreen))
|
||||
return FALSE;
|
||||
if (!RROutputSetClones (output, NULL, 0))
|
||||
return FALSE;
|
||||
if (!RROutputSetModes (output, &mode, 1, 0))
|
||||
return FALSE;
|
||||
if (!RROutputSetCrtcs (output, &crtc, 1))
|
||||
return FALSE;
|
||||
if (!RROutputSetConnection (output, RR_Connected))
|
||||
return FALSE;
|
||||
RRCrtcNotify (crtc, mode, 0, 0, RR_Rotate_0, 1, &output);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
|
1319
randr/randr.c
1319
randr/randr.c
File diff suppressed because it is too large
Load Diff
705
randr/randrstr.h
705
randr/randrstr.h
|
@ -1,24 +1,28 @@
|
|||
/*
|
||||
*
|
||||
* Copyright © 2000 Compaq Computer Corporation
|
||||
* Copyright © 2002 Hewlett-Packard Company
|
||||
* Copyright © 2006 Intel Corporation
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Compaq not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Compaq makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* COMPAQ DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL COMPAQ BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: Jim Gettys, Hewlett-Packard Company, Inc.
|
||||
* Keith Packard, Intel Corporation
|
||||
*/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
|
@ -28,56 +32,198 @@
|
|||
#ifndef _RANDRSTR_H_
|
||||
#define _RANDRSTR_H_
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include "misc.h"
|
||||
#include "os.h"
|
||||
#include "dixstruct.h"
|
||||
#include "resource.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "windowstr.h"
|
||||
#include "pixmapstr.h"
|
||||
#include "extnsionst.h"
|
||||
#include "servermd.h"
|
||||
#include <X11/extensions/randr.h>
|
||||
#include <X11/extensions/randrproto.h>
|
||||
#ifdef RENDER
|
||||
#include <X11/extensions/render.h> /* we share subpixel order information */
|
||||
#include "picturestr.h"
|
||||
#endif
|
||||
#include <X11/Xfuncproto.h>
|
||||
|
||||
typedef struct _rrScreenRate {
|
||||
int rate;
|
||||
Bool referenced;
|
||||
Bool oldReferenced;
|
||||
/* required for ABI compatibility for now */
|
||||
#define RANDR_10_INTERFACE 1
|
||||
#define RANDR_12_INTERFACE 1
|
||||
|
||||
typedef XID RRMode;
|
||||
typedef XID RROutput;
|
||||
typedef XID RRCrtc;
|
||||
|
||||
extern int RREventBase, RRErrorBase;
|
||||
|
||||
extern int (*ProcRandrVector[RRNumberRequests])(ClientPtr);
|
||||
extern int (*SProcRandrVector[RRNumberRequests])(ClientPtr);
|
||||
|
||||
/*
|
||||
* Modeline for a monitor. Name follows directly after this struct
|
||||
*/
|
||||
|
||||
#define RRModeName(pMode) ((char *) (pMode + 1))
|
||||
typedef struct _rrMode RRModeRec, *RRModePtr;
|
||||
typedef struct _rrCrtc RRCrtcRec, *RRCrtcPtr;
|
||||
typedef struct _rrOutput RROutputRec, *RROutputPtr;
|
||||
|
||||
struct _rrMode {
|
||||
int refcnt;
|
||||
xRRModeInfo mode;
|
||||
char *name;
|
||||
void *devPrivate;
|
||||
Bool userDefined;
|
||||
};
|
||||
|
||||
struct _rrCrtc {
|
||||
RRCrtc id;
|
||||
ScreenPtr pScreen;
|
||||
RRModePtr mode;
|
||||
int x, y;
|
||||
Rotation rotation;
|
||||
Rotation rotations;
|
||||
Bool changed;
|
||||
int numOutputs;
|
||||
RROutputPtr *outputs;
|
||||
int gammaSize;
|
||||
CARD16 *gammaRed;
|
||||
CARD16 *gammaBlue;
|
||||
CARD16 *gammaGreen;
|
||||
void *devPrivate;
|
||||
};
|
||||
|
||||
struct _rrOutput {
|
||||
RROutput id;
|
||||
ScreenPtr pScreen;
|
||||
char *name;
|
||||
int nameLength;
|
||||
CARD8 connection;
|
||||
CARD8 subpixelOrder;
|
||||
int mmWidth;
|
||||
int mmHeight;
|
||||
RRCrtcPtr crtc;
|
||||
int numCrtcs;
|
||||
RRCrtcPtr *crtcs;
|
||||
int numClones;
|
||||
RROutputPtr *clones;
|
||||
int numModes;
|
||||
int numPreferred;
|
||||
RRModePtr *modes;
|
||||
Bool changed;
|
||||
PropertyPtr properties;
|
||||
void *devPrivate;
|
||||
};
|
||||
|
||||
#if RANDR_12_INTERFACE
|
||||
typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr pScreen,
|
||||
CARD16 width,
|
||||
CARD16 height,
|
||||
CARD32 mmWidth,
|
||||
CARD32 mmHeight);
|
||||
|
||||
typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen,
|
||||
RRCrtcPtr crtc,
|
||||
RRModePtr mode,
|
||||
int x,
|
||||
int y,
|
||||
Rotation rotation,
|
||||
int numOutputs,
|
||||
RROutputPtr *outputs);
|
||||
|
||||
typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr pScreen,
|
||||
RRCrtcPtr crtc);
|
||||
|
||||
typedef Bool (*RROutputSetPropertyProcPtr) (ScreenPtr pScreen,
|
||||
RROutputPtr output,
|
||||
Atom property);
|
||||
|
||||
#endif
|
||||
|
||||
typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations);
|
||||
typedef Bool (*RRCloseScreenProcPtr) ( int i, ScreenPtr pscreen);
|
||||
|
||||
/* These are for 1.0 compatibility */
|
||||
|
||||
typedef struct _rrRefresh {
|
||||
CARD16 rate;
|
||||
RRModePtr mode;
|
||||
} RRScreenRate, *RRScreenRatePtr;
|
||||
|
||||
typedef struct _rrScreenSize {
|
||||
int id;
|
||||
short width, height;
|
||||
short mmWidth, mmHeight;
|
||||
RRScreenRatePtr pRates;
|
||||
int nRates;
|
||||
int nRatesInUse;
|
||||
Bool referenced;
|
||||
Bool oldReferenced;
|
||||
RRScreenRatePtr pRates;
|
||||
} RRScreenSize, *RRScreenSizePtr;
|
||||
|
||||
#ifdef RANDR_10_INTERFACE
|
||||
|
||||
typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen,
|
||||
Rotation rotation,
|
||||
int rate,
|
||||
RRScreenSizePtr pSize);
|
||||
|
||||
typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations);
|
||||
typedef Bool (*RRCloseScreenProcPtr) ( int i, ScreenPtr pscreen);
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct _rrScrPriv {
|
||||
/*
|
||||
* 'public' part of the structure; DDXen fill this in
|
||||
* as they initialize
|
||||
*/
|
||||
#if RANDR_10_INTERFACE
|
||||
RRSetConfigProcPtr rrSetConfig;
|
||||
#endif
|
||||
RRGetInfoProcPtr rrGetInfo;
|
||||
#if RANDR_12_INTERFACE
|
||||
RRScreenSetSizeProcPtr rrScreenSetSize;
|
||||
RRCrtcSetProcPtr rrCrtcSet;
|
||||
RRCrtcSetGammaProcPtr rrCrtcSetGamma;
|
||||
RROutputSetPropertyProcPtr rrOutputSetProperty;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Private part of the structure; not considered part of the ABI
|
||||
*/
|
||||
TimeStamp lastSetTime; /* last changed by client */
|
||||
TimeStamp lastConfigTime; /* possible configs changed */
|
||||
RRCloseScreenProcPtr CloseScreen;
|
||||
Bool changed; /* some config changed */
|
||||
CARD16 minWidth, minHeight;
|
||||
CARD16 maxWidth, maxHeight;
|
||||
CARD16 width, height; /* last known screen size */
|
||||
Bool layoutChanged; /* screen layout changed */
|
||||
|
||||
int numOutputs;
|
||||
RROutputPtr *outputs;
|
||||
|
||||
int numCrtcs;
|
||||
RRCrtcPtr *crtcs;
|
||||
|
||||
/* Last known pointer position */
|
||||
RRCrtcPtr pointerCrtc;
|
||||
|
||||
#ifdef RANDR_10_INTERFACE
|
||||
/*
|
||||
* Configuration information
|
||||
*/
|
||||
Rotation rotations;
|
||||
CARD16 reqWidth, reqHeight;
|
||||
|
||||
int nSizes;
|
||||
int nSizesInUse;
|
||||
RRScreenSizePtr pSizes;
|
||||
|
||||
/*
|
||||
* Current state
|
||||
*/
|
||||
|
||||
Rotation rotation;
|
||||
int size;
|
||||
int rate;
|
||||
int size;
|
||||
#endif
|
||||
} rrScrPrivRec, *rrScrPrivPtr;
|
||||
|
||||
extern int rrPrivIndex;
|
||||
|
@ -86,10 +232,169 @@ extern int rrPrivIndex;
|
|||
#define rrScrPriv(pScr) rrScrPrivPtr pScrPriv = rrGetScrPriv(pScr)
|
||||
#define SetRRScreen(s,p) ((s)->devPrivates[rrPrivIndex].ptr = (pointer) (p))
|
||||
|
||||
/*
|
||||
* each window has a list of clients requesting
|
||||
* RRNotify events. Each client has a resource
|
||||
* for each window it selects RRNotify input for,
|
||||
* this resource is used to delete the RRNotifyRec
|
||||
* entry from the per-window queue.
|
||||
*/
|
||||
|
||||
typedef struct _RREvent *RREventPtr;
|
||||
|
||||
typedef struct _RREvent {
|
||||
RREventPtr next;
|
||||
ClientPtr client;
|
||||
WindowPtr window;
|
||||
XID clientResource;
|
||||
int mask;
|
||||
} RREventRec;
|
||||
|
||||
typedef struct _RRTimes {
|
||||
TimeStamp setTime;
|
||||
TimeStamp configTime;
|
||||
} RRTimesRec, *RRTimesPtr;
|
||||
|
||||
typedef struct _RRClient {
|
||||
int major_version;
|
||||
int minor_version;
|
||||
/* RRTimesRec times[0]; */
|
||||
} RRClientRec, *RRClientPtr;
|
||||
|
||||
extern RESTYPE RRClientType, RREventType; /* resource types for event masks */
|
||||
extern int RRClientPrivateIndex;
|
||||
extern RESTYPE RRCrtcType, RRModeType, RROutputType;
|
||||
|
||||
#define LookupOutput(client,id,a) ((RROutputPtr) \
|
||||
(SecurityLookupIDByType (client, id, \
|
||||
RROutputType, a)))
|
||||
#define LookupCrtc(client,id,a) ((RRCrtcPtr) \
|
||||
(SecurityLookupIDByType (client, id, \
|
||||
RRCrtcType, a)))
|
||||
#define LookupMode(client,id,a) ((RRModePtr) \
|
||||
(SecurityLookupIDByType (client, id, \
|
||||
RRModeType, a)))
|
||||
|
||||
#define GetRRClient(pClient) ((RRClientPtr) (pClient)->devPrivates[RRClientPrivateIndex].ptr)
|
||||
#define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient)
|
||||
|
||||
/* Initialize the extension */
|
||||
void
|
||||
RRExtensionInit (void);
|
||||
|
||||
#ifdef RANDR_12_INTERFACE
|
||||
/*
|
||||
* Set the range of sizes for the screen
|
||||
*/
|
||||
void
|
||||
RRScreenSetSizeRange (ScreenPtr pScreen,
|
||||
CARD16 minWidth,
|
||||
CARD16 minHeight,
|
||||
CARD16 maxWidth,
|
||||
CARD16 maxHeight);
|
||||
#endif
|
||||
|
||||
/* rrscreen.c */
|
||||
/*
|
||||
* Notify the extension that the screen size has been changed.
|
||||
* The driver is responsible for calling this whenever it has changed
|
||||
* the size of the screen
|
||||
*/
|
||||
void
|
||||
RRScreenSizeNotify (ScreenPtr pScreen);
|
||||
|
||||
/*
|
||||
* Request that the screen be resized
|
||||
*/
|
||||
Bool
|
||||
RRScreenSizeSet (ScreenPtr pScreen,
|
||||
CARD16 width,
|
||||
CARD16 height,
|
||||
CARD32 mmWidth,
|
||||
CARD32 mmHeight);
|
||||
|
||||
/*
|
||||
* Send ConfigureNotify event to root window when 'something' happens
|
||||
*/
|
||||
void
|
||||
RRSendConfigNotify (ScreenPtr pScreen);
|
||||
|
||||
/*
|
||||
* screen dispatch
|
||||
*/
|
||||
int
|
||||
ProcRRGetScreenSizeRange (ClientPtr client);
|
||||
|
||||
int
|
||||
ProcRRSetScreenSize (ClientPtr client);
|
||||
|
||||
int
|
||||
ProcRRGetScreenResources (ClientPtr client);
|
||||
|
||||
int
|
||||
ProcRRSetScreenConfig (ClientPtr client);
|
||||
|
||||
int
|
||||
ProcRRGetScreenInfo (ClientPtr client);
|
||||
|
||||
/*
|
||||
* Deliver a ScreenNotify event
|
||||
*/
|
||||
void
|
||||
RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen);
|
||||
|
||||
/* mirandr.c */
|
||||
Bool
|
||||
miRandRInit (ScreenPtr pScreen);
|
||||
|
||||
Bool
|
||||
miRRGetInfo (ScreenPtr pScreen, Rotation *rotations);
|
||||
|
||||
Bool
|
||||
miRRGetScreenInfo (ScreenPtr pScreen);
|
||||
|
||||
Bool
|
||||
miRRCrtcSet (ScreenPtr pScreen,
|
||||
RRCrtcPtr crtc,
|
||||
RRModePtr mode,
|
||||
int x,
|
||||
int y,
|
||||
Rotation rotation,
|
||||
int numOutput,
|
||||
RROutputPtr *outputs);
|
||||
|
||||
/* randr.c */
|
||||
/*
|
||||
* Send all pending events
|
||||
*/
|
||||
void
|
||||
RRTellChanged (ScreenPtr pScreen);
|
||||
|
||||
/*
|
||||
* Poll the driver for changed information
|
||||
*/
|
||||
Bool
|
||||
RRGetInfo (ScreenPtr pScreen);
|
||||
|
||||
Bool RRInit (void);
|
||||
|
||||
Bool RRScreenInit(ScreenPtr pScreen);
|
||||
|
||||
RROutputPtr
|
||||
RRFirstOutput (ScreenPtr pScreen);
|
||||
|
||||
Rotation
|
||||
RRGetRotation (ScreenPtr pScreen);
|
||||
|
||||
CARD16
|
||||
RRVerticalRefresh (xRRModeInfo *mode);
|
||||
|
||||
#ifdef RANDR_10_INTERFACE
|
||||
/*
|
||||
* This is the old interface, deprecated but left
|
||||
* around for compatibility
|
||||
*/
|
||||
|
||||
/*
|
||||
* Then, register the specific size with the screen
|
||||
*/
|
||||
|
@ -115,7 +420,7 @@ RRSetCurrentConfig (ScreenPtr pScreen,
|
|||
int rate,
|
||||
RRScreenSizePtr pSize);
|
||||
|
||||
Bool RRScreenInit(ScreenPtr pScreen);
|
||||
Bool RRScreenInit (ScreenPtr pScreen);
|
||||
|
||||
Rotation
|
||||
RRGetRotation (ScreenPtr pScreen);
|
||||
|
@ -126,19 +431,347 @@ RRSetScreenConfig (ScreenPtr pScreen,
|
|||
int rate,
|
||||
RRScreenSizePtr pSize);
|
||||
|
||||
#endif
|
||||
|
||||
/* rrcrtc.c */
|
||||
|
||||
/*
|
||||
* Notify the CRTC of some change; layoutChanged indicates that
|
||||
* some position or size element changed
|
||||
*/
|
||||
void
|
||||
RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged);
|
||||
|
||||
/*
|
||||
* Create a CRTC
|
||||
*/
|
||||
RRCrtcPtr
|
||||
RRCrtcCreate (void *devPrivate);
|
||||
|
||||
/*
|
||||
* Attach a CRTC to a screen. Once done, this cannot be
|
||||
* undone without destroying the CRTC; it is separate from Create
|
||||
* only to allow an xf86-based driver to create objects in preinit
|
||||
*/
|
||||
Bool
|
||||
miRandRInit (ScreenPtr pScreen);
|
||||
RRCrtcAttachScreen (RRCrtcPtr crtc, ScreenPtr pScreen);
|
||||
|
||||
/*
|
||||
* Notify the extension that the Crtc has been reconfigured,
|
||||
* the driver calls this whenever it has updated the mode
|
||||
*/
|
||||
Bool
|
||||
RRCrtcNotify (RRCrtcPtr crtc,
|
||||
RRModePtr mode,
|
||||
int x,
|
||||
int y,
|
||||
Rotation rotation,
|
||||
int numOutputs,
|
||||
RROutputPtr *outputs);
|
||||
|
||||
void
|
||||
RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc);
|
||||
|
||||
/*
|
||||
* Request that the Crtc be reconfigured
|
||||
*/
|
||||
Bool
|
||||
RRCrtcSet (RRCrtcPtr crtc,
|
||||
RRModePtr mode,
|
||||
int x,
|
||||
int y,
|
||||
Rotation rotation,
|
||||
int numOutput,
|
||||
RROutputPtr *outputs);
|
||||
|
||||
/*
|
||||
* Request that the Crtc gamma be changed
|
||||
*/
|
||||
|
||||
Bool
|
||||
miRRGetInfo (ScreenPtr pScreen, Rotation *rotations);
|
||||
RRCrtcGammaSet (RRCrtcPtr crtc,
|
||||
CARD16 *red,
|
||||
CARD16 *green,
|
||||
CARD16 *blue);
|
||||
|
||||
/*
|
||||
* Notify the extension that the Crtc gamma has been changed
|
||||
* The driver calls this whenever it has changed the gamma values
|
||||
* in the RRCrtcRec
|
||||
*/
|
||||
|
||||
Bool
|
||||
miRRSetConfig (ScreenPtr pScreen,
|
||||
Rotation rotation,
|
||||
int rate,
|
||||
RRScreenSizePtr size);
|
||||
RRCrtcGammaNotify (RRCrtcPtr crtc);
|
||||
|
||||
/*
|
||||
* Set the size of the gamma table at server startup time
|
||||
*/
|
||||
|
||||
Bool
|
||||
miRRGetScreenInfo (ScreenPtr pScreen);
|
||||
RRCrtcGammaSetSize (RRCrtcPtr crtc,
|
||||
int size);
|
||||
|
||||
/*
|
||||
* Destroy a Crtc at shutdown
|
||||
*/
|
||||
void
|
||||
RRCrtcDestroy (RRCrtcPtr crtc);
|
||||
|
||||
/*
|
||||
* Initialize crtc type
|
||||
*/
|
||||
Bool
|
||||
RRCrtcInit (void);
|
||||
|
||||
/*
|
||||
* Crtc dispatch
|
||||
*/
|
||||
|
||||
int
|
||||
ProcRRGetCrtcInfo (ClientPtr client);
|
||||
|
||||
int
|
||||
ProcRRSetCrtcConfig (ClientPtr client);
|
||||
|
||||
int
|
||||
ProcRRGetCrtcGammaSize (ClientPtr client);
|
||||
|
||||
int
|
||||
ProcRRGetCrtcGamma (ClientPtr client);
|
||||
|
||||
int
|
||||
ProcRRSetCrtcGamma (ClientPtr client);
|
||||
|
||||
/* rrdispatch.c */
|
||||
Bool
|
||||
RRClientKnowsRates (ClientPtr pClient);
|
||||
|
||||
/* rrmode.c */
|
||||
/*
|
||||
* Find, and if necessary, create a mode
|
||||
*/
|
||||
|
||||
RRModePtr
|
||||
RRModeGet (xRRModeInfo *modeInfo,
|
||||
const char *name);
|
||||
|
||||
void
|
||||
RRModePruneUnused (ScreenPtr pScreen);
|
||||
|
||||
/*
|
||||
* Destroy a mode.
|
||||
*/
|
||||
|
||||
void
|
||||
RRModeDestroy (RRModePtr mode);
|
||||
|
||||
/*
|
||||
* Return a list of modes that are valid for some output in pScreen
|
||||
*/
|
||||
RRModePtr *
|
||||
RRModesForScreen (ScreenPtr pScreen, int *num_ret);
|
||||
|
||||
/*
|
||||
* Initialize mode type
|
||||
*/
|
||||
Bool
|
||||
RRModeInit (void);
|
||||
|
||||
int
|
||||
ProcRRCreateMode (ClientPtr client);
|
||||
|
||||
int
|
||||
ProcRRDestroyMode (ClientPtr client);
|
||||
|
||||
int
|
||||
ProcRRAddOutputMode (ClientPtr client);
|
||||
|
||||
int
|
||||
ProcRRDeleteOutputMode (ClientPtr client);
|
||||
|
||||
/* rroutput.c */
|
||||
|
||||
/*
|
||||
* Notify the output of some change
|
||||
*/
|
||||
void
|
||||
RROutputChanged (RROutputPtr output);
|
||||
|
||||
/*
|
||||
* Create an output
|
||||
*/
|
||||
|
||||
RROutputPtr
|
||||
RROutputCreate (const char *name,
|
||||
int nameLength,
|
||||
void *devPrivate);
|
||||
|
||||
/*
|
||||
* Attach an output to a screen, again split from creation so
|
||||
* xf86 DDXen can create randr resources before the ScreenRec
|
||||
* exists
|
||||
*/
|
||||
Bool
|
||||
RROutputAttachScreen (RROutputPtr output, ScreenPtr pScreen);
|
||||
|
||||
/*
|
||||
* Notify extension that output parameters have been changed
|
||||
*/
|
||||
Bool
|
||||
RROutputSetClones (RROutputPtr output,
|
||||
RROutputPtr *clones,
|
||||
int numClones);
|
||||
|
||||
Bool
|
||||
RROutputSetModes (RROutputPtr output,
|
||||
RRModePtr *modes,
|
||||
int numModes,
|
||||
int numPreferred);
|
||||
|
||||
Bool
|
||||
RROutputSetCrtcs (RROutputPtr output,
|
||||
RRCrtcPtr *crtcs,
|
||||
int numCrtcs);
|
||||
|
||||
void
|
||||
RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc);
|
||||
|
||||
Bool
|
||||
RROutputSetConnection (RROutputPtr output,
|
||||
CARD8 connection);
|
||||
|
||||
Bool
|
||||
RROutputSetSubpixelOrder (RROutputPtr output,
|
||||
int subpixelOrder);
|
||||
|
||||
Bool
|
||||
RROutputSetPhysicalSize (RROutputPtr output,
|
||||
int mmWidth,
|
||||
int mmHeight);
|
||||
|
||||
void
|
||||
RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output);
|
||||
|
||||
void
|
||||
RROutputDestroy (RROutputPtr output);
|
||||
|
||||
int
|
||||
ProcRRGetOutputInfo (ClientPtr client);
|
||||
|
||||
/*
|
||||
* Initialize output type
|
||||
*/
|
||||
Bool
|
||||
RROutputInit (void);
|
||||
|
||||
/* rrpointer.c */
|
||||
void
|
||||
RRPointerMoved (ScreenPtr pScreen, int x, int y);
|
||||
|
||||
void
|
||||
RRPointerScreenConfigured (ScreenPtr pScreen);
|
||||
|
||||
/* rrproperty.c */
|
||||
|
||||
void
|
||||
RRDeleteAllOutputProperties (RROutputPtr output);
|
||||
|
||||
void
|
||||
RRDeleteOutputProperty (RROutputPtr output, Atom property);
|
||||
|
||||
int
|
||||
RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
|
||||
int format, int mode, unsigned long len,
|
||||
pointer value, Bool sendevent);
|
||||
|
||||
int
|
||||
ProcRRChangeOutputProperty (ClientPtr client);
|
||||
|
||||
int
|
||||
ProcRRGetOutputProperty (ClientPtr client);
|
||||
|
||||
int
|
||||
ProcRRListOutputProperties (ClientPtr client);
|
||||
|
||||
int
|
||||
ProcRRDeleteOutputProperty (ClientPtr client);
|
||||
|
||||
/* rrxinerama.c */
|
||||
void
|
||||
RRXineramaExtensionInit(void);
|
||||
|
||||
#endif /* _RANDRSTR_H_ */
|
||||
|
||||
/*
|
||||
|
||||
randr extension implementation structure
|
||||
|
||||
Query state:
|
||||
ProcRRGetScreenInfo/ProcRRGetScreenResources
|
||||
RRGetInfo
|
||||
|
||||
• Request configuration from driver, either 1.0 or 1.2 style
|
||||
• These functions only record state changes, all
|
||||
other actions are pended until RRTellChanged is called
|
||||
|
||||
->rrGetInfo
|
||||
1.0:
|
||||
RRRegisterSize
|
||||
RRRegisterRate
|
||||
RRSetCurrentConfig
|
||||
1.2:
|
||||
RRScreenSetSizeRange
|
||||
RROutputSetCrtcs
|
||||
RROutputSetCrtc
|
||||
RRModeGet
|
||||
RROutputSetModes
|
||||
RROutputSetConnection
|
||||
RROutputSetSubpixelOrder
|
||||
RROutputSetClones
|
||||
RRCrtcNotify
|
||||
|
||||
• Must delay scanning configuration until after ->rrGetInfo returns
|
||||
because some drivers will call SetCurrentConfig in the middle
|
||||
of the ->rrGetInfo operation.
|
||||
|
||||
1.0:
|
||||
|
||||
• Scan old configuration, mirror to new structures
|
||||
|
||||
RRScanOldConfig
|
||||
RRCrtcCreate
|
||||
RROutputCreate
|
||||
RROutputSetCrtcs
|
||||
RROutputSetCrtc
|
||||
RROutputSetConnection
|
||||
RROutputSetSubpixelOrder
|
||||
RROldModeAdd • This adds modes one-at-a-time
|
||||
RRModeGet
|
||||
RRCrtcNotify
|
||||
|
||||
• send events, reset pointer if necessary
|
||||
|
||||
RRTellChanged
|
||||
WalkTree (sending events)
|
||||
|
||||
• when layout has changed:
|
||||
RRPointerScreenConfigured
|
||||
RRSendConfigNotify
|
||||
|
||||
Asynchronous state setting (1.2 only)
|
||||
When setting state asynchronously, the driver invokes the
|
||||
->rrGetInfo function and then calls RRTellChanged to flush
|
||||
the changes to the clients and reset pointer if necessary
|
||||
|
||||
Set state
|
||||
|
||||
ProcRRSetScreenConfig
|
||||
RRCrtcSet
|
||||
1.2:
|
||||
->rrCrtcSet
|
||||
RRCrtcNotify
|
||||
1.0:
|
||||
->rrSetConfig
|
||||
RRCrtcNotify
|
||||
RRTellChanged
|
||||
*/
|
||||
|
|
846
randr/rrcrtc.c
Normal file
846
randr/rrcrtc.c
Normal file
|
@ -0,0 +1,846 @@
|
|||
/*
|
||||
* Copyright © 2006 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "randrstr.h"
|
||||
#include "swaprep.h"
|
||||
|
||||
RESTYPE RRCrtcType;
|
||||
|
||||
/*
|
||||
* Notify the CRTC of some change
|
||||
*/
|
||||
void
|
||||
RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged)
|
||||
{
|
||||
ScreenPtr pScreen = crtc->pScreen;
|
||||
|
||||
crtc->changed = TRUE;
|
||||
if (pScreen)
|
||||
{
|
||||
rrScrPriv(pScreen);
|
||||
|
||||
pScrPriv->changed = TRUE;
|
||||
/*
|
||||
* Send ConfigureNotify on any layout change
|
||||
*/
|
||||
if (layoutChanged)
|
||||
pScrPriv->layoutChanged = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a CRTC
|
||||
*/
|
||||
RRCrtcPtr
|
||||
RRCrtcCreate (void *devPrivate)
|
||||
{
|
||||
RRCrtcPtr crtc;
|
||||
|
||||
crtc = xalloc (sizeof (RRCrtcRec));
|
||||
if (!crtc)
|
||||
return NULL;
|
||||
crtc->id = FakeClientID (0);
|
||||
crtc->pScreen = NULL;
|
||||
crtc->mode = NULL;
|
||||
crtc->x = 0;
|
||||
crtc->y = 0;
|
||||
crtc->rotation = RR_Rotate_0;
|
||||
crtc->rotations = RR_Rotate_0;
|
||||
crtc->outputs = NULL;
|
||||
crtc->numOutputs = 0;
|
||||
crtc->gammaSize = 0;
|
||||
crtc->gammaRed = crtc->gammaBlue = crtc->gammaGreen = NULL;
|
||||
crtc->changed = FALSE;
|
||||
crtc->devPrivate = devPrivate;
|
||||
|
||||
if (!AddResource (crtc->id, RRCrtcType, (pointer) crtc))
|
||||
return NULL;
|
||||
|
||||
return crtc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attach a Crtc to a screen. This is done as a separate step
|
||||
* so that an xf86-based driver can create CRTCs in PreInit
|
||||
* before the Screen has been created
|
||||
*/
|
||||
|
||||
Bool
|
||||
RRCrtcAttachScreen (RRCrtcPtr crtc, ScreenPtr pScreen)
|
||||
{
|
||||
rrScrPriv (pScreen);
|
||||
RRCrtcPtr *crtcs;
|
||||
|
||||
/* make space for the crtc pointer */
|
||||
if (pScrPriv->numCrtcs)
|
||||
crtcs = xrealloc (pScrPriv->crtcs,
|
||||
(pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr));
|
||||
else
|
||||
crtcs = xalloc (sizeof (RRCrtcPtr));
|
||||
if (!crtcs)
|
||||
return FALSE;
|
||||
|
||||
/* attach the screen and crtc together */
|
||||
crtc->pScreen = pScreen;
|
||||
pScrPriv->crtcs = crtcs;
|
||||
pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc;
|
||||
|
||||
RRCrtcChanged (crtc, TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Notify the extension that the Crtc has been reconfigured,
|
||||
* the driver calls this whenever it has updated the mode
|
||||
*/
|
||||
Bool
|
||||
RRCrtcNotify (RRCrtcPtr crtc,
|
||||
RRModePtr mode,
|
||||
int x,
|
||||
int y,
|
||||
Rotation rotation,
|
||||
int numOutputs,
|
||||
RROutputPtr *outputs)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
/*
|
||||
* Check to see if any of the new outputs were
|
||||
* not in the old list and mark them as changed
|
||||
*/
|
||||
for (i = 0; i < numOutputs; i++)
|
||||
{
|
||||
for (j = 0; j < crtc->numOutputs; j++)
|
||||
if (outputs[i] == crtc->outputs[j])
|
||||
break;
|
||||
if (j == crtc->numOutputs)
|
||||
{
|
||||
RROutputChanged (outputs[i]);
|
||||
RRCrtcChanged (crtc, FALSE);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Check to see if any of the old outputs are
|
||||
* not in the new list and mark them as changed
|
||||
*/
|
||||
for (j = 0; j < crtc->numOutputs; j++)
|
||||
{
|
||||
for (i = 0; i < numOutputs; i++)
|
||||
if (outputs[i] == crtc->outputs[j])
|
||||
break;
|
||||
if (i == numOutputs)
|
||||
{
|
||||
RROutputChanged (crtc->outputs[j]);
|
||||
RRCrtcChanged (crtc, FALSE);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Reallocate the crtc output array if necessary
|
||||
*/
|
||||
if (numOutputs != crtc->numOutputs)
|
||||
{
|
||||
RROutputPtr *newoutputs;
|
||||
|
||||
if (numOutputs)
|
||||
{
|
||||
if (crtc->numOutputs)
|
||||
newoutputs = xrealloc (crtc->outputs,
|
||||
numOutputs * sizeof (RROutputPtr));
|
||||
else
|
||||
newoutputs = xalloc (numOutputs * sizeof (RROutputPtr));
|
||||
if (!newoutputs)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (crtc->outputs)
|
||||
xfree (crtc->outputs);
|
||||
newoutputs = NULL;
|
||||
}
|
||||
crtc->outputs = newoutputs;
|
||||
crtc->numOutputs = numOutputs;
|
||||
}
|
||||
/*
|
||||
* Copy the new list of outputs into the crtc
|
||||
*/
|
||||
memcpy (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr));
|
||||
/*
|
||||
* Update remaining crtc fields
|
||||
*/
|
||||
if (mode != crtc->mode)
|
||||
{
|
||||
if (crtc->mode)
|
||||
RRModeDestroy (crtc->mode);
|
||||
crtc->mode = mode;
|
||||
if (mode != NULL)
|
||||
mode->refcnt++;
|
||||
RRCrtcChanged (crtc, TRUE);
|
||||
}
|
||||
if (x != crtc->x)
|
||||
{
|
||||
crtc->x = x;
|
||||
RRCrtcChanged (crtc, TRUE);
|
||||
}
|
||||
if (y != crtc->y)
|
||||
{
|
||||
crtc->y = y;
|
||||
RRCrtcChanged (crtc, TRUE);
|
||||
}
|
||||
if (rotation != crtc->rotation)
|
||||
{
|
||||
crtc->rotation = rotation;
|
||||
RRCrtcChanged (crtc, TRUE);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
rrScrPriv (pScreen);
|
||||
xRRCrtcChangeNotifyEvent ce;
|
||||
RRModePtr mode = crtc->mode;
|
||||
|
||||
ce.type = RRNotify + RREventBase;
|
||||
ce.subCode = RRNotify_CrtcChange;
|
||||
ce.sequenceNumber = client->sequence;
|
||||
ce.timestamp = pScrPriv->lastSetTime.milliseconds;
|
||||
ce.window = pWin->drawable.id;
|
||||
ce.crtc = crtc->id;
|
||||
ce.rotation = crtc->rotation;
|
||||
if (mode)
|
||||
{
|
||||
ce.mode = mode->mode.id;
|
||||
ce.x = crtc->x;
|
||||
ce.y = crtc->y;
|
||||
ce.width = mode->mode.width;
|
||||
ce.height = mode->mode.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
ce.mode = None;
|
||||
ce.x = 0;
|
||||
ce.y = 0;
|
||||
ce.width = 0;
|
||||
ce.height = 0;
|
||||
}
|
||||
WriteEventsToClient (client, 1, (xEvent *) &ce);
|
||||
}
|
||||
|
||||
/*
|
||||
* Request that the Crtc be reconfigured
|
||||
*/
|
||||
Bool
|
||||
RRCrtcSet (RRCrtcPtr crtc,
|
||||
RRModePtr mode,
|
||||
int x,
|
||||
int y,
|
||||
Rotation rotation,
|
||||
int numOutputs,
|
||||
RROutputPtr *outputs)
|
||||
{
|
||||
ScreenPtr pScreen = crtc->pScreen;
|
||||
|
||||
/* See if nothing changed */
|
||||
if (crtc->mode == mode &&
|
||||
crtc->x == x &&
|
||||
crtc->y == y &&
|
||||
crtc->rotation == rotation &&
|
||||
crtc->numOutputs == numOutputs &&
|
||||
!memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr)))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
if (pScreen)
|
||||
{
|
||||
#if RANDR_12_INTERFACE
|
||||
rrScrPriv(pScreen);
|
||||
if (pScrPriv->rrCrtcSet)
|
||||
{
|
||||
return (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y,
|
||||
rotation, numOutputs, outputs);
|
||||
}
|
||||
#endif
|
||||
#if RANDR_10_INTERFACE
|
||||
if (pScrPriv->rrSetConfig)
|
||||
{
|
||||
RRScreenSize size;
|
||||
RRScreenRate rate;
|
||||
Bool ret;
|
||||
|
||||
size.width = mode->mode.width;
|
||||
size.height = mode->mode.height;
|
||||
if (outputs[0]->mmWidth && outputs[0]->mmHeight)
|
||||
{
|
||||
size.mmWidth = outputs[0]->mmWidth;
|
||||
size.mmHeight = outputs[0]->mmHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
size.mmWidth = pScreen->mmWidth;
|
||||
size.mmHeight = pScreen->mmHeight;
|
||||
}
|
||||
size.nRates = 1;
|
||||
rate.rate = RRVerticalRefresh (&mode->mode);
|
||||
size.pRates = &rate;
|
||||
ret = (*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate, &size);
|
||||
/*
|
||||
* Old 1.0 interface tied screen size to mode size
|
||||
*/
|
||||
if (ret)
|
||||
RRCrtcNotify (crtc, mode, x, y, rotation, 1, outputs);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
RRTellChanged (pScreen);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroy a Crtc at shutdown
|
||||
*/
|
||||
void
|
||||
RRCrtcDestroy (RRCrtcPtr crtc)
|
||||
{
|
||||
FreeResource (crtc->id, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
RRCrtcDestroyResource (pointer value, XID pid)
|
||||
{
|
||||
RRCrtcPtr crtc = (RRCrtcPtr) value;
|
||||
ScreenPtr pScreen = crtc->pScreen;
|
||||
|
||||
if (pScreen)
|
||||
{
|
||||
rrScrPriv(pScreen);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < pScrPriv->numCrtcs; i++)
|
||||
{
|
||||
if (pScrPriv->crtcs[i] == crtc)
|
||||
{
|
||||
memmove (pScrPriv->crtcs + i, pScrPriv->crtcs + i + 1,
|
||||
(pScrPriv->numCrtcs - (i - 1)) * sizeof (RRCrtcPtr));
|
||||
--pScrPriv->numCrtcs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (crtc->gammaRed)
|
||||
xfree (crtc->gammaRed);
|
||||
xfree (crtc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Request that the Crtc gamma be changed
|
||||
*/
|
||||
|
||||
Bool
|
||||
RRCrtcGammaSet (RRCrtcPtr crtc,
|
||||
CARD16 *red,
|
||||
CARD16 *green,
|
||||
CARD16 *blue)
|
||||
{
|
||||
Bool ret = TRUE;
|
||||
#if RANDR_12_INTERFACE
|
||||
ScreenPtr pScreen = crtc->pScreen;
|
||||
#endif
|
||||
|
||||
memcpy (crtc->gammaRed, red, crtc->gammaSize * sizeof (CARD16));
|
||||
memcpy (crtc->gammaGreen, green, crtc->gammaSize * sizeof (CARD16));
|
||||
memcpy (crtc->gammaBlue, blue, crtc->gammaSize * sizeof (CARD16));
|
||||
#if RANDR_12_INTERFACE
|
||||
if (pScreen)
|
||||
{
|
||||
rrScrPriv(pScreen);
|
||||
if (pScrPriv->rrCrtcSetGamma)
|
||||
ret = (*pScrPriv->rrCrtcSetGamma) (pScreen, crtc);
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Notify the extension that the Crtc gamma has been changed
|
||||
* The driver calls this whenever it has changed the gamma values
|
||||
* in the RRCrtcRec
|
||||
*/
|
||||
|
||||
Bool
|
||||
RRCrtcGammaNotify (RRCrtcPtr crtc)
|
||||
{
|
||||
return TRUE; /* not much going on here */
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the size of the gamma table at server startup time
|
||||
*/
|
||||
|
||||
Bool
|
||||
RRCrtcGammaSetSize (RRCrtcPtr crtc,
|
||||
int size)
|
||||
{
|
||||
CARD16 *gamma;
|
||||
|
||||
if (size == crtc->gammaSize)
|
||||
return TRUE;
|
||||
if (size)
|
||||
{
|
||||
gamma = xalloc (size * 3 * sizeof (CARD16));
|
||||
if (!gamma)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
gamma = NULL;
|
||||
if (crtc->gammaRed)
|
||||
xfree (crtc->gammaRed);
|
||||
crtc->gammaRed = gamma;
|
||||
crtc->gammaGreen = gamma + size;
|
||||
crtc->gammaBlue = gamma + size*2;
|
||||
crtc->gammaSize = size;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize crtc type
|
||||
*/
|
||||
Bool
|
||||
RRCrtcInit (void)
|
||||
{
|
||||
RRCrtcType = CreateNewResourceType (RRCrtcDestroyResource);
|
||||
if (!RRCrtcType)
|
||||
return FALSE;
|
||||
#ifdef XResExtension
|
||||
RegisterResourceName (RRCrtcType, "CRTC");
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRGetCrtcInfo (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetCrtcInfoReq);;
|
||||
xRRGetCrtcInfoReply rep;
|
||||
RRCrtcPtr crtc;
|
||||
CARD8 *extra;
|
||||
unsigned long extraLen;
|
||||
ScreenPtr pScreen;
|
||||
rrScrPrivPtr pScrPriv;
|
||||
RRModePtr mode;
|
||||
RROutput *outputs;
|
||||
RROutput *possible;
|
||||
int i, j, k, n;
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
|
||||
crtc = LookupCrtc(client, stuff->crtc, SecurityReadAccess);
|
||||
|
||||
if (!crtc)
|
||||
return RRErrorBase + BadRRCrtc;
|
||||
|
||||
/* All crtcs must be associated with screens before client
|
||||
* requests are processed
|
||||
*/
|
||||
pScreen = crtc->pScreen;
|
||||
pScrPriv = rrGetScrPriv(pScreen);
|
||||
|
||||
mode = crtc->mode;
|
||||
|
||||
rep.type = X_Reply;
|
||||
rep.status = RRSetConfigSuccess;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.length = 0;
|
||||
rep.timestamp = pScrPriv->lastSetTime.milliseconds;
|
||||
rep.x = crtc->x;
|
||||
rep.y = crtc->y;
|
||||
rep.width = mode ? mode->mode.width : 0;
|
||||
rep.height = mode ? mode->mode.height : 0;
|
||||
rep.mode = mode ? mode->mode.id : 0;
|
||||
rep.rotation = crtc->rotation;
|
||||
rep.rotations = crtc->rotations;
|
||||
rep.nOutput = crtc->numOutputs;
|
||||
k = 0;
|
||||
for (i = 0; i < pScrPriv->numOutputs; i++)
|
||||
for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++)
|
||||
if (pScrPriv->outputs[i]->crtcs[j] == crtc)
|
||||
k++;
|
||||
rep.nPossibleOutput = k;
|
||||
|
||||
rep.length = rep.nOutput + rep.nPossibleOutput;
|
||||
|
||||
extraLen = rep.length << 2;
|
||||
if (extraLen)
|
||||
{
|
||||
extra = xalloc (extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
}
|
||||
else
|
||||
extra = NULL;
|
||||
|
||||
outputs = (RROutput *) extra;
|
||||
possible = (RROutput *) (outputs + rep.nOutput);
|
||||
|
||||
for (i = 0; i < crtc->numOutputs; i++)
|
||||
{
|
||||
outputs[i] = crtc->outputs[i]->id;
|
||||
if (client->swapped)
|
||||
swapl (&outputs[i], n);
|
||||
}
|
||||
k = 0;
|
||||
for (i = 0; i < pScrPriv->numOutputs; i++)
|
||||
for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++)
|
||||
if (pScrPriv->outputs[i]->crtcs[j] == crtc)
|
||||
{
|
||||
possible[k] = pScrPriv->outputs[i]->id;
|
||||
if (client->swapped)
|
||||
swapl (&possible[k], n);
|
||||
k++;
|
||||
}
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swapl(&rep.timestamp, n);
|
||||
swaps(&rep.x, n);
|
||||
swaps(&rep.y, n);
|
||||
swaps(&rep.width, n);
|
||||
swaps(&rep.height, n);
|
||||
swapl(&rep.mode, n);
|
||||
swaps(&rep.rotation, n);
|
||||
swaps(&rep.rotations, n);
|
||||
swaps(&rep.nOutput, n);
|
||||
swaps(&rep.nPossibleOutput, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xRRGetCrtcInfoReply), (char *)&rep);
|
||||
if (extraLen)
|
||||
{
|
||||
WriteToClient (client, extraLen, (char *) extra);
|
||||
xfree (extra);
|
||||
}
|
||||
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRSetCrtcConfig (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRSetCrtcConfigReq);
|
||||
xRRSetCrtcConfigReply rep;
|
||||
ScreenPtr pScreen;
|
||||
rrScrPrivPtr pScrPriv;
|
||||
RRCrtcPtr crtc;
|
||||
RRModePtr mode;
|
||||
int numOutputs;
|
||||
RROutputPtr *outputs = NULL;
|
||||
RROutput *outputIds;
|
||||
TimeStamp configTime;
|
||||
TimeStamp time;
|
||||
Rotation rotation;
|
||||
int i, j;
|
||||
|
||||
REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq);
|
||||
numOutputs = (stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2));
|
||||
|
||||
crtc = LookupIDByType (stuff->crtc, RRCrtcType);
|
||||
if (!crtc)
|
||||
{
|
||||
client->errorValue = stuff->crtc;
|
||||
return RRErrorBase + BadRRCrtc;
|
||||
}
|
||||
if (stuff->mode == None)
|
||||
{
|
||||
mode = NULL;
|
||||
if (numOutputs > 0)
|
||||
return BadMatch;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = LookupIDByType (stuff->mode, RRModeType);
|
||||
if (!mode)
|
||||
{
|
||||
client->errorValue = stuff->mode;
|
||||
return RRErrorBase + BadRRMode;
|
||||
}
|
||||
if (numOutputs == 0)
|
||||
return BadMatch;
|
||||
}
|
||||
if (numOutputs)
|
||||
{
|
||||
outputs = xalloc (numOutputs * sizeof (RROutputPtr));
|
||||
if (!outputs)
|
||||
return BadAlloc;
|
||||
}
|
||||
else
|
||||
outputs = NULL;
|
||||
|
||||
outputIds = (RROutput *) (stuff + 1);
|
||||
for (i = 0; i < numOutputs; i++)
|
||||
{
|
||||
outputs[i] = (RROutputPtr) LookupIDByType (outputIds[i], RROutputType);
|
||||
if (!outputs[i])
|
||||
{
|
||||
client->errorValue = outputIds[i];
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
return RRErrorBase + BadRROutput;
|
||||
}
|
||||
/* validate crtc for this output */
|
||||
for (j = 0; j < outputs[i]->numCrtcs; j++)
|
||||
if (outputs[i]->crtcs[j] == crtc)
|
||||
break;
|
||||
if (j == outputs[i]->numCrtcs)
|
||||
{
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
return BadMatch;
|
||||
}
|
||||
/* validate mode for this output */
|
||||
for (j = 0; j < outputs[i]->numModes; j++)
|
||||
if (outputs[i]->modes[j] == mode)
|
||||
break;
|
||||
if (j == outputs[i]->numModes)
|
||||
{
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
return BadMatch;
|
||||
}
|
||||
}
|
||||
|
||||
pScreen = crtc->pScreen;
|
||||
pScrPriv = rrGetScrPriv(pScreen);
|
||||
|
||||
time = ClientTimeToServerTime(stuff->timestamp);
|
||||
configTime = ClientTimeToServerTime(stuff->configTimestamp);
|
||||
|
||||
if (!pScrPriv)
|
||||
{
|
||||
time = currentTime;
|
||||
rep.status = RRSetConfigFailed;
|
||||
goto sendReply;
|
||||
}
|
||||
|
||||
/*
|
||||
* if the client's config timestamp is not the same as the last config
|
||||
* timestamp, then the config information isn't up-to-date and
|
||||
* can't even be validated
|
||||
*/
|
||||
if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0)
|
||||
{
|
||||
rep.status = RRSetConfigInvalidConfigTime;
|
||||
goto sendReply;
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate requested rotation
|
||||
*/
|
||||
rotation = (Rotation) stuff->rotation;
|
||||
|
||||
/* test the rotation bits only! */
|
||||
switch (rotation & 0xf) {
|
||||
case RR_Rotate_0:
|
||||
case RR_Rotate_90:
|
||||
case RR_Rotate_180:
|
||||
case RR_Rotate_270:
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
* Invalid rotation
|
||||
*/
|
||||
client->errorValue = stuff->rotation;
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
if (mode)
|
||||
{
|
||||
if ((~crtc->rotations) & rotation)
|
||||
{
|
||||
/*
|
||||
* requested rotation or reflection not supported by screen
|
||||
*/
|
||||
client->errorValue = stuff->rotation;
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
return BadMatch;
|
||||
}
|
||||
|
||||
#ifdef RANDR_12_INTERFACE
|
||||
/*
|
||||
* Check screen size bounds if the DDX provides a 1.2 interface
|
||||
* for setting screen size. Else, assume the CrtcSet sets
|
||||
* the size along with the mode
|
||||
*/
|
||||
if (pScrPriv->rrScreenSetSize)
|
||||
{
|
||||
if (stuff->x + mode->mode.width > pScreen->width)
|
||||
{
|
||||
client->errorValue = stuff->x;
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
if (stuff->y + mode->mode.height > pScreen->height)
|
||||
{
|
||||
client->errorValue = stuff->y;
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
return BadValue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure the requested set-time is not older than
|
||||
* the last set-time
|
||||
*/
|
||||
if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0)
|
||||
{
|
||||
rep.status = RRSetConfigInvalidTime;
|
||||
goto sendReply;
|
||||
}
|
||||
|
||||
if (!RRCrtcSet (crtc, mode, stuff->x, stuff->y,
|
||||
rotation, numOutputs, outputs))
|
||||
{
|
||||
rep.status = RRSetConfigFailed;
|
||||
goto sendReply;
|
||||
}
|
||||
rep.status = RRSetConfigSuccess;
|
||||
|
||||
sendReply:
|
||||
if (outputs)
|
||||
xfree (outputs);
|
||||
|
||||
rep.type = X_Reply;
|
||||
/* rep.status has already been filled in */
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.newTimestamp = pScrPriv->lastConfigTime.milliseconds;
|
||||
|
||||
if (client->swapped)
|
||||
{
|
||||
int n;
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swapl(&rep.newTimestamp, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xRRSetCrtcConfigReply), (char *)&rep);
|
||||
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRGetCrtcGammaSize (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetCrtcGammaSizeReq);
|
||||
xRRGetCrtcGammaSizeReply reply;
|
||||
RRCrtcPtr crtc;
|
||||
int n;
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq);
|
||||
crtc = LookupCrtc (client, stuff->crtc, SecurityReadAccess);
|
||||
if (!crtc)
|
||||
return RRErrorBase + BadRRCrtc;
|
||||
|
||||
reply.type = X_Reply;
|
||||
reply.sequenceNumber = client->sequence;
|
||||
reply.length = 0;
|
||||
reply.size = crtc->gammaSize;
|
||||
if (client->swapped) {
|
||||
swaps (&reply.sequenceNumber, n);
|
||||
swapl (&reply.length, n);
|
||||
swaps (&reply.size, n);
|
||||
}
|
||||
WriteToClient (client, sizeof (xRRGetCrtcGammaSizeReply), (char *) &reply);
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRGetCrtcGamma (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetCrtcGammaReq);
|
||||
xRRGetCrtcGammaReply reply;
|
||||
RRCrtcPtr crtc;
|
||||
int n;
|
||||
unsigned long len;
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
|
||||
crtc = LookupCrtc (client, stuff->crtc, SecurityReadAccess);
|
||||
if (!crtc)
|
||||
return RRErrorBase + BadRRCrtc;
|
||||
|
||||
len = crtc->gammaSize * 3 * 2;
|
||||
|
||||
reply.type = X_Reply;
|
||||
reply.sequenceNumber = client->sequence;
|
||||
reply.length = (len + 3) >> 2;
|
||||
reply.size = crtc->gammaSize;
|
||||
if (client->swapped) {
|
||||
swaps (&reply.sequenceNumber, n);
|
||||
swapl (&reply.length, n);
|
||||
swaps (&reply.size, n);
|
||||
}
|
||||
WriteToClient (client, sizeof (xRRGetCrtcGammaReply), (char *) &reply);
|
||||
if (crtc->gammaSize)
|
||||
{
|
||||
client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write;
|
||||
WriteSwappedDataToClient (client, len, (char *) crtc->gammaRed);
|
||||
}
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRSetCrtcGamma (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRSetCrtcGammaReq);
|
||||
RRCrtcPtr crtc;
|
||||
unsigned long len;
|
||||
CARD16 *red, *green, *blue;
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRSetCrtcGammaReq);
|
||||
crtc = LookupCrtc (client, stuff->crtc, SecurityWriteAccess);
|
||||
if (!crtc)
|
||||
return RRErrorBase + BadRRCrtc;
|
||||
|
||||
len = client->req_len - (sizeof (xRRSetCrtcGammaReq) >> 2);
|
||||
if (len < (stuff->size * 3 + 1) >> 1)
|
||||
return BadLength;
|
||||
|
||||
if (stuff->size != crtc->gammaSize)
|
||||
return BadMatch;
|
||||
|
||||
red = (CARD16 *) (stuff + 1);
|
||||
green = red + crtc->gammaSize;
|
||||
blue = green + crtc->gammaSize;
|
||||
|
||||
RRCrtcGammaSet (crtc, red, green, blue);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
208
randr/rrdispatch.c
Normal file
208
randr/rrdispatch.c
Normal file
|
@ -0,0 +1,208 @@
|
|||
/*
|
||||
* Copyright © 2006 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "randrstr.h"
|
||||
|
||||
Bool
|
||||
RRClientKnowsRates (ClientPtr pClient)
|
||||
{
|
||||
rrClientPriv(pClient);
|
||||
|
||||
return (pRRClient->major_version > 1 ||
|
||||
(pRRClient->major_version == 1 && pRRClient->minor_version >= 1));
|
||||
}
|
||||
|
||||
static int
|
||||
ProcRRQueryVersion (ClientPtr client)
|
||||
{
|
||||
xRRQueryVersionReply rep;
|
||||
register int n;
|
||||
REQUEST(xRRQueryVersionReq);
|
||||
rrClientPriv(client);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRQueryVersionReq);
|
||||
pRRClient->major_version = stuff->majorVersion;
|
||||
pRRClient->minor_version = stuff->minorVersion;
|
||||
rep.type = X_Reply;
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
/*
|
||||
* Report the current version; the current
|
||||
* spec says they're all compatible after 1.0
|
||||
*/
|
||||
rep.majorVersion = RANDR_MAJOR;
|
||||
rep.minorVersion = RANDR_MINOR;
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swapl(&rep.majorVersion, n);
|
||||
swapl(&rep.minorVersion, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xRRQueryVersionReply), (char *)&rep);
|
||||
return (client->noClientException);
|
||||
}
|
||||
|
||||
static int
|
||||
ProcRRSelectInput (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRSelectInputReq);
|
||||
rrClientPriv(client);
|
||||
RRTimesPtr pTimes;
|
||||
WindowPtr pWin;
|
||||
RREventPtr pRREvent, *pHead;
|
||||
XID clientResource;
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRSelectInputReq);
|
||||
pWin = SecurityLookupWindow (stuff->window, client, SecurityWriteAccess);
|
||||
if (!pWin)
|
||||
return BadWindow;
|
||||
pHead = (RREventPtr *)SecurityLookupIDByType(client,
|
||||
pWin->drawable.id, RREventType,
|
||||
SecurityWriteAccess);
|
||||
|
||||
if (stuff->enable & (RRScreenChangeNotifyMask|
|
||||
RRCrtcChangeNotifyMask|
|
||||
RROutputChangeNotifyMask))
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
rrScrPriv (pScreen);
|
||||
|
||||
pRREvent = NULL;
|
||||
if (pHead)
|
||||
{
|
||||
/* check for existing entry. */
|
||||
for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next)
|
||||
if (pRREvent->client == client)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pRREvent)
|
||||
{
|
||||
/* build the entry */
|
||||
pRREvent = (RREventPtr) xalloc (sizeof (RREventRec));
|
||||
if (!pRREvent)
|
||||
return BadAlloc;
|
||||
pRREvent->next = 0;
|
||||
pRREvent->client = client;
|
||||
pRREvent->window = pWin;
|
||||
pRREvent->mask = stuff->enable;
|
||||
/*
|
||||
* add a resource that will be deleted when
|
||||
* the client goes away
|
||||
*/
|
||||
clientResource = FakeClientID (client->index);
|
||||
pRREvent->clientResource = clientResource;
|
||||
if (!AddResource (clientResource, RRClientType, (pointer)pRREvent))
|
||||
return BadAlloc;
|
||||
/*
|
||||
* create a resource to contain a pointer to the list
|
||||
* of clients selecting input. This must be indirect as
|
||||
* the list may be arbitrarily rearranged which cannot be
|
||||
* done through the resource database.
|
||||
*/
|
||||
if (!pHead)
|
||||
{
|
||||
pHead = (RREventPtr *) xalloc (sizeof (RREventPtr));
|
||||
if (!pHead ||
|
||||
!AddResource (pWin->drawable.id, RREventType, (pointer)pHead))
|
||||
{
|
||||
FreeResource (clientResource, RT_NONE);
|
||||
return BadAlloc;
|
||||
}
|
||||
*pHead = 0;
|
||||
}
|
||||
pRREvent->next = *pHead;
|
||||
*pHead = pRREvent;
|
||||
}
|
||||
/*
|
||||
* Now see if the client needs an event
|
||||
*/
|
||||
if (pScrPriv && (pRREvent->mask & RRScreenChangeNotifyMask))
|
||||
{
|
||||
pTimes = &((RRTimesPtr) (pRRClient + 1))[pScreen->myNum];
|
||||
if (CompareTimeStamps (pTimes->setTime,
|
||||
pScrPriv->lastSetTime) != 0 ||
|
||||
CompareTimeStamps (pTimes->configTime,
|
||||
pScrPriv->lastConfigTime) != 0)
|
||||
{
|
||||
RRDeliverScreenEvent (client, pWin, pScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (stuff->enable == 0)
|
||||
{
|
||||
/* delete the interest */
|
||||
if (pHead) {
|
||||
RREventPtr pNewRREvent = 0;
|
||||
for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) {
|
||||
if (pRREvent->client == client)
|
||||
break;
|
||||
pNewRREvent = pRREvent;
|
||||
}
|
||||
if (pRREvent) {
|
||||
FreeResource (pRREvent->clientResource, RRClientType);
|
||||
if (pNewRREvent)
|
||||
pNewRREvent->next = pRREvent->next;
|
||||
else
|
||||
*pHead = pRREvent->next;
|
||||
xfree (pRREvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
client->errorValue = stuff->enable;
|
||||
return BadValue;
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = {
|
||||
ProcRRQueryVersion, /* 0 */
|
||||
/* we skip 1 to make old clients fail pretty immediately */
|
||||
NULL, /* 1 ProcRandrOldGetScreenInfo */
|
||||
/* V1.0 apps share the same set screen config request id */
|
||||
ProcRRSetScreenConfig, /* 2 */
|
||||
NULL, /* 3 ProcRandrOldScreenChangeSelectInput */
|
||||
/* 3 used to be ScreenChangeSelectInput; deprecated */
|
||||
ProcRRSelectInput, /* 4 */
|
||||
ProcRRGetScreenInfo, /* 5 */
|
||||
/* V1.2 additions */
|
||||
ProcRRGetScreenSizeRange, /* 6 */
|
||||
ProcRRSetScreenSize, /* 7 */
|
||||
ProcRRGetScreenResources, /* 8 */
|
||||
ProcRRGetOutputInfo, /* 9 */
|
||||
ProcRRListOutputProperties, /* 10 */
|
||||
ProcRRChangeOutputProperty, /* 11 */
|
||||
ProcRRDeleteOutputProperty, /* 12 */
|
||||
ProcRRGetOutputProperty, /* 13 */
|
||||
ProcRRCreateMode, /* 14 */
|
||||
ProcRRDestroyMode, /* 15 */
|
||||
ProcRRAddOutputMode, /* 16 */
|
||||
ProcRRDeleteOutputMode, /* 17 */
|
||||
ProcRRGetCrtcInfo, /* 18 */
|
||||
ProcRRSetCrtcConfig, /* 19 */
|
||||
ProcRRGetCrtcGammaSize, /* 20 */
|
||||
ProcRRGetCrtcGamma, /* 21 */
|
||||
ProcRRSetCrtcGamma, /* 22 */
|
||||
};
|
||||
|
342
randr/rrinfo.c
Normal file
342
randr/rrinfo.c
Normal file
|
@ -0,0 +1,342 @@
|
|||
/*
|
||||
* Copyright © 2006 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "randrstr.h"
|
||||
|
||||
#ifdef RANDR_10_INTERFACE
|
||||
static RRModePtr
|
||||
RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh)
|
||||
{
|
||||
ScreenPtr pScreen = output->pScreen;
|
||||
rrScrPriv(pScreen);
|
||||
xRRModeInfo modeInfo;
|
||||
char name[100];
|
||||
RRModePtr mode;
|
||||
int i;
|
||||
RRModePtr *modes;
|
||||
|
||||
memset (&modeInfo, '\0', sizeof (modeInfo));
|
||||
sprintf (name, "%dx%d", size->width, size->height);
|
||||
|
||||
modeInfo.width = size->width;
|
||||
modeInfo.height = size->height;
|
||||
modeInfo.hTotal = size->width;
|
||||
modeInfo.vTotal = size->height;
|
||||
modeInfo.dotClock = ((CARD32) size->width * (CARD32) size->height *
|
||||
(CARD32) refresh);
|
||||
modeInfo.nameLength = strlen (name);
|
||||
mode = RRModeGet (&modeInfo, name);
|
||||
if (!mode)
|
||||
return NULL;
|
||||
for (i = 0; i < output->numModes; i++)
|
||||
if (output->modes[i] == mode)
|
||||
{
|
||||
RRModeDestroy (mode);
|
||||
return mode;
|
||||
}
|
||||
|
||||
if (output->numModes)
|
||||
modes = xrealloc (output->modes,
|
||||
(output->numModes + 1) * sizeof (RRModePtr));
|
||||
else
|
||||
modes = xalloc (sizeof (RRModePtr));
|
||||
if (!modes)
|
||||
{
|
||||
RRModeDestroy (mode);
|
||||
FreeResource (mode->mode.id, 0);
|
||||
return NULL;
|
||||
}
|
||||
modes[output->numModes++] = mode;
|
||||
output->modes = modes;
|
||||
output->changed = TRUE;
|
||||
pScrPriv->changed = TRUE;
|
||||
return mode;
|
||||
}
|
||||
|
||||
static void
|
||||
RRScanOldConfig (ScreenPtr pScreen, Rotation rotations)
|
||||
{
|
||||
rrScrPriv(pScreen);
|
||||
RROutputPtr output;
|
||||
RRCrtcPtr crtc;
|
||||
RRModePtr mode, newMode = NULL;
|
||||
int i;
|
||||
CARD16 minWidth = MAXSHORT, minHeight = MAXSHORT;
|
||||
CARD16 maxWidth = 0, maxHeight = 0;
|
||||
|
||||
/*
|
||||
* First time through, create a crtc and output and hook
|
||||
* them together
|
||||
*/
|
||||
if (pScrPriv->numOutputs == 0 &&
|
||||
pScrPriv->numCrtcs == 0)
|
||||
{
|
||||
crtc = RRCrtcCreate (NULL);
|
||||
if (!crtc)
|
||||
return;
|
||||
if (!RRCrtcAttachScreen (crtc, pScreen))
|
||||
{
|
||||
RRCrtcDestroy (crtc);
|
||||
return;
|
||||
}
|
||||
output = RROutputCreate ("default", 7, NULL);
|
||||
if (!output)
|
||||
return;
|
||||
if (!RROutputAttachScreen (output, pScreen))
|
||||
return;
|
||||
RROutputSetCrtcs (output, &crtc, 1);
|
||||
RROutputSetCrtc (output, crtc);
|
||||
RROutputSetConnection (output, RR_Connected);
|
||||
#ifdef RENDER
|
||||
RROutputSetSubpixelOrder (output, PictureGetSubpixelOrder (pScreen));
|
||||
#endif
|
||||
}
|
||||
|
||||
output = RRFirstOutput (pScreen);
|
||||
if (!output)
|
||||
return;
|
||||
crtc = output->crtc;
|
||||
|
||||
/* check rotations */
|
||||
if (rotations != crtc->rotations)
|
||||
{
|
||||
crtc->rotations = rotations;
|
||||
crtc->changed = TRUE;
|
||||
pScrPriv->changed = TRUE;
|
||||
}
|
||||
|
||||
/* regenerate mode list */
|
||||
for (i = 0; i < pScrPriv->nSizes; i++)
|
||||
{
|
||||
RRScreenSizePtr size = &pScrPriv->pSizes[i];
|
||||
int r;
|
||||
|
||||
if (size->nRates)
|
||||
{
|
||||
for (r = 0; r < size->nRates; r++)
|
||||
{
|
||||
mode = RROldModeAdd (output, size, size->pRates[r].rate);
|
||||
if (i == pScrPriv->size &&
|
||||
size->pRates[r].rate == pScrPriv->rate)
|
||||
{
|
||||
newMode = mode;
|
||||
}
|
||||
}
|
||||
xfree (size->pRates);
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = RROldModeAdd (output, size, 0);
|
||||
if (i == pScrPriv->size)
|
||||
newMode = mode;
|
||||
}
|
||||
}
|
||||
if (pScrPriv->nSizes)
|
||||
xfree (pScrPriv->pSizes);
|
||||
pScrPriv->pSizes = NULL;
|
||||
pScrPriv->nSizes = 0;
|
||||
|
||||
/* find size bounds */
|
||||
for (i = 0; i < output->numModes; i++)
|
||||
{
|
||||
RRModePtr mode = output->modes[i];
|
||||
CARD16 width = mode->mode.width;
|
||||
CARD16 height = mode->mode.height;
|
||||
|
||||
if (width < minWidth) minWidth = width;
|
||||
if (width > maxWidth) maxWidth = width;
|
||||
if (height < minHeight) minHeight = height;
|
||||
if (height > maxHeight) maxHeight = height;
|
||||
}
|
||||
|
||||
if (minWidth != pScrPriv->minWidth) {
|
||||
pScrPriv->minWidth = minWidth; pScrPriv->changed = TRUE;
|
||||
}
|
||||
if (maxWidth != pScrPriv->maxWidth) {
|
||||
pScrPriv->maxWidth = maxWidth; pScrPriv->changed = TRUE;
|
||||
}
|
||||
if (minHeight != pScrPriv->minHeight) {
|
||||
pScrPriv->minHeight = minHeight; pScrPriv->changed = TRUE;
|
||||
}
|
||||
if (maxHeight != pScrPriv->maxHeight) {
|
||||
pScrPriv->maxHeight = maxHeight; pScrPriv->changed = TRUE;
|
||||
}
|
||||
|
||||
/* notice current mode */
|
||||
if (newMode)
|
||||
RRCrtcNotify (output->crtc, newMode, 0, 0, pScrPriv->rotation,
|
||||
1, &output);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Poll the driver for changed information
|
||||
*/
|
||||
Bool
|
||||
RRGetInfo (ScreenPtr pScreen)
|
||||
{
|
||||
rrScrPriv (pScreen);
|
||||
Rotation rotations;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < pScrPriv->numOutputs; i++)
|
||||
pScrPriv->outputs[i]->changed = FALSE;
|
||||
for (i = 0; i < pScrPriv->numCrtcs; i++)
|
||||
pScrPriv->crtcs[i]->changed = FALSE;
|
||||
|
||||
rotations = 0;
|
||||
pScrPriv->changed = FALSE;
|
||||
|
||||
if (!(*pScrPriv->rrGetInfo) (pScreen, &rotations))
|
||||
return FALSE;
|
||||
|
||||
#if RANDR_10_INTERFACE
|
||||
if (pScrPriv->nSizes)
|
||||
RRScanOldConfig (pScreen, rotations);
|
||||
#endif
|
||||
RRTellChanged (pScreen);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if RANDR_12_INTERFACE
|
||||
/*
|
||||
* Register the range of sizes for the screen
|
||||
*/
|
||||
void
|
||||
RRScreenSetSizeRange (ScreenPtr pScreen,
|
||||
CARD16 minWidth,
|
||||
CARD16 minHeight,
|
||||
CARD16 maxWidth,
|
||||
CARD16 maxHeight)
|
||||
{
|
||||
rrScrPriv (pScreen);
|
||||
|
||||
if (!pScrPriv)
|
||||
return;
|
||||
pScrPriv->minWidth = minWidth;
|
||||
pScrPriv->minHeight = minHeight;
|
||||
pScrPriv->maxWidth = maxWidth;
|
||||
pScrPriv->maxHeight = maxHeight;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RANDR_10_INTERFACE
|
||||
static Bool
|
||||
RRScreenSizeMatches (RRScreenSizePtr a,
|
||||
RRScreenSizePtr b)
|
||||
{
|
||||
if (a->width != b->width)
|
||||
return FALSE;
|
||||
if (a->height != b->height)
|
||||
return FALSE;
|
||||
if (a->mmWidth != b->mmWidth)
|
||||
return FALSE;
|
||||
if (a->mmHeight != b->mmHeight)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
RRScreenSizePtr
|
||||
RRRegisterSize (ScreenPtr pScreen,
|
||||
short width,
|
||||
short height,
|
||||
short mmWidth,
|
||||
short mmHeight)
|
||||
{
|
||||
rrScrPriv (pScreen);
|
||||
int i;
|
||||
RRScreenSize tmp;
|
||||
RRScreenSizePtr pNew;
|
||||
|
||||
if (!pScrPriv)
|
||||
return 0;
|
||||
|
||||
tmp.id = 0;
|
||||
tmp.width = width;
|
||||
tmp.height= height;
|
||||
tmp.mmWidth = mmWidth;
|
||||
tmp.mmHeight = mmHeight;
|
||||
tmp.pRates = 0;
|
||||
tmp.nRates = 0;
|
||||
for (i = 0; i < pScrPriv->nSizes; i++)
|
||||
if (RRScreenSizeMatches (&tmp, &pScrPriv->pSizes[i]))
|
||||
return &pScrPriv->pSizes[i];
|
||||
pNew = xrealloc (pScrPriv->pSizes,
|
||||
(pScrPriv->nSizes + 1) * sizeof (RRScreenSize));
|
||||
if (!pNew)
|
||||
return 0;
|
||||
pNew[pScrPriv->nSizes++] = tmp;
|
||||
pScrPriv->pSizes = pNew;
|
||||
return &pNew[pScrPriv->nSizes-1];
|
||||
}
|
||||
|
||||
Bool RRRegisterRate (ScreenPtr pScreen,
|
||||
RRScreenSizePtr pSize,
|
||||
int rate)
|
||||
{
|
||||
rrScrPriv(pScreen);
|
||||
int i;
|
||||
RRScreenRatePtr pNew, pRate;
|
||||
|
||||
if (!pScrPriv)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < pSize->nRates; i++)
|
||||
if (pSize->pRates[i].rate == rate)
|
||||
return TRUE;
|
||||
|
||||
pNew = xrealloc (pSize->pRates,
|
||||
(pSize->nRates + 1) * sizeof (RRScreenRate));
|
||||
if (!pNew)
|
||||
return FALSE;
|
||||
pRate = &pNew[pSize->nRates++];
|
||||
pRate->rate = rate;
|
||||
pSize->pRates = pNew;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Rotation
|
||||
RRGetRotation(ScreenPtr pScreen)
|
||||
{
|
||||
RROutputPtr output = RRFirstOutput (pScreen);
|
||||
|
||||
if (!output)
|
||||
return RR_Rotate_0;
|
||||
|
||||
return output->crtc->rotation;
|
||||
}
|
||||
|
||||
void
|
||||
RRSetCurrentConfig (ScreenPtr pScreen,
|
||||
Rotation rotation,
|
||||
int rate,
|
||||
RRScreenSizePtr pSize)
|
||||
{
|
||||
rrScrPriv (pScreen);
|
||||
|
||||
if (!pScrPriv)
|
||||
return;
|
||||
pScrPriv->size = pSize - pScrPriv->pSizes;
|
||||
pScrPriv->rotation = rotation;
|
||||
pScrPriv->rate = rate;
|
||||
}
|
||||
#endif
|
218
randr/rrmode.c
Normal file
218
randr/rrmode.c
Normal file
|
@ -0,0 +1,218 @@
|
|||
/*
|
||||
* Copyright © 2006 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "randrstr.h"
|
||||
|
||||
RESTYPE RRModeType;
|
||||
|
||||
static Bool
|
||||
RRModeEqual (xRRModeInfo *a, xRRModeInfo *b)
|
||||
{
|
||||
if (a->width != b->width) return FALSE;
|
||||
if (a->height != b->height) return FALSE;
|
||||
if (a->dotClock != b->dotClock) return FALSE;
|
||||
if (a->hSyncStart != b->hSyncStart) return FALSE;
|
||||
if (a->hSyncEnd != b->hSyncEnd) return FALSE;
|
||||
if (a->hTotal != b->hTotal) return FALSE;
|
||||
if (a->hSkew != b->hSkew) return FALSE;
|
||||
if (a->vSyncStart != b->vSyncStart) return FALSE;
|
||||
if (a->vSyncEnd != b->vSyncEnd) return FALSE;
|
||||
if (a->vTotal != b->vTotal) return FALSE;
|
||||
if (a->nameLength != b->nameLength) return FALSE;
|
||||
if (a->modeFlags != b->modeFlags) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Keep a list so it's easy to find modes in the resource database.
|
||||
*/
|
||||
static int num_modes;
|
||||
static RRModePtr *modes;
|
||||
|
||||
RRModePtr
|
||||
RRModeGet (xRRModeInfo *modeInfo,
|
||||
const char *name)
|
||||
{
|
||||
int i;
|
||||
RRModePtr mode;
|
||||
RRModePtr *newModes;
|
||||
|
||||
for (i = 0; i < num_modes; i++)
|
||||
{
|
||||
mode = modes[i];
|
||||
if (RRModeEqual (&mode->mode, modeInfo) &&
|
||||
!memcmp (name, mode->name, modeInfo->nameLength))
|
||||
{
|
||||
++mode->refcnt;
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
|
||||
mode = xalloc (sizeof (RRModeRec) + modeInfo->nameLength + 1);
|
||||
if (!mode)
|
||||
return NULL;
|
||||
mode->refcnt = 1;
|
||||
mode->mode = *modeInfo;
|
||||
mode->name = (char *) (mode + 1);
|
||||
memcpy (mode->name, name, modeInfo->nameLength);
|
||||
mode->name[modeInfo->nameLength] = '\0';
|
||||
mode->userDefined = FALSE;
|
||||
|
||||
if (num_modes)
|
||||
newModes = xrealloc (modes, (num_modes + 1) * sizeof (RRModePtr));
|
||||
else
|
||||
newModes = xalloc (sizeof (RRModePtr));
|
||||
|
||||
if (!newModes)
|
||||
{
|
||||
xfree (mode);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mode->mode.id = FakeClientID(0);
|
||||
if (!AddResource (mode->mode.id, RRModeType, (pointer) mode))
|
||||
return NULL;
|
||||
modes = newModes;
|
||||
modes[num_modes++] = mode;
|
||||
|
||||
/*
|
||||
* give the caller a reference to this mode
|
||||
*/
|
||||
++mode->refcnt;
|
||||
return mode;
|
||||
}
|
||||
|
||||
RRModePtr *
|
||||
RRModesForScreen (ScreenPtr pScreen, int *num_ret)
|
||||
{
|
||||
rrScrPriv(pScreen);
|
||||
int o;
|
||||
RRModePtr *screen_modes;
|
||||
int num_screen_modes = 0;
|
||||
|
||||
screen_modes = xalloc ((num_modes ? num_modes : 1) * sizeof (RRModePtr));
|
||||
|
||||
for (o = 0; o < pScrPriv->numOutputs; o++)
|
||||
{
|
||||
RROutputPtr output = pScrPriv->outputs[o];
|
||||
int m, n;
|
||||
|
||||
for (m = 0; m < output->numModes; m++)
|
||||
{
|
||||
RRModePtr mode = output->modes[m];
|
||||
for (n = 0; n < num_screen_modes; n++)
|
||||
if (screen_modes[n] == mode)
|
||||
break;
|
||||
if (n == num_screen_modes)
|
||||
screen_modes[num_screen_modes++] = mode;
|
||||
}
|
||||
}
|
||||
*num_ret = num_screen_modes;
|
||||
return screen_modes;
|
||||
}
|
||||
|
||||
void
|
||||
RRModeDestroy (RRModePtr mode)
|
||||
{
|
||||
int m;
|
||||
|
||||
if (--mode->refcnt > 0)
|
||||
return;
|
||||
for (m = 0; m < num_modes; m++)
|
||||
{
|
||||
if (modes[m] == mode)
|
||||
{
|
||||
memmove (modes + m, modes + m + 1,
|
||||
(num_modes - m - 1) * sizeof (RRModePtr));
|
||||
num_modes--;
|
||||
if (!num_modes)
|
||||
{
|
||||
xfree (modes);
|
||||
modes = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
xfree (mode);
|
||||
}
|
||||
|
||||
static int
|
||||
RRModeDestroyResource (pointer value, XID pid)
|
||||
{
|
||||
RRModeDestroy ((RRModePtr) value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Bool
|
||||
RRModeInit (void)
|
||||
{
|
||||
assert (num_modes == 0);
|
||||
assert (modes == NULL);
|
||||
RRModeType = CreateNewResourceType (RRModeDestroyResource);
|
||||
if (!RRModeType)
|
||||
return FALSE;
|
||||
#ifdef XResExtension
|
||||
RegisterResourceName (RRModeType, "MODE");
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRCreateMode (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRCreateModeReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRCreateModeReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRDestroyMode (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRDestroyModeReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRDestroyModeReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRAddOutputMode (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRAddOutputModeReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRAddOutputModeReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRDeleteOutputMode (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRDeleteOutputModeReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
461
randr/rroutput.c
Normal file
461
randr/rroutput.c
Normal file
|
@ -0,0 +1,461 @@
|
|||
/*
|
||||
* Copyright © 2006 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "randrstr.h"
|
||||
|
||||
RESTYPE RROutputType;
|
||||
|
||||
/*
|
||||
* Notify the output of some change
|
||||
*/
|
||||
void
|
||||
RROutputChanged (RROutputPtr output)
|
||||
{
|
||||
ScreenPtr pScreen = output->pScreen;
|
||||
|
||||
output->changed = TRUE;
|
||||
if (pScreen)
|
||||
{
|
||||
rrScrPriv (pScreen);
|
||||
pScrPriv->changed = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create an output
|
||||
*/
|
||||
|
||||
RROutputPtr
|
||||
RROutputCreate (const char *name,
|
||||
int nameLength,
|
||||
void *devPrivate)
|
||||
{
|
||||
RROutputPtr output;
|
||||
|
||||
output = xalloc (sizeof (RROutputRec) + nameLength + 1);
|
||||
if (!output)
|
||||
return NULL;
|
||||
output->id = FakeClientID (0);
|
||||
output->pScreen = NULL;
|
||||
output->name = (char *) (output + 1);
|
||||
output->nameLength = nameLength;
|
||||
memcpy (output->name, name, nameLength);
|
||||
output->name[nameLength] = '\0';
|
||||
output->connection = RR_UnknownConnection;
|
||||
output->subpixelOrder = SubPixelUnknown;
|
||||
output->mmWidth = 0;
|
||||
output->mmHeight = 0;
|
||||
output->crtc = NULL;
|
||||
output->numCrtcs = 0;
|
||||
output->crtcs = NULL;
|
||||
output->numClones = 0;
|
||||
output->clones = NULL;
|
||||
output->numModes = 0;
|
||||
output->numPreferred = 0;
|
||||
output->modes = NULL;
|
||||
output->properties = NULL;
|
||||
output->changed = FALSE;
|
||||
output->devPrivate = devPrivate;
|
||||
|
||||
if (!AddResource (output->id, RROutputType, (pointer) output))
|
||||
return NULL;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attach an Output to a screen. This is done as a separate step
|
||||
* so that an xf86-based driver can create Outputs in PreInit
|
||||
* before the Screen has been created
|
||||
*/
|
||||
|
||||
Bool
|
||||
RROutputAttachScreen (RROutputPtr output, ScreenPtr pScreen)
|
||||
{
|
||||
rrScrPriv (pScreen);
|
||||
RROutputPtr *outputs;
|
||||
|
||||
if (pScrPriv->numOutputs)
|
||||
outputs = xrealloc (pScrPriv->outputs,
|
||||
(pScrPriv->numOutputs + 1) * sizeof (RROutputPtr));
|
||||
else
|
||||
outputs = xalloc (sizeof (RROutputPtr));
|
||||
if (!outputs)
|
||||
return FALSE;
|
||||
output->pScreen = pScreen;
|
||||
pScrPriv->outputs = outputs;
|
||||
pScrPriv->outputs[pScrPriv->numOutputs++] = output;
|
||||
RROutputChanged (output);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Notify extension that output parameters have been changed
|
||||
*/
|
||||
Bool
|
||||
RROutputSetClones (RROutputPtr output,
|
||||
RROutputPtr *clones,
|
||||
int numClones)
|
||||
{
|
||||
RROutputPtr *newClones;
|
||||
int i;
|
||||
|
||||
if (numClones == output->numClones)
|
||||
{
|
||||
for (i = 0; i < numClones; i++)
|
||||
if (output->clones[i] != clones[i])
|
||||
break;
|
||||
if (i == numClones)
|
||||
return TRUE;
|
||||
}
|
||||
if (numClones)
|
||||
{
|
||||
newClones = xalloc (numClones * sizeof (RROutputPtr));
|
||||
if (!newClones)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
newClones = NULL;
|
||||
if (output->clones)
|
||||
xfree (output->clones);
|
||||
memcpy (newClones, clones, numClones * sizeof (RROutputPtr));
|
||||
output->clones = newClones;
|
||||
output->numClones = numClones;
|
||||
RROutputChanged (output);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
RROutputSetModes (RROutputPtr output,
|
||||
RRModePtr *modes,
|
||||
int numModes,
|
||||
int numPreferred)
|
||||
{
|
||||
RRModePtr *newModes;
|
||||
int i;
|
||||
|
||||
if (numModes == output->numModes && numPreferred == output->numPreferred)
|
||||
{
|
||||
for (i = 0; i < numModes; i++)
|
||||
if (output->modes[i] != modes[i])
|
||||
break;
|
||||
if (i == numModes)
|
||||
{
|
||||
for (i = 0; i < numModes; i++)
|
||||
RRModeDestroy (modes[i]);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (numModes)
|
||||
{
|
||||
newModes = xalloc (numModes * sizeof (RRModePtr));
|
||||
if (!newModes)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
newModes = NULL;
|
||||
if (output->modes)
|
||||
{
|
||||
for (i = 0; i < output->numModes; i++)
|
||||
RRModeDestroy (output->modes[i]);
|
||||
xfree (output->modes);
|
||||
}
|
||||
memcpy (newModes, modes, numModes * sizeof (RRModePtr));
|
||||
output->modes = newModes;
|
||||
output->numModes = numModes;
|
||||
output->numPreferred = numPreferred;
|
||||
RROutputChanged (output);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
RROutputSetCrtcs (RROutputPtr output,
|
||||
RRCrtcPtr *crtcs,
|
||||
int numCrtcs)
|
||||
{
|
||||
RRCrtcPtr *newCrtcs;
|
||||
int i;
|
||||
|
||||
if (numCrtcs == output->numCrtcs)
|
||||
{
|
||||
for (i = 0; i < numCrtcs; i++)
|
||||
if (output->crtcs[i] != crtcs[i])
|
||||
break;
|
||||
if (i == numCrtcs)
|
||||
return TRUE;
|
||||
}
|
||||
if (numCrtcs)
|
||||
{
|
||||
newCrtcs = xalloc (numCrtcs * sizeof (RRCrtcPtr));
|
||||
if (!newCrtcs)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
newCrtcs = NULL;
|
||||
if (output->crtcs)
|
||||
xfree (output->crtcs);
|
||||
memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr));
|
||||
output->crtcs = newCrtcs;
|
||||
output->numCrtcs = numCrtcs;
|
||||
RROutputChanged (output);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc)
|
||||
{
|
||||
if (output->crtc == crtc)
|
||||
return;
|
||||
output->crtc = crtc;
|
||||
RROutputChanged (output);
|
||||
}
|
||||
|
||||
Bool
|
||||
RROutputSetConnection (RROutputPtr output,
|
||||
CARD8 connection)
|
||||
{
|
||||
if (output->connection == connection)
|
||||
return TRUE;
|
||||
output->connection = connection;
|
||||
RROutputChanged (output);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
RROutputSetSubpixelOrder (RROutputPtr output,
|
||||
int subpixelOrder)
|
||||
{
|
||||
if (output->subpixelOrder == subpixelOrder)
|
||||
return TRUE;
|
||||
|
||||
output->subpixelOrder = subpixelOrder;
|
||||
RROutputChanged (output);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
RROutputSetPhysicalSize (RROutputPtr output,
|
||||
int mmWidth,
|
||||
int mmHeight)
|
||||
{
|
||||
if (output->mmWidth == mmWidth && output->mmHeight == mmHeight)
|
||||
return TRUE;
|
||||
output->mmWidth = mmWidth;
|
||||
output->mmHeight = mmHeight;
|
||||
RROutputChanged (output);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
rrScrPriv (pScreen);
|
||||
xRROutputChangeNotifyEvent oe;
|
||||
RRCrtcPtr crtc = output->crtc;
|
||||
RRModePtr mode = crtc ? crtc->mode : 0;
|
||||
|
||||
oe.type = RRNotify + RREventBase;
|
||||
oe.subCode = RRNotify_OutputChange;
|
||||
oe.sequenceNumber = client->sequence;
|
||||
oe.timestamp = pScrPriv->lastSetTime.milliseconds;
|
||||
oe.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
|
||||
oe.window = pWin->drawable.id;
|
||||
oe.output = output->id;
|
||||
if (crtc)
|
||||
{
|
||||
oe.crtc = crtc->id;
|
||||
oe.mode = mode ? mode->mode.id : None;
|
||||
oe.rotation = crtc->rotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
oe.crtc = None;
|
||||
oe.mode = None;
|
||||
oe.rotation = RR_Rotate_0;
|
||||
}
|
||||
oe.connection = output->connection;
|
||||
oe.subpixelOrder = output->subpixelOrder;
|
||||
WriteEventsToClient (client, 1, (xEvent *) &oe);
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroy a Output at shutdown
|
||||
*/
|
||||
void
|
||||
RROutputDestroy (RROutputPtr crtc)
|
||||
{
|
||||
FreeResource (crtc->id, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
RROutputDestroyResource (pointer value, XID pid)
|
||||
{
|
||||
RROutputPtr output = (RROutputPtr) value;
|
||||
ScreenPtr pScreen = output->pScreen;
|
||||
|
||||
if (pScreen)
|
||||
{
|
||||
rrScrPriv(pScreen);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < pScrPriv->numOutputs; i++)
|
||||
{
|
||||
if (pScrPriv->outputs[i] == output)
|
||||
{
|
||||
memmove (pScrPriv->outputs + i, pScrPriv->outputs + i + 1,
|
||||
(pScrPriv->numOutputs - (i - 1)) * sizeof (RROutputPtr));
|
||||
--pScrPriv->numOutputs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (output->modes)
|
||||
xfree (output->modes);
|
||||
if (output->crtcs)
|
||||
xfree (output->crtcs);
|
||||
if (output->clones)
|
||||
xfree (output->clones);
|
||||
RRDeleteAllOutputProperties (output);
|
||||
xfree (output);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize output type
|
||||
*/
|
||||
Bool
|
||||
RROutputInit (void)
|
||||
{
|
||||
RROutputType = CreateNewResourceType (RROutputDestroyResource);
|
||||
if (!RROutputType)
|
||||
return FALSE;
|
||||
#ifdef XResExtension
|
||||
RegisterResourceName (RROutputType, "OUTPUT");
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define OutputInfoExtra (SIZEOF(xRRGetOutputInfoReply) - 32)
|
||||
|
||||
int
|
||||
ProcRRGetOutputInfo (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetOutputInfoReq);;
|
||||
xRRGetOutputInfoReply rep;
|
||||
RROutputPtr output;
|
||||
CARD8 *extra;
|
||||
unsigned long extraLen;
|
||||
ScreenPtr pScreen;
|
||||
rrScrPrivPtr pScrPriv;
|
||||
RRCrtc *crtcs;
|
||||
RRMode *modes;
|
||||
RROutput *clones;
|
||||
char *name;
|
||||
int i, n;
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetOutputInfoReq);
|
||||
output = LookupOutput(client, stuff->output, SecurityReadAccess);
|
||||
|
||||
if (!output)
|
||||
return RRErrorBase + BadRROutput;
|
||||
|
||||
pScreen = output->pScreen;
|
||||
pScrPriv = rrGetScrPriv(pScreen);
|
||||
|
||||
rep.type = X_Reply;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.length = OutputInfoExtra >> 2;
|
||||
rep.timestamp = pScrPriv->lastSetTime.milliseconds;
|
||||
rep.crtc = output->crtc ? output->crtc->id : None;
|
||||
rep.mmWidth = output->mmWidth;
|
||||
rep.mmHeight = output->mmHeight;
|
||||
rep.connection = output->connection;
|
||||
rep.subpixelOrder = output->subpixelOrder;
|
||||
rep.nCrtcs = output->numCrtcs;
|
||||
rep.nModes = output->numModes;
|
||||
rep.nPreferred = output->numPreferred;
|
||||
rep.nClones = output->numClones;
|
||||
rep.nameLength = output->nameLength;
|
||||
|
||||
extraLen = ((output->numCrtcs +
|
||||
output->numModes +
|
||||
output->numClones +
|
||||
((rep.nameLength + 3) >> 2)) << 2);
|
||||
|
||||
if (extraLen)
|
||||
{
|
||||
rep.length += extraLen >> 2;
|
||||
extra = xalloc (extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
}
|
||||
else
|
||||
extra = NULL;
|
||||
|
||||
crtcs = (RRCrtc *) extra;
|
||||
modes = (RRMode *) (crtcs + output->numCrtcs);
|
||||
clones = (RROutput *) (modes + output->numModes);
|
||||
name = (char *) (clones + output->numClones);
|
||||
|
||||
for (i = 0; i < output->numCrtcs; i++)
|
||||
{
|
||||
crtcs[i] = output->crtcs[i]->id;
|
||||
if (client->swapped)
|
||||
swapl (&crtcs[i], n);
|
||||
}
|
||||
for (i = 0; i < output->numModes; i++)
|
||||
{
|
||||
modes[i] = output->modes[i]->mode.id;
|
||||
if (client->swapped)
|
||||
swapl (&modes[i], n);
|
||||
}
|
||||
for (i = 0; i < output->numClones; i++)
|
||||
{
|
||||
clones[i] = output->clones[i]->id;
|
||||
if (client->swapped)
|
||||
swapl (&clones[i], n);
|
||||
}
|
||||
memcpy (name, output->name, output->nameLength);
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swapl(&rep.timestamp, n);
|
||||
swapl(&rep.crtc, n);
|
||||
swapl(&rep.mmWidth, n);
|
||||
swapl(&rep.mmHeight, n);
|
||||
swaps(&rep.nCrtcs, n);
|
||||
swaps(&rep.nModes, n);
|
||||
swaps(&rep.nClones, n);
|
||||
swaps(&rep.nameLength, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *)&rep);
|
||||
if (extraLen)
|
||||
{
|
||||
WriteToClient (client, extraLen, (char *) extra);
|
||||
xfree (extra);
|
||||
}
|
||||
|
||||
return client->noClientException;
|
||||
}
|
137
randr/rrpointer.c
Normal file
137
randr/rrpointer.c
Normal file
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Copyright © 2006 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "randrstr.h"
|
||||
|
||||
/*
|
||||
* When the pointer moves, check to see if the specified position is outside
|
||||
* any of theavailable CRTCs and move it to a 'sensible' place if so, where
|
||||
* sensible is the closest monitor to the departing edge.
|
||||
*
|
||||
* Returns whether the position was adjusted
|
||||
*/
|
||||
|
||||
static Bool
|
||||
RRCrtcContainsPosition (RRCrtcPtr crtc, int x, int y)
|
||||
{
|
||||
RRModePtr mode = crtc->mode;
|
||||
|
||||
if (!mode)
|
||||
return FALSE;
|
||||
if (crtc->x <= x && x < crtc->x + mode->mode.width &&
|
||||
crtc->y <= y && y < crtc->y + mode->mode.height)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the CRTC nearest the specified position, ignoring 'skip'
|
||||
*/
|
||||
static void
|
||||
RRPointerToNearestCrtc (ScreenPtr pScreen, int x, int y, RRCrtcPtr skip)
|
||||
{
|
||||
rrScrPriv (pScreen);
|
||||
int c;
|
||||
RRCrtcPtr nearest = NULL;
|
||||
int best = 0;
|
||||
int best_dx = 0, best_dy = 0;
|
||||
|
||||
for (c = 0; c < pScrPriv->numCrtcs; c++)
|
||||
{
|
||||
RRCrtcPtr crtc = pScrPriv->crtcs[c];
|
||||
RRModePtr mode = crtc->mode;
|
||||
int dx, dy;
|
||||
int dist;
|
||||
|
||||
if (!mode)
|
||||
continue;
|
||||
if (crtc == skip)
|
||||
continue;
|
||||
if (x < crtc->x)
|
||||
dx = crtc->x - x;
|
||||
else if (x > crtc->x + mode->mode.width)
|
||||
dx = x - (crtc->x + mode->mode.width);
|
||||
else
|
||||
dx = 0;
|
||||
if (y < crtc->y)
|
||||
dy = crtc->y - x;
|
||||
else if (y > crtc->y + mode->mode.height)
|
||||
dy = y - (crtc->y + mode->mode.height);
|
||||
else
|
||||
dy = 0;
|
||||
dist = dx + dy;
|
||||
if (!nearest || dist < best)
|
||||
{
|
||||
nearest = crtc;
|
||||
best_dx = dx;
|
||||
best_dy = dy;
|
||||
}
|
||||
}
|
||||
if (best_dx || best_dy)
|
||||
(*pScreen->SetCursorPosition) (pScreen, x + best_dx, y + best_dy, TRUE);
|
||||
pScrPriv->pointerCrtc = nearest;
|
||||
}
|
||||
|
||||
void
|
||||
RRPointerMoved (ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
rrScrPriv (pScreen);
|
||||
RRCrtcPtr pointerCrtc = pScrPriv->pointerCrtc;;
|
||||
int c;
|
||||
|
||||
/* Check last known CRTC */
|
||||
if (pointerCrtc && RRCrtcContainsPosition (pointerCrtc, x, y))
|
||||
return;
|
||||
|
||||
/* Check all CRTCs */
|
||||
for (c = 0; c < pScrPriv->numCrtcs; c++)
|
||||
{
|
||||
RRCrtcPtr crtc = pScrPriv->crtcs[c];
|
||||
|
||||
if (RRCrtcContainsPosition (crtc, x, y))
|
||||
{
|
||||
/* Remember containing CRTC */
|
||||
pScrPriv->pointerCrtc = crtc;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* None contain pointer, find nearest */
|
||||
RRPointerToNearestCrtc (pScreen, x, y, pointerCrtc);
|
||||
}
|
||||
|
||||
/*
|
||||
* When the screen is reconfigured, move the pointer to the nearest
|
||||
* CRTC
|
||||
*/
|
||||
void
|
||||
RRPointerScreenConfigured (ScreenPtr pScreen)
|
||||
{
|
||||
WindowPtr pRoot = GetCurrentRootWindow ();
|
||||
ScreenPtr pCurrentScreen = pRoot ? pRoot->drawable.pScreen : NULL;
|
||||
int x, y;
|
||||
|
||||
if (pScreen != pCurrentScreen)
|
||||
return;
|
||||
GetSpritePosition (&x, &y);
|
||||
RRPointerToNearestCrtc (pScreen, x, y, NULL);
|
||||
}
|
431
randr/rrproperty.c
Normal file
431
randr/rrproperty.c
Normal file
|
@ -0,0 +1,431 @@
|
|||
/*
|
||||
* Copyright © 2006 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "randrstr.h"
|
||||
#include "propertyst.h"
|
||||
#include "swaprep.h"
|
||||
|
||||
static void
|
||||
RRDeliverEvent (ScreenPtr pScreen, xEvent *event, CARD32 mask)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
RRDeleteAllOutputProperties (RROutputPtr output)
|
||||
{
|
||||
PropertyPtr prop, next;
|
||||
xRROutputPropertyNotifyEvent event;
|
||||
|
||||
for (prop = output->properties; prop; prop = next)
|
||||
{
|
||||
next = prop->next;
|
||||
event.type = RREventBase + RRNotify;
|
||||
event.subCode = RRNotify_OutputProperty;
|
||||
event.output = output->id;
|
||||
event.state = PropertyDelete;
|
||||
event.atom = prop->propertyName;
|
||||
event.timestamp = currentTime.milliseconds;
|
||||
RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
|
||||
xfree(prop->data);
|
||||
xfree(prop);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RRDeleteOutputProperty (RROutputPtr output, Atom property)
|
||||
{
|
||||
PropertyPtr prop, *prev;
|
||||
xRROutputPropertyNotifyEvent event;
|
||||
|
||||
for (prev = &output->properties; (prop = *prev); prev = &(prop->next))
|
||||
if (prop->propertyName == property)
|
||||
break;
|
||||
if (prop)
|
||||
{
|
||||
*prev = prop->next;
|
||||
event.type = RREventBase + RRNotify;
|
||||
event.subCode = RRNotify_OutputProperty;
|
||||
event.output = output->id;
|
||||
event.state = PropertyDelete;
|
||||
event.atom = prop->propertyName;
|
||||
event.timestamp = currentTime.milliseconds;
|
||||
RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
|
||||
xfree(prop->data);
|
||||
xfree(prop);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
|
||||
int format, int mode, unsigned long len,
|
||||
pointer value, Bool sendevent)
|
||||
{
|
||||
PropertyPtr prop;
|
||||
xRROutputPropertyNotifyEvent event;
|
||||
int sizeInBytes;
|
||||
int totalSize;
|
||||
pointer data;
|
||||
|
||||
sizeInBytes = format >> 3;
|
||||
totalSize = len * sizeInBytes;
|
||||
|
||||
/* first see if property already exists */
|
||||
|
||||
for (prop = output->properties; prop; prop = prop->next)
|
||||
if (prop->propertyName == property)
|
||||
break;
|
||||
|
||||
if (!prop) /* just add to list */
|
||||
{
|
||||
prop = (PropertyPtr)xalloc(sizeof(PropertyRec));
|
||||
if (!prop)
|
||||
return(BadAlloc);
|
||||
data = (pointer)xalloc(totalSize);
|
||||
if (!data && len)
|
||||
{
|
||||
xfree(prop);
|
||||
return(BadAlloc);
|
||||
}
|
||||
prop->propertyName = property;
|
||||
prop->type = type;
|
||||
prop->format = format;
|
||||
prop->data = data;
|
||||
if (len)
|
||||
memmove((char *)data, (char *)value, totalSize);
|
||||
prop->size = len;
|
||||
prop->next = output->properties;
|
||||
output->properties = prop;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* To append or prepend to a property the request format and type
|
||||
must match those of the already defined property. The
|
||||
existing format and type are irrelevant when using the mode
|
||||
"PropModeReplace" since they will be written over. */
|
||||
|
||||
if ((format != prop->format) && (mode != PropModeReplace))
|
||||
return(BadMatch);
|
||||
if ((prop->type != type) && (mode != PropModeReplace))
|
||||
return(BadMatch);
|
||||
if (mode == PropModeReplace)
|
||||
{
|
||||
if (totalSize != prop->size * (prop->format >> 3))
|
||||
{
|
||||
data = (pointer)xrealloc(prop->data, totalSize);
|
||||
if (!data && len)
|
||||
return(BadAlloc);
|
||||
prop->data = data;
|
||||
}
|
||||
if (len)
|
||||
memmove((char *)prop->data, (char *)value, totalSize);
|
||||
prop->size = len;
|
||||
prop->type = type;
|
||||
prop->format = format;
|
||||
}
|
||||
else if (len == 0)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
else if (mode == PropModeAppend)
|
||||
{
|
||||
data = (pointer)xrealloc(prop->data,
|
||||
sizeInBytes * (len + prop->size));
|
||||
if (!data)
|
||||
return(BadAlloc);
|
||||
prop->data = data;
|
||||
memmove(&((char *)data)[prop->size * sizeInBytes],
|
||||
(char *)value,
|
||||
totalSize);
|
||||
prop->size += len;
|
||||
}
|
||||
else if (mode == PropModePrepend)
|
||||
{
|
||||
data = (pointer)xalloc(sizeInBytes * (len + prop->size));
|
||||
if (!data)
|
||||
return(BadAlloc);
|
||||
memmove(&((char *)data)[totalSize], (char *)prop->data,
|
||||
(int)(prop->size * sizeInBytes));
|
||||
memmove((char *)data, (char *)value, totalSize);
|
||||
xfree(prop->data);
|
||||
prop->data = data;
|
||||
prop->size += len;
|
||||
}
|
||||
}
|
||||
if (sendevent)
|
||||
{
|
||||
event.type = RREventBase + RRNotify;
|
||||
event.subCode = RRNotify_OutputProperty;
|
||||
event.output = output->id;
|
||||
event.state = PropertyNewValue;
|
||||
event.atom = prop->propertyName;
|
||||
event.timestamp = currentTime.milliseconds;
|
||||
RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
|
||||
}
|
||||
return(Success);
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRListOutputProperties (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRListOutputPropertiesReq);
|
||||
Atom *pAtoms = NULL, *temppAtoms;
|
||||
xRRListOutputPropertiesReply rep;
|
||||
int numProps = 0;
|
||||
RROutputPtr output;
|
||||
PropertyPtr prop;
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq);
|
||||
|
||||
output = LookupOutput (client, stuff->output, SecurityReadAccess);
|
||||
|
||||
if (!output)
|
||||
return RRErrorBase + BadRROutput;
|
||||
|
||||
for (prop = output->properties; prop; prop = prop->next)
|
||||
numProps++;
|
||||
if (numProps)
|
||||
if(!(pAtoms = (Atom *)ALLOCATE_LOCAL(numProps * sizeof(Atom))))
|
||||
return(BadAlloc);
|
||||
|
||||
rep.type = X_Reply;
|
||||
rep.nProperties = numProps;
|
||||
rep.length = (numProps * sizeof(Atom)) >> 2;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
temppAtoms = pAtoms;
|
||||
for (prop = output->properties; prop; prop = prop->next)
|
||||
*temppAtoms++ = prop->propertyName;
|
||||
|
||||
WriteReplyToClient(client, sizeof(xRRListOutputPropertiesReply), &rep);
|
||||
if (numProps)
|
||||
{
|
||||
client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write;
|
||||
WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
|
||||
DEALLOCATE_LOCAL(pAtoms);
|
||||
}
|
||||
return(client->noClientException);
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRChangeOutputProperty (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRChangeOutputPropertyReq);
|
||||
RROutputPtr output;
|
||||
char format, mode;
|
||||
unsigned long len;
|
||||
int sizeInBytes;
|
||||
int totalSize;
|
||||
int err;
|
||||
|
||||
REQUEST_AT_LEAST_SIZE(xRRChangeOutputPropertyReq);
|
||||
UpdateCurrentTime();
|
||||
format = stuff->format;
|
||||
mode = stuff->mode;
|
||||
if ((mode != PropModeReplace) && (mode != PropModeAppend) &&
|
||||
(mode != PropModePrepend))
|
||||
{
|
||||
client->errorValue = mode;
|
||||
return BadValue;
|
||||
}
|
||||
if ((format != 8) && (format != 16) && (format != 32))
|
||||
{
|
||||
client->errorValue = format;
|
||||
return BadValue;
|
||||
}
|
||||
len = stuff->nUnits;
|
||||
if (len > ((0xffffffff - sizeof(xChangePropertyReq)) >> 2))
|
||||
return BadLength;
|
||||
sizeInBytes = format>>3;
|
||||
totalSize = len * sizeInBytes;
|
||||
REQUEST_FIXED_SIZE(xRRChangeOutputPropertyReq, totalSize);
|
||||
|
||||
output = LookupOutput (client, stuff->output, SecurityWriteAccess);
|
||||
if (!output)
|
||||
return RRErrorBase + BadRROutput;
|
||||
|
||||
if (!ValidAtom(stuff->property))
|
||||
{
|
||||
client->errorValue = stuff->property;
|
||||
return(BadAtom);
|
||||
}
|
||||
if (!ValidAtom(stuff->type))
|
||||
{
|
||||
client->errorValue = stuff->type;
|
||||
return(BadAtom);
|
||||
}
|
||||
|
||||
err = RRChangeOutputProperty(output, stuff->property,
|
||||
stuff->type, (int)format,
|
||||
(int)mode, len, (pointer)&stuff[1], TRUE);
|
||||
if (err != Success)
|
||||
return err;
|
||||
else
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRDeleteOutputProperty (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRDeleteOutputPropertyReq);
|
||||
RROutputPtr output;
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq);
|
||||
UpdateCurrentTime();
|
||||
output = LookupOutput (client, stuff->output, SecurityWriteAccess);
|
||||
if (!output)
|
||||
return RRErrorBase + BadRROutput;
|
||||
|
||||
if (!ValidAtom(stuff->property))
|
||||
{
|
||||
client->errorValue = stuff->property;
|
||||
return (BadAtom);
|
||||
}
|
||||
|
||||
|
||||
RRDeleteOutputProperty(output, stuff->property);
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRGetOutputProperty (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetOutputPropertyReq);
|
||||
PropertyPtr prop, *prev;
|
||||
unsigned long n, len, ind;
|
||||
RROutputPtr output;
|
||||
xRRGetOutputPropertyReply reply;
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq);
|
||||
if (stuff->delete)
|
||||
UpdateCurrentTime();
|
||||
output = LookupOutput (client, stuff->output,
|
||||
stuff->delete ? SecurityWriteAccess :
|
||||
SecurityReadAccess);
|
||||
if (!output)
|
||||
return RRErrorBase + BadRROutput;
|
||||
|
||||
if (!ValidAtom(stuff->property))
|
||||
{
|
||||
client->errorValue = stuff->property;
|
||||
return(BadAtom);
|
||||
}
|
||||
if ((stuff->delete != xTrue) && (stuff->delete != xFalse))
|
||||
{
|
||||
client->errorValue = stuff->delete;
|
||||
return(BadValue);
|
||||
}
|
||||
if ((stuff->type != AnyPropertyType) && !ValidAtom(stuff->type))
|
||||
{
|
||||
client->errorValue = stuff->type;
|
||||
return(BadAtom);
|
||||
}
|
||||
|
||||
for (prev = &output->properties; (prop = *prev); prev = &prop->next)
|
||||
if (prop->propertyName == stuff->property)
|
||||
break;
|
||||
|
||||
reply.type = X_Reply;
|
||||
reply.sequenceNumber = client->sequence;
|
||||
if (!prop)
|
||||
{
|
||||
reply.nItems = 0;
|
||||
reply.length = 0;
|
||||
reply.bytesAfter = 0;
|
||||
reply.propertyType = None;
|
||||
reply.format = 0;
|
||||
WriteReplyToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
|
||||
return(client->noClientException);
|
||||
}
|
||||
|
||||
/* If the request type and actual type don't match. Return the
|
||||
property information, but not the data. */
|
||||
|
||||
if (((stuff->type != prop->type) &&
|
||||
(stuff->type != AnyPropertyType))
|
||||
)
|
||||
{
|
||||
reply.bytesAfter = prop->size;
|
||||
reply.format = prop->format;
|
||||
reply.length = 0;
|
||||
reply.nItems = 0;
|
||||
reply.propertyType = prop->type;
|
||||
WriteReplyToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
|
||||
return(client->noClientException);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return type, format, value to client
|
||||
*/
|
||||
n = (prop->format/8) * prop->size; /* size (bytes) of prop */
|
||||
ind = stuff->longOffset << 2;
|
||||
|
||||
/* If longOffset is invalid such that it causes "len" to
|
||||
be negative, it's a value error. */
|
||||
|
||||
if (n < ind)
|
||||
{
|
||||
client->errorValue = stuff->longOffset;
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
len = min(n - ind, 4 * stuff->longLength);
|
||||
|
||||
reply.bytesAfter = n - (ind + len);
|
||||
reply.format = prop->format;
|
||||
reply.length = (len + 3) >> 2;
|
||||
reply.nItems = len / (prop->format / 8 );
|
||||
reply.propertyType = prop->type;
|
||||
|
||||
if (stuff->delete && (reply.bytesAfter == 0))
|
||||
{
|
||||
xRROutputPropertyNotifyEvent event;
|
||||
|
||||
event.type = RREventBase + RRNotify;
|
||||
event.subCode = RRNotify_OutputProperty;
|
||||
event.output = output->id;
|
||||
event.state = PropertyDelete;
|
||||
event.atom = prop->propertyName;
|
||||
event.timestamp = currentTime.milliseconds;
|
||||
RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
|
||||
}
|
||||
|
||||
WriteReplyToClient(client, sizeof(xGenericReply), &reply);
|
||||
if (len)
|
||||
{
|
||||
switch (reply.format) {
|
||||
case 32: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write; break;
|
||||
case 16: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write; break;
|
||||
default: client->pSwapReplyFunc = (ReplySwapPtr)WriteToClient; break;
|
||||
}
|
||||
WriteSwappedDataToClient(client, len,
|
||||
(char *)prop->data + ind);
|
||||
}
|
||||
|
||||
if (stuff->delete && (reply.bytesAfter == 0))
|
||||
{ /* delete the Property */
|
||||
*prev = prop->next;
|
||||
xfree(prop->data);
|
||||
xfree(prop);
|
||||
}
|
||||
return(client->noClientException);
|
||||
}
|
||||
|
913
randr/rrscreen.c
Normal file
913
randr/rrscreen.c
Normal file
|
@ -0,0 +1,913 @@
|
|||
/*
|
||||
* Copyright © 2006 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "randrstr.h"
|
||||
|
||||
extern char *ConnectionInfo;
|
||||
|
||||
static int padlength[4] = {0, 3, 2, 1};
|
||||
|
||||
/*
|
||||
* Edit connection information block so that new clients
|
||||
* see the current screen size on connect
|
||||
*/
|
||||
static void
|
||||
RREditConnectionInfo (ScreenPtr pScreen)
|
||||
{
|
||||
xConnSetup *connSetup;
|
||||
char *vendor;
|
||||
xPixmapFormat *formats;
|
||||
xWindowRoot *root;
|
||||
xDepth *depth;
|
||||
xVisualType *visual;
|
||||
int screen = 0;
|
||||
int d;
|
||||
|
||||
connSetup = (xConnSetup *) ConnectionInfo;
|
||||
vendor = (char *) connSetup + sizeof (xConnSetup);
|
||||
formats = (xPixmapFormat *) ((char *) vendor +
|
||||
connSetup->nbytesVendor +
|
||||
padlength[connSetup->nbytesVendor & 3]);
|
||||
root = (xWindowRoot *) ((char *) formats +
|
||||
sizeof (xPixmapFormat) * screenInfo.numPixmapFormats);
|
||||
while (screen != pScreen->myNum)
|
||||
{
|
||||
depth = (xDepth *) ((char *) root +
|
||||
sizeof (xWindowRoot));
|
||||
for (d = 0; d < root->nDepths; d++)
|
||||
{
|
||||
visual = (xVisualType *) ((char *) depth +
|
||||
sizeof (xDepth));
|
||||
depth = (xDepth *) ((char *) visual +
|
||||
depth->nVisuals * sizeof (xVisualType));
|
||||
}
|
||||
root = (xWindowRoot *) ((char *) depth);
|
||||
screen++;
|
||||
}
|
||||
root->pixWidth = pScreen->width;
|
||||
root->pixHeight = pScreen->height;
|
||||
root->mmWidth = pScreen->mmWidth;
|
||||
root->mmHeight = pScreen->mmHeight;
|
||||
}
|
||||
|
||||
void
|
||||
RRSendConfigNotify (ScreenPtr pScreen)
|
||||
{
|
||||
WindowPtr pWin = WindowTable[pScreen->myNum];
|
||||
xEvent event;
|
||||
|
||||
event.u.u.type = ConfigureNotify;
|
||||
event.u.configureNotify.window = pWin->drawable.id;
|
||||
event.u.configureNotify.aboveSibling = None;
|
||||
event.u.configureNotify.x = 0;
|
||||
event.u.configureNotify.y = 0;
|
||||
|
||||
/* XXX xinerama stuff ? */
|
||||
|
||||
event.u.configureNotify.width = pWin->drawable.width;
|
||||
event.u.configureNotify.height = pWin->drawable.height;
|
||||
event.u.configureNotify.borderWidth = wBorderWidth (pWin);
|
||||
event.u.configureNotify.override = pWin->overrideRedirect;
|
||||
DeliverEvents(pWin, &event, 1, NullWindow);
|
||||
}
|
||||
|
||||
void
|
||||
RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
|
||||
{
|
||||
rrScrPriv (pScreen);
|
||||
xRRScreenChangeNotifyEvent se;
|
||||
RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL;
|
||||
RROutputPtr output = pScrPriv->numOutputs ? pScrPriv->outputs[0] : NULL;
|
||||
RRModePtr mode = crtc ? crtc->mode : NULL;
|
||||
WindowPtr pRoot = WindowTable[pScreen->myNum];
|
||||
int i;
|
||||
|
||||
se.type = RRScreenChangeNotify + RREventBase;
|
||||
se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0);
|
||||
se.timestamp = pScrPriv->lastSetTime.milliseconds;
|
||||
se.sequenceNumber = client->sequence;
|
||||
se.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
|
||||
se.root = pRoot->drawable.id;
|
||||
se.window = pWin->drawable.id;
|
||||
#ifdef RENDER
|
||||
se.subpixelOrder = PictureGetSubpixelOrder (pScreen);
|
||||
#else
|
||||
se.subpixelOrder = SubPixelUnknown;
|
||||
#endif
|
||||
|
||||
se.sequenceNumber = client->sequence;
|
||||
if (mode)
|
||||
{
|
||||
se.sizeID = -1;
|
||||
for (i = 0; i < output->numModes; i++)
|
||||
if (mode == output->modes[i])
|
||||
{
|
||||
se.sizeID = i;
|
||||
break;
|
||||
}
|
||||
se.widthInPixels = mode->mode.width;
|
||||
se.heightInPixels = mode->mode.height;
|
||||
se.widthInMillimeters = pScreen->mmWidth;
|
||||
se.heightInMillimeters = pScreen->mmHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* This "shouldn't happen", but a broken DDX can
|
||||
* forget to set the current configuration on GetInfo
|
||||
*/
|
||||
se.sizeID = 0xffff;
|
||||
se.widthInPixels = 0;
|
||||
se.heightInPixels = 0;
|
||||
se.widthInMillimeters = 0;
|
||||
se.heightInMillimeters = 0;
|
||||
}
|
||||
WriteEventsToClient (client, 1, (xEvent *) &se);
|
||||
}
|
||||
|
||||
/*
|
||||
* Notify the extension that the screen size has been changed.
|
||||
* The driver is responsible for calling this whenever it has changed
|
||||
* the size of the screen
|
||||
*/
|
||||
void
|
||||
RRScreenSizeNotify (ScreenPtr pScreen)
|
||||
{
|
||||
rrScrPriv(pScreen);
|
||||
/*
|
||||
* Deliver ConfigureNotify events when root changes
|
||||
* pixel size
|
||||
*/
|
||||
if (pScrPriv->width == pScreen->width &&
|
||||
pScrPriv->height == pScreen->height)
|
||||
return;
|
||||
|
||||
pScrPriv->width = pScreen->width;
|
||||
pScrPriv->height = pScreen->height;
|
||||
pScrPriv->changed = TRUE;
|
||||
/* pScrPriv->sizeChanged = TRUE; */
|
||||
|
||||
RRTellChanged (pScreen);
|
||||
RRSendConfigNotify (pScreen);
|
||||
RREditConnectionInfo (pScreen);
|
||||
|
||||
RRPointerScreenConfigured (pScreen);
|
||||
/*
|
||||
* Fix pointer bounds and location
|
||||
*/
|
||||
ScreenRestructured (pScreen);
|
||||
}
|
||||
|
||||
/*
|
||||
* Request that the screen be resized
|
||||
*/
|
||||
Bool
|
||||
RRScreenSizeSet (ScreenPtr pScreen,
|
||||
CARD16 width,
|
||||
CARD16 height,
|
||||
CARD32 mmWidth,
|
||||
CARD32 mmHeight)
|
||||
{
|
||||
rrScrPriv(pScreen);
|
||||
|
||||
#if RANDR_12_INTERFACE
|
||||
if (pScrPriv->rrScreenSetSize)
|
||||
{
|
||||
return (*pScrPriv->rrScreenSetSize) (pScreen,
|
||||
width, height,
|
||||
mmWidth, mmHeight);
|
||||
}
|
||||
#endif
|
||||
#if RANDR_10_INTERFACE
|
||||
if (pScrPriv->rrSetConfig)
|
||||
{
|
||||
return TRUE; /* can't set size separately */
|
||||
}
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve valid screen size range
|
||||
*/
|
||||
int
|
||||
ProcRRGetScreenSizeRange (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetScreenSizeRangeReq);
|
||||
xRRGetScreenSizeRangeReply rep;
|
||||
WindowPtr pWin;
|
||||
ScreenPtr pScreen;
|
||||
rrScrPrivPtr pScrPriv;
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
|
||||
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
|
||||
SecurityReadAccess);
|
||||
|
||||
if (!pWin)
|
||||
return BadWindow;
|
||||
|
||||
pScreen = pWin->drawable.pScreen;
|
||||
pScrPriv = rrGetScrPriv(pScreen);
|
||||
|
||||
rep.type = X_Reply;
|
||||
rep.pad = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.length = 0;
|
||||
|
||||
if (pScrPriv)
|
||||
{
|
||||
RRGetInfo (pScreen);
|
||||
rep.minWidth = pScrPriv->minWidth;
|
||||
rep.minHeight = pScrPriv->minHeight;
|
||||
rep.maxWidth = pScrPriv->maxWidth;
|
||||
rep.maxHeight = pScrPriv->maxHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
rep.maxWidth = rep.minWidth = pScreen->width;
|
||||
rep.maxHeight = rep.minHeight = pScreen->height;
|
||||
}
|
||||
if (client->swapped)
|
||||
{
|
||||
int n;
|
||||
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swaps(&rep.minWidth, n);
|
||||
swaps(&rep.minHeight, n);
|
||||
swaps(&rep.maxWidth, n);
|
||||
swaps(&rep.maxHeight, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep);
|
||||
return (client->noClientException);
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRSetScreenSize (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRSetScreenSizeReq);
|
||||
WindowPtr pWin;
|
||||
ScreenPtr pScreen;
|
||||
rrScrPrivPtr pScrPriv;
|
||||
RRCrtcPtr crtc;
|
||||
int i;
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
|
||||
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
|
||||
SecurityReadAccess);
|
||||
|
||||
if (!pWin)
|
||||
return BadWindow;
|
||||
|
||||
pScreen = pWin->drawable.pScreen;
|
||||
pScrPriv = rrGetScrPriv(pScreen);
|
||||
if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width)
|
||||
{
|
||||
client->errorValue = stuff->width;
|
||||
return BadValue;
|
||||
}
|
||||
if (stuff->height < pScrPriv->minHeight ||
|
||||
pScrPriv->maxHeight < stuff->height)
|
||||
{
|
||||
client->errorValue = stuff->height;
|
||||
return BadValue;
|
||||
}
|
||||
for (i = 0; i < pScrPriv->numCrtcs; i++) {
|
||||
crtc = pScrPriv->crtcs[i];
|
||||
if (crtc->mode &&
|
||||
(crtc->x + crtc->mode->mode.width > stuff->width ||
|
||||
crtc->y + crtc->mode->mode.height > stuff->height))
|
||||
return BadMatch;
|
||||
}
|
||||
if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0)
|
||||
{
|
||||
client->errorValue = 0;
|
||||
return BadValue;
|
||||
}
|
||||
if (!RRScreenSizeSet (pScreen,
|
||||
stuff->width, stuff->height,
|
||||
stuff->widthInMillimeters,
|
||||
stuff->heightInMillimeters))
|
||||
{
|
||||
return BadMatch;
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRGetScreenResources (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetScreenResourcesReq);
|
||||
xRRGetScreenResourcesReply rep;
|
||||
WindowPtr pWin;
|
||||
ScreenPtr pScreen;
|
||||
rrScrPrivPtr pScrPriv;
|
||||
CARD8 *extra;
|
||||
unsigned long extraLen;
|
||||
int i;
|
||||
RRCrtc *crtcs;
|
||||
RROutput *outputs;
|
||||
xRRModeInfo *modeinfos;
|
||||
CARD8 *names;
|
||||
int n;
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
|
||||
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
|
||||
SecurityReadAccess);
|
||||
|
||||
if (!pWin)
|
||||
return BadWindow;
|
||||
|
||||
pScreen = pWin->drawable.pScreen;
|
||||
pScrPriv = rrGetScrPriv(pScreen);
|
||||
rep.pad = 0;
|
||||
|
||||
if (pScrPriv)
|
||||
RRGetInfo (pScreen);
|
||||
|
||||
if (!pScrPriv)
|
||||
{
|
||||
rep.type = X_Reply;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.length = 0;
|
||||
rep.timestamp = currentTime.milliseconds;
|
||||
rep.configTimestamp = currentTime.milliseconds;
|
||||
rep.nCrtcs = 0;
|
||||
rep.nOutputs = 0;
|
||||
rep.nModes = 0;
|
||||
rep.nbytesNames = 0;
|
||||
extra = NULL;
|
||||
extraLen = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
RRModePtr *modes;
|
||||
int num_modes;
|
||||
|
||||
modes = RRModesForScreen (pScreen, &num_modes);
|
||||
if (!modes)
|
||||
return BadAlloc;
|
||||
|
||||
rep.type = X_Reply;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.length = 0;
|
||||
rep.timestamp = pScrPriv->lastSetTime.milliseconds;
|
||||
rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
|
||||
rep.nCrtcs = pScrPriv->numCrtcs;
|
||||
rep.nOutputs = pScrPriv->numOutputs;
|
||||
rep.nModes = num_modes;
|
||||
rep.nbytesNames = 0;
|
||||
|
||||
for (i = 0; i < num_modes; i++)
|
||||
rep.nbytesNames += modes[i]->mode.nameLength;
|
||||
|
||||
rep.length = (pScrPriv->numCrtcs +
|
||||
pScrPriv->numOutputs +
|
||||
num_modes * (SIZEOF(xRRModeInfo) >> 2) +
|
||||
((rep.nbytesNames + 3) >> 2));
|
||||
|
||||
extraLen = rep.length << 2;
|
||||
if (extraLen)
|
||||
{
|
||||
extra = xalloc (extraLen);
|
||||
if (!extra)
|
||||
{
|
||||
xfree (modes);
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
else
|
||||
extra = NULL;
|
||||
|
||||
crtcs = (RRCrtc *) extra;
|
||||
outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs);
|
||||
modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs);
|
||||
names = (CARD8 *) (modeinfos + num_modes);
|
||||
|
||||
for (i = 0; i < pScrPriv->numCrtcs; i++)
|
||||
{
|
||||
crtcs[i] = pScrPriv->crtcs[i]->id;
|
||||
if (client->swapped)
|
||||
swapl (&crtcs[i], n);
|
||||
}
|
||||
|
||||
for (i = 0; i < pScrPriv->numOutputs; i++)
|
||||
{
|
||||
outputs[i] = pScrPriv->outputs[i]->id;
|
||||
if (client->swapped)
|
||||
swapl (&outputs[i], n);
|
||||
}
|
||||
|
||||
for (i = 0; i < num_modes; i++)
|
||||
{
|
||||
RRModePtr mode = modes[i];
|
||||
modeinfos[i] = mode->mode;
|
||||
if (client->swapped)
|
||||
{
|
||||
swapl (&modeinfos[i].id, n);
|
||||
swaps (&modeinfos[i].width, n);
|
||||
swaps (&modeinfos[i].height, n);
|
||||
swapl (&modeinfos[i].dotClock, n);
|
||||
swaps (&modeinfos[i].hSyncStart, n);
|
||||
swaps (&modeinfos[i].hSyncEnd, n);
|
||||
swaps (&modeinfos[i].hTotal, n);
|
||||
swaps (&modeinfos[i].hSkew, n);
|
||||
swaps (&modeinfos[i].vSyncStart, n);
|
||||
swaps (&modeinfos[i].vSyncEnd, n);
|
||||
swaps (&modeinfos[i].vTotal, n);
|
||||
swaps (&modeinfos[i].nameLength, n);
|
||||
swapl (&modeinfos[i].modeFlags, n);
|
||||
}
|
||||
memcpy (names, mode->name,
|
||||
mode->mode.nameLength);
|
||||
names += mode->mode.nameLength;
|
||||
}
|
||||
xfree (modes);
|
||||
assert (((((char *) names - (char *) extra) + 3) >> 2) == rep.length);
|
||||
}
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swapl(&rep.timestamp, n);
|
||||
swapl(&rep.configTimestamp, n);
|
||||
swaps(&rep.nCrtcs, n);
|
||||
swaps(&rep.nOutputs, n);
|
||||
swaps(&rep.nModes, n);
|
||||
swaps(&rep.nbytesNames, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xRRGetScreenResourcesReply), (char *)&rep);
|
||||
if (extraLen)
|
||||
{
|
||||
WriteToClient (client, extraLen, (char *) extra);
|
||||
xfree (extra);
|
||||
}
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
typedef struct _RR10Data {
|
||||
RRScreenSizePtr sizes;
|
||||
int nsize;
|
||||
int nrefresh;
|
||||
int size;
|
||||
CARD16 refresh;
|
||||
} RR10DataRec, *RR10DataPtr;
|
||||
|
||||
/*
|
||||
* Convert 1.2 monitor data into 1.0 screen data
|
||||
*/
|
||||
static RR10DataPtr
|
||||
RR10GetData (ScreenPtr pScreen, RROutputPtr output)
|
||||
{
|
||||
RR10DataPtr data;
|
||||
RRScreenSizePtr size;
|
||||
int nmode = output->numModes;
|
||||
int i, j, k;
|
||||
RRScreenRatePtr refresh;
|
||||
CARD16 vRefresh;
|
||||
RRModePtr mode;
|
||||
|
||||
/* Make sure there is plenty of space for any combination */
|
||||
data = malloc (sizeof (RR10DataRec) +
|
||||
sizeof (RRScreenSize) * nmode +
|
||||
sizeof (RRScreenRate) * nmode);
|
||||
if (!data)
|
||||
return NULL;
|
||||
size = (RRScreenSizePtr) (data + 1);
|
||||
refresh = (RRScreenRatePtr) (size + nmode);
|
||||
data->sizes = size;
|
||||
data->nsize = 0;
|
||||
data->nrefresh = 0;
|
||||
data->size = 0;
|
||||
data->refresh = 0;
|
||||
for (i = 0; i < output->numModes; i++)
|
||||
{
|
||||
mode = output->modes[i];
|
||||
for (j = 0; j < data->nsize; j++)
|
||||
if (mode->mode.width == size[j].width &&
|
||||
mode->mode.height == size[j].height)
|
||||
break;
|
||||
if (j == data->nsize)
|
||||
{
|
||||
size[j].id = j;
|
||||
size[j].width = mode->mode.width;
|
||||
size[j].height = mode->mode.height;
|
||||
if (output->mmWidth && output->mmHeight) {
|
||||
size[j].mmWidth = output->mmWidth;
|
||||
size[j].mmHeight = output->mmHeight;
|
||||
} else {
|
||||
size[j].mmWidth = pScreen->mmWidth;
|
||||
size[j].mmHeight = pScreen->mmHeight;
|
||||
}
|
||||
size[j].nRates = 0;
|
||||
size[j].pRates = &refresh[data->nrefresh];
|
||||
data->nsize++;
|
||||
}
|
||||
vRefresh = RRVerticalRefresh (&mode->mode);
|
||||
for (k = 0; k < size[j].nRates; k++)
|
||||
if (vRefresh == size[j].pRates[k].rate)
|
||||
break;
|
||||
if (k == size[j].nRates)
|
||||
{
|
||||
size[j].pRates[k].rate = vRefresh;
|
||||
size[j].pRates[k].mode = mode;
|
||||
size[j].nRates++;
|
||||
data->nrefresh++;
|
||||
}
|
||||
if (mode == output->crtc->mode)
|
||||
{
|
||||
data->size = j;
|
||||
data->refresh = vRefresh;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRGetScreenInfo (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetScreenInfoReq);
|
||||
xRRGetScreenInfoReply rep;
|
||||
WindowPtr pWin;
|
||||
int n;
|
||||
ScreenPtr pScreen;
|
||||
rrScrPrivPtr pScrPriv;
|
||||
CARD8 *extra;
|
||||
unsigned long extraLen;
|
||||
RROutputPtr output;
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
|
||||
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
|
||||
SecurityReadAccess);
|
||||
|
||||
if (!pWin)
|
||||
return BadWindow;
|
||||
|
||||
pScreen = pWin->drawable.pScreen;
|
||||
pScrPriv = rrGetScrPriv(pScreen);
|
||||
rep.pad = 0;
|
||||
|
||||
if (pScrPriv)
|
||||
RRGetInfo (pScreen);
|
||||
|
||||
output = RRFirstOutput (pScreen);
|
||||
|
||||
if (!pScrPriv || !output)
|
||||
{
|
||||
rep.type = X_Reply;
|
||||
rep.setOfRotations = RR_Rotate_0;;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.length = 0;
|
||||
rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
|
||||
rep.timestamp = currentTime.milliseconds;
|
||||
rep.configTimestamp = currentTime.milliseconds;
|
||||
rep.nSizes = 0;
|
||||
rep.sizeID = 0;
|
||||
rep.rotation = RR_Rotate_0;
|
||||
rep.rate = 0;
|
||||
rep.nrateEnts = 0;
|
||||
extra = 0;
|
||||
extraLen = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i, j;
|
||||
xScreenSizes *size;
|
||||
CARD16 *rates;
|
||||
CARD8 *data8;
|
||||
Bool has_rate = RRClientKnowsRates (client);
|
||||
RR10DataPtr pData;
|
||||
RRScreenSizePtr pSize;
|
||||
|
||||
pData = RR10GetData (pScreen, output);
|
||||
if (!pData)
|
||||
return BadAlloc;
|
||||
|
||||
rep.type = X_Reply;
|
||||
rep.setOfRotations = output->crtc->rotations;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.length = 0;
|
||||
rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
|
||||
rep.timestamp = pScrPriv->lastSetTime.milliseconds;
|
||||
rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
|
||||
rep.rotation = output->crtc->rotation;
|
||||
rep.nSizes = pData->nsize;
|
||||
rep.nrateEnts = pData->nrefresh + pData->nsize;
|
||||
rep.sizeID = pData->size;
|
||||
rep.rate = pData->refresh;
|
||||
|
||||
extraLen = (rep.nSizes * sizeof (xScreenSizes) +
|
||||
rep.nrateEnts * sizeof (CARD16));
|
||||
|
||||
if (extraLen)
|
||||
{
|
||||
extra = (CARD8 *) xalloc (extraLen);
|
||||
if (!extra)
|
||||
{
|
||||
xfree (pData);
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
else
|
||||
extra = NULL;
|
||||
|
||||
/*
|
||||
* First comes the size information
|
||||
*/
|
||||
size = (xScreenSizes *) extra;
|
||||
rates = (CARD16 *) (size + rep.nSizes);
|
||||
for (i = 0; i < pData->nsize; i++)
|
||||
{
|
||||
pSize = &pData->sizes[i];
|
||||
size->widthInPixels = pSize->width;
|
||||
size->heightInPixels = pSize->height;
|
||||
size->widthInMillimeters = pSize->mmWidth;
|
||||
size->heightInMillimeters = pSize->mmHeight;
|
||||
if (client->swapped)
|
||||
{
|
||||
swaps (&size->widthInPixels, n);
|
||||
swaps (&size->heightInPixels, n);
|
||||
swaps (&size->widthInMillimeters, n);
|
||||
swaps (&size->heightInMillimeters, n);
|
||||
}
|
||||
size++;
|
||||
if (has_rate)
|
||||
{
|
||||
*rates = pSize->nRates;
|
||||
if (client->swapped)
|
||||
{
|
||||
swaps (rates, n);
|
||||
}
|
||||
rates++;
|
||||
for (j = 0; j < pSize->nRates; j++)
|
||||
{
|
||||
*rates = pSize->pRates[j].rate;
|
||||
if (client->swapped)
|
||||
{
|
||||
swaps (rates, n);
|
||||
}
|
||||
rates++;
|
||||
}
|
||||
}
|
||||
}
|
||||
xfree (pData);
|
||||
|
||||
data8 = (CARD8 *) rates;
|
||||
|
||||
if (data8 - (CARD8 *) extra != extraLen)
|
||||
FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n",
|
||||
(unsigned long)(data8 - (CARD8 *) extra), extraLen);
|
||||
rep.length = (extraLen + 3) >> 2;
|
||||
}
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swapl(&rep.timestamp, n);
|
||||
swaps(&rep.rotation, n);
|
||||
swaps(&rep.nSizes, n);
|
||||
swaps(&rep.sizeID, n);
|
||||
swaps(&rep.rate, n);
|
||||
swaps(&rep.nrateEnts, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *)&rep);
|
||||
if (extraLen)
|
||||
{
|
||||
WriteToClient (client, extraLen, (char *) extra);
|
||||
xfree (extra);
|
||||
}
|
||||
return (client->noClientException);
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRSetScreenConfig (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRSetScreenConfigReq);
|
||||
xRRSetScreenConfigReply rep;
|
||||
DrawablePtr pDraw;
|
||||
int n;
|
||||
ScreenPtr pScreen;
|
||||
rrScrPrivPtr pScrPriv;
|
||||
TimeStamp configTime;
|
||||
TimeStamp time;
|
||||
int i;
|
||||
Rotation rotation;
|
||||
int rate;
|
||||
Bool has_rate;
|
||||
RROutputPtr output;
|
||||
RRModePtr mode;
|
||||
RR10DataPtr pData = NULL;
|
||||
RRScreenSizePtr pSize;
|
||||
|
||||
UpdateCurrentTime ();
|
||||
|
||||
if (RRClientKnowsRates (client))
|
||||
{
|
||||
REQUEST_SIZE_MATCH (xRRSetScreenConfigReq);
|
||||
has_rate = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq);
|
||||
has_rate = FALSE;
|
||||
}
|
||||
|
||||
SECURITY_VERIFY_DRAWABLE(pDraw, stuff->drawable, client,
|
||||
SecurityWriteAccess);
|
||||
|
||||
pScreen = pDraw->pScreen;
|
||||
|
||||
pScrPriv = rrGetScrPriv(pScreen);
|
||||
|
||||
time = ClientTimeToServerTime(stuff->timestamp);
|
||||
configTime = ClientTimeToServerTime(stuff->configTimestamp);
|
||||
|
||||
if (!pScrPriv)
|
||||
{
|
||||
time = currentTime;
|
||||
rep.status = RRSetConfigFailed;
|
||||
goto sendReply;
|
||||
}
|
||||
if (!RRGetInfo (pScreen))
|
||||
return BadAlloc;
|
||||
|
||||
output = RRFirstOutput (pScreen);
|
||||
if (!output)
|
||||
{
|
||||
time = currentTime;
|
||||
rep.status = RRSetConfigFailed;
|
||||
goto sendReply;
|
||||
}
|
||||
|
||||
/*
|
||||
* if the client's config timestamp is not the same as the last config
|
||||
* timestamp, then the config information isn't up-to-date and
|
||||
* can't even be validated
|
||||
*/
|
||||
if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0)
|
||||
{
|
||||
rep.status = RRSetConfigInvalidConfigTime;
|
||||
goto sendReply;
|
||||
}
|
||||
|
||||
pData = RR10GetData (pScreen, output);
|
||||
if (!pData)
|
||||
return BadAlloc;
|
||||
|
||||
if (stuff->sizeID >= pData->nsize)
|
||||
{
|
||||
/*
|
||||
* Invalid size ID
|
||||
*/
|
||||
client->errorValue = stuff->sizeID;
|
||||
xfree (pData);
|
||||
return BadValue;
|
||||
}
|
||||
pSize = &pData->sizes[stuff->sizeID];
|
||||
|
||||
/*
|
||||
* Validate requested rotation
|
||||
*/
|
||||
rotation = (Rotation) stuff->rotation;
|
||||
|
||||
/* test the rotation bits only! */
|
||||
switch (rotation & 0xf) {
|
||||
case RR_Rotate_0:
|
||||
case RR_Rotate_90:
|
||||
case RR_Rotate_180:
|
||||
case RR_Rotate_270:
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
* Invalid rotation
|
||||
*/
|
||||
client->errorValue = stuff->rotation;
|
||||
xfree (pData);
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
if ((~output->crtc->rotations) & rotation)
|
||||
{
|
||||
/*
|
||||
* requested rotation or reflection not supported by screen
|
||||
*/
|
||||
client->errorValue = stuff->rotation;
|
||||
xfree (pData);
|
||||
return BadMatch;
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate requested refresh
|
||||
*/
|
||||
if (has_rate)
|
||||
rate = (int) stuff->rate;
|
||||
else
|
||||
rate = 0;
|
||||
|
||||
if (rate)
|
||||
{
|
||||
for (i = 0; i < pSize->nRates; i++)
|
||||
{
|
||||
if (pSize->pRates[i].rate == rate)
|
||||
break;
|
||||
}
|
||||
if (i == pSize->nRates)
|
||||
{
|
||||
/*
|
||||
* Invalid rate
|
||||
*/
|
||||
client->errorValue = rate;
|
||||
xfree (pData);
|
||||
return BadValue;
|
||||
}
|
||||
mode = pSize->pRates[i].mode;
|
||||
}
|
||||
else
|
||||
mode = pSize->pRates[0].mode;
|
||||
|
||||
/*
|
||||
* Make sure the requested set-time is not older than
|
||||
* the last set-time
|
||||
*/
|
||||
if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0)
|
||||
{
|
||||
rep.status = RRSetConfigInvalidTime;
|
||||
goto sendReply;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the screen size is changing, adjust all of the other outputs
|
||||
* to fit the new size, mirroring as much as possible
|
||||
*/
|
||||
if (mode->mode.width != pScreen->width ||
|
||||
mode->mode.height != pScreen->height)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < pScrPriv->numCrtcs; c++)
|
||||
{
|
||||
rep.status = RRCrtcSet (pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0,
|
||||
0, NULL);
|
||||
if (rep.status != Success)
|
||||
goto sendReply;
|
||||
}
|
||||
if (!RRScreenSizeSet (pScreen, mode->mode.width, mode->mode.height,
|
||||
pScreen->mmWidth, pScreen->mmHeight))
|
||||
{
|
||||
rep.status = RRSetConfigFailed;
|
||||
goto sendReply;
|
||||
}
|
||||
}
|
||||
|
||||
rep.status = RRCrtcSet (output->crtc, mode, 0, 0, stuff->rotation,
|
||||
1, &output);
|
||||
|
||||
/*
|
||||
* XXX Configure other crtcs to mirror as much as possible
|
||||
*/
|
||||
|
||||
sendReply:
|
||||
|
||||
if (pData)
|
||||
xfree (pData);
|
||||
|
||||
rep.type = X_Reply;
|
||||
/* rep.status has already been filled in */
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
|
||||
rep.newTimestamp = pScrPriv->lastSetTime.milliseconds;
|
||||
rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds;
|
||||
rep.root = WindowTable[pDraw->pScreen->myNum]->drawable.id;
|
||||
|
||||
if (client->swapped)
|
||||
{
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swapl(&rep.newTimestamp, n);
|
||||
swapl(&rep.newConfigTimestamp, n);
|
||||
swapl(&rep.root, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep);
|
||||
|
||||
return (client->noClientException);
|
||||
}
|
||||
|
283
randr/rrsdispatch.c
Normal file
283
randr/rrsdispatch.c
Normal file
|
@ -0,0 +1,283 @@
|
|||
/*
|
||||
* Copyright © 2006 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "randrstr.h"
|
||||
|
||||
static int
|
||||
SProcRRQueryVersion (ClientPtr client)
|
||||
{
|
||||
register int n;
|
||||
REQUEST(xRRQueryVersionReq);
|
||||
|
||||
swaps(&stuff->length, n);
|
||||
swapl(&stuff->majorVersion, n);
|
||||
swapl(&stuff->minorVersion, n);
|
||||
return (*ProcRandrVector[stuff->randrReqType]) (client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRGetScreenInfo (ClientPtr client)
|
||||
{
|
||||
register int n;
|
||||
REQUEST(xRRGetScreenInfoReq);
|
||||
|
||||
swaps(&stuff->length, n);
|
||||
swapl(&stuff->window, n);
|
||||
return (*ProcRandrVector[stuff->randrReqType]) (client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRSetScreenConfig (ClientPtr client)
|
||||
{
|
||||
register int n;
|
||||
REQUEST(xRRSetScreenConfigReq);
|
||||
|
||||
if (RRClientKnowsRates (client))
|
||||
{
|
||||
REQUEST_SIZE_MATCH (xRRSetScreenConfigReq);
|
||||
swaps (&stuff->rate, n);
|
||||
}
|
||||
else
|
||||
{
|
||||
REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq);
|
||||
}
|
||||
|
||||
swaps(&stuff->length, n);
|
||||
swapl(&stuff->drawable, n);
|
||||
swapl(&stuff->timestamp, n);
|
||||
swaps(&stuff->sizeID, n);
|
||||
swaps(&stuff->rotation, n);
|
||||
return (*ProcRandrVector[stuff->randrReqType]) (client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRSelectInput (ClientPtr client)
|
||||
{
|
||||
register int n;
|
||||
REQUEST(xRRSelectInputReq);
|
||||
|
||||
swaps(&stuff->length, n);
|
||||
swapl(&stuff->window, n);
|
||||
swaps(&stuff->enable, n);
|
||||
return (*ProcRandrVector[stuff->randrReqType]) (client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRGetScreenSizeRange (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetScreenSizeRangeReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetScreenSizeRangeReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRSetScreenSize (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRSetScreenSizeReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRGetScreenResources (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetScreenResourcesReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRGetOutputInfo (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetOutputInfoReq);;
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetOutputInfoReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRListOutputProperties (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRListOutputPropertiesReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRChangeOutputProperty (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRChangeOutputPropertyReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRChangeOutputPropertyReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRDeleteOutputProperty (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRDeleteOutputPropertyReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRGetOutputProperty (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetOutputPropertyReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRCreateMode (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRCreateModeReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRCreateModeReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRDestroyMode (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRDestroyModeReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRDestroyModeReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRAddOutputMode (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRAddOutputModeReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRAddOutputModeReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRDeleteOutputMode (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRDeleteOutputModeReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRGetCrtcInfo (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetCrtcInfoReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRSetCrtcConfig (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRSetCrtcConfigReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRSetCrtcConfigReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRGetCrtcGammaSize (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetCrtcGammaSizeReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRGetCrtcGamma (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRGetCrtcGammaReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRSetCrtcGamma (ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRSetCrtcGammaReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xRRSetCrtcGammaReq);
|
||||
(void) stuff;
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {
|
||||
SProcRRQueryVersion, /* 0 */
|
||||
/* we skip 1 to make old clients fail pretty immediately */
|
||||
NULL, /* 1 SProcRandrOldGetScreenInfo */
|
||||
/* V1.0 apps share the same set screen config request id */
|
||||
SProcRRSetScreenConfig, /* 2 */
|
||||
NULL, /* 3 SProcRandrOldScreenChangeSelectInput */
|
||||
/* 3 used to be ScreenChangeSelectInput; deprecated */
|
||||
SProcRRSelectInput, /* 4 */
|
||||
SProcRRGetScreenInfo, /* 5 */
|
||||
/* V1.2 additions */
|
||||
SProcRRGetScreenSizeRange, /* 6 */
|
||||
SProcRRSetScreenSize, /* 7 */
|
||||
SProcRRGetScreenResources, /* 8 */
|
||||
SProcRRGetOutputInfo, /* 9 */
|
||||
SProcRRListOutputProperties,/* 10 */
|
||||
SProcRRChangeOutputProperty,/* 11 */
|
||||
SProcRRDeleteOutputProperty,/* 12 */
|
||||
SProcRRGetOutputProperty, /* 13 */
|
||||
SProcRRCreateMode, /* 14 */
|
||||
SProcRRDestroyMode, /* 15 */
|
||||
SProcRRAddOutputMode, /* 16 */
|
||||
SProcRRDeleteOutputMode, /* 17 */
|
||||
SProcRRGetCrtcInfo, /* 18 */
|
||||
SProcRRSetCrtcConfig, /* 19 */
|
||||
SProcRRGetCrtcGammaSize, /* 20 */
|
||||
SProcRRGetCrtcGamma, /* 21 */
|
||||
SProcRRSetCrtcGamma, /* 22 */
|
||||
};
|
||||
|
431
randr/rrxinerama.c
Normal file
431
randr/rrxinerama.c
Normal file
|
@ -0,0 +1,431 @@
|
|||
/*
|
||||
* Copyright © 2006 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
/*
|
||||
* This Xinerama implementation comes from the SiS driver which has
|
||||
* the following notice:
|
||||
*/
|
||||
/*
|
||||
* SiS driver main code
|
||||
*
|
||||
* Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1) Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2) Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3) The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Thomas Winischhofer <thomas@winischhofer.net>
|
||||
* - driver entirely rewritten since 2001, only basic structure taken from
|
||||
* old code (except sis_dri.c, sis_shadow.c, sis_accel.c and parts of
|
||||
* sis_dga.c; these were mostly taken over; sis_dri.c was changed for
|
||||
* new versions of the DRI layer)
|
||||
*
|
||||
* This notice covers the entire driver code unless indicated otherwise.
|
||||
*
|
||||
* Formerly based on code which was
|
||||
* Copyright (C) 1998, 1999 by Alan Hourihane, Wigan, England.
|
||||
* Written by:
|
||||
* Alan Hourihane <alanh@fairlite.demon.co.uk>,
|
||||
* Mike Chapman <mike@paranoia.com>,
|
||||
* Juanjo Santamarta <santamarta@ctv.es>,
|
||||
* Mitani Hiroshi <hmitani@drl.mei.co.jp>,
|
||||
* David Thomas <davtom@dream.org.uk>.
|
||||
*/
|
||||
|
||||
#include "randrstr.h"
|
||||
#include "swaprep.h"
|
||||
#include <X11/extensions/panoramiXproto.h>
|
||||
|
||||
#define RR_XINERAMA_MAJOR_VERSION 1
|
||||
#define RR_XINERAMA_MINOR_VERSION 1
|
||||
|
||||
/* Xinerama is not multi-screen capable; just report about screen 0 */
|
||||
#define RR_XINERAMA_SCREEN 0
|
||||
|
||||
static int ProcRRXineramaQueryVersion(ClientPtr client);
|
||||
static int ProcRRXineramaGetState(ClientPtr client);
|
||||
static int ProcRRXineramaGetScreenCount(ClientPtr client);
|
||||
static int ProcRRXineramaGetScreenSize(ClientPtr client);
|
||||
static int ProcRRXineramaIsActive(ClientPtr client);
|
||||
static int ProcRRXineramaQueryScreens(ClientPtr client);
|
||||
static int SProcRRXineramaDispatch(ClientPtr client);
|
||||
|
||||
/* Proc */
|
||||
|
||||
int
|
||||
ProcRRXineramaQueryVersion(ClientPtr client)
|
||||
{
|
||||
xPanoramiXQueryVersionReply rep;
|
||||
register int n;
|
||||
|
||||
REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq);
|
||||
rep.type = X_Reply;
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.majorVersion = RR_XINERAMA_MAJOR_VERSION;
|
||||
rep.minorVersion = RR_XINERAMA_MINOR_VERSION;
|
||||
if(client->swapped) {
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swaps(&rep.majorVersion, n);
|
||||
swaps(&rep.minorVersion, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), (char *)&rep);
|
||||
return (client->noClientException);
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRXineramaGetState(ClientPtr client)
|
||||
{
|
||||
REQUEST(xPanoramiXGetStateReq);
|
||||
WindowPtr pWin;
|
||||
xPanoramiXGetStateReply rep;
|
||||
register int n;
|
||||
ScreenPtr pScreen;
|
||||
rrScrPrivPtr pScrPriv;
|
||||
Bool active = FALSE;
|
||||
|
||||
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
|
||||
pWin = LookupWindow(stuff->window, client);
|
||||
if(!pWin) return BadWindow;
|
||||
|
||||
pScreen = pWin->drawable.pScreen;
|
||||
pScrPriv = rrGetScrPriv(pScreen);
|
||||
if (pScrPriv)
|
||||
{
|
||||
/* XXX do we need more than this? */
|
||||
active = TRUE;
|
||||
}
|
||||
|
||||
rep.type = X_Reply;
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.state = active;
|
||||
if(client->swapped) {
|
||||
swaps (&rep.sequenceNumber, n);
|
||||
swapl (&rep.length, n);
|
||||
swaps (&rep.state, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *)&rep);
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
static Bool
|
||||
RRXineramaScreenActive (ScreenPtr pScreen)
|
||||
{
|
||||
return rrGetScrPriv(pScreen) != NULL;
|
||||
}
|
||||
|
||||
static Bool
|
||||
RRXineramaCrtcActive (RRCrtcPtr crtc)
|
||||
{
|
||||
return crtc->mode != NULL && crtc->numOutputs > 0;
|
||||
}
|
||||
|
||||
static int
|
||||
RRXineramaScreenCount (ScreenPtr pScreen)
|
||||
{
|
||||
int i, n;
|
||||
|
||||
n = 0;
|
||||
if (RRXineramaScreenActive (pScreen))
|
||||
{
|
||||
rrScrPriv(pScreen);
|
||||
for (i = 0; i < pScrPriv->numCrtcs; i++)
|
||||
if (RRXineramaCrtcActive (pScrPriv->crtcs[i]))
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRXineramaGetScreenCount(ClientPtr client)
|
||||
{
|
||||
REQUEST(xPanoramiXGetScreenCountReq);
|
||||
WindowPtr pWin;
|
||||
xPanoramiXGetScreenCountReply rep;
|
||||
register int n;
|
||||
|
||||
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
|
||||
pWin = LookupWindow(stuff->window, client);
|
||||
if(!pWin) return BadWindow;
|
||||
|
||||
rep.type = X_Reply;
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.ScreenCount = RRXineramaScreenCount (pWin->drawable.pScreen);
|
||||
if(client->swapped) {
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swaps(&rep.ScreenCount, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep);
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRXineramaGetScreenSize(ClientPtr client)
|
||||
{
|
||||
REQUEST(xPanoramiXGetScreenSizeReq);
|
||||
WindowPtr pWin, pRoot;
|
||||
ScreenPtr pScreen;
|
||||
xPanoramiXGetScreenSizeReply rep;
|
||||
register int n;
|
||||
|
||||
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
|
||||
pWin = LookupWindow (stuff->window, client);
|
||||
if(!pWin) return BadWindow;
|
||||
|
||||
pScreen = pWin->drawable.pScreen;
|
||||
pRoot = WindowTable[pScreen->myNum];
|
||||
|
||||
rep.type = X_Reply;
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.width = pRoot->drawable.width;
|
||||
rep.height = pRoot->drawable.height;
|
||||
if(client->swapped) {
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swaps(&rep.width, n);
|
||||
swaps(&rep.height, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep);
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRXineramaIsActive(ClientPtr client)
|
||||
{
|
||||
xXineramaIsActiveReply rep;
|
||||
|
||||
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
|
||||
|
||||
rep.type = X_Reply;
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.state = RRXineramaScreenActive (screenInfo.screens[RR_XINERAMA_SCREEN]);
|
||||
if(client->swapped) {
|
||||
register int n;
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swapl(&rep.state, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xXineramaIsActiveReply), (char *) &rep);
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
int
|
||||
ProcRRXineramaQueryScreens(ClientPtr client)
|
||||
{
|
||||
xXineramaQueryScreensReply rep;
|
||||
ScreenPtr pScreen = screenInfo.screens[RR_XINERAMA_SCREEN];
|
||||
|
||||
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
|
||||
|
||||
if (RRXineramaScreenActive (pScreen))
|
||||
{
|
||||
rrScrPriv(pScreen);
|
||||
if (pScrPriv->numCrtcs == 0 || pScrPriv->numOutputs == 0)
|
||||
RRGetInfo (pScreen);
|
||||
}
|
||||
|
||||
rep.type = X_Reply;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.number = RRXineramaScreenCount (pScreen);
|
||||
rep.length = rep.number * sz_XineramaScreenInfo >> 2;
|
||||
if(client->swapped) {
|
||||
register int n;
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swapl(&rep.number, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xXineramaQueryScreensReply), (char *)&rep);
|
||||
|
||||
if(rep.number) {
|
||||
rrScrPriv(pScreen);
|
||||
xXineramaScreenInfo scratch;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < pScrPriv->numCrtcs; i++) {
|
||||
RRCrtcPtr crtc = pScrPriv->crtcs[i];
|
||||
if (RRXineramaCrtcActive (crtc))
|
||||
{
|
||||
scratch.x_org = crtc->x;
|
||||
scratch.y_org = crtc->y;
|
||||
scratch.width = crtc->mode->mode.width;
|
||||
scratch.height = crtc->mode->mode.height;
|
||||
if(client->swapped) {
|
||||
register int n;
|
||||
swaps(&scratch.x_org, n);
|
||||
swaps(&scratch.y_org, n);
|
||||
swaps(&scratch.width, n);
|
||||
swaps(&scratch.height, n);
|
||||
}
|
||||
WriteToClient(client, sz_XineramaScreenInfo, (char *)&scratch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return client->noClientException;
|
||||
}
|
||||
|
||||
static int
|
||||
ProcRRXineramaDispatch(ClientPtr client)
|
||||
{
|
||||
REQUEST(xReq);
|
||||
switch (stuff->data) {
|
||||
case X_PanoramiXQueryVersion:
|
||||
return ProcRRXineramaQueryVersion(client);
|
||||
case X_PanoramiXGetState:
|
||||
return ProcRRXineramaGetState(client);
|
||||
case X_PanoramiXGetScreenCount:
|
||||
return ProcRRXineramaGetScreenCount(client);
|
||||
case X_PanoramiXGetScreenSize:
|
||||
return ProcRRXineramaGetScreenSize(client);
|
||||
case X_XineramaIsActive:
|
||||
return ProcRRXineramaIsActive(client);
|
||||
case X_XineramaQueryScreens:
|
||||
return ProcRRXineramaQueryScreens(client);
|
||||
}
|
||||
return BadRequest;
|
||||
}
|
||||
|
||||
/* SProc */
|
||||
|
||||
static int
|
||||
SProcRRXineramaQueryVersion (ClientPtr client)
|
||||
{
|
||||
REQUEST(xPanoramiXQueryVersionReq);
|
||||
register int n;
|
||||
swaps(&stuff->length,n);
|
||||
REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
|
||||
return ProcRRXineramaQueryVersion(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRXineramaGetState(ClientPtr client)
|
||||
{
|
||||
REQUEST(xPanoramiXGetStateReq);
|
||||
register int n;
|
||||
swaps (&stuff->length, n);
|
||||
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
|
||||
return ProcRRXineramaGetState(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRXineramaGetScreenCount(ClientPtr client)
|
||||
{
|
||||
REQUEST(xPanoramiXGetScreenCountReq);
|
||||
register int n;
|
||||
swaps (&stuff->length, n);
|
||||
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
|
||||
return ProcRRXineramaGetScreenCount(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRXineramaGetScreenSize(ClientPtr client)
|
||||
{
|
||||
REQUEST(xPanoramiXGetScreenSizeReq);
|
||||
register int n;
|
||||
swaps (&stuff->length, n);
|
||||
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
|
||||
return ProcRRXineramaGetScreenSize(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRXineramaIsActive(ClientPtr client)
|
||||
{
|
||||
REQUEST(xXineramaIsActiveReq);
|
||||
register int n;
|
||||
swaps (&stuff->length, n);
|
||||
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
|
||||
return ProcRRXineramaIsActive(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcRRXineramaQueryScreens(ClientPtr client)
|
||||
{
|
||||
REQUEST(xXineramaQueryScreensReq);
|
||||
register int n;
|
||||
swaps (&stuff->length, n);
|
||||
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
|
||||
return ProcRRXineramaQueryScreens(client);
|
||||
}
|
||||
|
||||
int
|
||||
SProcRRXineramaDispatch(ClientPtr client)
|
||||
{
|
||||
REQUEST(xReq);
|
||||
switch (stuff->data) {
|
||||
case X_PanoramiXQueryVersion:
|
||||
return SProcRRXineramaQueryVersion(client);
|
||||
case X_PanoramiXGetState:
|
||||
return SProcRRXineramaGetState(client);
|
||||
case X_PanoramiXGetScreenCount:
|
||||
return SProcRRXineramaGetScreenCount(client);
|
||||
case X_PanoramiXGetScreenSize:
|
||||
return SProcRRXineramaGetScreenSize(client);
|
||||
case X_XineramaIsActive:
|
||||
return SProcRRXineramaIsActive(client);
|
||||
case X_XineramaQueryScreens:
|
||||
return SProcRRXineramaQueryScreens(client);
|
||||
}
|
||||
return BadRequest;
|
||||
}
|
||||
|
||||
static void
|
||||
RRXineramaResetProc(ExtensionEntry* extEntry)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
RRXineramaExtensionInit(void)
|
||||
{
|
||||
#ifdef PANORAMIX
|
||||
if(!noPanoramiXExtension)
|
||||
return;
|
||||
#endif
|
||||
|
||||
(void) AddExtension(PANORAMIX_PROTOCOL_NAME, 0,0,
|
||||
ProcRRXineramaDispatch,
|
||||
SProcRRXineramaDispatch,
|
||||
RRXineramaResetProc,
|
||||
StandardMinorOpcode);
|
||||
}
|
Loading…
Reference in New Issue
Block a user