diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2012-01-11 09:35:39 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2012-01-11 11:07:24 +0100 |
commit | 8894f58e01b51e9b2072973edbe043ebe62858b4 (patch) | |
tree | 1a449793f14256d228b0ea0251e289a9013f13de /examples/qwindow-compositor | |
parent | bf850bd6ea971a44a0af8e6940edb3ba419da962 (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/qwindow-compositor')
-rw-r--r-- | examples/qwindow-compositor/qwindowcompositor.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/examples/qwindow-compositor/qwindowcompositor.cpp b/examples/qwindow-compositor/qwindowcompositor.cpp index c858e5729..eff7541cd 100644 --- a/examples/qwindow-compositor/qwindowcompositor.cpp +++ b/examples/qwindow-compositor/qwindowcompositor.cpp @@ -3,6 +3,8 @@ #include <QKeyEvent> #include <QTouchEvent> +#include <QtCompositor/waylandinput.h> + QWindowCompositor::QWindowCompositor(QOpenGLWindow *window) : WaylandCompositor(window) , m_window(window) @@ -35,8 +37,8 @@ void QWindowCompositor::surfaceDestroyed(QObject *object) { WaylandSurface *surface = static_cast<WaylandSurface *>(object); m_surfaces.removeOne(surface); - if (inputFocus() == surface || !inputFocus()) // typically reset to 0 already in Compositor::surfaceDestroyed() - setInputFocus(m_surfaces.isEmpty() ? 0 : m_surfaces.last()); + if (defaultInputDevice()->keyboardFocus() == surface || !defaultInputDevice()->keyboardFocus()) // typically reset to 0 already in Compositor::surfaceDestroyed() + defaultInputDevice()->setKeyboardFocus(m_surfaces.isEmpty() ? 0 : m_surfaces.last()); m_renderScheduler.start(0); } @@ -58,7 +60,7 @@ void QWindowCompositor::surfaceMapped() m_surfaces.removeOne(surface); } m_surfaces.append(surface); - setInputFocus(surface); + defaultInputDevice()->setKeyboardFocus(surface); m_renderScheduler.start(0); } @@ -193,6 +195,8 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) if (obj != m_window) return false; + WaylandInputDevice *input = defaultInputDevice(); + switch (event->type()) { case QEvent::Expose: m_renderScheduler.start(0); @@ -206,25 +210,25 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) m_draggingWindow = targetSurface; m_drag_diff = local; } else { - if (inputFocus() != targetSurface) { - setInputFocus(targetSurface); + if (input->keyboardFocus() != targetSurface) { + input->setKeyboardFocus(targetSurface); m_surfaces.removeOne(targetSurface); m_surfaces.append(targetSurface); m_renderScheduler.start(0); } - targetSurface->sendMousePressEvent(local, me->button()); + input->sendMousePressEvent(me->button(),local,me->pos()); } } break; } case QEvent::MouseButtonRelease: { - WaylandSurface *targetSurface = inputFocus(); + WaylandSurface *targetSurface = input->mouseFocus(); if (m_draggingWindow) { m_draggingWindow = 0; m_drag_diff = QPoint(); } else if (targetSurface) { QMouseEvent *me = static_cast<QMouseEvent *>(event); - targetSurface->sendMouseReleaseEvent(toSurface(targetSurface, me->pos()).toPoint(), me->button()); + input->sendMouseReleaseEvent(me->button(),toSurface(targetSurface, me->pos()).toPoint(),me->pos()); } break; } @@ -236,10 +240,7 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) } else { QPoint local; WaylandSurface *targetSurface = surfaceAt(me->pos(), &local); - setMouseFocus(targetSurface); - if (targetSurface) { - targetSurface->sendMouseMoveEvent(local); - } + input->sendMouseMoveEvent(targetSurface, local,me->pos()); } break; } @@ -248,9 +249,9 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) if (ke->key() == Qt::Key_Meta || ke->key() == Qt::Key_Super_L) { m_dragKeyIsPressed = true; } - WaylandSurface *targetSurface = inputFocus(); + WaylandSurface *targetSurface = input->keyboardFocus(); if (targetSurface) - targetSurface->sendKeyPressEvent(ke->nativeScanCode()); + input->sendKeyPressEvent(ke->nativeScanCode()); break; } case QEvent::KeyRelease: { @@ -258,9 +259,9 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) if (ke->key() == Qt::Key_Meta || ke->key() == Qt::Key_Super_L) { m_dragKeyIsPressed = false; } - WaylandSurface *targetSurface = inputFocus(); + WaylandSurface *targetSurface = input->keyboardFocus(); if (targetSurface) - targetSurface->sendKeyReleaseEvent(ke->nativeScanCode()); + input->sendKeyReleaseEvent(ke->nativeScanCode()); break; } case QEvent::TouchBegin: @@ -277,7 +278,7 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) targets.insert(targetSurface); } foreach (WaylandSurface *surface, targets) - surface->sendFullTouchEvent(te); + input->sendFullTouchEvent(te); break; } default: |