From 4fd98deb676f6ec6d9e0a8abeba8ccfc7c1978ec Mon Sep 17 00:00:00 2001 From: rankun Date: Fri, 12 Jul 2019 11:27:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E9=BC=A0=E6=A0=87=E6=8B=96=E5=8A=A8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QtScrcpy/device/ui/videoform.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/QtScrcpy/device/ui/videoform.cpp b/QtScrcpy/device/ui/videoform.cpp index a4ab032..bfeba21 100644 --- a/QtScrcpy/device/ui/videoform.cpp +++ b/QtScrcpy/device/ui/videoform.cpp @@ -246,12 +246,29 @@ void VideoForm::mousePressEvent(QMouseEvent *event) void VideoForm::mouseReleaseEvent(QMouseEvent *event) { - if (ui->videoWidget->geometry().contains(event->pos())) { + if (m_dragPosition.isNull()) { if (!m_controller) { return; } event->setLocalPos(ui->videoWidget->mapFrom(this, event->localPos().toPoint())); + // local check + QPointF local = event->localPos(); + if (local.x() < 0) { + local.setX(0); + } + if (local.x() > ui->videoWidget->width()) { + local.setX(ui->videoWidget->width()); + } + if (local.y() < 0) { + local.setY(0); + } + if (local.y() > ui->videoWidget->height()) { + local.setY(ui->videoWidget->height()); + } + event->setLocalPos(local); m_controller->mouseEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size()); + } else { + m_dragPosition = QPoint(0, 0); } } @@ -263,7 +280,7 @@ void VideoForm::mouseMoveEvent(QMouseEvent *event) } event->setLocalPos(ui->videoWidget->mapFrom(this, event->localPos().toPoint())); m_controller->mouseEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size()); - } else { + } else if (!m_dragPosition.isNull()){ if (event->buttons() & Qt::LeftButton) { move(event->globalPos() - m_dragPosition); event->accept();