Fix mouse input in WaylandSurfaceItem.
authorPier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Sun, 26 Aug 2012 19:55:37 +0000 (21:55 +0200)
committerJørgen Lind <jorgen.lind@nokia.com>
Mon, 27 Aug 2012 12:30:39 +0000 (14:30 +0200)
Mouse input is fixed by passing global coordinates to the mouse
events, now windows can be moved by a QML-based compositor.
Also, all the mouse buttons are accepted.

Change-Id: Ib4cdca047ffffcc2a89a23847c813d34387ca591
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
src/compositor/compositor_api/waylandsurfaceitem.cpp

index 6a6d8c6..f081e46 100644 (file)
@@ -132,7 +132,11 @@ void WaylandSurfaceItem::init(WaylandSurface *surface)
 
     setSmooth(true);
     setFlag(ItemHasContents);
-    setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton);
+    setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton |
+        Qt::ExtraButton1 | Qt::ExtraButton2 | Qt::ExtraButton3 | Qt::ExtraButton4 |
+        Qt::ExtraButton5 | Qt::ExtraButton6 | Qt::ExtraButton7 | Qt::ExtraButton8 |
+        Qt::ExtraButton9 | Qt::ExtraButton10 | Qt::ExtraButton11 |
+        Qt::ExtraButton12 | Qt::ExtraButton13);
     setAcceptHoverEvents(true);
     connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped()));
     connect(surface, SIGNAL(unmapped()), this, SLOT(surfaceUnmapped()));
@@ -192,7 +196,7 @@ void WaylandSurfaceItem::mousePressEvent(QMouseEvent *event)
         WaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice();
         if (inputDevice->mouseFocus() != m_surface)
             inputDevice->setMouseFocus(m_surface, event->pos(), event->globalPos());
-        inputDevice->sendMousePressEvent(event->button(), toSurface(event->pos()));
+        inputDevice->sendMousePressEvent(event->button(), toSurface(event->pos()), event->globalPos());
     }
 }
 
@@ -200,7 +204,7 @@ void WaylandSurfaceItem::mouseMoveEvent(QMouseEvent *event)
 {
     if (m_surface){
         WaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice();
-        inputDevice->sendMouseMoveEvent(m_surface, toSurface(event->pos()));
+        inputDevice->sendMouseMoveEvent(m_surface, toSurface(event->pos()), event->globalPos());
     }
 }
 
@@ -208,7 +212,7 @@ void WaylandSurfaceItem::mouseReleaseEvent(QMouseEvent *event)
 {
     if (m_surface){
         WaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice();
-        inputDevice->sendMouseReleaseEvent(event->button(), toSurface(event->pos()));
+        inputDevice->sendMouseReleaseEvent(event->button(), toSurface(event->pos()), event->globalPos());
     }
 }