42
OutputDevices::setGeometryOnDevice(unsigned int const nOutput,
44
const int width, const int height)
42
OutputDevices::setGeometryOnDevice (unsigned int const nOutput,
46
48
if (outputDevs.size() < nOutput + 1)
47
outputDevs.resize(nOutput + 1);
49
outputDevs.resize (nOutput + 1);
49
outputDevs[nOutput].setGeometry(x, y, width, height);
51
outputDevs[nOutput].setGeometry (x, y, width, height);
53
OutputDevices::adoptDevices(unsigned int nOutput, CompSize* screen)
55
OutputDevices::adoptDevices (unsigned int nOutput,
55
58
/* make sure we have at least one output */
58
setGeometryOnDevice(nOutput, 0, 0, screen->width(), screen->height());
61
setGeometryOnDevice (nOutput, 0, 0, screen->width (), screen->height ());
61
if (outputDevs.size() > nOutput)
62
outputDevs.resize(nOutput);
65
if (outputDevs.size () > nOutput)
66
outputDevs.resize (nOutput);
65
69
/* set name, width, height and update rect pointers in all regions */
66
for (unsigned int i = 0; i < nOutput; i++)
70
for (unsigned int i = 0; i < nOutput; ++i)
68
72
snprintf(str, 10, "Output %u", i);
69
outputDevs[i].setId(str, i);
73
outputDevs[i].setId (str, i);
71
76
overlappingOutputs = false;
72
77
setCurrentOutput (currentOutputDev);
73
for (unsigned int i = 0; i < nOutput - 1; i++)
74
for (unsigned int j = i + 1; j < nOutput; j++)
75
if (outputDevs[i].intersects(outputDevs[j]))
79
for (unsigned int i = 0; i < nOutput - 1; ++i)
80
for (unsigned int j = i + 1; j < nOutput; ++j)
81
if (outputDevs[i].intersects (outputDevs[j]))
76
82
overlappingOutputs = true;
89
OutputDevices::outputDeviceForGeometry (
90
const CompWindow::Geometry& gm,
92
CompSize* screen) const
95
OutputDevices::outputDeviceForGeometry (const CompWindow::Geometry &gm,
97
CompSize *screen) const
99
if (outputDevs.size () == 1)
94
102
int overlapAreas[outputDevs.size ()];
95
103
int highest, seen, highestScore;
100
if (outputDevs.size () == 1)
105
CompRect geomRect, overlap;
104
107
if (strategy == CoreOptions::OverlappingOutputsSmartMode)
114
117
/* for biggest/smallest modes, only use the window center to determine
115
118
the correct output device */
116
x = (gm.x () + (gm.width () / 2) + gm.border ()) % screen->width ();
119
int x = (gm.x () + (gm.width () / 2) + gm.border ()) % screen->width ();
118
122
x += screen->width ();
119
y = (gm.y () + (gm.height () / 2) + gm.border ()) % screen->height ();
124
int y = (gm.y () + (gm.height () / 2) + gm.border ()) % screen->height ();
121
127
y += screen->height ();
126
132
/* get amount of overlap on all output devices */
127
for (i = 0; i < outputDevs.size (); i++)
133
for (i = 0; i < outputDevs.size (); ++i)
129
CompRect overlap = outputDevs[i] & geomRect;
135
overlap = outputDevs[i] & geomRect;
130
136
overlapAreas[i] = overlap.area ();
133
139
/* find output with largest overlap */
134
for (i = 0, highest = 0, highestScore = 0;
135
i < outputDevs.size (); i++)
140
for (i = 0, highest = 0, highestScore = 0; i < outputDevs.size (); ++i)
137
142
if (overlapAreas[i] > highestScore)
140
145
highestScore = overlapAreas[i];
144
149
/* look if the highest score is unique */
145
for (i = 0, seen = 0; i < outputDevs.size (); i++)
150
for (i = 0, seen = 0; i < outputDevs.size (); ++i)
146
151
if (overlapAreas[i] == highestScore)
151
156
/* it's not unique, select one output of the matching ones and use the
152
157
user preferred strategy for that */
153
158
unsigned int currentSize, bestOutputSize;
157
162
(strategy != CoreOptions::OverlappingOutputsPreferSmallerOutput);
159
164
if (searchLargest)
162
167
bestOutputSize = UINT_MAX;
164
for (i = 0, highest = 0; i < outputDevs.size (); i++)
169
for (i = 0, highest = 0; i < outputDevs.size (); ++i)
165
171
if (overlapAreas[i] == highestScore)
169
173
currentSize = outputDevs[i].area ();
171
175
if (searchLargest)