Add conversion helpers between xinerama indices and output objects

Currently, we implicitly assume that enabled outputs are stored in the
xinerama order, but with ongoing refactorings, it's easy to break that
assumption. Also, we are not going to change the DRM backend so it
stores enabled outputs in the xinerama order.

This change adds xinerama index conversion helpers in order to reduce
the number of potential regressions with output refactorings.
This commit is contained in:
Vlad Zahorodnii 2022-07-13 19:41:25 +03:00
parent 4790916fb1
commit fc58fbaa71
4 changed files with 14 additions and 7 deletions

View file

@ -768,7 +768,7 @@ void X11Window::startupIdChanged()
workspace()->sendWindowToDesktop(this, desktop, true); workspace()->sendWindowToDesktop(this, desktop, true);
} }
if (asn_data.xinerama() != -1) { if (asn_data.xinerama() != -1) {
Output *output = kwinApp()->platform()->findOutput(asn_data.xinerama()); Output *output = workspace()->xineramaIndexToOutput(asn_data.xinerama());
if (output) { if (output) {
workspace()->sendWindowToOutput(this, output); workspace()->sendWindowToOutput(this, output);
} }

View file

@ -2248,7 +2248,7 @@ QRectF Workspace::clientArea(clientAreaOption opt, const Output *output, const V
const Output *effectiveOutput = output; const Output *effectiveOutput = output;
if (is_multihead) { if (is_multihead) {
effectiveOutput = kwinApp()->platform()->findOutput(screen_number); effectiveOutput = xineramaIndexToOutput(screen_number);
} }
if (auto desktopIt = m_screenAreas.constFind(desktop); desktopIt != m_screenAreas.constEnd()) { if (auto desktopIt = m_screenAreas.constFind(desktop); desktopIt != m_screenAreas.constEnd()) {
@ -2352,6 +2352,11 @@ int Workspace::oldDisplayHeight() const
return olddisplaysize.height(); return olddisplaysize.height();
} }
Output *Workspace::xineramaIndexToOutput(int index) const
{
return kwinApp()->platform()->enabledOutputs().value(index);
}
Output *Workspace::activeOutput() const Output *Workspace::activeOutput() const
{ {
if (options->activeMouseScreen()) { if (options->activeMouseScreen()) {

View file

@ -151,6 +151,8 @@ public:
bool initializing() const; bool initializing() const;
Output *xineramaIndexToOutput(int index) const;
Output *activeOutput() const; Output *activeOutput() const;
void setActiveOutput(Output *output); void setActiveOutput(Output *output);
void setActiveOutput(const QPointF &pos); void setActiveOutput(const QPointF &pos);

View file

@ -619,7 +619,7 @@ bool X11Window::manage(xcb_window_t w, bool isMapped)
} else { } else {
Output *output = nullptr; Output *output = nullptr;
if (asn_data.xinerama() != -1) { if (asn_data.xinerama() != -1) {
output = kwinApp()->platform()->findOutput(asn_data.xinerama()); output = workspace()->xineramaIndexToOutput(asn_data.xinerama());
} }
if (!output) { if (!output) {
output = workspace()->activeOutput(); output = workspace()->activeOutput();
@ -4649,16 +4649,16 @@ QRect X11Window::fullscreenMonitorsArea(NETFullscreenMonitors requestedTopology)
{ {
QRect total; QRect total;
if (auto output = kwinApp()->platform()->findOutput(requestedTopology.top)) { if (auto output = workspace()->xineramaIndexToOutput(requestedTopology.top)) {
total = total.united(output->geometry()); total = total.united(output->geometry());
} }
if (auto output = kwinApp()->platform()->findOutput(requestedTopology.bottom)) { if (auto output = workspace()->xineramaIndexToOutput(requestedTopology.bottom)) {
total = total.united(output->geometry()); total = total.united(output->geometry());
} }
if (auto output = kwinApp()->platform()->findOutput(requestedTopology.left)) { if (auto output = workspace()->xineramaIndexToOutput(requestedTopology.left)) {
total = total.united(output->geometry()); total = total.united(output->geometry());
} }
if (auto output = kwinApp()->platform()->findOutput(requestedTopology.right)) { if (auto output = workspace()->xineramaIndexToOutput(requestedTopology.right)) {
total = total.united(output->geometry()); total = total.united(output->geometry());
} }