on b0f3641 help sign in
unity8/MouseTouchAdaptor.h
52 lines 1.7 kB history raw
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 *
16 * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
17 */
19#ifndef MOUSE_TOUCH_ADAPTOR_H
20#define MOUSE_TOUCH_ADAPTOR_H
22#include <QtCore/QAbstractNativeEventFilter>
23#include <xcb/xcb.h>
25class QMouseEvent;
26class QTouchDevice;
27class QWindow;
29// Transforms QMouseEvents into single-finger QTouchEvents.
30class MouseTouchAdaptor : public QAbstractNativeEventFilter {
32public:
33 MouseTouchAdaptor();
35 // The window that will receive the generated QTouchEvents
36 void setTargetWindow(QWindow *window);
38 // Filters mouse events and posts the equivalent QTouchEvents.
39 virtual bool nativeEventFilter(const QByteArray & eventType, void *message, long *result);
41private:
43 bool handleButtonPress(xcb_button_press_event_t *pressEvent);
44 bool handleButtonRelease(xcb_button_release_event_t *releaseEvent);
45 bool handleMotionNotify(xcb_motion_notify_event_t *event);
47 QWindow *m_targetWindow;
48 QTouchDevice *m_touchDevice;
49 bool m_leftButtonIsPressed;
50};
52#endif // MOUSE_TOUCH_ADAPTOR_H