[platforms/wayland] Create output devices

Summary:
Since all Wayland session backends now use the same structure of
AbstractWaylandOutput we can create output devices like in the DRM backend.

First let us do this for Wayland nested sessions.

Test Plan: Manually with output-count 1 and 2. Outputs are correctly shown in KScreen.

Reviewers: #kwin

Subscribers: zzag, kwin

Tags: #kwin

Maniphest Tasks: T11140, T11459

Differential Revision: https://phabricator.kde.org/D23473
This commit is contained in:
Roman Gilg 2019-08-27 12:14:10 +02:00
parent e79aedb1de
commit f013a4369c
3 changed files with 35 additions and 14 deletions

View file

@ -454,6 +454,7 @@ WaylandBackend::WaylandBackend(QObject *parent)
, m_connectionThread(nullptr)
{
connect(this, &WaylandBackend::connectionFailed, this, &WaylandBackend::initFailed);
handleOutputs();
}
WaylandBackend::~WaylandBackend()
@ -707,8 +708,7 @@ void WaylandBackend::createOutputs()
return;
}
waylandOutput->setScale(initialOutputScale());
waylandOutput->setGeometry(QPoint(logicalWidthSum, 0), QSize(pixelWidth, pixelHeight));
waylandOutput->init(QPoint(logicalWidthSum, 0), QSize(pixelWidth, pixelHeight));
connect(waylandOutput, &WaylandOutput::sizeChanged, this, [this, waylandOutput](const QSize &size) {
Q_UNUSED(size)

View file

@ -17,7 +17,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "wayland_output.h"
#include "wayland_backend.h"
@ -38,9 +37,10 @@ namespace Wayland
using namespace KWayland::Client;
WaylandOutput::WaylandOutput(Surface *surface, QObject *parent)
: AbstractWaylandOutput(parent),
m_surface(surface)
WaylandOutput::WaylandOutput(Surface *surface, WaylandBackend *backend)
: AbstractWaylandOutput(backend)
, m_surface(surface)
, m_backend(backend)
{
connect(surface, &Surface::frameRendered, [this] {
m_rendered = true;
@ -54,6 +54,21 @@ WaylandOutput::~WaylandOutput()
delete m_surface;
}
void WaylandOutput::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: can we get refresh rate data from Wayland host?
AbstractWaylandOutput::initWaylandOutputDevice("model_TODO", "manufacturer_TODO",
"UUID_TODO", { mode });
setRawPhysicalSize(pixelSize);
setEnabled(true);
setGeometry(logicalPosition, pixelSize);
setScale(backend()->initialOutputScale());
}
QSize WaylandOutput::pixelSize() const
{
return m_pixelSize;
@ -81,7 +96,6 @@ ShellOutput::~ShellOutput()
XdgShellOutput::XdgShellOutput(Surface *surface, XdgShell *xdgShell, WaylandBackend *backend, int number)
: WaylandOutput(surface, backend)
, m_backend(backend)
, m_number(number)
{
m_xdgShellSurface = xdgShell->createSurface(surface, this);
@ -130,7 +144,7 @@ void XdgShellOutput::updateWindowTitle()
QString grab;
if (m_hasPointerLock) {
grab = i18n("Press right control to ungrab pointer");
} else if (m_backend->pointerConstraints()) {
} else if (backend()->pointerConstraints()) {
grab = i18n("Press right control key to grab pointer");
}
const QString title = i18nc("Title of nested KWin Wayland with Wayland socket identifier as argument",
@ -151,13 +165,13 @@ void XdgShellOutput::lockPointer(Pointer *pointer, bool lock)
m_pointerLock = nullptr;
m_hasPointerLock = false;
if (surfaceWasLocked) {
emit m_backend->pointerLockChanged(false);
emit backend()->pointerLockChanged(false);
}
return;
}
Q_ASSERT(!m_pointerLock);
m_pointerLock = m_backend->pointerConstraints()->lockPointer(surface(), pointer, nullptr,
m_pointerLock = backend()->pointerConstraints()->lockPointer(surface(), pointer, nullptr,
PointerConstraints::LifeTime::OneShot,
this);
if (!m_pointerLock->isValid()) {
@ -168,7 +182,7 @@ void XdgShellOutput::lockPointer(Pointer *pointer, bool lock)
connect(m_pointerLock, &LockedPointer::locked, this,
[this] {
m_hasPointerLock = true;
emit m_backend->pointerLockChanged(true);
emit backend()->pointerLockChanged(true);
}
);
connect(m_pointerLock, &LockedPointer::unlocked, this,
@ -176,7 +190,7 @@ void XdgShellOutput::lockPointer(Pointer *pointer, bool lock)
delete m_pointerLock;
m_pointerLock = nullptr;
m_hasPointerLock = false;
emit m_backend->pointerLockChanged(false);
emit backend()->pointerLockChanged(false);
}
);
}

View file

@ -50,9 +50,11 @@ class WaylandOutput : public AbstractWaylandOutput
{
Q_OBJECT
public:
explicit WaylandOutput(KWayland::Client::Surface *surface, QObject *parent = nullptr);
WaylandOutput(KWayland::Client::Surface *surface, WaylandBackend *backend);
~WaylandOutput() override;
void init(const QPoint &logicalPosition, const QSize &pixelSize);
virtual void lockPointer(KWayland::Client::Pointer *pointer, bool lock) {
Q_UNUSED(pointer)
Q_UNUSED(lock)
@ -84,8 +86,14 @@ Q_SIGNALS:
void sizeChanged(const QSize &size);
void frameRendered();
protected:
WaylandBackend *backend() {
return m_backend;
}
private:
KWayland::Client::Surface *m_surface;
WaylandBackend *m_backend;
QSize m_pixelSize;
bool m_rendered = false;
@ -118,7 +126,6 @@ private:
void updateWindowTitle();
KWayland::Client::XdgShellSurface *m_xdgShellSurface = nullptr;
WaylandBackend *m_backend;
int m_number;
KWayland::Client::LockedPointer *m_pointerLock = nullptr;
bool m_hasPointerLock = false;