Commit 8a606e47 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

platforms/x11: Introduce X11PlaceholderOutput

It is useful in case the Xrandr extension is unavailable or no outputs
are connected.
parent 1a40632f
......@@ -12,6 +12,7 @@ set(X11PLATFORM_SOURCES
x11_output.cpp
x11_platform.cpp
x11cursor.cpp
x11placeholderoutput.cpp
xfixes_cursor_event_filter.cpp
)
......
......@@ -8,6 +8,7 @@
*/
#include "x11_platform.h"
#include "x11cursor.h"
#include "x11placeholderoutput.h"
#include "edge.h"
#include "windowselector.h"
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
......@@ -436,20 +437,17 @@ template <typename T>
void X11StandalonePlatform::doUpdateOutputs()
{
auto fallback = [this]() {
auto *o = new X11Output(this);
o->setGammaRampSize(0);
o->setRefreshRate(60000);
o->setName(QStringLiteral("Xinerama"));
m_outputs << o;
emit outputAdded(o);
emit outputEnabled(o);
X11PlaceholderOutput *dummyOutput = new X11PlaceholderOutput();
m_outputs << dummyOutput;
emit outputAdded(dummyOutput);
emit outputEnabled(dummyOutput);
};
// TODO: instead of resetting all outputs, check if new output is added/removed
// or still available and leave still available outputs in m_outputs
// untouched (like in DRM backend)
while (!m_outputs.isEmpty()) {
X11Output *output = m_outputs.takeLast();
AbstractOutput *output = m_outputs.takeLast();
emit outputDisabled(output);
emit outputRemoved(output);
delete output;
......
......@@ -95,8 +95,7 @@ private:
Display *m_x11Display;
QScopedPointer<WindowSelector> m_windowSelector;
QScopedPointer<X11EventFilter> m_screenEdgesFilter;
QVector<X11Output*> m_outputs;
QVector<AbstractOutput *> m_outputs;
};
}
......
/*
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "x11placeholderoutput.h"
#include "main.h"
namespace KWin
{
X11PlaceholderOutput::X11PlaceholderOutput(QObject *parent)
: AbstractOutput(parent)
{
}
QString X11PlaceholderOutput::name() const
{
return QStringLiteral("Placeholder-0");
}
QRect X11PlaceholderOutput::geometry() const
{
xcb_screen_t *screen = kwinApp()->x11DefaultScreen();
if (screen) {
return QRect(0, 0, screen->width_in_pixels, screen->height_in_pixels);
}
return QRect();
}
int X11PlaceholderOutput::refreshRate() const
{
return 60000;
}
QSize X11PlaceholderOutput::pixelSize() const
{
return geometry().size();
}
} // namespace KWin
/*
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include "abstract_output.h"
namespace KWin
{
class X11PlaceholderOutput : public AbstractOutput
{
Q_OBJECT
public:
explicit X11PlaceholderOutput(QObject *parent = nullptr);
QString name() const override;
QRect geometry() const override;
int refreshRate() const override;
QSize pixelSize() const override;
};
} // namespace KWin
Markdown is supported
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