d1de19e212
Currently the Workspace processes output updates as they occur, e.g. when the drm backend scans connectors, the Workspace will handle hotplugged outputs one by one or if an output configuration changes the mode of several outputs, the workspace will process output layout updates one by one instead of handling it in one pass. The main reason for the current behavior is simplicity. However, that can create issues because it's possible that the output layout will be temporarily in degenerate state and features such as sticking windows to their outputs will be broken. In order to fix that, this change makes the Workspace process batched output updates. There are several challenges - disconnected outputs have to be alive when the outputsQueried signal is emitted, the workspace needs to determine what outputs have been added or removed on its own.
67 lines
1.3 KiB
C++
67 lines
1.3 KiB
C++
/*
|
|
KWin - the KDE window manager
|
|
This file is part of the KDE project.
|
|
|
|
SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
#include "screens.h"
|
|
|
|
#include <config-kwin.h>
|
|
|
|
#include "core/output.h"
|
|
#include "core/platform.h"
|
|
#include "cursor.h"
|
|
#include "settings.h"
|
|
#include "utils/common.h"
|
|
#include <window.h>
|
|
#include <workspace.h>
|
|
|
|
namespace KWin
|
|
{
|
|
|
|
Screens::Screens()
|
|
: m_maxScale(1.0)
|
|
{
|
|
connect(workspace(), &Workspace::outputsChanged, this, &Screens::changed);
|
|
}
|
|
|
|
void Screens::init()
|
|
{
|
|
connect(this, &Screens::changed, this, &Screens::updateSize);
|
|
|
|
Q_EMIT changed();
|
|
}
|
|
|
|
qreal Screens::scale(int screen) const
|
|
{
|
|
if (Output *output = findOutput(screen)) {
|
|
return output->scale();
|
|
}
|
|
return 1.0;
|
|
}
|
|
|
|
qreal Screens::maxScale() const
|
|
{
|
|
return m_maxScale;
|
|
}
|
|
|
|
void Screens::updateSize()
|
|
{
|
|
qreal maxScale = 1.0;
|
|
for (int i = 0; i < workspace()->outputs().count(); ++i) {
|
|
maxScale = qMax(maxScale, scale(i));
|
|
}
|
|
if (!qFuzzyCompare(m_maxScale, maxScale)) {
|
|
m_maxScale = maxScale;
|
|
Q_EMIT maxScaleChanged();
|
|
}
|
|
}
|
|
|
|
Output *Screens::findOutput(int screen) const
|
|
{
|
|
return workspace()->outputs().value(screen);
|
|
}
|
|
|
|
} // namespace
|