From edb200f6bcd531fb3c8f8bc9d43263922b8247f1 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Tue, 27 Aug 2019 12:31:42 +0200 Subject: [PATCH] [platforms/x11/windowed] Create output devices Summary: Create output devices in X11 nested Wayland session. Test Plan: Started nested session in X11. KScreen showed output. Reviewers: #kwin Subscribers: kwin Tags: #kwin Maniphest Tasks: T11459 Differential Revision: https://phabricator.kde.org/D23479 --- .../x11/windowed/x11windowed_backend.cpp | 5 ++--- .../x11/windowed/x11windowed_output.cpp | 16 ++++++++++++++-- .../platforms/x11/windowed/x11windowed_output.h | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/plugins/platforms/x11/windowed/x11windowed_backend.cpp b/plugins/platforms/x11/windowed/x11windowed_backend.cpp index 76077c960f..1523f2985f 100644 --- a/plugins/platforms/x11/windowed/x11windowed_backend.cpp +++ b/plugins/platforms/x11/windowed/x11windowed_backend.cpp @@ -54,6 +54,7 @@ X11WindowedBackend::X11WindowedBackend(QObject *parent) { setSupportsPointerWarping(true); connect(this, &X11WindowedBackend::sizeChanged, this, &X11WindowedBackend::screenSizeChanged); + handleOutputs(); } X11WindowedBackend::~X11WindowedBackend() @@ -153,9 +154,7 @@ void X11WindowedBackend::createOutputs() int logicalWidthSum = 0; for (int i = 0; i < initialOutputCount(); ++i) { auto *output = new X11WindowedOutput(this); - output->setScale(initialOutputScale()); - output->setGeometry(QPoint(logicalWidthSum, 0), QSize(pixelWidth, pixelHeight)); - output->init(); + output->init(QPoint(logicalWidthSum, 0), QSize(pixelWidth, pixelHeight)); m_protocols = protocolsAtom; m_deleteWindowProtocol = deleteWindowAtom; diff --git a/plugins/platforms/x11/windowed/x11windowed_output.cpp b/plugins/platforms/x11/windowed/x11windowed_output.cpp index 9889d32760..3c3c80b1b4 100644 --- a/plugins/platforms/x11/windowed/x11windowed_output.cpp +++ b/plugins/platforms/x11/windowed/x11windowed_output.cpp @@ -47,8 +47,20 @@ X11WindowedOutput::~X11WindowedOutput() xcb_flush(m_backend->connection()); } -void X11WindowedOutput::init() +void X11WindowedOutput::init(const QPoint &logicalPosition, const QSize &pixelSize) { + KWayland::Server::OutputDeviceInterface::Mode mode; + mode.id = 0; + mode.size = pixelSize; + mode.flags = KWayland::Server::OutputDeviceInterface::ModeFlag::Current; + mode.refreshRate = 60000; // TODO: get refresh rate via randr + AbstractWaylandOutput::initWaylandOutputDevice("model_TODO", "manufacturer_TODO", + "UUID_TODO", { mode }); + + setEnabled(true); + setGeometry(logicalPosition, pixelSize); + setScale(m_backend->initialOutputScale()); + uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; const uint32_t values[] = { m_backend->screen()->black_pixel, @@ -67,7 +79,7 @@ void X11WindowedOutput::init() m_window, m_backend->screen()->root, 0, 0, - pixelSize().width(), pixelSize().height(), + pixelSize.width(), pixelSize.height(), 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, mask, values); diff --git a/plugins/platforms/x11/windowed/x11windowed_output.h b/plugins/platforms/x11/windowed/x11windowed_output.h index 65ca9b7e96..460a3298e7 100644 --- a/plugins/platforms/x11/windowed/x11windowed_output.h +++ b/plugins/platforms/x11/windowed/x11windowed_output.h @@ -45,7 +45,7 @@ public: explicit X11WindowedOutput(X11WindowedBackend *backend); ~X11WindowedOutput() override; - void init(); + void init(const QPoint &logicalPosition, const QSize &pixelSize); xcb_window_t window() const { return m_window;