From 0313d020736a6f5772a2b7b64635d78162af7b17 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sat, 18 Dec 2021 00:37:30 +0600 Subject: [PATCH 1/2] Delegate input events of HardwareRenderer to RendererStack --- src/qt/qt_hardwarerenderer.cpp | 27 +++++++++++++++------------ src/qt/qt_hardwarerenderer.hpp | 8 +++++--- src/qt/qt_rendererstack.cpp | 5 +++-- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/qt/qt_hardwarerenderer.cpp b/src/qt/qt_hardwarerenderer.cpp index 5e34c1079..077021a24 100644 --- a/src/qt/qt_hardwarerenderer.cpp +++ b/src/qt/qt_hardwarerenderer.cpp @@ -47,18 +47,21 @@ void HardwareRenderer::resizeEvent(QResizeEvent *event) { QOpenGLWindow::resizeEvent(event); } -void HardwareRenderer::mouseReleaseEvent(QMouseEvent *event) +bool HardwareRenderer::event(QEvent *event) { - if (this->geometry().contains(event->pos()) && event->button() == Qt::LeftButton && !mouse_capture) + switch (event->type()) { - plat_mouse_capture(1); - this->setCursor(Qt::BlankCursor); - return; + default: + return QOpenGLWindow::event(event); + case QEvent::MouseButtonPress: + case QEvent::MouseMove: + case QEvent::MouseButtonRelease: + case QEvent::KeyPress: + case QEvent::KeyRelease: + case QEvent::Wheel: + case QEvent::Enter: + case QEvent::Leave: + return QApplication::sendEvent(parentWidget, event); } - if (mouse_capture && event->button() == Qt::MiddleButton) - { - plat_mouse_capture(0); - this->setCursor(Qt::ArrowCursor); - return; - } -} \ No newline at end of file + return false; +} diff --git a/src/qt/qt_hardwarerenderer.hpp b/src/qt/qt_hardwarerenderer.hpp index e5f1c1845..0068eb7dc 100644 --- a/src/qt/qt_hardwarerenderer.hpp +++ b/src/qt/qt_hardwarerenderer.hpp @@ -23,15 +23,17 @@ class HardwareRenderer : public QOpenGLWindow, protected QOpenGLFunctions, publi private: bool wayland = false; + QWidget* parentWidget{nullptr}; public: void resizeGL(int w, int h) override; void initializeGL() override; void paintGL() override; - HardwareRenderer(QWindow* parent = nullptr) - : QOpenGLWindow(QOpenGLWindow::NoPartialUpdate, parent), QOpenGLFunctions() + HardwareRenderer(QWidget* parent = nullptr) + : QOpenGLWindow(QOpenGLWindow::NoPartialUpdate, parent->windowHandle()), QOpenGLFunctions() { setMinimumSize(QSize(16, 16)); setFlags(Qt::FramelessWindowHint); + parentWidget = parent; } ~HardwareRenderer() { @@ -49,5 +51,5 @@ public slots: protected: void resizeEvent(QResizeEvent *event) override; - void mouseReleaseEvent(QMouseEvent* event) override; + bool event(QEvent* event) override; }; diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index e3ab5fc8e..72d79fae6 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -184,7 +184,7 @@ void RendererStack::switchRenderer(Renderer renderer) { case Renderer::OpenGL: { this->createWinId(); - auto hw = new HardwareRenderer(this->windowHandle()); + auto hw = new HardwareRenderer(this); connect(this, &RendererStack::blitToRenderer, hw, &HardwareRenderer::onBlit, Qt::QueuedConnection); hw->setRenderType(HardwareRenderer::RenderType::OpenGL); current.reset(this->createWindowContainer(hw, this)); @@ -193,7 +193,7 @@ void RendererStack::switchRenderer(Renderer renderer) { case Renderer::OpenGLES: { this->createWinId(); - auto hw = new HardwareRenderer(this->windowHandle()); + auto hw = new HardwareRenderer(this); connect(this, &RendererStack::blitToRenderer, hw, &HardwareRenderer::onBlit, Qt::QueuedConnection); hw->setRenderType(HardwareRenderer::RenderType::OpenGLES); current.reset(this->createWindowContainer(hw, this)); @@ -201,6 +201,7 @@ void RendererStack::switchRenderer(Renderer renderer) { } } current->setFocusPolicy(Qt::NoFocus); + current->setFocusProxy(this); addWidget(current.get()); for (auto& in_use : buffers_in_use) From 227e177b11457b66a0d0f81f93cfdbb0609cb720 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sat, 18 Dec 2021 01:03:05 +0600 Subject: [PATCH 2/2] Implement action exclusivity in menus --- src/qt/qt_mainwindow.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 64a589e63..839744eb3 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -26,6 +26,7 @@ extern "C" { #include #include #include +#include #include #include @@ -134,6 +135,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->actionHiDPI_scaling->setChecked(dpi_scale); ui->actionHide_status_bar->setChecked(hide_status_bar); ui->actionUpdate_status_bar_icons->setChecked(update_icons); + QActionGroup* actGroup = nullptr; switch (vid_api) { case 0: ui->stackedWidget->switchRenderer(RendererStack::Renderer::Software); @@ -148,6 +150,10 @@ MainWindow::MainWindow(QWidget *parent) : ui->actionHardware_Renderer_OpenGL_ES->setChecked(true); break; } + actGroup = new QActionGroup(this); + actGroup->addAction(ui->actionSoftware_Renderer); + actGroup->addAction(ui->actionHardware_Renderer_OpenGL); + actGroup->addAction(ui->actionHardware_Renderer_OpenGL_ES); switch (scale) { case 0: ui->action0_5x->setChecked(true); @@ -162,6 +168,11 @@ MainWindow::MainWindow(QWidget *parent) : ui->action2x->setChecked(true); break; } + actGroup = new QActionGroup(this); + actGroup->addAction(ui->action0_5x); + actGroup->addAction(ui->action1x); + actGroup->addAction(ui->action1_5x); + actGroup->addAction(ui->action2x); switch (video_filter_method) { case 0: ui->actionNearest->setChecked(true); @@ -170,6 +181,9 @@ MainWindow::MainWindow(QWidget *parent) : ui->actionLinear->setChecked(true); break; } + actGroup = new QActionGroup(this); + actGroup->addAction(ui->actionNearest); + actGroup->addAction(ui->actionLinear); switch (video_fullscreen_scale) { case FULLSCR_SCALE_FULL: ui->actionFullScreen_stretch->setChecked(true); @@ -184,6 +198,11 @@ MainWindow::MainWindow(QWidget *parent) : ui->actionFullScreen_int->setChecked(true); break; } + actGroup = new QActionGroup(this); + actGroup->addAction(ui->actionFullScreen_stretch); + actGroup->addAction(ui->actionFullScreen_43); + actGroup->addAction(ui->actionFullScreen_keepRatio); + actGroup->addAction(ui->actionFullScreen_int); switch (video_grayscale) { case 0: ui->actionRGB_Color->setChecked(true); @@ -201,6 +220,12 @@ MainWindow::MainWindow(QWidget *parent) : ui->actionWhite_monitor->setChecked(true); break; } + actGroup = new QActionGroup(this); + actGroup->addAction(ui->actionRGB_Grayscale); + actGroup->addAction(ui->actionAmber_monitor); + actGroup->addAction(ui->actionGreen_monitor); + actGroup->addAction(ui->actionWhite_monitor); + actGroup->addAction(ui->actionRGB_Color); switch (video_graytype) { case 0: ui->actionBT601_NTSC_PAL->setChecked(true); @@ -212,6 +237,10 @@ MainWindow::MainWindow(QWidget *parent) : ui->actionAverage->setChecked(true); break; } + actGroup = new QActionGroup(this); + actGroup->addAction(ui->actionBT601_NTSC_PAL); + actGroup->addAction(ui->actionBT709_HDTV); + actGroup->addAction(ui->actionAverage); if (force_43 > 0) { ui->actionForce_4_3_display_ratio->setChecked(true); } @@ -1281,4 +1310,4 @@ void MainWindow::on_actionSound_gain_triggered() void MainWindow::setSendKeyboardInput(bool enabled) { send_keyboard_input = enabled; -} \ No newline at end of file +}