summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2014-02-21 16:13:09 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2014-02-24 22:02:04 +0100
commitfa42110482171f82153596cbee766e3d1b84c925 (patch)
treec420bcf0916834de9809eb404c248896e4c0bced
parent6e2e82e6fbb8927d5154f32c83e2b95c08fef18e (diff)
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
-rw-r--r--src/vdagent-x11-randr.c9
1 files 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) {