From 12e4577c020c6905d09459d833fd1c5313f1647b Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Fri, 3 Sep 2010 11:19:01 +0200 Subject: vmwlegacy: Always scale screen dimensions to the initial DPI on modeswitch. When we switch mode we usually alter the size in a constant DPI environment rather than keeping the size constant and alter the DPI. Signed-off-by: Thomas Hellstrom --- src/vmware.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/vmware.c b/src/vmware.c index 1327d35..599ac07 100644 --- a/src/vmware.c +++ b/src/vmware.c @@ -74,6 +74,8 @@ char rcsId_vmware[] = #error "PCI_VENDOR_VMWARE is wrong, update it from vm_device_version.h" #endif +#define VMWARE_INCHTOMM 25.4 + /* * This is the only way I know to turn a #define of an integer constant into * a constant string. @@ -1557,7 +1559,6 @@ vmwareIsRegionEqual(const RegionPtr reg1, return TRUE; } - #if VMWARE_DRIVER_FUNC static Bool VMWareDriverFunc(ScrnInfoPtr pScrn, @@ -1585,8 +1586,10 @@ VMWareDriverFunc(ScrnInfoPtr pScrn, * keep the DPI constant. */ if (modemm && modemm->mode) { - modemm->mmWidth *= modemm->mode->HDisplay / (double)(modemm->virtX); - modemm->mmHeight *= modemm->mode->VDisplay / (double)(modemm->virtY); + modemm->mmWidth *= (modemm->mode->HDisplay * VMWARE_INCHTOMM + + pScrn->xDpi / 2) / pScrn->xDpi; + modemm->mmHeight *= (modemm->mode->VDisplay * VMWARE_INCHTOMM + + pScrn->yDpi / 2) / pScrn->yDpi; } return TRUE; default: @@ -1863,8 +1866,17 @@ VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) static Bool VMWARESwitchMode(int scrnIndex, DisplayModePtr mode, int flags) + { - return VMWAREModeInit(xf86Screens[scrnIndex], mode, TRUE); + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ScreenPtr pScreen = pScrn->pScreen; + + pScreen->mmWidth = (pScreen->width * VMWARE_INCHTOMM + + pScrn->xDpi / 2) / pScrn->xDpi; + pScreen->mmHeight = (pScreen->height * VMWARE_INCHTOMM + + pScrn->yDpi / 2) / pScrn->yDpi; + + return VMWAREModeInit(pScrn, mode, TRUE); } static Bool -- cgit v1.2.3