diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2016-10-06 15:01:35 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@qt.io> | 2016-10-07 12:01:42 +0000 |
commit | 4a792b169ed3810d60ddb5f8fab576368fbd7c4f (patch) | |
tree | c76bc5c1a4d2f119d7f24c1944849d9f699aff61 | |
parent | 985bd824ef70ea23484f70718b0f944533c4d076 (diff) |
Rename QWaylandSurface::throttlingView to primaryView
And make sure QWaylandWlShellIntegration and QWaylandXdgShellV5Integration only
send configure events if they have the primary view.
Also add a convenience, QWaylandView::isPrimary.
Change-Id: Ib3a9615f46c8c43897c7fac22f832d2581190c0a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
10 files changed, 77 insertions, 13 deletions
diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp index 19e17bb32..0129bd33b 100644 --- a/src/compositor/compositor_api/qwaylandoutput.cpp +++ b/src/compositor/compositor_api/qwaylandoutput.cpp @@ -872,7 +872,7 @@ void QWaylandOutput::frameStarted() Q_D(QWaylandOutput); for (int i = 0; i < d->surfaceViews.size(); i++) { QWaylandSurfaceViewMapper &surfacemapper = d->surfaceViews[i]; - if (surfacemapper.maybeThrottelingView()) + if (surfacemapper.maybePrimaryView()) surfacemapper.surface->frameStarted(); } } @@ -890,7 +890,7 @@ void QWaylandOutput::sendFrameCallbacks() surfaceEnter(surfacemapper.surface); d->surfaceViews[i].has_entered = true; } - if (surfacemapper.maybeThrottelingView()) + if (surfacemapper.maybePrimaryView()) surfacemapper.surface->sendFrameCallbacks(); } } diff --git a/src/compositor/compositor_api/qwaylandoutput_p.h b/src/compositor/compositor_api/qwaylandoutput_p.h index ea8e7bcd0..638575db9 100644 --- a/src/compositor/compositor_api/qwaylandoutput_p.h +++ b/src/compositor/compositor_api/qwaylandoutput_p.h @@ -78,10 +78,10 @@ struct QWaylandSurfaceViewMapper , has_entered(false) {} - QWaylandView *maybeThrottelingView() const + QWaylandView *maybePrimaryView() const { for (int i = 0; i < views.size(); i++) { - if (surface && surface->throttlingView() == views.at(i)) + if (surface && surface->primaryView() == views.at(i)) return views.at(i); } return Q_NULLPTR; diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index ff4ac4d66..f0454b72c 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -796,6 +796,23 @@ void QWaylandQuickItem::setAllowDiscardFrontBuffer(bool discard) } /*! + * \qmlmethod QtWaylandCompositor::WaylandQuickItem::setPrimary + * + * Makes this WaylandQuickItem the primary view for the surface. + */ + +/*! + * Makes this QWaylandQuickItem's view the primary view for the surface. + * + * \sa QWaylandSurface::primaryView + */ +void QWaylandQuickItem::setPrimary() +{ + Q_D(QWaylandQuickItem); + d->view->setPrimary(); +} + +/*! * \internal */ void QWaylandQuickItem::handleSurfaceChanged() diff --git a/src/compositor/compositor_api/qwaylandquickitem.h b/src/compositor/compositor_api/qwaylandquickitem.h index 2a226f5d4..821826d69 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.h +++ b/src/compositor/compositor_api/qwaylandquickitem.h @@ -119,6 +119,8 @@ public: bool allowDiscardFrontBuffer() const; void setAllowDiscardFrontBuffer(bool discard); + Q_INVOKABLE void setPrimary(); + protected: void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index 69d182812..80e8715ea 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -690,11 +690,11 @@ void QWaylandSurface::updateSelection() } /*! - * Returns this QWaylandSurface's throttling view. + * Returns this QWaylandSurface's primary view. * - * \sa QWaylandView::advance() + * \sa QWaylandView::advance(), QWaylandSurface::setPrimaryView() */ -QWaylandView *QWaylandSurface::throttlingView() const +QWaylandView *QWaylandSurface::primaryView() const { Q_D(const QWaylandSurface); if (d->views.isEmpty()) @@ -703,15 +703,20 @@ QWaylandView *QWaylandSurface::throttlingView() const } /*! - * Sets this QWaylandSurface's throttling view to \a view, in case there are - * multiple views of this surface. The throttling view is the view that + * Sets this QWaylandSurface's primary view to \a view, in case there are + * multiple views of this surface. The primary view is the view that * governs the client's refresh rate. It takes care of discarding buffer * references when QWaylandView::advance() is called. See the documentation * for QWaylandView::advance() for more details. * + * In shell surface integrations, such as QWaylandWlShellIntegration and + * QWaylandXdgShellV5Integration, maximize and fullscreen requests from the + * client will only have an effect if the integration has the primary view + * of the surface. + * * \sa QWaylandView::advance() */ -void QWaylandSurface::setThrottlingView(QWaylandView *view) +void QWaylandSurface::setPrimaryView(QWaylandView *view) { Q_D(QWaylandSurface); diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h index ed358fefa..40753ad47 100644 --- a/src/compositor/compositor_api/qwaylandsurface.h +++ b/src/compositor/compositor_api/qwaylandsurface.h @@ -124,8 +124,8 @@ public: Q_INVOKABLE void frameStarted(); Q_INVOKABLE void sendFrameCallbacks(); - QWaylandView *throttlingView() const; - void setThrottlingView(QWaylandView *view); + QWaylandView *primaryView() const; + void setPrimaryView(QWaylandView *view); QList<QWaylandView *> views() const; diff --git a/src/compositor/compositor_api/qwaylandview.cpp b/src/compositor/compositor_api/qwaylandview.cpp index f526c647f..2302fe604 100644 --- a/src/compositor/compositor_api/qwaylandview.cpp +++ b/src/compositor/compositor_api/qwaylandview.cpp @@ -232,7 +232,7 @@ bool QWaylandView::advance() if (d->bufferLocked) return false; - if (d->surface && d->surface->throttlingView() == this) { + if (d->surface && d->surface->primaryView() == this) { Q_FOREACH (QWaylandView *view, d->surface->views()) { if (view != this && view->allowDiscardFrontBuffer() && view->d_func()->currentBuffer == d->currentBuffer) view->discardCurrentBuffer(); @@ -346,6 +346,28 @@ void QWaylandView::setAllowDiscardFrontBuffer(bool discard) } /*! + * Makes this QWaylandView the primary view for the surface. + * + * \sa QWaylandSurface::primaryView + */ +void QWaylandView::setPrimary() +{ + Q_D(QWaylandView); + d->surface->setPrimaryView(this); +} + +/*! + * Returns true if this QWaylandView is the primary view for the QWaylandSurface + * + * \sa QWaylandSurface::primaryView + */ +bool QWaylandView::isPrimary() const +{ + Q_D(const QWaylandView); + return d->surface->primaryView() == this; +} + +/*! * Returns the Wayland surface resource for this QWaylandView. */ struct wl_resource *QWaylandView::surfaceResource() const diff --git a/src/compositor/compositor_api/qwaylandview.h b/src/compositor/compositor_api/qwaylandview.h index 44504ec3c..987340034 100644 --- a/src/compositor/compositor_api/qwaylandview.h +++ b/src/compositor/compositor_api/qwaylandview.h @@ -82,6 +82,9 @@ public: bool allowDiscardFrontBuffer() const; void setAllowDiscardFrontBuffer(bool discard); + void setPrimary(); + bool isPrimary() const; + struct wl_resource *surfaceResource() const; Q_SIGNALS: diff --git a/src/compositor/extensions/qwaylandwlshellintegration.cpp b/src/compositor/extensions/qwaylandwlshellintegration.cpp index 5aae77197..30e4704af 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration.cpp +++ b/src/compositor/extensions/qwaylandwlshellintegration.cpp @@ -109,6 +109,9 @@ void WlShellIntegration::handleSetTransient(QWaylandSurface *parentSurface, cons void WlShellIntegration::handleSetMaximized(QWaylandOutput *output) { + if (!m_item->view()->isPrimary()) + return; + if (currentState == State::Maximized) return; @@ -130,6 +133,9 @@ void WlShellIntegration::handleSetFullScreen(QWaylandWlShellSurface::FullScreenM Q_UNUSED(method); Q_UNUSED(framerate); + if (!m_item->view()->isPrimary()) + return; + if (currentState == State::FullScreen) return; @@ -225,6 +231,9 @@ void WlShellIntegration::handleRedraw() void WlShellIntegration::adjustOffsetForNextFrame(const QPointF &offset) { + if (!m_item->view()->isPrimary()) + return; + float scaleFactor = m_item->view()->output()->scaleFactor(); QQuickItem *moveItem = m_item->moveItem(); moveItem->setPosition(moveItem->position() + offset * scaleFactor); diff --git a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp b/src/compositor/extensions/qwaylandxdgshellv5integration.cpp index f15b5c275..b3170333f 100644 --- a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp +++ b/src/compositor/extensions/qwaylandxdgshellv5integration.cpp @@ -140,6 +140,9 @@ void XdgShellV5Integration::handleSetTransient() void XdgShellV5Integration::handleSetMaximized() { + if (!m_item->view()->isPrimary()) + return; + maximizeState.initialWindowSize = m_xdgSurface->windowGeometry().size(); maximizeState.initialPosition = m_item->moveItem()->position(); @@ -149,6 +152,9 @@ void XdgShellV5Integration::handleSetMaximized() void XdgShellV5Integration::handleUnsetMaximized() { + if (!m_item->view()->isPrimary()) + return; + m_xdgSurface->sendUnmaximized(maximizeState.initialWindowSize); } |