summaryrefslogtreecommitdiffstats
path: root/examples/qwidget-compositor
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2012-01-11 09:35:39 +0100
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-01-11 11:07:24 +0100
commit8894f58e01b51e9b2072973edbe043ebe62858b4 (patch)
tree1a449793f14256d228b0ea0251e289a9013f13de /examples/qwidget-compositor
parentbf850bd6ea971a44a0af8e6940edb3ba419da962 (diff)
Move event handling into WaylandInput api
Qt only gives us 1 input device as of now, ie. the mouse/keyboard and touch events. However, at some point in the future, this will change, so that the events will have a device id. This will ie on x map to the same device, but on evdev this can be different devices. Also this is part of what is needed to implement grabbing Change-Id: Ice049502d6f0f53fd06142d4dedde05806d60120 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
Diffstat (limited to 'examples/qwidget-compositor')
-rw-r--r--examples/qwidget-compositor/main.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/examples/qwidget-compositor/main.cpp b/examples/qwidget-compositor/main.cpp
index b123b8444..89fcad02f 100644
--- a/examples/qwidget-compositor/main.cpp
+++ b/examples/qwidget-compositor/main.cpp
@@ -41,6 +41,7 @@
#include "waylandcompositor.h"
#include "waylandsurface.h"
+#include <QtCompositor/waylandinput.h>
#include <QApplication>
#include <QWidget>
@@ -103,7 +104,7 @@ private slots:
m_surfaces.append(surface);
}
- setInputFocus(surface);
+ defaultInputDevice()->setKeyboardFocus(surface);
update();
}
@@ -256,7 +257,7 @@ protected:
}
void raise(WaylandSurface *surface) {
- setInputFocus(surface);
+ defaultInputDevice()->setKeyboardFocus(surface);
surfaceDamaged(surface, QRect(QPoint(), surface->size()));
m_surfaces.removeOne(surface);
m_surfaces.append(surface);
@@ -273,7 +274,7 @@ protected:
m_moveSurface = surface;
m_moveOffset = local;
} else {
- surface->sendMousePressEvent(local.toPoint(), e->button());
+ defaultInputDevice()->sendMousePressEvent(e->button(), local.toPoint(),e->pos());
}
}
}
@@ -293,6 +294,7 @@ protected:
m_lastDragSourcePos = local;
raise(surface);
}
+ //this should go away when draggin is reimplemented
sendDragMoveEvent(global, local.toPoint(), surface);
return;
}
@@ -303,7 +305,7 @@ protected:
}
QPointF local;
if (WaylandSurface *surface = surfaceAt(e->pos(), &local))
- surface->sendMouseMoveEvent(local.toPoint());
+ defaultInputDevice()->sendMouseMoveEvent(local.toPoint(),pos());
}
void mouseReleaseEvent(QMouseEvent *e) {
@@ -311,7 +313,8 @@ protected:
sendDragEndEvent();
if (m_dragSourceSurface) {
// Must send a release event to the source too, no matter where the cursor is now.
- m_dragSourceSurface->sendMouseReleaseEvent(m_lastDragSourcePos.toPoint(), e->button());
+ // This is a hack and should go away when we reimplement draging
+ defaultInputDevice()->sendMouseReleaseEvent(e->button(), m_lastDragSourcePos.toPoint(), e->pos());
m_dragSourceSurface = 0;
}
}
@@ -321,21 +324,17 @@ protected:
}
QPointF local;
if (WaylandSurface *surface = surfaceAt(e->pos(), &local))
- surface->sendMouseReleaseEvent(local.toPoint(), e->button());
+ defaultInputDevice()->sendMouseReleaseEvent(e->button(), local.toPoint(), e->pos());
}
void keyPressEvent(QKeyEvent *event)
{
- if (m_surfaces.isEmpty())
- return;
- m_surfaces.last()->sendKeyPressEvent(event->nativeScanCode());
+ defaultInputDevice()->sendKeyPressEvent(event->nativeScanCode());
}
void keyReleaseEvent(QKeyEvent *event)
{
- if (m_surfaces.isEmpty())
- return;
- m_surfaces.last()->sendKeyReleaseEvent(event->nativeScanCode());
+ defaultInputDevice()->sendKeyReleaseEvent(event->nativeScanCode());
}
WaylandSurface *surfaceAt(const QPointF &point, QPointF *local = 0) {