xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #163: 0002-Constant-DPI.2.patch

File 0002-Constant-DPI.2.patch, 3.3 KB (added by Antoine Martin, 8 years ago)

updated version of the patch for use with rpm specfiles

  • src/dummy.h

    diff --git a/src/dummy.h b/src/dummy.h
    index c3fdd6e..7e7e0aa 100644
    a b typedef struct dummyRec 
    5151    /* options */
    5252    OptionInfoPtr Options;
    5353    Bool swCursor;
     54    Bool constantDPI;
    5455    /* proc pointer */
    5556    CloseScreenProcPtr CloseScreen;
    5657    xf86CursorInfoPtr CursorInfo;
  • src/dummy_driver.c

    diff --git a/src/dummy_driver.c b/src/dummy_driver.c
    index 6062c39..c994d79 100644
    a b  
    1717/* All drivers using the mi colormap manipulation need this */
    1818#include "micmap.h"
    1919
     20#ifdef RANDR
     21#include "randrstr.h"
     22#endif
     23
     24#include "windowstr.h"
     25
    2026/* identifying atom needed by magnifiers */
    2127#include <X11/Xatom.h>
    2228#include "property.h"
    static SymTabRec DUMMYChipsets[] = { 
    118124};
    119125
    120126typedef enum {
    121     OPTION_SW_CURSOR
     127    OPTION_SW_CURSOR,
     128    OPTION_CONSTANT_DPI
    122129} DUMMYOpts;
    123130
    124131static const OptionInfoRec DUMMYOptions[] = {
    125132    { OPTION_SW_CURSOR, "SWcursor",     OPTV_BOOLEAN,   {0}, FALSE },
     133#ifdef RANDR
     134    { OPTION_CONSTANT_DPI,      "ConstantDPI",  OPTV_BOOLEAN,   {0}, FALSE },
     135#endif
    126136    { -1,                  NULL,           OPTV_NONE,   {0}, FALSE }
    127137};
    128138
    DUMMYPreInit(ScrnInfoPtr pScrn, int flags) 
    362372    xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, dPtr->Options);
    363373
    364374    xf86GetOptValBool(dPtr->Options, OPTION_SW_CURSOR,&dPtr->swCursor);
     375    xf86GetOptValBool(dPtr->Options, OPTION_CONSTANT_DPI, &dPtr->constantDPI);
    365376
    366377    if (device->videoRam != 0) {
    367378        pScrn->videoRam = device->videoRam;
    DUMMYScreenInit(SCREEN_INIT_ARGS_DECL) 
    661672    return TRUE;
    662673}
    663674
     675const char *XDPY_PROPERTY = "dummy-constant-xdpi";
     676const char *YDPY_PROPERTY = "dummy-constant-ydpi";
     677static 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
    664696/* Mandatory */
    665697Bool
    666698DUMMYSwitchMode(SWITCH_MODE_ARGS_DECL)
    667699{
    668700    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;
    670717}
    671718
    672719/* Mandatory */