From fa42110482171f82153596cbee766e3d1b84c925 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Fri, 21 Feb 2014 16:13:09 +0100 Subject: randr: set physical screen size to keep a constant 96 dpi Some applications compute DPI based on physcial screen size. Currently, the width is reported to be 270mm, regardless of the resolution. This patch instead compute a physical screen size to have a constant DPI of 96. Of course, there are possible improvements to this approach (see fixme), however, since that code is no longer executed with DRM driver, I don't think we should invest more effort here (I guess DRM driver relies on xrandr / gnome-settings-daemon to do the right thing, so physical screen is updated) https://bugzilla.redhat.com/show_bug.cgi?id=1066094 --- src/vdagent-x11-randr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/vdagent-x11-randr.c b/src/vdagent-x11-randr.c index 0ed5246..46367bc 100644 --- a/src/vdagent-x11-randr.c +++ b/src/vdagent-x11-randr.c @@ -32,6 +32,8 @@ #include "vdagent-x11.h" #include "vdagent-x11-priv.h" +#define MM_PER_INCH (25.4) + static int error_handler(Display *display, XErrorEvent *error) { vdagent_x11_caught_error = 1; @@ -779,13 +781,16 @@ void vdagent_x11_set_monitor_config(struct vdagent_x11 *x11, /* Then we can resize the RandR screen. */ if (primary_w != x11->width[0] || primary_h != x11->height[0]) { + const int dpi = 96; /* FIXME: read settings from desktop or get from client dpi? */ + int width_mm = (MM_PER_INCH * primary_w) / dpi; + int height_mm = (MM_PER_INCH * primary_h) / dpi; + if (x11->debug) syslog(LOG_DEBUG, "Changing screen size to %dx%d", primary_w, primary_h); vdagent_x11_set_error_handler(x11, error_handler); XRRSetScreenSize(x11->display, x11->root_window[0], primary_w, primary_h, - DisplayWidthMM(x11->display, 0), - DisplayHeightMM(x11->display, 0)); + width_mm, height_mm); if (vdagent_x11_restore_error_handler(x11)) { syslog(LOG_ERR, "XRRSetScreenSize failed, not enough mem?"); if (!fallback && curr) { -- cgit v1.2.3