Skip to content
This repository has been archived by the owner on Jul 23, 2020. It is now read-only.

Commit

Permalink
Merge pull request #33 from sirspudd/master
Browse files Browse the repository at this point in the history
Get gtk platform plugin working against Qt 5.10
  • Loading branch information
rburchell authored Dec 18, 2017
2 parents 1714d4d + ba993a2 commit 3cb8e51
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/qgtkbackingstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,18 @@ void QGtkBackingStore::endPaint()
}

void QGtkBackingStore::composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
QPlatformTextureList *textures, bool translucentBackground)
#else
QPlatformTextureList *textures, QOpenGLContext *context, bool translucentBackground)
#endif
{
TRACE_EVENT0("gfx", "QGtkBackingStore::composeAndFlush");
#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
QPlatformBackingStore::composeAndFlush(window, region, offset, textures, translucentBackground);
#else
QPlatformBackingStore::composeAndFlush(window, region, offset, textures, context, translucentBackground);
#endif
}

void QGtkBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
Expand Down
4 changes: 4 additions & 0 deletions src/qgtkbackingstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ class QGtkBackingStore : public QPlatformBackingStore
void beginPaint(const QRegion &region) override;
void endPaint() override;
void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
QPlatformTextureList *textures, bool translucentBackground) override;
#else
QPlatformTextureList *textures, QOpenGLContext *context, bool translucentBackground) override;
#endif
void flush(QWindow *window, const QRegion &region, const QPoint &offset) override;
void resize(const QSize &size, const QRegion &staticContents) override;
QImage toImage() const override;
Expand Down
9 changes: 8 additions & 1 deletion src/qgtkwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,15 @@ void QGtkWindow::setWindowFlags(Qt::WindowFlags flags)
}
}

void QGtkWindow::setWindowState(Qt::WindowState state)
#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
void QGtkWindow::setWindowState(Qt::WindowStates requestedState)
{
const Qt::WindowState state = QWindowPrivate::effectiveState(requestedState);
#else
void QGtkWindow::setWindowState(Qt::WindowState requestedState)
{
#endif

if (state == m_state) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions src/qgtkwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ class QGtkWindow : public QPlatformWindow

void setVisible(bool visible) override;
void setWindowFlags(Qt::WindowFlags flags) override;
#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
void setWindowState(Qt::WindowStates state) override;
#else
void setWindowState(Qt::WindowState state) override;
#endif

WId winId() const override;
void setParent(const QPlatformWindow *window) override;
Expand Down
24 changes: 24 additions & 0 deletions src/qgtkwindow_gesture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ void QGtkWindow::beginZoom(QPointF &contentPoint, guint32 ts)
m_initialZoomSet = false;
if (m_activeNativeGestures++ == 0) {
qCDebug(lcGesture) << "Started native gesture sequence (due to zoom)";
#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
QWindowSystemInterface::handleGestureEvent(window(), nullptr, ts, Qt::BeginNativeGesture, contentPoint, contentPoint);
#else
QWindowSystemInterface::handleGestureEvent(window(), ts, Qt::BeginNativeGesture, contentPoint, contentPoint);
#endif
}
}

Expand All @@ -111,14 +115,22 @@ void QGtkWindow::zoom(QPointF &contentPoint, double scale, guint32 ts)
}
double modScale = (scale - m_initialZoom) / m_initialZoom;
m_initialZoom = scale;
#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
QWindowSystemInterface::handleGestureEventWithRealValue(window(), nullptr, ts, Qt::ZoomNativeGesture, modScale, contentPoint, contentPoint);
#else
QWindowSystemInterface::handleGestureEventWithRealValue(window(), ts, Qt::ZoomNativeGesture, modScale, contentPoint, contentPoint);
#endif
}

void QGtkWindow::endZoom(QPointF &contentPoint, guint32 ts)
{
if (--m_activeNativeGestures == 0) {
qCDebug(lcGesture) << "Ended native gesture sequence (due to zoom)";
#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
QWindowSystemInterface::handleGestureEvent(window(), nullptr, ts, Qt::EndNativeGesture, contentPoint, contentPoint);
#else
QWindowSystemInterface::handleGestureEvent(window(), ts, Qt::EndNativeGesture, contentPoint, contentPoint);
#endif
}
}

Expand Down Expand Up @@ -172,7 +184,11 @@ void QGtkWindow::beginRotate(QPointF &contentPoint, guint32 ts)
m_initialRotateSet = false;
if (m_activeNativeGestures++ == 0) {
qCDebug(lcGesture) << "Started native gesture sequence (due to rotate)";
#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
QWindowSystemInterface::handleGestureEvent(window(), nullptr, ts, Qt::BeginNativeGesture, contentPoint, contentPoint);
#else
QWindowSystemInterface::handleGestureEvent(window(), ts, Qt::BeginNativeGesture, contentPoint, contentPoint);
#endif
}
}

Expand All @@ -186,14 +202,22 @@ void QGtkWindow::rotate(QPointF &contentPoint, double angle, double angle_delta,
}
double degrees = m_initialRotate - (angle * 180 / M_PI);
m_initialRotate = angle * 180 / M_PI;
#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
QWindowSystemInterface::handleGestureEventWithRealValue(window(), nullptr, ts, Qt::RotateNativeGesture, degrees, contentPoint, contentPoint);
#else
QWindowSystemInterface::handleGestureEventWithRealValue(window(), ts, Qt::RotateNativeGesture, degrees, contentPoint, contentPoint);
#endif
}

void QGtkWindow::endRotate(QPointF &contentPoint, guint32 ts)
{
if (--m_activeNativeGestures == 0) {
qCDebug(lcGesture) << "Ended native gesture sequence (due to rotate)";
#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
QWindowSystemInterface::handleGestureEvent(window(), nullptr, ts, Qt::EndNativeGesture, contentPoint, contentPoint);
#else
QWindowSystemInterface::handleGestureEvent(window(), ts, Qt::EndNativeGesture, contentPoint, contentPoint);
#endif
}
}

4 changes: 4 additions & 0 deletions src/qgtkwindow_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ void QGtkWindow::onDraw(cairo_t *cr)
{
if (m_newGeometry != m_windowGeometry) {
bool needsExpose = m_newGeometry.size() != m_windowGeometry.size();
#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
QWindowSystemInterface::handleGeometryChange(window(), m_newGeometry);
#else
QWindowSystemInterface::handleGeometryChange(window(), m_newGeometry, m_windowGeometry);
#endif
m_windowGeometry = m_newGeometry;

if (needsExpose) {
Expand Down

0 comments on commit 3cb8e51

Please sign in to comment.