Move physical size from mode to output.

Modes can be shared across different sized monitors this way.

Also caught some missing byteswapping and an incorrect return type.
This commit is contained in:
Keith Packard 2006-11-01 00:29:46 -08:00
parent e21604914d
commit 4056e6e79a
8 changed files with 50 additions and 15 deletions

View File

@ -111,8 +111,6 @@ miRandRInit (ScreenPtr pScreen)
memset (&modeInfo, '\0', sizeof (modeInfo)); memset (&modeInfo, '\0', sizeof (modeInfo));
modeInfo.width = pScreen->width; modeInfo.width = pScreen->width;
modeInfo.height = pScreen->height; modeInfo.height = pScreen->height;
modeInfo.mmWidth = pScreen->mmWidth;
modeInfo.mmHeight = pScreen->mmHeight;
modeInfo.nameLength = strlen (name); modeInfo.nameLength = strlen (name);
mode = RRModeGet (pScreen, &modeInfo, name); mode = RRModeGet (pScreen, &modeInfo, name);

View File

@ -107,6 +107,8 @@ struct _rrOutput {
int nameLength; int nameLength;
CARD8 connection; CARD8 connection;
CARD8 subpixelOrder; CARD8 subpixelOrder;
int mmWidth;
int mmHeight;
RRCrtcPtr crtc; RRCrtcPtr crtc;
CARD32 currentOptions; CARD32 currentOptions;
CARD32 possibleOptions; CARD32 possibleOptions;
@ -642,6 +644,11 @@ Bool
RROutputSetCurrentOptions (RROutputPtr output, RROutputSetCurrentOptions (RROutputPtr output,
CARD32 currentOptions); CARD32 currentOptions);
Bool
RROutputSetPhysicalSize (RROutputPtr output,
int mmWidth,
int mmHeight);
void void
RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output); RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output);

View File

@ -270,8 +270,16 @@ RRCrtcSet (RRCrtcPtr crtc,
size.width = mode->mode.width; size.width = mode->mode.width;
size.height = mode->mode.height; size.height = mode->mode.height;
size.mmWidth = mode->mode.mmWidth; if (outputs[0].output->mmWidth && outputs[0].output->mmHeight)
size.mmHeight = mode->mode.mmHeight; {
size.mmWidth = outputs[0].output->mmWidth;
size.mmHeight = outputs[0].output->mmHeight;
}
else
{
size.mmWidth = pScreen->mmWidth;
size.mmHeight = pScreen->mmHeight;
}
size.nRates = 1; size.nRates = 1;
rate.rate = RRVerticalRefresh (&mode->mode); rate.rate = RRVerticalRefresh (&mode->mode);
size.pRates = &rate; size.pRates = &rate;

View File

@ -39,8 +39,6 @@ RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh)
modeInfo.width = size->width; modeInfo.width = size->width;
modeInfo.height = size->height; modeInfo.height = size->height;
modeInfo.mmWidth = size->mmWidth;
modeInfo.mmHeight = size->mmHeight;
modeInfo.hTotal = size->width; modeInfo.hTotal = size->width;
modeInfo.vTotal = size->height; modeInfo.vTotal = size->height;
modeInfo.dotClock = ((CARD32) size->width * (CARD32) size->height * modeInfo.dotClock = ((CARD32) size->width * (CARD32) size->height *

View File

@ -29,8 +29,6 @@ RRModeEqual (xRRModeInfo *a, xRRModeInfo *b)
{ {
if (a->width != b->width) return FALSE; if (a->width != b->width) return FALSE;
if (a->height != b->height) return FALSE; if (a->height != b->height) return FALSE;
if (a->mmWidth != b->mmWidth) return FALSE;
if (a->mmHeight != b->mmHeight) return FALSE;
if (a->dotClock != b->dotClock) return FALSE; if (a->dotClock != b->dotClock) return FALSE;
if (a->hSyncStart != b->hSyncStart) return FALSE; if (a->hSyncStart != b->hSyncStart) return FALSE;
if (a->hSyncEnd != b->hSyncEnd) return FALSE; if (a->hSyncEnd != b->hSyncEnd) return FALSE;

View File

@ -72,6 +72,8 @@ RROutputCreate (ScreenPtr pScreen,
output->name[nameLength] = '\0'; output->name[nameLength] = '\0';
output->connection = RR_UnknownConnection; output->connection = RR_UnknownConnection;
output->subpixelOrder = SubPixelUnknown; output->subpixelOrder = SubPixelUnknown;
output->mmWidth = 0;
output->mmHeight = 0;
output->crtc = NULL; output->crtc = NULL;
output->currentOptions = 0; output->currentOptions = 0;
output->possibleOptions = 0; output->possibleOptions = 0;
@ -262,6 +264,20 @@ RROutputSetCurrentOptions (RROutputPtr output,
return TRUE; 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 void
RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output) RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output)
{ {
@ -381,6 +397,8 @@ ProcRRGetOutputInfo (ClientPtr client)
rep.timestamp = pScrPriv->lastSetTime.milliseconds; rep.timestamp = pScrPriv->lastSetTime.milliseconds;
rep.crtc = output->crtc ? output->crtc->id : None; rep.crtc = output->crtc ? output->crtc->id : None;
rep.currentOptions = output->currentOptions; rep.currentOptions = output->currentOptions;
rep.mmWidth = output->mmWidth;
rep.mmHeight = output->mmHeight;
rep.connection = output->connection; rep.connection = output->connection;
rep.subpixelOrder = output->subpixelOrder; rep.subpixelOrder = output->subpixelOrder;
rep.nCrtcs = output->numCrtcs; rep.nCrtcs = output->numCrtcs;
@ -434,10 +452,15 @@ ProcRRGetOutputInfo (ClientPtr client)
swapl(&rep.length, n); swapl(&rep.length, n);
swapl(&rep.timestamp, n); swapl(&rep.timestamp, n);
swapl(&rep.crtc, n); swapl(&rep.crtc, n);
swapl(&rep.currentOptions, n);
swapl(&rep.mmWidth, n);
swapl(&rep.mmHeight, n);
swaps(&rep.nCrtcs, n); swaps(&rep.nCrtcs, n);
swaps(&rep.nModes, n); swaps(&rep.nModes, n);
swaps(&rep.nClones, n); swaps(&rep.nClones, n);
swapl(&rep.possibleOptions, n);
swaps(&rep.nameLength, n); swaps(&rep.nameLength, n);
swapl(&rep.possibleOptions, n);
} }
WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *)&rep); WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *)&rep);
if (extraLen) if (extraLen)

