Implement a TerminateServerFilter to handle XKB_KEY_Terminate_Server

On special request by sebas. It's not really dangerous as by default
the xkb layout doesn't have it enabled. So if a user actually enables
it, we can also support it.

And now I'm going to reconfigure my layout again to not hit it by chance.

Reviewed-By: sebas
This commit is contained in:
Martin Gräßlin 2016-03-10 20:30:49 +01:00
parent d8a3e0525f
commit 16301aa4cf

View file

@ -123,6 +123,20 @@ public:
}; };
#endif #endif
class TerminateServerFilter : public InputEventFilter {
public:
bool keyEvent(QKeyEvent *event) override {
if (event->type() == QEvent::KeyPress && !event->isAutoRepeat()) {
if (event->nativeVirtualKey() == XKB_KEY_Terminate_Server) {
qCWarning(KWIN_CORE) << "Request to terminate server";
QMetaObject::invokeMethod(qApp, "quit", Qt::QueuedConnection);
return true;
}
}
return false;
}
};
class LockScreenFilter : public InputEventFilter { class LockScreenFilter : public InputEventFilter {
public: public:
bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override {
@ -866,6 +880,7 @@ void InputRedirection::setupInputFilters()
} }
#endif #endif
if (waylandServer()) { if (waylandServer()) {
installInputEventFilter(new TerminateServerFilter);
installInputEventFilter(new DragAndDropInputFilter); installInputEventFilter(new DragAndDropInputFilter);
installInputEventFilter(new LockScreenFilter); installInputEventFilter(new LockScreenFilter);
} }