mirror of
https://github.com/X11Libre/xserver.git
synced 2026-11-23 06:43:07 +00:00
Add Support for DPI Auto-Detection
This PR re-adds support for DPI Auto-Detection which was available in X.Org till 21.1, but was removed. This reverts commit 35af1299 and allows to get Auto DPI Detection back only when specified by user as:
$ X -dpi auto
This commit is contained in:
parent
2c98c76fb7
commit
2b7cbdda1a
6 changed files with 22 additions and 3 deletions
|
|
@ -119,6 +119,7 @@ TimeStamp currentTime;
|
|||
|
||||
int defaultColorVisualClass = -1;
|
||||
int monitorResolution = 0;
|
||||
Bool autosetDPI = FALSE;
|
||||
|
||||
Bool explicit_display = FALSE;
|
||||
char *ConnectionInfo;
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@
|
|||
#include "xf86InPriv.h"
|
||||
#include "xf86Config.h"
|
||||
#include "xf86Module_priv.h"
|
||||
#include "xf86Crtc.h"
|
||||
|
||||
static int xf86ScrnInfoPrivateCount = 0;
|
||||
|
||||
|
|
@ -848,6 +849,7 @@ xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
|
|||
xf86MonPtr DDC = (xf86MonPtr) (pScrn->monitor->DDC);
|
||||
int ddcWidthmm, ddcHeightmm;
|
||||
int widthErr, heightErr;
|
||||
xf86OutputPtr compat = xf86CompatOutput(pScrn);
|
||||
|
||||
/* XXX Maybe there is no need for widthmm/heightmm in ScrnInfoRec */
|
||||
pScrn->widthmm = pScrn->monitor->widthmm;
|
||||
|
|
@ -860,6 +862,10 @@ xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
|
|||
ddcWidthmm = DDC->features.hsize * 10; /* 10mm in 1cm */
|
||||
ddcHeightmm = DDC->features.vsize * 10; /* 10mm in 1cm */
|
||||
}
|
||||
else if (autosetDPI && compat && compat->mm_width > 0 && compat->mm_height > 0) {
|
||||
ddcWidthmm = compat->mm_width;
|
||||
ddcHeightmm = compat->mm_height;
|
||||
}
|
||||
else {
|
||||
ddcWidthmm = ddcHeightmm = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3228,8 +3228,10 @@ xf86OutputSetEDID(xf86OutputPtr output, xf86MonPtr edid_mon)
|
|||
free(output->MonInfo);
|
||||
|
||||
output->MonInfo = edid_mon;
|
||||
output->mm_width = 0;
|
||||
output->mm_height = 0;
|
||||
if (!autosetDPI || edid_mon) {
|
||||
output->mm_width = 0;
|
||||
output->mm_height = 0;
|
||||
}
|
||||
|
||||
if (debug_modes) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_INFO, "EDID for output %s\n",
|
||||
|
|
|
|||
|
|
@ -806,6 +806,12 @@ xf86RandR12CreateScreenResources(ScreenPtr pScreen)
|
|||
mmWidth = output->conf_monitor->mon_width;
|
||||
mmHeight = output->conf_monitor->mon_height;
|
||||
}
|
||||
else if (autosetDPI && output &&
|
||||
(output->mm_width > 0 &&
|
||||
output->mm_height > 0)) {
|
||||
mmWidth = output->mm_width;
|
||||
mmHeight = output->mm_height;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Otherwise, just set the screen to DEFAULT_DPI
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
extern _X_EXPORT const char *defaultFontPath;
|
||||
extern _X_EXPORT int monitorResolution;
|
||||
extern _X_EXPORT Bool autosetDPI;
|
||||
extern _X_EXPORT int defaultColorVisualClass;
|
||||
|
||||
#endif /* !_XSERV_GLOBAL_H_ */
|
||||
|
|
|
|||
|
|
@ -502,7 +502,10 @@ ProcessCommandLine(int argc, char *argv[])
|
|||
}
|
||||
else if (strcmp(argv[i], "-dpi") == 0) {
|
||||
if (++i < argc)
|
||||
monitorResolution = atoi(argv[i]);
|
||||
if (strcmp(argv[i], "auto") == 0)
|
||||
autosetDPI = TRUE;
|
||||
else
|
||||
monitorResolution = atoi(argv[i]);
|
||||
else
|
||||
UseMsg();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue