diff options
author | Jeremy Katz <jeremy.katz@nokia.com> | 2010-01-26 13:52:09 (GMT) |
---|---|---|
committer | Jeremy Katz <jeremy.katz@nokia.com> | 2010-01-26 13:52:09 (GMT) |
commit | 33a5ecd4908690d6a8366d8f7384ad1e8cf86f92 (patch) | |
tree | f623030733f4297b41c664c8a981aa14c385a036 /src/plugins/graphicssystems | |
parent | f0f1d8588892ba94301ecad2aa4495e9bfa364ae (diff) | |
download | Qt-33a5ecd4908690d6a8366d8f7384ad1e8cf86f92.zip Qt-33a5ecd4908690d6a8366d8f7384ad1e8cf86f92.tar.gz Qt-33a5ecd4908690d6a8366d8f7384ad1e8cf86f92.tar.bz2 |
queue user mouse, wheel, and keyboard input events
For plugins: testlite, minimaldfb, vnc, LinuxInput[Mouse|Keyboard]
Diffstat (limited to 'src/plugins/graphicssystems')
5 files changed, 19 insertions, 85 deletions
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; }; |