summaryrefslogtreecommitdiffstats
path: root/examples/qwindow-compositor
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2012-01-04 10:26:20 +0100
committerJørgen Lind <jorgen.lind@nokia.com>2012-01-04 11:51:06 +0100
commita5ce91c023aeb433f1b5b792291a88c9a5683955 (patch)
tree9b576c2dcf57267ce00e08da7a1bf86e848a1293 /examples/qwindow-compositor
parent1b7f1e42d18574ef610b709272f20b92dc7eda2e (diff)
Remove the geometry from the wayland surface
and add pos and size properties instead. The pos is a PointF while the size is a integer based Size since pos can be transformed, while the size reffers to the pixel size. Change-Id: I5d84aa6661405cb0df356b787246d0d73ad0c503 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'examples/qwindow-compositor')
-rw-r--r--examples/qwindow-compositor/qwindowcompositor.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/examples/qwindow-compositor/qwindowcompositor.cpp b/examples/qwindow-compositor/qwindowcompositor.cpp
index b6ad9ca33..e97bfb6a9 100644
--- a/examples/qwindow-compositor/qwindowcompositor.cpp
+++ b/examples/qwindow-compositor/qwindowcompositor.cpp
@@ -45,12 +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->geometry().size().width() - 2));
- uint py = 1 + (qrand() % (m_window->height() - surface->geometry().size().height() - 2));
+ uint px = 1 + (qrand() % (m_window->width() - surface->size().width() - 2));
+ uint py = 1 + (qrand() % (m_window->height() - surface->size().height() - 2));
pos = QPoint(px, py);
- surface->setGeometry(QRect(pos, surface->geometry().size()));
+ surface->setPos(pos);
} else {
- surface->setGeometry(QRect(window()->geometry().topLeft(),surface->geometry().size()));
+ surface->setPos(window()->geometry().topLeft());
m_surfaces.removeOne(surface);
}
m_surfaces.append(surface);
@@ -81,16 +81,18 @@ void QWindowCompositor::surfaceCreated(WaylandSurface *surface)
QPointF QWindowCompositor::toSurface(WaylandSurface *surface, const QPointF &pos) const
{
- return pos - surface->geometry().topLeft();
+ return pos - surface->pos();
}
WaylandSurface *QWindowCompositor::surfaceAt(const QPoint &point, QPoint *local)
{
for (int i = m_surfaces.size() - 1; i >= 0; --i) {
- if (m_surfaces.at(i)->geometry().contains(point)) {
+ WaylandSurface *surface = m_surfaces.at(i);
+ QRect geo(surface->pos().toPoint(),surface->size());
+ if (geo.contains(point)) {
if (local)
- *local = toSurface(m_surfaces.at(i), point).toPoint();
- return m_surfaces.at(i);
+ *local = toSurface(surface, point).toPoint();
+ return surface;
}
}
return 0;
@@ -124,18 +126,16 @@ void QWindowCompositor::paintChildren(WaylandSurface *surface, WaylandSurface *w
QLinkedListIterator<WaylandSurface *> i(surface->subSurfaces());
while (i.hasNext()) {
WaylandSurface *subSurface = i.next();
- QPoint p = subSurface->mapTo(window,QPoint(0,0));
- QRect geo = subSurface->geometry();
- geo.moveTo(p);
- if (geo.isValid()) {
+ QPointF p = subSurface->mapTo(window,QPointF(0,0));
+ if (subSurface->size().isValid()) {
GLuint texture = 0;
if (subSurface->type() == WaylandSurface::Texture) {
texture = subSurface->texture(QOpenGLContext::currentContext());
} else if (surface->type() == WaylandSurface::Shm ) {
texture = m_textureCache->bindTexture(QOpenGLContext::currentContext(),surface->image());
}
- qDebug() << "window geo is" << window->geometry().size();
- m_textureBlitter->drawTexture(texture,geo,window->geometry().size(),0,window->isYInverted(),subSurface->isYInverted());
+ QRect geo(p.toPoint(),subSurface->size());
+ m_textureBlitter->drawTexture(texture,geo,window->size(),0,window->isYInverted(),subSurface->isYInverted());
}
paintChildren(subSurface,window);
}
@@ -160,7 +160,8 @@ void QWindowCompositor::render()
foreach (WaylandSurface *surface, m_surfaces) {
GLuint texture = composeSurface(surface);
- m_textureBlitter->drawTexture(texture,surface->geometry(),m_window->size(),0,false,surface->isYInverted());
+ QRect geo(surface->pos().toPoint(),surface->size());
+ m_textureBlitter->drawTexture(texture,geo,m_window->size(),0,false,surface->isYInverted());
}
m_textureBlitter->release();
@@ -213,9 +214,7 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event)
case QEvent::MouseMove: {
QMouseEvent *me = static_cast<QMouseEvent *>(event);
if (m_draggingWindow) {
- QRect geo = m_draggingWindow->geometry();
- geo.moveTopLeft(me->pos() - m_drag_diff);
- m_draggingWindow->setGeometry(geo);
+ m_draggingWindow->setPos(me->posF() - m_drag_diff);
m_renderScheduler.start(0);
} else {
QPoint local;