Mouse event improvements
* Only center the cursor when it leaves the emulator screen * Ignore the very first mouse event that appears after it is captured for the first time after starting
This commit is contained in:
@@ -103,7 +103,7 @@ void RendererStack::wheelEvent(QWheelEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
int ignoreNextMouseEvent = 0;
|
||||
int ignoreNextMouseEvent = 1;
|
||||
void RendererStack::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (QApplication::platformName().contains("wayland"))
|
||||
@@ -120,12 +120,23 @@ void RendererStack::mouseMoveEvent(QMouseEvent *event)
|
||||
if (ignoreNextMouseEvent) { oldPos = event->pos(); ignoreNextMouseEvent--; event->accept(); return; }
|
||||
mousedata.deltax += event->pos().x() - oldPos.x();
|
||||
mousedata.deltay += event->pos().y() - oldPos.y();
|
||||
QCursor::setPos(mapToGlobal(QPoint(width() / 2, height() / 2)));
|
||||
oldPos = event->pos();
|
||||
ignoreNextMouseEvent = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void RendererStack::leaveEvent(QEvent* event)
|
||||
{
|
||||
if (QApplication::platformName().contains("wayland"))
|
||||
{
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
if (!mouse_capture) return;
|
||||
QCursor::setPos(mapToGlobal(QPoint(width() / 2, height() / 2)));
|
||||
ignoreNextMouseEvent = 2;
|
||||
event->accept();
|
||||
}
|
||||
|
||||
// called from blitter thread
|
||||
void RendererStack::blit(int x, int y, int w, int h)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user