diff options
author | Simon Matter <simon.matter@invoca.ch> | 2017-10-09 11:36:23 +0200 |
---|---|---|
committer | Mihai Moldovan <ionic@ionic.de> | 2018-02-27 09:29:45 +0100 |
commit | 9dd2830e0c01e163a3ba92cb07476c02fd132b99 (patch) | |
tree | 665c9c4493fc678df5a51211c417a4c04d5f6bcb /nx-X11/programs/Xserver/hw/nxagent/Screen.c | |
parent | a88ca271751c1bcf90b352b8c5a79631263c56aa (diff) | |
download | nx-libs-9dd2830e0c01e163a3ba92cb07476c02fd132b99.tar.gz nx-libs-9dd2830e0c01e163a3ba92cb07476c02fd132b99.tar.bz2 nx-libs-9dd2830e0c01e163a3ba92cb07476c02fd132b99.zip |
nxagent: Auto-detect client-side DPI at session startup.
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Screen.c')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Screen.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 36da8b905..d4a083a1b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -210,6 +210,9 @@ void nxagentShadowAdaptDepth(unsigned int, unsigned int, unsigned int, char **); RegionRec nxagentShadowUpdateRegion; #define NXAGENT_DEFAULT_DPI 75 +#define NXAGENT_AUTO_DPI -1 + +extern Bool nxagentAutoDPI; /* * From randr/randr.c. This was originally static @@ -1327,10 +1330,14 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, rootDepth, (long unsigned int)defaultVisual); #endif - if (monitorResolution < 1) + if ((monitorResolution < 1) && (nxagentAutoDPI == False)) { monitorResolution = NXAGENT_DEFAULT_DPI; } + else if ((monitorResolution < 1) && (nxagentAutoDPI == True)) + { + monitorResolution = NXAGENT_AUTO_DPI; + } if (!fbScreenInit(pScreen, pFrameBufferBits, nxagentOption(RootWidth), nxagentOption(RootHeight), monitorResolution, monitorResolution, PixmapBytePad(nxagentOption(RootWidth), rootDepth), bitsPerPixel)) @@ -1474,6 +1481,17 @@ N/A * return FALSE; */ + if (monitorResolution < 0) + { + pScreen->mmWidth = nxagentOption(RootWidth) * DisplayWidthMM(nxagentDisplay, + DefaultScreen(nxagentDisplay)) / DisplayWidth(nxagentDisplay, + DefaultScreen(nxagentDisplay)); + + pScreen->mmHeight = nxagentOption(RootHeight) * DisplayHeightMM(nxagentDisplay, + DefaultScreen(nxagentDisplay)) / DisplayHeight(nxagentDisplay, + DefaultScreen(nxagentDisplay)); + } + pScreen->defColormap = (Colormap) FakeClientID(0); pScreen->minInstalledCmaps = MINCMAPS; pScreen->maxInstalledCmaps = MAXCMAPS; @@ -2294,22 +2312,40 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, if (mmWidth == 0) { - mmWidth = (width * 254 + monitorResolution * 5) / (monitorResolution * 10); + if (monitorResolution < 0) + { + mmWidth = width * DisplayWidthMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) / + DisplayWidth(nxagentDisplay, DefaultScreen(nxagentDisplay)); + } + else + { + mmWidth = (width * 254 + monitorResolution * 5) / (monitorResolution * 10); + } if (mmWidth < 1) { mmWidth = 1; } + } if (mmHeight == 0) { - mmHeight = (height * 254 + monitorResolution * 5) / (monitorResolution * 10); + if (monitorResolution < 0) + { + mmHeight = height * DisplayHeightMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) / + DisplayHeight(nxagentDisplay, DefaultScreen(nxagentDisplay)); + } + else + { + mmHeight = (height * 254 + monitorResolution * 5) / (monitorResolution * 10); + } if (mmHeight < 1) { mmHeight = 1; } + } pScreen -> mmWidth = mmWidth; |