diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2012-05-09 11:25:44 +0300 |
---|---|---|
committer | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2012-05-09 14:17:07 +0200 |
commit | 7f71672e27a2cbb7fb19333b77d7b3e4d4a068b9 (patch) | |
tree | 605ccf104302781f2646c416c5317cf583c14950 /examples | |
parent | 9bda431e60b5626b7aeb01dcfa6fcb183ee17258 (diff) |
Start using the new wl_fixed_t type properly
The mouse and touch coordinates cannot just be treated as integers
anymore, they need to be converted from/to double using the helper
functions. Some necessary QPoint -> QPointF changes have also been
made.
For the Qt-specific touch extension we will not switch to wl_fixed_t
though. This is because the precision is unfortunately quite small
(factor of 256 vs. 10000).
Change-Id: I23deaaffe478a39495b12d336985bc62e38a6af4
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/qwindow-compositor/qwindowcompositor.cpp | 26 | ||||
-rw-r--r-- | examples/qwindow-compositor/qwindowcompositor.h | 4 |
2 files changed, 15 insertions, 15 deletions
diff --git a/examples/qwindow-compositor/qwindowcompositor.cpp b/examples/qwindow-compositor/qwindowcompositor.cpp index 6e571ced3..b9661f0ff 100644 --- a/examples/qwindow-compositor/qwindowcompositor.cpp +++ b/examples/qwindow-compositor/qwindowcompositor.cpp @@ -157,14 +157,14 @@ void QWindowCompositor::changeCursor(const QImage &image, int hotspotX, int hots } } -WaylandSurface *QWindowCompositor::surfaceAt(const QPoint &point, QPoint *local) +WaylandSurface *QWindowCompositor::surfaceAt(const QPointF &point, QPointF *local) { for (int i = m_surfaces.size() - 1; i >= 0; --i) { WaylandSurface *surface = m_surfaces.at(i); - QRect geo(surface->pos().toPoint(),surface->size()); + QRectF geo(surface->pos(), surface->size()); if (geo.contains(point)) { if (local) - *local = toSurface(surface, point).toPoint(); + *local = toSurface(surface, point); return surface; } } @@ -259,9 +259,9 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) m_renderScheduler.start(0); break; case QEvent::MouseButtonPress: { - QPoint local; + QPointF local; QMouseEvent *me = static_cast<QMouseEvent *>(event); - WaylandSurface *targetSurface = surfaceAt(me->pos(), &local); + WaylandSurface *targetSurface = surfaceAt(me->localPos(), &local); if (m_dragKeyIsPressed && targetSurface) { m_draggingWindow = targetSurface; m_drag_diff = local; @@ -272,7 +272,7 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) m_surfaces.append(targetSurface); m_renderScheduler.start(0); } - input->sendMousePressEvent(me->button(),local,me->pos()); + input->sendMousePressEvent(me->button(), local, me->localPos()); } return true; } @@ -280,25 +280,25 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) WaylandSurface *targetSurface = input->mouseFocus(); if (m_draggingWindow) { m_draggingWindow = 0; - m_drag_diff = QPoint(); + m_drag_diff = QPointF(); } else { QMouseEvent *me = static_cast<QMouseEvent *>(event); QPointF localPos; if (targetSurface) - localPos = toSurface(targetSurface, me->pos()); - input->sendMouseReleaseEvent(me->button(),localPos.toPoint(),me->pos()); + localPos = toSurface(targetSurface, me->localPos()); + input->sendMouseReleaseEvent(me->button(), localPos, me->localPos()); } return true; } case QEvent::MouseMove: { QMouseEvent *me = static_cast<QMouseEvent *>(event); if (m_draggingWindow) { - m_draggingWindow->setPos(me->posF() - m_drag_diff); + m_draggingWindow->setPos(me->localPos() - m_drag_diff); m_renderScheduler.start(0); } else { - QPoint local; - WaylandSurface *targetSurface = surfaceAt(me->pos(), &local); - input->sendMouseMoveEvent(targetSurface, local,me->pos()); + QPointF local; + WaylandSurface *targetSurface = surfaceAt(me->localPos(), &local); + input->sendMouseMoveEvent(targetSurface, local, me->localPos()); } break; } diff --git a/examples/qwindow-compositor/qwindowcompositor.h b/examples/qwindow-compositor/qwindowcompositor.h index 561b76e52..78bab6999 100644 --- a/examples/qwindow-compositor/qwindowcompositor.h +++ b/examples/qwindow-compositor/qwindowcompositor.h @@ -67,7 +67,7 @@ protected: void surfaceDamaged(WaylandSurface *surface, const QRect &rect); void surfaceCreated(WaylandSurface *surface); - WaylandSurface* surfaceAt(const QPoint &point, QPoint *local = 0); + WaylandSurface* surfaceAt(const QPointF &point, QPointF *local = 0); GLuint composeSurface(WaylandSurface *surface); void paintChildren(WaylandSurface *surface, WaylandSurface *window); @@ -94,7 +94,7 @@ private: //Dragging windows around WaylandSurface *m_draggingWindow; bool m_dragKeyIsPressed; - QPoint m_drag_diff; + QPointF m_drag_diff; }; |