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>
29
// Transforms QMouseEvents into single-finger QTouchEvents.
30
class UCMouseTouchAdaptor : public QObject, public QAbstractNativeEventFilter
34
UCMouseTouchAdaptor();
36
// Filters mouse events and posts the equivalent QTouchEvents.
37
bool nativeEventFilter(const QByteArray & eventType, void *message, long *result) override;
39
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
42
void setEnabled(bool value);
45
void enabledChanged(bool value);
49
bool handleButtonPress(xcb_button_press_event_t *pressEvent);
50
bool handleButtonRelease(xcb_button_release_event_t *releaseEvent);
51
bool handleMotionNotify(xcb_motion_notify_event_t *event);
52
QWindow *findQWindowWithXWindowID(WId windowId);
54
QTouchDevice *m_touchDevice;
55
bool m_leftButtonIsPressed;
60
#endif // MOUSE_TOUCH_ADAPTOR_H