xserver: Branch 'master' - 2 commits

Adam Jackson ajax at kemper.freedesktop.org
Wed Oct 7 07:41:07 PDT 2015


 hw/xwayland/xwayland-output.c |   54 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)

New commits:
commit 880d4e78b1823bcc0e66e68270af1a475f097bb5
Author: Jonas Ådahl <jadahl at gmail.com>
Date:   Wed Oct 7 12:02:39 2015 +0800

    xwayland: Set physical screen size to something
    
    When we have a single output, just set it to the physical size of that
    output. Otherwise try to approximate it calculating a mean m.m. per
    dot. Last fallback is to default to 96 DPI.
    
    Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
    Reviewed-by: Daniel Stone <daniels at collabora.com>

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index a8c2f2e..e4623d4 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -30,6 +30,8 @@
 #include "xwayland.h"
 #include <randrstr.h>
 
+#define DEFAULT_DPI 96
+
 static Rotation
 wl_transform_to_xrandr(enum wl_output_transform transform)
 {
@@ -129,12 +131,40 @@ output_get_new_size(struct xwl_output *xwl_output,
         *height = xwl_output->y + xwl_output->height;
 }
 
+/* Approximate some kind of mmpd (m.m. per dot) of the screen given the outputs
+ * associated with it.
+ *
+ * It will either calculate the mean mmpd of all the outputs, or default to
+ * 96 DPI if no reasonable value could be calculated.
+ */
+static double
+approximate_mmpd(struct xwl_screen *xwl_screen)
+{
+    struct xwl_output *it;
+    int total_width_mm = 0;
+    int total_width = 0;
+
+    xorg_list_for_each_entry(it, &xwl_screen->output_list, link) {
+        if (it->randr_output->mmWidth == 0)
+            continue;
+
+        total_width_mm += it->randr_output->mmWidth;
+        total_width += it->width;
+    }
+
+    if (total_width_mm != 0)
+        return (double)total_width_mm / total_width;
+    else
+        return 25.4 / DEFAULT_DPI;
+}
+
 static void
 output_handle_done(void *data, struct wl_output *wl_output)
 {
     struct xwl_output *it, *xwl_output = data;
     struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
     int width = 0, height = 0, has_this_output = 0;
+    double mmpd;
 
     xorg_list_for_each_entry(it, &xwl_screen->output_list, link) {
         /* output done event is sent even when some property
@@ -164,6 +194,15 @@ output_handle_done(void *data, struct wl_output *wl_output)
     xwl_screen->screen->width = width;
     xwl_screen->screen->height = height;
 
+    if (xwl_output->width == width && xwl_output->height == height) {
+        xwl_screen->screen->mmWidth = xwl_output->randr_output->mmWidth;
+        xwl_screen->screen->mmHeight = xwl_output->randr_output->mmHeight;
+    } else {
+        mmpd = approximate_mmpd(xwl_screen);
+        xwl_screen->screen->mmWidth = width * mmpd;
+        xwl_screen->screen->mmHeight = height * mmpd;
+    }
+
     if (xwl_screen->screen->root) {
         xwl_screen->screen->root->drawable.width = width;
         xwl_screen->screen->root->drawable.height = height;
commit 216bdbc7351e2078d94857a3323f6cd8f0d2f191
Author: Jonas Ådahl <jadahl at gmail.com>
Date:   Wed Oct 7 12:02:38 2015 +0800

    xwayland: Update actual screen and root window size on output hot plug
    
    When a new output is hot-plugged we need to not only update our internal
    screen dimensions, but also the dix screen dimensions, screenInfo
    dimensions and the root window dimensions.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=92273
    
    Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
    Reviewed-by: Daniel Stone <daniels at collabora.com>

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 923f368..a8c2f2e 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -156,9 +156,22 @@ output_handle_done(void *data, struct wl_output *wl_output)
 	--xwl_screen->expecting_event;
     }
 
+    if (xwl_screen->screen->root)
+        SetRootClip(xwl_screen->screen, FALSE);
+
     xwl_screen->width = width;
     xwl_screen->height = height;
-    RRScreenSizeNotify(xwl_screen->screen);
+    xwl_screen->screen->width = width;
+    xwl_screen->screen->height = height;
+
+    if (xwl_screen->screen->root) {
+        xwl_screen->screen->root->drawable.width = width;
+        xwl_screen->screen->root->drawable.height = height;
+        SetRootClip(xwl_screen->screen, TRUE);
+        RRScreenSizeNotify(xwl_screen->screen);
+    }
+
+    update_desktop_dimensions();
 }
 
 static void


More information about the xorg-commit mailing list