Commit 1f39c45a authored by Janet Blackquill's avatar Janet Blackquill 🌈
Browse files

PopupEventFilter: handle keyboard events too

XDG popups want keyboard events routed to the topmost popup
as well as the pointer-outside-of-popup-cancels functionality.
parent 63b96d7c
......@@ -8,8 +8,11 @@
#include "abstract_client.h"
#include "deleted.h"
#include "internal_client.h"
#include "wayland_server.h"
#include "workspace.h"
#include <KWaylandServer/keyboard_interface.h>
#include <KWaylandServer/seat_interface.h>
#include <QMouseEvent>
namespace KWin
......@@ -65,6 +68,34 @@ bool PopupInputFilter::pointerEvent(QMouseEvent *event, quint32 nativeButton)
return false;
}
bool PopupInputFilter::keyEvent(QKeyEvent *event)
{
if (m_popupClients.isEmpty()) {
return false;
}
auto seat = waylandServer()->seat();
auto last = m_popupClients.last();
if (last->surface() == nullptr) {
return false;
}
seat->setFocusedKeyboardSurface(last->surface());
switch (event->type()) {
case QEvent::KeyPress:
seat->keyboard()->keyPressed(event->nativeScanCode());
break;
case QEvent::KeyRelease:
seat->keyboard()->keyReleased(event->nativeScanCode());
break;
default:
break;
}
return true;
}
void PopupInputFilter::cancelPopups()
{
while (!m_popupClients.isEmpty()) {
......
......@@ -22,6 +22,7 @@ class PopupInputFilter : public QObject, public InputEventFilter
public:
explicit PopupInputFilter();
bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override;
bool keyEvent(QKeyEvent *event) override;
private:
void handleClientAdded(Toplevel *client);
void handleClientRemoved(Toplevel *client);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment