Merge pull request #21 from Cacodemon345/patch-32
Fix mouse support on EGLFS
This commit is contained in:
@@ -70,12 +70,14 @@ void RendererStack::mousePoll()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ignoreNextMouseEvent = 1;
|
||||||
void RendererStack::mouseReleaseEvent(QMouseEvent *event)
|
void RendererStack::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (this->geometry().contains(event->pos()) && event->button() == Qt::LeftButton && !mouse_capture)
|
if (this->geometry().contains(event->pos()) && event->button() == Qt::LeftButton && !mouse_capture)
|
||||||
{
|
{
|
||||||
plat_mouse_capture(1);
|
plat_mouse_capture(1);
|
||||||
this->setCursor(Qt::BlankCursor);
|
this->setCursor(Qt::BlankCursor);
|
||||||
|
if (!ignoreNextMouseEvent) ignoreNextMouseEvent++; // Avoid jumping cursor when moved.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mouse_capture && event->button() == Qt::MiddleButton && mouse_get_buttons() < 3)
|
if (mouse_capture && event->button() == Qt::MiddleButton && mouse_get_buttons() < 3)
|
||||||
@@ -105,7 +107,6 @@ void RendererStack::wheelEvent(QWheelEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ignoreNextMouseEvent = 1;
|
|
||||||
void RendererStack::mouseMoveEvent(QMouseEvent *event)
|
void RendererStack::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (QApplication::platformName().contains("wayland"))
|
if (QApplication::platformName().contains("wayland"))
|
||||||
@@ -122,8 +123,13 @@ void RendererStack::mouseMoveEvent(QMouseEvent *event)
|
|||||||
if (ignoreNextMouseEvent) { oldPos = event->pos(); ignoreNextMouseEvent--; event->accept(); return; }
|
if (ignoreNextMouseEvent) { oldPos = event->pos(); ignoreNextMouseEvent--; event->accept(); return; }
|
||||||
mousedata.deltax += event->pos().x() - oldPos.x();
|
mousedata.deltax += event->pos().x() - oldPos.x();
|
||||||
mousedata.deltay += event->pos().y() - oldPos.y();
|
mousedata.deltay += event->pos().y() - oldPos.y();
|
||||||
if (event->globalPos().x() == 0 || event->globalPos().y() == 0) leaveEvent((QEvent*)event);
|
if (QApplication::platformName() == "eglfs")
|
||||||
if (event->globalPos().x() == (screen()->geometry().width() - 1) || event->globalPos().y() == (screen()->geometry().height() - 1)) leaveEvent((QEvent*)event);
|
{
|
||||||
|
leaveEvent((QEvent*)event);
|
||||||
|
ignoreNextMouseEvent--;
|
||||||
|
}
|
||||||
|
else if (event->globalPos().x() == 0 || event->globalPos().y() == 0) leaveEvent((QEvent*)event);
|
||||||
|
else if (event->globalPos().x() == (screen()->geometry().width() - 1) || event->globalPos().y() == (screen()->geometry().height() - 1)) leaveEvent((QEvent*)event);
|
||||||
oldPos = event->pos();
|
oldPos = event->pos();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user