summaryrefslogtreecommitdiffstats
path: root/examples/wayland/minimal-cpp/window.cpp
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2018-03-01 15:12:02 +0100
committerPaul Olav Tvete <paul.tvete@qt.io>2018-03-21 11:36:00 +0000
commitd29cbc2a0604f1b9a35f480a63a2472ca9e54661 (patch)
tree6469dc2d16802345b6ac733130bbdba73726ec29 /examples/wayland/minimal-cpp/window.cpp
parent942958a870dd01ebe1f4b03b70d7dda1ed9f67ab (diff)
Make the minimal-cpp example a real compositor
Use the ivi-application protocol, since a compositor without a shell is not really a proper compositor. Use the IVI id to determine the position instead of generating a random position for each frame. Change-Id: I2ede824c656e4c2ef88117cf0f0b8d27ad80b6e2 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Diffstat (limited to 'examples/wayland/minimal-cpp/window.cpp')
-rw-r--r--examples/wayland/minimal-cpp/window.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/examples/wayland/minimal-cpp/window.cpp b/examples/wayland/minimal-cpp/window.cpp
index b84806472..c43255dfc 100644
--- a/examples/wayland/minimal-cpp/window.cpp
+++ b/examples/wayland/minimal-cpp/window.cpp
@@ -70,11 +70,12 @@ void Window::initializeGL()
m_textureBlitter.create();
}
-static int sillyrandom(int range)
+static QPoint sillyrandom(int seed, QSize screenSize, QSize surfaceSize)
{
- if (range <= 0)
- range = 200;
- return QRandomGenerator::global()->bounded(range);
+ QRandomGenerator rand(seed);
+ int xrange = qMax(screenSize.width() - surfaceSize.width(), 200);
+ int yrange = qMax(screenSize.height() - surfaceSize.height(), 200);
+ return QPoint(rand.bounded(xrange), rand.bounded(yrange));
}
void Window::paintGL()
@@ -91,8 +92,6 @@ void Window::paintGL()
functions->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Q_FOREACH (View *view, m_compositor->views()) {
- if (view->isCursor())
- continue;
auto texture = view->getTexture();
if (!texture)
continue;
@@ -104,7 +103,7 @@ void Window::paintGL()
QWaylandSurface *surface = view->surface();
if (surface && surface->hasContent()) {
QSize s = surface->size();
- QPointF pos(sillyrandom(width() - s.width()), sillyrandom(height() - s.height()));
+ QPointF pos = sillyrandom(view->iviId(), size(), s);
QRectF surfaceGeometry(pos, s);
QOpenGLTextureBlitter::Origin surfaceOrigin =
view->currentBuffer().origin() == QWaylandSurface::OriginTopLeft