summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--src/gui/embedded/qkbd_qws.cpp4
-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
-rw-r--r--src/plugins/generic/linuxinput/qlinuxinput.cpp10
-rw-r--r--src/plugins/graphicssystems/fb_base/fb_base.cpp4
-rw-r--r--src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp42
-rw-r--r--src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp18
-rw-r--r--src/plugins/graphicssystems/vnc/qvncserver.cpp8
13 files changed, 318 insertions, 207 deletions
diff --git a/src/gui/embedded/qkbd_qws.cpp b/src/gui/embedded/qkbd_qws.cpp
index 97fb7a0..c4dd6bd 100644
--- a/src/gui/embedded/qkbd_qws.cpp
+++ b/src/gui/embedded/qkbd_qws.cpp
@@ -54,7 +54,7 @@
#endif
#ifdef Q_WS_LITE
-#include <private/qapplication_p.h>
+#include <QWindowSystemInterface>
#include <QKeyEvent>
#endif
@@ -367,7 +367,7 @@ void QWSKeyboardHandler::processKeyEvent(int unicode, int keycode, Qt::KeyboardM
QString str;
if (unicode != 0xffff)
str = QString(unicode);
- QApplicationPrivate::handleKeyEvent(0, type, keycode, modifiers, str);
+ QWindowSystemInterface::handleKeyEvent(0, type, keycode, modifiers, str);
#endif
}
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
diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp
index 363e91f..32137ee 100644
--- a/src/plugins/generic/linuxinput/qlinuxinput.cpp
+++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp
@@ -46,7 +46,7 @@
#include <QSocketNotifier>
#include <QStringList>
#include <QPoint>
-#include <private/qapplication_p.h>
+#include <QWindowSystemInterface>
#include <qkbd_qws.h>
@@ -141,13 +141,13 @@ void QLinuxInputMouseHandler::readMouseData()
} else if (data->code == ABS_WHEEL) { // vertical scroll
// data->value: 1 == up, -1 == down
int delta = 120 * data->value;
- QApplicationPrivate::handleWheelEvent(0, QPoint(m_x, m_y),
+ QWindowSystemInterface::handleWheelEvent(0, QPoint(m_x, m_y),
QPoint(m_x, m_y),
delta, Qt::Vertical);
} else if (data->code == ABS_THROTTLE) { // horizontal scroll
// data->value: 1 == right, -1 == left
int delta = 120 * -data->value;
- QApplicationPrivate::handleWheelEvent(0, QPoint(m_x, m_y),
+ QWindowSystemInterface::handleWheelEvent(0, QPoint(m_x, m_y),
QPoint(m_x, m_y),
delta, Qt::Horizontal);
} else {
@@ -167,7 +167,7 @@ void QLinuxInputMouseHandler::readMouseData()
else
m_buttons &= ~button;
- QApplicationPrivate::handleMouseEvent(0, QPoint(m_x, m_y),
+ QWindowSystemInterface::handleMouseEvent(0, QPoint(m_x, m_y),
QPoint(m_x, m_y), m_buttons);
} else if (data->type == EV_SYN && data->code == SYN_REPORT) {
if (!posChanged)
@@ -175,7 +175,7 @@ void QLinuxInputMouseHandler::readMouseData()
posChanged = false;
QPoint pos(m_x, m_y);
- QApplicationPrivate::handleMouseEvent(0, pos, pos, m_buttons);
+ QWindowSystemInterface::handleMouseEvent(0, pos, pos, m_buttons);
// pos = m_handler->transform(pos);
//m_handler->limitToScreen(pos);
diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp
index eeaa220..6567e95 100644
--- a/src/plugins/graphicssystems/fb_base/fb_base.cpp
+++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp
@@ -1,10 +1,10 @@
#include "fb_base.h"
#include <qpainter.h>
-#include <private/qapplication_p.h>
#include <qdebug.h>
#include <qbitmap.h>
#include <qgraphicssystemcursor.h>
+#include <QWindowSystemInterface>
QGraphicsSystemSoftwareCursor::QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen *scr)
: QGraphicsSystemCursor(scr), currentRect(QRect()), prevRect(QRect())
@@ -261,7 +261,7 @@ void QGraphicsSystemFbWindowSurface::setGeometry(const QRect &rect)
if (mImage.size() != rect.size())
mImage = QImage(rect.size(), mScreen->format());
- QApplicationPrivate::handleGeometryChange(this->window(), rect);
+ QWindowSystemInterface::handleGeometryChange(window(), rect);
QWindowSurface::setGeometry(rect);
}
diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp
index c3b5522..74a38a4 100644
--- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp
+++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp
@@ -3,9 +3,10 @@
#include <QThread>
#include <QDebug>
-#include <private/qapplication_p.h>
+#include <QWindowSystemInterface>
#include <QMouseEvent>
#include <QEvent>
+#include <QApplication>
#include <directfb.h>
@@ -65,7 +66,7 @@ QDirectFbInput::QDirectFbInput()
m_inputHandler = new InputSocketWaiter(eventBuffer,this);
connect(m_inputHandler,SIGNAL(newEvent()),this,SLOT(handleEvents()));
- connect(qApp,SIGNAL(aboutToQuit()),SLOT(applicationEnd()));
+ connect(QApplication::instance(),SIGNAL(aboutToQuit()),SLOT(applicationEnd()));
}
void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw)
@@ -127,42 +128,23 @@ void QDirectFbInput::handleEvents()
void QDirectFbInput::handleMouseEvents(const DFBEvent &event)
{
- QEvent::Type type = QDirectFbConvenience::eventType(event.window.type);
QPoint p(event.window.x, event.window.y);
QPoint globalPos = globalPoint(event);
Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons);
- QWidget *tlw = tlwMap.value(event.window.window_id);
IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer();
IDirectFBWindow *window;
layer->GetWindow(layer,event.window.window_id,&window);
long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000);
- timestamp /= 1000;
if (event.window.type == DWET_BUTTONDOWN) {
- static long prevTime = 0;
- static QWidget *prevWindow;
- static int prevX = -999;
- static int prevY = -999;
-
- if (tlw == prevWindow && timestamp - prevTime < QApplication::doubleClickInterval()
- && qAbs(event.window.cx - prevX) < 5 && qAbs(event.window.cy - prevY) < 5) {
- type = QEvent::MouseButtonDblClick;
- prevTime = timestamp - QApplication::doubleClickInterval(); //no double click next time
- } else {
- prevTime = timestamp;
- }
- prevWindow = tlw;
- prevX = event.window.cx;
- prevY = event.window.cy;
-
window->GrabPointer(window);
} else if (event.window.type == DWET_BUTTONUP) {
window->UngrabPointer(window);
}
-
- QApplicationPrivate::handleMouseEvent(event.window.window_id, timestamp, p, globalPos, buttons);
+ QWidget *tlw = tlwMap.value(event.window.window_id);
+ QWindowSystemInterface::handleMouseEvent(tlw, timestamp, p, globalPos, buttons);
}
void QDirectFbInput::applicationEnd()
@@ -176,9 +158,8 @@ void QDirectFbInput::handleWheelEvent(const DFBEvent &event)
QPoint p(event.window.cx, event.window.cy);
QPoint globalPos = globalPoint(event);
long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000);
- timestamp /= 1000;
-
- QApplicationPrivate::handleWheelEvent(event.window.window_id, timestamp, p, globalPos,
+ QWidget *tlw = tlwMap.value(event.window.window_id);
+ QWindowSystemInterface::handleWheelEvent(tlw, timestamp, p, globalPos,
event.window.step*120,
Qt::Vertical);
}
@@ -190,13 +171,12 @@ void QDirectFbInput::handleKeyEvents(const DFBEvent &event)
Qt::KeyboardModifiers modifiers = QDirectFbConvenience::keyboardModifiers(event.window.modifiers);
long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000);
- timestamp /= 1000;
QChar character;
if (DFB_KEY_TYPE(event.window.key_symbol) == DIKT_UNICODE)
character = QChar(event.window.key_symbol);
-
- QApplicationPrivate::handleKeyEvent(event.window.window_id, timestamp, type, key, modifiers, character);
+ QWidget *tlw = tlwMap.value(event.window.window_id);
+ QWindowSystemInterface::handleKeyEvent(tlw, timestamp, type, key, modifiers, character);
}
void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event)
@@ -204,10 +184,10 @@ void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event)
QWidget *tlw = tlwMap.value(event.window.window_id);
switch (event.window.type) {
case DWET_ENTER:
- QApplicationPrivate::handleEnterEvent(tlw);
+ QWindowSystemInterface::handleEnterEvent(tlw);
break;
case DWET_LEAVE:
- QApplicationPrivate::handleLeaveEvent(tlw);
+ QWindowSystemInterface::handleLeaveEvent(tlw);
break;
default:
break;
diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp
index e159106..c54f6eb 100644
--- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp
+++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp
@@ -43,7 +43,7 @@
#include "qgraphicssystem_testlite.h"
#include <QtCore/qdebug.h>
-#include <private/qapplication_p.h>
+#include <QWindowSystemInterface>
#include "x11util.h"
@@ -245,7 +245,7 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev)
bool hor = (((e->button == Button4 || e->button == Button5)
&& (modifiers & Qt::AltModifier))
|| (e->button == 6 || e->button == 7));
- QApplicationPrivate::handleWheelEvent(winId(), e->time,
+ QWindowSystemInterface::handleWheelEvent(window(), e->time,
QPoint(e->x, e->y),
QPoint(e->x_root, e->y_root),
delta, hor ? Qt::Horizontal : Qt::Vertical);
@@ -258,7 +258,7 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev)
buttons ^= button; // X event uses state *before*, Qt uses state *after*
- QApplicationPrivate::handleMouseEvent(winId(), e->time, QPoint(e->x, e->y),
+ QWindowSystemInterface::handleMouseEvent(window(), e->time, QPoint(e->x, e->y),
QPoint(e->x_root, e->y_root),
buttons);
@@ -267,24 +267,24 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev)
void QTestLiteWindowSurface::handleGeometryChange(int x, int y, int w, int h)
{
- QApplicationPrivate::handleGeometryChange(window(), QRect(x,y,w,h));
+ QWindowSystemInterface::handleGeometryChange(window(), QRect(x,y,w,h));
}
void QTestLiteWindowSurface::handleCloseEvent()
{
- QApplicationPrivate::handleCloseEvent(window());
+ QWindowSystemInterface::handleCloseEvent(window());
}
void QTestLiteWindowSurface::handleEnterEvent()
{
- QApplicationPrivate::handleEnterEvent(window());
+ QWindowSystemInterface::handleEnterEvent(window());
}
void QTestLiteWindowSurface::handleLeaveEvent()
{
- QApplicationPrivate::handleLeaveEvent(window());
+ QWindowSystemInterface::handleLeaveEvent(window());
}
@@ -592,12 +592,12 @@ void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev)
modifiers ^= modifierFromKeyCode(qtcode);
if (qtcode) {
- QApplicationPrivate::handleKeyEvent(winId(), e->time, type, qtcode, modifiers);
+ QWindowSystemInterface::handleKeyEvent(window(), e->time, type, qtcode, modifiers);
} else if (chars[0]) {
int qtcode = chars.toUpper()[0]; //Not exactly right...
if (modifiers & Qt::ControlModifier && qtcode < ' ')
qtcode = chars[0] + '@';
- QApplicationPrivate::handleKeyEvent(winId(), e->time, type, qtcode, modifiers, QString::fromLatin1(chars));
+ QWindowSystemInterface::handleKeyEvent(window(), e->time, type, qtcode, modifiers, QString::fromLatin1(chars));
} else {
qWarning() << "unknown X keycode" << hex << e->keycode << keySym;
}
diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp
index 490ca02..ea576d4 100644
--- a/src/plugins/graphicssystems/vnc/qvncserver.cpp
+++ b/src/plugins/graphicssystems/vnc/qvncserver.cpp
@@ -48,7 +48,7 @@
#include <QtGui/qpainter.h>
#include <QtGui/qevent.h>
-#include <private/qapplication_p.h>
+#include <QWindowSystemInterface>
#include <qplatformdefs.h>
@@ -844,7 +844,7 @@ void QVNCServer::pointerEvent()
bool isPress;
if (buttonChange(buttons, ev.buttons, &button, &isPress))
type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease;
- QApplicationPrivate::handleMouseEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), ev.buttons);
+ QWindowSystemInterface::handleMouseEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), ev.buttons);
} else {
// No buttons or motion reported at the same time as wheel events
Qt::Orientation orientation;
@@ -853,7 +853,7 @@ void QVNCServer::pointerEvent()
else
orientation = Qt::Vertical;
int delta = 120 * ((ev.wheelDirection == ev.WheelLeft || ev.wheelDirection == ev.WheelUp) ? 1 : -1);
- QApplicationPrivate::handleWheelEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), delta, orientation);
+ QWindowSystemInterface::handleWheelEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), delta, orientation);
}
handleMsg = false;
}
@@ -879,7 +879,7 @@ void QVNCServer::keyEvent()
QString str;
if (ev.unicode && ev.unicode != 0xffff)
str = QString(ev.unicode);
- QApplicationPrivate::handleKeyEvent(0, type, ev.keycode, keymod, str);
+ QWindowSystemInterface::handleKeyEvent(0, type, ev.keycode, keymod, str);
}
handleMsg = false;
}