Commit 1136386d authored by Roman Gilg's avatar Roman Gilg
Browse files

[platforms/virtual] Store virtual outputs per reference

Summary:
Since VirtualOutput is a QObject, store it per reference and not per value.

Also fix some compilation warnings.

Test Plan: Before and after 92% tests passed.

Reviewers: #kwin, davidedmundson

Reviewed By: davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D11581
parent 4dd5bfab
......@@ -56,7 +56,7 @@ QRect VirtualScreens::geometry(int screen) const
if (screen >= outputs.size()) {
return QRect();
}
return outputs.at(screen).geometry();
return outputs.at(screen)->geometry();
}
QSize VirtualScreens::size(int screen) const
......@@ -75,7 +75,7 @@ int VirtualScreens::number(const QPoint &pos) const
int minDistance = INT_MAX;
const auto outputs = m_backend->outputs();
for (int i = 0; i < outputs.size(); ++i) {
const QRect &geo = outputs.at(i).geometry();
const QRect &geo = outputs.at(i)->geometry();
if (geo.contains(pos)) {
return i;
}
......
......@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "virtual_backend.h"
#include "virtual_output.h"
#include "scene_qpainter_virtual_backend.h"
#include "screens_virtual.h"
#include "wayland_server.h"
......@@ -33,7 +34,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#if HAVE_GBM
#include <gbm.h>
#endif
#include <colorcorrection/manager.h>
namespace KWin
{
......@@ -75,8 +75,8 @@ void VirtualBackend::init()
* TODO: rewrite all tests to explicitly set the outputs.
*/
if (!m_outputs.size()) {
auto dummyOutput = VirtualOutput(this);
dummyOutput.m_geo = QRect(QPoint(0, 0), initialWindowSize());
VirtualOutput *dummyOutput = new VirtualOutput(this);
dummyOutput->m_geo = QRect(QPoint(0, 0), initialWindowSize());
m_outputs = { dummyOutput };
}
......@@ -118,29 +118,31 @@ void VirtualBackend::setVirtualOutputs(int count, QVector<QRect> geometries)
Q_ASSERT(geometries.size() == 0 || geometries.size() == count);
bool countChanged = m_outputs.size() != count;
qDeleteAll(m_outputs.begin(), m_outputs.end());
m_outputs.resize(count);
int sumWidth = 0;
for (int i = 0; i < count; i++) {
VirtualOutput& o = m_outputs[i];
VirtualOutput *vo = new VirtualOutput(this);
if (geometries.size()) {
o.m_geo = geometries.at(i);
} else if (!o.m_geo.isValid()) {
o.m_geo = QRect(QPoint(sumWidth, 0), initialWindowSize());
sumWidth += o.m_geo.width();
vo->m_geo = geometries.at(i);
} else if (!vo->m_geo.isValid()) {
vo->m_geo = QRect(QPoint(sumWidth, 0), initialWindowSize());
sumWidth += vo->m_geo.width();
}
m_outputs[i] = vo;
}
emit virtualOutputsSet(countChanged);
}
int VirtualBackend::gammaRampSize(int screen) const {
return m_outputs[screen].m_gammaSize;
return m_outputs[screen]->m_gammaSize;
}
bool VirtualBackend::setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma) {
Q_UNUSED(gamma);
return m_outputs[screen].m_gammaResult;
return m_outputs[screen]->m_gammaResult;
}
}
......@@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef KWIN_VIRTUAL_BACKEND_H
#define KWIN_VIRTUAL_BACKEND_H
#include "platform.h"
#include "virtual_output.h"
#include <kwin_export.h>
......@@ -33,7 +32,7 @@ struct gbm_device;
namespace KWin
{
struct ColorCorrect::GammaRamp;
class VirtualOutput;
class KWIN_EXPORT VirtualBackend : public Platform
{
......@@ -49,7 +48,7 @@ public:
int outputCount() const {
return m_outputs.size();
}
const QVector<VirtualOutput> outputs() const {
const QVector<VirtualOutput*> outputs() const {
return m_outputs;
}
qreal outputScale() const {
......@@ -95,7 +94,7 @@ Q_SIGNALS:
void virtualOutputsSet(bool countChanged);
private:
QVector<VirtualOutput> m_outputs;
QVector<VirtualOutput*> m_outputs;
qreal m_outputScale = 1;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment