Propagate the source of mouse events
Set the source for mouse events which were caused by other mouse events. Change-Id: Ifca1648883ef2b94bb317ed9340759475d350146 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
This commit is contained in:
parent
fb9eca8c9c
commit
7b8aaf04f6
@ -270,6 +270,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
|
||||
QMouseEvent mouseEvent(type, pos, receiver->mapTo(receiver->topLevelWidget(), pos.toPoint()),
|
||||
receiver->mapToGlobal(pos.toPoint()),
|
||||
event->button(), event->buttons(), event->modifiers());
|
||||
QGuiApplicationPrivate::setMouseEventSource(&mouseEvent, event->source());
|
||||
|
||||
QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
|
||||
QApplicationPrivate::sendMouseEvent(receiver, &mouseEvent, alienWidget, widget,
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include <qstyleditemdelegate.h>
|
||||
#include <private/qabstractitemview_p.h>
|
||||
#include <private/qabstractitemmodel_p.h>
|
||||
#include <private/qguiapplication_p.h>
|
||||
#ifndef QT_NO_ACCESSIBILITY
|
||||
#include <qaccessible.h>
|
||||
#endif
|
||||
@ -1884,6 +1885,7 @@ void QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
QMouseEvent me(QEvent::MouseButtonPress,
|
||||
event->localPos(), event->windowPos(), event->screenPos(),
|
||||
event->button(), event->buttons(), event->modifiers());
|
||||
QGuiApplicationPrivate::setMouseEventSource(&me, event->source());
|
||||
mousePressEvent(&me);
|
||||
return;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "qgraphicssceneevent.h"
|
||||
#include "qgraphicsview.h"
|
||||
#include "qscroller.h"
|
||||
#include "private/qapplication_p.h"
|
||||
#include "private/qevent_p.h"
|
||||
#include "private/qflickgesture_p.h"
|
||||
#include "qdebug.h"
|
||||
@ -65,7 +66,9 @@ static QMouseEvent *copyMouseEvent(QEvent *e)
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::MouseMove: {
|
||||
QMouseEvent *me = static_cast<QMouseEvent *>(e);
|
||||
return new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(), me->button(), me->buttons(), me->modifiers());
|
||||
QMouseEvent *cme = new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(), me->button(), me->buttons(), me->modifiers());
|
||||
QGuiApplicationPrivate::setMouseEventSource(cme, me->source());
|
||||
return cme;
|
||||
}
|
||||
#ifndef QT_NO_GRAPHICSVIEW
|
||||
case QEvent::GraphicsSceneMousePress:
|
||||
@ -75,7 +78,9 @@ static QMouseEvent *copyMouseEvent(QEvent *e)
|
||||
#if 1
|
||||
QEvent::Type met = me->type() == QEvent::GraphicsSceneMousePress ? QEvent::MouseButtonPress :
|
||||
(me->type() == QEvent::GraphicsSceneMouseRelease ? QEvent::MouseButtonRelease : QEvent::MouseMove);
|
||||
return new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers());
|
||||
QMouseEvent *cme = new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers());
|
||||
QGuiApplicationPrivate::setMouseEventSource(cme, me->source());
|
||||
return cme;
|
||||
#else
|
||||
QGraphicsSceneMouseEvent *copy = new QGraphicsSceneMouseEvent(me->type());
|
||||
copy->setPos(me->pos());
|
||||
@ -113,6 +118,7 @@ private:
|
||||
, sendingEvent(false)
|
||||
, mouseButton(Qt::NoButton)
|
||||
, mouseTarget(0)
|
||||
, mouseEventSource(Qt::MouseEventNotSynthesized)
|
||||
{ }
|
||||
|
||||
static PressDelayHandler *inst;
|
||||
@ -148,6 +154,7 @@ public:
|
||||
pressDelayTimer = startTimer(delay);
|
||||
mouseTarget = QApplication::widgetAt(pressDelayEvent->globalPos());
|
||||
mouseButton = pressDelayEvent->button();
|
||||
mouseEventSource = pressDelayEvent->source();
|
||||
qFGDebug() << "QFG: consuming/delaying mouse press";
|
||||
} else {
|
||||
qFGDebug() << "QFG: NOT consuming/delaying mouse press";
|
||||
@ -234,6 +241,7 @@ public:
|
||||
QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, farFarAway,
|
||||
mouseButton, QApplication::mouseButtons() & ~mouseButton,
|
||||
QApplication::keyboardModifiers());
|
||||
QGuiApplicationPrivate::setMouseEventSource(&re, mouseEventSource);
|
||||
sendMouseEvent(&re, RegrabMouseAfterwards);
|
||||
// don't clear the mouseTarget just yet, since we need to explicitly ungrab the mouse on release!
|
||||
}
|
||||
@ -284,6 +292,7 @@ protected:
|
||||
QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()),
|
||||
mouseTarget->topLevelWidget()->mapFromGlobal(me->globalPos()), me->screenPos(),
|
||||
me->button(), me->buttons(), me->modifiers());
|
||||
QGuiApplicationPrivate::setMouseEventSource(©, me->source());
|
||||
qt_sendSpontaneousEvent(mouseTarget, ©);
|
||||
}
|
||||
|
||||
@ -309,6 +318,7 @@ private:
|
||||
bool sendingEvent;
|
||||
Qt::MouseButton mouseButton;
|
||||
QPointer<QWidget> mouseTarget;
|
||||
Qt::MouseEventSource mouseEventSource;
|
||||
};
|
||||
|
||||
|
||||
|
@ -984,6 +984,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
|
||||
if(e->type() != QEvent::MouseButtonRelease || mouseDown == caused) {
|
||||
QMouseEvent new_e(e->type(), cpos, caused->mapTo(caused->topLevelWidget(), cpos), e->screenPos(),
|
||||
e->button(), e->buttons(), e->modifiers());
|
||||
QGuiApplicationPrivate::setMouseEventSource(&new_e, e->source());
|
||||
QApplication::sendEvent(caused, &new_e);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user