From 9a69e1800d1532c45297b64c7d766463927c789a Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 9 May 2025 14:56:55 +0600 Subject: [PATCH 1/2] Honour `--nohook` on X11 as well --- src/qt/qt_mainwindow.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 3a0f1cb8a..aaf625c2d 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -322,7 +322,8 @@ MainWindow::MainWindow(QWidget *parent) mouse_capture = state ? 1 : 0; qt_mouse_capture(mouse_capture); if (mouse_capture) { - this->grabKeyboard(); + if (hook_enabled) + this->grabKeyboard(); if (ui->stackedWidget->mouse_capture_func) ui->stackedWidget->mouse_capture_func(this->windowHandle()); } else { @@ -1481,13 +1482,15 @@ MainWindow::eventFilter(QObject *receiver, QEvent *event) plat_pause(curdopause); #ifdef __unix__ if (!QApplication::platformName().contains("wayland") && (this->windowState() & Qt::WindowActive)) { - this->grabKeyboard(); + if (hook_enabled) + this->grabKeyboard(); } #endif } else if (event->type() == QEvent::WindowActivate) { #ifdef __unix__ if (!QApplication::platformName().contains("wayland")) { - this->grabKeyboard(); + if (hook_enabled) + this->grabKeyboard(); } #endif } else if (event->type() == QEvent::WindowDeactivate) { From b0c9ca6b20aee537a4cbf7fdaece49a4a942b1b8 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 9 May 2025 15:28:05 +0600 Subject: [PATCH 2/2] Fix stack use-after-return on Linux --- src/qt/qt_rendererstack.cpp | 2 +- src/qt/qt_rendererstack.hpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index 431b3609b..79fa78097 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -77,7 +77,7 @@ RendererStack::RendererStack(QWidget *parent, int monitor_index) m_monitor_index = monitor_index; #if defined __unix__ && !defined __HAIKU__ - char auto_mouse_type[16]; + memset(auto_mouse_type, 0, sizeof (auto_mouse_type)); mousedata.mouse_type = getenv("EMU86BOX_MOUSE"); if (!mousedata.mouse_type || (mousedata.mouse_type[0] == '\0') || !stricmp(mousedata.mouse_type, "auto")) { if (QApplication::platformName().contains("wayland")) diff --git a/src/qt/qt_rendererstack.hpp b/src/qt/qt_rendererstack.hpp index 172dc2fe6..3a76f3ada 100644 --- a/src/qt/qt_rendererstack.hpp +++ b/src/qt/qt_rendererstack.hpp @@ -137,6 +137,8 @@ private: std::atomic_bool rendererTakesScreenshots; std::atomic_bool switchInProgress{false}; + + char auto_mouse_type[16]; }; #endif // QT_RENDERERCONTAINER_HPP