diff options
author | Jørgen Lind <jorgen.lind@theqtcompany.com> | 2015-08-17 11:54:06 +0200 |
---|---|---|
committer | Jørgen Lind <jorgen.lind@theqtcompany.com> | 2015-08-28 13:10:33 +0200 |
commit | 78be8272ff4f4c77b3892d84cbafff9e74b28a81 (patch) | |
tree | 0392d0d5f19fe50d21a6b8e8ab7b432d5f7c7670 /examples | |
parent | e38e7cf94d2c66d0562edaafe8ece708c191cbde (diff) |
In QWaylandWindowCompositor rename m_surfaces to m_visibleSurfaces
And make the compositor work with the updated semantics of
QWaylandSurface
Change-Id: Ic73dda431fe829ead3d822adcae09bc3dc22a6d3
Diffstat (limited to 'examples')
-rw-r--r-- | examples/wayland/qwindow-compositor/qwindowcompositor.cpp | 46 | ||||
-rw-r--r-- | examples/wayland/qwindow-compositor/qwindowcompositor.h | 2 |
2 files changed, 22 insertions, 26 deletions
diff --git a/examples/wayland/qwindow-compositor/qwindowcompositor.cpp b/examples/wayland/qwindow-compositor/qwindowcompositor.cpp index abd76cd3a..999d92865 100644 --- a/examples/wayland/qwindow-compositor/qwindowcompositor.cpp +++ b/examples/wayland/qwindow-compositor/qwindowcompositor.cpp @@ -185,13 +185,12 @@ void QWindowCompositor::ensureKeyboardFocusSurface(QWaylandSurface *oldSurface) { QWaylandSurface *kbdFocus = defaultInputDevice()->keyboardFocus(); if (kbdFocus == oldSurface || !kbdFocus) - defaultInputDevice()->setKeyboardFocus(m_surfaces.isEmpty() ? 0 : m_surfaces.last()); + defaultInputDevice()->setKeyboardFocus(m_visibleSurfaces.isEmpty() ? 0 : m_visibleSurfaces.last()); } void QWindowCompositor::surfaceDestroyed() { QWaylandSurface *surface = static_cast<QWaylandSurface *>(sender()); - m_surfaces.removeOne(surface); ensureKeyboardFocusSurface(surface); m_renderScheduler.start(0); } @@ -206,30 +205,27 @@ void QWindowCompositor::surfaceMappedChanged() } void QWindowCompositor::surfaceMapped(QWaylandSurface *surface) { + Q_ASSERT(!m_visibleSurfaces.contains(surface)); QtWayland::ShellSurface *shellSurface = QtWayland::ShellSurface::findIn(surface); QPoint pos; - if (!m_surfaces.contains(surface)) { - if (!shellSurface || (shellSurface->surfaceType() != QtWayland::ShellSurface::Popup)) { - uint px = 0; - uint py = 0; - if (!QCoreApplication::arguments().contains(QLatin1String("-stickytopleft"))) { - px = 1 + (qrand() % (m_window->width() - surface->size().width() - 2)); - py = 1 + (qrand() % (m_window->height() - surface->size().height() - 2)); - } - pos = QPoint(px, py); - QWaylandView *view = surface->views().first(); - view->setRequestedPosition(pos); + if (!shellSurface || (shellSurface->surfaceType() != QtWayland::ShellSurface::Popup)) { + uint px = 0; + uint py = 0; + if (!QCoreApplication::arguments().contains(QLatin1String("-stickytopleft"))) { + px = 1 + (qrand() % (m_window->width() - surface->size().width() - 2)); + py = 1 + (qrand() % (m_window->height() - surface->size().height() - 2)); } - } else { - m_surfaces.removeOne(surface); + pos = QPoint(px, py); + QWaylandView *view = surface->views().first(); + view->setRequestedPosition(pos); } - if (shellSurface && shellSurface->surfaceType() == QtWayland::ShellSurface::Popup) { - QWaylandView *view = surface->views().first(); + QWaylandView *view = shellSurface->view(); view->setRequestedPosition(shellSurface->transientParent()->views().first()->pos() + shellSurface->transientOffset()); } - m_surfaces.append(surface); + m_visibleSurfaces.append(surface); + if (!surface->isCursorSurface()) defaultInputDevice()->setKeyboardFocus(surface); @@ -238,7 +234,7 @@ void QWindowCompositor::surfaceMapped(QWaylandSurface *surface) void QWindowCompositor::surfaceUnmapped(QWaylandSurface *surface) { - m_surfaces.removeOne(surface); + m_visibleSurfaces.removeOne(surface); ensureKeyboardFocusSurface(surface); m_renderScheduler.start(0); @@ -330,8 +326,8 @@ QWaylandSurface *QWindowCompositor::createSurface(QWaylandClient *client, quint3 QWaylandView *QWindowCompositor::viewAt(const QPointF &point, QPointF *local) { - for (int i = m_surfaces.size() - 1; i >= 0; --i) { - QWaylandSurface *surface = m_surfaces.at(i); + for (int i = m_visibleSurfaces.size() - 1; i >= 0; --i) { + QWaylandSurface *surface = m_visibleSurfaces.at(i); foreach (QWaylandView *view, surface->views()) { QRectF geo(view->pos(), surface->size()); if (geo.contains(point)) { @@ -361,7 +357,7 @@ void QWindowCompositor::render() m_window->size(), 0, false, true); - foreach (QWaylandSurface *surface, m_surfaces) { + foreach (QWaylandSurface *surface, m_visibleSurfaces) { if (!surface->isMapped()) continue; drawSubSurface(QPoint(), surface); @@ -388,7 +384,7 @@ void QWindowCompositor::drawSubSurface(const QPoint &offset, QWaylandSurface *s) surface->hasSentOnScreen = onscreen; } - if (onscreen) { + if (surface->isMapped() && onscreen) { m_textureBlitter->drawTexture(texture, geo, m_window->size(), 0, false, invert_y); QtWayland::SubSurface *subSurface = QtWayland::SubSurface::findIn(surface); @@ -436,8 +432,8 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) } else { if (target && input->keyboardFocus() != target->surface()) { input->setKeyboardFocus(target->surface()); - m_surfaces.removeOne(target->surface()); - m_surfaces.append(target->surface()); + m_visibleSurfaces.removeOne(target->surface()); + m_visibleSurfaces.append(target->surface()); m_renderScheduler.start(0); } input->sendMousePressEvent(me->button()); diff --git a/examples/wayland/qwindow-compositor/qwindowcompositor.h b/examples/wayland/qwindow-compositor/qwindowcompositor.h index b08c8a628..9ce6e0c8c 100644 --- a/examples/wayland/qwindow-compositor/qwindowcompositor.h +++ b/examples/wayland/qwindow-compositor/qwindowcompositor.h @@ -105,7 +105,7 @@ private: CompositorWindow *m_window; QImage m_backgroundImage; QOpenGLTexture *m_backgroundTexture; - QList<QWaylandSurface *> m_surfaces; + QList<QWaylandSurface *> m_visibleSurfaces; TextureBlitter *m_textureBlitter; GLuint m_surface_fbo; QTimer m_renderScheduler; |