Better handling for forwarding key events to Wayland Server

A new protected method is added to InputEventFilter to forward a
QKeyEvent to the Wayland server. Several input filters need to forward
the event to have a proper state of the events. E.g. the TabBox filter,
but also the internal window filter and effects filter. It's important
to update all events even if the events are not forwarded to a surface.

This new method takes care of the general handling like ignoring key
repeats, etc.

Reviewed-By: bshah
icc-effect-5.14.5
Martin Gräßlin 2016-09-15 08:47:01 +02:00
parent c70df62ce5
commit 8fdcc24b05
2 changed files with 25 additions and 20 deletions

View File

@ -160,6 +160,24 @@ bool InputEventFilter::swipeGestureCancelled(quint32 time)
return false;
}
void InputEventFilter::passToWaylandServer(QKeyEvent *event)
{
Q_ASSERT(waylandServer());
if (event->isAutoRepeat()) {
return;
}
switch (event->type()) {
case QEvent::KeyPress:
waylandServer()->seat()->keyPressed(event->nativeScanCode());
break;
case QEvent::KeyRelease:
waylandServer()->seat()->keyReleased(event->nativeScanCode());
break;
default:
break;
}
}
#if HAVE_INPUT
class VirtualTerminalFilter : public InputEventFilter {
public:
@ -341,6 +359,7 @@ public:
return false;
}
waylandServer()->seat()->setFocusedKeyboardSurface(nullptr);
passToWaylandServer(event);
static_cast< EffectsHandlerImpl* >(effects)->grabbedKeyboardEvent(event);
return true;
}
@ -511,6 +530,7 @@ class InternalWindowEventFilter : public InputEventFilter {
event->setAccepted(false);
if (QCoreApplication::sendEvent(found, event)) {
waylandServer()->seat()->setFocusedKeyboardSurface(nullptr);
passToWaylandServer(event);
return true;
}
return false;
@ -748,16 +768,7 @@ public:
seat->setFocusedKeyboardSurface(nullptr);
// pass the key event to the seat, so that it has a proper model of the currently hold keys
// this is important for combinations like alt+shift to ensure that shift is not considered pressed
switch (event->type()) {
case QEvent::KeyPress:
seat->keyPressed(event->nativeScanCode());
break;
case QEvent::KeyRelease:
seat->keyReleased(event->nativeScanCode());
break;
default:
break;
}
passToWaylandServer(event);
if (event->type() == QEvent::KeyPress) {
TabBox::TabBox::self()->keyPress(event->modifiers() | event->key());
@ -920,16 +931,7 @@ public:
auto seat = waylandServer()->seat();
input()->keyboard()->update();
seat->setTimestamp(event->timestamp());
switch (event->type()) {
case QEvent::KeyPress:
seat->keyPressed(event->nativeScanCode());
break;
case QEvent::KeyRelease:
seat->keyReleased(event->nativeScanCode());
break;
default:
break;
}
passToWaylandServer(event);
return true;
}
bool touchDown(quint32 id, const QPointF &pos, quint32 time) override {

View File

@ -298,6 +298,9 @@ public:
virtual bool swipeGestureUpdate(const QSizeF &delta, quint32 time);
virtual bool swipeGestureEnd(quint32 time);
virtual bool swipeGestureCancelled(quint32 time);
protected:
void passToWaylandServer(QKeyEvent *event);
};
class InputDeviceHandler : public QObject