diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/embedded/qkbd_qws.cpp | 3 | ||||
-rw-r--r-- | src/gui/kernel/kernel.pri | 15 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_lite.cpp | 133 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_p.h | 74 | ||||
-rw-r--r-- | src/gui/kernel/qeventdispatcher_glib_lite.cpp | 138 | ||||
-rw-r--r-- | src/gui/kernel/qeventdispatcher_glib_lite_p.h | 88 | ||||
-rw-r--r-- | src/gui/kernel/qeventdispatcher_lite.cpp | 141 | ||||
-rw-r--r-- | src/gui/kernel/qeventdispatcher_lite_p.h | 86 | ||||
-rw-r--r-- | src/gui/kernel/qeventdispatcher_qws_p.h | 2 | ||||
-rw-r--r-- | src/plugins/generic/linuxinput/qlinuxinput.cpp | 34 | ||||
-rw-r--r-- | src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp | 16 | ||||
-rw-r--r-- | src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp | 27 | ||||
-rw-r--r-- | src/plugins/graphicssystems/testlite/x11util.h | 2 | ||||
-rw-r--r-- | src/plugins/graphicssystems/vnc/qvncserver.cpp | 54 | ||||
-rw-r--r-- | src/plugins/graphicssystems/vnc/qvncserver.h | 5 |
15 files changed, 673 insertions, 145 deletions
diff --git a/src/gui/embedded/qkbd_qws.cpp b/src/gui/embedded/qkbd_qws.cpp index 233b6fa..97fb7a0 100644 --- a/src/gui/embedded/qkbd_qws.cpp +++ b/src/gui/embedded/qkbd_qws.cpp @@ -367,8 +367,7 @@ void QWSKeyboardHandler::processKeyEvent(int unicode, int keycode, Qt::KeyboardM QString str; if (unicode != 0xffff) str = QString(unicode); - QKeyEvent ke(type, keycode, modifiers, str); - QApplicationPrivate::handleKeyEvent(0, &ke); + QApplicationPrivate::handleKeyEvent(0, type, keycode, modifiers, str); #endif } diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 9fbdfc8..0c7231e 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -195,7 +195,8 @@ embedded { embedded_lite { HEADERS += \ kernel/qgenericpluginfactory_lite.h \ - kernel/qgenericplugin_lite.h + kernel/qgenericplugin_lite.h \ + kernel/qeventdispatcher_lite_p.h SOURCES += \ kernel/qapplication_lite.cpp \ @@ -207,7 +208,17 @@ embedded_lite { kernel/qgenericplugin_lite.cpp \ kernel/qkeymapper_qws.cpp \ kernel/qsound_lite.cpp \ - kernel/qwidget_lite.cpp + kernel/qwidget_lite.cpp \ + kernel/qeventdispatcher_lite.cpp + + contains(QT_CONFIG, glib) { + SOURCES += \ + kernel/qeventdispatcher_glib_lite.cpp + HEADERS += \ + kernel/qeventdispatcher_glib_lite_p.h + QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB + LIBS_PRIVATE +=$$QT_LIBS_GLIB + } } !embedded:!embedded_lite:!x11:mac { diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 57f6d72..4242ff7 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -43,9 +43,9 @@ #include "qcolormap.h" #include "qpixmapcache.h" #if !defined(QT_NO_GLIB) -#include "private/qeventdispatcher_glib_p.h" +#include "qeventdispatcher_glib_lite_p.h" #endif -#include "private/qeventdispatcher_unix_p.h" +#include "qeventdispatcher_lite_p.h" #ifndef QT_NO_CURSOR #include "private/qcursor_p.h" #endif @@ -75,6 +75,32 @@ 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; + +void QApplicationPrivate::processUserEvent(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)); + break; + case QEvent::Wheel: + QApplicationPrivate::processWheelEvent(static_cast<WheelEvent *>(e)); + break; + case QEvent::KeyPress: + case QEvent::KeyRelease: + QApplicationPrivate::processKeyEvent(static_cast<KeyEvent *>(e)); + break; + default: + qWarning() << "Unknown user input event type:" << e->type; + break; + } +} + QString QApplicationPrivate::appName() const { return QT_PREPEND_NAMESPACE(appName); @@ -85,13 +111,13 @@ void QApplicationPrivate::createEventDispatcher() Q_Q(QApplication); #if !defined(QT_NO_GLIB) if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported()) - eventDispatcher = new QEventDispatcherGlib(q); + eventDispatcher = new QLiteEventDispatcherGlib(q); else #endif - eventDispatcher = new QEventDispatcherUNIX(q); + eventDispatcher = new QEventDispatcherLite(q); } -static bool qt_try_modal(QWidget *widget, const QEvent *event) +static bool qt_try_modal(QWidget *widget, QEvent::Type type) { QWidget * top = 0; @@ -101,7 +127,7 @@ static bool qt_try_modal(QWidget *widget, const QEvent *event) bool block_event = false; bool paint_event = false; - switch (event->type()) { + switch (type) { #if 0 case QEvent::Focus: if (!static_cast<QWSFocusEvent*>(event)->simpleData.get_focus) @@ -520,22 +546,51 @@ void QApplicationPrivate::handleLeaveEvent(QWidget *tlw) qt_last_mouse_receiver = 0; } -void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) +void QApplicationPrivate::processMouseEvent(MouseEvent *e) { // qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons(); - static QWidget *implicit_mouse_grabber=0; - QPointer<QGraphicsSystemCursor> cursor = QGraphicsSystemCursor::getInstance(); - if (cursor) - cursor->pointerEvent(ev); + QEvent::Type type; + // 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->tlw, e->localPos, e->globalPos, e->buttons); + userEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop + stateChange = Qt::NoButton; + } - QPoint localPoint = ev.pos(); - QPoint globalPoint = ev.globalPos(); - QWidget *mouseWindow = tlw; + QPoint localPoint = e->localPos; + QPoint globalPoint = e->globalPos; + QWidget *mouseWindow = e->tlw; + + Qt::MouseButton button = Qt::NoButton; - qt_last_x = globalPoint.x(); - qt_last_y = globalPoint.y(); + + if (qt_last_x != globalPoint.x() || qt_last_y != globalPoint.y()) { + type = QEvent::MouseMove; + qt_last_x = globalPoint.x(); + qt_last_y = globalPoint.y(); + } + else { // check to see if a new button has been pressed/released + for (int check = Qt::LeftButton; + check <= Qt::XButton2; + check = check << 1) { + if (check & stateChange) { + button = Qt::MouseButton(check); + break; + } + } + if (button == Qt::NoButton) { + // Ignore mouse events that don't change the current state + return; + } + buttons = e->buttons; + if (button & e->buttons) + type = QEvent::MouseButtonPress; + else + type = QEvent::MouseButtonRelease; + } if (self->inPopupMode()) { //popup mouse handling is magical... @@ -544,11 +599,11 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) implicit_mouse_grabber = 0; //### how should popup mode and implicit mouse grab interact? - } else if (tlw && app_do_modal && !qt_try_modal(tlw, &ev) ) { + } else if (e->tlw && app_do_modal && !qt_try_modal(e->tlw, e->type) ) { //even if we're blocked by modality, we should deliver the mouse release event.. //### this code is not completely correct: multiple buttons can be pressed simultaneously - if (!(implicit_mouse_grabber && ev.buttons() == Qt::NoButton)) { - qDebug() << "modal blocked mouse event to" << tlw; + if (!(implicit_mouse_grabber && buttons == Qt::NoButton)) { + qDebug() << "modal blocked mouse event to" << e->tlw; return; } } @@ -561,7 +616,7 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) if (!mouseWindow && !implicit_mouse_grabber) mouseWindow = QApplication::desktop(); - if (mouseWindow && mouseWindow != tlw) { + if (mouseWindow && mouseWindow != e->tlw) { //we did not get a sensible localPoint from the window system, so let's calculate it localPoint = mouseWindow->mapFromGlobal(globalPoint); } @@ -576,7 +631,7 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) } //handle implicit mouse grab - if (ev.type() == QEvent::MouseButtonPress && !implicit_mouse_grabber) { + if (type == QEvent::MouseButtonPress && !implicit_mouse_grabber) { implicit_mouse_grabber = mouseWidget; Q_ASSERT(mouseWindow); @@ -584,7 +639,7 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) } else if (implicit_mouse_grabber) { mouseWidget = implicit_mouse_grabber; mouseWindow = mouseWidget->window(); - if (mouseWindow != tlw) + if (mouseWindow != e->tlw) localPoint = mouseWindow->mapFromGlobal(globalPoint); } @@ -593,7 +648,7 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) //localPoint is local to mouseWindow, but it needs to be local to mouseWidget localPoint = mouseWidget->mapFrom(mouseWindow, localPoint); - if (ev.buttons() == Qt::NoButton) { + if (buttons == Qt::NoButton) { //qDebug() << "resetting mouse grabber"; implicit_mouse_grabber = 0; } @@ -608,25 +663,29 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) // qDebug() << "sending mouse ev." << ev.type() << localPoint << globalPoint << ev.button() << ev.buttons() << mouseWidget << "mouse grabber" << implicit_mouse_grabber; - QMouseEvent e(ev.type(), localPoint, globalPoint, ev.button(), ev.buttons(), ev.modifiers()); - QApplication::sendSpontaneousEvent(mouseWidget, &e); + QMouseEvent ev(type, localPoint, globalPoint, button, buttons, modifiers); + + QPointer<QGraphicsSystemCursor> cursor = QGraphicsSystemCursor::getInstance(); + if (cursor) + cursor->pointerEvent(ev); + QApplication::sendSpontaneousEvent(mouseWidget, &ev); } //### there's a lot of duplicated logic here -- refactoring required! -void QApplicationPrivate::handleWheelEvent(QWidget *tlw, QWheelEvent &ev) +void QApplicationPrivate::processWheelEvent(WheelEvent *e) { // QPoint localPoint = ev.pos(); - QPoint globalPoint = ev.globalPos(); + QPoint globalPoint = e->globalPos; // bool trustLocalPoint = !!tlw; //is there something the local point can be local to? QWidget *mouseWidget; qt_last_x = globalPoint.x(); qt_last_y = globalPoint.y(); - QWidget *mouseWindow = tlw; + QWidget *mouseWindow = e->tlw; // find the tlw if we didn't get it from the plugin if (!mouseWindow) { @@ -638,7 +697,7 @@ void QApplicationPrivate::handleWheelEvent(QWidget *tlw, QWheelEvent &ev) mouseWidget = mouseWindow; - if (app_do_modal && !qt_try_modal(mouseWindow, &ev) ) { + if (app_do_modal && !qt_try_modal(mouseWindow, e->type) ) { qDebug() << "modal blocked wheel event" << mouseWindow; return; } @@ -649,16 +708,16 @@ void QApplicationPrivate::handleWheelEvent(QWidget *tlw, QWheelEvent &ev) p = mouseWidget->mapFromGlobal(globalPoint); } - QWheelEvent e(p, globalPoint, ev.delta(), ev.buttons(), ev.modifiers(), - ev.orientation()); - QApplication::sendSpontaneousEvent(mouseWidget, &e); + QWheelEvent ev(p, globalPoint, e->delta, buttons, modifiers, + e->orient); + QApplication::sendSpontaneousEvent(mouseWidget, &ev); } // Remember, Qt convention is: keyboard state is state *before* -void QApplicationPrivate::handleKeyEvent(QWidget *tlw, QKeyEvent *e) +void QApplicationPrivate::processKeyEvent(KeyEvent *e) { QWidget *focusW = 0; if (self->inPopupMode()) { @@ -668,7 +727,7 @@ void QApplicationPrivate::handleKeyEvent(QWidget *tlw, QKeyEvent *e) if (!focusW) focusW = QApplication::focusWidget(); if (!focusW) - focusW = tlw; + focusW = e->tlw; if (!focusW) focusW = QApplication::activeWindow(); @@ -676,10 +735,12 @@ void QApplicationPrivate::handleKeyEvent(QWidget *tlw, QKeyEvent *e) if (!focusW) return; - if (app_do_modal && !qt_try_modal(focusW, e)) + if (app_do_modal && !qt_try_modal(focusW, e->type)) return; - QApplication::sendSpontaneousEvent(focusW, e); + modifiers = e->modifiers; + QKeyEvent ev(e->type, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount); + QApplication::sendSpontaneousEvent(focusW, &ev); } diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index a93fd63..955a3fc 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -65,8 +65,9 @@ #include "QtCore/qhash.h" #include "QtCore/qpointer.h" #include "private/qcoreapplication_p.h" -#include "private/qshortcutmap_p.h" +#include "QtGui/private/qshortcutmap_p.h" #include <private/qthread_p.h> +#include "QtCore/qpoint.h" #ifdef Q_WS_QWS #include "QtGui/qscreen_qws.h" #include <private/qgraphicssystem_qws_p.h> @@ -564,11 +565,72 @@ public: #endif #ifdef Q_WS_LITE - static void handleMouseEvent(QWidget *tlw, const QMouseEvent &ev); - static void handleKeyEvent(QWidget *tlw, QKeyEvent *e); + + class UserEvent { + public: + UserEvent(QWidget *w) { tlw = w; } + QWidget * tlw; + QEvent::Type type; + }; + + class MouseEvent : public UserEvent { + public: + MouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) + : UserEvent(w){ localPos = local; globalPos = global; buttons = b; type = QEvent::MouseMove; } + QPoint localPos; + QPoint globalPos; + Qt::MouseButtons buttons; + }; + + class WheelEvent : public UserEvent { + public: + WheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) + : UserEvent(w) { localPos = local; globalPos = global; delta = d; orient = o; type = QEvent::Wheel; } + int delta; + QPoint localPos; + QPoint globalPos; + Qt::Orientation orient; + }; + + class KeyEvent : public UserEvent { + public: + KeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) + :UserEvent(w){ type = 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(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { + MouseEvent * e = new MouseEvent(w, local, global, b); + queueUserEvent(e); + } + + static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { + KeyEvent * e = new KeyEvent(w, t, k, mods, text, autorep, count); + queueUserEvent(e); + } + + static void handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { + WheelEvent *e = new WheelEvent(w, 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 handleWheelEvent(QWidget *tlw, QWheelEvent &e); static void handleEnterEvent(QWidget *tlw); static void handleLeaveEvent(QWidget *tlw); #endif @@ -587,6 +649,10 @@ 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 new file mode 100644 index 0000000..b8d2a5b --- /dev/null +++ b/src/gui/kernel/qeventdispatcher_glib_lite.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** 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 QtCore 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 "qeventdispatcher_glib_lite_p.h" + +#include "qapplication.h" + +#include "qplatformdefs.h" +#include "qapplication.h" + +#include <glib.h> +#include "qapplication_p.h" + +#include <qdebug.h> + +QT_BEGIN_NAMESPACE + +struct GUserEventSource +{ + GSource source; + QLiteEventDispatcherGlib *q; +}; + +static gboolean userEventSourcePrepare(GSource *s, gint *timeout) +{ + Q_UNUSED(s) + Q_UNUSED(timeout) + + return QApplicationPrivate::userEventsQueued() > 0; +} + +static gboolean userEventSourceCheck(GSource *source) +{ + return userEventSourcePrepare(source, 0); +} + +static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer) +{ + GUserEventSource * source = reinterpret_cast<GUserEventSource *>(s); + + int i = QApplicationPrivate::userEventsQueued(); + QApplicationPrivate::UserEvent * event; + while (i--) { + event = QApplicationPrivate::getUserEvent(); + + // send through event filter + if (source->q->filterEvent(event)) { + delete event; + continue; + } + QApplicationPrivate::processUserEvent(event); + delete event; + } + + return true; +} + + +static GSourceFuncs userEventSourceFuncs = { + userEventSourcePrepare, + userEventSourceCheck, + userEventSourceDispatch, + NULL, + NULL, + NULL +}; + +QLiteEventDispatcherGlibPrivate::QLiteEventDispatcherGlibPrivate(GMainContext *context) + : QEventDispatcherGlibPrivate(context) +{ + userEventSource = reinterpret_cast<GUserEventSource *>(g_source_new(&userEventSourceFuncs, + sizeof(GUserEventSource))); + userEventSource->q = 0; + g_source_set_can_recurse(&userEventSource->source, true); + g_source_attach(&userEventSource->source, mainContext); +} + + +QLiteEventDispatcherGlib::QLiteEventDispatcherGlib(QObject *parent) + : QEventDispatcherGlib(*new QLiteEventDispatcherGlibPrivate, parent) +{ + Q_D(QLiteEventDispatcherGlib); + d->userEventSource->q = this; +} + +QLiteEventDispatcherGlib::~QLiteEventDispatcherGlib() +{ + Q_D(QLiteEventDispatcherGlib); + + g_source_destroy(&d->userEventSource->source); + g_source_unref(&d->userEventSource->source); + d->userEventSource = 0; +} + +bool QLiteEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags) +{ + return QEventDispatcherGlib::processEvents(flags); +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qeventdispatcher_glib_lite_p.h b/src/gui/kernel/qeventdispatcher_glib_lite_p.h new file mode 100644 index 0000000..6ebdb25 --- /dev/null +++ b/src/gui/kernel/qeventdispatcher_glib_lite_p.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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 QtCore 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 QLITEEVENTDISPATCHER_GLIB_P_H +#define QLITEEVENTDISPATCHER_GLIB_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qeventdispatcher_glib_p.h> + +typedef struct _GMainContext GMainContext; + +QT_BEGIN_NAMESPACE +class QLiteEventDispatcherGlibPrivate; + +class QLiteEventDispatcherGlib : public QEventDispatcherGlib +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QLiteEventDispatcherGlib) + +public: + explicit QLiteEventDispatcherGlib(QObject *parent = 0); + ~QLiteEventDispatcherGlib(); + + bool processEvents(QEventLoop::ProcessEventsFlags flags); +}; + +struct GUserEventSource; + +class QLiteEventDispatcherGlibPrivate : public QEventDispatcherGlibPrivate +{ + Q_DECLARE_PUBLIC(QLiteEventDispatcherGlib) +public: + QLiteEventDispatcherGlibPrivate(GMainContext *context = 0); + GUserEventSource *userEventSource; +}; + + +QT_END_NAMESPACE + +#endif // QLITEEVENTDISPATCHER_GLIB_P_H diff --git a/src/gui/kernel/qeventdispatcher_lite.cpp b/src/gui/kernel/qeventdispatcher_lite.cpp new file mode 100644 index 0000000..39eef96 --- /dev/null +++ b/src/gui/kernel/qeventdispatcher_lite.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** 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 "qplatformdefs.h" +#include "qapplication.h" +#include "qeventdispatcher_lite_p.h" +#include "private/qeventdispatcher_unix_p.h" +#include "qapplication_p.h" +#ifndef QT_NO_THREAD +# include "qmutex.h" +#endif + +#include <errno.h> +QT_BEGIN_NAMESPACE + +QT_USE_NAMESPACE + +class QEventDispatcherLitePrivate : public QEventDispatcherUNIXPrivate +{ + Q_DECLARE_PUBLIC(QEventDispatcherLite) +public: + inline QEventDispatcherLitePrivate() + { } +}; + + +QEventDispatcherLite::QEventDispatcherLite(QObject *parent) + : QEventDispatcherUNIX(*new QEventDispatcherLitePrivate, parent) +{ } + +QEventDispatcherLite::~QEventDispatcherLite() +{ } + + + +//#define ZERO_FOR_THE_MOMENT + +bool QEventDispatcherLite::processEvents(QEventLoop::ProcessEventsFlags flags) +{ + Q_D(QEventDispatcherLite); + int nevents = 0; + + // handle gui and posted events + d->interrupt = false; + QApplication::sendPostedEvents(); + + while (!d->interrupt) { // also flushes output buffer ###can be optimized + QApplicationPrivate::UserEvent *event; + if (!(flags & QEventLoop::ExcludeUserInputEvents) + && QApplicationPrivate::userEventsQueued() > 0) { + // process a pending user input event + event = QApplicationPrivate::getUserEvent(); + } else { + break; + } + + if (filterEvent(event)) { + delete event; + continue; + } + nevents++; + + QApplicationPrivate::processUserEvent(event); + delete event; + } + + if (!d->interrupt) { + if (QEventDispatcherUNIX::processEvents(flags)) + return true; + } + return (nevents > 0); +} + +bool QEventDispatcherLite::hasPendingEvents() +{ + extern uint qGlobalPostedEventsCount(); // from qapplication.cpp + return qGlobalPostedEventsCount() || QApplicationPrivate::userEventsQueued();; +} + +void QEventDispatcherLite::startingUp() +{ + +} + +void QEventDispatcherLite::closingDown() +{ + +} + +void QEventDispatcherLite::flush() +{ + if(qApp) + qApp->sendPostedEvents(); +} + + +int QEventDispatcherLite::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, + timeval *timeout) +{ + return QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout); +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qeventdispatcher_lite_p.h b/src/gui/kernel/qeventdispatcher_lite_p.h new file mode 100644 index 0000000..c098e6c --- /dev/null +++ b/src/gui/kernel/qeventdispatcher_lite_p.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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 QEVENTDISPATCHER_LITE_P_H +#define QEVENTDISPATCHER_LITE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qeventdispatcher_unix_p.h" + +QT_BEGIN_NAMESPACE + +class QEventDispatcherLitePrivate; + +class QEventDispatcherLite : public QEventDispatcherUNIX +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QEventDispatcherLite) + +public: + explicit QEventDispatcherLite(QObject *parent = 0); + ~QEventDispatcherLite(); + + bool processEvents(QEventLoop::ProcessEventsFlags flags); + bool hasPendingEvents(); + + void flush(); + + void startingUp(); + void closingDown(); + +protected: + int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, + timeval *timeout); +}; + +QT_END_NAMESPACE + +#endif // QEVENTDISPATCHER_LITE_P_H diff --git a/src/gui/kernel/qeventdispatcher_qws_p.h b/src/gui/kernel/qeventdispatcher_qws_p.h index 8d8d61c..5a2b016 100644 --- a/src/gui/kernel/qeventdispatcher_qws_p.h +++ b/src/gui/kernel/qeventdispatcher_qws_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE -class QEventDispatcherQWSPrivate; +class QEventDispatcherLitePrivate; class QEventDispatcherQWS : public QEventDispatcherUNIX { diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index 308af6b..363e91f 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -46,7 +46,6 @@ #include <QSocketNotifier> #include <QStringList> #include <QPoint> -#include <QMouseEvent> #include <private/qapplication_p.h> #include <qkbd_qws.h> @@ -100,6 +99,7 @@ void QLinuxInputMouseHandler::readMouseData() { struct ::input_event buffer[32]; int n = 0; + bool posChanged = false; forever { n = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n); @@ -122,28 +122,34 @@ void QLinuxInputMouseHandler::readMouseData() bool unknown = false; if (data->type == EV_ABS) { - if (data->code == ABS_X) { + if (data->code == ABS_X && m_x != data->value) { m_x = data->value; - } else if (data->code == ABS_Y) { + posChanged = true; + } else if (data->code == ABS_Y && m_y != data->value) { m_y = data->value; + posChanged = true; } else { unknown = true; } } else if (data->type == EV_REL) { if (data->code == REL_X) { m_x += data->value; + posChanged = true; } else if (data->code == REL_Y) { m_y += data->value; + posChanged = true; } else if (data->code == ABS_WHEEL) { // vertical scroll // data->value: 1 == up, -1 == down int delta = 120 * data->value; - QWheelEvent we(QPoint(m_x, m_y), QPoint(m_x, m_y), delta, m_buttons, Qt::NoModifier, Qt::Vertical); - QApplicationPrivate::handleWheelEvent(0, we); + QApplicationPrivate::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; - QWheelEvent we(QPoint(m_x, m_y), QPoint(m_x, m_y), delta, m_buttons, Qt::NoModifier, Qt::Horizontal); - QApplicationPrivate::handleWheelEvent(0, we); + QApplicationPrivate::handleWheelEvent(0, QPoint(m_x, m_y), + QPoint(m_x, m_y), + delta, Qt::Horizontal); } else { unknown = true; } @@ -161,17 +167,15 @@ void QLinuxInputMouseHandler::readMouseData() else m_buttons &= ~button; - Qt::KeyboardModifiers modifiers = Qt::NoModifier; //### - QMouseEvent m(data->value ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease, - QPoint(m_x, m_y), QPoint(m_x, m_y), button, m_buttons, modifiers); - QApplicationPrivate::handleMouseEvent(0, m); + QApplicationPrivate::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) + continue; + posChanged = false; QPoint pos(m_x, m_y); - Qt::KeyboardModifiers modifiers = Qt::NoModifier; //### - QMouseEvent m(QEvent::MouseMove, QPoint(m_x, m_y), QPoint(m_x, m_y), - Qt::NoButton, m_buttons, modifiers); - QApplicationPrivate::handleMouseEvent(0, m); + QApplicationPrivate::handleMouseEvent(0, pos, pos, m_buttons); // pos = m_handler->transform(pos); //m_handler->limitToScreen(pos); diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index 17fdd10..8809536 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -109,7 +109,6 @@ 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::MouseButton button = QDirectFbConvenience::mouseButton(event.window.button); Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); QWidget *tlw = tlwMap.value(event.window.window_id); @@ -141,9 +140,7 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) window->UngrabPointer(window); } - //DFB doesn't give keyboardmodifiers on mouseevents - QMouseEvent mouseEvent(type,p,globalPos,button, buttons,(Qt::KeyboardModifiers)0); - QApplicationPrivate::handleMouseEvent(tlw,mouseEvent); + QApplicationPrivate::handleMouseEvent(tlw, p, globalPos, buttons); } void QDirectFbInput::applicationEnd() @@ -156,13 +153,11 @@ void QDirectFbInput::handleWheelEvent(const DFBEvent &event) { QPoint p(event.window.cx, event.window.cy); QPoint globalPos = globalPoint(event); - Qt::MouseButton button = QDirectFbConvenience::mouseButton(event.window.button); - Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); QWidget *tlw = tlwMap.value(event.window.window_id); - QWheelEvent wheelEvent(p,globalPos,event.window.step*120,buttons,Qt::NoModifier,Qt::Vertical); - QApplicationPrivate::handleWheelEvent(tlw,wheelEvent); - + QApplicationPrivate::handleWheelEvent(tlw, p, globalPos, + event.window.step*120, + Qt::Vertical); } void QDirectFbInput::handleKeyEvents(const DFBEvent &event) @@ -171,9 +166,8 @@ void QDirectFbInput::handleKeyEvents(const DFBEvent &event) Qt::Key key = QDirectFbConvenience::keyMap()->value(event.window.key_symbol); Qt::KeyboardModifiers modifiers = QDirectFbConvenience::keyboardModifiers(event.window.modifiers); - QKeyEvent keyEvent(type,key,modifiers,QChar(event.window.key_symbol)); QWidget *tlw = tlwMap.value(event.window.window_id); - QApplicationPrivate::handleKeyEvent(tlw,&keyEvent); + QApplicationPrivate::handleKeyEvent(tlw, type, key, modifiers, QChar(event.window.key_symbol)); } void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index 0afbf2f..26a7675 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -254,9 +254,10 @@ 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)); - QWheelEvent we(QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), delta, - buttons, modifiers, hor ? Qt::Horizontal : Qt::Vertical); - QApplicationPrivate::handleWheelEvent(window(),we); + QApplicationPrivate::handleWheelEvent(window(), + QPoint(e->x, e->y), + QPoint(e->x_root, e->y_root), + delta, hor ? Qt::Horizontal : Qt::Vertical); } return; } @@ -264,18 +265,12 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) } } - if (type == QEvent::MouseButtonPress && mousePoint != QPoint(e->x_root, e->y_root)) { - //we've missed a mouse move event somewhere (maybe because we - //haven't implemented mouse tracking yet); let's synthesize it. - QMouseEvent me(QEvent::MouseMove, QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), - Qt::NoButton, buttons, modifiers); - QApplicationPrivate::handleMouseEvent(window(), me); - } - buttons ^= button; // X event uses state *before*, Qt uses state *after* - QMouseEvent me(type, QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), button, buttons, modifiers); - QApplicationPrivate::handleMouseEvent(window(), me); + QApplicationPrivate::handleMouseEvent(window(), QPoint(e->x, e->y), + QPoint(e->x_root, e->y_root), + buttons); + mousePoint = QPoint(e->x_root, e->y_root); } @@ -587,14 +582,12 @@ void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev) // qDebug() << "lookup: " << hex << keySym << qtcode << "mod" << modifiers; if (qtcode) { - QKeyEvent keyEvent(type, qtcode, modifiers); - QApplicationPrivate::handleKeyEvent(window(), &keyEvent); + QApplicationPrivate::handleKeyEvent(window(), type, qtcode, modifiers); } else if (chars[0]) { int qtcode = chars.toUpper()[0]; //Not exactly right... if (modifiers & Qt::ControlModifier && qtcode < ' ') qtcode = chars[0] + '@'; - QKeyEvent keyEvent(type, qtcode, modifiers, QString::fromLatin1(chars)); - QApplicationPrivate::handleKeyEvent(window(), &keyEvent); + QApplicationPrivate::handleKeyEvent(window(), type, qtcode, modifiers, QString::fromLatin1(chars)); } else { qWarning() << "unknown X keycode" << hex << e->keycode << keySym; } diff --git a/src/plugins/graphicssystems/testlite/x11util.h b/src/plugins/graphicssystems/testlite/x11util.h index db87d92..76e029d 100644 --- a/src/plugins/graphicssystems/testlite/x11util.h +++ b/src/plugins/graphicssystems/testlite/x11util.h @@ -68,7 +68,7 @@ public: unsigned long whitePixel() { return WhitePixel(display, screen); } bool handleEvent(XEvent *xe); - QImage grabWindow(Window w, int x, int y, int w, int h); + QImage grabWindow(Window window, int x, int y, int w, int h); public slots: void eventDispatcher(); diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp index 9576d10..490ca02 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.cpp +++ b/src/plugins/graphicssystems/vnc/qvncserver.cpp @@ -399,10 +399,6 @@ void QVNCServer::init(uint port) qvnc_cursor = 0; #endif encoder = 0; - - eventTimer.setInterval(0); - eventTimer.setSingleShot(true); - connect(&eventTimer, SIGNAL(timeout()), this, SLOT(sendInputEvents())); } QVNCServer::~QVNCServer() @@ -833,35 +829,6 @@ static bool buttonChange(Qt::MouseButtons before, Qt::MouseButtons after, Qt::Mo return false; } -void QVNCServer::sendInputEvents() -{ - EventPair pair; - QMouseEvent *me; - QKeyEvent *ke; - QWheelEvent *we; - - while(!eventList.isEmpty()) { - pair = eventList.takeFirst(); - switch(pair.first) { - case MouseEvent: - me = static_cast<QMouseEvent *>(pair.second); - QApplicationPrivate::handleMouseEvent(0, *me); - delete me; - break; - case KeyboardEvent: - ke = static_cast<QKeyEvent *>(pair.second); - QApplicationPrivate::handleKeyEvent(0, ke); - delete ke; - break; - case WheelEvent: - we = static_cast<QWheelEvent *>(pair.second); - QApplicationPrivate::handleWheelEvent(0, *we); - delete we; - break; - } - } -} - void QVNCServer::pointerEvent() { QRfbPointerEvent ev; @@ -870,7 +837,6 @@ void QVNCServer::pointerEvent() // QWSServer::sendMouseEvent(offset + QPoint(ev.x, ev.y), ev.buttons); - EventPair pair; //qDebug() << "pointerEvent" << ev.x << ev.y << hex << ev.buttons; if (ev.wheelDirection == ev.WheelNone) { QEvent::Type type = QEvent::MouseMove; @@ -878,10 +844,7 @@ void QVNCServer::pointerEvent() bool isPress; if (buttonChange(buttons, ev.buttons, &button, &isPress)) type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; - QMouseEvent * me = new QMouseEvent(type, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), button, ev.buttons, keymod); - pair.first = MouseEvent; - pair.second = me; - buttons = ev.buttons; + QApplicationPrivate::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; @@ -890,13 +853,8 @@ void QVNCServer::pointerEvent() else orientation = Qt::Vertical; int delta = 120 * ((ev.wheelDirection == ev.WheelLeft || ev.wheelDirection == ev.WheelUp) ? 1 : -1); - QWheelEvent *we = new QWheelEvent(QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), delta, buttons, keymod, orientation); - pair.first = WheelEvent; - pair.second = we; + QApplicationPrivate::handleWheelEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), delta, orientation); } - eventList.append(pair); - if (!eventTimer.isActive()) - eventTimer.start(); handleMsg = false; } } @@ -921,13 +879,7 @@ void QVNCServer::keyEvent() QString str; if (ev.unicode && ev.unicode != 0xffff) str = QString(ev.unicode); - QKeyEvent *keyEvent = new QKeyEvent(type, ev.keycode, keymod, str); - EventPair pair; - pair.first = KeyboardEvent; - pair.second = keyEvent; - eventList.append(pair); - if (!eventTimer.isActive()) - eventTimer.start(); + QApplicationPrivate::handleKeyEvent(0, type, ev.keycode, keymod, str); } handleMsg = false; } diff --git a/src/plugins/graphicssystems/vnc/qvncserver.h b/src/plugins/graphicssystems/vnc/qvncserver.h index 7532cb4..4fcdbae 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.h +++ b/src/plugins/graphicssystems/vnc/qvncserver.h @@ -526,11 +526,6 @@ private: QRfbEncoder *encoder; QVNCCursor *cursor; - - enum EventType { MouseEvent, KeyboardEvent, WheelEvent }; - QTimer eventTimer; - typedef QPair<EventType, QInputEvent *> EventPair; - QList<EventPair> eventList; }; |