]>
Commit | Line | Data |
---|---|---|
313ed234 SS |
1 | From 1766ae8a69daa06730e41d094fdddf53db3a1a9e Mon Sep 17 00:00:00 2001 |
2 | From: Adam Jackson <ajax@redhat.com> | |
3 | Date: Tue, 28 Jul 2009 11:07:13 -0400 | |
4 | Subject: [PATCH] RANDR: right-of placement by default | |
5 | ||
6 | [Enhanced to add a new prefer clone option for drivers. This | |
7 | allows for servers like RN50 where two heads are disjoint. - airlied] | |
8 | ||
9 | [Enhanced to ignore rightof on single crtc cards - airlied] | |
10 | --- | |
11 | hw/xfree86/common/xf86str.h | 9 ++++- | |
12 | hw/xfree86/modes/xf86Crtc.c | 77 +++++++++++++++++++++++++++++++++++++++---- | |
13 | 2 files changed, 77 insertions(+), 9 deletions(-) | |
14 | ||
15 | diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h | |
16 | index 5c3aa00..8224668 100644 | |
17 | --- a/hw/xfree86/common/xf86str.h | |
18 | +++ b/hw/xfree86/common/xf86str.h | |
19 | @@ -503,10 +503,13 @@ typedef struct _confdrirec { | |
20 | } confDRIRec, *confDRIPtr; | |
21 | ||
22 | /* These values should be adjusted when new fields are added to ScrnInfoRec */ | |
23 | -#define NUM_RESERVED_INTS 15 | |
24 | +#define NUM_RESERVED_INTS 14 | |
25 | #define NUM_RESERVED_POINTERS 14 | |
26 | #define NUM_RESERVED_FUNCS 11 | |
27 | ||
28 | +/* let clients know they can use this */ | |
29 | +#define XF86_SCRN_HAS_PREFER_CLONE 1 | |
30 | + | |
31 | typedef pointer (*funcPointer)(void); | |
32 | ||
33 | /* flags for depth 24 pixmap options */ | |
34 | @@ -672,7 +675,6 @@ typedef void xf86SetOverscanProc (ScrnInfoPtr, int); | |
35 | * are to be dependent on compile-time defines. | |
36 | */ | |
37 | ||
38 | - | |
39 | typedef struct _ScrnInfoRec { | |
40 | int driverVersion; | |
41 | char * driverName; /* canonical name used in */ | |
42 | @@ -778,6 +780,9 @@ typedef struct _ScrnInfoRec { | |
43 | /* -nr support */ | |
44 | int canDoBGNoneRoot; | |
45 | ||
46 | + /* initial rightof support disable */ | |
47 | + int preferClone; | |
48 | + | |
49 | /* | |
50 | * These can be used when the minor ABI version is incremented. | |
51 | * The NUM_* parameters must be reduced appropriately to keep the | |
52 | diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c | |
53 | index a66c979..4d14f57 100644 | |
54 | --- a/hw/xfree86/modes/xf86Crtc.c | |
55 | +++ b/hw/xfree86/modes/xf86Crtc.c | |
56 | @@ -1146,6 +1146,15 @@ xf86InitialOutputPositions (ScrnInfoPtr scrn, DisplayModePtr *modes) | |
57 | int o; | |
58 | int min_x, min_y; | |
59 | ||
60 | + /* check for initial right-of heuristic */ | |
61 | + for (o = 0; o < config->num_output; o++) | |
62 | + { | |
63 | + xf86OutputPtr output = config->output[o]; | |
64 | + | |
65 | + if (output->initial_x || output->initial_y) | |
66 | + return TRUE; | |
67 | + } | |
68 | + | |
69 | for (o = 0; o < config->num_output; o++) | |
70 | { | |
71 | xf86OutputPtr output = config->output[o]; | |
72 | @@ -2028,6 +2037,60 @@ bestModeForAspect(xf86CrtcConfigPtr config, Bool *enabled, float aspect) | |
73 | return match; | |
74 | } | |
75 | ||
76 | +static int | |
77 | +numEnabledOutputs(xf86CrtcConfigPtr config, Bool *enabled) | |
78 | +{ | |
79 | + int i = 0, p; | |
80 | + | |
81 | + for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++) ; | |
82 | + | |
83 | + return i; | |
84 | +} | |
85 | + | |
86 | +static Bool | |
87 | +xf86TargetRightOf(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, | |
88 | + DisplayModePtr *modes, Bool *enabled, | |
89 | + int width, int height) | |
90 | +{ | |
91 | + int o; | |
92 | + int w = 0; | |
93 | + | |
94 | + if (config->num_crtc == 1) | |
95 | + return FALSE; | |
96 | + | |
97 | + if (scrn->preferClone) | |
98 | + return FALSE; | |
99 | + | |
100 | + if (numEnabledOutputs(config, enabled) < 2) | |
101 | + return FALSE; | |
102 | + | |
103 | + for (o = -1; nextEnabledOutput(config, enabled, &o); ) { | |
104 | + DisplayModePtr mode = | |
105 | + xf86OutputHasPreferredMode(config->output[o], width, height); | |
106 | + | |
107 | + if (!mode) | |
108 | + return FALSE; | |
109 | + | |
110 | + w += mode->HDisplay; | |
111 | + } | |
112 | + | |
113 | + if (w > width) | |
114 | + return FALSE; | |
115 | + | |
116 | + w = 0; | |
117 | + for (o = -1; nextEnabledOutput(config, enabled, &o); ) { | |
118 | + DisplayModePtr mode = | |
119 | + xf86OutputHasPreferredMode(config->output[o], width, height); | |
120 | + | |
121 | + config->output[o]->initial_x = w; | |
122 | + w += mode->HDisplay; | |
123 | + | |
124 | + modes[o] = mode; | |
125 | + } | |
126 | + | |
127 | + return TRUE; | |
128 | +} | |
129 | + | |
130 | static Bool | |
131 | xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, | |
132 | DisplayModePtr *modes, Bool *enabled, | |
133 | @@ -2085,13 +2148,9 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, | |
134 | * biggest mode for its aspect ratio, assuming one exists. | |
135 | */ | |
136 | if (!ret) do { | |
137 | - int i = 0; | |
138 | float aspect = 0.0; | |
139 | ||
140 | - /* count the number of enabled outputs */ | |
141 | - for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++) ; | |
142 | - | |
143 | - if (i != 1) | |
144 | + if (numEnabledOutputs(config, enabled) != 1) | |
145 | break; | |
146 | ||
147 | p = -1; | |
148 | @@ -2378,6 +2437,8 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) | |
149 | ||
150 | if (xf86TargetUserpref(scrn, config, modes, enabled, width, height)) | |
151 | xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n"); | |
152 | + else if (xf86TargetRightOf(scrn, config, modes, enabled, width, height)) | |
153 | + xf86DrvMsg(i, X_INFO, "Using spanning desktop for initial modes\n"); | |
154 | else if (xf86TargetPreferred(scrn, config, modes, enabled, width, height)) | |
155 | xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n"); | |
156 | else if (xf86TargetAspect(scrn, config, modes, enabled, width, height)) | |
157 | @@ -2394,8 +2455,10 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) | |
158 | config->output[o]->name); | |
159 | else | |
160 | xf86DrvMsg (scrn->scrnIndex, X_INFO, | |
161 | - "Output %s using initial mode %s\n", | |
162 | - config->output[o]->name, modes[o]->name); | |
163 | + "Output %s using initial mode %s +%d+%d\n", | |
164 | + config->output[o]->name, modes[o]->name, | |
165 | + config->output[o]->initial_x, | |
166 | + config->output[o]->initial_y); | |
167 | } | |
168 | ||
169 | /* | |
170 | -- | |
171 | 1.7.0.1 | |
172 |