summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorJeremy Katz <jeremy.katz@nokia.com>2010-02-10 15:31:13 (GMT)
committerJeremy Katz <jeremy.katz@nokia.com>2010-02-10 15:31:13 (GMT)
commit5dcacb00fd68e6cc2bf3e6a467b603f387cb1a60 (patch)
tree45b73fb93cc61a2c612dfda951babdd9e3d9ab91 /src/gui/kernel
parent7651a4bacf8f34f3700853f147093a073f0472ab (diff)
downloadQt-5dcacb00fd68e6cc2bf3e6a467b603f387cb1a60.zip
Qt-5dcacb00fd68e6cc2bf3e6a467b603f387cb1a60.tar.gz
Qt-5dcacb00fd68e6cc2bf3e6a467b603f387cb1a60.tar.bz2
Move user event handling into QWindowSystemInterface class
This currently includes mouse, wheel, keyboard, enter, leave, geometry, and close events. Windowing system plugins should limit themselves to the QWindowSystemInterface::handle*Event() methods, as the other methods will likely become private.
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/kernel.pri6
-rw-r--r--src/gui/kernel/qapplication_lite.cpp71
-rw-r--r--src/gui/kernel/qapplication_p.h104
-rw-r--r--src/gui/kernel/qeventdispatcher_glib_lite.cpp8
-rw-r--r--src/gui/kernel/qeventdispatcher_lite.cpp9
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp112
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h129
7 files changed, 285 insertions, 154 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index c32b84f..51167d4 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -201,7 +201,8 @@ embedded_lite {
HEADERS += \
kernel/qgenericpluginfactory_lite.h \
kernel/qgenericplugin_lite.h \
- kernel/qeventdispatcher_lite_p.h
+ kernel/qeventdispatcher_lite_p.h \
+ kernel/qwindowsysteminterface.h \
SOURCES += \
kernel/qapplication_lite.cpp \
@@ -214,7 +215,8 @@ embedded_lite {
kernel/qkeymapper_qws.cpp \
kernel/qsound_lite.cpp \
kernel/qwidget_lite.cpp \
- kernel/qeventdispatcher_lite.cpp
+ kernel/qeventdispatcher_lite.cpp \
+ kernel/qwindowsysteminterface.cpp
contains(QT_CONFIG, glib) {
SOURCES += \
diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp
index 39cc29f..6142e15 100644
--- a/src/gui/kernel/qapplication_lite.cpp
+++ b/src/gui/kernel/qapplication_lite.cpp
@@ -59,9 +59,11 @@
#include "private/qgraphicssystem_p.h"
#include "qgraphicssystemcursor.h"
#include <qdebug.h>
+#include <QWindowSystemInterface>
QT_BEGIN_NAMESPACE
+QList<QWindowSystemInterface::UserEvent *> userEventQueue;
static QString appName;
static const char *appFont = 0; // application font
@@ -75,7 +77,6 @@ int qt_last_x = 0;
int qt_last_y = 0;
QPointer<QWidget> qt_last_mouse_receiver = 0;
-QList<QApplicationPrivate::UserEvent *> QApplicationPrivate::userEventQueue;
static Qt::KeyboardModifiers modifiers = Qt::NoModifier;
static Qt::MouseButtons buttons = Qt::NoButton;
static ulong mousePressTime;
@@ -83,23 +84,22 @@ static Qt::MouseButton mousePressButton = Qt::NoButton;
static int mousePressX;
static int mousePressY;
static int mouse_double_click_distance = 5;
-QTime QApplicationPrivate::time;
-void QApplicationPrivate::processUserEvent(UserEvent *e)
+void QApplicationPrivate::processUserEvent(QWindowSystemInterface::UserEvent *e)
{
switch(e->type) {
case QEvent::MouseButtonDblClick: // if mouse event, calculate appropriate widget and local coordinates
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
- QApplicationPrivate::processMouseEvent(static_cast<MouseEvent *>(e));
+ QApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterface::MouseEvent *>(e));
break;
case QEvent::Wheel:
- QApplicationPrivate::processWheelEvent(static_cast<WheelEvent *>(e));
+ QApplicationPrivate::processWheelEvent(static_cast<QWindowSystemInterface::WheelEvent *>(e));
break;
case QEvent::KeyPress:
case QEvent::KeyRelease:
- QApplicationPrivate::processKeyEvent(static_cast<KeyEvent *>(e));
+ QApplicationPrivate::processKeyEvent(static_cast<QWindowSystemInterface::KeyEvent *>(e));
break;
default:
qWarning() << "Unknown user input event type:" << e->type;
@@ -524,35 +524,7 @@ void QApplication::setMainWidget(QWidget *mainWidget)
}
#endif
-
-//------------------------------------------------------------
-//
-// Callback functions for plugins:
-//
-
-/*!
-
-\a tlw == 0 means that \a ev is in global coords only
-
-
-*/
-
-
-void QApplicationPrivate::handleEnterEvent(QWidget *tlw)
-{
- dispatchEnterLeave(tlw, 0);
- qt_last_mouse_receiver = tlw;
-}
-
-void QApplicationPrivate::handleLeaveEvent(QWidget *tlw)
-{
- dispatchEnterLeave(0, qt_last_mouse_receiver);
- if (!tlw->isAncestorOf(qt_last_mouse_receiver)) //(???) this should not happen
- dispatchEnterLeave(0, tlw);
- qt_last_mouse_receiver = 0;
-}
-
-void QApplicationPrivate::processMouseEvent(MouseEvent *e)
+void QApplicationPrivate::processMouseEvent(QWindowSystemInterface::MouseEvent *e)
{
// qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons();
static QWeakPointer<QWidget> implicit_mouse_grabber;
@@ -561,16 +533,12 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e)
// move first
Qt::MouseButtons stateChange = e->buttons ^ buttons;
if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) {
- MouseEvent * newMouseEvent = new MouseEvent(e->id, e->timestamp, e->localPos, e->globalPos, e->buttons);
+ QWindowSystemInterface::MouseEvent * newMouseEvent = new QWindowSystemInterface::MouseEvent(e->widget.data(), e->timestamp, e->localPos, e->globalPos, e->buttons);
userEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop
stateChange = Qt::NoButton;
}
- QWidget * tlw;
- if (e->id)
- tlw = QWidget::find(e->id);
- else
- tlw = 0;
+ QWidget * tlw = e->widget.data();
QPoint localPoint = e->localPos;
QPoint globalPoint = e->globalPos;
@@ -701,7 +669,7 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e)
//### there's a lot of duplicated logic here -- refactoring required!
-void QApplicationPrivate::processWheelEvent(WheelEvent *e)
+void QApplicationPrivate::processWheelEvent(QWindowSystemInterface::WheelEvent *e)
{
// QPoint localPoint = ev.pos();
QPoint globalPoint = e->globalPos;
@@ -711,11 +679,7 @@ void QApplicationPrivate::processWheelEvent(WheelEvent *e)
qt_last_x = globalPoint.x();
qt_last_y = globalPoint.y();
- QWidget *mouseWindow;
- if (e->id)
- mouseWindow = QWidget::find(e->id);
- else
- mouseWindow = 0;
+ QWidget *mouseWindow = e->widget.data();
// find the tlw if we didn't get it from the plugin
if (!mouseWindow) {
@@ -747,7 +711,7 @@ void QApplicationPrivate::processWheelEvent(WheelEvent *e)
// Remember, Qt convention is: keyboard state is state *before*
-void QApplicationPrivate::processKeyEvent(KeyEvent *e)
+void QApplicationPrivate::processKeyEvent(QWindowSystemInterface::KeyEvent *e)
{
QWidget *focusW = 0;
if (self->inPopupMode()) {
@@ -756,8 +720,8 @@ void QApplicationPrivate::processKeyEvent(KeyEvent *e)
}
if (!focusW)
focusW = QApplication::focusWidget();
- if (!focusW && e->id) {
- focusW = QWidget::find(e->id);
+ if (!focusW) {
+ focusW = e->widget.data();
}
if (!focusW)
focusW = QApplication::activeWindow();
@@ -774,8 +738,7 @@ void QApplicationPrivate::processKeyEvent(KeyEvent *e)
QApplication::sendSpontaneousEvent(focusW, &ev);
}
-
-void QApplicationPrivate::handleGeometryChange(QWidget *tlw, const QRect &newRect)
+void QApplicationPrivate::processGeometryChange(QWidget *tlw, const QRect &newRect)
{
QRect cr(tlw->geometry());
@@ -794,11 +757,9 @@ void QApplicationPrivate::handleGeometryChange(QWidget *tlw, const QRect &newRec
}
}
-
-void QApplicationPrivate::handleCloseEvent(QWidget *tlw)
+void QApplicationPrivate::processCloseEvent(QWidget *tlw)
{
tlw->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
}
-
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index f6e91f7..273e9ea 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -76,6 +76,9 @@
#ifdef Q_OS_SYMBIAN
#include <w32std.h>
#endif
+#ifdef Q_WS_LITE
+#include <QWindowSystemInterface>
+#endif
QT_BEGIN_NAMESPACE
@@ -462,6 +465,18 @@ public:
static bool qt_mac_apply_settings();
#endif
+#ifdef Q_WS_LITE
+ static void processMouseEvent(QWindowSystemInterface::MouseEvent *e);
+ static void processKeyEvent(QWindowSystemInterface::KeyEvent *e);
+ static void processWheelEvent(QWindowSystemInterface::WheelEvent *e);
+
+ static void processCloseEvent(QWidget *tlw);
+ static void processGeometryChange(QWidget *tlw, const QRect &newRect);
+
+ static void processUserEvent(QWindowSystemInterface::UserEvent *e);
+
+#endif
+
#ifdef Q_WS_QWS
QPointer<QWSManager> last_manager;
QWSServerCleaner qwsServerCleaner;
@@ -565,91 +580,6 @@ public:
void _q_readRX71MultiTouchEvents();
#endif
-#ifdef Q_WS_LITE
- static QTime time;
-
- class UserEvent {
- public:
- UserEvent(WId w, ulong time, QEvent::Type t) { id = w; type = t; timestamp = time; }
- WId id;
- QEvent::Type type;
- unsigned long timestamp;
- };
-
- class MouseEvent : public UserEvent {
- public:
- MouseEvent(WId w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
- : UserEvent(w, time, QEvent::MouseMove){ localPos = local; globalPos = global; buttons = b; }
- QPoint localPos;
- QPoint globalPos;
- Qt::MouseButtons buttons;
- };
-
- class WheelEvent : public UserEvent {
- public:
- WheelEvent(WId w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
- : UserEvent(w, time, QEvent::Wheel) { localPos = local; globalPos = global; delta = d; orient = o; }
- int delta;
- QPoint localPos;
- QPoint globalPos;
- Qt::Orientation orient;
- };
-
- class KeyEvent : public UserEvent {
- public:
- KeyEvent(WId w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
- :UserEvent(w, time, t){ key = k; unicode = text; repeat = autorep; repeatCount = count; modifiers = mods; }
- int key;
- QString unicode;
- bool repeat;
- ushort repeatCount;
- Qt::KeyboardModifiers modifiers;
- };
-
- static void handleMouseEvent(WId w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) {
- handleMouseEvent(w, time.elapsed(), local, global, b);
- }
-
- static void handleMouseEvent(WId w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b) {
- MouseEvent * e = new MouseEvent(w, timestamp, local, global, b);
- queueUserEvent(e);
- }
-
- static void handleKeyEvent(WId w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) {
- handleKeyEvent(w, time.elapsed(), t, k, mods, text, autorep, count);
- }
-
- static void handleKeyEvent(WId w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) {
- KeyEvent * e = new KeyEvent(w, timestamp, t, k, mods, text, autorep, count);
- queueUserEvent(e);
- }
-
- static void handleWheelEvent(WId w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
- handleWheelEvent(w, time.elapsed(), local, global, d, o);
- }
-
- static void handleWheelEvent(WId w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
- WheelEvent *e = new WheelEvent(w, timestamp, local, global, d, o);
- queueUserEvent(e);
- }
-
- static void queueUserEvent(UserEvent *ev) { userEventQueue.append(ev); }
- static void processUserEvent(UserEvent *e);
- static int userEventsQueued() { return userEventQueue.count(); }
- static UserEvent * getUserEvent() { return userEventQueue.takeFirst(); }
-
- // could be private, should only be used by deliverUserEvents()
- static void processMouseEvent(MouseEvent *e);
- static void processKeyEvent(KeyEvent *e);
- static void processWheelEvent(WheelEvent *e);
-
- // delivered directly by the plugin via spontaneous events
- static void handleGeometryChange(QWidget *tlw, const QRect &newRect);
- static void handleCloseEvent(QWidget *tlw);
- static void handleEnterEvent(QWidget *tlw);
- static void handleLeaveEvent(QWidget *tlw);
-#endif
-
#if defined(Q_WS_S60)
int maxTouchPressure;
QList<QTouchEvent::TouchPoint> appAllTouchPoints;
@@ -664,10 +594,6 @@ private:
static QHash<TInt, TUint> scanCodeCache;
#endif
-#ifdef Q_WS_LITE
- static QList<UserEvent *> userEventQueue;
-#endif
-
static QApplicationPrivate *self;
static void giveFocusAccordingToFocusPolicy(QWidget *w,
diff --git a/src/gui/kernel/qeventdispatcher_glib_lite.cpp b/src/gui/kernel/qeventdispatcher_glib_lite.cpp
index 6d80823..757bb00 100644
--- a/src/gui/kernel/qeventdispatcher_glib_lite.cpp
+++ b/src/gui/kernel/qeventdispatcher_glib_lite.cpp
@@ -64,7 +64,7 @@ static gboolean userEventSourcePrepare(GSource *s, gint *timeout)
Q_UNUSED(s)
Q_UNUSED(timeout)
- return QApplicationPrivate::userEventsQueued() > 0;
+ return QWindowSystemInterface::userEventsQueued() > 0;
}
static gboolean userEventSourceCheck(GSource *source)
@@ -76,9 +76,9 @@ static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer)
{
GUserEventSource * source = reinterpret_cast<GUserEventSource *>(s);
- QApplicationPrivate::UserEvent * event;
- while (QApplicationPrivate::userEventsQueued()) {
- event = QApplicationPrivate::getUserEvent();
+ QWindowSystemInterface::UserEvent * event;
+ while (QWindowSystemInterface::userEventsQueued()) {
+ event = QWindowSystemInterface::getUserEvent();
// send through event filter
if (source->q->filterEvent(event)) {
diff --git a/src/gui/kernel/qeventdispatcher_lite.cpp b/src/gui/kernel/qeventdispatcher_lite.cpp
index 39eef96..bd177cb 100644
--- a/src/gui/kernel/qeventdispatcher_lite.cpp
+++ b/src/gui/kernel/qeventdispatcher_lite.cpp
@@ -47,6 +47,7 @@
#ifndef QT_NO_THREAD
# include "qmutex.h"
#endif
+#include <QWindowSystemInterface>
#include <errno.h>
QT_BEGIN_NAMESPACE
@@ -83,11 +84,11 @@ bool QEventDispatcherLite::processEvents(QEventLoop::ProcessEventsFlags flags)
QApplication::sendPostedEvents();
while (!d->interrupt) { // also flushes output buffer ###can be optimized
- QApplicationPrivate::UserEvent *event;
+ QWindowSystemInterface::UserEvent *event;
if (!(flags & QEventLoop::ExcludeUserInputEvents)
- && QApplicationPrivate::userEventsQueued() > 0) {
+ && QWindowSystemInterface::userEventsQueued() > 0) {
// process a pending user input event
- event = QApplicationPrivate::getUserEvent();
+ event = QWindowSystemInterface::getUserEvent();
} else {
break;
}
@@ -112,7 +113,7 @@ bool QEventDispatcherLite::processEvents(QEventLoop::ProcessEventsFlags flags)
bool QEventDispatcherLite::hasPendingEvents()
{
extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
- return qGlobalPostedEventsCount() || QApplicationPrivate::userEventsQueued();;
+ return qGlobalPostedEventsCount() || QWindowSystemInterface::userEventsQueued();;
}
void QEventDispatcherLite::startingUp()
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
new file mode 100644
index 0000000..e051533
--- /dev/null
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qwindowsysteminterface.h"
+#include "qapplication_p.h"
+
+QT_BEGIN_NAMESPACE
+
+
+QTime QWindowSystemInterface::eventTime;
+
+//------------------------------------------------------------
+//
+// Callback functions for plugins:
+//
+
+QList<QWindowSystemInterface::UserEvent *> QWindowSystemInterface::userEventQueue;
+
+extern QPointer<QWidget> qt_last_mouse_receiver;
+/*!
+
+\a tlw == 0 means that \a ev is in global coords only
+
+
+*/
+
+
+void QWindowSystemInterface::handleEnterEvent(QWidget *tlw)
+{
+ if (tlw) {
+ QApplicationPrivate::dispatchEnterLeave(tlw, 0);
+ qt_last_mouse_receiver = tlw;
+ }
+}
+
+void QWindowSystemInterface::handleLeaveEvent(QWidget *tlw)
+{
+ QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver);
+ if (tlw && !tlw->isAncestorOf(qt_last_mouse_receiver)) //(???) this should not happen
+ QApplicationPrivate::dispatchEnterLeave(0, tlw);
+ qt_last_mouse_receiver = 0;
+}
+
+void QWindowSystemInterface::handleGeometryChange(QWidget *tlw, const QRect &newRect)
+{
+ if (tlw)
+ QApplicationPrivate::processGeometryChange(tlw, newRect);
+}
+
+
+void QWindowSystemInterface::handleCloseEvent(QWidget *tlw)
+{
+ if (tlw)
+ QApplicationPrivate::processCloseEvent(tlw);
+}
+
+void QWindowSystemInterface::handleMouseEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
+{
+ MouseEvent * e = new MouseEvent(tlw, timestamp, local, global, b);
+ queueUserEvent(e);
+}
+
+void QWindowSystemInterface::handleKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
+{
+ KeyEvent * e = new KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count);
+ queueUserEvent(e);
+}
+
+void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
+{
+ WheelEvent *e = new WheelEvent(tlw, timestamp, local, global, d, o);
+ queueUserEvent(e);
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
new file mode 100644
index 0000000..caeacd3
--- /dev/null
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QWINDOWSYSTEMINTERFACE_H
+#define QWINDOWSYSTEMINTERFACE_H
+
+#include <QTime>
+#include <qwindowdefs.h>
+#include <QEvent>
+#include <QWidget>
+#include <QWeakPointer>
+
+QT_BEGIN_NAMESPACE
+class Q_GUI_EXPORT QWindowSystemInterface
+{
+public:
+ class UserEvent {
+ public:
+ UserEvent(QWidget * w, ulong time, QEvent::Type t)
+ { widget = QWeakPointer<QWidget>::QWeakPointer(w); type = t; timestamp = time; }
+ QWeakPointer<QWidget> widget;
+ QEvent::Type type;
+ unsigned long timestamp;
+ };
+
+ class MouseEvent : public UserEvent {
+ public:
+ MouseEvent(QWidget * w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
+ : UserEvent(w, time, QEvent::MouseMove){ localPos = local; globalPos = global; buttons = b; }
+ QPoint localPos;
+ QPoint globalPos;
+ Qt::MouseButtons buttons;
+ };
+
+ class WheelEvent : public UserEvent {
+ public:
+ WheelEvent(QWidget *w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
+ : UserEvent(w, time, QEvent::Wheel) { localPos = local; globalPos = global; delta = d; orient = o; }
+ int delta;
+ QPoint localPos;
+ QPoint globalPos;
+ Qt::Orientation orient;
+ };
+
+ class KeyEvent : public UserEvent {
+ public:
+ KeyEvent(QWidget *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
+ :UserEvent(w, time, t){ key = k; unicode = text; repeat = autorep; repeatCount = count; modifiers = mods; }
+ int key;
+ QString unicode;
+ bool repeat;
+ ushort repeatCount;
+ Qt::KeyboardModifiers modifiers;
+ };
+
+ static QTime eventTime;
+
+ static int userEventsQueued() { return userEventQueue.count(); }
+ static UserEvent * getUserEvent() { return userEventQueue.takeFirst(); }
+ static void queueUserEvent(UserEvent *ev) { userEventQueue.append(ev); }
+
+
+public:
+ static QList<UserEvent *> userEventQueue;
+
+ static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) {
+ handleMouseEvent(w, eventTime.elapsed(), local, global, b);
+ }
+
+ static void handleMouseEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b);
+
+ static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) {
+ handleKeyEvent(w, eventTime.elapsed(), t, k, mods, text, autorep, count);
+ }
+
+ static void handleKeyEvent(QWidget *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
+
+ static void handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
+ handleWheelEvent(w, eventTime.elapsed(), local, global, d, o);
+ }
+
+ static void handleWheelEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
+
+ // delivered directly by the plugin via spontaneous events
+ static void handleGeometryChange(QWidget *w, const QRect &newRect);
+ static void handleCloseEvent(QWidget *w);
+ static void handleEnterEvent(QWidget *w);
+ static void handleLeaveEvent(QWidget *w);
+};
+
+QT_END_NAMESPACE
+#endif // QWINDOWSYSTEMINTERFACE_H