From ffde0ea25427ba822a6e86312999275221e9c8dd Mon Sep 17 00:00:00 2001 From: ts-korhonen Date: Fri, 17 Dec 2021 18:37:57 +0200 Subject: [PATCH] qt: fix mouse grab on opengl renderer (for windows) --- src/qt/qt_hardwarerenderer.cpp | 17 +++++++++++++++++ src/qt/qt_hardwarerenderer.hpp | 1 + 2 files changed, 18 insertions(+) diff --git a/src/qt/qt_hardwarerenderer.cpp b/src/qt/qt_hardwarerenderer.cpp index 30d4a42a8..5e34c1079 100644 --- a/src/qt/qt_hardwarerenderer.cpp +++ b/src/qt/qt_hardwarerenderer.cpp @@ -4,6 +4,7 @@ extern "C" { #include <86box/86box.h> +#include <86box/plat.h> } void HardwareRenderer::resizeGL(int w, int h) @@ -45,3 +46,19 @@ void HardwareRenderer::resizeEvent(QResizeEvent *event) { onResize(width(), height()); QOpenGLWindow::resizeEvent(event); } + +void HardwareRenderer::mouseReleaseEvent(QMouseEvent *event) +{ + if (this->geometry().contains(event->pos()) && event->button() == Qt::LeftButton && !mouse_capture) + { + plat_mouse_capture(1); + this->setCursor(Qt::BlankCursor); + return; + } + if (mouse_capture && event->button() == Qt::MiddleButton) + { + plat_mouse_capture(0); + this->setCursor(Qt::ArrowCursor); + return; + } +} \ No newline at end of file diff --git a/src/qt/qt_hardwarerenderer.hpp b/src/qt/qt_hardwarerenderer.hpp index 8b75d19b8..e5f1c1845 100644 --- a/src/qt/qt_hardwarerenderer.hpp +++ b/src/qt/qt_hardwarerenderer.hpp @@ -49,4 +49,5 @@ public slots: protected: void resizeEvent(QResizeEvent *event) override; + void mouseReleaseEvent(QMouseEvent* event) override; };