Also forward key to input method for popup surface.
Popup may also want to use input method. If there is a keygrab, it also need to forward input method instead of directly passing to wayland server.
This commit is contained in:
parent
9f44013fb5
commit
cfa463c0ef
3 changed files with 24 additions and 23 deletions
|
@ -274,6 +274,25 @@ void InputEventFilter::passToWaylandServer(QKeyEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
bool InputEventFilter::passToInputMethod(QKeyEvent *event)
|
||||
{
|
||||
auto *inputmethod = InputMethod::self();
|
||||
|
||||
if (!inputmethod) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto keyboardGrab = inputmethod->keyboardGrab()) {
|
||||
if (event->isAutoRepeat()) {
|
||||
return true;
|
||||
}
|
||||
auto newState = event->type() == QEvent::KeyPress ? KWaylandServer::KeyboardKeyState::Pressed : KWaylandServer::KeyboardKeyState::Released;
|
||||
keyboardGrab->sendKey(waylandServer()->display()->nextSerial(), event->timestamp(), event->nativeScanCode(), newState);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
class VirtualTerminalFilter : public InputEventFilter {
|
||||
public:
|
||||
bool keyEvent(QKeyEvent *event) override {
|
||||
|
@ -1494,20 +1513,7 @@ class InputKeyboardFilter : public InputEventFilter
|
|||
public:
|
||||
bool keyEvent(QKeyEvent *event) override
|
||||
{
|
||||
auto *inputmethod = InputMethod::self();
|
||||
if (!inputmethod) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto keyboardGrab = inputmethod->keyboardGrab()) {
|
||||
if (event->isAutoRepeat()) {
|
||||
return true;
|
||||
}
|
||||
auto newState = event->type() == QEvent::KeyPress ? KWaylandServer::KeyboardKeyState::Pressed : KWaylandServer::KeyboardKeyState::Released;
|
||||
keyboardGrab->sendKey(waylandServer()->display()->nextSerial(), event->timestamp(), event->nativeScanCode(), newState);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return passToInputMethod(event);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -404,6 +404,7 @@ public:
|
|||
|
||||
protected:
|
||||
void passToWaylandServer(QKeyEvent *event);
|
||||
bool passToInputMethod(QKeyEvent *event);
|
||||
};
|
||||
|
||||
class KWIN_EXPORT InputDeviceHandler : public QObject
|
||||
|
|
|
@ -81,15 +81,9 @@ bool PopupInputFilter::keyEvent(QKeyEvent *event)
|
|||
}
|
||||
|
||||
seat->setFocusedKeyboardSurface(last->surface());
|
||||
switch (event->type()) {
|
||||
case QEvent::KeyPress:
|
||||
seat->notifyKeyboardKey(event->nativeScanCode(), KWaylandServer::KeyboardKeyState::Pressed);
|
||||
break;
|
||||
case QEvent::KeyRelease:
|
||||
seat->notifyKeyboardKey(event->nativeScanCode(), KWaylandServer::KeyboardKeyState::Released);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
if (!passToInputMethod(event)) {
|
||||
passToWaylandServer(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue