Replace calls to deprecated QEvent accessor functions

Many of these were generated by clazy using the new qevent-accessors check.

Change-Id: Ie17af17f50fdc9f47d7859d267c14568cc350fd0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Shawn Rutledge 2020-06-04 18:07:06 +02:00
parent 24e52c10de
commit a061a64642
99 changed files with 742 additions and 742 deletions

View File

@ -190,7 +190,7 @@ void MandelbrotWidget::wheelEvent(QWheelEvent *event)
void MandelbrotWidget::mousePressEvent(QMouseEvent *event) void MandelbrotWidget::mousePressEvent(QMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)
lastDragPos = event->pos(); lastDragPos = event->position().toPoint();
} }
//! [13] //! [13]
@ -198,8 +198,8 @@ void MandelbrotWidget::mousePressEvent(QMouseEvent *event)
void MandelbrotWidget::mouseMoveEvent(QMouseEvent *event) void MandelbrotWidget::mouseMoveEvent(QMouseEvent *event)
{ {
if (event->buttons() & Qt::LeftButton) { if (event->buttons() & Qt::LeftButton) {
pixmapOffset += event->pos() - lastDragPos; pixmapOffset += event->position().toPoint() - lastDragPos;
lastDragPos = event->pos(); lastDragPos = event->position().toPoint();
update(); update();
} }
} }
@ -209,7 +209,7 @@ void MandelbrotWidget::mouseMoveEvent(QMouseEvent *event)
void MandelbrotWidget::mouseReleaseEvent(QMouseEvent *event) void MandelbrotWidget::mouseReleaseEvent(QMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
pixmapOffset += event->pos() - lastDragPos; pixmapOffset += event->position().toPoint() - lastDragPos;
lastDragPos = QPoint(); lastDragPos = QPoint();
const auto pixmapSize = pixmap.size() / pixmap.devicePixelRatioF(); const auto pixmapSize = pixmap.size() / pixmap.devicePixelRatioF();

View File

@ -158,14 +158,14 @@ void Flickable::handleMousePress(QMouseEvent *event)
case FlickablePrivate::Steady: case FlickablePrivate::Steady:
event->accept(); event->accept();
d->state = FlickablePrivate::Pressed; d->state = FlickablePrivate::Pressed;
d->pressPos = event->pos(); d->pressPos = event->position().toPoint();
break; break;
case FlickablePrivate::AutoScroll: case FlickablePrivate::AutoScroll:
event->accept(); event->accept();
d->state = FlickablePrivate::Stop; d->state = FlickablePrivate::Stop;
d->speed = QPoint(0, 0); d->speed = QPoint(0, 0);
d->pressPos = event->pos(); d->pressPos = event->position().toPoint();
d->offset = scrollOffset(); d->offset = scrollOffset();
d->ticker->stop(); d->ticker->stop();
break; break;
@ -206,14 +206,14 @@ void Flickable::handleMouseRelease(QMouseEvent *event)
case FlickablePrivate::ManualScroll: case FlickablePrivate::ManualScroll:
event->accept(); event->accept();
delta = event->pos() - d->pressPos; delta = event->position().toPoint() - d->pressPos;
if (d->timeStamp.elapsed() > 100) { if (d->timeStamp.elapsed() > 100) {
d->timeStamp.start(); d->timeStamp.start();
d->speed = delta - d->delta; d->speed = delta - d->delta;
d->delta = delta; d->delta = delta;
} }
d->offset = scrollOffset(); d->offset = scrollOffset();
d->pressPos = event->pos(); d->pressPos = event->position().toPoint();
if (d->speed == QPoint(0, 0)) { if (d->speed == QPoint(0, 0)) {
d->state = FlickablePrivate::Steady; d->state = FlickablePrivate::Steady;
} else { } else {
@ -250,20 +250,20 @@ void Flickable::handleMouseMove(QMouseEvent *event)
case FlickablePrivate::Pressed: case FlickablePrivate::Pressed:
case FlickablePrivate::Stop: case FlickablePrivate::Stop:
delta = event->pos() - d->pressPos; delta = event->position().toPoint() - d->pressPos;
if (delta.x() > d->threshold || delta.x() < -d->threshold || if (delta.x() > d->threshold || delta.x() < -d->threshold ||
delta.y() > d->threshold || delta.y() < -d->threshold) { delta.y() > d->threshold || delta.y() < -d->threshold) {
d->timeStamp.start(); d->timeStamp.start();
d->state = FlickablePrivate::ManualScroll; d->state = FlickablePrivate::ManualScroll;
d->delta = QPoint(0, 0); d->delta = QPoint(0, 0);
d->pressPos = event->pos(); d->pressPos = event->position().toPoint();
event->accept(); event->accept();
} }
break; break;
case FlickablePrivate::ManualScroll: case FlickablePrivate::ManualScroll:
event->accept(); event->accept();
delta = event->pos() - d->pressPos; delta = event->position().toPoint() - d->pressPos;
setScrollOffset(d->offset - delta); setScrollOffset(d->offset - delta);
if (d->timeStamp.elapsed() > 100) { if (d->timeStamp.elapsed() > 100) {
d->timeStamp.start(); d->timeStamp.start();

View File

@ -185,7 +185,7 @@ protected:
return; return;
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
int y = event->pos().y() + m_offset; int y = event->position().toPoint().y() + m_offset;
int i = y / m_height; int i = y / m_height;
if (i != m_highlight) { if (i != m_highlight) {
m_highlight = i; m_highlight = i;

View File

@ -209,7 +209,7 @@ void LightMaps::mousePressEvent(QMouseEvent *event)
if (event->buttons() != Qt::LeftButton) if (event->buttons() != Qt::LeftButton)
return; return;
pressed = snapped = true; pressed = snapped = true;
pressPos = dragPos = event->pos(); pressPos = dragPos = event->position().toPoint();
tapTimer.stop(); tapTimer.stop();
tapTimer.start(HOLD_TIME, this); tapTimer.start(HOLD_TIME, this);
} }
@ -220,13 +220,13 @@ void LightMaps::mouseMoveEvent(QMouseEvent *event)
return; return;
if (!zoomed) { if (!zoomed) {
if (!pressed || !snapped) { if (!pressed || !snapped) {
QPoint delta = event->pos() - pressPos; QPoint delta = event->position().toPoint() - pressPos;
pressPos = event->pos(); pressPos = event->position().toPoint();
m_normalMap->pan(delta); m_normalMap->pan(delta);
return; return;
} else { } else {
const int threshold = 10; const int threshold = 10;
QPoint delta = event->pos() - pressPos; QPoint delta = event->position().toPoint() - pressPos;
if (snapped) { if (snapped) {
snapped &= delta.x() < threshold; snapped &= delta.x() < threshold;
snapped &= delta.y() < threshold; snapped &= delta.y() < threshold;
@ -237,7 +237,7 @@ void LightMaps::mouseMoveEvent(QMouseEvent *event)
tapTimer.stop(); tapTimer.stop();
} }
} else { } else {
dragPos = event->pos(); dragPos = event->position().toPoint();
update(); update();
} }
} }

View File

@ -336,15 +336,15 @@ protected:
} }
void mousePressEvent(QMouseEvent *event) { void mousePressEvent(QMouseEvent *event) {
qreal dx = centerPad.x() - event->pos().x(); qreal dx = centerPad.x() - event->position().toPoint().x();
qreal dy = centerPad.y() - event->pos().y(); qreal dy = centerPad.y() - event->position().toPoint().y();
angleDelta = dx * 2 * M_PI / width(); angleDelta = dx * 2 * M_PI / width();
moveDelta = dy * 10 / height(); moveDelta = dy * 10 / height();
} }
void mouseMoveEvent(QMouseEvent *event) { void mouseMoveEvent(QMouseEvent *event) {
qreal dx = centerPad.x() - event->pos().x(); qreal dx = centerPad.x() - event->position().toPoint().x();
qreal dy = centerPad.y() - event->pos().y(); qreal dy = centerPad.y() - event->position().toPoint().y();
angleDelta = dx * 2 * M_PI / width(); angleDelta = dx * 2 * M_PI / width();
moveDelta = dy * 10 / height(); moveDelta = dy * 10 / height();
} }

View File

@ -68,13 +68,13 @@ MainWidget::~MainWidget()
void MainWidget::mousePressEvent(QMouseEvent *e) void MainWidget::mousePressEvent(QMouseEvent *e)
{ {
// Save mouse press position // Save mouse press position
mousePressPosition = QVector2D(e->localPos()); mousePressPosition = QVector2D(e->position());
} }
void MainWidget::mouseReleaseEvent(QMouseEvent *e) void MainWidget::mouseReleaseEvent(QMouseEvent *e)
{ {
// Mouse release position - mouse press position // Mouse release position - mouse press position
QVector2D diff = QVector2D(e->localPos()) - mousePressPosition; QVector2D diff = QVector2D(e->position()) - mousePressPosition;
// Rotation axis is perpendicular to the mouse position difference // Rotation axis is perpendicular to the mouse position difference
// vector // vector

View File

@ -284,13 +284,13 @@ void GLWidget::resizeGL(int w, int h)
void GLWidget::mousePressEvent(QMouseEvent *event) void GLWidget::mousePressEvent(QMouseEvent *event)
{ {
m_lastPos = event->pos(); m_lastPos = event->position().toPoint();
} }
void GLWidget::mouseMoveEvent(QMouseEvent *event) void GLWidget::mouseMoveEvent(QMouseEvent *event)
{ {
int dx = event->x() - m_lastPos.x(); int dx = event->position().toPoint().x() - m_lastPos.x();
int dy = event->y() - m_lastPos.y(); int dy = event->position().toPoint().y() - m_lastPos.y();
if (event->buttons() & Qt::LeftButton) { if (event->buttons() & Qt::LeftButton) {
setXRotation(m_xRot + 8 * dy); setXRotation(m_xRot + 8 * dy);
@ -299,5 +299,5 @@ void GLWidget::mouseMoveEvent(QMouseEvent *event)
setXRotation(m_xRot + 8 * dy); setXRotation(m_xRot + 8 * dy);
setZRotation(m_zRot + 8 * dx); setZRotation(m_zRot + 8 * dx);
} }
m_lastPos = event->pos(); m_lastPos = event->position().toPoint();
} }

View File

@ -164,20 +164,20 @@ void GLWidget::resizeGL(int width, int height)
void GLWidget::mousePressEvent(QMouseEvent *event) void GLWidget::mousePressEvent(QMouseEvent *event)
{ {
lastPos = event->pos(); lastPos = event->position().toPoint();
} }
void GLWidget::mouseMoveEvent(QMouseEvent *event) void GLWidget::mouseMoveEvent(QMouseEvent *event)
{ {
int dx = event->x() - lastPos.x(); int dx = event->position().toPoint().x() - lastPos.x();
int dy = event->y() - lastPos.y(); int dy = event->position().toPoint().y() - lastPos.y();
if (event->buttons() & Qt::LeftButton) { if (event->buttons() & Qt::LeftButton) {
rotateBy(8 * dy, 8 * dx, 0); rotateBy(8 * dy, 8 * dx, 0);
} else if (event->buttons() & Qt::RightButton) { } else if (event->buttons() & Qt::RightButton) {
rotateBy(8 * dy, 0, 8 * dx); rotateBy(8 * dy, 0, 8 * dx);
} }
lastPos = event->pos(); lastPos = event->position().toPoint();
} }
void GLWidget::mouseReleaseEvent(QMouseEvent * /* event */) void GLWidget::mouseReleaseEvent(QMouseEvent * /* event */)

View File

@ -106,7 +106,7 @@ void Window::initialize()
void Window::mousePressEvent(QMouseEvent *event) void Window::mousePressEvent(QMouseEvent *event)
{ {
m_lastPos = event->pos(); m_lastPos = event->position().toPoint();
} }
void Window::mouseMoveEvent(QMouseEvent *event) void Window::mouseMoveEvent(QMouseEvent *event)
@ -114,8 +114,8 @@ void Window::mouseMoveEvent(QMouseEvent *event)
if (m_lastPos != QPoint(-1, -1)) { if (m_lastPos != QPoint(-1, -1)) {
QPainter p(&m_image); QPainter p(&m_image);
p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::Antialiasing);
p.drawLine(m_lastPos, event->pos()); p.drawLine(m_lastPos, event->position().toPoint());
m_lastPos = event->pos(); m_lastPos = event->position().toPoint();
scheduleRender(); scheduleRender();
} }
@ -126,7 +126,7 @@ void Window::mouseReleaseEvent(QMouseEvent *event)
if (m_lastPos != QPoint(-1, -1)) { if (m_lastPos != QPoint(-1, -1)) {
QPainter p(&m_image); QPainter p(&m_image);
p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::Antialiasing);
p.drawLine(m_lastPos, event->pos()); p.drawLine(m_lastPos, event->position().toPoint());
m_lastPos = QPoint(-1, -1); m_lastPos = QPoint(-1, -1);
scheduleRender(); scheduleRender();

View File

@ -127,7 +127,7 @@ void Images::open()
} }
} }
std::function<QImage(const QString&)> scale = [imageSize](const QString &imageFileName) { std::function<QImage(const QString&)> scale = [](const QString &imageFileName) {
QImage image(imageFileName); QImage image(imageFileName);
return image.scaled(QSize(imageSize, imageSize), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); return image.scaled(QSize(imageSize, imageSize), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}; };

View File

@ -116,7 +116,7 @@ bool BookDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
if (event->type() == QEvent::MouseButtonPress) { if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
int stars = qBound(0, int(0.7 + qreal(mouseEvent->pos().x() int stars = qBound(0, int(0.7 + qreal(mouseEvent->position().toPoint().x()
- option.rect.x()) / star.width()), 5); - option.rect.x()) / star.width()), 5);
model->setData(index, QVariant(stars)); model->setData(index, QVariant(stars));
// So that the selection can change: // So that the selection can change:

View File

@ -115,7 +115,7 @@ void View::addItems()
//! [5] //! [5]
void View::mouseReleaseEvent(QMouseEvent *event) void View::mouseReleaseEvent(QMouseEvent *event)
{ {
if (QGraphicsItem *item = itemAt(event->pos())) { if (QGraphicsItem *item = itemAt(event->position().toPoint())) {
if (ImageItem *image = qgraphicsitem_cast<ImageItem *>(item)) if (ImageItem *image = qgraphicsitem_cast<ImageItem *>(item))
showInformation(image); showInformation(image);
} }

View File

@ -82,7 +82,7 @@ void VulkanWindow::meshSwitched(bool enable)
void VulkanWindow::mousePressEvent(QMouseEvent *e) void VulkanWindow::mousePressEvent(QMouseEvent *e)
{ {
m_pressed = true; m_pressed = true;
m_lastPos = e->pos(); m_lastPos = e->position().toPoint();
} }
void VulkanWindow::mouseReleaseEvent(QMouseEvent *) void VulkanWindow::mouseReleaseEvent(QMouseEvent *)
@ -95,8 +95,8 @@ void VulkanWindow::mouseMoveEvent(QMouseEvent *e)
if (!m_pressed) if (!m_pressed)
return; return;
int dx = e->pos().x() - m_lastPos.x(); int dx = e->position().toPoint().x() - m_lastPos.x();
int dy = e->pos().y() - m_lastPos.y(); int dy = e->position().toPoint().y() - m_lastPos.y();
if (dy) if (dy)
m_renderer->pitch(dy / 10.0f); m_renderer->pitch(dy / 10.0f);
@ -104,7 +104,7 @@ void VulkanWindow::mouseMoveEvent(QMouseEvent *e)
if (dx) if (dx)
m_renderer->yaw(dx / 10.0f); m_renderer->yaw(dx / 10.0f);
m_lastPos = e->pos(); m_lastPos = e->position().toPoint();
} }
void VulkanWindow::keyPressEvent(QKeyEvent *e) void VulkanWindow::keyPressEvent(QKeyEvent *e)

View File

@ -120,7 +120,7 @@ void DragWidget::dropEvent(QDropEvent *event)
QLabel *newIcon = new QLabel(this); QLabel *newIcon = new QLabel(this);
newIcon->setPixmap(pixmap); newIcon->setPixmap(pixmap);
newIcon->move(event->pos() - offset); newIcon->move(event->position().toPoint() - offset);
newIcon->show(); newIcon->show();
newIcon->setAttribute(Qt::WA_DeleteOnClose); newIcon->setAttribute(Qt::WA_DeleteOnClose);
@ -138,7 +138,7 @@ void DragWidget::dropEvent(QDropEvent *event)
//! [1] //! [1]
void DragWidget::mousePressEvent(QMouseEvent *event) void DragWidget::mousePressEvent(QMouseEvent *event)
{ {
QLabel *child = static_cast<QLabel*>(childAt(event->pos())); QLabel *child = static_cast<QLabel*>(childAt(event->position().toPoint()));
if (!child) if (!child)
return; return;
@ -146,7 +146,7 @@ void DragWidget::mousePressEvent(QMouseEvent *event)
QByteArray itemData; QByteArray itemData;
QDataStream dataStream(&itemData, QIODevice::WriteOnly); QDataStream dataStream(&itemData, QIODevice::WriteOnly);
dataStream << pixmap << QPoint(event->pos() - child->pos()); dataStream << pixmap << QPoint(event->position().toPoint() - child->pos());
//! [1] //! [1]
//! [2] //! [2]
@ -158,7 +158,7 @@ void DragWidget::mousePressEvent(QMouseEvent *event)
QDrag *drag = new QDrag(this); QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData); drag->setMimeData(mimeData);
drag->setPixmap(pixmap); drag->setPixmap(pixmap);
drag->setHotSpot(event->pos() - child->pos()); drag->setHotSpot(event->position().toPoint() - child->pos());
//! [3] //! [3]
QPixmap tempPixmap = pixmap; QPixmap tempPixmap = pixmap;

View File

@ -114,7 +114,7 @@ void DragWidget::dropEvent(QDropEvent *event)
const QMimeData *mime = event->mimeData(); const QMimeData *mime = event->mimeData();
QStringList pieces = mime->text().split(QRegularExpression(QStringLiteral("\\s+")), QStringList pieces = mime->text().split(QRegularExpression(QStringLiteral("\\s+")),
Qt::SkipEmptyParts); Qt::SkipEmptyParts);
QPoint position = event->pos(); QPoint position = event->position().toPoint();
QPoint hotSpot; QPoint hotSpot;
QByteArrayList hotSpotPos = mime->data(hotSpotMimeDataKey()).split(' '); QByteArrayList hotSpotPos = mime->data(hotSpotMimeDataKey()).split(' ');
@ -149,11 +149,11 @@ void DragWidget::dropEvent(QDropEvent *event)
void DragWidget::mousePressEvent(QMouseEvent *event) void DragWidget::mousePressEvent(QMouseEvent *event)
{ {
QLabel *child = qobject_cast<QLabel*>(childAt(event->pos())); QLabel *child = qobject_cast<QLabel*>(childAt(event->position().toPoint()));
if (!child) if (!child)
return; return;
QPoint hotSpot = event->pos() - child->pos(); QPoint hotSpot = event->position().toPoint() - child->pos();
QMimeData *mimeData = new QMimeData; QMimeData *mimeData = new QMimeData;
mimeData->setText(child->text()); mimeData->setText(child->text());

View File

@ -151,7 +151,7 @@ void DragWidget::dropEvent(QDropEvent *event)
//! [10] //! [10]
//! [11] //! [11]
DragLabel *newLabel = new DragLabel(text, this); DragLabel *newLabel = new DragLabel(text, this);
newLabel->move(event->pos() - offset); newLabel->move(event->position().toPoint() - offset);
newLabel->show(); newLabel->show();
newLabel->setAttribute(Qt::WA_DeleteOnClose); newLabel->setAttribute(Qt::WA_DeleteOnClose);
@ -165,7 +165,7 @@ void DragWidget::dropEvent(QDropEvent *event)
} else if (event->mimeData()->hasText()) { } else if (event->mimeData()->hasText()) {
QStringList pieces = event->mimeData()->text().split( QStringList pieces = event->mimeData()->text().split(
QRegularExpression(QStringLiteral("\\s+")), Qt::SkipEmptyParts); QRegularExpression(QStringLiteral("\\s+")), Qt::SkipEmptyParts);
QPoint position = event->pos(); QPoint position = event->position().toPoint();
for (const QString &piece : pieces) { for (const QString &piece : pieces) {
DragLabel *newLabel = new DragLabel(piece, this); DragLabel *newLabel = new DragLabel(piece, this);
@ -188,11 +188,11 @@ void DragWidget::mousePressEvent(QMouseEvent *event)
{ {
//! [13] //! [13]
//! [14] //! [14]
DragLabel *child = static_cast<DragLabel*>(childAt(event->pos())); DragLabel *child = static_cast<DragLabel*>(childAt(event->position().toPoint()));
if (!child) if (!child)
return; return;
QPoint hotSpot = event->pos() - child->pos(); QPoint hotSpot = event->position().toPoint() - child->pos();
QByteArray itemData; QByteArray itemData;
QDataStream dataStream(&itemData, QIODevice::WriteOnly); QDataStream dataStream(&itemData, QIODevice::WriteOnly);

View File

@ -90,12 +90,12 @@ void PuzzleWidget::dragLeaveEvent(QDragLeaveEvent *event)
void PuzzleWidget::dragMoveEvent(QDragMoveEvent *event) void PuzzleWidget::dragMoveEvent(QDragMoveEvent *event)
{ {
QRect updateRect = highlightedRect.united(targetSquare(event->pos())); QRect updateRect = highlightedRect.united(targetSquare(event->position().toPoint()));
if (event->mimeData()->hasFormat(PiecesList::puzzleMimeType()) if (event->mimeData()->hasFormat(PiecesList::puzzleMimeType())
&& findPiece(targetSquare(event->pos())) == -1) { && findPiece(targetSquare(event->position().toPoint())) == -1) {
highlightedRect = targetSquare(event->pos()); highlightedRect = targetSquare(event->position().toPoint());
event->setDropAction(Qt::MoveAction); event->setDropAction(Qt::MoveAction);
event->accept(); event->accept();
} else { } else {
@ -109,12 +109,12 @@ void PuzzleWidget::dragMoveEvent(QDragMoveEvent *event)
void PuzzleWidget::dropEvent(QDropEvent *event) void PuzzleWidget::dropEvent(QDropEvent *event)
{ {
if (event->mimeData()->hasFormat(PiecesList::puzzleMimeType()) if (event->mimeData()->hasFormat(PiecesList::puzzleMimeType())
&& findPiece(targetSquare(event->pos())) == -1) { && findPiece(targetSquare(event->position().toPoint())) == -1) {
QByteArray pieceData = event->mimeData()->data(PiecesList::puzzleMimeType()); QByteArray pieceData = event->mimeData()->data(PiecesList::puzzleMimeType());
QDataStream dataStream(&pieceData, QIODevice::ReadOnly); QDataStream dataStream(&pieceData, QIODevice::ReadOnly);
Piece piece; Piece piece;
piece.rect = targetSquare(event->pos()); piece.rect = targetSquare(event->position().toPoint());
dataStream >> piece.pixmap >> piece.location; dataStream >> piece.pixmap >> piece.location;
pieces.append(piece); pieces.append(piece);
@ -147,7 +147,7 @@ int PuzzleWidget::findPiece(const QRect &pieceRect) const
void PuzzleWidget::mousePressEvent(QMouseEvent *event) void PuzzleWidget::mousePressEvent(QMouseEvent *event)
{ {
QRect square = targetSquare(event->pos()); QRect square = targetSquare(event->position().toPoint());
const int found = findPiece(square); const int found = findPiece(square);
if (found == -1) if (found == -1)
@ -170,12 +170,12 @@ void PuzzleWidget::mousePressEvent(QMouseEvent *event)
QDrag *drag = new QDrag(this); QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData); drag->setMimeData(mimeData);
drag->setHotSpot(event->pos() - square.topLeft()); drag->setHotSpot(event->position().toPoint() - square.topLeft());
drag->setPixmap(piece.pixmap); drag->setPixmap(piece.pixmap);
if (drag->exec(Qt::MoveAction) != Qt::MoveAction) { if (drag->exec(Qt::MoveAction) != Qt::MoveAction) {
pieces.insert(found, piece); pieces.insert(found, piece);
update(targetSquare(event->pos())); update(targetSquare(event->position().toPoint()));
if (piece.location == square.topLeft() / pieceSize()) if (piece.location == square.topLeft() / pieceSize())
inPlace++; inPlace++;

View File

@ -152,7 +152,7 @@ void BlurPicker::resizeEvent(QResizeEvent * /* event */)
void BlurPicker::mousePressEvent(QMouseEvent *event) void BlurPicker::mousePressEvent(QMouseEvent *event)
{ {
int delta = 0; int delta = 0;
if(event->x() > (width() / 2)) if (event->position().x() > (width() / 2))
{ {
delta = 1; delta = 1;
} }

View File

@ -251,7 +251,7 @@ int PieView::horizontalOffset() const
void PieView::mousePressEvent(QMouseEvent *event) void PieView::mousePressEvent(QMouseEvent *event)
{ {
QAbstractItemView::mousePressEvent(event); QAbstractItemView::mousePressEvent(event);
origin = event->pos(); origin = event->position().toPoint();
if (!rubberBand) if (!rubberBand)
rubberBand = new QRubberBand(QRubberBand::Rectangle, viewport()); rubberBand = new QRubberBand(QRubberBand::Rectangle, viewport());
rubberBand->setGeometry(QRect(origin, QSize())); rubberBand->setGeometry(QRect(origin, QSize()));
@ -261,7 +261,7 @@ void PieView::mousePressEvent(QMouseEvent *event)
void PieView::mouseMoveEvent(QMouseEvent *event) void PieView::mouseMoveEvent(QMouseEvent *event)
{ {
if (rubberBand) if (rubberBand)
rubberBand->setGeometry(QRect(origin, event->pos()).normalized()); rubberBand->setGeometry(QRect(origin, event->position().toPoint()).normalized());
QAbstractItemView::mouseMoveEvent(event); QAbstractItemView::mouseMoveEvent(event);
} }

View File

@ -86,12 +86,12 @@ void PuzzleWidget::dragLeaveEvent(QDragLeaveEvent *event)
void PuzzleWidget::dragMoveEvent(QDragMoveEvent *event) void PuzzleWidget::dragMoveEvent(QDragMoveEvent *event)
{ {
QRect updateRect = highlightedRect.united(targetSquare(event->pos())); QRect updateRect = highlightedRect.united(targetSquare(event->position().toPoint()));
if (event->mimeData()->hasFormat("image/x-puzzle-piece") if (event->mimeData()->hasFormat("image/x-puzzle-piece")
&& findPiece(targetSquare(event->pos())) == -1) { && findPiece(targetSquare(event->position().toPoint())) == -1) {
highlightedRect = targetSquare(event->pos()); highlightedRect = targetSquare(event->position().toPoint());
event->setDropAction(Qt::MoveAction); event->setDropAction(Qt::MoveAction);
event->accept(); event->accept();
} else { } else {
@ -105,12 +105,12 @@ void PuzzleWidget::dragMoveEvent(QDragMoveEvent *event)
void PuzzleWidget::dropEvent(QDropEvent *event) void PuzzleWidget::dropEvent(QDropEvent *event)
{ {
if (event->mimeData()->hasFormat("image/x-puzzle-piece") if (event->mimeData()->hasFormat("image/x-puzzle-piece")
&& findPiece(targetSquare(event->pos())) == -1) { && findPiece(targetSquare(event->position().toPoint())) == -1) {
QByteArray pieceData = event->mimeData()->data("image/x-puzzle-piece"); QByteArray pieceData = event->mimeData()->data("image/x-puzzle-piece");
QDataStream dataStream(&pieceData, QIODevice::ReadOnly); QDataStream dataStream(&pieceData, QIODevice::ReadOnly);
Piece piece; Piece piece;
piece.rect = targetSquare(event->pos()); piece.rect = targetSquare(event->position().toPoint());
dataStream >> piece.pixmap >> piece.location; dataStream >> piece.pixmap >> piece.location;
pieces.append(piece); pieces.append(piece);
@ -143,7 +143,7 @@ int PuzzleWidget::findPiece(const QRect &pieceRect) const
void PuzzleWidget::mousePressEvent(QMouseEvent *event) void PuzzleWidget::mousePressEvent(QMouseEvent *event)
{ {
QRect square = targetSquare(event->pos()); QRect square = targetSquare(event->position().toPoint());
int found = findPiece(square); int found = findPiece(square);
if (found == -1) if (found == -1)
@ -166,12 +166,12 @@ void PuzzleWidget::mousePressEvent(QMouseEvent *event)
QDrag *drag = new QDrag(this); QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData); drag->setMimeData(mimeData);
drag->setHotSpot(event->pos() - square.topLeft()); drag->setHotSpot(event->position().toPoint() - square.topLeft());
drag->setPixmap(piece.pixmap); drag->setPixmap(piece.pixmap);
if (drag->exec(Qt::MoveAction) == Qt::IgnoreAction) { if (drag->exec(Qt::MoveAction) == Qt::IgnoreAction) {
pieces.insert(found, piece); pieces.insert(found, piece);
update(targetSquare(event->pos())); update(targetSquare(event->position().toPoint()));
if (piece.location == QPoint(square.x() / pieceSize(), square.y() / pieceSize())) if (piece.location == QPoint(square.x() / pieceSize(), square.y() / pieceSize()))
inPlace++; inPlace++;

View File

@ -79,7 +79,7 @@ void StarEditor::paintEvent(QPaintEvent *)
//! [2] //! [2]
void StarEditor::mouseMoveEvent(QMouseEvent *event) void StarEditor::mouseMoveEvent(QMouseEvent *event)
{ {
const int star = starAtPosition(event->x()); const int star = starAtPosition(event->position().toPoint().x());
if (star != myStarRating.starCount() && star != -1) { if (star != myStarRating.starCount() && star != -1) {
myStarRating.setStarCount(star); myStarRating.setStarCount(star);

View File

@ -628,7 +628,7 @@ void BlueTitleBar::paintEvent(QPaintEvent*)
void BlueTitleBar::mouseReleaseEvent(QMouseEvent *event) void BlueTitleBar::mouseReleaseEvent(QMouseEvent *event)
{ {
QPoint pos = event->pos(); QPoint pos = event->position().toPoint();
QRect rect = this->rect(); QRect rect = this->rect();

View File

@ -490,10 +490,10 @@ void PathDeformRenderer::mousePressEvent(QMouseEvent *e)
m_repaintTimer.stop(); m_repaintTimer.stop();
m_offset = QPointF(); m_offset = QPointF();
if (QLineF(m_pos, e->pos()).length() <= m_radius) if (QLineF(m_pos, e->position().toPoint()).length() <= m_radius)
m_offset = m_pos - e->pos(); m_offset = m_pos - e->position().toPoint();
m_mousePress = e->pos(); m_mousePress = e->position().toPoint();
// If we're not running in small screen mode, always assume we're dragging // If we're not running in small screen mode, always assume we're dragging
m_mouseDrag = !m_smallScreen; m_mouseDrag = !m_smallScreen;
@ -514,18 +514,18 @@ void PathDeformRenderer::mouseReleaseEvent(QMouseEvent *e)
void PathDeformRenderer::mouseMoveEvent(QMouseEvent *e) void PathDeformRenderer::mouseMoveEvent(QMouseEvent *e)
{ {
if (!m_mouseDrag && (QLineF(m_mousePress, e->pos()).length() > 25.0) ) if (!m_mouseDrag && (QLineF(m_mousePress, e->position().toPoint()).length() > 25.0) )
m_mouseDrag = true; m_mouseDrag = true;
if (m_mouseDrag) { if (m_mouseDrag) {
QRect rectBefore = circle_bounds(m_pos, m_radius, m_fontSize); QRect rectBefore = circle_bounds(m_pos, m_radius, m_fontSize);
if (e->type() == QEvent::MouseMove) { if (e->type() == QEvent::MouseMove) {
QLineF line(m_pos, e->pos() + m_offset); QLineF line(m_pos, e->position().toPoint() + m_offset);
line.setLength(line.length() * .1); line.setLength(line.length() * .1);
QPointF dir(line.dx(), line.dy()); QPointF dir(line.dx(), line.dy());
m_direction = (m_direction + dir) / 2; m_direction = (m_direction + dir) / 2;
} }
m_pos = e->pos() + m_offset; m_pos = e->position().toPoint() + m_offset;
#if QT_CONFIG(opengl) #if QT_CONFIG(opengl)
if (usesOpenGL()) { if (usesOpenGL()) {
update(); update();

View File

@ -559,7 +559,7 @@ void PathStrokeRenderer::mousePressEvent(QMouseEvent *e)
m_activePoint = -1; m_activePoint = -1;
qreal distance = -1; qreal distance = -1;
for (int i = 0; i < m_points.size(); ++i) { for (int i = 0; i < m_points.size(); ++i) {
qreal d = QLineF(e->pos(), m_points.at(i)).length(); qreal d = QLineF(e->position().toPoint(), m_points.at(i)).length();
if ((distance < 0 && d < 8 * m_pointSize) || d < distance) { if ((distance < 0 && d < 8 * m_pointSize) || d < distance) {
distance = d; distance = d;
m_activePoint = i; m_activePoint = i;
@ -574,7 +574,7 @@ void PathStrokeRenderer::mousePressEvent(QMouseEvent *e)
// If we're not running in small screen mode, always assume we're dragging // If we're not running in small screen mode, always assume we're dragging
m_mouseDrag = !m_smallScreen; m_mouseDrag = !m_smallScreen;
m_mousePress = e->pos(); m_mousePress = e->position().toPoint();
} }
void PathStrokeRenderer::mouseMoveEvent(QMouseEvent *e) void PathStrokeRenderer::mouseMoveEvent(QMouseEvent *e)
@ -582,11 +582,11 @@ void PathStrokeRenderer::mouseMoveEvent(QMouseEvent *e)
if (!m_fingerPointMapping.isEmpty()) if (!m_fingerPointMapping.isEmpty())
return; return;
// If we've moved more then 25 pixels, assume user is dragging // If we've moved more then 25 pixels, assume user is dragging
if (!m_mouseDrag && QPoint(m_mousePress - e->pos()).manhattanLength() > 25) if (!m_mouseDrag && QPoint(m_mousePress - e->position().toPoint()).manhattanLength() > 25)
m_mouseDrag = true; m_mouseDrag = true;
if (m_mouseDrag && m_activePoint >= 0 && m_activePoint < m_points.size()) { if (m_mouseDrag && m_activePoint >= 0 && m_activePoint < m_points.size()) {
m_points[m_activePoint] = e->pos(); m_points[m_activePoint] = e->position().toPoint();
update(); update();
} }
} }
@ -638,7 +638,7 @@ bool PathStrokeRenderer::event(QEvent *e)
if (activePoints.contains(i)) if (activePoints.contains(i))
continue; continue;
qreal d = QLineF(touchPoint.pos(), m_points.at(i)).length(); qreal d = QLineF(touchPoint.position(), m_points.at(i)).length();
if ((distance < 0 && d < 12 * m_pointSize) || d < distance) { if ((distance < 0 && d < 12 * m_pointSize) || d < distance) {
distance = d; distance = d;
activePoint = i; activePoint = i;
@ -646,7 +646,7 @@ bool PathStrokeRenderer::event(QEvent *e)
} }
if (activePoint != -1) { if (activePoint != -1) {
m_fingerPointMapping.insert(touchPoint.id(), activePoint); m_fingerPointMapping.insert(touchPoint.id(), activePoint);
m_points[activePoint] = touchPoint.pos(); m_points[activePoint] = touchPoint.position();
} }
break; break;
} }
@ -654,7 +654,7 @@ bool PathStrokeRenderer::event(QEvent *e)
{ {
// move the point and release // move the point and release
QHash<int,int>::iterator it = m_fingerPointMapping.find(id); QHash<int,int>::iterator it = m_fingerPointMapping.find(id);
m_points[it.value()] = touchPoint.pos(); m_points[it.value()] = touchPoint.position();
m_fingerPointMapping.erase(it); m_fingerPointMapping.erase(it);
break; break;
} }
@ -663,7 +663,7 @@ bool PathStrokeRenderer::event(QEvent *e)
// move the point // move the point
const int pointIdx = m_fingerPointMapping.value(id, -1); const int pointIdx = m_fingerPointMapping.value(id, -1);
if (pointIdx >= 0) if (pointIdx >= 0)
m_points[pointIdx] = touchPoint.pos(); m_points[pointIdx] = touchPoint.position();
break; break;
} }
default: default:

View File

@ -102,7 +102,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event)
return true; return true;
QMouseEvent *me = (QMouseEvent *) event; QMouseEvent *me = (QMouseEvent *) event;
QPointF clickPos = me->pos(); QPointF clickPos = me->position().toPoint();
int index = -1; int index = -1;
for (int i=0; i<m_points.size(); ++i) { for (int i=0; i<m_points.size(); ++i) {
QPainterPath path; QPainterPath path;
@ -170,7 +170,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event)
if (!m_fingerPointMapping.isEmpty()) if (!m_fingerPointMapping.isEmpty())
return true; return true;
if (m_currentIndex >= 0) if (m_currentIndex >= 0)
movePoint(m_currentIndex, ((QMouseEvent *)event)->pos()); movePoint(m_currentIndex, ((QMouseEvent *)event)->position().toPoint());
break; break;
case QEvent::TouchBegin: case QEvent::TouchBegin:
case QEvent::TouchUpdate: case QEvent::TouchUpdate:
@ -197,7 +197,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event)
if (activePoints.contains(i)) if (activePoints.contains(i))
continue; continue;
qreal d = QLineF(touchPoint.pos(), m_points.at(i)).length(); qreal d = QLineF(touchPoint.position(), m_points.at(i)).length();
if ((distance < 0 && d < 12 * pointSize) || d < distance) { if ((distance < 0 && d < 12 * pointSize) || d < distance) {
distance = d; distance = d;
activePoint = i; activePoint = i;
@ -207,7 +207,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event)
} }
if (activePoint != -1) { if (activePoint != -1) {
m_fingerPointMapping.insert(touchPoint.id(), activePoint); m_fingerPointMapping.insert(touchPoint.id(), activePoint);
movePoint(activePoint, touchPoint.pos()); movePoint(activePoint, touchPoint.position());
} }
} }
break; break;
@ -215,7 +215,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event)
{ {
// move the point and release // move the point and release
QHash<int,int>::iterator it = m_fingerPointMapping.find(id); QHash<int,int>::iterator it = m_fingerPointMapping.find(id);
movePoint(it.value(), touchPoint.pos()); movePoint(it.value(), touchPoint.position());
m_fingerPointMapping.erase(it); m_fingerPointMapping.erase(it);
} }
break; break;
@ -224,7 +224,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event)
// move the point // move the point
const int pointIdx = m_fingerPointMapping.value(id, -1); const int pointIdx = m_fingerPointMapping.value(id, -1);
if (pointIdx >= 0) // do we track this point? if (pointIdx >= 0) // do we track this point?
movePoint(pointIdx, touchPoint.pos()); movePoint(pointIdx, touchPoint.position());
} }
break; break;
default: default:

View File

@ -137,7 +137,7 @@ void PaintArea::mousePressEvent(QMouseEvent *event)
gradient.setColorAt(1.0, QColor(color.red(), color.green(), gradient.setColorAt(1.0, QColor(color.red(), color.green(),
color.blue(), 191)); color.blue(), 191));
painter.setBrush(gradient); painter.setBrush(gradient);
painter.translate(event->pos() - boundingRect.center()); painter.translate(event->position().toPoint() - boundingRect.center());
painter.drawPath(pendingPath); painter.drawPath(pendingPath);
pendingPath = QPainterPath(); pendingPath = QPainterPath();
@ -150,11 +150,11 @@ void PaintArea::mousePressEvent(QMouseEvent *event)
QPainter painter(&theImage); QPainter painter(&theImage);
setupPainter(painter); setupPainter(painter);
const QRect rect = brushInterface->mousePress(brush, painter, const QRect rect = brushInterface->mousePress(brush, painter,
event->pos()); event->position().toPoint());
update(rect); update(rect);
} }
lastPos = event->pos(); lastPos = event->position().toPoint();
} }
} }
} }
@ -167,11 +167,11 @@ void PaintArea::mouseMoveEvent(QMouseEvent *event)
QPainter painter(&theImage); QPainter painter(&theImage);
setupPainter(painter); setupPainter(painter);
const QRect rect = brushInterface->mouseMove(brush, painter, lastPos, const QRect rect = brushInterface->mouseMove(brush, painter, lastPos,
event->pos()); event->position().toPoint());
update(rect); update(rect);
} }
lastPos = event->pos(); lastPos = event->position().toPoint();
} }
} }
//! [1] //! [1]
@ -183,7 +183,7 @@ void PaintArea::mouseReleaseEvent(QMouseEvent *event)
QPainter painter(&theImage); QPainter painter(&theImage);
setupPainter(painter); setupPainter(painter);
QRect rect = brushInterface->mouseRelease(brush, painter, QRect rect = brushInterface->mouseRelease(brush, painter,
event->pos()); event->position().toPoint());
update(rect); update(rect);
} }

View File

@ -283,17 +283,17 @@ int Document::indexAt(const QPoint &pos) const
void Document::mousePressEvent(QMouseEvent *event) void Document::mousePressEvent(QMouseEvent *event)
{ {
event->accept(); event->accept();
int index = indexAt(event->pos());; int index = indexAt(event->position().toPoint());;
if (index != -1) { if (index != -1) {
setCurrentShape(index); setCurrentShape(index);
const Shape &shape = m_shapeList.at(index); const Shape &shape = m_shapeList.at(index);
m_resizeHandlePressed = shape.resizeHandle().contains(event->pos()); m_resizeHandlePressed = shape.resizeHandle().contains(event->position().toPoint());
if (m_resizeHandlePressed) if (m_resizeHandlePressed)
m_mousePressOffset = shape.rect().bottomRight() - event->pos(); m_mousePressOffset = shape.rect().bottomRight() - event->position().toPoint();
else else
m_mousePressOffset = event->pos() - shape.rect().topLeft(); m_mousePressOffset = event->position().toPoint() - shape.rect().topLeft();
} }
m_mousePressIndex = index; m_mousePressIndex = index;
} }
@ -315,10 +315,10 @@ void Document::mouseMoveEvent(QMouseEvent *event)
QRect rect; QRect rect;
if (m_resizeHandlePressed) { if (m_resizeHandlePressed) {
rect = QRect(shape.rect().topLeft(), event->pos() + m_mousePressOffset); rect = QRect(shape.rect().topLeft(), event->position().toPoint() + m_mousePressOffset);
} else { } else {
rect = shape.rect(); rect = shape.rect();
rect.moveTopLeft(event->pos() - m_mousePressOffset); rect.moveTopLeft(event->position().toPoint() - m_mousePressOffset);
} }
QSize size = rect.size().expandedTo(Shape::minSize); QSize size = rect.size().expandedTo(Shape::minSize);

View File

@ -216,13 +216,13 @@ bool ScribbleArea::event(QEvent *event)
QPainter painter(&image); QPainter painter(&image);
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
painter.setBrush(myPenColors.at(touchPoint.id() % myPenColors.count())); painter.setBrush(myPenColors.at(touchPoint.id() % myPenColors.count()));
painter.drawEllipse(touchPoint.pos(), diams.width() / 2, diams.height() / 2); painter.drawEllipse(touchPoint.position(), diams.width() / 2, diams.height() / 2);
painter.end(); painter.end();
modified = true; modified = true;
const int rad = 2; const int rad = 2;
QRectF rect(QPointF(), diams); QRectF rect(QPointF(), diams);
rect.moveCenter(touchPoint.pos()); rect.moveCenter(touchPoint.position());
update(rect.toRect().adjusted(-rad,-rad, +rad, +rad)); update(rect.toRect().adjusted(-rad,-rad, +rad, +rad));
} }
break; break;

View File

@ -82,7 +82,7 @@ bool Knob::sceneEvent(QEvent *event)
const QTouchEvent::TouchPoint &touchPoint2 = touchEvent->touchPoints().last(); const QTouchEvent::TouchPoint &touchPoint2 = touchEvent->touchPoints().last();
QLineF line1(touchPoint1.lastScenePos(), touchPoint2.lastScenePos()); QLineF line1(touchPoint1.lastScenePos(), touchPoint2.lastScenePos());
QLineF line2(touchPoint1.scenePos(), touchPoint2.scenePos()); QLineF line2(touchPoint1.scenePosition(), touchPoint2.scenePosition());
setTransform(QTransform().rotate(line2.angleTo(line1)), true); setTransform(QTransform().rotate(line2.angleTo(line1)), true);
} }

View File

@ -74,8 +74,8 @@ bool GraphicsView::viewportEvent(QEvent *event)
const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first(); const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last(); const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();
qreal currentScaleFactor = qreal currentScaleFactor =
QLineF(touchPoint0.pos(), touchPoint1.pos()).length() QLineF(touchPoint0.position(), touchPoint1.position()).length()
/ QLineF(touchPoint0.startPos(), touchPoint1.startPos()).length(); / QLineF(touchPoint0.pressPosition(), touchPoint1.pressPosition()).length();
if (touchEvent->touchPointStates() & Qt::TouchPointReleased) { if (touchEvent->touchPointStates() & Qt::TouchPointReleased) {
// if one of the fingers is released, remember the current scale // if one of the fingers is released, remember the current scale
// factor so that adding another finger later will continue zooming // factor so that adding another finger later will continue zooming

View File

@ -120,14 +120,14 @@ QSize CharacterWidget::sizeHint() const
//! [4] //! [4]
void CharacterWidget::mouseMoveEvent(QMouseEvent *event) void CharacterWidget::mouseMoveEvent(QMouseEvent *event)
{ {
QPoint widgetPosition = mapFromGlobal(event->globalPos()); QPoint widgetPosition = mapFromGlobal(event->globalPosition().toPoint());
uint key = (widgetPosition.y() / squareSize) * columns + widgetPosition.x() / squareSize; uint key = (widgetPosition.y() / squareSize) * columns + widgetPosition.x() / squareSize;
QString text = QString::fromLatin1("<p>Character: <span style=\"font-size: 24pt; font-family: %1\">").arg(displayFont.family()) QString text = QString::fromLatin1("<p>Character: <span style=\"font-size: 24pt; font-family: %1\">").arg(displayFont.family())
+ QChar(key) + QChar(key)
+ QString::fromLatin1("</span><p>Value: 0x") + QString::fromLatin1("</span><p>Value: 0x")
+ QString::number(key, 16); + QString::number(key, 16);
QToolTip::showText(event->globalPos(), text, this); QToolTip::showText(event->globalPosition().toPoint(), text, this);
} }
//! [4] //! [4]
@ -135,7 +135,7 @@ void CharacterWidget::mouseMoveEvent(QMouseEvent *event)
void CharacterWidget::mousePressEvent(QMouseEvent *event) void CharacterWidget::mousePressEvent(QMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
lastKey = (event->y() / squareSize) * columns + event->x() / squareSize; lastKey = (event->position().toPoint().y() / squareSize) * columns + event->position().toPoint().x() / squareSize;
if (QChar(lastKey).category() != QChar::Other_NotAssigned) if (QChar(lastKey).category() != QChar::Other_NotAssigned)
emit characterSelected(QString(QChar(lastKey))); emit characterSelected(QString(QChar(lastKey)));
update(); update();

View File

@ -132,7 +132,7 @@ void ScribbleArea::mousePressEvent(QMouseEvent *event)
//! [11] //! [12] //! [11] //! [12]
{ {
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
lastPoint = event->pos(); lastPoint = event->position().toPoint();
scribbling = true; scribbling = true;
} }
} }
@ -140,13 +140,13 @@ void ScribbleArea::mousePressEvent(QMouseEvent *event)
void ScribbleArea::mouseMoveEvent(QMouseEvent *event) void ScribbleArea::mouseMoveEvent(QMouseEvent *event)
{ {
if ((event->buttons() & Qt::LeftButton) && scribbling) if ((event->buttons() & Qt::LeftButton) && scribbling)
drawLineTo(event->pos()); drawLineTo(event->position().toPoint());
} }
void ScribbleArea::mouseReleaseEvent(QMouseEvent *event) void ScribbleArea::mouseReleaseEvent(QMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton && scribbling) { if (event->button() == Qt::LeftButton && scribbling) {
drawLineTo(event->pos()); drawLineTo(event->position().toPoint());
scribbling = false; scribbling = false;
} }
} }

View File

@ -82,7 +82,7 @@ ShapedClock::ShapedClock(QWidget *parent)
void ShapedClock::mousePressEvent(QMouseEvent *event) void ShapedClock::mousePressEvent(QMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
dragPosition = event->globalPos() - frameGeometry().topLeft(); dragPosition = event->globalPosition().toPoint() - frameGeometry().topLeft();
event->accept(); event->accept();
} }
} }
@ -92,7 +92,7 @@ void ShapedClock::mousePressEvent(QMouseEvent *event)
void ShapedClock::mouseMoveEvent(QMouseEvent *event) void ShapedClock::mouseMoveEvent(QMouseEvent *event)
{ {
if (event->buttons() & Qt::LeftButton) { if (event->buttons() & Qt::LeftButton) {
move(event->globalPos() - dragPosition); move(event->globalPosition().toPoint() - dragPosition);
event->accept(); event->accept();
} }
} }

View File

@ -99,7 +99,7 @@ void TabletCanvas::tabletEvent(QTabletEvent *event)
case QEvent::TabletPress: case QEvent::TabletPress:
if (!m_deviceDown) { if (!m_deviceDown) {
m_deviceDown = true; m_deviceDown = true;
lastPoint.pos = event->posF(); lastPoint.pos = event->position();
lastPoint.pressure = event->pressure(); lastPoint.pressure = event->pressure();
lastPoint.rotation = event->rotation(); lastPoint.rotation = event->rotation();
} }
@ -113,7 +113,7 @@ void TabletCanvas::tabletEvent(QTabletEvent *event)
updateBrush(event); updateBrush(event);
QPainter painter(&m_pixmap); QPainter painter(&m_pixmap);
paintPixmap(painter, event); paintPixmap(painter, event);
lastPoint.pos = event->posF(); lastPoint.pos = event->position();
lastPoint.pressure = event->pressure(); lastPoint.pressure = event->pressure();
lastPoint.rotation = event->rotation(); lastPoint.rotation = event->rotation();
} }
@ -173,8 +173,8 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
grad.setColorAt(0.5, Qt::transparent); grad.setColorAt(0.5, Qt::transparent);
painter.setBrush(grad); painter.setBrush(grad);
qreal radius = grad.radius(); qreal radius = grad.radius();
painter.drawEllipse(event->posF(), radius, radius); painter.drawEllipse(event->position(), radius, radius);
update(QRect(event->pos() - QPoint(radius, radius), QSize(radius * 2, radius * 2))); update(QRect(event->position().toPoint() - QPoint(radius, radius), QSize(radius * 2, radius * 2)));
} }
break; break;
case QTabletEvent::RotationStylus: case QTabletEvent::RotationStylus:
@ -191,8 +191,8 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
halfWidth = m_pen.widthF(); halfWidth = m_pen.widthF();
brushAdjust = QPointF(qSin(qDegreesToRadians(-event->rotation())) * halfWidth, brushAdjust = QPointF(qSin(qDegreesToRadians(-event->rotation())) * halfWidth,
qCos(qDegreesToRadians(-event->rotation())) * halfWidth); qCos(qDegreesToRadians(-event->rotation())) * halfWidth);
poly << event->posF() - brushAdjust; poly << event->position() - brushAdjust;
poly << event->posF() + brushAdjust; poly << event->position() + brushAdjust;
painter.drawConvexPolygon(poly); painter.drawConvexPolygon(poly);
update(poly.boundingRect().toRect()); update(poly.boundingRect().toRect());
} }
@ -223,8 +223,8 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case QTabletEvent::Stylus: case QTabletEvent::Stylus:
painter.setPen(m_pen); painter.setPen(m_pen);
painter.drawLine(lastPoint.pos, event->posF()); painter.drawLine(lastPoint.pos, event->position());
update(QRect(lastPoint.pos.toPoint(), event->pos()).normalized() update(QRect(lastPoint.pos.toPoint(), event->position().toPoint()).normalized()
.adjusted(-maxPenRadius, -maxPenRadius, maxPenRadius, maxPenRadius)); .adjusted(-maxPenRadius, -maxPenRadius, maxPenRadius, maxPenRadius));
break; break;
} }

View File

@ -159,10 +159,10 @@ void SortingBox::paintEvent(QPaintEvent * /* event */)
void SortingBox::mousePressEvent(QMouseEvent *event) void SortingBox::mousePressEvent(QMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
int index = itemAt(event->pos()); int index = itemAt(event->position().toPoint());
if (index != -1) { if (index != -1) {
itemInMotion = &shapeItems[index]; itemInMotion = &shapeItems[index];
previousPosition = event->pos(); previousPosition = event->position().toPoint();
shapeItems.move(index, shapeItems.size() - 1); shapeItems.move(index, shapeItems.size() - 1);
update(); update();
} }
@ -174,7 +174,7 @@ void SortingBox::mousePressEvent(QMouseEvent *event)
void SortingBox::mouseMoveEvent(QMouseEvent *event) void SortingBox::mouseMoveEvent(QMouseEvent *event)
{ {
if ((event->buttons() & Qt::LeftButton) && itemInMotion) if ((event->buttons() & Qt::LeftButton) && itemInMotion)
moveItemTo(event->pos()); moveItemTo(event->position().toPoint());
} }
//! [12] //! [12]
@ -182,7 +182,7 @@ void SortingBox::mouseMoveEvent(QMouseEvent *event)
void SortingBox::mouseReleaseEvent(QMouseEvent *event) void SortingBox::mouseReleaseEvent(QMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton && itemInMotion) { if (event->button() == Qt::LeftButton && itemInMotion) {
moveItemTo(event->pos()); moveItemTo(event->position().toPoint());
itemInMotion = nullptr; itemInMotion = nullptr;
} }
} }

View File

@ -100,7 +100,7 @@ public:
if (!m_mouseDown) { if (!m_mouseDown) {
m_mouseDown = true; m_mouseDown = true;
m_polygon.clear(); m_polygon.clear();
m_polygon.append(e->pos()); m_polygon.append(e->position().toPoint());
renderLater(); renderLater();
} }
} }
@ -108,7 +108,7 @@ public:
void mouseMoveEvent(QMouseEvent *e) override void mouseMoveEvent(QMouseEvent *e) override
{ {
if (m_mouseDown) { if (m_mouseDown) {
m_polygon.append(e->pos()); m_polygon.append(e->position().toPoint());
renderLater(); renderLater();
} }
} }
@ -117,7 +117,7 @@ public:
{ {
if (m_mouseDown) { if (m_mouseDown) {
m_mouseDown = false; m_mouseDown = false;
m_polygon.append(e->pos()); m_polygon.append(e->position().toPoint());
renderLater(); renderLater();
} }
} }

View File

@ -40,7 +40,7 @@
#include "qevent.h" #include "qevent.h"
#include "qcursor.h" #include "qcursor.h"
#include "private/qguiapplication_p.h" #include "private/qguiapplication_p.h"
#include "private/qtouchdevice_p.h" #include "qtouchdevice.h"
#include "qpa/qplatformintegration.h" #include "qpa/qplatformintegration.h"
#include "private/qevent_p.h" #include "private/qevent_p.h"
#include "qfile.h" #include "qfile.h"
@ -3585,13 +3585,13 @@ static void formatDropEvent(QDebug d, const QDropEvent *e)
d << ", possibleActions="; d << ", possibleActions=";
QtDebugUtils::formatQFlags(d, e->possibleActions()); QtDebugUtils::formatQFlags(d, e->possibleActions());
d << ", posF="; d << ", posF=";
QtDebugUtils::formatQPoint(d, e->posF()); QtDebugUtils::formatQPoint(d, e->position());
if (type == QEvent::DragMove || type == QEvent::DragEnter) if (type == QEvent::DragMove || type == QEvent::DragEnter)
d << ", answerRect=" << static_cast<const QDragMoveEvent *>(e)->answerRect(); d << ", answerRect=" << static_cast<const QDragMoveEvent *>(e)->answerRect();
d << ", formats=" << e->mimeData()->formats(); d << ", formats=" << e->mimeData()->formats();
QtDebugUtils::formatNonNullQFlags(d, ", keyboardModifiers=", e->keyboardModifiers()); QtDebugUtils::formatNonNullQFlags(d, ", keyboardModifiers=", e->modifiers());
d << ", "; d << ", ";
QtDebugUtils::formatQFlags(d, e->mouseButtons()); QtDebugUtils::formatQFlags(d, e->buttons());
} }
# endif // QT_CONFIG(draganddrop) # endif // QT_CONFIG(draganddrop)
@ -3609,7 +3609,7 @@ static void formatTabletEvent(QDebug d, const QTabletEvent *e)
d << ", pointerType="; d << ", pointerType=";
QtDebugUtils::formatQEnum(d, e->pointerType()); QtDebugUtils::formatQEnum(d, e->pointerType());
d << ", uniqueId=" << e->uniqueId() d << ", uniqueId=" << e->uniqueId()
<< ", pos=" << e->posF() << ", pos=" << e->position()
<< ", z=" << e->z() << ", z=" << e->z()
<< ", xTilt=" << e->xTilt() << ", xTilt=" << e->xTilt()
<< ", yTilt=" << e->yTilt() << ", yTilt=" << e->yTilt()
@ -3630,7 +3630,7 @@ QDebug operator<<(QDebug dbg, const QTouchEvent::TouchPoint &tp)
QDebugStateSaver saver(dbg); QDebugStateSaver saver(dbg);
dbg.nospace(); dbg.nospace();
dbg << "TouchPoint(" << Qt::hex << tp.id() << Qt::dec << " ("; dbg << "TouchPoint(" << Qt::hex << tp.id() << Qt::dec << " (";
QtDebugUtils::formatQPoint(dbg, tp.pos()); QtDebugUtils::formatQPoint(dbg, tp.position());
dbg << ") "; dbg << ") ";
QtDebugUtils::formatQEnum(dbg, tp.state()); QtDebugUtils::formatQEnum(dbg, tp.state());
dbg << " pressure " << tp.pressure() << " ellipse (" dbg << " pressure " << tp.pressure() << " ellipse ("
@ -3638,11 +3638,11 @@ QDebug operator<<(QDebug dbg, const QTouchEvent::TouchPoint &tp)
<< " angle " << tp.rotation() << ") vel ("; << " angle " << tp.rotation() << ") vel (";
QtDebugUtils::formatQPoint(dbg, tp.velocity().toPointF()); QtDebugUtils::formatQPoint(dbg, tp.velocity().toPointF());
dbg << ") start ("; dbg << ") start (";
QtDebugUtils::formatQPoint(dbg, tp.startPos()); QtDebugUtils::formatQPoint(dbg, tp.pressPosition());
dbg << ") last ("; dbg << ") last (";
QtDebugUtils::formatQPoint(dbg, tp.lastPos()); QtDebugUtils::formatQPoint(dbg, tp.lastPos());
dbg << ") delta ("; dbg << ") delta (";
QtDebugUtils::formatQPoint(dbg, tp.pos() - tp.lastPos()); QtDebugUtils::formatQPoint(dbg, tp.position() - tp.lastPos());
dbg << ')'; dbg << ')';
return dbg; return dbg;
} }
@ -3688,9 +3688,9 @@ QDebug operator<<(QDebug dbg, const QEvent *e)
} }
QtDebugUtils::formatNonNullQFlags(dbg, ", ", me->modifiers()); QtDebugUtils::formatNonNullQFlags(dbg, ", ", me->modifiers());
dbg << ", localPos="; dbg << ", localPos=";
QtDebugUtils::formatQPoint(dbg, me->localPos()); QtDebugUtils::formatQPoint(dbg, me->position());
dbg << ", screenPos="; dbg << ", screenPos=";
QtDebugUtils::formatQPoint(dbg, me->screenPos()); QtDebugUtils::formatQPoint(dbg, me->globalPosition());
QtDebugUtils::formatNonNullQEnum(dbg, ", ", me->source()); QtDebugUtils::formatNonNullQEnum(dbg, ", ", me->source());
QtDebugUtils::formatNonNullQFlags(dbg, ", flags=", me->flags()); QtDebugUtils::formatNonNullQFlags(dbg, ", flags=", me->flags());
dbg << ')'; dbg << ')';
@ -3791,7 +3791,7 @@ QDebug operator<<(QDebug dbg, const QEvent *e)
dbg << "QNativeGestureEvent("; dbg << "QNativeGestureEvent(";
QtDebugUtils::formatQEnum(dbg, ne->gestureType()); QtDebugUtils::formatQEnum(dbg, ne->gestureType());
dbg << ", localPos="; dbg << ", localPos=";
QtDebugUtils::formatQPoint(dbg, ne->localPos()); QtDebugUtils::formatQPoint(dbg, ne->position());
dbg << ", value=" << ne->value() << ')'; dbg << ", value=" << ne->value() << ')';
} }
break; break;
@ -3816,7 +3816,7 @@ QDebug operator<<(QDebug dbg, const QEvent *e)
break; break;
# endif // QT_CONFIG(tabletevent) # endif // QT_CONFIG(tabletevent)
case QEvent::Enter: case QEvent::Enter:
dbg << "QEnterEvent(" << static_cast<const QEnterEvent *>(e)->pos() << ')'; dbg << "QEnterEvent(" << static_cast<const QEnterEvent *>(e)->position() << ')';
break; break;
case QEvent::Timer: case QEvent::Timer:
dbg << "QTimerEvent(id=" << static_cast<const QTimerEvent *>(e)->timerId() << ')'; dbg << "QTimerEvent(id=" << static_cast<const QTimerEvent *>(e)->timerId() << ')';

View File

@ -2842,15 +2842,15 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
if (!w) { if (!w) {
// determine which window this event will go to // determine which window this event will go to
if (!window) if (!window)
window = QGuiApplication::topLevelAt(touchPoint.screenPos().toPoint()); window = QGuiApplication::topLevelAt(touchPoint.globalPosition().toPoint());
if (!window) if (!window)
continue; continue;
w = window; w = window;
} }
touchInfo.window = w; touchInfo.window = w;
touchPoint.d->startScreenPos = touchPoint.screenPos(); touchPoint.d->startScreenPos = touchPoint.globalPosition();
touchPoint.d->lastScreenPos = touchPoint.screenPos(); touchPoint.d->lastScreenPos = touchPoint.globalPosition();
touchPoint.d->startNormalizedPos = touchPoint.normalizedPos(); touchPoint.d->startNormalizedPos = touchPoint.normalizedPos();
touchPoint.d->lastNormalizedPos = touchPoint.normalizedPos(); touchPoint.d->lastNormalizedPos = touchPoint.normalizedPos();
if (touchPoint.pressure() < qreal(0.)) if (touchPoint.pressure() < qreal(0.))
@ -2865,10 +2865,10 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
continue; continue;
previousTouchPoint = touchInfo.touchPoint; previousTouchPoint = touchInfo.touchPoint;
touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); touchPoint.d->startScreenPos = previousTouchPoint.globalPressPosition();
touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); touchPoint.d->lastScreenPos = previousTouchPoint.globalPosition();
touchPoint.d->startPos = previousTouchPoint.startPos(); touchPoint.d->startPos = previousTouchPoint.pressPosition();
touchPoint.d->lastPos = previousTouchPoint.pos(); touchPoint.d->lastPos = previousTouchPoint.position();
touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos();
touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos();
if (touchPoint.pressure() < qreal(0.)) if (touchPoint.pressure() < qreal(0.))
@ -2882,10 +2882,10 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
continue; continue;
previousTouchPoint = touchInfo.touchPoint; previousTouchPoint = touchInfo.touchPoint;
touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); touchPoint.d->startScreenPos = previousTouchPoint.globalPressPosition();
touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); touchPoint.d->lastScreenPos = previousTouchPoint.globalPosition();
touchPoint.d->startPos = previousTouchPoint.startPos(); touchPoint.d->startPos = previousTouchPoint.pressPosition();
touchPoint.d->lastPos = previousTouchPoint.pos(); touchPoint.d->lastPos = previousTouchPoint.position();
touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos();
touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos();
if (touchPoint.pressure() < qreal(0.)) if (touchPoint.pressure() < qreal(0.))
@ -2916,8 +2916,8 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
// Note: touchPoint is a reference to the one from activeTouchPoints, // Note: touchPoint is a reference to the one from activeTouchPoints,
// so we can modify it as long as we're careful NOT to call setters and // so we can modify it as long as we're careful NOT to call setters and
// otherwise NOT to cause the d-pointer to be detached. // otherwise NOT to cause the d-pointer to be detached.
touchPoint.d->scenePos = touchPoint.screenPos(); touchPoint.d->scenePos = touchPoint.globalPosition();
touchPoint.d->startScenePos = touchPoint.startScreenPos(); touchPoint.d->startScenePos = touchPoint.globalPressPosition();
touchPoint.d->lastScenePos = touchPoint.lastScreenPos(); touchPoint.d->lastScenePos = touchPoint.lastScreenPos();
StatesAndTouchPoints &maskAndPoints = windowsNeedingEvents[w.data()]; StatesAndTouchPoints &maskAndPoints = windowsNeedingEvents[w.data()];
@ -2981,7 +2981,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
QTouchEvent::TouchPoint &touchPoint = touchEvent._touchPoints[i]; QTouchEvent::TouchPoint &touchPoint = touchEvent._touchPoints[i];
// preserve the sub-pixel resolution // preserve the sub-pixel resolution
const QPointF screenPos = touchPoint.screenPos(); const QPointF screenPos = touchPoint.globalPosition();
const QPointF delta = screenPos - screenPos.toPoint(); const QPointF delta = screenPos - screenPos.toPoint();
touchPoint.d->pos = w->mapFromGlobal(screenPos.toPoint()) + delta; touchPoint.d->pos = w->mapFromGlobal(screenPos.toPoint()) + delta;
@ -2989,7 +2989,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
// touchPoint is actually a reference to one that is stored in activeTouchPoints, // touchPoint is actually a reference to one that is stored in activeTouchPoints,
// and we are now going to store the startPos and lastPos there, for the benefit // and we are now going to store the startPos and lastPos there, for the benefit
// of future moves and releases. It's important that the d-pointer is NOT detached. // of future moves and releases. It's important that the d-pointer is NOT detached.
touchPoint.d->startPos = w->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta; touchPoint.d->startPos = w->mapFromGlobal(touchPoint.globalPressPosition().toPoint()) + delta;
touchPoint.d->lastPos = w->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; touchPoint.d->lastPos = w->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta;
} }
} }
@ -3023,12 +3023,12 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
if (touchPoint.id() == m_fakeMouseSourcePointId) { if (touchPoint.id() == m_fakeMouseSourcePointId) {
if (eventType != QEvent::TouchEnd) if (eventType != QEvent::TouchEnd)
self->synthesizedMousePoints.insert(w, SynthesizedMouseData( self->synthesizedMousePoints.insert(w, SynthesizedMouseData(
touchPoint.pos(), touchPoint.screenPos(), w)); touchPoint.position(), touchPoint.globalPosition(), w));
// All touch events that are not accepted by the application will be translated to // All touch events that are not accepted by the application will be translated to
// left mouse button events instead (see AA_SynthesizeMouseForUnhandledTouchEvents docs). // left mouse button events instead (see AA_SynthesizeMouseForUnhandledTouchEvents docs).
QWindowSystemInterfacePrivate::MouseEvent fake(w, e->timestamp, QWindowSystemInterfacePrivate::MouseEvent fake(w, e->timestamp,
touchPoint.pos(), touchPoint.position(),
touchPoint.screenPos(), touchPoint.globalPosition(),
buttons, buttons,
e->modifiers, e->modifiers,
button, button,

View File

@ -114,7 +114,7 @@ void QBasicDrag::disableEventFilter()
static inline QPoint getNativeMousePos(QEvent *e, QWindow *window) static inline QPoint getNativeMousePos(QEvent *e, QWindow *window)
{ {
return QHighDpi::toNativePixels(static_cast<QMouseEvent *>(e)->globalPos(), window); return QHighDpi::toNativePixels(static_cast<QMouseEvent *>(e)->globalPosition().toPoint(), window);
} }
bool QBasicDrag::eventFilter(QObject *o, QEvent *e) bool QBasicDrag::eventFilter(QObject *o, QEvent *e)
@ -176,13 +176,13 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e)
// If there is no such window (belonging to this Qt application), // If there is no such window (belonging to this Qt application),
// make the event relative to the window where the drag started. (QTBUG-66103) // make the event relative to the window where the drag started. (QTBUG-66103)
const QMouseEvent *release = static_cast<QMouseEvent *>(e); const QMouseEvent *release = static_cast<QMouseEvent *>(e);
const QWindow *releaseWindow = topLevelAt(release->globalPos()); const QWindow *releaseWindow = topLevelAt(release->globalPosition().toPoint());
qCDebug(lcDnd) << "mouse released over" << releaseWindow << "after drag from" << m_sourceWindow << "globalPos" << release->globalPos(); qCDebug(lcDnd) << "mouse released over" << releaseWindow << "after drag from" << m_sourceWindow << "globalPos" << release->globalPosition().toPoint();
if (!releaseWindow) if (!releaseWindow)
releaseWindow = m_sourceWindow; releaseWindow = m_sourceWindow;
QPoint releaseWindowPos = (releaseWindow ? releaseWindow->mapFromGlobal(release->globalPos()) : release->globalPos()); QPoint releaseWindowPos = (releaseWindow ? releaseWindow->mapFromGlobal(release->globalPosition().toPoint()) : release->globalPosition().toPoint());
QMouseEvent *newRelease = new QMouseEvent(release->type(), QMouseEvent *newRelease = new QMouseEvent(release->type(),
releaseWindowPos, releaseWindowPos, release->screenPos(), releaseWindowPos, releaseWindowPos, release->globalPosition(),
release->button(), release->buttons(), release->button(), release->buttons(),
release->modifiers(), release->source()); release->modifiers(), release->source());
QCoreApplication::postEvent(o, newRelease); QCoreApplication::postEvent(o, newRelease);

View File

@ -709,7 +709,7 @@ QList<QWindowSystemInterface::TouchPoint>
p.flags = pt.flags(); p.flags = pt.flags();
p.normalPosition = QHighDpi::toNativeLocalPosition(pt.normalizedPos(), window); p.normalPosition = QHighDpi::toNativeLocalPosition(pt.normalizedPos(), window);
QRectF area(QPointF(), pt.ellipseDiameters()); QRectF area(QPointF(), pt.ellipseDiameters());
area.moveCenter(pt.screenPos()); area.moveCenter(pt.globalPosition());
// TODO store ellipseDiameters in QWindowSystemInterface::TouchPoint or just use QTouchEvent::TouchPoint // TODO store ellipseDiameters in QWindowSystemInterface::TouchPoint or just use QTouchEvent::TouchPoint
p.area = QHighDpi::toNativePixels(area, window); p.area = QHighDpi::toNativePixels(area, window);
p.pressure = pt.pressure(); p.pressure = pt.pressure();

View File

@ -113,7 +113,7 @@ void QFbCursor::pointerEvent(const QMouseEvent &e)
{ {
if (e.type() != QEvent::MouseMove) if (e.type() != QEvent::MouseMove)
return; return;
m_pos = e.screenPos().toPoint(); m_pos = e.globalPosition().toPoint();
if (!mVisible) if (!mVisible)
return; return;
mCurrentRect = getCurrentRect(); mCurrentRect = getCurrentRect();

View File

@ -323,7 +323,7 @@ void QEglFSCursor::pointerEvent(const QMouseEvent &event)
if (event.type() != QEvent::MouseMove) if (event.type() != QEvent::MouseMove)
return; return;
const QRect oldCursorRect = cursorRect(); const QRect oldCursorRect = cursorRect();
m_cursor.pos = event.screenPos().toPoint(); m_cursor.pos = event.globalPosition().toPoint();
update(oldCursorRect | cursorRect(), false); update(oldCursorRect | cursorRect(), false);
for (QPlatformScreen *screen : m_screen->virtualSiblings()) for (QPlatformScreen *screen : m_screen->virtualSiblings())
static_cast<QEglFSScreen *>(screen)->handleCursorMove(m_cursor.pos); static_cast<QEglFSScreen *>(screen)->handleCursorMove(m_cursor.pos);

View File

@ -151,7 +151,7 @@ void QEglFSKmsGbmCursorDeviceListener::onDeviceListChanged(QInputDeviceManager::
void QEglFSKmsGbmCursor::pointerEvent(const QMouseEvent &event) void QEglFSKmsGbmCursor::pointerEvent(const QMouseEvent &event)
{ {
setPos(event.screenPos().toPoint()); setPos(event.globalPosition().toPoint());
} }
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR

View File

@ -382,7 +382,7 @@ void QWellArray::paintCellContents(QPainter *p, int row, int col, const QRect &r
void QWellArray::mousePressEvent(QMouseEvent *e) void QWellArray::mousePressEvent(QMouseEvent *e)
{ {
// The current cell marker is set to the cell the mouse is pressed in // The current cell marker is set to the cell the mouse is pressed in
QPoint pos = e->pos(); QPoint pos = e->position().toPoint();
setCurrent(rowAt(pos.y()), columnAt(pos.x())); setCurrent(rowAt(pos.y()), columnAt(pos.x()));
} }
@ -626,7 +626,7 @@ void QColorWell::mousePressEvent(QMouseEvent *e)
oldCurrent = QPoint(selectedRow(), selectedColumn()); oldCurrent = QPoint(selectedRow(), selectedColumn());
QWellArray::mousePressEvent(e); QWellArray::mousePressEvent(e);
mousePressed = true; mousePressed = true;
pressPos = e->pos(); pressPos = e->position().toPoint();
} }
void QColorWell::mouseMoveEvent(QMouseEvent *e) void QColorWell::mouseMoveEvent(QMouseEvent *e)
@ -635,7 +635,7 @@ void QColorWell::mouseMoveEvent(QMouseEvent *e)
#if QT_CONFIG(draganddrop) #if QT_CONFIG(draganddrop)
if (!mousePressed) if (!mousePressed)
return; return;
if ((pressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { if ((pressPos - e->position().toPoint()).manhattanLength() > QApplication::startDragDistance()) {
setCurrent(oldCurrent.x(), oldCurrent.y()); setCurrent(oldCurrent.x(), oldCurrent.y());
int i = rowAt(pressPos.y()) + columnAt(pressPos.x()) * numRows(); int i = rowAt(pressPos.y()) + columnAt(pressPos.x()) * numRows();
QColor col(values[i]); QColor col(values[i]);
@ -673,7 +673,7 @@ void QColorWell::dragLeaveEvent(QDragLeaveEvent *)
void QColorWell::dragMoveEvent(QDragMoveEvent *e) void QColorWell::dragMoveEvent(QDragMoveEvent *e)
{ {
if (qvariant_cast<QColor>(e->mimeData()->colorData()).isValid()) { if (qvariant_cast<QColor>(e->mimeData()->colorData()).isValid()) {
setCurrent(rowAt(e->pos().y()), columnAt(e->pos().x())); setCurrent(rowAt(e->position().toPoint().y()), columnAt(e->position().toPoint().x()));
e->accept(); e->accept();
} else { } else {
e->ignore(); e->ignore();
@ -684,7 +684,7 @@ void QColorWell::dropEvent(QDropEvent *e)
{ {
QColor col = qvariant_cast<QColor>(e->mimeData()->colorData()); QColor col = qvariant_cast<QColor>(e->mimeData()->colorData());
if (col.isValid()) { if (col.isValid()) {
int i = rowAt(e->pos().y()) + columnAt(e->pos().x()) * numRows(); int i = rowAt(e->position().toPoint().y()) + columnAt(e->position().toPoint().x()) * numRows();
emit colorChanged(i, col.rgb()); emit colorChanged(i, col.rgb());
e->accept(); e->accept();
} else { } else {
@ -799,11 +799,11 @@ QColorLuminancePicker::~QColorLuminancePicker()
void QColorLuminancePicker::mouseMoveEvent(QMouseEvent *m) void QColorLuminancePicker::mouseMoveEvent(QMouseEvent *m)
{ {
setVal(y2val(m->y())); setVal(y2val(m->position().toPoint().y()));
} }
void QColorLuminancePicker::mousePressEvent(QMouseEvent *m) void QColorLuminancePicker::mousePressEvent(QMouseEvent *m)
{ {
setVal(y2val(m->y())); setVal(y2val(m->position().toPoint().y()));
} }
void QColorLuminancePicker::setVal(int v) void QColorLuminancePicker::setVal(int v)
@ -932,14 +932,14 @@ void QColorPicker::setCol(int h, int s)
void QColorPicker::mouseMoveEvent(QMouseEvent *m) void QColorPicker::mouseMoveEvent(QMouseEvent *m)
{ {
QPoint p = m->pos() - contentsRect().topLeft(); QPoint p = m->position().toPoint() - contentsRect().topLeft();
setCol(p); setCol(p);
emit newCol(hue, sat); emit newCol(hue, sat);
} }
void QColorPicker::mousePressEvent(QMouseEvent *m) void QColorPicker::mousePressEvent(QMouseEvent *m)
{ {
QPoint p = m->pos() - contentsRect().topLeft(); QPoint p = m->position().toPoint() - contentsRect().topLeft();
setCol(p); setCol(p);
emit newCol(hue, sat); emit newCol(hue, sat);
} }
@ -1113,7 +1113,7 @@ inline bool QColorShower::isAlphaVisible() const
void QColorShowLabel::mousePressEvent(QMouseEvent *e) void QColorShowLabel::mousePressEvent(QMouseEvent *e)
{ {
mousePressed = true; mousePressed = true;
pressPos = e->pos(); pressPos = e->position().toPoint();
} }
void QColorShowLabel::mouseMoveEvent(QMouseEvent *e) void QColorShowLabel::mouseMoveEvent(QMouseEvent *e)
@ -1123,7 +1123,7 @@ void QColorShowLabel::mouseMoveEvent(QMouseEvent *e)
#else #else
if (!mousePressed) if (!mousePressed)
return; return;
if ((pressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { if ((pressPos - e->position().toPoint()).manhattanLength() > QApplication::startDragDistance()) {
QMimeData *mime = new QMimeData; QMimeData *mime = new QMimeData;
mime->setColorData(col); mime->setColorData(col);
QPixmap pix(30, 20); QPixmap pix(30, 20);
@ -2219,15 +2219,15 @@ void QColorDialogPrivate::updateColorPicking(const QPoint &globalPos)
bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e) bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e)
{ {
// If the cross is visible the grabbed color will be black most of the times // If the cross is visible the grabbed color will be black most of the times
cp->setCrossVisible(!cp->geometry().contains(e->pos())); cp->setCrossVisible(!cp->geometry().contains(e->position().toPoint()));
updateColorPicking(e->globalPos()); updateColorPicking(e->globalPosition().toPoint());
return true; return true;
} }
bool QColorDialogPrivate::handleColorPickingMouseButtonRelease(QMouseEvent *e) bool QColorDialogPrivate::handleColorPickingMouseButtonRelease(QMouseEvent *e)
{ {
setCurrentColor(grabScreenColor(e->globalPos()), SetColorAll); setCurrentColor(grabScreenColor(e->globalPosition().toPoint()), SetColorAll);
releaseColorPicking(); releaseColorPicking();
return true; return true;
} }

View File

@ -5830,8 +5830,8 @@ void QGraphicsScenePrivate::updateTouchPointsForItem(QGraphicsItem *item, QTouch
item->d_ptr->genericMapFromSceneTransform(static_cast<const QWidget *>(touchEvent->target())); item->d_ptr->genericMapFromSceneTransform(static_cast<const QWidget *>(touchEvent->target()));
for (auto &touchPoint : touchEvent->_touchPoints) { for (auto &touchPoint : touchEvent->_touchPoints) {
touchPoint.setPos(mapFromScene.map(touchPoint.scenePos())); touchPoint.setPos(mapFromScene.map(touchPoint.scenePosition()));
touchPoint.setStartPos(mapFromScene.map(touchPoint.startScenePos())); touchPoint.setStartPos(mapFromScene.map(touchPoint.scenePressPosition()));
touchPoint.setLastPos(mapFromScene.map(touchPoint.lastScenePos())); touchPoint.setLastPos(mapFromScene.map(touchPoint.lastScenePos()));
} }
} }
@ -5841,7 +5841,7 @@ int QGraphicsScenePrivate::findClosestTouchPointId(const QPointF &scenePos)
int closestTouchPointId = -1; int closestTouchPointId = -1;
qreal closestDistance = qreal(0.); qreal closestDistance = qreal(0.);
for (const QTouchEvent::TouchPoint &touchPoint : qAsConst(sceneCurrentTouchPoints)) { for (const QTouchEvent::TouchPoint &touchPoint : qAsConst(sceneCurrentTouchPoints)) {
qreal distance = QLineF(scenePos, touchPoint.scenePos()).length(); qreal distance = QLineF(scenePos, touchPoint.scenePosition()).length();
if (closestTouchPointId == -1|| distance < closestDistance) { if (closestTouchPointId == -1|| distance < closestDistance) {
closestTouchPointId = touchPoint.id(); closestTouchPointId = touchPoint.id();
closestDistance = distance; closestDistance = distance;
@ -5869,15 +5869,15 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent)
if (!item) { if (!item) {
// determine which item this touch point will go to // determine which item this touch point will go to
cachedItemsUnderMouse = itemsAtPosition(touchPoint.screenPos().toPoint(), cachedItemsUnderMouse = itemsAtPosition(touchPoint.globalPosition().toPoint(),
touchPoint.scenePos(), touchPoint.scenePosition(),
static_cast<QWidget *>(sceneTouchEvent->target())); static_cast<QWidget *>(sceneTouchEvent->target()));
item = cachedItemsUnderMouse.isEmpty() ? 0 : cachedItemsUnderMouse.constFirst(); item = cachedItemsUnderMouse.isEmpty() ? 0 : cachedItemsUnderMouse.constFirst();
} }
if (sceneTouchEvent->device()->type() == QTouchDevice::TouchScreen) { if (sceneTouchEvent->device()->type() == QTouchDevice::TouchScreen) {
// on touch-screens, combine this touch point with the closest one we find // on touch-screens, combine this touch point with the closest one we find
int closestTouchPointId = findClosestTouchPointId(touchPoint.scenePos()); int closestTouchPointId = findClosestTouchPointId(touchPoint.scenePosition());
QGraphicsItem *closestItem = itemForTouchPointId.value(closestTouchPointId); QGraphicsItem *closestItem = itemForTouchPointId.value(closestTouchPointId);
if (!item || (closestItem && cachedItemsUnderMouse.contains(closestItem))) if (!item || (closestItem && cachedItemsUnderMouse.contains(closestItem)))
item = closestItem; item = closestItem;
@ -5985,8 +5985,8 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
if (focusOnTouch) { if (focusOnTouch) {
if (cachedItemsUnderMouse.isEmpty() || cachedItemsUnderMouse.constFirst() != origin) { if (cachedItemsUnderMouse.isEmpty() || cachedItemsUnderMouse.constFirst() != origin) {
const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first(); const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first();
cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.screenPos().toPoint(), cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.globalPosition().toPoint(),
firstTouchPoint.scenePos(), firstTouchPoint.scenePosition(),
static_cast<QWidget *>(touchEvent->target())); static_cast<QWidget *>(touchEvent->target()));
} }

View File

@ -318,8 +318,8 @@ void QGraphicsViewPrivate::translateTouchEvent(QGraphicsViewPrivate *d, QTouchEv
const QSizeF ellipseDiameters = touchPoint.ellipseDiameters(); const QSizeF ellipseDiameters = touchPoint.ellipseDiameters();
// the scene will set the item local pos, startPos, lastPos, and rect before delivering to // the scene will set the item local pos, startPos, lastPos, and rect before delivering to
// an item, but for now those functions are returning the view's local coordinates // an item, but for now those functions are returning the view's local coordinates
touchPoint.setScenePos(d->mapToScene(touchPoint.pos())); touchPoint.setScenePos(d->mapToScene(touchPoint.position()));
touchPoint.setStartScenePos(d->mapToScene(touchPoint.startPos())); touchPoint.setStartScenePos(d->mapToScene(touchPoint.pressPosition()));
touchPoint.setLastScenePos(d->mapToScene(touchPoint.lastPos())); touchPoint.setLastScenePos(d->mapToScene(touchPoint.lastPos()));
touchPoint.setEllipseDiameters(ellipseDiameters); touchPoint.setEllipseDiameters(ellipseDiameters);
@ -647,7 +647,7 @@ void QGraphicsViewPrivate::replayLastMouseEvent()
void QGraphicsViewPrivate::storeMouseEvent(QMouseEvent *event) void QGraphicsViewPrivate::storeMouseEvent(QMouseEvent *event)
{ {
useLastMouseEvent = true; useLastMouseEvent = true;
lastMouseEvent = QMouseEvent(QEvent::MouseMove, event->localPos(), event->windowPos(), event->screenPos(), lastMouseEvent = QMouseEvent(QEvent::MouseMove, event->position(), event->scenePosition(), event->globalPosition(),
event->button(), event->buttons(), event->modifiers()); event->button(), event->buttons(), event->modifiers());
} }
@ -673,8 +673,8 @@ void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event)
mouseEvent.setWidget(viewport); mouseEvent.setWidget(viewport);
mouseEvent.setButtonDownScenePos(mousePressButton, mousePressScenePoint); mouseEvent.setButtonDownScenePos(mousePressButton, mousePressScenePoint);
mouseEvent.setButtonDownScreenPos(mousePressButton, mousePressScreenPoint); mouseEvent.setButtonDownScreenPos(mousePressButton, mousePressScreenPoint);
mouseEvent.setScenePos(q->mapToScene(event->pos())); mouseEvent.setScenePos(q->mapToScene(event->position().toPoint()));
mouseEvent.setScreenPos(event->globalPos()); mouseEvent.setScreenPos(event->globalPosition().toPoint());
mouseEvent.setLastScenePos(lastMouseMoveScenePoint); mouseEvent.setLastScenePos(lastMouseMoveScenePoint);
mouseEvent.setLastScreenPos(lastMouseMoveScreenPoint); mouseEvent.setLastScreenPos(lastMouseMoveScreenPoint);
mouseEvent.setButtons(event->buttons()); mouseEvent.setButtons(event->buttons());
@ -753,7 +753,7 @@ void QGraphicsViewPrivate::updateRubberBand(const QMouseEvent *event)
if (dragMode != QGraphicsView::RubberBandDrag || !sceneInteractionAllowed || !rubberBanding) if (dragMode != QGraphicsView::RubberBandDrag || !sceneInteractionAllowed || !rubberBanding)
return; return;
// Check for enough drag distance // Check for enough drag distance
if ((mousePressViewPoint - event->pos()).manhattanLength() < QApplication::startDragDistance()) if ((mousePressViewPoint - event->position().toPoint()).manhattanLength() < QApplication::startDragDistance())
return; return;
// Update old rubberband // Update old rubberband
@ -780,7 +780,7 @@ void QGraphicsViewPrivate::updateRubberBand(const QMouseEvent *event)
// Update rubberband position // Update rubberband position
const QPoint mp = q->mapFromScene(mousePressScenePoint); const QPoint mp = q->mapFromScene(mousePressScenePoint);
const QPoint ep = event->pos(); const QPoint ep = event->position().toPoint();
rubberBandRect = QRect(qMin(mp.x(), ep.x()), qMin(mp.y(), ep.y()), rubberBandRect = QRect(qMin(mp.x(), ep.x()), qMin(mp.y(), ep.y()),
qAbs(mp.x() - ep.x()) + 1, qAbs(mp.y() - ep.y()) + 1); qAbs(mp.x() - ep.x()) + 1, qAbs(mp.y() - ep.y()) + 1);
@ -848,7 +848,7 @@ void QGraphicsViewPrivate::_q_setViewportCursor(const QCursor &cursor)
void QGraphicsViewPrivate::_q_unsetViewportCursor() void QGraphicsViewPrivate::_q_unsetViewportCursor()
{ {
Q_Q(QGraphicsView); Q_Q(QGraphicsView);
const auto items = q->items(lastMouseEvent.pos()); const auto items = q->items(lastMouseEvent.position().toPoint());
for (QGraphicsItem *item : items) { for (QGraphicsItem *item : items) {
if (item->isEnabled() && item->hasCursor()) { if (item->isEnabled() && item->hasCursor()) {
_q_setViewportCursor(item->cursor()); _q_setViewportCursor(item->cursor());
@ -894,10 +894,10 @@ void QGraphicsViewPrivate::populateSceneDragDropEvent(QGraphicsSceneDragDropEven
{ {
#if QT_CONFIG(draganddrop) #if QT_CONFIG(draganddrop)
Q_Q(QGraphicsView); Q_Q(QGraphicsView);
dest->setScenePos(q->mapToScene(source->pos())); dest->setScenePos(q->mapToScene(source->position().toPoint()));
dest->setScreenPos(q->mapToGlobal(source->pos())); dest->setScreenPos(q->mapToGlobal(source->position().toPoint()));
dest->setButtons(source->mouseButtons()); dest->setButtons(source->buttons());
dest->setModifiers(source->keyboardModifiers()); dest->setModifiers(source->modifiers());
dest->setPossibleActions(source->possibleActions()); dest->setPossibleActions(source->possibleActions());
dest->setProposedAction(source->proposedAction()); dest->setProposedAction(source->proposedAction());
dest->setDropAction(source->dropAction()); dest->setDropAction(source->dropAction());
@ -3179,9 +3179,9 @@ void QGraphicsView::mouseDoubleClickEvent(QMouseEvent *event)
return; return;
d->storeMouseEvent(event); d->storeMouseEvent(event);
d->mousePressViewPoint = event->pos(); d->mousePressViewPoint = event->position().toPoint();
d->mousePressScenePoint = mapToScene(d->mousePressViewPoint); d->mousePressScenePoint = mapToScene(d->mousePressViewPoint);
d->mousePressScreenPoint = event->globalPos(); d->mousePressScreenPoint = event->globalPosition().toPoint();
d->lastMouseMoveScenePoint = d->mousePressScenePoint; d->lastMouseMoveScenePoint = d->mousePressScenePoint;
d->lastMouseMoveScreenPoint = d->mousePressScreenPoint; d->lastMouseMoveScreenPoint = d->mousePressScreenPoint;
d->mousePressButton = event->button(); d->mousePressButton = event->button();
@ -3228,9 +3228,9 @@ void QGraphicsView::mousePressEvent(QMouseEvent *event)
if (d->sceneInteractionAllowed) { if (d->sceneInteractionAllowed) {
// Store some of the event's button-down data. // Store some of the event's button-down data.
d->mousePressViewPoint = event->pos(); d->mousePressViewPoint = event->position().toPoint();
d->mousePressScenePoint = mapToScene(d->mousePressViewPoint); d->mousePressScenePoint = mapToScene(d->mousePressViewPoint);
d->mousePressScreenPoint = event->globalPos(); d->mousePressScreenPoint = event->globalPosition().toPoint();
d->lastMouseMoveScenePoint = d->mousePressScenePoint; d->lastMouseMoveScenePoint = d->mousePressScenePoint;
d->lastMouseMoveScreenPoint = d->mousePressScreenPoint; d->lastMouseMoveScreenPoint = d->mousePressScreenPoint;
d->mousePressButton = event->button(); d->mousePressButton = event->button();
@ -3310,7 +3310,7 @@ void QGraphicsView::mouseMoveEvent(QMouseEvent *event)
if (d->handScrolling) { if (d->handScrolling) {
QScrollBar *hBar = horizontalScrollBar(); QScrollBar *hBar = horizontalScrollBar();
QScrollBar *vBar = verticalScrollBar(); QScrollBar *vBar = verticalScrollBar();
QPoint delta = event->pos() - d->lastMouseEvent.pos(); QPoint delta = event->position().toPoint() - d->lastMouseEvent.position().toPoint();
hBar->setValue(hBar->value() + (isRightToLeft() ? delta.x() : -delta.x())); hBar->setValue(hBar->value() + (isRightToLeft() ? delta.x() : -delta.x()));
vBar->setValue(vBar->value() - delta.y()); vBar->setValue(vBar->value() - delta.y());
@ -3364,8 +3364,8 @@ void QGraphicsView::mouseReleaseEvent(QMouseEvent *event)
mouseEvent.setWidget(viewport()); mouseEvent.setWidget(viewport());
mouseEvent.setButtonDownScenePos(d->mousePressButton, d->mousePressScenePoint); mouseEvent.setButtonDownScenePos(d->mousePressButton, d->mousePressScenePoint);
mouseEvent.setButtonDownScreenPos(d->mousePressButton, d->mousePressScreenPoint); mouseEvent.setButtonDownScreenPos(d->mousePressButton, d->mousePressScreenPoint);
mouseEvent.setScenePos(mapToScene(event->pos())); mouseEvent.setScenePos(mapToScene(event->position().toPoint()));
mouseEvent.setScreenPos(event->globalPos()); mouseEvent.setScreenPos(event->globalPosition().toPoint());
mouseEvent.setLastScenePos(d->lastMouseMoveScenePoint); mouseEvent.setLastScenePos(d->lastMouseMoveScenePoint);
mouseEvent.setLastScreenPos(d->lastMouseMoveScreenPoint); mouseEvent.setLastScreenPos(d->lastMouseMoveScreenPoint);
mouseEvent.setButtons(event->buttons()); mouseEvent.setButtons(event->buttons());

View File

@ -1693,7 +1693,7 @@ bool QAbstractItemView::viewportEvent(QEvent *event)
switch (event->type()) { switch (event->type()) {
case QEvent::HoverMove: case QEvent::HoverMove:
case QEvent::HoverEnter: case QEvent::HoverEnter:
d->setHoverIndex(indexAt(static_cast<QHoverEvent*>(event)->pos())); d->setHoverIndex(indexAt(static_cast<QHoverEvent*>(event)->position().toPoint()));
break; break;
case QEvent::HoverLeave: case QEvent::HoverLeave:
d->setHoverIndex(QModelIndex()); d->setHoverIndex(QModelIndex());
@ -1756,7 +1756,7 @@ void QAbstractItemView::mousePressEvent(QMouseEvent *event)
{ {
Q_D(QAbstractItemView); Q_D(QAbstractItemView);
d->delayedAutoScroll.stop(); //any interaction with the view cancel the auto scrolling d->delayedAutoScroll.stop(); //any interaction with the view cancel the auto scrolling
QPoint pos = event->pos(); QPoint pos = event->position().toPoint();
QPersistentModelIndex index = indexAt(pos); QPersistentModelIndex index = indexAt(pos);
if (!d->selectionModel if (!d->selectionModel
@ -1822,7 +1822,7 @@ void QAbstractItemView::mouseMoveEvent(QMouseEvent *event)
{ {
Q_D(QAbstractItemView); Q_D(QAbstractItemView);
QPoint topLeft; QPoint topLeft;
QPoint bottomRight = event->pos(); QPoint bottomRight = event->position().toPoint();
if (state() == ExpandingState || state() == CollapsingState) if (state() == ExpandingState || state() == CollapsingState)
return; return;
@ -1901,7 +1901,7 @@ void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event)
{ {
Q_D(QAbstractItemView); Q_D(QAbstractItemView);
QPoint pos = event->pos(); QPoint pos = event->position().toPoint();
QPersistentModelIndex index = indexAt(pos); QPersistentModelIndex index = indexAt(pos);
if (state() == EditingState) { if (state() == EditingState) {
@ -1949,12 +1949,12 @@ void QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event)
{ {
Q_D(QAbstractItemView); Q_D(QAbstractItemView);
QModelIndex index = indexAt(event->pos()); QModelIndex index = indexAt(event->position().toPoint());
if (!index.isValid() if (!index.isValid()
|| !d->isIndexEnabled(index) || !d->isIndexEnabled(index)
|| (d->pressedIndex != index)) { || (d->pressedIndex != index)) {
QMouseEvent me(QEvent::MouseButtonPress, QMouseEvent me(QEvent::MouseButtonPress,
event->localPos(), event->windowPos(), event->screenPos(), event->position(), event->scenePosition(), event->globalPosition(),
event->button(), event->buttons(), event->modifiers(), event->source()); event->button(), event->buttons(), event->modifiers(), event->source());
mousePressEvent(&me); mousePressEvent(&me);
return; return;
@ -2009,14 +2009,14 @@ void QAbstractItemView::dragMoveEvent(QDragMoveEvent *event)
// ignore by default // ignore by default
event->ignore(); event->ignore();
QModelIndex index = indexAt(event->pos()); QModelIndex index = indexAt(event->position().toPoint());
d->hover = index; d->hover = index;
if (!d->droppingOnItself(event, index) if (!d->droppingOnItself(event, index)
&& d->canDrop(event)) { && d->canDrop(event)) {
if (index.isValid() && d->showDropIndicator) { if (index.isValid() && d->showDropIndicator) {
QRect rect = visualRect(index); QRect rect = visualRect(index);
d->dropIndicatorPosition = d->position(event->pos(), rect, index); d->dropIndicatorPosition = d->position(event->position().toPoint(), rect, index);
switch (d->dropIndicatorPosition) { switch (d->dropIndicatorPosition) {
case AboveItem: case AboveItem:
if (d->isIndexDropEnabled(index.parent())) { if (d->isIndexDropEnabled(index.parent())) {
@ -2059,7 +2059,7 @@ void QAbstractItemView::dragMoveEvent(QDragMoveEvent *event)
d->viewport->update(); d->viewport->update();
} // can drop } // can drop
if (d->shouldAutoScroll(event->pos())) if (d->shouldAutoScroll(event->position().toPoint()))
startAutoScroll(); startAutoScroll();
} }
@ -2156,9 +2156,9 @@ bool QAbstractItemViewPrivate::dropOn(QDropEvent *event, int *dropRow, int *drop
QModelIndex index; QModelIndex index;
// rootIndex() (i.e. the viewport) might be a valid index // rootIndex() (i.e. the viewport) might be a valid index
if (viewport->rect().contains(event->pos())) { if (viewport->rect().contains(event->position().toPoint())) {
index = q->indexAt(event->pos()); index = q->indexAt(event->position().toPoint());
if (!index.isValid() || !q->visualRect(index).contains(event->pos())) if (!index.isValid() || !q->visualRect(index).contains(event->position().toPoint()))
index = root; index = root;
} }
@ -2167,7 +2167,7 @@ bool QAbstractItemViewPrivate::dropOn(QDropEvent *event, int *dropRow, int *drop
int row = -1; int row = -1;
int col = -1; int col = -1;
if (index != root) { if (index != root) {
dropIndicatorPosition = position(event->pos(), q->visualRect(index), index); dropIndicatorPosition = position(event->position().toPoint(), q->visualRect(index), index);
switch (dropIndicatorPosition) { switch (dropIndicatorPosition) {
case QAbstractItemView::AboveItem: case QAbstractItemView::AboveItem:
row = index.row(); row = index.row();

View File

@ -149,7 +149,7 @@ void QColumnViewGrip::mouseDoubleClickEvent(QMouseEvent *event)
void QColumnViewGrip::mousePressEvent(QMouseEvent *event) void QColumnViewGrip::mousePressEvent(QMouseEvent *event)
{ {
Q_D(QColumnViewGrip); Q_D(QColumnViewGrip);
d->originalXLocation = event->globalX(); d->originalXLocation = event->globalPosition().toPoint().x();
event->accept(); event->accept();
} }
@ -160,7 +160,7 @@ void QColumnViewGrip::mousePressEvent(QMouseEvent *event)
void QColumnViewGrip::mouseMoveEvent(QMouseEvent *event) void QColumnViewGrip::mouseMoveEvent(QMouseEvent *event)
{ {
Q_D(QColumnViewGrip); Q_D(QColumnViewGrip);
int offset = event->globalX() - d->originalXLocation; int offset = event->globalPosition().toPoint().x() - d->originalXLocation;
d->originalXLocation = moveGrip(offset) + d->originalXLocation; d->originalXLocation = moveGrip(offset) + d->originalXLocation;
event->accept(); event->accept();
} }

View File

@ -2371,7 +2371,7 @@ bool QHeaderView::event(QEvent *e)
switch (e->type()) { switch (e->type()) {
case QEvent::HoverEnter: { case QEvent::HoverEnter: {
QHoverEvent *he = static_cast<QHoverEvent*>(e); QHoverEvent *he = static_cast<QHoverEvent*>(e);
d->hover = logicalIndexAt(he->pos()); d->hover = logicalIndexAt(he->position().toPoint());
if (d->hover != -1) if (d->hover != -1)
updateSection(d->hover); updateSection(d->hover);
break; } break; }
@ -2384,7 +2384,7 @@ bool QHeaderView::event(QEvent *e)
case QEvent::HoverMove: { case QEvent::HoverMove: {
QHoverEvent *he = static_cast<QHoverEvent*>(e); QHoverEvent *he = static_cast<QHoverEvent*>(e);
int oldHover = d->hover; int oldHover = d->hover;
d->hover = logicalIndexAt(he->pos()); d->hover = logicalIndexAt(he->position().toPoint());
if (d->hover != oldHover) { if (d->hover != oldHover) {
if (oldHover != -1) if (oldHover != -1)
updateSection(oldHover); updateSection(oldHover);
@ -2524,7 +2524,7 @@ void QHeaderView::mousePressEvent(QMouseEvent *e)
Q_D(QHeaderView); Q_D(QHeaderView);
if (d->state != QHeaderViewPrivate::NoState || e->button() != Qt::LeftButton) if (d->state != QHeaderViewPrivate::NoState || e->button() != Qt::LeftButton)
return; return;
int pos = d->orientation == Qt::Horizontal ? e->x() : e->y(); int pos = d->orientation == Qt::Horizontal ? e->position().toPoint().x() : e->position().toPoint().y();
int handle = d->sectionHandleAt(pos); int handle = d->sectionHandleAt(pos);
d->originalSize = -1; // clear the stored original size d->originalSize = -1; // clear the stored original size
if (handle == -1) { if (handle == -1) {
@ -2566,7 +2566,7 @@ void QHeaderView::mousePressEvent(QMouseEvent *e)
void QHeaderView::mouseMoveEvent(QMouseEvent *e) void QHeaderView::mouseMoveEvent(QMouseEvent *e)
{ {
Q_D(QHeaderView); Q_D(QHeaderView);
int pos = d->orientation == Qt::Horizontal ? e->x() : e->y(); int pos = d->orientation == Qt::Horizontal ? e->position().toPoint().x() : e->position().toPoint().y();
if (pos < 0 && d->state != QHeaderViewPrivate::SelectSections) if (pos < 0 && d->state != QHeaderViewPrivate::SelectSections)
return; return;
if (e->buttons() == Qt::NoButton) { if (e->buttons() == Qt::NoButton) {
@ -2594,7 +2594,7 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e)
return; return;
} }
case QHeaderViewPrivate::MoveSection: { case QHeaderViewPrivate::MoveSection: {
if (d->shouldAutoScroll(e->pos())) if (d->shouldAutoScroll(e->position().toPoint()))
d->startAutoScroll(); d->startAutoScroll();
if (qAbs(pos - d->firstPos) >= QApplication::startDragDistance() if (qAbs(pos - d->firstPos) >= QApplication::startDragDistance()
#if QT_CONFIG(label) #if QT_CONFIG(label)
@ -2678,7 +2678,7 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e)
void QHeaderView::mouseReleaseEvent(QMouseEvent *e) void QHeaderView::mouseReleaseEvent(QMouseEvent *e)
{ {
Q_D(QHeaderView); Q_D(QHeaderView);
int pos = d->orientation == Qt::Horizontal ? e->x() : e->y(); int pos = d->orientation == Qt::Horizontal ? e->position().toPoint().x() : e->position().toPoint().y();
switch (d->state) { switch (d->state) {
case QHeaderViewPrivate::MoveSection: case QHeaderViewPrivate::MoveSection:
if (true if (true
@ -2731,7 +2731,7 @@ void QHeaderView::mouseReleaseEvent(QMouseEvent *e)
void QHeaderView::mouseDoubleClickEvent(QMouseEvent *e) void QHeaderView::mouseDoubleClickEvent(QMouseEvent *e)
{ {
Q_D(QHeaderView); Q_D(QHeaderView);
int pos = d->orientation == Qt::Horizontal ? e->x() : e->y(); int pos = d->orientation == Qt::Horizontal ? e->position().toPoint().x() : e->position().toPoint().y();
int handle = d->sectionHandleAt(pos); int handle = d->sectionHandleAt(pos);
if (handle > -1 && sectionResizeMode(handle) == Interactive) { if (handle > -1 && sectionResizeMode(handle) == Interactive) {
emit sectionHandleDoubleClicked(handle); emit sectionHandleDoubleClicked(handle);
@ -2746,7 +2746,7 @@ void QHeaderView::mouseDoubleClickEvent(QMouseEvent *e)
} }
#endif #endif
} else { } else {
emit sectionDoubleClicked(logicalIndexAt(e->pos())); emit sectionDoubleClicked(logicalIndexAt(e->position().toPoint()));
} }
} }

View File

@ -1177,7 +1177,7 @@ bool QItemDelegate::editorEvent(QEvent *event,
QRect emptyRect; QRect emptyRect;
doLayout(option, &checkRect, &emptyRect, &emptyRect, false); doLayout(option, &checkRect, &emptyRect, &emptyRect, false);
QMouseEvent *me = static_cast<QMouseEvent*>(event); QMouseEvent *me = static_cast<QMouseEvent*>(event);
if (me->button() != Qt::LeftButton || !checkRect.contains(me->pos())) if (me->button() != Qt::LeftButton || !checkRect.contains(me->position().toPoint()))
return false; return false;
// eat the double click events inside the check rect // eat the double click events inside the check rect

View File

@ -785,7 +785,7 @@ void QListView::mouseMoveEvent(QMouseEvent *e)
&& d->showElasticBand && d->showElasticBand
&& d->selectionMode != SingleSelection && d->selectionMode != SingleSelection
&& d->selectionMode != NoSelection) { && d->selectionMode != NoSelection) {
QRect rect(d->pressedPosition, e->pos() + QPoint(horizontalOffset(), verticalOffset())); QRect rect(d->pressedPosition, e->position().toPoint() + QPoint(horizontalOffset(), verticalOffset()));
rect = rect.normalized(); rect = rect.normalized();
d->viewport->update(d->mapToViewport(rect.united(d->elasticBand))); d->viewport->update(d->mapToViewport(rect.united(d->elasticBand)));
d->elasticBand = rect; d->elasticBand = rect;
@ -2135,7 +2135,7 @@ void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event)
event->ignore(); event->ignore();
// can't use indexAt, doesn't account for spacing. // can't use indexAt, doesn't account for spacing.
QPoint p = event->pos(); QPoint p = event->position().toPoint();
QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1); QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1);
rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing()); rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing());
const QVector<QModelIndex> intersectVector = dd->intersectingSet(rect); const QVector<QModelIndex> intersectVector = dd->intersectingSet(rect);
@ -2147,7 +2147,7 @@ void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event)
if (index.isValid() && dd->showDropIndicator) { if (index.isValid() && dd->showDropIndicator) {
QRect rect = qq->visualRect(index); QRect rect = qq->visualRect(index);
dd->dropIndicatorPosition = position(event->pos(), rect, index); dd->dropIndicatorPosition = position(event->position().toPoint(), rect, index);
// if spacing, should try to draw between items, not just next to item. // if spacing, should try to draw between items, not just next to item.
switch (dd->dropIndicatorPosition) { switch (dd->dropIndicatorPosition) {
case QAbstractItemView::AboveItem: case QAbstractItemView::AboveItem:
@ -2191,7 +2191,7 @@ void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event)
dd->viewport->update(); dd->viewport->update();
} // can drop } // can drop
if (dd->shouldAutoScroll(event->pos())) if (dd->shouldAutoScroll(event->position().toPoint()))
qq->startAutoScroll(); qq->startAutoScroll();
} }
@ -2212,9 +2212,9 @@ bool QListModeViewBase::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QM
return false; return false;
QModelIndex index; QModelIndex index;
if (dd->viewport->rect().contains(event->pos())) { if (dd->viewport->rect().contains(event->position().toPoint())) {
// can't use indexAt, doesn't account for spacing. // can't use indexAt, doesn't account for spacing.
QPoint p = event->pos(); QPoint p = event->position().toPoint();
QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1); QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1);
rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing()); rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing());
const QVector<QModelIndex> intersectVector = dd->intersectingSet(rect); const QVector<QModelIndex> intersectVector = dd->intersectingSet(rect);
@ -2229,7 +2229,7 @@ bool QListModeViewBase::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QM
int row = -1; int row = -1;
int col = -1; int col = -1;
if (index != dd->root) { if (index != dd->root) {
dd->dropIndicatorPosition = position(event->pos(), qq->visualRect(index), index); dd->dropIndicatorPosition = position(event->position().toPoint(), qq->visualRect(index), index);
switch (dd->dropIndicatorPosition) { switch (dd->dropIndicatorPosition) {
case QAbstractItemView::AboveItem: case QAbstractItemView::AboveItem:
row = index.row(); row = index.row();
@ -2896,7 +2896,7 @@ bool QIconModeViewBase::filterDropEvent(QDropEvent *e)
const QSize contents = contentsSize; const QSize contents = contentsSize;
QPoint offset(horizontalOffset(), verticalOffset()); QPoint offset(horizontalOffset(), verticalOffset());
QPoint end = e->pos() + offset; QPoint end = e->position().toPoint() + offset;
if (qq->acceptDrops()) { if (qq->acceptDrops()) {
const Qt::ItemFlags dropableFlags = Qt::ItemIsDropEnabled|Qt::ItemIsEnabled; const Qt::ItemFlags dropableFlags = Qt::ItemIsDropEnabled|Qt::ItemIsEnabled;
const QVector<QModelIndex> &dropIndices = intersectingSet(QRect(end, QSize(1, 1))); const QVector<QModelIndex> &dropIndices = intersectingSet(QRect(end, QSize(1, 1)));
@ -2957,17 +2957,17 @@ bool QIconModeViewBase::filterDragMoveEvent(QDragMoveEvent *e)
QRect itemsRect = this->itemsRect(draggedItems); QRect itemsRect = this->itemsRect(draggedItems);
viewport()->update(itemsRect.translated(draggedItemsDelta())); viewport()->update(itemsRect.translated(draggedItemsDelta()));
// update position // update position
draggedItemsPos = e->pos(); draggedItemsPos = e->position().toPoint();
// get new items rect // get new items rect
viewport()->update(itemsRect.translated(draggedItemsDelta())); viewport()->update(itemsRect.translated(draggedItemsDelta()));
// set the item under the cursor to current // set the item under the cursor to current
QModelIndex index; QModelIndex index;
if (movement() == QListView::Snap) { if (movement() == QListView::Snap) {
QRect rect(snapToGrid(e->pos() + offset()), gridSize()); QRect rect(snapToGrid(e->position().toPoint() + offset()), gridSize());
const QVector<QModelIndex> intersectVector = intersectingSet(rect); const QVector<QModelIndex> intersectVector = intersectingSet(rect);
index = intersectVector.count() > 0 ? intersectVector.last() : QModelIndex(); index = intersectVector.count() > 0 ? intersectVector.last() : QModelIndex();
} else { } else {
index = qq->indexAt(e->pos()); index = qq->indexAt(e->position().toPoint());
} }
// check if we allow drops here // check if we allow drops here
if (draggedItems.contains(index)) if (draggedItems.contains(index))
@ -2978,7 +2978,7 @@ bool QIconModeViewBase::filterDragMoveEvent(QDragMoveEvent *e)
e->accept(); // allow dropping in empty areas e->accept(); // allow dropping in empty areas
// the event was treated. do autoscrolling // the event was treated. do autoscrolling
if (dd->shouldAutoScroll(e->pos())) if (dd->shouldAutoScroll(e->position().toPoint()))
dd->startAutoScroll(); dd->startAutoScroll();
return true; return true;
} }

View File

@ -612,7 +612,7 @@ bool QStyledItemDelegate::editorEvent(QEvent *event,
initStyleOption(&viewOpt, index); initStyleOption(&viewOpt, index);
QRect checkRect = style->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &viewOpt, widget); QRect checkRect = style->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &viewOpt, widget);
QMouseEvent *me = static_cast<QMouseEvent*>(event); QMouseEvent *me = static_cast<QMouseEvent*>(event);
if (me->button() != Qt::LeftButton || !checkRect.contains(me->pos())) if (me->button() != Qt::LeftButton || !checkRect.contains(me->position().toPoint()))
return false; return false;
if ((event->type() == QEvent::MouseButtonPress) if ((event->type() == QEvent::MouseButtonPress)

View File

@ -1297,8 +1297,8 @@ bool QTreeView::viewportEvent(QEvent *event)
case QEvent::HoverMove: { case QEvent::HoverMove: {
QHoverEvent *he = static_cast<QHoverEvent*>(event); QHoverEvent *he = static_cast<QHoverEvent*>(event);
int oldBranch = d->hoverBranch; int oldBranch = d->hoverBranch;
d->hoverBranch = d->itemDecorationAt(he->pos()); d->hoverBranch = d->itemDecorationAt(he->position().toPoint());
QModelIndex newIndex = indexAt(he->pos()); QModelIndex newIndex = indexAt(he->position().toPoint());
if (d->hover != newIndex || d->hoverBranch != oldBranch) { if (d->hover != newIndex || d->hoverBranch != oldBranch) {
// Update the whole hovered over row. No need to update the old hovered // Update the whole hovered over row. No need to update the old hovered
// row, that is taken care in superclass hover handling. // row, that is taken care in superclass hover handling.
@ -1907,8 +1907,8 @@ void QTreeView::mousePressEvent(QMouseEvent *event)
Q_D(QTreeView); Q_D(QTreeView);
bool handled = false; bool handled = false;
if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, nullptr, this) == QEvent::MouseButtonPress) if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, nullptr, this) == QEvent::MouseButtonPress)
handled = d->expandOrCollapseItemAtPos(event->pos()); handled = d->expandOrCollapseItemAtPos(event->position().toPoint());
if (!handled && d->itemDecorationAt(event->pos()) == -1) if (!handled && d->itemDecorationAt(event->position().toPoint()) == -1)
QAbstractItemView::mousePressEvent(event); QAbstractItemView::mousePressEvent(event);
else else
d->pressedIndex = QModelIndex(); d->pressedIndex = QModelIndex();
@ -1920,13 +1920,13 @@ void QTreeView::mousePressEvent(QMouseEvent *event)
void QTreeView::mouseReleaseEvent(QMouseEvent *event) void QTreeView::mouseReleaseEvent(QMouseEvent *event)
{ {
Q_D(QTreeView); Q_D(QTreeView);
if (d->itemDecorationAt(event->pos()) == -1) { if (d->itemDecorationAt(event->position().toPoint()) == -1) {
QAbstractItemView::mouseReleaseEvent(event); QAbstractItemView::mouseReleaseEvent(event);
} else { } else {
if (state() == QAbstractItemView::DragSelectingState || state() == QAbstractItemView::DraggingState) if (state() == QAbstractItemView::DragSelectingState || state() == QAbstractItemView::DraggingState)
setState(QAbstractItemView::NoState); setState(QAbstractItemView::NoState);
if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, nullptr, this) == QEvent::MouseButtonRelease) if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, nullptr, this) == QEvent::MouseButtonRelease)
d->expandOrCollapseItemAtPos(event->pos()); d->expandOrCollapseItemAtPos(event->position().toPoint());
} }
} }
@ -1936,17 +1936,17 @@ void QTreeView::mouseReleaseEvent(QMouseEvent *event)
void QTreeView::mouseDoubleClickEvent(QMouseEvent *event) void QTreeView::mouseDoubleClickEvent(QMouseEvent *event)
{ {
Q_D(QTreeView); Q_D(QTreeView);
if (state() != NoState || !d->viewport->rect().contains(event->pos())) if (state() != NoState || !d->viewport->rect().contains(event->position().toPoint()))
return; return;
int i = d->itemDecorationAt(event->pos()); int i = d->itemDecorationAt(event->position().toPoint());
if (i == -1) { if (i == -1) {
i = d->itemAtCoordinate(event->y()); i = d->itemAtCoordinate(event->position().toPoint().y());
if (i == -1) if (i == -1)
return; // user clicked outside the items return; // user clicked outside the items
const QPersistentModelIndex firstColumnIndex = d->viewItems.at(i).index; const QPersistentModelIndex firstColumnIndex = d->viewItems.at(i).index;
const QPersistentModelIndex persistent = indexAt(event->pos()); const QPersistentModelIndex persistent = indexAt(event->position().toPoint());
if (d->pressedIndex != persistent) { if (d->pressedIndex != persistent) {
mousePressEvent(event); mousePressEvent(event);
@ -1995,7 +1995,7 @@ void QTreeView::mouseDoubleClickEvent(QMouseEvent *event)
void QTreeView::mouseMoveEvent(QMouseEvent *event) void QTreeView::mouseMoveEvent(QMouseEvent *event)
{ {
Q_D(QTreeView); Q_D(QTreeView);
if (d->itemDecorationAt(event->pos()) == -1) // ### what about expanding/collapsing state ? if (d->itemDecorationAt(event->position().toPoint()) == -1) // ### what about expanding/collapsing state ?
QAbstractItemView::mouseMoveEvent(event); QAbstractItemView::mouseMoveEvent(event);
} }

View File

@ -2380,7 +2380,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
const bool graphicsWidget = nativeWidget->testAttribute(Qt::WA_DontShowOnScreen); const bool graphicsWidget = nativeWidget->testAttribute(Qt::WA_DontShowOnScreen);
bool widgetUnderMouse = QRectF(receiver->rect()).contains(event->localPos()); bool widgetUnderMouse = QRectF(receiver->rect()).contains(event->position());
// Clear the obsolete leaveAfterRelease value, if mouse button has been released but // Clear the obsolete leaveAfterRelease value, if mouse button has been released but
// leaveAfterRelease has not been updated. // leaveAfterRelease has not been updated.
@ -2406,9 +2406,9 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
|| (isAlien(lastMouseReceiver) && !alienWidget)) { || (isAlien(lastMouseReceiver) && !alienWidget)) {
if (activePopupWidget) { if (activePopupWidget) {
if (!QWidget::mouseGrabber()) if (!QWidget::mouseGrabber())
dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver, event->screenPos()); dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver, event->globalPosition());
} else { } else {
dispatchEnterLeave(receiver, lastMouseReceiver, event->screenPos()); dispatchEnterLeave(receiver, lastMouseReceiver, event->globalPosition());
} }
} }
@ -2416,7 +2416,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
#ifdef ALIEN_DEBUG #ifdef ALIEN_DEBUG
qDebug() << "QApplicationPrivate::sendMouseEvent: receiver:" << receiver qDebug() << "QApplicationPrivate::sendMouseEvent: receiver:" << receiver
<< "pos:" << event->pos() << "alien" << alienWidget << "button down" << "pos:" << event->position() << "alien" << alienWidget << "button down"
<< *buttonDown << "last" << lastMouseReceiver << "leave after release" << *buttonDown << "last" << lastMouseReceiver << "leave after release"
<< leaveAfterRelease; << leaveAfterRelease;
#endif #endif
@ -2445,8 +2445,8 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
if (nativeGuard) if (nativeGuard)
enter = alienGuard ? alienWidget : nativeWidget; enter = alienGuard ? alienWidget : nativeWidget;
else // The receiver is typically deleted on mouse release with drag'n'drop. else // The receiver is typically deleted on mouse release with drag'n'drop.
enter = QApplication::widgetAt(event->globalPos()); enter = QApplication::widgetAt(event->globalPosition().toPoint());
dispatchEnterLeave(enter, leaveAfterRelease, event->screenPos()); dispatchEnterLeave(enter, leaveAfterRelease, event->globalPosition());
leaveAfterRelease = nullptr; leaveAfterRelease = nullptr;
lastMouseReceiver = enter; lastMouseReceiver = enter;
} else if (!wasLeaveAfterRelease) { } else if (!wasLeaveAfterRelease) {
@ -2454,7 +2454,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
if (!QWidget::mouseGrabber()) if (!QWidget::mouseGrabber())
lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget : nullptr); lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget : nullptr);
} else { } else {
lastMouseReceiver = receiverGuard ? receiver : QApplication::widgetAt(event->globalPos()); lastMouseReceiver = receiverGuard ? receiver : QApplication::widgetAt(event->globalPosition().toPoint());
} }
} }
@ -2904,7 +2904,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
QWidget* w = static_cast<QWidget *>(receiver); QWidget* w = static_cast<QWidget *>(receiver);
QMouseEvent* mouse = static_cast<QMouseEvent*>(e); QMouseEvent* mouse = static_cast<QMouseEvent*>(e);
QPoint relpos = mouse->pos(); QPoint relpos = mouse->position().toPoint();
if (e->spontaneous()) { if (e->spontaneous()) {
if (e->type() != QEvent::MouseMove) if (e->type() != QEvent::MouseMove)
@ -2921,7 +2921,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
&& w->rect().contains(relpos)) { // Outside due to mouse grab? && w->rect().contains(relpos)) { // Outside due to mouse grab?
d->toolTipWidget = w; d->toolTipWidget = w;
d->toolTipPos = relpos; d->toolTipPos = relpos;
d->toolTipGlobalPos = mouse->globalPos(); d->toolTipGlobalPos = mouse->globalPosition().toPoint();
QStyle *s = d->toolTipWidget->style(); QStyle *s = d->toolTipWidget->style();
int wakeDelay = s->styleHint(QStyle::SH_ToolTip_WakeUpDelay, nullptr, d->toolTipWidget, nullptr); int wakeDelay = s->styleHint(QStyle::SH_ToolTip_WakeUpDelay, nullptr, d->toolTipWidget, nullptr);
d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive() ? 20 : wakeDelay, this); d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive() ? 20 : wakeDelay, this);
@ -2932,7 +2932,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
QPointer<QWidget> pw = w; QPointer<QWidget> pw = w;
while (w) { while (w) {
QMouseEvent me(mouse->type(), relpos, mouse->windowPos(), mouse->globalPos(), QMouseEvent me(mouse->type(), relpos, mouse->scenePosition(), mouse->globalPosition().toPoint(),
mouse->button(), mouse->buttons(), mouse->modifiers(), mouse->source()); mouse->button(), mouse->buttons(), mouse->modifiers(), mouse->source());
me.spont = mouse->spontaneous(); me.spont = mouse->spontaneous();
me.setTimestamp(mouse->timestamp()); me.setTimestamp(mouse->timestamp());
@ -2964,7 +2964,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
break; break;
w = static_cast<QWidget *>(receiver); w = static_cast<QWidget *>(receiver);
relpos = mouse->pos(); relpos = mouse->position().toPoint();
QPoint diff = relpos - w->mapFromGlobal(d->hoverGlobalPos); QPoint diff = relpos - w->mapFromGlobal(d->hoverGlobalPos);
while (w) { while (w) {
if (w->testAttribute(Qt::WA_Hover) && if (w->testAttribute(Qt::WA_Hover) &&
@ -2979,7 +2979,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
} }
} }
d->hoverGlobalPos = mouse->globalPos(); d->hoverGlobalPos = mouse->globalPosition().toPoint();
} }
break; break;
#if QT_CONFIG(wheelevent) #if QT_CONFIG(wheelevent)
@ -3109,10 +3109,10 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
{ {
QWidget *w = static_cast<QWidget *>(receiver); QWidget *w = static_cast<QWidget *>(receiver);
QTabletEvent *tablet = static_cast<QTabletEvent*>(e); QTabletEvent *tablet = static_cast<QTabletEvent*>(e);
QPointF relpos = tablet->posF(); QPointF relpos = tablet->position();
bool eventAccepted = tablet->isAccepted(); bool eventAccepted = tablet->isAccepted();
while (w) { while (w) {
QTabletEvent te(tablet->type(), relpos, tablet->globalPosF(), QTabletEvent te(tablet->type(), relpos, tablet->globalPosition(),
tablet->deviceType(), tablet->pointerType(), tablet->deviceType(), tablet->pointerType(),
tablet->pressure(), tablet->xTilt(), tablet->yTilt(), tablet->pressure(), tablet->xTilt(), tablet->yTilt(),
tablet->tangentialPressure(), tablet->rotation(), tablet->z(), tablet->tangentialPressure(), tablet->rotation(), tablet->z(),
@ -3246,7 +3246,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents); bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents);
if (acceptTouchEvents && e->spontaneous()) { if (acceptTouchEvents && e->spontaneous()) {
const QPoint localPos = touchEvent->touchPoints()[0].pos().toPoint(); const QPoint localPos = touchEvent->touchPoints()[0].position().toPoint();
QApplicationPrivate::giveFocusAccordingToFocusPolicy(widget, e, localPos); QApplicationPrivate::giveFocusAccordingToFocusPolicy(widget, e, localPos);
} }
@ -3286,8 +3286,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
touchEvent->setTarget(widget); touchEvent->setTarget(widget);
for (int i = 0; i < touchEvent->_touchPoints.size(); ++i) { for (int i = 0; i < touchEvent->_touchPoints.size(); ++i) {
QTouchEvent::TouchPoint &pt = touchEvent->_touchPoints[i]; QTouchEvent::TouchPoint &pt = touchEvent->_touchPoints[i];
pt.d->pos = pt.pos() + offset; pt.d->pos = pt.position() + offset;
pt.d->startPos = pt.startPos() + offset; pt.d->startPos = pt.pressPosition() + offset;
pt.d->lastPos = pt.lastPos() + offset; pt.d->lastPos = pt.lastPos() + offset;
} }
} }
@ -3936,11 +3936,11 @@ bool QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEven
QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i]; QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i];
// preserve the sub-pixel resolution // preserve the sub-pixel resolution
const QPointF screenPos = touchPoint.screenPos(); const QPointF screenPos = touchPoint.globalPosition();
const QPointF delta = screenPos - screenPos.toPoint(); const QPointF delta = screenPos - screenPos.toPoint();
touchPoint.d->pos = widget->mapFromGlobal(screenPos.toPoint()) + delta; touchPoint.d->pos = widget->mapFromGlobal(screenPos.toPoint()) + delta;
touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta; touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.globalPressPosition().toPoint()) + delta;
touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta;
if (touchPoint.state() == Qt::TouchPointPressed) if (touchPoint.state() == Qt::TouchPointPressed)
@ -3969,7 +3969,7 @@ void QApplicationPrivate::cleanupMultitouch_sys()
QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, const QTouchEvent::TouchPoint &touchPoint) QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, const QTouchEvent::TouchPoint &touchPoint)
{ {
const QPointF screenPos = touchPoint.screenPos(); const QPointF screenPos = touchPoint.globalPosition();
int closestTouchPointId = -1; int closestTouchPointId = -1;
QObject *closestTarget = nullptr; QObject *closestTarget = nullptr;
qreal closestDistance = qreal(0.); qreal closestDistance = qreal(0.);
@ -3978,8 +3978,8 @@ QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device,
while (it != ite) { while (it != ite) {
if (it.key().device == device && it.key().touchPointId != touchPoint.id()) { if (it.key().device == device && it.key().touchPointId != touchPoint.id()) {
const QTouchEvent::TouchPoint &touchPoint = it->touchPoint; const QTouchEvent::TouchPoint &touchPoint = it->touchPoint;
qreal dx = screenPos.x() - touchPoint.screenPos().x(); qreal dx = screenPos.x() - touchPoint.globalPosition().x();
qreal dy = screenPos.y() - touchPoint.screenPos().y(); qreal dy = screenPos.y() - touchPoint.globalPosition().y();
qreal distance = dx * dx + dy * dy; qreal distance = dx * dx + dy * dy;
if (closestTouchPointId == -1 || distance < closestDistance) { if (closestTouchPointId == -1 || distance < closestDistance) {
closestTouchPointId = touchPoint.id(); closestTouchPointId = touchPoint.id();
@ -4034,10 +4034,10 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
if (!target) { if (!target) {
// determine which widget this event will go to // determine which widget this event will go to
if (!window) if (!window)
window = QApplication::topLevelAt(touchPoint.screenPos().toPoint()); window = QApplication::topLevelAt(touchPoint.globalPosition().toPoint());
if (!window) if (!window)
continue; continue;
target = window->childAt(window->mapFromGlobal(touchPoint.screenPos().toPoint())); target = window->childAt(window->mapFromGlobal(touchPoint.globalPosition().toPoint()));
if (!target) if (!target)
target = window; target = window;
} }

View File

@ -67,7 +67,7 @@ QMacSwipeGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *e
case Qt::SwipeNativeGesture: { case Qt::SwipeNativeGesture: {
QSwipeGesture *g = static_cast<QSwipeGesture *>(gesture); QSwipeGesture *g = static_cast<QSwipeGesture *>(gesture);
g->setSwipeAngle(ev->value()); g->setSwipeAngle(ev->value());
g->setHotSpot(ev->screenPos()); g->setHotSpot(ev->globalPosition());
return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint; return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint;
break; } break; }
default: default:
@ -105,11 +105,11 @@ QMacPinchGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *e
switch (ev->gestureType()) { switch (ev->gestureType()) {
case Qt::BeginNativeGesture: case Qt::BeginNativeGesture:
reset(gesture); reset(gesture);
g->setStartCenterPoint(static_cast<QWidget*>(obj)->mapFromGlobal(ev->screenPos().toPoint())); g->setStartCenterPoint(static_cast<QWidget*>(obj)->mapFromGlobal(ev->globalPosition().toPoint()));
g->setCenterPoint(g->startCenterPoint()); g->setCenterPoint(g->startCenterPoint());
g->setChangeFlags(QPinchGesture::CenterPointChanged); g->setChangeFlags(QPinchGesture::CenterPointChanged);
g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags()); g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags());
g->setHotSpot(ev->screenPos()); g->setHotSpot(ev->globalPosition());
return QGestureRecognizer::MayBeGesture | QGestureRecognizer::ConsumeEventHint; return QGestureRecognizer::MayBeGesture | QGestureRecognizer::ConsumeEventHint;
case Qt::RotateNativeGesture: case Qt::RotateNativeGesture:
g->setLastScaleFactor(g->scaleFactor()); g->setLastScaleFactor(g->scaleFactor());
@ -117,7 +117,7 @@ QMacPinchGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *e
g->setRotationAngle(g->rotationAngle() + ev->value()); g->setRotationAngle(g->rotationAngle() + ev->value());
g->setChangeFlags(QPinchGesture::RotationAngleChanged); g->setChangeFlags(QPinchGesture::RotationAngleChanged);
g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags()); g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags());
g->setHotSpot(ev->screenPos()); g->setHotSpot(ev->globalPosition());
return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint; return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
case Qt::ZoomNativeGesture: case Qt::ZoomNativeGesture:
g->setLastScaleFactor(g->scaleFactor()); g->setLastScaleFactor(g->scaleFactor());
@ -126,7 +126,7 @@ QMacPinchGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *e
g->setTotalScaleFactor(g->totalScaleFactor() * g->scaleFactor()); g->setTotalScaleFactor(g->totalScaleFactor() * g->scaleFactor());
g->setChangeFlags(QPinchGesture::ScaleFactorChanged); g->setChangeFlags(QPinchGesture::ScaleFactorChanged);
g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags()); g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags());
g->setHotSpot(ev->screenPos()); g->setHotSpot(ev->globalPosition());
return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint; return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
case Qt::SmartZoomNativeGesture: case Qt::SmartZoomNativeGesture:
g->setLastScaleFactor(g->scaleFactor()); g->setLastScaleFactor(g->scaleFactor());
@ -134,7 +134,7 @@ QMacPinchGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *e
g->setScaleFactor(ev->value() ? 1.7f : 1.0f); g->setScaleFactor(ev->value() ? 1.7f : 1.0f);
g->setChangeFlags(QPinchGesture::ScaleFactorChanged); g->setChangeFlags(QPinchGesture::ScaleFactorChanged);
g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags()); g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags());
g->setHotSpot(ev->screenPos()); g->setHotSpot(ev->globalPosition());
return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint; return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
case Qt::EndNativeGesture: case Qt::EndNativeGesture:
return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint; return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint;

View File

@ -76,7 +76,7 @@ static QPointF panOffset(const QList<QTouchEvent::TouchPoint> &touchPoints, int
QPointF result; QPointF result;
const int count = qMin(touchPoints.size(), maxCount); const int count = qMin(touchPoints.size(), maxCount);
for (int p = 0; p < count; ++p) for (int p = 0; p < count; ++p)
result += touchPoints.at(p).pos() - touchPoints.at(p).startPos(); result += touchPoints.at(p).position() - touchPoints.at(p).pressPosition();
return result / qreal(count); return result / qreal(count);
} }
@ -117,7 +117,7 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state,
d->offset = panOffset(ev->touchPoints(), d->pointCount); d->offset = panOffset(ev->touchPoints(), d->pointCount);
if (d->offset.x() > 10 || d->offset.y() > 10 || if (d->offset.x() > 10 || d->offset.y() > 10 ||
d->offset.x() < -10 || d->offset.y() < -10) { d->offset.x() < -10 || d->offset.y() < -10) {
q->setHotSpot(ev->touchPoints().first().startScreenPos()); q->setHotSpot(ev->touchPoints().first().globalPressPosition());
result = QGestureRecognizer::TriggerGesture; result = QGestureRecognizer::TriggerGesture;
} else { } else {
result = QGestureRecognizer::MayBeGesture; result = QGestureRecognizer::MayBeGesture;
@ -188,13 +188,13 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state,
QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0); QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0);
QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1); QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1);
d->hotSpot = p1.screenPos(); d->hotSpot = p1.globalPosition();
d->isHotSpotSet = true; d->isHotSpotSet = true;
QPointF centerPoint = (p1.screenPos() + p2.screenPos()) / 2.0; QPointF centerPoint = (p1.globalPosition() + p2.globalPosition()) / 2.0;
if (d->isNewSequence) { if (d->isNewSequence) {
d->startPosition[0] = p1.screenPos(); d->startPosition[0] = p1.globalPosition();
d->startPosition[1] = p2.screenPos(); d->startPosition[1] = p2.globalPosition();
d->lastCenterPoint = centerPoint; d->lastCenterPoint = centerPoint;
} else { } else {
d->lastCenterPoint = d->centerPoint; d->lastCenterPoint = d->centerPoint;
@ -208,7 +208,7 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state,
d->lastScaleFactor = 1.0; d->lastScaleFactor = 1.0;
} else { } else {
d->lastScaleFactor = d->scaleFactor; d->lastScaleFactor = d->scaleFactor;
QLineF line(p1.screenPos(), p2.screenPos()); QLineF line(p1.globalPosition(), p2.globalPosition());
QLineF lastLine(p1.lastScreenPos(), p2.lastScreenPos()); QLineF lastLine(p1.lastScreenPos(), p2.lastScreenPos());
qreal newScaleFactor = line.length() / lastLine.length(); qreal newScaleFactor = line.length() / lastLine.length();
if (newScaleFactor > kSingleStepScaleMax || newScaleFactor < kSingleStepScaleMin) if (newScaleFactor > kSingleStepScaleMax || newScaleFactor < kSingleStepScaleMin)
@ -218,10 +218,10 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state,
d->totalScaleFactor = d->totalScaleFactor * d->scaleFactor; d->totalScaleFactor = d->totalScaleFactor * d->scaleFactor;
d->changeFlags |= QPinchGesture::ScaleFactorChanged; d->changeFlags |= QPinchGesture::ScaleFactorChanged;
qreal angle = QLineF(p1.screenPos(), p2.screenPos()).angle(); qreal angle = QLineF(p1.globalPosition(), p2.globalPosition()).angle();
if (angle > 180) if (angle > 180)
angle -= 360; angle -= 360;
qreal startAngle = QLineF(p1.startScreenPos(), p2.startScreenPos()).angle(); qreal startAngle = QLineF(p1.globalPressPosition(), p2.globalPressPosition()).angle();
if (startAngle > 180) if (startAngle > 180)
startAngle -= 360; startAngle -= 360;
const qreal rotationAngle = startAngle - angle; const qreal rotationAngle = startAngle - angle;
@ -320,34 +320,34 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
QTouchEvent::TouchPoint p3 = ev->touchPoints().at(2); QTouchEvent::TouchPoint p3 = ev->touchPoints().at(2);
if (d->lastPositions[0].isNull()) { if (d->lastPositions[0].isNull()) {
d->lastPositions[0] = p1.startScreenPos().toPoint(); d->lastPositions[0] = p1.globalPressPosition().toPoint();
d->lastPositions[1] = p2.startScreenPos().toPoint(); d->lastPositions[1] = p2.globalPressPosition().toPoint();
d->lastPositions[2] = p3.startScreenPos().toPoint(); d->lastPositions[2] = p3.globalPressPosition().toPoint();
} }
d->hotSpot = p1.screenPos(); d->hotSpot = p1.globalPosition();
d->isHotSpotSet = true; d->isHotSpotSet = true;
int xDistance = (p1.screenPos().x() - d->lastPositions[0].x() + int xDistance = (p1.globalPosition().x() - d->lastPositions[0].x() +
p2.screenPos().x() - d->lastPositions[1].x() + p2.globalPosition().x() - d->lastPositions[1].x() +
p3.screenPos().x() - d->lastPositions[2].x()) / 3; p3.globalPosition().x() - d->lastPositions[2].x()) / 3;
int yDistance = (p1.screenPos().y() - d->lastPositions[0].y() + int yDistance = (p1.globalPosition().y() - d->lastPositions[0].y() +
p2.screenPos().y() - d->lastPositions[1].y() + p2.globalPosition().y() - d->lastPositions[1].y() +
p3.screenPos().y() - d->lastPositions[2].y()) / 3; p3.globalPosition().y() - d->lastPositions[2].y()) / 3;
const int distance = xDistance >= yDistance ? xDistance : yDistance; const int distance = xDistance >= yDistance ? xDistance : yDistance;
int elapsedTime = d->time.restart(); int elapsedTime = d->time.restart();
if (!elapsedTime) if (!elapsedTime)
elapsedTime = 1; elapsedTime = 1;
d->velocityValue = 0.9 * d->velocityValue + (qreal) distance / elapsedTime; d->velocityValue = 0.9 * d->velocityValue + (qreal) distance / elapsedTime;
d->swipeAngle = QLineF(p1.startScreenPos(), p1.screenPos()).angle(); d->swipeAngle = QLineF(p1.globalPressPosition(), p1.globalPosition()).angle();
static const int MoveThreshold = 50; static const int MoveThreshold = 50;
static const int directionChangeThreshold = MoveThreshold / 8; static const int directionChangeThreshold = MoveThreshold / 8;
if (qAbs(xDistance) > MoveThreshold || qAbs(yDistance) > MoveThreshold) { if (qAbs(xDistance) > MoveThreshold || qAbs(yDistance) > MoveThreshold) {
// measure the distance to check if the direction changed // measure the distance to check if the direction changed
d->lastPositions[0] = p1.screenPos().toPoint(); d->lastPositions[0] = p1.globalPosition().toPoint();
d->lastPositions[1] = p2.screenPos().toPoint(); d->lastPositions[1] = p2.globalPosition().toPoint();
d->lastPositions[2] = p3.screenPos().toPoint(); d->lastPositions[2] = p3.globalPosition().toPoint();
result = QGestureRecognizer::TriggerGesture; result = QGestureRecognizer::TriggerGesture;
// QTBUG-46195, small changes in direction should not cause the gesture to be canceled. // QTBUG-46195, small changes in direction should not cause the gesture to be canceled.
if (d->verticalDirection == QSwipeGesture::NoDirection || qAbs(yDistance) > directionChangeThreshold) { if (d->verticalDirection == QSwipeGesture::NoDirection || qAbs(yDistance) > directionChangeThreshold) {
@ -439,8 +439,8 @@ QGestureRecognizer::Result QTapGestureRecognizer::recognize(QGesture *state,
switch (event->type()) { switch (event->type()) {
case QEvent::TouchBegin: { case QEvent::TouchBegin: {
d->position = ev->touchPoints().at(0).pos(); d->position = ev->touchPoints().at(0).position();
q->setHotSpot(ev->touchPoints().at(0).screenPos()); q->setHotSpot(ev->touchPoints().at(0).globalPosition());
result = QGestureRecognizer::TriggerGesture; result = QGestureRecognizer::TriggerGesture;
break; break;
} }
@ -448,7 +448,7 @@ QGestureRecognizer::Result QTapGestureRecognizer::recognize(QGesture *state,
case QEvent::TouchEnd: { case QEvent::TouchEnd: {
if (q->state() != Qt::NoGesture && ev->touchPoints().size() == 1) { if (q->state() != Qt::NoGesture && ev->touchPoints().size() == 1) {
QTouchEvent::TouchPoint p = ev->touchPoints().at(0); QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
QPoint delta = p.pos().toPoint() - p.startPos().toPoint(); QPoint delta = p.position().toPoint() - p.pressPosition().toPoint();
enum { TapRadius = 40 }; enum { TapRadius = 40 };
if (delta.manhattanLength() <= TapRadius) { if (delta.manhattanLength() <= TapRadius) {
if (event->type() == QEvent::TouchEnd) if (event->type() == QEvent::TouchEnd)
@ -526,7 +526,7 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
#endif #endif
case QEvent::MouseButtonPress: { case QEvent::MouseButtonPress: {
const QMouseEvent *me = static_cast<const QMouseEvent *>(event); const QMouseEvent *me = static_cast<const QMouseEvent *>(event);
d->position = me->globalPos(); d->position = me->globalPosition().toPoint();
q->setHotSpot(d->position); q->setHotSpot(d->position);
if (d->timerId) if (d->timerId)
q->killTimer(d->timerId); q->killTimer(d->timerId);
@ -535,7 +535,7 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
} }
case QEvent::TouchBegin: { case QEvent::TouchBegin: {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event); const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
d->position = ev->touchPoints().at(0).startScreenPos(); d->position = ev->touchPoints().at(0).globalPressPosition();
q->setHotSpot(d->position); q->setHotSpot(d->position);
if (d->timerId) if (d->timerId)
q->killTimer(d->timerId); q->killTimer(d->timerId);
@ -552,7 +552,7 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event); const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
if (d->timerId && ev->touchPoints().size() == 1) { if (d->timerId && ev->touchPoints().size() == 1) {
QTouchEvent::TouchPoint p = ev->touchPoints().at(0); QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
QPoint delta = p.pos().toPoint() - p.startPos().toPoint(); QPoint delta = p.position().toPoint() - p.pressPosition().toPoint();
if (delta.manhattanLength() <= TapRadius) if (delta.manhattanLength() <= TapRadius)
return QGestureRecognizer::MayBeGesture; return QGestureRecognizer::MayBeGesture;
} }
@ -560,7 +560,7 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
} }
case QEvent::MouseMove: { case QEvent::MouseMove: {
const QMouseEvent *me = static_cast<const QMouseEvent *>(event); const QMouseEvent *me = static_cast<const QMouseEvent *>(event);
QPoint delta = me->globalPos() - d->position.toPoint(); QPoint delta = me->globalPosition().toPoint() - d->position.toPoint();
if (d->timerId && delta.manhattanLength() <= TapRadius) if (d->timerId && delta.manhattanLength() <= TapRadius)
return QGestureRecognizer::MayBeGesture; return QGestureRecognizer::MayBeGesture;
return QGestureRecognizer::CancelGesture; return QGestureRecognizer::CancelGesture;

View File

@ -264,7 +264,7 @@ void QTipLabel::resizeEvent(QResizeEvent *e)
void QTipLabel::mouseMoveEvent(QMouseEvent *e) void QTipLabel::mouseMoveEvent(QMouseEvent *e)
{ {
if (!rect.isNull()) { if (!rect.isNull()) {
QPoint pos = e->globalPos(); QPoint pos = e->globalPosition().toPoint();
if (widget) if (widget)
pos = widget->mapFromGlobal(pos); pos = widget->mapFromGlobal(pos);
if (!rect.contains(pos)) if (!rect.contains(pos))
@ -358,7 +358,7 @@ bool QTipLabel::eventFilter(QObject *o, QEvent *e)
break; break;
case QEvent::MouseMove: case QEvent::MouseMove:
if (o == widget && !rect.isNull() && !rect.contains(static_cast<QMouseEvent*>(e)->pos())) if (o == widget && !rect.isNull() && !rect.contains(static_cast<QMouseEvent*>(e)->position().toPoint()))
hideTip(); hideTip();
default: default:
break; break;

View File

@ -243,9 +243,9 @@ void QWhatsThat::showEvent(QShowEvent *)
void QWhatsThat::mousePressEvent(QMouseEvent* e) void QWhatsThat::mousePressEvent(QMouseEvent* e)
{ {
pressed = true; pressed = true;
if (e->button() == Qt::LeftButton && rect().contains(e->pos())) { if (e->button() == Qt::LeftButton && rect().contains(e->position().toPoint())) {
if (doc) if (doc)
anchor = doc->documentLayout()->anchorAt(e->pos() - QPoint(hMargin, vMargin)); anchor = doc->documentLayout()->anchorAt(e->position().toPoint() - QPoint(hMargin, vMargin));
return; return;
} }
close(); close();
@ -255,8 +255,8 @@ void QWhatsThat::mouseReleaseEvent(QMouseEvent* e)
{ {
if (!pressed) if (!pressed)
return; return;
if (widget && e->button() == Qt::LeftButton && doc && rect().contains(e->pos())) { if (widget && e->button() == Qt::LeftButton && doc && rect().contains(e->position().toPoint())) {
QString a = doc->documentLayout()->anchorAt(e->pos() - QPoint(hMargin, vMargin)); QString a = doc->documentLayout()->anchorAt(e->position().toPoint() - QPoint(hMargin, vMargin));
QString href; QString href;
if (anchor == a) if (anchor == a)
href = a; href = a;
@ -277,7 +277,7 @@ void QWhatsThat::mouseMoveEvent(QMouseEvent* e)
#else #else
if (!doc) if (!doc)
return; return;
QString a = doc->documentLayout()->anchorAt(e->pos() - QPoint(hMargin, vMargin)); QString a = doc->documentLayout()->anchorAt(e->position().toPoint() - QPoint(hMargin, vMargin));
if (!a.isEmpty()) if (!a.isEmpty())
setCursor(Qt::PointingHandCursor); setCursor(Qt::PointingHandCursor);
else else
@ -438,7 +438,7 @@ bool QWhatsThisPrivate::eventFilter(QObject *o, QEvent *e)
QMouseEvent *me = static_cast<QMouseEvent*>(e); QMouseEvent *me = static_cast<QMouseEvent*>(e);
if (me->button() == Qt::RightButton || customWhatsThis) if (me->button() == Qt::RightButton || customWhatsThis)
return false; return false;
QHelpEvent e(QEvent::WhatsThis, me->pos(), me->globalPos()); QHelpEvent e(QEvent::WhatsThis, me->position().toPoint(), me->globalPosition().toPoint());
if (!QCoreApplication::sendEvent(w, &e) || !e.isAccepted()) if (!QCoreApplication::sendEvent(w, &e) || !e.isAccepted())
leaveOnMouseRelease = true; leaveOnMouseRelease = true;
@ -447,7 +447,7 @@ bool QWhatsThisPrivate::eventFilter(QObject *o, QEvent *e)
case QEvent::MouseMove: case QEvent::MouseMove:
{ {
QMouseEvent *me = static_cast<QMouseEvent*>(e); QMouseEvent *me = static_cast<QMouseEvent*>(e);
QHelpEvent e(QEvent::QueryWhatsThis, me->pos(), me->globalPos()); QHelpEvent e(QEvent::QueryWhatsThis, me->position().toPoint(), me->globalPosition().toPoint());
const bool sentEvent = QCoreApplication::sendEvent(w, &e); const bool sentEvent = QCoreApplication::sendEvent(w, &e);
#ifdef QT_NO_CURSOR #ifdef QT_NO_CURSOR
Q_UNUSED(sentEvent); Q_UNUSED(sentEvent);

View File

@ -9175,7 +9175,7 @@ void QWidget::mousePressEvent(QMouseEvent *event)
if (QApplication::activePopupWidget() == w) // widget does not want to disappear if (QApplication::activePopupWidget() == w) // widget does not want to disappear
w->hide(); // hide at least w->hide(); // hide at least
} }
if (!rect().contains(event->pos())){ if (!rect().contains(event->position().toPoint())){
close(); close();
} }
} }

View File

@ -448,7 +448,7 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
} }
} else { } else {
const QEnterEvent *ee = static_cast<QEnterEvent *>(event); const QEnterEvent *ee = static_cast<QEnterEvent *>(event);
QWidget *child = m_widget->childAt(ee->pos()); QWidget *child = m_widget->childAt(ee->position().toPoint());
QWidget *receiver = child ? child : m_widget.data(); QWidget *receiver = child ? child : m_widget.data();
QWidget *leave = nullptr; QWidget *leave = nullptr;
if (QApplicationPrivate::inPopupMode() && receiver == m_widget if (QApplicationPrivate::inPopupMode() && receiver == m_widget
@ -457,7 +457,7 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
// action on first-level menu. // action on first-level menu.
leave = qt_last_mouse_receiver; leave = qt_last_mouse_receiver;
} }
QApplicationPrivate::dispatchEnterLeave(receiver, leave, ee->screenPos()); QApplicationPrivate::dispatchEnterLeave(receiver, leave, ee->globalPosition());
qt_last_mouse_receiver = receiver; qt_last_mouse_receiver = receiver;
} }
} }
@ -510,9 +510,9 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
QEvent::MouseButtonRelease : QEvent::MouseButtonPress; QEvent::MouseButtonRelease : QEvent::MouseButtonPress;
if (QApplicationPrivate::inPopupMode()) { if (QApplicationPrivate::inPopupMode()) {
QPointer<QWidget> activePopupWidget = QApplication::activePopupWidget(); QPointer<QWidget> activePopupWidget = QApplication::activePopupWidget();
QPoint mapped = event->pos(); QPoint mapped = event->position().toPoint();
if (activePopupWidget != m_widget) if (activePopupWidget != m_widget)
mapped = activePopupWidget->mapFromGlobal(event->globalPos()); mapped = activePopupWidget->mapFromGlobal(event->globalPosition().toPoint());
bool releaseAfter = false; bool releaseAfter = false;
QWidget *popupChild = activePopupWidget->childAt(mapped); QWidget *popupChild = activePopupWidget->childAt(mapped);
@ -546,22 +546,22 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
else if (popupChild) else if (popupChild)
receiver = popupChild; receiver = popupChild;
if (receiver != activePopupWidget) if (receiver != activePopupWidget)
widgetPos = receiver->mapFromGlobal(event->globalPos()); widgetPos = receiver->mapFromGlobal(event->globalPosition().toPoint());
#if !defined(Q_OS_MACOS) && !defined(Q_OS_IOS) // Cocoa tracks popups #if !defined(Q_OS_MACOS) && !defined(Q_OS_IOS) // Cocoa tracks popups
const bool reallyUnderMouse = activePopupWidget->rect().contains(mapped); const bool reallyUnderMouse = activePopupWidget->rect().contains(mapped);
const bool underMouse = activePopupWidget->underMouse(); const bool underMouse = activePopupWidget->underMouse();
if (underMouse != reallyUnderMouse) { if (underMouse != reallyUnderMouse) {
if (reallyUnderMouse) { if (reallyUnderMouse) {
const QPoint receiverMapped = receiver->mapFromGlobal(event->screenPos().toPoint()); const QPoint receiverMapped = receiver->mapFromGlobal(event->globalPosition().toPoint());
// Prevent negative mouse position on enter event - this event // Prevent negative mouse position on enter event - this event
// should be properly handled in "handleEnterLeaveEvent()". // should be properly handled in "handleEnterLeaveEvent()".
if (receiverMapped.x() >= 0 && receiverMapped.y() >= 0) { if (receiverMapped.x() >= 0 && receiverMapped.y() >= 0) {
QApplicationPrivate::dispatchEnterLeave(receiver, nullptr, event->screenPos()); QApplicationPrivate::dispatchEnterLeave(receiver, nullptr, event->globalPosition());
qt_last_mouse_receiver = receiver; qt_last_mouse_receiver = receiver;
} }
} else { } else {
QApplicationPrivate::dispatchEnterLeave(nullptr, qt_last_mouse_receiver, event->screenPos()); QApplicationPrivate::dispatchEnterLeave(nullptr, qt_last_mouse_receiver, event->globalPosition());
qt_last_mouse_receiver = receiver; qt_last_mouse_receiver = receiver;
receiver = activePopupWidget; receiver = activePopupWidget;
} }
@ -572,7 +572,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
// if the widget that was pressed is gone, then deliver move events without buttons // if the widget that was pressed is gone, then deliver move events without buttons
const auto buttons = event->type() == QEvent::MouseMove && qt_button_down == nullptr const auto buttons = event->type() == QEvent::MouseMove && qt_button_down == nullptr
? Qt::NoButton : event->buttons(); ? Qt::NoButton : event->buttons();
QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(), QMouseEvent e(event->type(), widgetPos, event->scenePosition(), event->globalPosition(),
event->button(), buttons, event->modifiers(), event->source()); event->button(), buttons, event->modifiers(), event->source());
e.setTimestamp(event->timestamp()); e.setTimestamp(event->timestamp());
QApplicationPrivate::sendMouseEvent(receiver, &e, receiver, receiver->window(), &qt_button_down, qt_last_mouse_receiver); QApplicationPrivate::sendMouseEvent(receiver, &e, receiver, receiver->window(), &qt_button_down, qt_last_mouse_receiver);
@ -598,7 +598,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
qt_button_down = nullptr; qt_button_down = nullptr;
if (event->type() == QEvent::MouseButtonPress) { if (event->type() == QEvent::MouseButtonPress) {
// the popup disappeared, replay the mouse press event // the popup disappeared, replay the mouse press event
QWidget *w = QApplication::widgetAt(event->globalPos()); QWidget *w = QApplication::widgetAt(event->globalPosition().toPoint());
if (w && !QApplicationPrivate::isBlockedByModal(w)) { if (w && !QApplicationPrivate::isBlockedByModal(w)) {
// activate window of the widget under mouse pointer // activate window of the widget under mouse pointer
if (!w->isActiveWindow()) { if (!w->isActiveWindow()) {
@ -610,10 +610,10 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
const QRect globalGeometry = win->isTopLevel() const QRect globalGeometry = win->isTopLevel()
? win->geometry() ? win->geometry()
: QRect(win->mapToGlobal(QPoint(0, 0)), win->size()); : QRect(win->mapToGlobal(QPoint(0, 0)), win->size());
if (globalGeometry.contains(event->globalPos())) { if (globalGeometry.contains(event->globalPosition().toPoint())) {
// Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec() // Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec()
const QPoint localPos = win->mapFromGlobal(event->globalPos()); const QPoint localPos = win->mapFromGlobal(event->globalPosition().toPoint());
QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPosition().toPoint(),
event->button(), event->buttons(), event->modifiers(), event->source()); event->button(), event->buttons(), event->modifiers(), event->source());
QCoreApplicationPrivate::setEventSpontaneous(e, true); QCoreApplicationPrivate::setEventSpontaneous(e, true);
e->setTimestamp(event->timestamp()); e->setTimestamp(event->timestamp());
@ -632,7 +632,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
receiver = qt_button_down; receiver = qt_button_down;
else if(popupChild) else if(popupChild)
receiver = popupChild; receiver = popupChild;
QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers()); QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPosition().toPoint(), event->modifiers());
QApplication::forwardEvent(receiver, &e, event); QApplication::forwardEvent(receiver, &e, event);
} }
#else #else
@ -653,8 +653,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
return; return;
// which child should have it? // which child should have it?
QWidget *widget = m_widget->childAt(event->pos()); QWidget *widget = m_widget->childAt(event->position().toPoint());
QPoint mapped = event->pos(); QPoint mapped = event->position().toPoint();
if (!widget) if (!widget)
widget = m_widget; widget = m_widget;
@ -663,7 +663,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
if (event->type() == QEvent::MouseButtonPress && initialPress) if (event->type() == QEvent::MouseButtonPress && initialPress)
qt_button_down = widget; qt_button_down = widget;
QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->windowPos().toPoint(), &mapped, event->type(), event->buttons(), QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->scenePosition().toPoint(), &mapped, event->type(), event->buttons(),
qt_button_down, widget); qt_button_down, widget);
if (!receiver) if (!receiver)
return; return;
@ -673,7 +673,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
// The preceding statement excludes MouseButtonPress events which caused // The preceding statement excludes MouseButtonPress events which caused
// creation of a MouseButtonDblClick event. QTBUG-25831 // creation of a MouseButtonDblClick event. QTBUG-25831
QMouseEvent translated(event->type(), mapped, event->windowPos(), event->screenPos(), QMouseEvent translated(event->type(), mapped, event->scenePosition(), event->globalPosition(),
event->button(), event->buttons(), event->modifiers(), event->source()); event->button(), event->buttons(), event->modifiers(), event->source());
translated.setTimestamp(event->timestamp()); translated.setTimestamp(event->timestamp());
QApplicationPrivate::sendMouseEvent(receiver, &translated, widget, m_widget, QApplicationPrivate::sendMouseEvent(receiver, &translated, widget, m_widget,
@ -682,8 +682,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
} }
#ifndef QT_NO_CONTEXTMENU #ifndef QT_NO_CONTEXTMENU
if (event->type() == contextMenuTrigger && event->button() == Qt::RightButton if (event->type() == contextMenuTrigger && event->button() == Qt::RightButton
&& m_widget->rect().contains(event->pos())) { && m_widget->rect().contains(event->position().toPoint())) {
QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers()); QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPosition().toPoint(), event->modifiers());
QGuiApplication::forwardEvent(receiver, &e, event); QGuiApplication::forwardEvent(receiver, &e, event);
} }
#endif #endif
@ -893,16 +893,16 @@ void QWidgetWindow::handleDragEnterEvent(QDragEnterEvent *event, QWidget *widget
{ {
Q_ASSERT(m_dragTarget == nullptr); Q_ASSERT(m_dragTarget == nullptr);
if (!widget) if (!widget)
widget = findDnDTarget(m_widget, event->pos()); widget = findDnDTarget(m_widget, event->position().toPoint());
if (!widget) { if (!widget) {
event->ignore(); event->ignore();
return; return;
} }
m_dragTarget = widget; m_dragTarget = widget;
const QPoint mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->pos())); const QPoint mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->position().toPoint()));
QDragEnterEvent translated(mapped, event->possibleActions(), event->mimeData(), QDragEnterEvent translated(mapped, event->possibleActions(), event->mimeData(),
event->mouseButtons(), event->keyboardModifiers()); event->buttons(), event->modifiers());
QGuiApplication::forwardEvent(m_dragTarget, &translated, event); QGuiApplication::forwardEvent(m_dragTarget, &translated, event);
event->setAccepted(translated.isAccepted()); event->setAccepted(translated.isAccepted());
event->setDropAction(translated.dropAction()); event->setDropAction(translated.dropAction());
@ -910,7 +910,7 @@ void QWidgetWindow::handleDragEnterEvent(QDragEnterEvent *event, QWidget *widget
void QWidgetWindow::handleDragMoveEvent(QDragMoveEvent *event) void QWidgetWindow::handleDragMoveEvent(QDragMoveEvent *event)
{ {
QPointer<QWidget> widget = findDnDTarget(m_widget, event->pos()); QPointer<QWidget> widget = findDnDTarget(m_widget, event->position().toPoint());
if (!widget) { if (!widget) {
event->ignore(); event->ignore();
if (m_dragTarget) { // Send DragLeave to previous if (m_dragTarget) { // Send DragLeave to previous
@ -919,9 +919,9 @@ void QWidgetWindow::handleDragMoveEvent(QDragMoveEvent *event)
m_dragTarget = nullptr; m_dragTarget = nullptr;
} }
} else { } else {
const QPoint mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->pos())); const QPoint mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->position().toPoint()));
QDragMoveEvent translated(mapped, event->possibleActions(), event->mimeData(), QDragMoveEvent translated(mapped, event->possibleActions(), event->mimeData(),
event->mouseButtons(), event->keyboardModifiers()); event->buttons(), event->modifiers());
if (widget == m_dragTarget) { // Target widget unchanged: Send DragMove if (widget == m_dragTarget) { // Target widget unchanged: Send DragMove
translated.setDropAction(event->dropAction()); translated.setDropAction(event->dropAction());
@ -965,8 +965,8 @@ void QWidgetWindow::handleDropEvent(QDropEvent *event)
event->ignore(); event->ignore();
return; return;
} }
const QPoint mapped = m_dragTarget->mapFromGlobal(m_widget->mapToGlobal(event->pos())); const QPoint mapped = m_dragTarget->mapFromGlobal(m_widget->mapToGlobal(event->position().toPoint()));
QDropEvent translated(mapped, event->possibleActions(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers()); QDropEvent translated(mapped, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
QGuiApplication::forwardEvent(m_dragTarget, &translated, event); QGuiApplication::forwardEvent(m_dragTarget, &translated, event);
event->setAccepted(translated.isAccepted()); event->setAccepted(translated.isAccepted());
event->setDropAction(translated.dropAction()); event->setDropAction(translated.dropAction());
@ -1060,7 +1060,7 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event)
QWidget *widget = qt_tablet_target; QWidget *widget = qt_tablet_target;
if (!widget) { if (!widget) {
widget = m_widget->childAt(event->pos()); widget = m_widget->childAt(event->position().toPoint());
if (event->type() == QEvent::TabletPress) { if (event->type() == QEvent::TabletPress) {
if (!widget) if (!widget)
widget = m_widget; widget = m_widget;
@ -1069,9 +1069,9 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event)
} }
if (widget) { if (widget) {
QPointF delta = event->globalPosF() - event->globalPos(); QPointF delta = event->globalPosition() - event->globalPosition().toPoint();
QPointF mapped = widget->mapFromGlobal(event->globalPos()) + delta; QPointF mapped = widget->mapFromGlobal(event->globalPosition().toPoint()) + delta;
QTabletEvent ev(event->type(), mapped, event->globalPosF(), event->deviceType(), event->pointerType(), QTabletEvent ev(event->type(), mapped, event->globalPosition(), event->deviceType(), event->pointerType(),
event->pressure(), event->xTilt(), event->yTilt(), event->tangentialPressure(), event->pressure(), event->xTilt(), event->yTilt(), event->tangentialPressure(),
event->rotation(), event->z(), event->modifiers(), event->uniqueId(), event->button(), event->buttons()); event->rotation(), event->z(), event->modifiers(), event->uniqueId(), event->button(), event->buttons());
ev.setTimestamp(event->timestamp()); ev.setTimestamp(event->timestamp());
@ -1096,7 +1096,7 @@ void QWidgetWindow::handleGestureEvent(QNativeGestureEvent *e)
receiver = popupFocusWidget ? popupFocusWidget : popup; receiver = popupFocusWidget ? popupFocusWidget : popup;
} }
if (!receiver) if (!receiver)
receiver = QApplication::widgetAt(e->globalPos()); receiver = QApplication::widgetAt(e->globalPosition().toPoint());
if (!receiver) if (!receiver)
receiver = m_widget; // last resort receiver = m_widget; // last resort

View File

@ -191,7 +191,7 @@ bool QBasicMouseEventTransition::eventTest(QEvent *event)
QMouseEvent *me = static_cast<QMouseEvent*>(event); QMouseEvent *me = static_cast<QMouseEvent*>(event);
return (me->button() == d->button) return (me->button() == d->button)
&& ((me->modifiers() & d->modifierMask) == d->modifierMask) && ((me->modifiers() & d->modifierMask) == d->modifierMask)
&& (d->path.isEmpty() || d->path.contains(me->pos())); && (d->path.isEmpty() || d->path.contains(me->position().toPoint()));
} }
return false; return false;
} }

View File

@ -75,7 +75,7 @@ static QMouseEvent *copyMouseEvent(QEvent *e)
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
case QEvent::MouseMove: { case QEvent::MouseMove: {
QMouseEvent *me = static_cast<QMouseEvent *>(e); QMouseEvent *me = static_cast<QMouseEvent *>(e);
QMouseEvent *cme = new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(), QMouseEvent *cme = new QMouseEvent(me->type(), QPoint(0, 0), me->scenePosition(), me->globalPosition(),
me->button(), me->buttons(), me->modifiers(), me->source()); me->button(), me->buttons(), me->modifiers(), me->source());
return cme; return cme;
} }
@ -159,7 +159,7 @@ public:
if (!pressDelayEvent) { if (!pressDelayEvent) {
pressDelayEvent.reset(copyMouseEvent(e)); pressDelayEvent.reset(copyMouseEvent(e));
pressDelayTimer = startTimer(delay); pressDelayTimer = startTimer(delay);
mouseTarget = QApplication::widgetAt(pressDelayEvent->globalPos()); mouseTarget = QApplication::widgetAt(pressDelayEvent->globalPosition().toPoint());
mouseButton = pressDelayEvent->button(); mouseButton = pressDelayEvent->button();
mouseEventSource = pressDelayEvent->source(); mouseEventSource = pressDelayEvent->source();
qFGDebug("QFG: consuming/delaying mouse press"); qFGDebug("QFG: consuming/delaying mouse press");
@ -297,8 +297,8 @@ protected:
#endif // QT_CONFIG(graphicsview) #endif // QT_CONFIG(graphicsview)
if (me) { if (me) {
QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()), QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPosition().toPoint()),
mouseTarget->topLevelWidget()->mapFromGlobal(me->globalPos()), me->screenPos(), mouseTarget->topLevelWidget()->mapFromGlobal(me->globalPosition().toPoint()), me->globalPosition(),
me->button(), me->buttons(), me->modifiers(), me->source()); me->button(), me->buttons(), me->modifiers(), me->source());
qt_sendSpontaneousEvent(mouseTarget, &copy); qt_sendSpontaneousEvent(mouseTarget, &copy);
} }
@ -437,7 +437,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
return Ignore; return Ignore;
if (button != Qt::NoButton) { if (button != Qt::NoButton) {
me = static_cast<const QMouseEvent *>(event); me = static_cast<const QMouseEvent *>(event);
globalPos = me->globalPos(); globalPos = me->globalPosition().toPoint();
} }
break; break;
#if QT_CONFIG(graphicsview) #if QT_CONFIG(graphicsview)
@ -458,7 +458,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
if (button == Qt::NoButton) { if (button == Qt::NoButton) {
te = static_cast<const QTouchEvent *>(event); te = static_cast<const QTouchEvent *>(event);
if (!te->touchPoints().isEmpty()) if (!te->touchPoints().isEmpty())
globalPos = te->touchPoints().at(0).screenPos().toPoint(); globalPos = te->touchPoints().at(0).globalPosition().toPoint();
} }
break; break;
@ -492,7 +492,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
switch (event->type()) { switch (event->type()) {
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
if (me && me->button() == button && me->buttons() == button) { if (me && me->button() == button && me->buttons() == button) {
point = me->globalPos(); point = me->globalPosition().toPoint();
inputType = QScroller::InputPress; inputType = QScroller::InputPress;
} else if (me) { } else if (me) {
scroller->stop(); scroller->stop();
@ -501,13 +501,13 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
break; break;
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
if (me && me->button() == button) { if (me && me->button() == button) {
point = me->globalPos(); point = me->globalPosition().toPoint();
inputType = QScroller::InputRelease; inputType = QScroller::InputRelease;
} }
break; break;
case QEvent::MouseMove: case QEvent::MouseMove:
if (me && me->buttons() == button) { if (me && me->buttons() == button) {
point = me->globalPos(); point = me->globalPosition().toPoint();
inputType = QScroller::InputMove; inputType = QScroller::InputMove;
} }
break; break;
@ -551,14 +551,14 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
if (te->touchPoints().count() != 2) // 2 fingers on pad if (te->touchPoints().count() != 2) // 2 fingers on pad
return Ignore; return Ignore;
point = te->touchPoints().at(0).startScenePos() + point = te->touchPoints().at(0).scenePressPosition() +
((te->touchPoints().at(0).scenePos() - te->touchPoints().at(0).startScenePos()) + ((te->touchPoints().at(0).scenePosition() - te->touchPoints().at(0).scenePressPosition()) +
(te->touchPoints().at(1).scenePos() - te->touchPoints().at(1).startScenePos())) / 2; (te->touchPoints().at(1).scenePosition() - te->touchPoints().at(1).scenePressPosition())) / 2;
} else { // TouchScreen } else { // TouchScreen
if (te->touchPoints().count() != 1) // 1 finger on screen if (te->touchPoints().count() != 1) // 1 finger on screen
return Ignore; return Ignore;
point = te->touchPoints().at(0).scenePos(); point = te->touchPoints().at(0).scenePosition();
} }
break; break;

View File

@ -120,7 +120,7 @@ QRect QSystemTrayIconSys::globalGeometry() const
void QSystemTrayIconSys::mousePressEvent(QMouseEvent *ev) void QSystemTrayIconSys::mousePressEvent(QMouseEvent *ev)
{ {
QPoint globalPos = ev->globalPos(); QPoint globalPos = ev->globalPosition().toPoint();
#ifndef QT_NO_CONTEXTMENU #ifndef QT_NO_CONTEXTMENU
if (ev->button() == Qt::RightButton && q->contextMenu()) if (ev->button() == Qt::RightButton && q->contextMenu())
q->contextMenu()->popup(globalPos); q->contextMenu()->popup(globalPos);

View File

@ -976,7 +976,7 @@ void QAbstractButton::mousePressEvent(QMouseEvent *e)
e->ignore(); e->ignore();
return; return;
} }
if (hitButton(e->pos())) { if (hitButton(e->position().toPoint())) {
setDown(true); setDown(true);
d->pressed = true; d->pressed = true;
repaint(); repaint();
@ -1006,7 +1006,7 @@ void QAbstractButton::mouseReleaseEvent(QMouseEvent *e)
return; return;
} }
if (hitButton(e->pos())) { if (hitButton(e->position().toPoint())) {
d->repeatTimer.stop(); d->repeatTimer.stop();
d->click(); d->click();
e->accept(); e->accept();
@ -1025,7 +1025,7 @@ void QAbstractButton::mouseMoveEvent(QMouseEvent *e)
return; return;
} }
if (hitButton(e->pos()) != d->down) { if (hitButton(e->position().toPoint()) != d->down) {
setDown(!d->down); setDown(!d->down);
repaint(); repaint();
if (d->down) if (d->down)
@ -1033,7 +1033,7 @@ void QAbstractButton::mouseMoveEvent(QMouseEvent *e)
else else
d->emitReleased(); d->emitReleased();
e->accept(); e->accept();
} else if (!hitButton(e->pos())) { } else if (!hitButton(e->position().toPoint())) {
e->ignore(); e->ignore();
} }
} }

View File

@ -795,7 +795,7 @@ bool QAbstractSpinBox::event(QEvent *event)
case QEvent::HoverEnter: case QEvent::HoverEnter:
case QEvent::HoverLeave: case QEvent::HoverLeave:
case QEvent::HoverMove: case QEvent::HoverMove:
d->updateHoverControl(static_cast<const QHoverEvent *>(event)->pos()); d->updateHoverControl(static_cast<const QHoverEvent *>(event)->position().toPoint());
break; break;
case QEvent::ShortcutOverride: case QEvent::ShortcutOverride:
if (d->edit->event(event)) if (d->edit->event(event))
@ -1359,7 +1359,7 @@ void QAbstractSpinBox::mouseMoveEvent(QMouseEvent *event)
{ {
Q_D(QAbstractSpinBox); Q_D(QAbstractSpinBox);
d->updateHoverControl(event->pos()); d->updateHoverControl(event->position().toPoint());
// If we have a timer ID, update the state // If we have a timer ID, update the state
if (d->spinClickTimerId != -1 && d->buttonSymbols != NoButtons) { if (d->spinClickTimerId != -1 && d->buttonSymbols != NoButtons) {
@ -1386,7 +1386,7 @@ void QAbstractSpinBox::mousePressEvent(QMouseEvent *event)
return; return;
} }
d->updateHoverControl(event->pos()); d->updateHoverControl(event->position().toPoint());
event->accept(); event->accept();
const StepEnabled se = (d->buttonSymbols == NoButtons) ? StepEnabled(StepNone) : stepEnabled(); const StepEnabled se = (d->buttonSymbols == NoButtons) ? StepEnabled(StepNone) : stepEnabled();

View File

@ -1485,7 +1485,7 @@ QDate QCalendarView::handleMouseEvent(QMouseEvent *event)
if (!calendarModel) if (!calendarModel)
return QDate(); return QDate();
QPoint pos = event->pos(); QPoint pos = event->position().toPoint();
QModelIndex index = indexAt(pos); QModelIndex index = indexAt(pos);
QDate date = calendarModel->dateForCell(index.row(), index.column()); QDate date = calendarModel->dateForCell(index.row(), index.column());
if (date.isValid() && date >= calendarModel->m_minimumDate if (date.isValid() && date >= calendarModel->m_minimumDate
@ -3145,7 +3145,7 @@ bool QCalendarWidget::eventFilter(QObject *watched, QEvent *event)
if (!widget || widget->window() != tlw) if (!widget || widget->window() != tlw)
return QWidget::eventFilter(watched, event); return QWidget::eventFilter(watched, event);
QPoint mousePos = widget->mapTo(tlw, static_cast<QMouseEvent *>(event)->pos()); QPoint mousePos = widget->mapTo(tlw, static_cast<QMouseEvent *>(event)->position().toPoint());
QRect geom = QRect(d->yearEdit->mapTo(tlw, QPoint(0, 0)), d->yearEdit->size()); QRect geom = QRect(d->yearEdit->mapTo(tlw, QPoint(0, 0)), d->yearEdit->size());
if (!geom.contains(mousePos)) { if (!geom.contains(mousePos)) {
event->accept(); event->accept();

View File

@ -325,7 +325,7 @@ void QCheckBox::mouseMoveEvent(QMouseEvent *e)
if (testAttribute(Qt::WA_Hover)) { if (testAttribute(Qt::WA_Hover)) {
bool hit = false; bool hit = false;
if (underMouse()) if (underMouse())
hit = hitButton(e->pos()); hit = hitButton(e->position().toPoint());
if (hit != d->hovering) { if (hit != d->hovering) {
update(rect()); update(rect());

View File

@ -780,10 +780,10 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e)
if (isVisible()) { if (isVisible()) {
QMouseEvent *m = static_cast<QMouseEvent *>(e); QMouseEvent *m = static_cast<QMouseEvent *>(e);
QWidget *widget = static_cast<QWidget *>(o); QWidget *widget = static_cast<QWidget *>(o);
QPoint vector = widget->mapToGlobal(m->pos()) - initialClickPosition; QPoint vector = widget->mapToGlobal(m->position().toPoint()) - initialClickPosition;
if (vector.manhattanLength() > 9 && blockMouseReleaseTimer.isActive()) if (vector.manhattanLength() > 9 && blockMouseReleaseTimer.isActive())
blockMouseReleaseTimer.stop(); blockMouseReleaseTimer.stop();
QModelIndex indexUnderMouse = view->indexAt(m->pos()); QModelIndex indexUnderMouse = view->indexAt(m->position().toPoint());
if (indexUnderMouse.isValid() if (indexUnderMouse.isValid()
&& !QComboBoxDelegate::isSeparator(indexUnderMouse)) { && !QComboBoxDelegate::isSeparator(indexUnderMouse)) {
view->setCurrentIndex(indexUnderMouse); view->setCurrentIndex(indexUnderMouse);
@ -797,7 +797,7 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e)
bool ignoreEvent = maybeIgnoreMouseButtonRelease && popupTimer.elapsed() < QApplication::doubleClickInterval(); bool ignoreEvent = maybeIgnoreMouseButtonRelease && popupTimer.elapsed() < QApplication::doubleClickInterval();
QMouseEvent *m = static_cast<QMouseEvent *>(e); QMouseEvent *m = static_cast<QMouseEvent *>(e);
if (isVisible() && view->rect().contains(m->pos()) && view->currentIndex().isValid() if (isVisible() && view->rect().contains(m->position().toPoint()) && view->currentIndex().isValid()
&& !blockMouseReleaseTimer.isActive() && !ignoreEvent && !blockMouseReleaseTimer.isActive() && !ignoreEvent
&& (view->currentIndex().flags() & Qt::ItemIsEnabled) && (view->currentIndex().flags() & Qt::ItemIsEnabled)
&& (view->currentIndex().flags() & Qt::ItemIsSelectable)) { && (view->currentIndex().flags() & Qt::ItemIsSelectable)) {
@ -838,7 +838,7 @@ void QComboBoxPrivateContainer::mousePressEvent(QMouseEvent *e)
opt.subControls = QStyle::SC_All; opt.subControls = QStyle::SC_All;
opt.activeSubControls = QStyle::SC_ComboBoxArrow; opt.activeSubControls = QStyle::SC_ComboBoxArrow;
QStyle::SubControl sc = combo->style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, QStyle::SubControl sc = combo->style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt,
combo->mapFromGlobal(e->globalPos()), combo->mapFromGlobal(e->globalPosition().toPoint()),
combo); combo);
if ((combo->isEditable() && sc == QStyle::SC_ComboBoxArrow) if ((combo->isEditable() && sc == QStyle::SC_ComboBoxArrow)
|| (!combo->isEditable() && sc != QStyle::SC_None)) || (!combo->isEditable() && sc != QStyle::SC_None))
@ -3072,7 +3072,7 @@ bool QComboBox::event(QEvent *event)
case QEvent::HoverLeave: case QEvent::HoverLeave:
case QEvent::HoverMove: case QEvent::HoverMove:
if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event)) if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event))
d->updateHoverControl(he->pos()); d->updateHoverControl(he->position().toPoint());
break; break;
case QEvent::ShortcutOverride: case QEvent::ShortcutOverride:
if (d->lineEdit) if (d->lineEdit)
@ -3111,7 +3111,7 @@ void QComboBoxPrivate::showPopupFromMouseEvent(QMouseEvent *e)
Q_Q(QComboBox); Q_Q(QComboBox);
QStyleOptionComboBox opt; QStyleOptionComboBox opt;
q->initStyleOption(&opt); q->initStyleOption(&opt);
QStyle::SubControl sc = q->style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, e->pos(), q); QStyle::SubControl sc = q->style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, e->position().toPoint(), q);
if (e->button() == Qt::LeftButton if (e->button() == Qt::LeftButton
&& !(sc == QStyle::SC_None && e->type() == QEvent::MouseButtonRelease) && !(sc == QStyle::SC_None && e->type() == QEvent::MouseButtonRelease)
@ -3127,7 +3127,7 @@ void QComboBoxPrivate::showPopupFromMouseEvent(QMouseEvent *e)
#endif #endif
// We've restricted the next couple of lines, because by not calling // We've restricted the next couple of lines, because by not calling
// viewContainer(), we avoid creating the QComboBoxPrivateContainer. // viewContainer(), we avoid creating the QComboBoxPrivateContainer.
viewContainer()->initialClickPosition = q->mapToGlobal(e->pos()); viewContainer()->initialClickPosition = q->mapToGlobal(e->position().toPoint());
} }
q->showPopup(); q->showPopup();
// The code below ensures that regular mousepress and pick item still works // The code below ensures that regular mousepress and pick item still works

View File

@ -178,8 +178,8 @@ protected:
void mouseMoveEvent(QMouseEvent *e) override void mouseMoveEvent(QMouseEvent *e) override
{ {
// Enable fast scrolling if the cursor is directly above or below the popup. // Enable fast scrolling if the cursor is directly above or below the popup.
const int mouseX = e->pos().x(); const int mouseX = e->position().toPoint().x();
const int mouseY = e->pos().y(); const int mouseY = e->position().toPoint().y();
const bool horizontallyInside = pos().x() < mouseX && mouseX < rect().right() + 1; const bool horizontallyInside = pos().x() < mouseX && mouseX < rect().right() + 1;
const bool verticallyOutside = (sliderAction == QAbstractSlider::SliderSingleStepAdd) ? const bool verticallyOutside = (sliderAction == QAbstractSlider::SliderSingleStepAdd) ?
rect().bottom() + 1 < mouseY : mouseY < pos().y(); rect().bottom() + 1 < mouseY : mouseY < pos().y();

View File

@ -1528,7 +1528,7 @@ void QDateTimeEdit::mousePressEvent(QMouseEvent *event)
QAbstractSpinBox::mousePressEvent(event); QAbstractSpinBox::mousePressEvent(event);
return; return;
} }
d->updateHoverControl(event->pos()); d->updateHoverControl(event->position().toPoint());
if (d->hoverControl == QStyle::SC_ComboBoxArrow) { if (d->hoverControl == QStyle::SC_ComboBoxArrow) {
event->accept(); event->accept();
if (d->readOnly) { if (d->readOnly) {
@ -2712,7 +2712,7 @@ void QCalendarPopup::mousePressEvent(QMouseEvent *event)
QRect arrowRect = dateTime->style()->subControlRect(QStyle::CC_ComboBox, &opt, QRect arrowRect = dateTime->style()->subControlRect(QStyle::CC_ComboBox, &opt,
QStyle::SC_ComboBoxArrow, dateTime); QStyle::SC_ComboBoxArrow, dateTime);
arrowRect.moveTo(dateTime->mapToGlobal(arrowRect .topLeft())); arrowRect.moveTo(dateTime->mapToGlobal(arrowRect .topLeft()));
if (arrowRect.contains(event->globalPos()) || rect().contains(event->pos())) if (arrowRect.contains(event->globalPosition().toPoint()) || rect().contains(event->position().toPoint()))
setAttribute(Qt::WA_NoMouseReplay); setAttribute(Qt::WA_NoMouseReplay);
} }
QWidget::mousePressEvent(event); QWidget::mousePressEvent(event);

View File

@ -280,7 +280,7 @@ void QDial::mousePressEvent(QMouseEvent *e)
return; return;
} }
e->accept(); e->accept();
setSliderPosition(d->valueFromPoint(e->pos())); setSliderPosition(d->valueFromPoint(e->position().toPoint()));
// ### This isn't quite right, // ### This isn't quite right,
// we should be doing a hit test and only setting this if it's // we should be doing a hit test and only setting this if it's
// the actual dial thingie (similar to what QSlider does), but we have no // the actual dial thingie (similar to what QSlider does), but we have no
@ -302,7 +302,7 @@ void QDial::mouseReleaseEvent(QMouseEvent * e)
return; return;
} }
e->accept(); e->accept();
setValue(d->valueFromPoint(e->pos())); setValue(d->valueFromPoint(e->position().toPoint()));
setSliderDown(false); setSliderDown(false);
} }
@ -320,7 +320,7 @@ void QDial::mouseMoveEvent(QMouseEvent * e)
} }
e->accept(); e->accept();
d->doNotEmit = true; d->doNotEmit = true;
setSliderPosition(d->valueFromPoint(e->pos())); setSliderPosition(d->valueFromPoint(e->position().toPoint()));
d->doNotEmit = false; d->doNotEmit = false;
} }

View File

@ -918,7 +918,7 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent); QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent);
if (event->button() != Qt::LeftButton || if (event->button() != Qt::LeftButton ||
!titleArea.contains(event->pos()) || !titleArea.contains(event->position().toPoint()) ||
// check if the tool window is movable... do nothing if it // check if the tool window is movable... do nothing if it
// is not (but allow moving if the window is floating) // is not (but allow moving if the window is floating)
(!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) || (!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) ||
@ -927,7 +927,7 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
return false; return false;
} }
initDrag(event->pos(), false); initDrag(event->position().toPoint(), false);
if (state) if (state)
state->ctrlDrag = (hasFeature(this, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier) || state->ctrlDrag = (hasFeature(this, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier) ||
@ -947,7 +947,7 @@ bool QDockWidgetPrivate::mouseDoubleClickEvent(QMouseEvent *event)
if (!dwLayout->nativeWindowDeco()) { if (!dwLayout->nativeWindowDeco()) {
QRect titleArea = dwLayout->titleArea(); QRect titleArea = dwLayout->titleArea();
if (event->button() == Qt::LeftButton && titleArea.contains(event->pos()) && if (event->button() == Qt::LeftButton && titleArea.contains(event->position().toPoint()) &&
hasFeature(this, QDockWidget::DockWidgetFloatable)) { hasFeature(this, QDockWidget::DockWidgetFloatable)) {
_q_toggleTopLevel(); _q_toggleTopLevel();
return true; return true;
@ -971,7 +971,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
if (!dwlayout->nativeWindowDeco()) { if (!dwlayout->nativeWindowDeco()) {
if (!state->dragging if (!state->dragging
&& mwlayout->pluggingWidget == nullptr && mwlayout->pluggingWidget == nullptr
&& (event->pos() - state->pressPos).manhattanLength() && (event->position().toPoint() - state->pressPos).manhattanLength()
> QApplication::startDragDistance()) { > QApplication::startDragDistance()) {
startDrag(); startDrag();
q->grabMouse(); q->grabMouse();
@ -982,7 +982,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
if (state->dragging && !state->nca) { if (state->dragging && !state->nca) {
QMargins windowMargins = q->window()->windowHandle()->frameMargins(); QMargins windowMargins = q->window()->windowHandle()->frameMargins();
QPoint windowMarginOffset = QPoint(windowMargins.left(), windowMargins.top()); QPoint windowMarginOffset = QPoint(windowMargins.left(), windowMargins.top());
QPoint pos = event->globalPos() - state->pressPos - windowMarginOffset; QPoint pos = event->globalPosition().toPoint() - state->pressPos - windowMarginOffset;
QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent); QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent);
if (floatingTab && !q->isFloating()) if (floatingTab && !q->isFloating())
@ -991,7 +991,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
q->move(pos); q->move(pos);
if (state && !state->ctrlDrag) if (state && !state->ctrlDrag)
mwlayout->hover(state->widgetItem, event->globalPos()); mwlayout->hover(state->widgetItem, event->globalPosition().toPoint());
ret = true; ret = true;
} }
@ -1031,7 +1031,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
switch (event->type()) { switch (event->type()) {
case QEvent::NonClientAreaMouseButtonPress: case QEvent::NonClientAreaMouseButtonPress:
if (!titleRect.contains(event->globalPos())) if (!titleRect.contains(event->globalPosition().toPoint()))
break; break;
if (state != nullptr) if (state != nullptr)
break; break;
@ -1039,7 +1039,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
break; break;
if (isAnimating()) if (isAnimating())
break; break;
initDrag(event->pos(), true); initDrag(event->position().toPoint(), true);
if (state == nullptr) if (state == nullptr)
break; break;
state->ctrlDrag = (event->modifiers() & Qt::ControlModifier) || state->ctrlDrag = (event->modifiers() & Qt::ControlModifier) ||

View File

@ -339,7 +339,7 @@ bool QGroupBox::event(QEvent *e)
case QEvent::HoverEnter: case QEvent::HoverEnter:
case QEvent::HoverMove: { case QEvent::HoverMove: {
QStyle::SubControl control = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, QStyle::SubControl control = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box,
static_cast<QHoverEvent *>(e)->pos(), static_cast<QHoverEvent *>(e)->position().toPoint(),
this); this);
bool oldHover = d->hover; bool oldHover = d->hover;
d->hover = d->checkable && (control == QStyle::SC_GroupBoxLabel || control == QStyle::SC_GroupBoxCheckBox); d->hover = d->checkable && (control == QStyle::SC_GroupBoxLabel || control == QStyle::SC_GroupBoxCheckBox);
@ -702,7 +702,7 @@ void QGroupBox::mousePressEvent(QMouseEvent *event)
QStyleOptionGroupBox box; QStyleOptionGroupBox box;
initStyleOption(&box); initStyleOption(&box);
d->pressedControl = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, d->pressedControl = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box,
event->pos(), this); event->position().toPoint(), this);
if (d->checkable && (d->pressedControl & (QStyle::SC_GroupBoxCheckBox | QStyle::SC_GroupBoxLabel))) { if (d->checkable && (d->pressedControl & (QStyle::SC_GroupBoxCheckBox | QStyle::SC_GroupBoxLabel))) {
d->overCheckBox = true; d->overCheckBox = true;
update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)); update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
@ -718,7 +718,7 @@ void QGroupBox::mouseMoveEvent(QMouseEvent *event)
QStyleOptionGroupBox box; QStyleOptionGroupBox box;
initStyleOption(&box); initStyleOption(&box);
QStyle::SubControl pressed = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, QStyle::SubControl pressed = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box,
event->pos(), this); event->position().toPoint(), this);
bool oldOverCheckBox = d->overCheckBox; bool oldOverCheckBox = d->overCheckBox;
d->overCheckBox = (pressed == QStyle::SC_GroupBoxCheckBox || pressed == QStyle::SC_GroupBoxLabel); d->overCheckBox = (pressed == QStyle::SC_GroupBoxCheckBox || pressed == QStyle::SC_GroupBoxLabel);
if (d->checkable && (d->pressedControl == QStyle::SC_GroupBoxCheckBox || d->pressedControl == QStyle::SC_GroupBoxLabel) if (d->checkable && (d->pressedControl == QStyle::SC_GroupBoxCheckBox || d->pressedControl == QStyle::SC_GroupBoxLabel)
@ -744,7 +744,7 @@ void QGroupBox::mouseReleaseEvent(QMouseEvent *event)
QStyleOptionGroupBox box; QStyleOptionGroupBox box;
initStyleOption(&box); initStyleOption(&box);
QStyle::SubControl released = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, QStyle::SubControl released = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box,
event->pos(), this); event->position().toPoint(), this);
bool toggle = d->checkable && (released == QStyle::SC_GroupBoxLabel bool toggle = d->checkable && (released == QStyle::SC_GroupBoxLabel
|| released == QStyle::SC_GroupBoxCheckBox); || released == QStyle::SC_GroupBoxCheckBox);
d->pressedControl = QStyle::SC_None; d->pressedControl = QStyle::SC_None;

View File

@ -1513,7 +1513,7 @@ void QLineEdit::mousePressEvent(QMouseEvent* e)
{ {
Q_D(QLineEdit); Q_D(QLineEdit);
d->mousePressPos = e->pos(); d->mousePressPos = e->position().toPoint();
if (d->sendMouseEventToInputContext(e)) if (d->sendMouseEventToInputContext(e))
return; return;
@ -1527,7 +1527,7 @@ void QLineEdit::mousePressEvent(QMouseEvent* e)
d->control->completer()->complete(); d->control->completer()->complete();
} }
#endif #endif
if (d->tripleClickTimer.isActive() && (e->pos() - d->tripleClick).manhattanLength() < if (d->tripleClickTimer.isActive() && (e->position().toPoint() - d->tripleClick).manhattanLength() <
QApplication::startDragDistance()) { QApplication::startDragDistance()) {
selectAll(); selectAll();
return; return;
@ -1536,10 +1536,10 @@ void QLineEdit::mousePressEvent(QMouseEvent* e)
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
mark = mark && (d->imHints & Qt::ImhNoPredictiveText); mark = mark && (d->imHints & Qt::ImhNoPredictiveText);
#endif // Q_OS_ANDROID #endif // Q_OS_ANDROID
int cursor = d->xToPos(e->pos().x()); int cursor = d->xToPos(e->position().toPoint().x());
#if QT_CONFIG(draganddrop) #if QT_CONFIG(draganddrop)
if (!mark && d->dragEnabled && d->control->echoMode() == Normal && if (!mark && d->dragEnabled && d->control->echoMode() == Normal &&
e->button() == Qt::LeftButton && d->inSelection(e->pos().x())) { e->button() == Qt::LeftButton && d->inSelection(e->position().toPoint().x())) {
if (!d->dndTimer.isActive()) if (!d->dndTimer.isActive())
d->dndTimer.start(QApplication::startDragTime(), this); d->dndTimer.start(QApplication::startDragTime(), this);
} else } else
@ -1558,7 +1558,7 @@ void QLineEdit::mouseMoveEvent(QMouseEvent * e)
if (e->buttons() & Qt::LeftButton) { if (e->buttons() & Qt::LeftButton) {
#if QT_CONFIG(draganddrop) #if QT_CONFIG(draganddrop)
if (d->dndTimer.isActive()) { if (d->dndTimer.isActive()) {
if ((d->mousePressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) if ((d->mousePressPos - e->position().toPoint()).manhattanLength() > QApplication::startDragDistance())
d->drag(); d->drag();
} else } else
#endif #endif
@ -1569,26 +1569,26 @@ void QLineEdit::mouseMoveEvent(QMouseEvent * e)
const bool select = (d->imHints & Qt::ImhNoPredictiveText); const bool select = (d->imHints & Qt::ImhNoPredictiveText);
#endif #endif
#ifndef QT_NO_IM #ifndef QT_NO_IM
if (d->mouseYThreshold > 0 && e->pos().y() > d->mousePressPos.y() + d->mouseYThreshold) { if (d->mouseYThreshold > 0 && e->position().toPoint().y() > d->mousePressPos.y() + d->mouseYThreshold) {
if (layoutDirection() == Qt::RightToLeft) if (layoutDirection() == Qt::RightToLeft)
d->control->home(select); d->control->home(select);
else else
d->control->end(select); d->control->end(select);
} else if (d->mouseYThreshold > 0 && e->pos().y() + d->mouseYThreshold < d->mousePressPos.y()) { } else if (d->mouseYThreshold > 0 && e->position().toPoint().y() + d->mouseYThreshold < d->mousePressPos.y()) {
if (layoutDirection() == Qt::RightToLeft) if (layoutDirection() == Qt::RightToLeft)
d->control->end(select); d->control->end(select);
else else
d->control->home(select); d->control->home(select);
} else if (d->control->composeMode() && select) { } else if (d->control->composeMode() && select) {
int startPos = d->xToPos(d->mousePressPos.x()); int startPos = d->xToPos(d->mousePressPos.x());
int currentPos = d->xToPos(e->pos().x()); int currentPos = d->xToPos(e->position().toPoint().x());
if (startPos != currentPos) if (startPos != currentPos)
d->control->setSelection(startPos, currentPos - startPos); d->control->setSelection(startPos, currentPos - startPos);
} else } else
#endif #endif
{ {
d->control->moveCursor(d->xToPos(e->pos().x()), select); d->control->moveCursor(d->xToPos(e->position().toPoint().x()), select);
} }
} }
} }
@ -1623,7 +1623,7 @@ void QLineEdit::mouseReleaseEvent(QMouseEvent* e)
} }
#endif #endif
if (!isReadOnly() && rect().contains(e->pos())) if (!isReadOnly() && rect().contains(e->position().toPoint()))
d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus); d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);
d->clickCausedFocus = 0; d->clickCausedFocus = 0;
} }
@ -1635,7 +1635,7 @@ void QLineEdit::mouseDoubleClickEvent(QMouseEvent* e)
Q_D(QLineEdit); Q_D(QLineEdit);
if (e->button() == Qt::LeftButton) { if (e->button() == Qt::LeftButton) {
int position = d->xToPos(e->pos().x()); int position = d->xToPos(e->position().toPoint().x());
// exit composition mode // exit composition mode
#ifndef QT_NO_IM #ifndef QT_NO_IM
@ -1669,7 +1669,7 @@ void QLineEdit::mouseDoubleClickEvent(QMouseEvent* e)
d->control->selectWordAtPos(position); d->control->selectWordAtPos(position);
d->tripleClickTimer.start(QApplication::doubleClickInterval(), this); d->tripleClickTimer.start(QApplication::doubleClickInterval(), this);
d->tripleClick = e->pos(); d->tripleClick = e->position().toPoint();
} else { } else {
d->sendMouseEventToInputContext(e); d->sendMouseEventToInputContext(e);
} }
@ -2075,7 +2075,7 @@ void QLineEdit::dragMoveEvent(QDragMoveEvent *e)
Q_D(QLineEdit); Q_D(QLineEdit);
if (!d->control->isReadOnly() && e->mimeData()->hasFormat(QLatin1String("text/plain"))) { if (!d->control->isReadOnly() && e->mimeData()->hasFormat(QLatin1String("text/plain"))) {
e->acceptProposedAction(); e->acceptProposedAction();
d->control->moveCursor(d->xToPos(e->pos().x()), false); d->control->moveCursor(d->xToPos(e->position().toPoint().x()), false);
d->cursorVisible = true; d->cursorVisible = true;
update(); update();
} }
@ -2106,7 +2106,7 @@ void QLineEdit::dropEvent(QDropEvent* e)
if (!str.isNull() && !d->control->isReadOnly()) { if (!str.isNull() && !d->control->isReadOnly()) {
if (e->source() == this && e->dropAction() == Qt::CopyAction) if (e->source() == this && e->dropAction() == Qt::CopyAction)
deselect(); deselect();
int cursorPos = d->xToPos(e->pos().x()); int cursorPos = d->xToPos(e->position().toPoint().x());
int selStart = cursorPos; int selStart = cursorPos;
int oldSelStart = d->control->selectionStart(); int oldSelStart = d->control->selectionStart();
int oldSelEnd = d->control->selectionEnd(); int oldSelEnd = d->control->selectionEnd();

View File

@ -302,7 +302,7 @@ bool QLineEditPrivate::sendMouseEventToInputContext( QMouseEvent *e )
{ {
#if !defined QT_NO_IM #if !defined QT_NO_IM
if ( control->composeMode() ) { if ( control->composeMode() ) {
int tmp_cursor = xToPos(e->pos().x()); int tmp_cursor = xToPos(e->position().toPoint().x());
int mousePos = tmp_cursor - control->cursor(); int mousePos = tmp_cursor - control->cursor();
if ( mousePos < 0 || mousePos > control->preeditAreaText().length() ) if ( mousePos < 0 || mousePos > control->preeditAreaText().length() )
mousePos = -1; mousePos = -1;

View File

@ -1713,7 +1713,7 @@ void QMainWindowTabBar::mouseMoveEvent(QMouseEvent *e)
int offset = QApplication::startDragDistance() + 1; int offset = QApplication::startDragDistance() + 1;
offset *= 3; offset *= 3;
QRect r = rect().adjusted(-offset, -offset, offset, offset); QRect r = rect().adjusted(-offset, -offset, offset, offset);
if (d->dragInProgress && !r.contains(e->pos()) && d->validIndex(d->pressedIndex)) { if (d->dragInProgress && !r.contains(e->position().toPoint()) && d->validIndex(d->pressedIndex)) {
QMainWindowLayout* mlayout = qt_mainwindow_layout(mainWindow); QMainWindowLayout* mlayout = qt_mainwindow_layout(mainWindow);
QDockAreaLayoutInfo *info = mlayout->dockInfo(this); QDockAreaLayoutInfo *info = mlayout->dockInfo(this);
Q_ASSERT(info); Q_ASSERT(info);
@ -1743,7 +1743,7 @@ void QMainWindowTabBar::mouseMoveEvent(QMouseEvent *e)
if (draggingDock) { if (draggingDock) {
QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock)); QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock));
if (dockPriv->state && dockPriv->state->dragging) { if (dockPriv->state && dockPriv->state->dragging) {
QPoint pos = e->globalPos() - dockPriv->state->pressPos; QPoint pos = e->globalPosition().toPoint() - dockPriv->state->pressPos;
draggingDock->move(pos); draggingDock->move(pos);
// move will call QMainWindowLayout::hover // move will call QMainWindowLayout::hover
} }

View File

@ -210,7 +210,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
#if QT_CONFIG(cursor) #if QT_CONFIG(cursor)
case QEvent::HoverMove: { case QEvent::HoverMove: {
adjustCursor(static_cast<QHoverEvent *>(event)->pos()); adjustCursor(static_cast<QHoverEvent *>(event)->position().toPoint());
break; break;
} }
@ -228,7 +228,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
case QEvent::MouseButtonPress: { case QEvent::MouseButtonPress: {
QMouseEvent *e = static_cast<QMouseEvent *>(event); QMouseEvent *e = static_cast<QMouseEvent *>(event);
if (e->button() == Qt::LeftButton && startSeparatorMove(e->pos())) { if (e->button() == Qt::LeftButton && startSeparatorMove(e->position().toPoint())) {
// The click was on a separator, eat this event // The click was on a separator, eat this event
e->accept(); e->accept();
return true; return true;
@ -240,10 +240,10 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
QMouseEvent *e = static_cast<QMouseEvent *>(event); QMouseEvent *e = static_cast<QMouseEvent *>(event);
#if QT_CONFIG(cursor) #if QT_CONFIG(cursor)
adjustCursor(e->pos()); adjustCursor(e->position().toPoint());
#endif #endif
if (e->buttons() & Qt::LeftButton) { if (e->buttons() & Qt::LeftButton) {
if (separatorMove(e->pos())) { if (separatorMove(e->position().toPoint())) {
// We're moving a separator, eat this event // We're moving a separator, eat this event
e->accept(); e->accept();
return true; return true;
@ -255,7 +255,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
case QEvent::MouseButtonRelease: { case QEvent::MouseButtonRelease: {
QMouseEvent *e = static_cast<QMouseEvent *>(event); QMouseEvent *e = static_cast<QMouseEvent *>(event);
if (endSeparatorMove(e->pos())) { if (endSeparatorMove(e->position().toPoint())) {
// We've released a separator, eat this event // We've released a separator, eat this event
e->accept(); e->accept();
return true; return true;

View File

@ -589,7 +589,7 @@ void QMdiAreaTabBar::mousePressEvent(QMouseEvent *event)
return; return;
} }
QMdiSubWindow *subWindow = subWindowFromIndex(tabAt(event->pos())); QMdiSubWindow *subWindow = subWindowFromIndex(tabAt(event->position().toPoint()));
if (!subWindow) { if (!subWindow) {
event->ignore(); event->ignore();
return; return;

View File

@ -613,7 +613,7 @@ void ControllerWidget::mousePressEvent(QMouseEvent *event)
event->ignore(); event->ignore();
return; return;
} }
activeControl = getSubControl(event->pos()); activeControl = getSubControl(event->position().toPoint());
update(); update();
} }
@ -627,7 +627,7 @@ void ControllerWidget::mouseReleaseEvent(QMouseEvent *event)
return; return;
} }
QStyle::SubControl under_mouse = getSubControl(event->pos()); QStyle::SubControl under_mouse = getSubControl(event->position().toPoint());
if (under_mouse == activeControl) { if (under_mouse == activeControl) {
switch (activeControl) { switch (activeControl) {
case QStyle::SC_MdiCloseButton: case QStyle::SC_MdiCloseButton:
@ -653,7 +653,7 @@ void ControllerWidget::mouseReleaseEvent(QMouseEvent *event)
*/ */
void ControllerWidget::mouseMoveEvent(QMouseEvent *event) void ControllerWidget::mouseMoveEvent(QMouseEvent *event)
{ {
QStyle::SubControl under_mouse = getSubControl(event->pos()); QStyle::SubControl under_mouse = getSubControl(event->position().toPoint());
//test if hover state changes //test if hover state changes
if (hoverControl != under_mouse) { if (hoverControl != under_mouse) {
hoverControl = under_mouse; hoverControl = under_mouse;
@ -2659,12 +2659,12 @@ bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event)
if (d->systemMenu && d->systemMenu == object) { if (d->systemMenu && d->systemMenu == object) {
if (event->type() == QEvent::MouseButtonDblClick) { if (event->type() == QEvent::MouseButtonDblClick) {
const QMouseEvent *mouseEvent = static_cast<const QMouseEvent *>(event); const QMouseEvent *mouseEvent = static_cast<const QMouseEvent *>(event);
const QAction *action = d->systemMenu->actionAt(mouseEvent->pos()); const QAction *action = d->systemMenu->actionAt(mouseEvent->position().toPoint());
if (!action || action->isEnabled()) if (!action || action->isEnabled())
close(); close();
} else if (event->type() == QEvent::MouseMove) { } else if (event->type() == QEvent::MouseMove) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
d->hoveredSubControl = d->getSubControl(mapFromGlobal(mouseEvent->globalPos())); d->hoveredSubControl = d->getSubControl(mapFromGlobal(mouseEvent->globalPosition().toPoint()));
} else if (event->type() == QEvent::Hide) { } else if (event->type() == QEvent::Hide) {
d->activeSubControl = QStyle::SC_None; d->activeSubControl = QStyle::SC_None;
update(QRegion(0, 0, width(), d->titleBarHeight())); update(QRegion(0, 0, width(), d->titleBarHeight()));
@ -2678,7 +2678,7 @@ bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event)
if (event->type() != QEvent::MouseButtonPress || !testOption(QMdiSubWindow::RubberBandResize)) if (event->type() != QEvent::MouseButtonPress || !testOption(QMdiSubWindow::RubberBandResize))
return QWidget::eventFilter(object, event); return QWidget::eventFilter(object, event);
const QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); const QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
d->mousePressPosition = parentWidget()->mapFromGlobal(mouseEvent->globalPos()); d->mousePressPosition = parentWidget()->mapFromGlobal(mouseEvent->globalPosition().toPoint());
d->oldGeometry = geometry(); d->oldGeometry = geometry();
d->currentOperation = isLeftToRight() ? QMdiSubWindowPrivate::BottomRightResize d->currentOperation = isLeftToRight() ? QMdiSubWindowPrivate::BottomRightResize
: QMdiSubWindowPrivate::BottomLeftResize; : QMdiSubWindowPrivate::BottomLeftResize;
@ -3173,7 +3173,7 @@ void QMdiSubWindow::mousePressEvent(QMouseEvent *mouseEvent)
if (d->currentOperation != QMdiSubWindowPrivate::None) { if (d->currentOperation != QMdiSubWindowPrivate::None) {
d->updateCursor(); d->updateCursor();
d->mousePressPosition = mapToParent(mouseEvent->pos()); d->mousePressPosition = mapToParent(mouseEvent->position().toPoint());
if (d->resizeEnabled || d->moveEnabled) if (d->resizeEnabled || d->moveEnabled)
d->oldGeometry = geometry(); d->oldGeometry = geometry();
#if QT_CONFIG(rubberband) #if QT_CONFIG(rubberband)
@ -3264,10 +3264,10 @@ void QMdiSubWindow::mouseReleaseEvent(QMouseEvent *mouseEvent)
d->oldGeometry = geometry(); d->oldGeometry = geometry();
} }
d->currentOperation = d->getOperation(mouseEvent->pos()); d->currentOperation = d->getOperation(mouseEvent->position().toPoint());
d->updateCursor(); d->updateCursor();
d->hoveredSubControl = d->getSubControl(mouseEvent->pos()); d->hoveredSubControl = d->getSubControl(mouseEvent->position().toPoint());
if (d->activeSubControl != QStyle::SC_None if (d->activeSubControl != QStyle::SC_None
&& d->activeSubControl == d->hoveredSubControl) { && d->activeSubControl == d->hoveredSubControl) {
d->processClickedSubControl(); d->processClickedSubControl();
@ -3292,7 +3292,7 @@ void QMdiSubWindow::mouseMoveEvent(QMouseEvent *mouseEvent)
// Find previous and current hover region. // Find previous and current hover region.
const QStyleOptionTitleBar options = d->titleBarOptions(); const QStyleOptionTitleBar options = d->titleBarOptions();
QStyle::SubControl oldHover = d->hoveredSubControl; QStyle::SubControl oldHover = d->hoveredSubControl;
d->hoveredSubControl = d->getSubControl(mouseEvent->pos()); d->hoveredSubControl = d->getSubControl(mouseEvent->position().toPoint());
QRegion hoverRegion; QRegion hoverRegion;
if (isHoverControl(oldHover) && oldHover != d->hoveredSubControl) if (isHoverControl(oldHover) && oldHover != d->hoveredSubControl)
hoverRegion += style()->subControlRect(QStyle::CC_TitleBar, &options, oldHover, this); hoverRegion += style()->subControlRect(QStyle::CC_TitleBar, &options, oldHover, this);
@ -3312,13 +3312,13 @@ void QMdiSubWindow::mouseMoveEvent(QMouseEvent *mouseEvent)
if ((d->isResizeOperation() && d->resizeEnabled) || (d->isMoveOperation() && d->moveEnabled)) { if ((d->isResizeOperation() && d->resizeEnabled) || (d->isMoveOperation() && d->moveEnabled)) {
// As setNewGeometry moves the window, it invalidates the pos() value of any mouse move events that are // As setNewGeometry moves the window, it invalidates the pos() value of any mouse move events that are
// currently queued in the event loop. Map to parent using globalPos() instead. // currently queued in the event loop. Map to parent using globalPos() instead.
d->setNewGeometry(parentWidget()->mapFromGlobal(mouseEvent->globalPos())); d->setNewGeometry(parentWidget()->mapFromGlobal(mouseEvent->globalPosition().toPoint()));
} }
return; return;
} }
// Do not resize/move if not allowed. // Do not resize/move if not allowed.
d->currentOperation = d->getOperation(mouseEvent->pos()); d->currentOperation = d->getOperation(mouseEvent->position().toPoint());
if ((d->isResizeOperation() && !d->resizeEnabled) || (d->isMoveOperation() && !d->moveEnabled)) if ((d->isResizeOperation() && !d->resizeEnabled) || (d->isMoveOperation() && !d->moveEnabled))
d->currentOperation = QMdiSubWindowPrivate::None; d->currentOperation = QMdiSubWindowPrivate::None;
d->updateCursor(); d->updateCursor();

View File

@ -1303,7 +1303,7 @@ void QMenuPrivate::scrollMenu(QMenuScroller::ScrollDirection direction, bool pag
bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
{ {
Q_Q(QMenu); Q_Q(QMenu);
QPoint pos = q->mapFromGlobal(e->globalPos()); QPoint pos = q->mapFromGlobal(e->globalPosition().toPoint());
QStyle *style = q->style(); QStyle *style = q->style();
QStyleOption opt(0); QStyleOption opt(0);
@ -1342,7 +1342,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
if (scroll && scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) if (scroll && scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
tearRect.translate(0, scrollerHeight()); tearRect.translate(0, scrollerHeight());
q->update(tearRect); q->update(tearRect);
if (tearRect.contains(pos) && hasMouseMoved(e->globalPos())) { if (tearRect.contains(pos) && hasMouseMoved(e->globalPosition().toPoint())) {
setCurrentAction(nullptr); setCurrentAction(nullptr);
tearoffHighlighted = 1; tearoffHighlighted = 1;
if (e->type() == QEvent::MouseButtonRelease) { if (e->type() == QEvent::MouseButtonRelease) {
@ -1357,13 +1357,13 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
tearoffHighlighted = 0; tearoffHighlighted = 0;
} }
if (q->frameGeometry().contains(e->globalPos())) if (q->frameGeometry().contains(e->globalPosition().toPoint()))
return false; //otherwise if the event is in our rect we want it.. return false; //otherwise if the event is in our rect we want it..
for(QWidget *caused = causedPopup.widget; caused;) { for(QWidget *caused = causedPopup.widget; caused;) {
bool passOnEvent = false; bool passOnEvent = false;
QWidget *next_widget = nullptr; QWidget *next_widget = nullptr;
QPoint cpos = caused->mapFromGlobal(e->globalPos()); QPoint cpos = caused->mapFromGlobal(e->globalPosition().toPoint());
#if QT_CONFIG(menubar) #if QT_CONFIG(menubar)
if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) { if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
passOnEvent = mb->rect().contains(cpos); passOnEvent = mb->rect().contains(cpos);
@ -1375,7 +1375,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
} }
if (passOnEvent) { if (passOnEvent) {
if (e->type() != QEvent::MouseButtonRelease || mouseDown == caused) { if (e->type() != QEvent::MouseButtonRelease || mouseDown == caused) {
QMouseEvent new_e(e->type(), cpos, caused->mapTo(caused->topLevelWidget(), cpos), e->screenPos(), QMouseEvent new_e(e->type(), cpos, caused->mapTo(caused->topLevelWidget(), cpos), e->globalPosition(),
e->button(), e->buttons(), e->modifiers(), e->source()); e->button(), e->buttons(), e->modifiers(), e->source());
QCoreApplication::sendEvent(caused, &new_e); QCoreApplication::sendEvent(caused, &new_e);
return true; return true;
@ -2934,9 +2934,9 @@ void QMenu::mousePressEvent(QMouseEvent *e)
// and mouse clicks on second screen, e->pos() is QPoint(0,0) and the menu doesn't hide. This trick makes // and mouse clicks on second screen, e->pos() is QPoint(0,0) and the menu doesn't hide. This trick makes
// possible to hide the menu when mouse clicks on another screen (e->screenPos() returns correct value). // possible to hide the menu when mouse clicks on another screen (e->screenPos() returns correct value).
// Only when mouse clicks in QPoint(0,0) on second screen, the menu doesn't hide. // Only when mouse clicks in QPoint(0,0) on second screen, the menu doesn't hide.
if ((e->pos().isNull() && !e->screenPos().isNull()) || !rect().contains(e->pos())) { if ((e->position().toPoint().isNull() && !e->globalPosition().isNull()) || !rect().contains(e->position().toPoint())) {
if (d->noReplayFor if (d->noReplayFor
&& QRect(d->noReplayFor->mapToGlobal(QPoint()), d->noReplayFor->size()).contains(e->globalPos())) && QRect(d->noReplayFor->mapToGlobal(QPoint()), d->noReplayFor->size()).contains(e->globalPosition().toPoint()))
setAttribute(Qt::WA_NoMouseReplay); setAttribute(Qt::WA_NoMouseReplay);
if (d->eventLoop) // synchronous operation if (d->eventLoop) // synchronous operation
d->syncAction = nullptr; d->syncAction = nullptr;
@ -2945,7 +2945,7 @@ void QMenu::mousePressEvent(QMouseEvent *e)
} }
QMenuPrivate::mouseDown = this; QMenuPrivate::mouseDown = this;
QAction *action = d->actionAt(e->pos()); QAction *action = d->actionAt(e->position().toPoint());
d->setCurrentAction(action, 20); d->setCurrentAction(action, 20);
update(); update();
} }
@ -2965,7 +2965,7 @@ void QMenu::mouseReleaseEvent(QMouseEvent *e)
QMenuPrivate::mouseDown = nullptr; QMenuPrivate::mouseDown = nullptr;
d->setSyncAction(); d->setSyncAction();
QAction *action = d->actionAt(e->pos()); QAction *action = d->actionAt(e->position().toPoint());
if (action && action == d->currentAction) { if (action && action == d->currentAction) {
if (!action->menu()){ if (!action->menu()){
@ -2975,7 +2975,7 @@ void QMenu::mouseReleaseEvent(QMouseEvent *e)
#endif #endif
d->activateAction(action, QAction::Trigger); d->activateAction(action, QAction::Trigger);
} }
} else if ((!action || action->isEnabled()) && d->hasMouseMoved(e->globalPos())) { } else if ((!action || action->isEnabled()) && d->hasMouseMoved(e->globalPosition().toPoint())) {
d->hideUpToMenuBar(); d->hideUpToMenuBar();
} }
} }
@ -3485,9 +3485,9 @@ void QMenu::mouseMoveEvent(QMouseEvent *e)
if (d->motions == 0) if (d->motions == 0)
return; return;
d->hasHadMouse = d->hasHadMouse || rect().contains(e->pos()); d->hasHadMouse = d->hasHadMouse || rect().contains(e->position().toPoint());
QAction *action = d->actionAt(e->pos()); QAction *action = d->actionAt(e->position().toPoint());
if ((!action || action->isSeparator()) && !d->sloppyState.enabled()) { if ((!action || action->isSeparator()) && !d->sloppyState.enabled()) {
if (d->hasHadMouse if (d->hasHadMouse
|| (!d->currentAction || !d->currentAction->menu() || !d->currentAction->menu()->isVisible())) { || (!d->currentAction || !d->currentAction->menu() || !d->currentAction->menu()->isVisible())) {
@ -3502,7 +3502,7 @@ void QMenu::mouseMoveEvent(QMouseEvent *e)
if (d->activeMenu) if (d->activeMenu)
d->activeMenu->d_func()->setCurrentAction(nullptr); d->activeMenu->d_func()->setCurrentAction(nullptr);
QMenuSloppyState::MouseEventResult sloppyEventResult = d->sloppyState.processMouseEvent(e->localPos(), action, d->currentAction); QMenuSloppyState::MouseEventResult sloppyEventResult = d->sloppyState.processMouseEvent(e->position(), action, d->currentAction);
if (sloppyEventResult == QMenuSloppyState::EventShouldBePropagated) { if (sloppyEventResult == QMenuSloppyState::EventShouldBePropagated) {
d->setCurrentAction(action, d->mousePopupDelay); d->setCurrentAction(action, d->mousePopupDelay);
} else if (sloppyEventResult == QMenuSloppyState::EventDiscardsSloppyState) { } else if (sloppyEventResult == QMenuSloppyState::EventDiscardsSloppyState) {

View File

@ -1053,12 +1053,12 @@ void QMenuBar::mousePressEvent(QMouseEvent *e)
d->mouseDown = true; d->mouseDown = true;
QAction *action = d->actionAt(e->pos()); QAction *action = d->actionAt(e->position().toPoint());
if (!action || !d->isVisible(action) || !action->isEnabled()) { if (!action || !d->isVisible(action) || !action->isEnabled()) {
d->setCurrentAction(nullptr); d->setCurrentAction(nullptr);
#if QT_CONFIG(whatsthis) #if QT_CONFIG(whatsthis)
if (QWhatsThis::inWhatsThisMode()) if (QWhatsThis::inWhatsThisMode())
QWhatsThis::showText(e->globalPos(), d->whatsThis, this); QWhatsThis::showText(e->globalPosition().toPoint(), d->whatsThis, this);
#endif #endif
return; return;
} }
@ -1084,7 +1084,7 @@ void QMenuBar::mouseReleaseEvent(QMouseEvent *e)
return; return;
d->mouseDown = false; d->mouseDown = false;
QAction *action = d->actionAt(e->pos()); QAction *action = d->actionAt(e->position().toPoint());
// do noting if the action is hidden // do noting if the action is hidden
if (!d->isVisible(action)) if (!d->isVisible(action))
@ -1222,7 +1222,7 @@ void QMenuBar::mouseMoveEvent(QMouseEvent *e)
} }
bool popupState = d->popupState || d->mouseDown; bool popupState = d->popupState || d->mouseDown;
QAction *action = d->actionAt(e->pos()); QAction *action = d->actionAt(e->position().toPoint());
if ((action && d->isVisible(action)) || !popupState) if ((action && d->isVisible(action)) || !popupState)
d->setCurrentAction(action, popupState); d->setCurrentAction(action, popupState);
} }

View File

@ -2091,7 +2091,7 @@ void QPlainTextEdit::mouseMoveEvent(QMouseEvent *e)
{ {
Q_D(QPlainTextEdit); Q_D(QPlainTextEdit);
d->inDrag = false; // paranoia d->inDrag = false; // paranoia
const QPoint pos = e->pos(); const QPoint pos = e->position().toPoint();
d->sendControlEvent(e); d->sendControlEvent(e);
if (!(e->buttons() & Qt::LeftButton)) if (!(e->buttons() & Qt::LeftButton))
return; return;
@ -2115,7 +2115,7 @@ void QPlainTextEdit::mouseReleaseEvent(QMouseEvent *e)
d->ensureCursorVisible(); d->ensureCursorVisible();
} }
if (!isReadOnly() && rect().contains(e->pos())) if (!isReadOnly() && rect().contains(e->position().toPoint()))
d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus); d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);
d->clickCausedFocus = 0; d->clickCausedFocus = 0;
} }
@ -2186,7 +2186,7 @@ void QPlainTextEdit::dragLeaveEvent(QDragLeaveEvent *e)
void QPlainTextEdit::dragMoveEvent(QDragMoveEvent *e) void QPlainTextEdit::dragMoveEvent(QDragMoveEvent *e)
{ {
Q_D(QPlainTextEdit); Q_D(QPlainTextEdit);
d->autoScrollDragPos = e->pos(); d->autoScrollDragPos = e->position().toPoint();
if (!d->autoScrollTimer.isActive()) if (!d->autoScrollTimer.isActive())
d->autoScrollTimer.start(100, this); d->autoScrollTimer.start(100, this);
d->sendControlEvent(e); d->sendControlEvent(e);

View File

@ -226,7 +226,7 @@ void QRadioButton::mouseMoveEvent(QMouseEvent *e)
if (testAttribute(Qt::WA_Hover)) { if (testAttribute(Qt::WA_Hover)) {
bool hit = false; bool hit = false;
if (underMouse()) if (underMouse())
hit = hitButton(e->pos()); hit = hitButton(e->position().toPoint());
if (hit != d->hovering) { if (hit != d->hovering) {
update(); update();

View File

@ -468,7 +468,7 @@ bool QScrollBar::event(QEvent *event)
case QEvent::HoverLeave: case QEvent::HoverLeave:
case QEvent::HoverMove: case QEvent::HoverMove:
if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event)) if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event))
d_func()->updateHoverControl(he->pos()); d_func()->updateHoverControl(he->position().toPoint());
break; break;
case QEvent::StyleChange: case QEvent::StyleChange:
d_func()->setTransient(style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, this)); d_func()->setTransient(style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, this));
@ -559,12 +559,12 @@ void QScrollBar::mousePressEvent(QMouseEvent *e)
|| !(e->button() == Qt::LeftButton || (midButtonAbsPos && e->button() == Qt::MidButton))) || !(e->button() == Qt::LeftButton || (midButtonAbsPos && e->button() == Qt::MidButton)))
return; return;
d->pressedControl = style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, e->pos(), this); d->pressedControl = style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, e->position().toPoint(), this);
d->pointerOutsidePressedControl = false; d->pointerOutsidePressedControl = false;
QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt, QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarSlider, this); QStyle::SC_ScrollBarSlider, this);
QPoint click = e->pos(); QPoint click = e->position().toPoint();
QPoint pressValue = click - sr.center() + sr.topLeft(); QPoint pressValue = click - sr.center() + sr.topLeft();
d->pressValue = d->orientation == Qt::Horizontal ? d->pixelPosToRangeValue(pressValue.x()) : d->pressValue = d->orientation == Qt::Horizontal ? d->pixelPosToRangeValue(pressValue.x()) :
d->pixelPosToRangeValue(pressValue.y()); d->pixelPosToRangeValue(pressValue.y());
@ -579,8 +579,8 @@ void QScrollBar::mousePressEvent(QMouseEvent *e)
|| (style()->styleHint(QStyle::SH_ScrollBar_LeftClickAbsolutePosition, &opt, this) || (style()->styleHint(QStyle::SH_ScrollBar_LeftClickAbsolutePosition, &opt, this)
&& e->button() == Qt::LeftButton))) { && e->button() == Qt::LeftButton))) {
int sliderLength = HORIZONTAL ? sr.width() : sr.height(); int sliderLength = HORIZONTAL ? sr.width() : sr.height();
setSliderPosition(d->pixelPosToRangeValue((HORIZONTAL ? e->pos().x() setSliderPosition(d->pixelPosToRangeValue((HORIZONTAL ? e->position().toPoint().x()
: e->pos().y()) - sliderLength / 2)); : e->position().toPoint().y()) - sliderLength / 2));
d->pressedControl = QStyle::SC_ScrollBarSlider; d->pressedControl = QStyle::SC_ScrollBarSlider;
d->clickOffset = sliderLength / 2; d->clickOffset = sliderLength / 2;
} }
@ -636,13 +636,13 @@ void QScrollBar::mouseMoveEvent(QMouseEvent *e)
return; return;
if (d->pressedControl == QStyle::SC_ScrollBarSlider) { if (d->pressedControl == QStyle::SC_ScrollBarSlider) {
QPoint click = e->pos(); QPoint click = e->position().toPoint();
int newPosition = d->pixelPosToRangeValue((HORIZONTAL ? click.x() : click.y()) -d->clickOffset); int newPosition = d->pixelPosToRangeValue((HORIZONTAL ? click.x() : click.y()) -d->clickOffset);
int m = style()->pixelMetric(QStyle::PM_MaximumDragDistance, &opt, this); int m = style()->pixelMetric(QStyle::PM_MaximumDragDistance, &opt, this);
if (m >= 0) { if (m >= 0) {
QRect r = rect(); QRect r = rect();
r.adjust(-m, -m, m, m); r.adjust(-m, -m, m, m);
if (! r.contains(e->pos())) if (! r.contains(e->position().toPoint()))
newPosition = d->snapBackPosition; newPosition = d->snapBackPosition;
} }
setSliderPosition(newPosition); setSliderPosition(newPosition);
@ -650,7 +650,7 @@ void QScrollBar::mouseMoveEvent(QMouseEvent *e)
if (style()->styleHint(QStyle::SH_ScrollBar_RollBetweenButtons, &opt, this) if (style()->styleHint(QStyle::SH_ScrollBar_RollBetweenButtons, &opt, this)
&& d->pressedControl & (QStyle::SC_ScrollBarAddLine | QStyle::SC_ScrollBarSubLine)) { && d->pressedControl & (QStyle::SC_ScrollBarAddLine | QStyle::SC_ScrollBarSubLine)) {
QStyle::SubControl newSc = style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, e->pos(), this); QStyle::SubControl newSc = style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, e->position().toPoint(), this);
if (newSc == d->pressedControl && !d->pointerOutsidePressedControl) if (newSc == d->pressedControl && !d->pointerOutsidePressedControl)
return; // nothing to do return; // nothing to do
if (newSc & (QStyle::SC_ScrollBarAddLine | QStyle::SC_ScrollBarSubLine)) { if (newSc & (QStyle::SC_ScrollBarAddLine | QStyle::SC_ScrollBarSubLine)) {
@ -667,7 +667,7 @@ void QScrollBar::mouseMoveEvent(QMouseEvent *e)
// stop scrolling when the mouse pointer leaves a control // stop scrolling when the mouse pointer leaves a control
// similar to push buttons // similar to push buttons
QRect pr = style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this); QRect pr = style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this);
if (pr.contains(e->pos()) == d->pointerOutsidePressedControl) { if (pr.contains(e->position().toPoint()) == d->pointerOutsidePressedControl) {
if ((d->pointerOutsidePressedControl = !d->pointerOutsidePressedControl)) { if ((d->pointerOutsidePressedControl = !d->pointerOutsidePressedControl)) {
d->pointerOutsidePressedControl = true; d->pointerOutsidePressedControl = true;
setRepeatAction(SliderNoAction); setRepeatAction(SliderNoAction);

View File

@ -279,7 +279,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
Q_D(QSizeGrip); Q_D(QSizeGrip);
QWidget *tlw = qt_sizegrip_topLevelWidget(this); QWidget *tlw = qt_sizegrip_topLevelWidget(this);
d->p = e->globalPos(); d->p = e->globalPosition().toPoint();
d->gotMousePress = true; d->gotMousePress = true;
d->r = tlw->geometry(); d->r = tlw->geometry();
@ -373,7 +373,7 @@ void QSizeGrip::mouseMoveEvent(QMouseEvent * e)
if (!d->gotMousePress || tlw->testAttribute(Qt::WA_WState_ConfigPending)) if (!d->gotMousePress || tlw->testAttribute(Qt::WA_WState_ConfigPending))
return; return;
QPoint np(e->globalPos()); QPoint np(e->globalPosition().toPoint());
// Don't extend beyond the available geometry; bound to dyMax and dxMax. // Don't extend beyond the available geometry; bound to dyMax and dxMax.
QSize ns; QSize ns;

View File

@ -338,7 +338,7 @@ bool QSlider::event(QEvent *event)
case QEvent::HoverLeave: case QEvent::HoverLeave:
case QEvent::HoverMove: case QEvent::HoverMove:
if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event)) if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event))
d->updateHoverControl(he->pos()); d->updateHoverControl(he->position().toPoint());
break; break;
case QEvent::StyleChange: case QEvent::StyleChange:
case QEvent::MacSizeChange: case QEvent::MacSizeChange:
@ -372,7 +372,7 @@ void QSlider::mousePressEvent(QMouseEvent *ev)
const QPoint center = sliderRect.center() - sliderRect.topLeft(); const QPoint center = sliderRect.center() - sliderRect.topLeft();
// to take half of the slider off for the setSliderPosition call we use the center - topLeft // to take half of the slider off for the setSliderPosition call we use the center - topLeft
setSliderPosition(d->pixelPosToRangeValue(d->pick(ev->pos() - center))); setSliderPosition(d->pixelPosToRangeValue(d->pick(ev->position().toPoint() - center)));
triggerAction(SliderMove); triggerAction(SliderMove);
setRepeatAction(SliderNoAction); setRepeatAction(SliderNoAction);
d->pressedControl = QStyle::SC_SliderHandle; d->pressedControl = QStyle::SC_SliderHandle;
@ -381,11 +381,11 @@ void QSlider::mousePressEvent(QMouseEvent *ev)
QStyleOptionSlider opt; QStyleOptionSlider opt;
initStyleOption(&opt); initStyleOption(&opt);
d->pressedControl = style()->hitTestComplexControl(QStyle::CC_Slider, d->pressedControl = style()->hitTestComplexControl(QStyle::CC_Slider,
&opt, ev->pos(), this); &opt, ev->position().toPoint(), this);
SliderAction action = SliderNoAction; SliderAction action = SliderNoAction;
if (d->pressedControl == QStyle::SC_SliderGroove) { if (d->pressedControl == QStyle::SC_SliderGroove) {
const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
int pressValue = d->pixelPosToRangeValue(d->pick(ev->pos() - sliderRect.center() + sliderRect.topLeft())); int pressValue = d->pixelPosToRangeValue(d->pick(ev->position().toPoint() - sliderRect.center() + sliderRect.topLeft()));
d->pressValue = pressValue; d->pressValue = pressValue;
if (pressValue > d->value) if (pressValue > d->value)
action = SliderPageStepAdd; action = SliderPageStepAdd;
@ -406,7 +406,7 @@ void QSlider::mousePressEvent(QMouseEvent *ev)
initStyleOption(&opt); initStyleOption(&opt);
setRepeatAction(SliderNoAction); setRepeatAction(SliderNoAction);
QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
d->clickOffset = d->pick(ev->pos() - sr.topLeft()); d->clickOffset = d->pick(ev->position().toPoint() - sr.topLeft());
update(sr); update(sr);
setSliderDown(true); setSliderDown(true);
} }
@ -423,7 +423,7 @@ void QSlider::mouseMoveEvent(QMouseEvent *ev)
return; return;
} }
ev->accept(); ev->accept();
int newPosition = d->pixelPosToRangeValue(d->pick(ev->pos()) - d->clickOffset); int newPosition = d->pixelPosToRangeValue(d->pick(ev->position().toPoint()) - d->clickOffset);
QStyleOptionSlider opt; QStyleOptionSlider opt;
initStyleOption(&opt); initStyleOption(&opt);
setSliderPosition(newPosition); setSliderPosition(newPosition);

View File

@ -292,7 +292,7 @@ void QSplitterHandle::mouseMoveEvent(QMouseEvent *e)
Q_D(QSplitterHandle); Q_D(QSplitterHandle);
if (!(e->buttons() & Qt::LeftButton)) if (!(e->buttons() & Qt::LeftButton))
return; return;
int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPos())) int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPosition().toPoint()))
- d->mouseOffset; - d->mouseOffset;
if (opaqueResize()) { if (opaqueResize()) {
moveSplitter(pos); moveSplitter(pos);
@ -308,7 +308,7 @@ void QSplitterHandle::mousePressEvent(QMouseEvent *e)
{ {
Q_D(QSplitterHandle); Q_D(QSplitterHandle);
if (e->button() == Qt::LeftButton) { if (e->button() == Qt::LeftButton) {
d->mouseOffset = d->pick(e->pos()); d->mouseOffset = d->pick(e->position().toPoint());
d->pressed = true; d->pressed = true;
update(); update();
} }
@ -321,7 +321,7 @@ void QSplitterHandle::mouseReleaseEvent(QMouseEvent *e)
{ {
Q_D(QSplitterHandle); Q_D(QSplitterHandle);
if (!opaqueResize() && e->button() == Qt::LeftButton) { if (!opaqueResize() && e->button() == Qt::LeftButton) {
int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPos())) int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPosition().toPoint()))
- d->mouseOffset; - d->mouseOffset;
d->s->setRubberBand(-1); d->s->setRubberBand(-1);
moveSplitter(pos); moveSplitter(pos);

View File

@ -1685,12 +1685,12 @@ bool QTabBar::event(QEvent *event)
case QEvent::HoverMove: case QEvent::HoverMove:
case QEvent::HoverEnter: { case QEvent::HoverEnter: {
QHoverEvent *he = static_cast<QHoverEvent *>(event); QHoverEvent *he = static_cast<QHoverEvent *>(event);
if (!d->hoverRect.contains(he->pos())) { if (!d->hoverRect.contains(he->position().toPoint())) {
QRect oldHoverRect = d->hoverRect; QRect oldHoverRect = d->hoverRect;
bool cursorOverTabs = false; bool cursorOverTabs = false;
for (int i = 0; i < d->tabList.count(); ++i) { for (int i = 0; i < d->tabList.count(); ++i) {
QRect area = tabRect(i); QRect area = tabRect(i);
if (area.contains(he->pos())) { if (area.contains(he->position().toPoint())) {
d->hoverIndex = i; d->hoverIndex = i;
d->hoverRect = area; d->hoverRect = area;
cursorOverTabs = true; cursorOverTabs = true;
@ -1766,7 +1766,7 @@ bool QTabBar::event(QEvent *event)
break; break;
case QEvent::DragMove: case QEvent::DragMove:
if (d->changeCurrentOnDrag) { if (d->changeCurrentOnDrag) {
const int tabIndex = tabAt(static_cast<QDragMoveEvent *>(event)->pos()); const int tabIndex = tabAt(static_cast<QDragMoveEvent *>(event)->position().toPoint());
if (isTabEnabled(tabIndex) && d->switchTabCurrentIndex != tabIndex) { if (isTabEnabled(tabIndex) && d->switchTabCurrentIndex != tabIndex) {
d->switchTabCurrentIndex = tabIndex; d->switchTabCurrentIndex = tabIndex;
if (d->switchTabTimerId) if (d->switchTabTimerId)
@ -2100,7 +2100,7 @@ void QTabBar::mousePressEvent(QMouseEvent *event)
{ {
Q_D(QTabBar); Q_D(QTabBar);
const QPoint pos = event->pos(); const QPoint pos = event->position().toPoint();
const bool isEventInCornerButtons = (!d->leftB->isHidden() && d->leftB->geometry().contains(pos)) const bool isEventInCornerButtons = (!d->leftB->isHidden() && d->leftB->geometry().contains(pos))
|| (!d->rightB->isHidden() && d->rightB->geometry().contains(pos)); || (!d->rightB->isHidden() && d->rightB->geometry().contains(pos));
if (!isEventInCornerButtons) { if (!isEventInCornerButtons) {
@ -2116,7 +2116,7 @@ void QTabBar::mousePressEvent(QMouseEvent *event)
if (d->pressedIndex != -1 && d->movable) if (d->pressedIndex != -1 && d->movable)
d->moveTabFinished(d->pressedIndex); d->moveTabFinished(d->pressedIndex);
d->pressedIndex = d->indexAtPos(event->pos()); d->pressedIndex = d->indexAtPos(event->position().toPoint());
if (d->validIndex(d->pressedIndex)) { if (d->validIndex(d->pressedIndex)) {
QStyleOptionTabBarBase optTabBase; QStyleOptionTabBarBase optTabBase;
@ -2127,7 +2127,7 @@ void QTabBar::mousePressEvent(QMouseEvent *event)
else else
repaint(tabRect(d->pressedIndex)); repaint(tabRect(d->pressedIndex));
if (d->movable) { if (d->movable) {
d->dragStartPosition = event->pos(); d->dragStartPosition = event->position().toPoint();
} }
} }
} }
@ -2145,7 +2145,7 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event)
// Start drag // Start drag
if (!d->dragInProgress && d->pressedIndex != -1) { if (!d->dragInProgress && d->pressedIndex != -1) {
if ((event->pos() - d->dragStartPosition).manhattanLength() > QApplication::startDragDistance()) { if ((event->position().toPoint() - d->dragStartPosition).manhattanLength() > QApplication::startDragDistance()) {
d->dragInProgress = true; d->dragInProgress = true;
d->setupMovableTab(); d->setupMovableTab();
} }
@ -2157,9 +2157,9 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event)
bool vertical = verticalTabs(d->shape); bool vertical = verticalTabs(d->shape);
int dragDistance; int dragDistance;
if (vertical) { if (vertical) {
dragDistance = (event->pos().y() - d->dragStartPosition.y()); dragDistance = (event->position().toPoint().y() - d->dragStartPosition.y());
} else { } else {
dragDistance = (event->pos().x() - d->dragStartPosition.x()); dragDistance = (event->position().toPoint().x() - d->dragStartPosition.x());
} }
d->tabList[d->pressedIndex].dragOffset = dragDistance; d->tabList[d->pressedIndex].dragOffset = dragDistance;
@ -2304,7 +2304,7 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event)
d->dragStartPosition = QPoint(); d->dragStartPosition = QPoint();
} }
int i = d->indexAtPos(event->pos()) == d->pressedIndex ? d->pressedIndex : -1; int i = d->indexAtPos(event->position().toPoint()) == d->pressedIndex ? d->pressedIndex : -1;
d->pressedIndex = -1; d->pressedIndex = -1;
QStyleOptionTabBarBase optTabBase; QStyleOptionTabBarBase optTabBase;
optTabBase.initFrom(this); optTabBase.initFrom(this);
@ -2322,7 +2322,7 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event)
void QTabBar::mouseDoubleClickEvent(QMouseEvent *event) void QTabBar::mouseDoubleClickEvent(QMouseEvent *event)
{ {
Q_D(QTabBar); Q_D(QTabBar);
const QPoint pos = event->pos(); const QPoint pos = event->position().toPoint();
const bool isEventInCornerButtons = (!d->leftB->isHidden() && d->leftB->geometry().contains(pos)) const bool isEventInCornerButtons = (!d->leftB->isHidden() && d->leftB->geometry().contains(pos))
|| (!d->rightB->isHidden() && d->rightB->geometry().contains(pos)); || (!d->rightB->isHidden() && d->rightB->geometry().contains(pos));
if (!isEventInCornerButtons) if (!isEventInCornerButtons)

View File

@ -1677,7 +1677,7 @@ void QTextEdit::mouseMoveEvent(QMouseEvent *e)
{ {
Q_D(QTextEdit); Q_D(QTextEdit);
d->inDrag = false; // paranoia d->inDrag = false; // paranoia
const QPoint pos = e->pos(); const QPoint pos = e->position().toPoint();
d->sendControlEvent(e); d->sendControlEvent(e);
if (!(e->buttons() & Qt::LeftButton)) if (!(e->buttons() & Qt::LeftButton))
return; return;
@ -1700,7 +1700,7 @@ void QTextEdit::mouseReleaseEvent(QMouseEvent *e)
d->autoScrollTimer.stop(); d->autoScrollTimer.stop();
ensureCursorVisible(); ensureCursorVisible();
} }
if (!isReadOnly() && rect().contains(e->pos())) if (!isReadOnly() && rect().contains(e->position().toPoint()))
d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus); d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);
d->clickCausedFocus = 0; d->clickCausedFocus = 0;
} }
@ -1771,7 +1771,7 @@ void QTextEdit::dragLeaveEvent(QDragLeaveEvent *e)
void QTextEdit::dragMoveEvent(QDragMoveEvent *e) void QTextEdit::dragMoveEvent(QDragMoveEvent *e)
{ {
Q_D(QTextEdit); Q_D(QTextEdit);
d->autoScrollDragPos = e->pos(); d->autoScrollDragPos = e->position().toPoint();
if (!d->autoScrollTimer.isActive()) if (!d->autoScrollTimer.isActive())
d->autoScrollTimer.start(100, this); d->autoScrollTimer.start(100, this);
d->sendControlEvent(e); d->sendControlEvent(e);

View File

@ -247,7 +247,7 @@ bool QToolBarPrivate::mousePressEvent(QMouseEvent *event)
Q_Q(QToolBar); Q_Q(QToolBar);
QStyleOptionToolBar opt; QStyleOptionToolBar opt;
q->initStyleOption(&opt); q->initStyleOption(&opt);
if (q->style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, q).contains(event->pos()) == false) { if (q->style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, q).contains(event->position().toPoint()) == false) {
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
// When using the unified toolbar on OS X, the user can click and // When using the unified toolbar on OS X, the user can click and
// drag between toolbar contents to move the window. Make this work by // drag between toolbar contents to move the window. Make this work by
@ -272,7 +272,7 @@ bool QToolBarPrivate::mousePressEvent(QMouseEvent *event)
if (!layout->movable()) if (!layout->movable())
return true; return true;
initDrag(event->pos()); initDrag(event->position().toPoint());
return true; return true;
} }
@ -317,11 +317,11 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event)
Q_ASSERT(layout != nullptr); Q_ASSERT(layout != nullptr);
if (layout->pluggingWidget == nullptr if (layout->pluggingWidget == nullptr
&& (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()) { && (event->position().toPoint() - state->pressPos).manhattanLength() > QApplication::startDragDistance()) {
const bool wasDragging = state->dragging; const bool wasDragging = state->dragging;
const bool moving = !q->isWindow() && (orientation == Qt::Vertical ? const bool moving = !q->isWindow() && (orientation == Qt::Vertical ?
event->x() >= 0 && event->x() < q->width() : event->position().toPoint().x() >= 0 && event->position().toPoint().x() < q->width() :
event->y() >= 0 && event->y() < q->height()); event->position().toPoint().y() >= 0 && event->position().toPoint().y() < q->height());
startDrag(moving); startDrag(moving);
if (!moving && !wasDragging) if (!moving && !wasDragging)
@ -329,7 +329,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event)
} }
if (state->dragging) { if (state->dragging) {
QPoint pos = event->globalPos(); QPoint pos = event->globalPosition().toPoint();
// if we are right-to-left, we move so as to keep the right edge the same distance // if we are right-to-left, we move so as to keep the right edge the same distance
// from the mouse // from the mouse
if (q->isLeftToRight()) if (q->isLeftToRight())
@ -338,14 +338,14 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event)
pos += QPoint(state->pressPos.x() - q->width(), -state->pressPos.y()); pos += QPoint(state->pressPos.x() - q->width(), -state->pressPos.y());
q->move(pos); q->move(pos);
layout->hover(state->widgetItem, event->globalPos()); layout->hover(state->widgetItem, event->globalPosition().toPoint());
} else if (state->moving) { } else if (state->moving) {
const QPoint rtl(q->width() - state->pressPos.x(), state->pressPos.y()); //for RTL const QPoint rtl(q->width() - state->pressPos.x(), state->pressPos.y()); //for RTL
const QPoint globalPressPos = q->mapToGlobal(q->isRightToLeft() ? rtl : state->pressPos); const QPoint globalPressPos = q->mapToGlobal(q->isRightToLeft() ? rtl : state->pressPos);
int pos = 0; int pos = 0;
QPoint delta = event->globalPos() - globalPressPos; QPoint delta = event->globalPosition().toPoint() - globalPressPos;
if (orientation == Qt::Vertical) { if (orientation == Qt::Vertical) {
pos = q->y() + delta.y(); pos = q->y() + delta.y();
} else { } else {
@ -1150,7 +1150,7 @@ bool QToolBar::event(QEvent *event)
QHoverEvent *e = static_cast<QHoverEvent*>(event); QHoverEvent *e = static_cast<QHoverEvent*>(event);
QStyleOptionToolBar opt; QStyleOptionToolBar opt;
initStyleOption(&opt); initStyleOption(&opt);
if (style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->pos())) if (style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->position().toPoint()))
setCursor(Qt::SizeAllCursor); setCursor(Qt::SizeAllCursor);
else else
unsetCursor(); unsetCursor();

View File

@ -603,7 +603,7 @@ void QToolButton::mousePressEvent(QMouseEvent *e)
if (e->button() == Qt::LeftButton && (d->popupMode == MenuButtonPopup)) { if (e->button() == Qt::LeftButton && (d->popupMode == MenuButtonPopup)) {
QRect popupr = style()->subControlRect(QStyle::CC_ToolButton, &opt, QRect popupr = style()->subControlRect(QStyle::CC_ToolButton, &opt,
QStyle::SC_ToolButtonMenu, this); QStyle::SC_ToolButtonMenu, this);
if (popupr.isValid() && popupr.contains(e->pos())) { if (popupr.isValid() && popupr.contains(e->position().toPoint())) {
d->buttonPressed = QToolButtonPrivate::MenuButtonPressed; d->buttonPressed = QToolButtonPrivate::MenuButtonPressed;
showMenu(); showMenu();
return; return;
@ -1004,7 +1004,7 @@ bool QToolButton::event(QEvent *event)
case QEvent::HoverLeave: case QEvent::HoverLeave:
case QEvent::HoverMove: case QEvent::HoverMove:
if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event)) if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event))
d_func()->updateHoverControl(he->pos()); d_func()->updateHoverControl(he->position().toPoint());
break; break;
default: default:
break; break;

View File

@ -111,7 +111,7 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee)
if (w->isMaximized()) if (w->isMaximized())
break; break;
const QRect widgetRect = widget->rect().marginsAdded(QMargins(range, range, range, range)); const QRect widgetRect = widget->rect().marginsAdded(QMargins(range, range, range, range));
const QPoint cursorPoint = widget->mapFromGlobal(e->globalPos()); const QPoint cursorPoint = widget->mapFromGlobal(e->globalPosition().toPoint());
if (!widgetRect.contains(cursorPoint)) if (!widgetRect.contains(cursorPoint))
return false; return false;
if (e->button() == Qt::LeftButton) { if (e->button() == Qt::LeftButton) {
@ -119,7 +119,7 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee)
emit activate(); emit activate();
mouseMoveEvent(e); mouseMoveEvent(e);
buttonDown = true; buttonDown = true;
moveOffset = widget->mapFromGlobal(e->globalPos()); moveOffset = widget->mapFromGlobal(e->globalPosition().toPoint());
invertedMoveOffset = widget->rect().bottomRight() - moveOffset; invertedMoveOffset = widget->rect().bottomRight() - moveOffset;
if (mode != Center) if (mode != Center)
return true; return true;
@ -165,7 +165,7 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee)
void QWidgetResizeHandler::mouseMoveEvent(QMouseEvent *e) void QWidgetResizeHandler::mouseMoveEvent(QMouseEvent *e)
{ {
QPoint pos = widget->mapFromGlobal(e->globalPos()); QPoint pos = widget->mapFromGlobal(e->globalPosition().toPoint());
if (!active && !buttonDown) { if (!active && !buttonDown) {
if (pos.y() <= range && pos.x() <= range) if (pos.y() <= range && pos.x() <= range)
mode = TopLeft; mode = TopLeft;
@ -204,7 +204,7 @@ void QWidgetResizeHandler::mouseMoveEvent(QMouseEvent *e)
QPoint globalPos = (!widget->isWindow() && widget->parentWidget()) ? QPoint globalPos = (!widget->isWindow() && widget->parentWidget()) ?
widget->parentWidget()->mapFromGlobal(e->globalPos()) : e->globalPos(); widget->parentWidget()->mapFromGlobal(e->globalPosition().toPoint()) : e->globalPosition().toPoint();
if (!widget->isWindow() && !widget->parentWidget()->rect().contains(globalPos)) { if (!widget->isWindow() && !widget->parentWidget()->rect().contains(globalPos)) {
if (globalPos.x() < 0) if (globalPos.x() < 0)
globalPos.rx() = 0; globalPos.rx() = 0;

View File

@ -1040,23 +1040,23 @@ void QWidgetTextControl::processEvent(QEvent *e, const QTransform &transform, QW
break; break;
case QEvent::MouseButtonPress: { case QEvent::MouseButtonPress: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e); QMouseEvent *ev = static_cast<QMouseEvent *>(e);
d->mousePressEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), d->mousePressEvent(ev, ev->button(), transform.map(ev->position().toPoint()), ev->modifiers(),
ev->buttons(), ev->globalPos()); ev->buttons(), ev->globalPosition().toPoint());
break; } break; }
case QEvent::MouseMove: { case QEvent::MouseMove: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e); QMouseEvent *ev = static_cast<QMouseEvent *>(e);
d->mouseMoveEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), d->mouseMoveEvent(ev, ev->button(), transform.map(ev->position().toPoint()), ev->modifiers(),
ev->buttons(), ev->globalPos()); ev->buttons(), ev->globalPosition().toPoint());
break; } break; }
case QEvent::MouseButtonRelease: { case QEvent::MouseButtonRelease: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e); QMouseEvent *ev = static_cast<QMouseEvent *>(e);
d->mouseReleaseEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), d->mouseReleaseEvent(ev, ev->button(), transform.map(ev->position().toPoint()), ev->modifiers(),
ev->buttons(), ev->globalPos()); ev->buttons(), ev->globalPosition().toPoint());
break; } break; }
case QEvent::MouseButtonDblClick: { case QEvent::MouseButtonDblClick: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e); QMouseEvent *ev = static_cast<QMouseEvent *>(e);
d->mouseDoubleClickEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), d->mouseDoubleClickEvent(ev, ev->button(), transform.map(ev->position().toPoint()), ev->modifiers(),
ev->buttons(), ev->globalPos()); ev->buttons(), ev->globalPosition().toPoint());
break; } break; }
case QEvent::InputMethod: case QEvent::InputMethod:
d->inputMethodEvent(static_cast<QInputMethodEvent *>(e)); d->inputMethodEvent(static_cast<QInputMethodEvent *>(e));
@ -1096,13 +1096,13 @@ void QWidgetTextControl::processEvent(QEvent *e, const QTransform &transform, QW
break; break;
case QEvent::DragMove: { case QEvent::DragMove: {
QDragMoveEvent *ev = static_cast<QDragMoveEvent *>(e); QDragMoveEvent *ev = static_cast<QDragMoveEvent *>(e);
if (d->dragMoveEvent(e, ev->mimeData(), transform.map(ev->pos()))) if (d->dragMoveEvent(e, ev->mimeData(), transform.map(ev->position().toPoint())))
ev->acceptProposedAction(); ev->acceptProposedAction();
break; break;
} }
case QEvent::Drop: { case QEvent::Drop: {
QDropEvent *ev = static_cast<QDropEvent *>(e); QDropEvent *ev = static_cast<QDropEvent *>(e);
if (d->dropEvent(ev->mimeData(), transform.map(ev->pos()), ev->dropAction(), ev->source())) if (d->dropEvent(ev->mimeData(), transform.map(ev->position().toPoint()), ev->dropAction(), ev->source()))
ev->acceptProposedAction(); ev->acceptProposedAction();
break; break;
} }

View File

@ -117,15 +117,15 @@ void tst_QMouseEvent::mouseEventBasic()
QCOMPARE(me.isAccepted(), true); QCOMPARE(me.isAccepted(), true);
QCOMPARE(me.button(), Qt::LeftButton); QCOMPARE(me.button(), Qt::LeftButton);
QCOMPARE(me.buttons(), Qt::LeftButton); QCOMPARE(me.buttons(), Qt::LeftButton);
QCOMPARE(me.localPos(), local); QCOMPARE(me.position(), local);
QCOMPARE(me.windowPos(), scene); QCOMPARE(me.scenePosition(), scene);
QCOMPARE(me.screenPos(), screen); QCOMPARE(me.globalPosition(), screen);
QPointF changedLocal(33, 66); QPointF changedLocal(33, 66);
me.setLocalPos(changedLocal); me.setLocalPos(changedLocal);
QCOMPARE(me.localPos(), changedLocal); QCOMPARE(me.position(), changedLocal);
QCOMPARE(me.windowPos(), scene); QCOMPARE(me.scenePosition(), scene);
QCOMPARE(me.screenPos(), screen); QCOMPARE(me.globalPosition(), screen);
} }
void tst_QMouseEvent::checkMousePressEvent_data() void tst_QMouseEvent::checkMousePressEvent_data()

View File

@ -306,8 +306,8 @@ void tst_QTouchEvent::touchDisabledByDefault()
QTouchEvent::TouchPoint touchPoint(0); QTouchEvent::TouchPoint touchPoint(0);
touchPoint.setState(Qt::TouchPointPressed); touchPoint.setState(Qt::TouchPointPressed);
touchPoint.setPos(view.mapFromScene(item.mapToScene(item.boundingRect().center()))); touchPoint.setPos(view.mapFromScene(item.mapToScene(item.boundingRect().center())));
touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); touchPoint.setScreenPos(view.mapToGlobal(touchPoint.position().toPoint()));
touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); touchPoint.setScenePos(view.mapToScene(touchPoint.position().toPoint()));
QTouchEvent touchEvent(QEvent::TouchBegin, QTouchEvent touchEvent(QEvent::TouchBegin,
touchScreenDevice, touchScreenDevice,
Qt::NoModifier, Qt::NoModifier,
@ -365,8 +365,8 @@ void tst_QTouchEvent::touchEventAcceptedByDefault()
QTouchEvent::TouchPoint touchPoint(0); QTouchEvent::TouchPoint touchPoint(0);
touchPoint.setState(Qt::TouchPointPressed); touchPoint.setState(Qt::TouchPointPressed);
touchPoint.setPos(view.mapFromScene(item.mapToScene(item.boundingRect().center()))); touchPoint.setPos(view.mapFromScene(item.mapToScene(item.boundingRect().center())));
touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); touchPoint.setScreenPos(view.mapToGlobal(touchPoint.position().toPoint()));
touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); touchPoint.setScenePos(view.mapToScene(touchPoint.position().toPoint()));
QTouchEvent touchEvent(QEvent::TouchBegin, QTouchEvent touchEvent(QEvent::TouchBegin,
touchScreenDevice, touchScreenDevice,
Qt::NoModifier, Qt::NoModifier,
@ -442,8 +442,8 @@ void tst_QTouchEvent::touchBeginPropagatesWhenIgnored()
QTouchEvent::TouchPoint touchPoint(0); QTouchEvent::TouchPoint touchPoint(0);
touchPoint.setState(Qt::TouchPointPressed); touchPoint.setState(Qt::TouchPointPressed);
touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center())));
touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); touchPoint.setScreenPos(view.mapToGlobal(touchPoint.position().toPoint()));
touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); touchPoint.setScenePos(view.mapToScene(touchPoint.position().toPoint()));
QTouchEvent touchEvent(QEvent::TouchBegin, QTouchEvent touchEvent(QEvent::TouchBegin,
touchScreenDevice, touchScreenDevice,
Qt::NoModifier, Qt::NoModifier,
@ -477,8 +477,8 @@ void tst_QTouchEvent::touchBeginPropagatesWhenIgnored()
QTouchEvent::TouchPoint touchPoint(0); QTouchEvent::TouchPoint touchPoint(0);
touchPoint.setState(Qt::TouchPointPressed); touchPoint.setState(Qt::TouchPointPressed);
touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center())));
touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); touchPoint.setScreenPos(view.mapToGlobal(touchPoint.position().toPoint()));
touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); touchPoint.setScenePos(view.mapToScene(touchPoint.position().toPoint()));
QTouchEvent touchEvent(QEvent::TouchBegin, QTouchEvent touchEvent(QEvent::TouchBegin,
touchScreenDevice, touchScreenDevice,
Qt::NoModifier, Qt::NoModifier,
@ -560,8 +560,8 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate()
QTouchEvent::TouchPoint touchPoint(0); QTouchEvent::TouchPoint touchPoint(0);
touchPoint.setState(Qt::TouchPointPressed); touchPoint.setState(Qt::TouchPointPressed);
touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center())));
touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); touchPoint.setScreenPos(view.mapToGlobal(touchPoint.position().toPoint()));
touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); touchPoint.setScenePos(view.mapToScene(touchPoint.position().toPoint()));
QTouchEvent touchBeginEvent(QEvent::TouchBegin, QTouchEvent touchBeginEvent(QEvent::TouchBegin,
touchScreenDevice, touchScreenDevice,
Qt::NoModifier, Qt::NoModifier,
@ -625,7 +625,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
// this should be translated to a TouchBegin // this should be translated to a TouchBegin
rawTouchPoint.setState(Qt::TouchPointPressed); rawTouchPoint.setState(Qt::TouchPointPressed);
rawTouchPoint.setScreenPos(screenPos); rawTouchPoint.setScreenPos(screenPos);
rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.position(), screenGeometry));
QVector<QPointF> rawPosList; QVector<QPointF> rawPosList;
rawPosList << QPointF(12, 34) << QPointF(56, 78); rawPosList << QPointF(12, 34) << QPointF(56, 78);
rawTouchPoint.setRawScreenPositions(rawPosList); rawTouchPoint.setRawScreenPositions(rawPosList);
@ -644,21 +644,21 @@ void tst_QTouchEvent::basicRawEventTranslation()
const int touchPointId = (QTouchDevicePrivate::get(touchScreenDevice)->id << 24) + 1; const int touchPointId = (QTouchDevicePrivate::get(touchScreenDevice)->id << 24) + 1;
QCOMPARE(touchBeginPoint.id(), touchPointId); QCOMPARE(touchBeginPoint.id(), touchPointId);
QCOMPARE(touchBeginPoint.state(), rawTouchPoint.state()); QCOMPARE(touchBeginPoint.state(), rawTouchPoint.state());
QCOMPARE(touchBeginPoint.pos(), pos); QCOMPARE(touchBeginPoint.position(), pos);
QCOMPARE(touchBeginPoint.startPos(), pos); QCOMPARE(touchBeginPoint.pressPosition(), pos);
QCOMPARE(touchBeginPoint.lastPos(), pos); QCOMPARE(touchBeginPoint.lastPos(), pos);
QCOMPARE(touchBeginPoint.scenePos(), rawTouchPoint.screenPos()); QCOMPARE(touchBeginPoint.scenePosition(), rawTouchPoint.globalPosition());
QCOMPARE(touchBeginPoint.startScenePos(), rawTouchPoint.screenPos()); QCOMPARE(touchBeginPoint.scenePressPosition(), rawTouchPoint.globalPosition());
QCOMPARE(touchBeginPoint.lastScenePos(), rawTouchPoint.screenPos()); QCOMPARE(touchBeginPoint.lastScenePos(), rawTouchPoint.globalPosition());
QCOMPARE(touchBeginPoint.screenPos(), rawTouchPoint.screenPos()); QCOMPARE(touchBeginPoint.globalPosition(), rawTouchPoint.globalPosition());
QCOMPARE(touchBeginPoint.startScreenPos(), rawTouchPoint.screenPos()); QCOMPARE(touchBeginPoint.globalPressPosition(), rawTouchPoint.globalPosition());
QCOMPARE(touchBeginPoint.lastScreenPos(), rawTouchPoint.screenPos()); QCOMPARE(touchBeginPoint.lastScreenPos(), rawTouchPoint.globalPosition());
QCOMPARE(touchBeginPoint.normalizedPos(), rawTouchPoint.normalizedPos()); QCOMPARE(touchBeginPoint.normalizedPos(), rawTouchPoint.normalizedPos());
QCOMPARE(touchBeginPoint.startNormalizedPos(), touchBeginPoint.normalizedPos()); QCOMPARE(touchBeginPoint.startNormalizedPos(), touchBeginPoint.normalizedPos());
QCOMPARE(touchBeginPoint.lastNormalizedPos(), touchBeginPoint.normalizedPos()); QCOMPARE(touchBeginPoint.lastNormalizedPos(), touchBeginPoint.normalizedPos());
QCOMPARE(touchBeginPoint.pos(), pos); QCOMPARE(touchBeginPoint.position(), pos);
QCOMPARE(touchBeginPoint.screenPos(), rawTouchPoint.screenPos()); QCOMPARE(touchBeginPoint.globalPosition(), rawTouchPoint.globalPosition());
QCOMPARE(touchBeginPoint.scenePos(), touchBeginPoint.scenePos()); QCOMPARE(touchBeginPoint.scenePosition(), touchBeginPoint.scenePosition());
QCOMPARE(touchBeginPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(touchBeginPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(touchBeginPoint.pressure(), qreal(1.)); QCOMPARE(touchBeginPoint.pressure(), qreal(1.));
QCOMPARE(touchBeginPoint.velocity(), QVector2D()); QCOMPARE(touchBeginPoint.velocity(), QVector2D());
@ -668,7 +668,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
// moving the point should translate to TouchUpdate // moving the point should translate to TouchUpdate
rawTouchPoint.setState(Qt::TouchPointMoved); rawTouchPoint.setState(Qt::TouchPointMoved);
rawTouchPoint.setScreenPos(screenPos + delta); rawTouchPoint.setScreenPos(screenPos + delta);
rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.position(), screenGeometry));
nativeTouchPoints = nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, window); QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, window);
QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
@ -680,28 +680,28 @@ void tst_QTouchEvent::basicRawEventTranslation()
QTouchEvent::TouchPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first(); QTouchEvent::TouchPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first();
QCOMPARE(touchUpdatePoint.id(), touchPointId); QCOMPARE(touchUpdatePoint.id(), touchPointId);
QCOMPARE(touchUpdatePoint.state(), rawTouchPoint.state()); QCOMPARE(touchUpdatePoint.state(), rawTouchPoint.state());
QCOMPARE(touchUpdatePoint.pos(), pos + delta); QCOMPARE(touchUpdatePoint.position(), pos + delta);
QCOMPARE(touchUpdatePoint.startPos(), pos); QCOMPARE(touchUpdatePoint.pressPosition(), pos);
QCOMPARE(touchUpdatePoint.lastPos(), pos); QCOMPARE(touchUpdatePoint.lastPos(), pos);
QCOMPARE(touchUpdatePoint.scenePos(), rawTouchPoint.screenPos()); QCOMPARE(touchUpdatePoint.scenePosition(), rawTouchPoint.globalPosition());
QCOMPARE(touchUpdatePoint.startScenePos(), screenPos); QCOMPARE(touchUpdatePoint.scenePressPosition(), screenPos);
QCOMPARE(touchUpdatePoint.lastScenePos(), screenPos); QCOMPARE(touchUpdatePoint.lastScenePos(), screenPos);
QCOMPARE(touchUpdatePoint.screenPos(), rawTouchPoint.screenPos()); QCOMPARE(touchUpdatePoint.globalPosition(), rawTouchPoint.globalPosition());
QCOMPARE(touchUpdatePoint.startScreenPos(), screenPos); QCOMPARE(touchUpdatePoint.globalPressPosition(), screenPos);
QCOMPARE(touchUpdatePoint.lastScreenPos(), screenPos); QCOMPARE(touchUpdatePoint.lastScreenPos(), screenPos);
QCOMPARE(touchUpdatePoint.normalizedPos(), rawTouchPoint.normalizedPos()); QCOMPARE(touchUpdatePoint.normalizedPos(), rawTouchPoint.normalizedPos());
QCOMPARE(touchUpdatePoint.startNormalizedPos(), touchBeginPoint.normalizedPos()); QCOMPARE(touchUpdatePoint.startNormalizedPos(), touchBeginPoint.normalizedPos());
QCOMPARE(touchUpdatePoint.lastNormalizedPos(), touchBeginPoint.normalizedPos()); QCOMPARE(touchUpdatePoint.lastNormalizedPos(), touchBeginPoint.normalizedPos());
QCOMPARE(touchUpdatePoint.pos(), pos + delta); QCOMPARE(touchUpdatePoint.position(), pos + delta);
QCOMPARE(touchUpdatePoint.screenPos(), rawTouchPoint.screenPos()); QCOMPARE(touchUpdatePoint.globalPosition(), rawTouchPoint.globalPosition());
QCOMPARE(touchUpdatePoint.scenePos(), touchUpdatePoint.scenePos()); QCOMPARE(touchUpdatePoint.scenePosition(), touchUpdatePoint.scenePosition());
QCOMPARE(touchUpdatePoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(touchUpdatePoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(touchUpdatePoint.pressure(), qreal(1.)); QCOMPARE(touchUpdatePoint.pressure(), qreal(1.));
// releasing the point translates to TouchEnd // releasing the point translates to TouchEnd
rawTouchPoint.setState(Qt::TouchPointReleased); rawTouchPoint.setState(Qt::TouchPointReleased);
rawTouchPoint.setScreenPos(screenPos + delta + delta); rawTouchPoint.setScreenPos(screenPos + delta + delta);
rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.position(), screenGeometry));
nativeTouchPoints = nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, window); QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, window);
QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
@ -713,21 +713,21 @@ void tst_QTouchEvent::basicRawEventTranslation()
QTouchEvent::TouchPoint touchEndPoint = touchWidget.touchEndPoints.first(); QTouchEvent::TouchPoint touchEndPoint = touchWidget.touchEndPoints.first();
QCOMPARE(touchEndPoint.id(), touchPointId); QCOMPARE(touchEndPoint.id(), touchPointId);
QCOMPARE(touchEndPoint.state(), rawTouchPoint.state()); QCOMPARE(touchEndPoint.state(), rawTouchPoint.state());
QCOMPARE(touchEndPoint.pos(), pos + delta + delta); QCOMPARE(touchEndPoint.position(), pos + delta + delta);
QCOMPARE(touchEndPoint.startPos(), pos); QCOMPARE(touchEndPoint.pressPosition(), pos);
QCOMPARE(touchEndPoint.lastPos(), pos + delta); QCOMPARE(touchEndPoint.lastPos(), pos + delta);
QCOMPARE(touchEndPoint.scenePos(), rawTouchPoint.screenPos()); QCOMPARE(touchEndPoint.scenePosition(), rawTouchPoint.globalPosition());
QCOMPARE(touchEndPoint.startScenePos(), screenPos); QCOMPARE(touchEndPoint.scenePressPosition(), screenPos);
QCOMPARE(touchEndPoint.lastScenePos(), screenPos + delta); QCOMPARE(touchEndPoint.lastScenePos(), screenPos + delta);
QCOMPARE(touchEndPoint.screenPos(), rawTouchPoint.screenPos()); QCOMPARE(touchEndPoint.globalPosition(), rawTouchPoint.globalPosition());
QCOMPARE(touchEndPoint.startScreenPos(), screenPos); QCOMPARE(touchEndPoint.globalPressPosition(), screenPos);
QCOMPARE(touchEndPoint.lastScreenPos(), screenPos + delta); QCOMPARE(touchEndPoint.lastScreenPos(), screenPos + delta);
QCOMPARE(touchEndPoint.normalizedPos(), rawTouchPoint.normalizedPos()); QCOMPARE(touchEndPoint.normalizedPos(), rawTouchPoint.normalizedPos());
QCOMPARE(touchEndPoint.startNormalizedPos(), touchBeginPoint.normalizedPos()); QCOMPARE(touchEndPoint.startNormalizedPos(), touchBeginPoint.normalizedPos());
QCOMPARE(touchEndPoint.lastNormalizedPos(), touchUpdatePoint.normalizedPos()); QCOMPARE(touchEndPoint.lastNormalizedPos(), touchUpdatePoint.normalizedPos());
QCOMPARE(touchEndPoint.pos(), pos + delta + delta); QCOMPARE(touchEndPoint.position(), pos + delta + delta);
QCOMPARE(touchEndPoint.screenPos(), rawTouchPoint.screenPos()); QCOMPARE(touchEndPoint.globalPosition(), rawTouchPoint.globalPosition());
QCOMPARE(touchEndPoint.scenePos(), touchEndPoint.scenePos()); QCOMPARE(touchEndPoint.scenePosition(), touchEndPoint.scenePosition());
QCOMPARE(touchEndPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(touchEndPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(touchEndPoint.pressure(), qreal(0.)); QCOMPARE(touchEndPoint.pressure(), qreal(0.));
} }
@ -765,10 +765,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
// generate TouchBegins on both leftWidget and rightWidget // generate TouchBegins on both leftWidget and rightWidget
rawTouchPoints[0].setState(Qt::TouchPointPressed); rawTouchPoints[0].setState(Qt::TouchPointPressed);
rawTouchPoints[0].setScreenPos(leftScreenPos); rawTouchPoints[0].setScreenPos(leftScreenPos);
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].position(), screenGeometry));
rawTouchPoints[1].setState(Qt::TouchPointPressed); rawTouchPoints[1].setState(Qt::TouchPointPressed);
rawTouchPoints[1].setScreenPos(rightScreenPos); rawTouchPoints[1].setScreenPos(rightScreenPos);
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].position(), screenGeometry));
QWindow *window = touchWidget.windowHandle(); QWindow *window = touchWidget.windowHandle();
QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints = QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
@ -791,42 +791,42 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchBeginPoints.first(); QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchBeginPoints.first();
QCOMPARE(leftTouchPoint.id(), touchPointId0); QCOMPARE(leftTouchPoint.id(), touchPointId0);
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
QCOMPARE(leftTouchPoint.pos(), leftPos); QCOMPARE(leftTouchPoint.position(), leftPos);
QCOMPARE(leftTouchPoint.startPos(), leftPos); QCOMPARE(leftTouchPoint.pressPosition(), leftPos);
QCOMPARE(leftTouchPoint.lastPos(), leftPos); QCOMPARE(leftTouchPoint.lastPos(), leftPos);
QCOMPARE(leftTouchPoint.scenePos(), leftScreenPos); QCOMPARE(leftTouchPoint.scenePosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); QCOMPARE(leftTouchPoint.scenePressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos); QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos);
QCOMPARE(leftTouchPoint.screenPos(), leftScreenPos); QCOMPARE(leftTouchPoint.globalPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos); QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos);
QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.pos(), leftPos); QCOMPARE(leftTouchPoint.position(), leftPos);
QCOMPARE(leftTouchPoint.scenePos(), leftScreenPos); QCOMPARE(leftTouchPoint.scenePosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.screenPos(), leftScreenPos); QCOMPARE(leftTouchPoint.globalPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); QCOMPARE(leftTouchPoint.pressure(), qreal(1.));
QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchBeginPoints.first(); QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchBeginPoints.first();
QCOMPARE(rightTouchPoint.id(), touchPointId1); QCOMPARE(rightTouchPoint.id(), touchPointId1);
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
QCOMPARE(rightTouchPoint.pos(), rightPos); QCOMPARE(rightTouchPoint.position(), rightPos);
QCOMPARE(rightTouchPoint.startPos(), rightPos); QCOMPARE(rightTouchPoint.pressPosition(), rightPos);
QCOMPARE(rightTouchPoint.lastPos(), rightPos); QCOMPARE(rightTouchPoint.lastPos(), rightPos);
QCOMPARE(rightTouchPoint.scenePos(), rightScreenPos); QCOMPARE(rightTouchPoint.scenePosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); QCOMPARE(rightTouchPoint.scenePressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos); QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos);
QCOMPARE(rightTouchPoint.screenPos(), rightScreenPos); QCOMPARE(rightTouchPoint.globalPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos); QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos);
QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.pos(), rightPos); QCOMPARE(rightTouchPoint.position(), rightPos);
QCOMPARE(rightTouchPoint.scenePos(), rightScreenPos); QCOMPARE(rightTouchPoint.scenePosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.screenPos(), rightScreenPos); QCOMPARE(rightTouchPoint.globalPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); QCOMPARE(rightTouchPoint.pressure(), qreal(1.));
} }
@ -834,10 +834,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
// generate TouchUpdates on both leftWidget and rightWidget // generate TouchUpdates on both leftWidget and rightWidget
rawTouchPoints[0].setState(Qt::TouchPointMoved); rawTouchPoints[0].setState(Qt::TouchPointMoved);
rawTouchPoints[0].setScreenPos(centerScreenPos); rawTouchPoints[0].setScreenPos(centerScreenPos);
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].position(), screenGeometry));
rawTouchPoints[1].setState(Qt::TouchPointMoved); rawTouchPoints[1].setState(Qt::TouchPointMoved);
rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setScreenPos(centerScreenPos);
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].position(), screenGeometry));
nativeTouchPoints = nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
@ -857,42 +857,42 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchUpdatePoints.first(); QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchUpdatePoints.first();
QCOMPARE(leftTouchPoint.id(), touchPointId0); QCOMPARE(leftTouchPoint.id(), touchPointId0);
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); QCOMPARE(leftTouchPoint.position(), QPointF(leftWidget.mapFromParent(centerPos.toPoint())));
QCOMPARE(leftTouchPoint.startPos(), leftPos); QCOMPARE(leftTouchPoint.pressPosition(), leftPos);
QCOMPARE(leftTouchPoint.lastPos(), leftPos); QCOMPARE(leftTouchPoint.lastPos(), leftPos);
QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); QCOMPARE(leftTouchPoint.scenePressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos); QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos);
QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos); QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos);
QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.pos(), leftWidget.mapFromParent(centerPos.toPoint())); QCOMPARE(leftTouchPoint.position(), leftWidget.mapFromParent(centerPos.toPoint()));
QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); QCOMPARE(leftTouchPoint.pressure(), qreal(1.));
QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchUpdatePoints.first(); QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchUpdatePoints.first();
QCOMPARE(rightTouchPoint.id(), touchPointId1); QCOMPARE(rightTouchPoint.id(), touchPointId1);
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
QCOMPARE(rightTouchPoint.pos(), QPointF(rightWidget.mapFromParent(centerPos.toPoint()))); QCOMPARE(rightTouchPoint.position(), QPointF(rightWidget.mapFromParent(centerPos.toPoint())));
QCOMPARE(rightTouchPoint.startPos(), rightPos); QCOMPARE(rightTouchPoint.pressPosition(), rightPos);
QCOMPARE(rightTouchPoint.lastPos(), rightPos); QCOMPARE(rightTouchPoint.lastPos(), rightPos);
QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); QCOMPARE(rightTouchPoint.scenePressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos); QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos);
QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos); QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos);
QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.pos(), rightWidget.mapFromParent(centerPos.toPoint())); QCOMPARE(rightTouchPoint.position(), rightWidget.mapFromParent(centerPos.toPoint()));
QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); QCOMPARE(rightTouchPoint.pressure(), qreal(1.));
} }
@ -900,10 +900,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
// generate TouchEnds on both leftWidget and rightWidget // generate TouchEnds on both leftWidget and rightWidget
rawTouchPoints[0].setState(Qt::TouchPointReleased); rawTouchPoints[0].setState(Qt::TouchPointReleased);
rawTouchPoints[0].setScreenPos(centerScreenPos); rawTouchPoints[0].setScreenPos(centerScreenPos);
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].position(), screenGeometry));
rawTouchPoints[1].setState(Qt::TouchPointReleased); rawTouchPoints[1].setState(Qt::TouchPointReleased);
rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setScreenPos(centerScreenPos);
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].position(), screenGeometry));
nativeTouchPoints = nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
@ -923,42 +923,42 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchEndPoints.first(); QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchEndPoints.first();
QCOMPARE(leftTouchPoint.id(), touchPointId0); QCOMPARE(leftTouchPoint.id(), touchPointId0);
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); QCOMPARE(leftTouchPoint.position(), QPointF(leftWidget.mapFromParent(centerPos.toPoint())));
QCOMPARE(leftTouchPoint.startPos(), leftPos); QCOMPARE(leftTouchPoint.pressPosition(), leftPos);
QCOMPARE(leftTouchPoint.lastPos(), leftTouchPoint.pos()); QCOMPARE(leftTouchPoint.lastPos(), leftTouchPoint.position());
QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); QCOMPARE(leftTouchPoint.scenePressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.lastScenePos(), leftTouchPoint.scenePos()); QCOMPARE(leftTouchPoint.lastScenePos(), leftTouchPoint.scenePosition());
QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.lastScreenPos(), leftTouchPoint.screenPos()); QCOMPARE(leftTouchPoint.lastScreenPos(), leftTouchPoint.globalPosition());
QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.pos(), leftWidget.mapFromParent(centerPos.toPoint())); QCOMPARE(leftTouchPoint.position(), leftWidget.mapFromParent(centerPos.toPoint()));
QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(leftTouchPoint.pressure(), qreal(0.)); QCOMPARE(leftTouchPoint.pressure(), qreal(0.));
QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchEndPoints.first(); QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchEndPoints.first();
QCOMPARE(rightTouchPoint.id(), touchPointId1); QCOMPARE(rightTouchPoint.id(), touchPointId1);
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
QCOMPARE(rightTouchPoint.pos(), QPointF(rightWidget.mapFromParent(centerPos.toPoint()))); QCOMPARE(rightTouchPoint.position(), QPointF(rightWidget.mapFromParent(centerPos.toPoint())));
QCOMPARE(rightTouchPoint.startPos(), rightPos); QCOMPARE(rightTouchPoint.pressPosition(), rightPos);
QCOMPARE(rightTouchPoint.lastPos(), rightTouchPoint.pos()); QCOMPARE(rightTouchPoint.lastPos(), rightTouchPoint.position());
QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); QCOMPARE(rightTouchPoint.scenePressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.lastScenePos(), rightTouchPoint.scenePos()); QCOMPARE(rightTouchPoint.lastScenePos(), rightTouchPoint.scenePosition());
QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.lastScreenPos(), rightTouchPoint.screenPos()); QCOMPARE(rightTouchPoint.lastScreenPos(), rightTouchPoint.globalPosition());
QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.pos(), rightWidget.mapFromParent(centerPos.toPoint())); QCOMPARE(rightTouchPoint.position(), rightWidget.mapFromParent(centerPos.toPoint()));
QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(rightTouchPoint.pressure(), qreal(0.)); QCOMPARE(rightTouchPoint.pressure(), qreal(0.));
} }
@ -987,7 +987,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
// this should be translated to a TouchBegin // this should be translated to a TouchBegin
rawTouchPoints[0].setState(Qt::TouchPointPressed); rawTouchPoints[0].setState(Qt::TouchPointPressed);
rawTouchPoints[0].setScreenPos(screenPos); rawTouchPoints[0].setScreenPos(screenPos);
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].position(), screenGeometry));
rawTouchPoints[0].setRawScreenPositions({{12, 34}, {56, 78}}); rawTouchPoints[0].setRawScreenPositions({{12, 34}, {56, 78}});
ulong timestamp = 1234; ulong timestamp = 1234;
QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints = QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
@ -1004,13 +1004,13 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
const int secTouchPointId = (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 2; const int secTouchPointId = (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 2;
QCOMPARE(touchBeginPoint.id(), touchPointId); QCOMPARE(touchBeginPoint.id(), touchPointId);
QCOMPARE(touchBeginPoint.state(), rawTouchPoints[0].state()); QCOMPARE(touchBeginPoint.state(), rawTouchPoints[0].state());
QCOMPARE(touchBeginPoint.pos(), pos); QCOMPARE(touchBeginPoint.position(), pos);
// press a point on secondaryTouchScreenDevice // press a point on secondaryTouchScreenDevice
touchWidget.seenTouchBegin = false; touchWidget.seenTouchBegin = false;
rawTouchPoints[1].setState(Qt::TouchPointPressed); rawTouchPoints[1].setState(Qt::TouchPointPressed);
rawTouchPoints[1].setScreenPos(screenPos); rawTouchPoints[1].setScreenPos(screenPos);
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].position(), screenGeometry));
rawTouchPoints[1].setRawScreenPositions({{90, 100}, {110, 120}}); rawTouchPoints[1].setRawScreenPositions({{90, 100}, {110, 120}});
nativeTouchPoints = nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[1], window); QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[1], window);
@ -1022,13 +1022,13 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
touchBeginPoint = touchWidget.touchBeginPoints[0]; touchBeginPoint = touchWidget.touchBeginPoints[0];
QCOMPARE(touchBeginPoint.id(), (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 2); QCOMPARE(touchBeginPoint.id(), (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 2);
QCOMPARE(touchBeginPoint.state(), rawTouchPoints[1].state()); QCOMPARE(touchBeginPoint.state(), rawTouchPoints[1].state());
QCOMPARE(touchBeginPoint.pos(), pos); QCOMPARE(touchBeginPoint.position(), pos);
// press another point on secondaryTouchScreenDevice // press another point on secondaryTouchScreenDevice
touchWidget.seenTouchBegin = false; touchWidget.seenTouchBegin = false;
rawTouchPoints[2].setState(Qt::TouchPointPressed); rawTouchPoints[2].setState(Qt::TouchPointPressed);
rawTouchPoints[2].setScreenPos(screenPos); rawTouchPoints[2].setScreenPos(screenPos);
rawTouchPoints[2].setNormalizedPos(normalized(rawTouchPoints[2].pos(), screenGeometry)); rawTouchPoints[2].setNormalizedPos(normalized(rawTouchPoints[2].position(), screenGeometry));
rawTouchPoints[2].setRawScreenPositions({{130, 140}, {150, 160}}); rawTouchPoints[2].setRawScreenPositions({{130, 140}, {150, 160}});
nativeTouchPoints = nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[2], window); QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[2], window);
@ -1040,12 +1040,12 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
touchBeginPoint = touchWidget.touchBeginPoints[0]; touchBeginPoint = touchWidget.touchBeginPoints[0];
QCOMPARE(touchBeginPoint.id(), (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 3); QCOMPARE(touchBeginPoint.id(), (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 3);
QCOMPARE(touchBeginPoint.state(), rawTouchPoints[2].state()); QCOMPARE(touchBeginPoint.state(), rawTouchPoints[2].state());
QCOMPARE(touchBeginPoint.pos(), pos); QCOMPARE(touchBeginPoint.position(), pos);
// moving the first point should translate to TouchUpdate // moving the first point should translate to TouchUpdate
rawTouchPoints[0].setState(Qt::TouchPointMoved); rawTouchPoints[0].setState(Qt::TouchPointMoved);
rawTouchPoints[0].setScreenPos(screenPos + delta); rawTouchPoints[0].setScreenPos(screenPos + delta);
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].position(), screenGeometry));
nativeTouchPoints = nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[0], window); QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[0], window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints); QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
@ -1057,12 +1057,12 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QTouchEvent::TouchPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first(); QTouchEvent::TouchPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first();
QCOMPARE(touchUpdatePoint.id(), touchPointId); QCOMPARE(touchUpdatePoint.id(), touchPointId);
QCOMPARE(touchUpdatePoint.state(), rawTouchPoints[0].state()); QCOMPARE(touchUpdatePoint.state(), rawTouchPoints[0].state());
QCOMPARE(touchUpdatePoint.pos(), pos + delta); QCOMPARE(touchUpdatePoint.position(), pos + delta);
// releasing the first point translates to TouchEnd // releasing the first point translates to TouchEnd
rawTouchPoints[0].setState(Qt::TouchPointReleased); rawTouchPoints[0].setState(Qt::TouchPointReleased);
rawTouchPoints[0].setScreenPos(screenPos + delta + delta); rawTouchPoints[0].setScreenPos(screenPos + delta + delta);
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].position(), screenGeometry));
nativeTouchPoints = nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[0], window); QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[0], window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints); QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
@ -1074,7 +1074,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QTouchEvent::TouchPoint touchEndPoint = touchWidget.touchEndPoints.first(); QTouchEvent::TouchPoint touchEndPoint = touchWidget.touchEndPoints.first();
QCOMPARE(touchEndPoint.id(), touchPointId); QCOMPARE(touchEndPoint.id(), touchPointId);
QCOMPARE(touchEndPoint.state(), rawTouchPoints[0].state()); QCOMPARE(touchEndPoint.state(), rawTouchPoints[0].state());
QCOMPARE(touchEndPoint.pos(), pos + delta + delta); QCOMPARE(touchEndPoint.position(), pos + delta + delta);
// Widgets don't normally handle this case: if a TouchEnd was seen before, then // Widgets don't normally handle this case: if a TouchEnd was seen before, then
// WA_WState_AcceptedTouchBeginEvent will be false, and // WA_WState_AcceptedTouchBeginEvent will be false, and
@ -1149,10 +1149,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
// generate TouchBegin on leftWidget only // generate TouchBegin on leftWidget only
rawTouchPoints[0].setState(Qt::TouchPointPressed); rawTouchPoints[0].setState(Qt::TouchPointPressed);
rawTouchPoints[0].setScreenPos(leftScreenPos); rawTouchPoints[0].setScreenPos(leftScreenPos);
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].position(), screenGeometry));
rawTouchPoints[1].setState(Qt::TouchPointPressed); rawTouchPoints[1].setState(Qt::TouchPointPressed);
rawTouchPoints[1].setScreenPos(rightScreenPos); rawTouchPoints[1].setScreenPos(rightScreenPos);
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].position(), screenGeometry));
QWindow *window = touchWidget.windowHandle(); QWindow *window = touchWidget.windowHandle();
QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints = QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
@ -1174,42 +1174,42 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchBeginPoints.at(0); QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchBeginPoints.at(0);
QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id());
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
QCOMPARE(leftTouchPoint.pos(), leftPos); QCOMPARE(leftTouchPoint.position(), leftPos);
QCOMPARE(leftTouchPoint.startPos(), leftPos); QCOMPARE(leftTouchPoint.pressPosition(), leftPos);
QCOMPARE(leftTouchPoint.lastPos(), leftPos); QCOMPARE(leftTouchPoint.lastPos(), leftPos);
QCOMPARE(leftTouchPoint.scenePos(), leftScreenPos); QCOMPARE(leftTouchPoint.scenePosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); QCOMPARE(leftTouchPoint.scenePressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos); QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos);
QCOMPARE(leftTouchPoint.screenPos(), leftScreenPos); QCOMPARE(leftTouchPoint.globalPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos); QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos);
QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.pos(), leftPos); QCOMPARE(leftTouchPoint.position(), leftPos);
QCOMPARE(leftTouchPoint.scenePos(), leftScreenPos); QCOMPARE(leftTouchPoint.scenePosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.screenPos(), leftScreenPos); QCOMPARE(leftTouchPoint.globalPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); QCOMPARE(leftTouchPoint.pressure(), qreal(1.));
QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchBeginPoints.at(1); QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchBeginPoints.at(1);
QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id());
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
QCOMPARE(rightTouchPoint.pos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); QCOMPARE(rightTouchPoint.position(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint())));
QCOMPARE(rightTouchPoint.startPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); QCOMPARE(rightTouchPoint.pressPosition(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint())));
QCOMPARE(rightTouchPoint.lastPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); QCOMPARE(rightTouchPoint.lastPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint())));
QCOMPARE(rightTouchPoint.scenePos(), rightScreenPos); QCOMPARE(rightTouchPoint.scenePosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); QCOMPARE(rightTouchPoint.scenePressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos); QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos);
QCOMPARE(rightTouchPoint.screenPos(), rightScreenPos); QCOMPARE(rightTouchPoint.globalPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos); QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos);
QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.pos(), rightWidget.mapFromParent(rightScreenPos.toPoint())); QCOMPARE(rightTouchPoint.position(), rightWidget.mapFromParent(rightScreenPos.toPoint()));
QCOMPARE(rightTouchPoint.scenePos(), rightScreenPos); QCOMPARE(rightTouchPoint.scenePosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.screenPos(), rightScreenPos); QCOMPARE(rightTouchPoint.globalPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); QCOMPARE(rightTouchPoint.pressure(), qreal(1.));
} }
@ -1217,10 +1217,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
// generate TouchUpdate on leftWidget // generate TouchUpdate on leftWidget
rawTouchPoints[0].setState(Qt::TouchPointMoved); rawTouchPoints[0].setState(Qt::TouchPointMoved);
rawTouchPoints[0].setScreenPos(centerScreenPos); rawTouchPoints[0].setScreenPos(centerScreenPos);
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].position(), screenGeometry));
rawTouchPoints[1].setState(Qt::TouchPointMoved); rawTouchPoints[1].setState(Qt::TouchPointMoved);
rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setScreenPos(centerScreenPos);
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].position(), screenGeometry));
nativeTouchPoints = nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, 0, touchPadDevice, nativeTouchPoints); QWindowSystemInterface::handleTouchEvent(window, 0, touchPadDevice, nativeTouchPoints);
@ -1240,42 +1240,42 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchUpdatePoints.at(0); QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchUpdatePoints.at(0);
QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id());
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); QCOMPARE(leftTouchPoint.position(), QPointF(leftWidget.mapFromParent(centerPos.toPoint())));
QCOMPARE(leftTouchPoint.startPos(), leftPos); QCOMPARE(leftTouchPoint.pressPosition(), leftPos);
QCOMPARE(leftTouchPoint.lastPos(), leftPos); QCOMPARE(leftTouchPoint.lastPos(), leftPos);
QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); QCOMPARE(leftTouchPoint.scenePressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos); QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos);
QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos); QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos);
QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.pos(), leftWidget.mapFromParent(centerPos.toPoint())); QCOMPARE(leftTouchPoint.position(), leftWidget.mapFromParent(centerPos.toPoint()));
QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); QCOMPARE(leftTouchPoint.pressure(), qreal(1.));
QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchUpdatePoints.at(1); QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchUpdatePoints.at(1);
QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id());
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
QCOMPARE(rightTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); QCOMPARE(rightTouchPoint.position(), QPointF(leftWidget.mapFromParent(centerPos.toPoint())));
QCOMPARE(rightTouchPoint.startPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); QCOMPARE(rightTouchPoint.pressPosition(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint())));
QCOMPARE(rightTouchPoint.lastPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); QCOMPARE(rightTouchPoint.lastPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint())));
QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); QCOMPARE(rightTouchPoint.scenePressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos); QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos);
QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos); QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos);
QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.pos(), leftWidget.mapFromParent(centerPos.toPoint())); QCOMPARE(rightTouchPoint.position(), leftWidget.mapFromParent(centerPos.toPoint()));
QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); QCOMPARE(rightTouchPoint.pressure(), qreal(1.));
} }
@ -1283,10 +1283,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
// generate TouchEnd on leftWidget // generate TouchEnd on leftWidget
rawTouchPoints[0].setState(Qt::TouchPointReleased); rawTouchPoints[0].setState(Qt::TouchPointReleased);
rawTouchPoints[0].setScreenPos(centerScreenPos); rawTouchPoints[0].setScreenPos(centerScreenPos);
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].position(), screenGeometry));
rawTouchPoints[1].setState(Qt::TouchPointReleased); rawTouchPoints[1].setState(Qt::TouchPointReleased);
rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setScreenPos(centerScreenPos);
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].position(), screenGeometry));
nativeTouchPoints = nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, 0, touchPadDevice, nativeTouchPoints); QWindowSystemInterface::handleTouchEvent(window, 0, touchPadDevice, nativeTouchPoints);
@ -1306,42 +1306,42 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchEndPoints.at(0); QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchEndPoints.at(0);
QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id());
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); QCOMPARE(leftTouchPoint.position(), QPointF(leftWidget.mapFromParent(centerPos.toPoint())));
QCOMPARE(leftTouchPoint.startPos(), leftPos); QCOMPARE(leftTouchPoint.pressPosition(), leftPos);
QCOMPARE(leftTouchPoint.lastPos(), leftTouchPoint.pos()); QCOMPARE(leftTouchPoint.lastPos(), leftTouchPoint.position());
QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); QCOMPARE(leftTouchPoint.scenePressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.lastScenePos(), leftTouchPoint.scenePos()); QCOMPARE(leftTouchPoint.lastScenePos(), leftTouchPoint.scenePosition());
QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.lastScreenPos(), leftTouchPoint.screenPos()); QCOMPARE(leftTouchPoint.lastScreenPos(), leftTouchPoint.globalPosition());
QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos());
QCOMPARE(leftTouchPoint.pos(), leftWidget.mapFromParent(centerPos.toPoint())); QCOMPARE(leftTouchPoint.position(), leftWidget.mapFromParent(centerPos.toPoint()));
QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(leftTouchPoint.pressure(), qreal(0.)); QCOMPARE(leftTouchPoint.pressure(), qreal(0.));
QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchEndPoints.at(1); QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchEndPoints.at(1);
QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id());
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
QCOMPARE(rightTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); QCOMPARE(rightTouchPoint.position(), QPointF(leftWidget.mapFromParent(centerPos.toPoint())));
QCOMPARE(rightTouchPoint.startPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); QCOMPARE(rightTouchPoint.pressPosition(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint())));
QCOMPARE(rightTouchPoint.lastPos(), rightTouchPoint.pos()); QCOMPARE(rightTouchPoint.lastPos(), rightTouchPoint.position());
QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); QCOMPARE(rightTouchPoint.scenePressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.lastScenePos(), rightTouchPoint.scenePos()); QCOMPARE(rightTouchPoint.lastScenePos(), rightTouchPoint.scenePosition());
QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.lastScreenPos(), rightTouchPoint.screenPos()); QCOMPARE(rightTouchPoint.lastScreenPos(), rightTouchPoint.globalPosition());
QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos());
QCOMPARE(rightTouchPoint.pos(), leftWidget.mapFromParent(centerPos.toPoint())); QCOMPARE(rightTouchPoint.position(), leftWidget.mapFromParent(centerPos.toPoint()));
QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(rightTouchPoint.pressure(), qreal(0.)); QCOMPARE(rightTouchPoint.pressure(), qreal(0.));
} }
@ -1376,7 +1376,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
rawTouchPoint.setId(i); rawTouchPoint.setId(i);
rawTouchPoint.setState(Qt::TouchPointPressed); rawTouchPoint.setState(Qt::TouchPointPressed);
rawTouchPoint.setScreenPos(screenPos[i]); rawTouchPoint.setScreenPos(screenPos[i]);
rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.position(), screenGeometry));
rawTouchPoint.setRawScreenPositions(rawPosList); rawTouchPoint.setRawScreenPositions(rawPosList);
rawTouchPoints << rawTouchPoint; rawTouchPoints << rawTouchPoint;
} }
@ -1406,8 +1406,8 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
for (int i = 0; i < rawTouchPoints.count(); ++i) { for (int i = 0; i < rawTouchPoints.count(); ++i) {
QTouchEvent::TouchPoint &p = rawTouchPoints[i]; QTouchEvent::TouchPoint &p = rawTouchPoints[i];
p.setState(Qt::TouchPointMoved); p.setState(Qt::TouchPointMoved);
p.setScreenPos(p.screenPos() + delta); p.setScreenPos(p.globalPosition() + delta);
p.setNormalizedPos(normalized(p.pos(), screenGeometry)); p.setNormalizedPos(normalized(p.position(), screenGeometry));
} }
nativeTouchPoints = nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
@ -1550,8 +1550,8 @@ void tst_QTouchEvent::deleteInEventHandler()
QTouchEvent::TouchPoint touchPoint(0); QTouchEvent::TouchPoint touchPoint(0);
touchPoint.setState(Qt::TouchPointPressed); touchPoint.setState(Qt::TouchPointPressed);
touchPoint.setPos(view.mapFromScene(child1->mapToScene(child1->boundingRect().center()))); touchPoint.setPos(view.mapFromScene(child1->mapToScene(child1->boundingRect().center())));
touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); touchPoint.setScreenPos(view.mapToGlobal(touchPoint.position().toPoint()));
touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); touchPoint.setScenePos(view.mapToScene(touchPoint.position().toPoint()));
QList<QTouchEvent::TouchPoint> touchPoints; QList<QTouchEvent::TouchPoint> touchPoints;
touchPoints.append(touchPoint); touchPoints.append(touchPoint);
QTouchEvent touchBeginEvent(QEvent::TouchBegin, QTouchEvent touchBeginEvent(QEvent::TouchBegin,
@ -1652,13 +1652,13 @@ void tst_QTouchEvent::deleteInRawEventTranslation()
rawTouchPoints.append(QTouchEvent::TouchPoint(2)); rawTouchPoints.append(QTouchEvent::TouchPoint(2));
rawTouchPoints[0].setState(Qt::TouchPointPressed); rawTouchPoints[0].setState(Qt::TouchPointPressed);
rawTouchPoints[0].setScreenPos(leftScreenPos); rawTouchPoints[0].setScreenPos(leftScreenPos);
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].position(), screenGeometry));
rawTouchPoints[1].setState(Qt::TouchPointPressed); rawTouchPoints[1].setState(Qt::TouchPointPressed);
rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setScreenPos(centerScreenPos);
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].position(), screenGeometry));
rawTouchPoints[2].setState(Qt::TouchPointPressed); rawTouchPoints[2].setState(Qt::TouchPointPressed);
rawTouchPoints[2].setScreenPos(rightScreenPos); rawTouchPoints[2].setScreenPos(rightScreenPos);
rawTouchPoints[2].setNormalizedPos(normalized(rawTouchPoints[2].pos(), screenGeometry)); rawTouchPoints[2].setNormalizedPos(normalized(rawTouchPoints[2].position(), screenGeometry));
// generate begin events on all widgets, the left widget should die // generate begin events on all widgets, the left widget should die
QWindow *window = touchWidget.windowHandle(); QWindow *window = touchWidget.windowHandle();
@ -1895,14 +1895,14 @@ void tst_QTouchEvent::testMultiDevice()
QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1); QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1);
QCOMPARE(filter.d.value(deviceTwo).points.count(), 2); QCOMPARE(filter.d.value(deviceTwo).points.count(), 2);
QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).screenPos(), area0.center()); QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).globalPosition(), area0.center());
QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).ellipseDiameters(), area0.size()); QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).ellipseDiameters(), area0.size());
QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).state(), pointsOne[0].state); QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).state(), pointsOne[0].state);
QCOMPARE(filter.d.value(deviceTwo).points.at(0).screenPos(), area0.center()); QCOMPARE(filter.d.value(deviceTwo).points.at(0).globalPosition(), area0.center());
QCOMPARE(filter.d.value(deviceTwo).points.at(0).ellipseDiameters(), area0.size()); QCOMPARE(filter.d.value(deviceTwo).points.at(0).ellipseDiameters(), area0.size());
QCOMPARE(filter.d.value(deviceTwo).points.at(0).state(), pointsTwo[0].state); QCOMPARE(filter.d.value(deviceTwo).points.at(0).state(), pointsTwo[0].state);
QCOMPARE(filter.d.value(deviceTwo).points.at(1).screenPos(), area1.center()); QCOMPARE(filter.d.value(deviceTwo).points.at(1).globalPosition(), area1.center());
QCOMPARE(filter.d.value(deviceTwo).points.at(1).state(), pointsTwo[1].state); QCOMPARE(filter.d.value(deviceTwo).points.at(1).state(), pointsTwo[1].state);
} }

