Fix unsolicited mouse captures after a double-click in an file selection dialog

This commit is contained in:
Alexander Babikov 2022-02-05 01:01:06 +05:00
parent 129ffab728
commit 45520768ba
2 changed files with 6 additions and 1 deletions

View file

@ -89,26 +89,30 @@ void RendererStack::mousePoll()
int ignoreNextMouseEvent = 1;
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 && (isMouseDown & 1))
{
plat_mouse_capture(1);
this->setCursor(Qt::BlankCursor);
if (!ignoreNextMouseEvent) ignoreNextMouseEvent++; // Avoid jumping cursor when moved.
isMouseDown &= ~1;
return;
}
if (mouse_capture && event->button() == Qt::MiddleButton && mouse_get_buttons() < 3)
{
plat_mouse_capture(0);
this->setCursor(Qt::ArrowCursor);
isMouseDown &= ~1;
return;
}
if (mouse_capture)
{
mousedata.mousebuttons &= ~event->button();
}
isMouseDown &= ~1;
}
void RendererStack::mousePressEvent(QMouseEvent *event)
{
isMouseDown |= 1;
if (mouse_capture)
{
mousedata.mousebuttons |= event->button();

View file

@ -64,6 +64,7 @@ private:
int x, y, w, h, sx, sy, sw, sh;
int currentBuf = 0;
int isMouseDown = 0;
std::vector<std::tuple<uint8_t*, std::atomic_flag*>> imagebufs;
std::unique_ptr<QWidget> current;