Add an option to qwindow-compositor for disabling random positioning
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Tue, 10 Jan 2012 08:29:38 +0000 (10:29 +0200)
committerJørgen Lind <jorgen.lind@nokia.com>
Tue, 10 Jan 2012 11:35:35 +0000 (12:35 +0100)
When passing -stickytopleft all surfaces will be shown at position 0,0
instead of picking a random one. This is useful for apps with one
single large window in combination with -nofullscreen.

Change-Id: I0834c43981a2d2c7b9796e273ac0eb0cfd738132
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
examples/qwindow-compositor/qwindowcompositor.cpp

index b88dcf5..fd5b24a 100644 (file)
@@ -45,8 +45,12 @@ void QWindowCompositor::surfaceMapped()
     WaylandSurface *surface = qobject_cast<WaylandSurface *>(sender());
     QPoint pos;
     if (!m_surfaces.contains(surface)) {
-        uint px = 1 + (qrand() % (m_window->width() - surface->size().width() - 2));
-        uint py = 1 + (qrand() % (m_window->height() - surface->size().height() - 2));
+        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);
         surface->setPos(pos);
     } else {