Commit 2629007e authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Make outputs disabled by default

This can be used to make our backends more multi-purpose. At the moment,
new outputs are enabled by default, but it makes sense to do otherwise.

For example, if an output is disabled by default, it would be possible
to delegate initial output configuration to layer above, to kwin.

In long term, the drm backend would need to scan connectors, create an
Output for every one of them, kwin sees new outputs and tries to apply
the initial output configuration, which includes the enabled status.
parent 854aebb3
......@@ -335,12 +335,12 @@ void DrmBackend::addOutput(DrmAbstractOutput *o)
{
m_outputs.append(o);
Q_EMIT outputAdded(o);
enableOutput(o, true);
o->setEnabled(true);
}
void DrmBackend::removeOutput(DrmAbstractOutput *o)
{
enableOutput(o, false);
o->setEnabled(false);
m_outputs.removeOne(o);
Q_EMIT outputRemoved(o);
}
......
......@@ -55,9 +55,8 @@ bool VirtualBackend::initialize()
VirtualOutput *dummyOutput = new VirtualOutput(this);
dummyOutput->init(QPoint(0, 0), initialWindowSize());
m_outputs << dummyOutput;
m_outputsEnabled << dummyOutput;
Q_EMIT outputAdded(dummyOutput);
Q_EMIT outputEnabled(dummyOutput);
dummyOutput->setEnabled(true);
}
setReady(true);
......@@ -115,14 +114,12 @@ void VirtualBackend::setVirtualOutputs(int count, QVector<QRect> geometries, QVe
vo->setScale(scales.at(i));
}
m_outputs.append(vo);
m_outputsEnabled.append(vo);
Q_EMIT outputAdded(vo);
Q_EMIT outputEnabled(vo);
vo->setEnabled(true);
}
for (VirtualOutput *output : disabled) {
m_outputsEnabled.removeOne(output);
Q_EMIT outputDisabled(output);
output->setEnabled(false);
}
for (VirtualOutput *output : removed) {
......@@ -145,8 +142,6 @@ void VirtualBackend::enableOutput(VirtualOutput *output, bool enable)
m_outputsEnabled.removeOne(output);
Q_EMIT outputDisabled(output);
}
Q_EMIT screensQueried();
}
void VirtualBackend::removeOutput(Output *output)
......
......@@ -832,7 +832,7 @@ void WaylandBackend::destroyOutputs()
{
while (!m_outputs.isEmpty()) {
WaylandOutput *output = m_outputs.takeLast();
Q_EMIT outputDisabled(output);
output->setEnabled(false);
Q_EMIT outputRemoved(output);
delete output;
}
......@@ -957,7 +957,7 @@ void WaylandBackend::addConfiguredOutput(WaylandOutput *output)
{
m_outputs << output;
Q_EMIT outputAdded(output);
Q_EMIT outputEnabled(output);
output->setEnabled(true);
m_pendingInitialOutputs--;
if (m_pendingInitialOutputs == 0) {
......@@ -993,7 +993,7 @@ void WaylandBackend::removeVirtualOutput(Output *output)
{
WaylandOutput *waylandOutput = dynamic_cast<WaylandOutput *>(output);
if (waylandOutput && m_outputs.removeAll(waylandOutput)) {
Q_EMIT outputDisabled(waylandOutput);
waylandOutput->setEnabled(false);
Q_EMIT outputRemoved(waylandOutput);
delete waylandOutput;
}
......
......@@ -8,13 +8,14 @@
*/
#include "x11_standalone_output.h"
#include "colorlut.h"
#include "main.h"
#include "x11_standalone_platform.h"
namespace KWin
{
X11Output::X11Output(QObject *parent)
X11Output::X11Output(X11StandalonePlatform *backend, QObject *parent)
: Output(parent)
, m_backend(backend)
{
}
......@@ -71,4 +72,13 @@ void X11Output::setMode(const QSize &size, uint32_t refreshRate)
}
}
void X11Output::updateEnablement(bool enabled)
{
if (enabled) {
Q_EMIT m_backend->outputEnabled(this);
} else {
Q_EMIT m_backend->outputDisabled(this);
}
}
} // namespace KWin
......@@ -20,6 +20,8 @@
namespace KWin
{
class X11StandalonePlatform;
/**
* X11 output representation
*/
......@@ -28,9 +30,10 @@ class KWIN_EXPORT X11Output : public Output
Q_OBJECT
public:
explicit X11Output(QObject *parent = nullptr);
explicit X11Output(X11StandalonePlatform *backend, QObject *parent = nullptr);
bool usesSoftwareCursor() const override;
void updateEnablement(bool enabled) override;
RenderLoop *renderLoop() const override;
void setRenderLoop(RenderLoop *loop);
......@@ -46,6 +49,7 @@ private:
void setCrtc(xcb_randr_crtc_t crtc);
void setGammaRampSize(int size);
X11StandalonePlatform *m_backend;
RenderLoop *m_loop = nullptr;
xcb_randr_crtc_t m_crtc = XCB_NONE;
int m_gammaRampSize;
......
......@@ -5,14 +5,14 @@
*/
#include "x11_standalone_placeholderoutput.h"
#include "main.h"
#include "x11_standalone_platform.h"
namespace KWin
{
X11PlaceholderOutput::X11PlaceholderOutput(RenderLoop *loop, QObject *parent)
X11PlaceholderOutput::X11PlaceholderOutput(X11StandalonePlatform *backend, QObject *parent)
: Output(parent)
, m_loop(loop)
, m_backend(backend)
{
QSize pixelSize;
xcb_screen_t *screen = kwinApp()->x11DefaultScreen();
......@@ -30,7 +30,16 @@ X11PlaceholderOutput::X11PlaceholderOutput(RenderLoop *loop, QObject *parent)
RenderLoop *X11PlaceholderOutput::renderLoop() const
{
return m_loop;
return m_backend->renderLoop();
}
void X11PlaceholderOutput::updateEnablement(bool enabled)
{
if (enabled) {
Q_EMIT m_backend->outputEnabled(this);
} else {
Q_EMIT m_backend->outputDisabled(this);
}
}
} // namespace KWin
......@@ -11,17 +11,21 @@
namespace KWin
{
class X11StandalonePlatform;
class X11PlaceholderOutput : public Output
{
Q_OBJECT
public:
explicit X11PlaceholderOutput(RenderLoop *loop, QObject *parent = nullptr);
explicit X11PlaceholderOutput(X11StandalonePlatform *backend, QObject *parent = nullptr);
RenderLoop *renderLoop() const override;
private:
RenderLoop *m_loop;
void updateEnablement(bool enabled) override;
X11StandalonePlatform *m_backend;
};
} // namespace KWin
......@@ -530,7 +530,7 @@ void X11StandalonePlatform::doUpdateOutputs()
changed.append(output);
removed.removeOne(output);
} else {
output = new X11Output();
output = new X11Output(this);
added.append(output);
}
......@@ -585,23 +585,23 @@ void X11StandalonePlatform::doUpdateOutputs()
// The workspace handles having no outputs poorly. If the last output is about to be
// removed, create a dummy output to avoid crashing.
if (changed.isEmpty() && added.isEmpty()) {
auto dummyOutput = new X11PlaceholderOutput(m_renderLoop.get());
auto dummyOutput = new X11PlaceholderOutput(this);
m_outputs << dummyOutput;
Q_EMIT outputAdded(dummyOutput);
Q_EMIT outputEnabled(dummyOutput);
dummyOutput->setEnabled(true);
}
// Process new outputs. Note new outputs must be introduced before removing any other outputs.
for (Output *output : qAsConst(added)) {
m_outputs.append(output);
Q_EMIT outputAdded(output);
Q_EMIT outputEnabled(output);
output->setEnabled(true);
}
// Outputs have to be removed last to avoid the case where there are no enabled outputs.
for (Output *output : qAsConst(removed)) {
m_outputs.removeOne(output);
Q_EMIT outputDisabled(output);
output->setEnabled(false);
Q_EMIT outputRemoved(output);
delete output;
}
......
......@@ -302,7 +302,7 @@ void X11WindowedBackend::createOutputs()
logicalWidthSum += logicalWidth;
m_outputs << output;
Q_EMIT outputAdded(output);
Q_EMIT outputEnabled(output);
output->setEnabled(true);
}
updateWindowTitle();
......@@ -507,7 +507,7 @@ void X11WindowedBackend::handleClientMessage(xcb_client_message_event_t *event)
x += (*it)->geometry().width();
}
Q_EMIT outputDisabled(removedOutput);
removedOutput->setEnabled(false);
Q_EMIT outputRemoved(removedOutput);
delete removedOutput;
Q_EMIT screensQueried();
......
......@@ -181,4 +181,13 @@ bool X11WindowedOutput::usesSoftwareCursor() const
return false;
}
void X11WindowedOutput::updateEnablement(bool enabled)
{
if (enabled) {
Q_EMIT m_backend->outputEnabled(this);
} else {
Q_EMIT m_backend->outputDisabled(this);
}
}
} // namespace KWin
......@@ -67,6 +67,7 @@ public:
QPointF mapFromGlobal(const QPointF &pos) const;
bool usesSoftwareCursor() const override;
void updateEnablement(bool enabled) override;
private:
void initXInputForWindow();
......
......@@ -343,7 +343,7 @@ private:
std::shared_ptr<OutputMode> m_currentMode;
DpmsMode m_dpmsMode = DpmsMode::On;
SubPixel m_subPixel = SubPixel::Unknown;
bool m_isEnabled = true;
bool m_isEnabled = false;
uint32_t m_overscan = 0;
RgbRange m_rgbRange = RgbRange::Automatic;
friend class EffectScreenImpl; // to access m_effectScreen
......
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