Blame SOURCES/xserver-1.6.99-right-of.patch

70130e
From 291bc9f827188461ff9717efccec1e350db537e8 Mon Sep 17 00:00:00 2001
70130e
From: Adam Jackson <ajax@redhat.com>
70130e
Date: Tue, 28 Jul 2009 11:07:13 -0400
70130e
Subject: [PATCH 3/7] RANDR: right-of placement by default
70130e
70130e
[Enhanced to add a new prefer clone option for drivers. This
70130e
allows for servers like RN50 where two heads are disjoint. - airlied]
70130e
---
70130e
 hw/xfree86/common/xf86str.h |    8 ++++-
70130e
 hw/xfree86/modes/xf86Crtc.c |   76 ++++++++++++++++++++++++++++++++++++++-----
70130e
 2 files changed, 75 insertions(+), 9 deletions(-)
70130e
70130e
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
70130e
index 0590262..d246634 100644
70130e
--- a/hw/xfree86/common/xf86str.h
70130e
+++ b/hw/xfree86/common/xf86str.h
70130e
@@ -508,10 +508,13 @@ typedef struct _confdrirec {
70130e
 } confDRIRec, *confDRIPtr;
70130e
 
70130e
 /* These values should be adjusted when new fields are added to ScrnInfoRec */
70130e
-#define NUM_RESERVED_INTS		16
70130e
+#define NUM_RESERVED_INTS		15
70130e
 #define NUM_RESERVED_POINTERS		14
70130e
 #define NUM_RESERVED_FUNCS		10
70130e
 
70130e
+/* let clients know they can use this */
70130e
+#define XF86_SCRN_HAS_PREFER_CLONE 1
70130e
+
70130e
 typedef pointer (*funcPointer) (void);
70130e
 
70130e
 /* flags for depth 24 pixmap options */
70130e
@@ -769,6 +772,9 @@ typedef struct _ScrnInfoRec {
70130e
     ClockRangePtr clockRanges;
70130e
     int adjustFlags;
70130e
 
70130e
+    /* initial rightof support disable */
70130e
+    int                 preferClone;
70130e
+
70130e
     /*
70130e
      * These can be used when the minor ABI version is incremented.
70130e
      * The NUM_* parameters must be reduced appropriately to keep the
70130e
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
70130e
index 154f684..c58088d 100644
70130e
--- a/hw/xfree86/modes/xf86Crtc.c
70130e
+++ b/hw/xfree86/modes/xf86Crtc.c
70130e
@@ -1130,6 +1130,15 @@ xf86InitialOutputPositions(ScrnInfoPtr scrn, DisplayModePtr * modes)
70130e
     int o;
70130e
     int min_x, min_y;
70130e
 
70130e
+    /* check for initial right-of heuristic */
70130e
+    for (o = 0; o < config->num_output; o++)
70130e
+    {
70130e
+        xf86OutputPtr output = config->output[o];
70130e
+
70130e
+        if (output->initial_x || output->initial_y)
70130e
+            return TRUE;
70130e
+    }
70130e
+
70130e
     for (o = 0; o < config->num_output; o++) {
70130e
         xf86OutputPtr output = config->output[o];
70130e
 
70130e
@@ -1998,6 +2007,57 @@ bestModeForAspect(xf86CrtcConfigPtr config, Bool *enabled, float aspect)
70130e
     return match;
70130e
 }
70130e
 
70130e
+static int
70130e
+numEnabledOutputs(xf86CrtcConfigPtr config, Bool *enabled)
70130e
+{
70130e
+    int i = 0, p;
70130e
+
70130e
+    for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++) ;
70130e
+
70130e
+    return i;
70130e
+}
70130e
+
70130e
+static Bool
70130e
+xf86TargetRightOf(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
70130e
+                  DisplayModePtr *modes, Bool *enabled,
70130e
+                  int width, int height)
70130e
+{
70130e
+    int o;
70130e
+    int w = 0;
70130e
+
70130e
+    if (scrn->preferClone)
70130e
+        return FALSE;
70130e
+
70130e
+    if (numEnabledOutputs(config, enabled) < 2)
70130e
+        return FALSE;
70130e
+
70130e
+    for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
70130e
+        DisplayModePtr mode =
70130e
+            xf86OutputHasPreferredMode(config->output[o], width, height);
70130e
+
70130e
+        if (!mode)
70130e
+            return FALSE;
70130e
+
70130e
+        w += mode->HDisplay;
70130e
+    }
70130e
+
70130e
+    if (w > width)
70130e
+        return FALSE;
70130e
+
70130e
+    w = 0;
70130e
+    for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
70130e
+        DisplayModePtr mode =
70130e
+            xf86OutputHasPreferredMode(config->output[o], width, height);
70130e
+
70130e
+        config->output[o]->initial_x = w;
70130e
+        w += mode->HDisplay;
70130e
+
70130e
+        modes[o] = mode;
70130e
+    }
70130e
+
70130e
+    return TRUE;
70130e
+}
70130e
+
70130e
 static Bool
70130e
 xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
70130e
                     DisplayModePtr * modes, Bool *enabled,
70130e
@@ -2074,14 +2134,10 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
70130e
      */
70130e
     if (!ret)
70130e
         do {
70130e
-            int i = 0;
70130e
             float aspect = 0.0;
70130e
             DisplayModePtr a = NULL, b = NULL;
70130e
 
70130e
-            /* count the number of enabled outputs */
70130e
-            for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++);
70130e
-
70130e
-            if (i != 1)
70130e
+            if (numEnabledOutputs(config, enabled) != 1)
70130e
                 break;
70130e
 
70130e
             p = -1;
70130e
@@ -2385,6 +2441,8 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow)
70130e
     else {
70130e
         if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
70130e
             xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
70130e
+        else if (xf86TargetRightOf(scrn, config, modes, enabled, width, height))
70130e
+            xf86DrvMsg(i, X_INFO, "Using spanning desktop for initial modes\n");
70130e
         else if (xf86TargetPreferred
70130e
                  (scrn, config, modes, enabled, width, height))
70130e
             xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
70130e
@@ -2404,9 +2462,11 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow)
70130e
                        "Output %s enabled but has no modes\n",
70130e
                        config->output[o]->name);
70130e
         else
70130e
-            xf86DrvMsg(scrn->scrnIndex, X_INFO,
70130e
-                       "Output %s using initial mode %s\n",
70130e
-                       config->output[o]->name, modes[o]->name);
70130e
+            xf86DrvMsg (scrn->scrnIndex, X_INFO,
70130e
+                        "Output %s using initial mode %s +%d+%d\n",
70130e
+                        config->output[o]->name, modes[o]->name,
70130e
+                        config->output[o]->initial_x,
70130e
+                        config->output[o]->initial_y);
70130e
     }
70130e
 
70130e
     /*
70130e
-- 
70130e
1.7.10.4
70130e