diff --git a/src/dummy.h b/src/dummy.h
index c3fdd6e..7e7e0aa 100644
a
|
b
|
typedef struct dummyRec |
51 | 51 | /* options */ |
52 | 52 | OptionInfoPtr Options; |
53 | 53 | Bool swCursor; |
| 54 | Bool constantDPI; |
54 | 55 | /* proc pointer */ |
55 | 56 | CloseScreenProcPtr CloseScreen; |
56 | 57 | xf86CursorInfoPtr CursorInfo; |
diff --git a/src/dummy_driver.c b/src/dummy_driver.c
index 6062c39..c994d79 100644
a
|
b
|
|
17 | 17 | /* All drivers using the mi colormap manipulation need this */ |
18 | 18 | #include "micmap.h" |
19 | 19 | |
| 20 | #ifdef RANDR |
| 21 | #include "randrstr.h" |
| 22 | #endif |
| 23 | |
| 24 | #include "windowstr.h" |
| 25 | |
20 | 26 | /* identifying atom needed by magnifiers */ |
21 | 27 | #include <X11/Xatom.h> |
22 | 28 | #include "property.h" |
… |
… |
static SymTabRec DUMMYChipsets[] = { |
118 | 124 | }; |
119 | 125 | |
120 | 126 | typedef enum { |
121 | | OPTION_SW_CURSOR |
| 127 | OPTION_SW_CURSOR, |
| 128 | OPTION_CONSTANT_DPI |
122 | 129 | } DUMMYOpts; |
123 | 130 | |
124 | 131 | static const OptionInfoRec DUMMYOptions[] = { |
125 | 132 | { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, |
| 133 | #ifdef RANDR |
| 134 | { OPTION_CONSTANT_DPI, "ConstantDPI", OPTV_BOOLEAN, {0}, FALSE }, |
| 135 | #endif |
126 | 136 | { -1, NULL, OPTV_NONE, {0}, FALSE } |
127 | 137 | }; |
128 | 138 | |
… |
… |
DUMMYPreInit(ScrnInfoPtr pScrn, int flags) |
362 | 372 | xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, dPtr->Options); |
363 | 373 | |
364 | 374 | xf86GetOptValBool(dPtr->Options, OPTION_SW_CURSOR,&dPtr->swCursor); |
| 375 | xf86GetOptValBool(dPtr->Options, OPTION_CONSTANT_DPI, &dPtr->constantDPI); |
365 | 376 | |
366 | 377 | if (device->videoRam != 0) { |
367 | 378 | pScrn->videoRam = device->videoRam; |
… |
… |
DUMMYScreenInit(SCREEN_INIT_ARGS_DECL) |
661 | 672 | return TRUE; |
662 | 673 | } |
663 | 674 | |
| 675 | const char *XDPY_PROPERTY = "dummy-constant-xdpi"; |
| 676 | const char *YDPY_PROPERTY = "dummy-constant-ydpi"; |
| 677 | static int get_dpi_value(WindowPtr root, const char *property_name, int default_dpi) |
| 678 | { |
| 679 | PropertyPtr prop; |
| 680 | Atom type_atom = MakeAtom("CARDINAL", 8, TRUE); |
| 681 | Atom prop_atom = MakeAtom(property_name, strlen(property_name), FALSE); |
| 682 | |
| 683 | for (prop = wUserProps(root); prop; prop = prop->next) { |
| 684 | if (prop->propertyName == prop_atom && prop->type == type_atom && prop->data) { |
| 685 | int v = (int) (*((CARD32 *) prop->data)); |
| 686 | if ((v>0) && (v<4096)) { |
| 687 | xf86DrvMsg(0, X_INFO, "get_constant_dpi_value() found property \"%s\" with value=%i\n", property_name, (int) v); |
| 688 | return (int) v; |
| 689 | } |
| 690 | break; |
| 691 | } |
| 692 | } |
| 693 | return default_dpi; |
| 694 | } |
| 695 | |
664 | 696 | /* Mandatory */ |
665 | 697 | Bool |
666 | 698 | DUMMYSwitchMode(SWITCH_MODE_ARGS_DECL) |
667 | 699 | { |
668 | 700 | SCRN_INFO_PTR(arg); |
669 | | return dummyModeInit(pScrn, mode); |
| 701 | if (!dummyModeInit(pScrn, mode)) |
| 702 | return FALSE; |
| 703 | #ifdef RANDR |
| 704 | DUMMYPtr dPtr = DUMMYPTR(pScrn); |
| 705 | if (dPtr->constantDPI) { |
| 706 | int xDpi = get_dpi_value(pScrn->pScreen->root, XDPY_PROPERTY, pScrn->xDpi); |
| 707 | int yDpi = get_dpi_value(pScrn->pScreen->root, YDPY_PROPERTY, pScrn->yDpi); |
| 708 | //25.4 mm per inch: (254/10) |
| 709 | pScrn->pScreen->mmWidth = mode->HDisplay * 254 / xDpi / 10; |
| 710 | pScrn->pScreen->mmHeight = mode->VDisplay * 254 / yDpi / 10; |
| 711 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "mm(dpi %ix%i)=%ix%i\n", xDpi, yDpi, pScrn->pScreen->mmWidth, pScrn->pScreen->mmHeight); |
| 712 | RRScreenSizeNotify(pScrn->pScreen); |
| 713 | RRTellChanged(pScrn->pScreen); |
| 714 | } |
| 715 | #endif |
| 716 | return TRUE; |
670 | 717 | } |
671 | 718 | |
672 | 719 | /* Mandatory */ |