View File

@ -131,7 +131,7 @@ RRPointerScreenConfigured (ScreenPtr pScreen)
int x, y; int x, y;
if (pScreen != pCurrentScreen) if (pScreen != pCurrentScreen)
return FALSE; return;
GetSpritePosition (&x, &y); GetSpritePosition (&x, &y);
RRPointerToNearestCrtc (pScreen, x, y, NULL); RRPointerToNearestCrtc (pScreen, x, y, NULL);
} }

View File

@ -126,8 +126,8 @@ RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
} }
se.widthInPixels = mode->mode.width; se.widthInPixels = mode->mode.width;
se.heightInPixels = mode->mode.height; se.heightInPixels = mode->mode.height;
se.widthInMillimeters = mode->mode.mmWidth; se.widthInMillimeters = pScreen->mmWidth;
se.heightInMillimeters = mode->mode.mmHeight; se.heightInMillimeters = pScreen->mmHeight;
} }
else else
{ {
@ -415,8 +415,6 @@ ProcRRGetScreenResources (ClientPtr client)
swapl (&modeinfos[i].id, n); swapl (&modeinfos[i].id, n);
swaps (&modeinfos[i].width, n); swaps (&modeinfos[i].width, n);
swaps (&modeinfos[i].height, n); swaps (&modeinfos[i].height, n);
swapl (&modeinfos[i].mmWidth, n);
swapl (&modeinfos[i].mmHeight, n);
swapl (&modeinfos[i].dotClock, n); swapl (&modeinfos[i].dotClock, n);
swaps (&modeinfos[i].hSyncStart, n); swaps (&modeinfos[i].hSyncStart, n);
swaps (&modeinfos[i].hSyncEnd, n); swaps (&modeinfos[i].hSyncEnd, n);
@ -501,8 +499,13 @@ RR10GetData (ScreenPtr pScreen, RROutputPtr output)
size[j].id = j; size[j].id = j;
size[j].width = mode->mode.width; size[j].width = mode->mode.width;
size[j].height = mode->mode.height; size[j].height = mode->mode.height;
size[j].mmWidth = mode->mode.mmWidth; if (output->mmWidth && output->mmHeight) {
size[j].mmHeight = mode->mode.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].nRates = 0;
size[j].pRates = &refresh[data->nrefresh]; size[j].pRates = &refresh[data->nrefresh];
data->nsize++; data->nsize++;