View File

@ -911,8 +911,8 @@ public:
++mousePressedCount; ++mousePressedCount;
mouseSequenceSignature += 'p'; mouseSequenceSignature += 'p';
mousePressButton = event->button(); mousePressButton = event->button();
mousePressScreenPos = event->screenPos(); mousePressScreenPos = event->globalPosition();
mousePressLocalPos = event->localPos(); mousePressLocalPos = event->position();
if (spinLoopWhenPressed) if (spinLoopWhenPressed)
QCoreApplication::processEvents(); QCoreApplication::processEvents();
} }
@ -935,7 +935,7 @@ public:
} else { } else {
++mouseMovedCount; ++mouseMovedCount;
mouseMoveButton = event->button(); mouseMoveButton = event->button();
mouseMoveScreenPos = event->screenPos(); mouseMoveScreenPos = event->globalPosition();
} }
} }
void mouseDoubleClickEvent(QMouseEvent *event) override void mouseDoubleClickEvent(QMouseEvent *event) override
@ -1697,8 +1697,8 @@ public:
void tabletEvent(QTabletEvent *ev) override void tabletEvent(QTabletEvent *ev) override
{ {
eventType = ev->type(); eventType = ev->type();
eventGlobal = ev->globalPosF(); eventGlobal = ev->globalPosition();
eventLocal = ev->posF(); eventLocal = ev->position();
eventDevice = ev->deviceType(); eventDevice = ev->deviceType();
} }

