Commit c82c1490 authored by Andrew den Exter's avatar Andrew den Exter

[lipstick] Enable building against QtWayland 5.6. JB#44844

Adapt to the introduced QWaylandOutput and QWaylandClient classes
and the associated API breakage.
parent aab8dd3a
......@@ -13,8 +13,14 @@
**
****************************************************************************/
#include <QtCompositorVersion>
#include <QtCompositor/QWaylandSurface>
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
#include <QtCompositor/QWaylandClient>
#endif
#include "lipstickcompositor.h"
#include "aliensurface.h"
#include "alienmanager.h"
......@@ -23,7 +29,11 @@
AlienSurface::AlienSurface(AlienClient *client, QWaylandSurface *surface, uint32_t version, uint32_t id, const QString &package)
: QObject(client)
, QWaylandSurfaceInterface(surface)
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
, QtWaylandServer::alien_surface(surface->client()->client(), id, version)
#else
, QtWaylandServer::alien_surface(reinterpret_cast<wl_client *>(surface->client()), id, version)
#endif
, m_client(client)
, m_hidden(false)
, m_coverized(false)
......
......@@ -38,10 +38,19 @@
#include <private/qguiapplication_p.h>
#include <QtGui/qpa/qplatformintegration.h>
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
#include <QWaylandClient>
#endif
LipstickCompositor *LipstickCompositor::m_instance = 0;
LipstickCompositor::LipstickCompositor()
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
: QWaylandQuickCompositor(nullptr, (QWaylandCompositor::ExtensionFlags)QWaylandCompositor::DefaultExtensions & ~QWaylandCompositor::QtKeyExtension)
, m_output(this, this, QString(), QString())
#else
: QWaylandQuickCompositor(this, 0, (QWaylandCompositor::ExtensionFlags)QWaylandCompositor::DefaultExtensions & ~QWaylandCompositor::QtKeyExtension)
#endif
, m_totalWindowCount(0)
, m_nextWindowId(1)
, m_homeActive(true)
......@@ -162,7 +171,14 @@ void LipstickCompositor::onVisibleChanged(bool visible)
void LipstickCompositor::componentComplete()
{
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
QScreen * const screen = QGuiApplication::primaryScreen();
m_output.setGeometry(QRect(QPoint(0, 0), screen->size()));
m_output.setPhysicalSize(screen->physicalSize().toSize());
#else
QWaylandCompositor::setOutputGeometry(QRect(0, 0, width(), height()));
#endif
}
void LipstickCompositor::surfaceCreated(QWaylandSurface *surface)
......@@ -297,7 +313,11 @@ int LipstickCompositor::windowIdForLink(QWaylandSurface *s, uint link) const
QWaylandSurface *windowSurface = iter.value()->surface();
if (windowSurface && windowSurface->client() && s->client() &&
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
windowSurface->client()->processId() == s->client()->processId() &&
#else
windowSurface->processId() == s->processId() &&
#endif
windowSurface->windowProperties().value("WINID", uint(0)).toUInt() == link)
return iter.value()->windowId();
}
......@@ -355,7 +375,12 @@ void LipstickCompositor::setTopmostWindowId(int id)
QWaylandSurface *surface = surfaceForId(m_topmostWindowId);
if (surface)
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
pid = surface->client()->processId();
#else
pid = surface->processId();
#endif
if (m_topmostWindowProcessId != pid) {
m_topmostWindowProcessId = pid;
......
......@@ -16,10 +16,15 @@
#ifndef LIPSTICKCOMPOSITOR_H
#define LIPSTICKCOMPOSITOR_H
#include <QtCompositorVersion>
#include <QQuickWindow>
#include "lipstickglobal.h"
#include "homeapplication.h"
#include <QQmlParserStatus>
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
#include <QWaylandQuickOutput>
#endif
#include <QWaylandQuickCompositor>
#include <QWaylandSurfaceItem>
#include <QPointer>
......@@ -37,6 +42,10 @@ namespace ContentAction {
class Action;
}
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
typedef QWaylandClient WaylandClient;
#endif
class LIPSTICK_EXPORT LipstickCompositor : public QQuickWindow, public QWaylandQuickCompositor,
public QQmlParserStatus
{
......@@ -207,6 +216,10 @@ private:
static LipstickCompositor *m_instance;
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
QWaylandQuickOutput m_output;
#endif
int m_totalWindowCount;
QHash<int, LipstickCompositorWindow *> m_mappedSurfaces;
QHash<int, LipstickCompositorWindow *> m_windows;
......
......@@ -13,9 +13,14 @@
**
****************************************************************************/
#include <QtCompositorVersion>
#include <QCoreApplication>
#include <QWaylandCompositor>
#include <QWaylandInputDevice>
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
#include <QWaylandClient>
#endif
#include <QTimer>
#include <sys/types.h>
#include <signal.h>
......@@ -28,6 +33,7 @@
#include <private/qwlsurface_p.h>
#include <private/qquickwindow_p.h>
LipstickCompositorWindow::LipstickCompositorWindow(int windowId, const QString &category,
QWaylandQuickSurface *surface, QQuickItem *parent)
: QWaylandSurfaceItem(surface, parent), m_windowId(windowId), m_isAlien(false), m_category(category),
......@@ -85,7 +91,11 @@ bool LipstickCompositorWindow::isAlien() const
qint64 LipstickCompositorWindow::processId() const
{
if (surface())
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
return surface()->client()->processId();
#else
return surface()->processId();
#endif
else return 0;
}
......
......@@ -20,6 +20,10 @@
#include "lipstickcompositor.h"
#include "windowmodel.h"
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
#include <QWaylandClient>
#endif
WindowModel::WindowModel()
: m_complete(false)
{
......@@ -70,7 +74,11 @@ QVariant WindowModel::data(const QModelIndex &index, int role) const
return m_items.at(idx);
} else if (role == Qt::UserRole + 2) {
QWaylandSurface *s = c->surfaceForId(m_items.at(idx));
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
return s?s->client()->processId():0;
#else
return s?s->processId():0;
#endif
} else if (role == Qt::UserRole + 3) {
LipstickCompositorWindow *w = static_cast<LipstickCompositorWindow *>(c->windowForId(m_items.at(idx)));
return w->title();
......
......@@ -377,6 +377,9 @@ LipstickCompositorStub *gLipstickCompositorStub = &gDefaultLipstickCompositorStu
// 4. CREATE A PROXY WHICH CALLS THE STUB
LipstickCompositor::LipstickCompositor()
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
: m_output(this, this, QString(), QString())
#endif
{
gLipstickCompositorStub->LipstickCompositorConstructor();
}
......@@ -625,6 +628,19 @@ void LipstickCompositor::timerEvent(QTimerEvent *e)
gLipstickCompositorStub->timerEvent(e);
}
#if QTCOMPOSITOR_VERSION >= QT_VERSION_CHECK(5, 6, 0)
QWaylandQuickCompositor::QWaylandQuickCompositor(const char *, ExtensionFlags)
{
}
QWaylandOutput::QWaylandOutput(QWaylandCompositor *, QWindow *, const QString &, const QString &)
: d_ptr(nullptr)
{
}
#else
QWaylandCompositor::QWaylandCompositor(QWindow *, const char *, QWaylandCompositor::ExtensionFlags)
{
}
......@@ -634,3 +650,5 @@ QWaylandQuickCompositor::QWaylandQuickCompositor(QQuickWindow *, const char *, Q
}
#endif
#endif
Markdown is supported
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