2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2014-09-02 16:46:07 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2014 Fredrik Höglund <fredrik@kde.org>
|
2014-09-02 16:46:07 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2014-09-02 16:46:07 +00:00
|
|
|
|
|
|
|
#include "x11eventfilter.h"
|
2021-01-31 12:12:02 +00:00
|
|
|
#include "main.h"
|
2014-09-02 16:46:07 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2016-11-15 07:22:41 +00:00
|
|
|
X11EventFilter::X11EventFilter(const QVector<int> &eventTypes)
|
|
|
|
: m_eventTypes(eventTypes)
|
|
|
|
, m_extension(0)
|
|
|
|
{
|
2021-01-31 12:12:02 +00:00
|
|
|
kwinApp()->registerEventFilter(this);
|
2016-11-15 07:22:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-02 16:46:07 +00:00
|
|
|
X11EventFilter::X11EventFilter(int eventType, int opcode, int genericEventType)
|
2016-08-11 10:55:25 +00:00
|
|
|
: X11EventFilter(eventType, opcode, QVector<int>{genericEventType})
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
X11EventFilter::X11EventFilter(int eventType, int opcode, const QVector< int > &genericEventTypes)
|
2016-11-15 07:22:41 +00:00
|
|
|
: m_eventTypes(QVector<int>{eventType}), m_extension(opcode), m_genericEventTypes(genericEventTypes)
|
2014-09-02 16:46:07 +00:00
|
|
|
{
|
2021-01-31 12:12:02 +00:00
|
|
|
kwinApp()->registerEventFilter(this);
|
2014-09-02 16:46:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
X11EventFilter::~X11EventFilter()
|
|
|
|
{
|
2021-01-31 12:12:02 +00:00
|
|
|
if (kwinApp()) {
|
|
|
|
kwinApp()->unregisterEventFilter(this);
|
2014-11-25 11:57:37 +00:00
|
|
|
}
|
2014-09-02 16:46:07 +00:00
|
|
|
}
|
|
|
|
|
2016-11-15 07:22:41 +00:00
|
|
|
bool X11EventFilter::isGenericEvent() const
|
|
|
|
{
|
|
|
|
if (m_eventTypes.count() != 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return m_eventTypes.first() == XCB_GE_GENERIC;
|
|
|
|
}
|
|
|
|
|
2014-09-02 16:46:07 +00:00
|
|
|
}
|