Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[lipstick] Enable building against QtWayland 5.6. JB#44844
Adapt to the introduced QWaylandOutput and QWaylandClient classes
and the associated API breakage.
  • Loading branch information
adenexter committed Jul 12, 2019
1 parent aab8dd3 commit c82c149
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/compositor/alienmanager/aliensurface.cpp
Expand Up @@ -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"
Expand All @@ -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)
Expand Down
25 changes: 25 additions & 0 deletions src/compositor/lipstickcompositor.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions src/compositor/lipstickcompositor.h
Expand Up @@ -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>
Expand All @@ -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
{
Expand Down Expand Up @@ -207,6 +216,10 @@ private slots:

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;
Expand Down
10 changes: 10 additions & 0 deletions src/compositor/lipstickcompositorwindow.cpp
Expand Up @@ -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>
Expand All @@ -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),
Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions src/compositor/windowmodel.cpp
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
Expand Down
18 changes: 18 additions & 0 deletions tests/stubs/lipstickcompositor_stub.h
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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)
{
}
Expand All @@ -634,3 +650,5 @@ QWaylandQuickCompositor::QWaylandQuickCompositor(QQuickWindow *, const char *, Q
}

#endif

#endif

0 comments on commit c82c149

Please sign in to comment.