From 26752058d6a393ac7c33cd38b6db5fd2db78a7c9 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 18 Aug 2022 11:33:04 +0300 Subject: [PATCH] backends/x11: Remove initial position logic Let kwin decide the output position. This makes the behavior of the x11 backend consistent with the drm backend. --- src/backends/x11/windowed/x11_windowed_backend.cpp | 14 ++------------ src/backends/x11/windowed/x11_windowed_output.cpp | 8 +++----- src/backends/x11/windowed/x11_windowed_output.h | 10 ++-------- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/backends/x11/windowed/x11_windowed_backend.cpp b/src/backends/x11/windowed/x11_windowed_backend.cpp index 782e674e8f..31157ef5fe 100644 --- a/src/backends/x11/windowed/x11_windowed_backend.cpp +++ b/src/backends/x11/windowed/x11_windowed_backend.cpp @@ -281,12 +281,10 @@ void X11WindowedBackend::createOutputs() // create an output window of this size in the end const int pixelWidth = initialWindowSize().width() * initialOutputScale() + 0.5; const int pixelHeight = initialWindowSize().height() * initialOutputScale() + 0.5; - const int logicalWidth = initialWindowSize().width(); - int logicalWidthSum = 0; for (int i = 0; i < initialOutputCount(); ++i) { auto *output = new X11WindowedOutput(this); - output->init(QPoint(logicalWidthSum, 0), QSize(pixelWidth, pixelHeight)); + output->init(QSize(pixelWidth, pixelHeight)); m_protocols = protocolsAtom; m_deleteWindowProtocol = deleteWindowAtom; @@ -299,7 +297,6 @@ void X11WindowedBackend::createOutputs() 32, 1, &m_deleteWindowProtocol); - logicalWidthSum += logicalWidth; m_outputs << output; Q_EMIT outputAdded(output); output->setEnabled(true); @@ -500,13 +497,6 @@ void X11WindowedBackend::handleClientMessage(xcb_client_message_event_t *event) auto removedOutput = *it; it = m_outputs.erase(it); - // update the sizes - int x = removedOutput->internalPosition().x(); - for (; it != m_outputs.end(); ++it) { - (*it)->setGeometry(QPoint(x, 0), (*it)->pixelSize()); - x += (*it)->geometry().width(); - } - removedOutput->setEnabled(false); Q_EMIT outputRemoved(removedOutput); delete removedOutput; @@ -590,7 +580,7 @@ void X11WindowedBackend::updateSize(xcb_configure_notify_event_t *event) const QSize s = QSize(event->width, event->height); if (s != output->pixelSize()) { - output->setGeometry(output->internalPosition(), s); + output->resize(s); } Q_EMIT sizeChanged(); } diff --git a/src/backends/x11/windowed/x11_windowed_output.cpp b/src/backends/x11/windowed/x11_windowed_output.cpp index 8515e0f4b2..f9b509c55d 100644 --- a/src/backends/x11/windowed/x11_windowed_output.cpp +++ b/src/backends/x11/windowed/x11_windowed_output.cpp @@ -74,13 +74,13 @@ SoftwareVsyncMonitor *X11WindowedOutput::vsyncMonitor() const return m_vsyncMonitor.get(); } -void X11WindowedOutput::init(const QPoint &logicalPosition, const QSize &pixelSize) +void X11WindowedOutput::init(const QSize &pixelSize) { const int refreshRate = 60000; // TODO: get refresh rate via randr m_renderLoop->setRefreshRate(refreshRate); m_vsyncMonitor->setRefreshRate(refreshRate); - setGeometry(logicalPosition, pixelSize); + resize(pixelSize); setScale(m_backend->initialOutputScale()); const uint32_t eventMask = XCB_EVENT_MASK_KEY_PRESS @@ -157,12 +157,10 @@ void X11WindowedOutput::initXInputForWindow() #endif } -void X11WindowedOutput::setGeometry(const QPoint &logicalPosition, const QSize &pixelSize) +void X11WindowedOutput::resize(const QSize &pixelSize) { auto mode = std::make_shared(pixelSize, m_renderLoop->refreshRate()); setModesInternal({mode}, mode); - - moveTo(logicalPosition); } void X11WindowedOutput::setWindowTitle(const QString &title) diff --git a/src/backends/x11/windowed/x11_windowed_output.h b/src/backends/x11/windowed/x11_windowed_output.h index d972779d1e..f007978736 100644 --- a/src/backends/x11/windowed/x11_windowed_output.h +++ b/src/backends/x11/windowed/x11_windowed_output.h @@ -38,7 +38,8 @@ public: RenderLoop *renderLoop() const override; SoftwareVsyncMonitor *vsyncMonitor() const; - void init(const QPoint &logicalPosition, const QSize &pixelSize); + void init(const QSize &pixelSize); + void resize(const QSize &pixelSize); xcb_window_t window() const { @@ -54,13 +55,6 @@ public: void setWindowTitle(const QString &title); - /** - * @brief defines the geometry of the output - * @param logicalPosition top left position of the output in compositor space - * @param pixelSize output size as seen from the outside - */ - void setGeometry(const QPoint &logicalPosition, const QSize &pixelSize); - /** * Translates the global X11 screen coordinate @p pos to output coordinates. */