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
|
|
|
|
|
|
|
#ifndef X11EVENTFILTER_H
|
|
|
|
#define X11EVENTFILTER_H
|
|
|
|
|
|
|
|
#include <xcb/xcb.h>
|
|
|
|
|
2016-08-11 10:55:25 +00:00
|
|
|
#include <QVector>
|
|
|
|
|
2016-04-08 08:32:37 +00:00
|
|
|
#include <kwin_export.h>
|
|
|
|
|
2014-09-02 16:46:07 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2016-04-08 08:32:37 +00:00
|
|
|
class KWIN_EXPORT X11EventFilter
|
2014-09-02 16:46:07 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Creates an event filter for the given event type.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2014-09-02 16:46:07 +00:00
|
|
|
X11EventFilter(int eventType, int opcode = 0, int genericEventType = 0);
|
2016-08-11 10:55:25 +00:00
|
|
|
X11EventFilter(int eventType, int opcode, const QVector<int> &genericEventTypes);
|
2016-11-15 07:22:41 +00:00
|
|
|
X11EventFilter(const QVector<int> &eventTypes);
|
2014-09-02 16:46:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys the event filter.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2014-09-02 16:46:07 +00:00
|
|
|
virtual ~X11EventFilter();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the type of events to filter.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-11-15 07:22:41 +00:00
|
|
|
QVector<int> eventTypes() const { return m_eventTypes; }
|
2014-09-02 16:46:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the major opcode of the extension.
|
|
|
|
*
|
|
|
|
* Only used when the event type is XCB_GE_GENERIC.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2014-09-02 16:46:07 +00:00
|
|
|
int extension() const { return m_extension; }
|
|
|
|
|
|
|
|
/**
|
2016-08-11 10:55:25 +00:00
|
|
|
* Returns the types of generic events to filter.
|
2014-09-02 16:46:07 +00:00
|
|
|
*
|
|
|
|
* Only used when the event type is XCB_GE_GENERIC.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-08-11 10:55:25 +00:00
|
|
|
QVector<int> genericEventTypes() const { return m_genericEventTypes; }
|
2014-09-02 16:46:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is called for every event of the filtered type.
|
|
|
|
*
|
|
|
|
* Return true to accept the event and stop further processing, and false otherwise.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2014-09-02 16:46:07 +00:00
|
|
|
virtual bool event(xcb_generic_event_t *event) = 0;
|
|
|
|
|
2016-11-15 07:22:41 +00:00
|
|
|
/**
|
|
|
|
* Whether the event filter is for XCB_GE_GENERIC events.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-11-15 07:22:41 +00:00
|
|
|
bool isGenericEvent() const;
|
|
|
|
|
2014-09-02 16:46:07 +00:00
|
|
|
private:
|
2016-11-15 07:22:41 +00:00
|
|
|
QVector<int> m_eventTypes;
|
2014-09-02 16:46:07 +00:00
|
|
|
int m_extension;
|
2016-08-11 10:55:25 +00:00
|
|
|
QVector<int> m_genericEventTypes;
|
2014-09-02 16:46:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace KWin
|
|
|
|
|
|
|
|
#endif
|