Select also raw button press/release in XInput2 based polling

Summary:
The mouse polling is also used to detect mouse button press/release
events. This is used e.g. by the MouseClickEffect. The XInput2 filter
only selected for Raw Motion events which means mouse button events
are missed in case it's not combined with a motion.

This change makes the input filter also select for raw button press
and release events. To support this the X11EventFilter needed to
be adjusted to support multiple generic event types to filter for.

BUG: 366612
FIXED-IN: 5.7.4

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D2406
This commit is contained in:
Martin Gräßlin 2016-08-11 12:55:25 +02:00
parent 81d0454147
commit 71c996fe33
5 changed files with 17 additions and 7 deletions

View file

@ -138,7 +138,7 @@ void TestXRandRScreens::testStartup()
QVERIFY(screens->eventType() != 0);
QCOMPARE(screens->eventType(), Xcb::Extensions::self()->randrNotifyEvent());
QCOMPARE(screens->extension(), 0);
QCOMPARE(screens->genericEventType(), 0);
QCOMPARE(screens->genericEventTypes(), QVector<int>{0});
screens->init();
QRect xephyrDefault = QRect(0, 0, 640, 480);
QCOMPARE(screens->count(), 1);

View file

@ -263,7 +263,7 @@ class XInputEventFilter : public X11EventFilter
{
public:
XInputEventFilter(X11Cursor *parent, int xi_opcode)
: X11EventFilter(XCB_GE_GENERIC, xi_opcode, XI_RawMotion)
: X11EventFilter(XCB_GE_GENERIC, xi_opcode, QVector<int>{XI_RawMotion, XI_RawButtonPress, XI_RawButtonRelease})
, m_x11Cursor(parent)
{}
virtual ~XInputEventFilter() = default;
@ -389,6 +389,8 @@ void X11Cursor::doStartMousePolling()
memset(mask1, 0, sizeof(mask1));
XISetMask(mask1, XI_RawMotion);
XISetMask(mask1, XI_RawButtonPress);
XISetMask(mask1, XI_RawButtonRelease);
evmasks[0].deviceid = XIAllMasterDevices;
evmasks[0].mask_len = sizeof(mask1);

View file

@ -237,7 +237,7 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e)
xcb_ge_generic_event_t *ge = reinterpret_cast<xcb_ge_generic_event_t *>(e);
foreach (X11EventFilter *filter, m_genericEventFilters) {
if (filter->extension() == ge->extension && filter->genericEventType() == ge->event_type && filter->event(e)) {
if (filter->extension() == ge->extension && filter->genericEventTypes().contains(ge->event_type) && filter->event(e)) {
return true;
}
}

View file

@ -25,7 +25,12 @@ namespace KWin
{
X11EventFilter::X11EventFilter(int eventType, int opcode, int genericEventType)
: m_eventType(eventType), m_extension(opcode), m_genericEventType(genericEventType)
: X11EventFilter(eventType, opcode, QVector<int>{genericEventType})
{
}
X11EventFilter::X11EventFilter(int eventType, int opcode, const QVector< int > &genericEventTypes)
: m_eventType(eventType), m_extension(opcode), m_genericEventTypes(genericEventTypes)
{
Workspace::self()->registerEventFilter(this);
}

View file

@ -23,6 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <xcb/xcb.h>
#include <QVector>
#include <kwin_export.h>
namespace KWin
@ -35,6 +37,7 @@ public:
* Creates an event filter for the given event type.
*/
X11EventFilter(int eventType, int opcode = 0, int genericEventType = 0);
X11EventFilter(int eventType, int opcode, const QVector<int> &genericEventTypes);
/**
* Destroys the event filter.
@ -54,11 +57,11 @@ public:
int extension() const { return m_extension; }
/**
* Returns the type of generic events to filter.
* Returns the types of generic events to filter.
*
* Only used when the event type is XCB_GE_GENERIC.
*/
int genericEventType() const { return m_genericEventType; }
QVector<int> genericEventTypes() const { return m_genericEventTypes; }
/**
* This method is called for every event of the filtered type.
@ -70,7 +73,7 @@ public:
private:
int m_eventType;
int m_extension;
int m_genericEventType;
QVector<int> m_genericEventTypes;
};
} // namespace KWin