Commit b062d09f authored by Kai Uwe Broulik's avatar Kai Uwe Broulik Committed by Merge Service
Browse files

backends/x11: Support resizing the windowed output



In response to a XCB_CONFIGURE_NOTIFY on the output window, the new size
is set as mode and the output layer buffer is recreated.

Signed-off-by: default avatarVictoria Fischer <victoria.fischer@mbition.io>
Part-of: <!2459>
parent 486d229c
Pipeline #180975 passed with stage
in 13 minutes and 46 seconds
......@@ -23,7 +23,6 @@ namespace KWin
EglX11Output::EglX11Output(EglX11Backend *backend, Output *output, EGLSurface surface)
: m_eglSurface(surface)
, m_fbo(new GLFramebuffer(0, output->pixelSize()))
, m_output(output)
, m_backend(backend)
{
......@@ -34,9 +33,17 @@ EglX11Output::~EglX11Output()
eglDestroySurface(m_backend->eglDisplay(), m_eglSurface);
}
void EglX11Output::ensureFbo()
{
if (!m_fbo || m_fbo->size() != m_output->pixelSize()) {
m_fbo.reset(new GLFramebuffer(0, m_output->pixelSize()));
}
}
OutputLayerBeginFrameInfo EglX11Output::beginFrame()
{
eglMakeCurrent(m_backend->eglDisplay(), m_eglSurface, m_eglSurface, m_backend->context());
ensureFbo();
GLFramebuffer::pushFramebuffer(m_fbo.data());
return OutputLayerBeginFrameInfo{
.renderTarget = RenderTarget(m_fbo.data()),
......
......@@ -32,6 +32,8 @@ public:
QRegion lastDamage() const;
private:
void ensureFbo();
EGLSurface m_eglSurface;
QScopedPointer<GLFramebuffer> m_fbo;
QRegion m_lastDamage;
......
......@@ -18,14 +18,23 @@ namespace KWin
X11WindowedQPainterOutput::X11WindowedQPainterOutput(Output *output, xcb_window_t window)
: window(window)
, buffer(output->pixelSize() * output->scale(), QImage::Format_RGB32)
, m_output(output)
{
buffer.fill(Qt::black);
}
void X11WindowedQPainterOutput::ensureBuffer()
{
const QSize nativeSize(m_output->pixelSize() * m_output->scale());
if (buffer.size() != nativeSize) {
buffer = QImage(nativeSize, QImage::Format_RGB32);
buffer.fill(Qt::black);
}
}
OutputLayerBeginFrameInfo X11WindowedQPainterOutput::beginFrame()
{
ensureBuffer();
return OutputLayerBeginFrameInfo{
.renderTarget = RenderTarget(&buffer),
.repaint = m_output->rect(),
......
......@@ -29,6 +29,8 @@ class X11WindowedQPainterOutput : public OutputLayer
public:
X11WindowedQPainterOutput(Output *output, xcb_window_t window);
void ensureBuffer();
OutputLayerBeginFrameInfo beginFrame() override;
void endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override;
......
......@@ -66,9 +66,6 @@ void X11WindowedOutput::init(const QPoint &logicalPosition, const QSize &pixelSi
m_renderLoop->setRefreshRate(refreshRate);
m_vsyncMonitor->setRefreshRate(refreshRate);
auto mode = QSharedPointer<OutputMode>::create(pixelSize, refreshRate);
setModesInternal({mode}, mode);
setGeometry(logicalPosition, pixelSize);
setScale(m_backend->initialOutputScale());
......@@ -150,8 +147,9 @@ void X11WindowedOutput::initXInputForWindow()
void X11WindowedOutput::setGeometry(const QPoint &logicalPosition, const QSize &pixelSize)
{
// TODO: set mode to have updated pixelSize
Q_UNUSED(pixelSize);
auto mode = QSharedPointer<OutputMode>::create(pixelSize, m_renderLoop->refreshRate());
setModesInternal({mode}, mode);
moveTo(logicalPosition);
}
......
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