[Spice-devel] [PATCH] randr: set physical screen size to keep a constant 96 dpi
Marc-André Lureau
marcandre.lureau at gmail.com
Fri Feb 21 07:17:06 PST 2014
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
relied 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 | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/vdagent-x11-randr.c b/src/vdagent-x11-randr.c
index 5223f88..9bde7b9 100644
--- a/src/vdagent-x11-randr.c
+++ b/src/vdagent-x11-randr.c
@@ -767,13 +767,16 @@ void vdagent_x11_set_monitor_config(struct vdagent_x11 *x11,
}
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 fb_width_mm = (25.4 * primary_w) / dpi;
+ int fb_height_mm = (25.4 * 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));
+ fb_width_mm, fb_height_mm);
if (vdagent_x11_restore_error_handler(x11)) {
syslog(LOG_ERR, "XRRSetScreenSize failed, not enough mem?");
if (!fallback && curr) {
--
1.8.5.3
More information about the Spice-devel
mailing list