View File

@ -2099,7 +2099,7 @@ public:
switch(event->type()) { switch(event->type()) {
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
if (me->button() == mouseButton && gesture->state() == Qt::NoGesture) { if (me->button() == mouseButton && gesture->state() == Qt::NoGesture) {
gesture->setHotSpot(QPointF(me->globalPos())); gesture->setHotSpot(QPointF(me->globalPosition().toPoint()));
if (m_type == RmbAndCancelAllType) if (m_type == RmbAndCancelAllType)
gesture->setGestureCancelPolicy(QGesture::CancelAllInContext); gesture->setGestureCancelPolicy(QGesture::CancelAllInContext);
return QGestureRecognizer::TriggerGesture; return QGestureRecognizer::TriggerGesture;

View File

@ -10489,7 +10489,7 @@ protected:
case QEvent::MouseMove: case QEvent::MouseMove:
case QEvent::MouseButtonRelease: { case QEvent::MouseButtonRelease: {
QMouseEvent *me = static_cast<QMouseEvent *>(e); QMouseEvent *me = static_cast<QMouseEvent *>(e);
m_log->push_back(mouseEventLogEntry(objectName(), me->type(), me->pos(), me->buttons())); m_log->push_back(mouseEventLogEntry(objectName(), me->type(), me->position().toPoint(), me->buttons()));
me->accept(); me->accept();
return true; return true;
} }
@ -10613,7 +10613,7 @@ protected:
case QEvent::MouseMove: case QEvent::MouseMove:
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
++m_mouseEventCount; ++m_mouseEventCount;
m_lastMouseEventPos = static_cast<QMouseEvent *>(e)->localPos(); m_lastMouseEventPos = static_cast<QMouseEvent *>(e)->position();
if (m_acceptMouse) if (m_acceptMouse)
e->accept(); e->accept();
else else

View File

@ -533,7 +533,7 @@ private:
void DnDEventLoggerWidget::formatDropEvent(const char *function, const QDropEvent *e, QTextStream &str) const void DnDEventLoggerWidget::formatDropEvent(const char *function, const QDropEvent *e, QTextStream &str) const
{ {
str << objectName() << "::" << function << " at " << e->pos().x() << ',' << e->pos().y() str << objectName() << "::" << function << " at " << e->position().toPoint().x() << ',' << e->position().toPoint().y()
<< " action=" << e->dropAction() << " action=" << e->dropAction()
<< ' ' << quintptr(e->mimeData()) << " '" << e->mimeData()->text() << '\''; << ' ' << quintptr(e->mimeData()) << " '" << e->mimeData()->text() << '\'';
} }
@ -577,7 +577,7 @@ static QString msgEventAccepted(const QDropEvent &e)
{ {
QString message; QString message;
QTextStream str(&message); QTextStream str(&message);
str << "Event at " << e.pos().x() << ',' << e.pos().y() << ' ' << (e.isAccepted() ? "accepted" : "ignored"); str << "Event at " << e.position().toPoint().x() << ',' << e.position().toPoint().y() << ' ' << (e.isAccepted() ? "accepted" : "ignored");
return message; return message;
} }