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.
This commit is contained in:
parent
63b96d7c0d
commit
1f39c45a10
2 changed files with 32 additions and 0 deletions
|
@ -8,8 +8,11 @@
|
||||||
#include "abstract_client.h"
|
#include "abstract_client.h"
|
||||||
#include "deleted.h"
|
#include "deleted.h"
|
||||||
#include "internal_client.h"
|
#include "internal_client.h"
|
||||||
|
#include "wayland_server.h"
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
|
|
||||||
|
#include <KWaylandServer/keyboard_interface.h>
|
||||||
|
#include <KWaylandServer/seat_interface.h>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
|
@ -65,6 +68,34 @@ bool PopupInputFilter::pointerEvent(QMouseEvent *event, quint32 nativeButton)
|
||||||
return false;
|
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()
|
void PopupInputFilter::cancelPopups()
|
||||||
{
|
{
|
||||||
while (!m_popupClients.isEmpty()) {
|
while (!m_popupClients.isEmpty()) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ class PopupInputFilter : public QObject, public InputEventFilter
|
||||||
public:
|
public:
|
||||||
explicit PopupInputFilter();
|
explicit PopupInputFilter();
|
||||||
bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override;
|
bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override;
|
||||||
|
bool keyEvent(QKeyEvent *event) override;
|
||||||
private:
|
private:
|
||||||
void handleClientAdded(Toplevel *client);
|
void handleClientAdded(Toplevel *client);
|
||||||
void handleClientRemoved(Toplevel *client);
|
void handleClientRemoved(Toplevel *client);
|
||||||
|
|
Loading…
Reference in a new issue