[Xorg] RandR physical screen size question
Aaron Plattner
aplattner at nvidia.com
Mon Aug 9 12:43:07 PDT 2004
Does anyone have any objections to the attached patch? It stores the screen's
mmWidth and mmHeight in the private struct along with virtualX and virtualY, and
uses that to construct the sizes. Then, on RRSetConfig the screen's physical
size is changed. This lets me do this:
bash-2.05b$ xdpyinfo | grep -B1 dots
dimensions: 1600x1200 pixels (402x302 millimeters)
resolution: 101x101 dots per inch
bash-2.05b$ xrandr -o left
bash-2.05b$ xdpyinfo | grep -B1 dots
dimensions: 1200x1600 pixels (302x402 millimeters)
resolution: 101x101 dots per inch <----- yay!
The decision on whether or not to use randrp->virtual[XY] in xf86RandRGetInfo
still seems a little questionable, but it seems to work okay.
-- Aaron
On Fri, Aug 06, 2004 at 08:42:22PM -0700, Keith Packard wrote:
>
> Around 20 o'clock on Aug 6, Aaron Plattner wrote:
>
> > My question is, is this intentional, or a bug? Why isn't the physical
> > size simply set to pScreen->mmWidth x pScreen->mmHeight?
>
> That's a good question; I do what you suggest in the kdrive servers which
> have supported rotation for "a while" now.
>
> Could it have something to do with the virtual desktop mode?
>
> -keith
-------------- next part --------------
Index: hw/xfree86/common/xf86RandR.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v
retrieving revision 1.4
diff -u -r1.4 xf86RandR.c
--- hw/xfree86/common/xf86RandR.c 2 Aug 2004 19:35:07 -0000 1.4
+++ hw/xfree86/common/xf86RandR.c 9 Aug 2004 19:17:36 -0000
@@ -38,6 +38,8 @@
CloseScreenProcPtr CloseScreen;
int virtualX;
int virtualY;
+ int mmWidth;
+ int mmHeight;
Rotation rotation;
} XF86RandRInfoRec, *XF86RandRInfoPtr;
@@ -73,7 +75,7 @@
refresh0 = refresh;
pSize = RRRegisterSize (pScreen,
mode->HDisplay, mode->VDisplay,
- pScreen->mmWidth, pScreen->mmHeight);
+ randrp->mmWidth, randrp->mmHeight);
if (!pSize)
return FALSE;
RRRegisterRate (pScreen, pSize, refresh);
@@ -89,8 +91,8 @@
mode = scrp->modes;
pSize = RRRegisterSize (pScreen,
randrp->virtualX, randrp->virtualY,
- pScreen->mmWidth * randrp->virtualX / scrp->currentMode->HDisplay,
- pScreen->mmHeight * randrp->virtualY / scrp->currentMode->VDisplay);
+ randrp->mmWidth,
+ randrp->mmHeight);
if (!pSize)
return FALSE;
RRRegisterRate (pScreen, pSize, refresh0);
@@ -117,12 +119,16 @@
static Bool
xf86RandRSetMode (ScreenPtr pScreen,
DisplayModePtr mode,
- Bool useVirtual)
+ Bool useVirtual,
+ int mmWidth,
+ int mmHeight)
{
ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
int oldWidth = pScreen->width;
int oldHeight = pScreen->height;
+ int oldmmWidth = pScreen->mmWidth;
+ int oldmmHeight = pScreen->mmHeight;
WindowPtr pRoot = WindowTable[pScreen->myNum];
if (pRoot)
@@ -142,16 +148,22 @@
/* If the screen is rotated 90 or 270 degrees, swap the sizes. */
pScreen->width = scrp->virtualY;
pScreen->height = scrp->virtualX;
+ pScreen->mmWidth = mmHeight;
+ pScreen->mmHeight = mmWidth;
}
else
{
pScreen->width = scrp->virtualX;
pScreen->height = scrp->virtualY;
+ pScreen->mmWidth = mmWidth;
+ pScreen->mmHeight = mmHeight;
}
if (!xf86SwitchMode (pScreen, mode))
{
scrp->virtualX = pScreen->width = oldWidth;
scrp->virtualY = pScreen->height = oldHeight;
+ pScreen->mmWidth = oldmmWidth;
+ pScreen->mmHeight = oldmmHeight;
return FALSE;
}
/*
@@ -215,7 +227,7 @@
return FALSE;
}
- if (!xf86RandRSetMode (pScreen, mode, useVirtual))
+ if (!xf86RandRSetMode (pScreen, mode, useVirtual, pSize->mmWidth, pSize->mmHeight))
return FALSE;
/*
* Move the cursor back where it belongs; SwitchMode repositions it
@@ -307,6 +319,8 @@
randrp->virtualX = scrp->virtualX;
randrp->virtualY = scrp->virtualY;
+ randrp->mmWidth = pScreen->mmWidth;
+ randrp->mmHeight = pScreen->mmHeight;
randrp->CreateScreenResources = pScreen->CreateScreenResources;
pScreen->CreateScreenResources = xf86RandRCreateScreenResources;
More information about the xorg
mailing list