Skip to content

Commit

Permalink
Fix mouse input in WaylandSurfaceItem.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
plfiorini authored and Jørgen Lind committed Aug 27, 2012
1 parent ec187fe commit c5df6af
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/compositor/compositor_api/waylandsurfaceitem.cpp
Expand Up @@ -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()));
Expand Down Expand Up @@ -192,23 +196,23 @@ 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());
}
}

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());
}
}

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());
}
}

Expand Down

0 comments on commit c5df6af

Please sign in to comment.