2
* Copyright (C) 2013,2015 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
19
#ifndef MOUSE_TOUCH_ADAPTOR_H
20
#define MOUSE_TOUCH_ADAPTOR_H
22
#include <QtCore/QAbstractNativeEventFilter>
30
// Transforms QMouseEvents into single-finger QTouchEvents.
31
class MouseTouchAdaptor : public QObject, public QAbstractNativeEventFilter {
34
virtual ~MouseTouchAdaptor();
36
static MouseTouchAdaptor* instance();
38
// Filters mouse events and posts the equivalent QTouchEvents.
39
bool nativeEventFilter(const QByteArray & eventType, void *message, long *result) override;
41
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
44
void setEnabled(bool value);
47
void enabledChanged(bool value);
51
void fetchXInput2Info();
52
bool xi2HandleEvent(xcb_ge_event_t *event);
54
bool handleButtonPress(WId windowId, uint32_t detail, uint32_t modifiers, int x, int y);
55
bool handleButtonRelease(WId windowId, uint32_t detail, uint32_t modifiers, int x, int y);
56
bool handleMotionNotify(WId windowId, uint32_t modifiers, int x, int y);
57
QWindow *findQWindowWithXWindowID(WId windowId);
59
QTouchDevice *m_touchDevice;
60
bool m_leftButtonIsPressed;
61
bool m_triPressModifier;
62
bool m_quadPressModifier;
67
bool m_xi2Enabled{false};
69
int m_xiOpCode, m_xiEventBase, m_xiErrorBase;
72
#endif // MOUSE_TOUCH_ADAPTOR_H