From 560df7e06d02ece55a7479d7d381754e4681016a Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 26 Jul 2022 22:02:16 +1000 Subject: [PATCH] Qt: Fix hide mouse cursor in fullscreen --- src/duckstation-qt/displaywidget.cpp | 6 ++++++ src/duckstation-qt/mainwindow.cpp | 20 +++++++++++++------- src/duckstation-qt/mainwindow.h | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/duckstation-qt/displaywidget.cpp b/src/duckstation-qt/displaywidget.cpp index 4d7cc742d..9cafa8abb 100644 --- a/src/duckstation-qt/displaywidget.cpp +++ b/src/duckstation-qt/displaywidget.cpp @@ -158,9 +158,15 @@ void DisplayWidget::updateCursor(bool master_enable) m_cursor_hidden = hide; if (hide) + { setCursor(Qt::BlankCursor); + Log_WarningPrint("set blank cursor"); + } else + { unsetCursor(); + Log_WarningPrint("clear blank cursor"); + } } void DisplayWidget::updateCenterPos() diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 17ba96aeb..1b79e9f41 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -142,9 +142,9 @@ bool MainWindow::confirmMessage(const QString& title, const QString& message) return (QMessageBox::question(this, title, message) == QMessageBox::Yes); } -bool MainWindow::shouldHideCursorInFullscreen() const +bool MainWindow::shouldHideCursor() const { - return Host::GetBoolSettingValue("Main", "HideCursorInFullscreen", true); + return m_mouse_cursor_hidden || (isRenderingFullscreen() && Host::GetBoolSettingValue("Main", "HideCursorInFullscreen", true)); } bool MainWindow::createDisplay(bool fullscreen, bool render_to_main) @@ -482,10 +482,16 @@ void MainWindow::onMouseModeRequested(bool relative_mode, bool hide_cursor) m_relative_mouse_mode = relative_mode; m_mouse_cursor_hidden = hide_cursor; - if (m_display_widget && !s_system_paused) + if (m_display_widget) { - m_display_widget->updateRelativeMode(m_relative_mouse_mode); - m_display_widget->updateCursor(m_mouse_cursor_hidden); + m_display_widget->setShouldHideCursor(shouldHideCursor()); + + const bool update = s_system_valid && !s_system_paused; + + m_display_widget->updateCursor(update); + + if (update) + m_display_widget->updateRelativeMode(m_relative_mouse_mode); } } @@ -539,7 +545,7 @@ void MainWindow::onSystemResumed() if (m_display_widget) { m_display_widget->updateRelativeMode(m_relative_mouse_mode); - m_display_widget->updateCursor(m_mouse_cursor_hidden); + m_display_widget->updateCursor(true); m_display_widget->setFocus(); } } @@ -1722,7 +1728,7 @@ bool MainWindow::isRenderingToMain() const bool MainWindow::shouldHideMouseCursor() const { - return isRenderingFullscreen() && Host::GetBoolSettingValue("Main", "HideMouseCursor", false); + return isRenderingFullscreen() && Host::GetBoolSettingValue("Main", "HideCursorInFullscreen", false); } bool MainWindow::shouldHideMainWindow() const diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index 1260dc2dd..d28d4e04f 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -200,7 +200,7 @@ private: void createDisplayWidget(bool fullscreen, bool render_to_main, bool is_exclusive_fullscreen); void destroyDisplayWidget(bool show_game_list); void setDisplayFullscreen(const std::string& fullscreen_mode); - bool shouldHideCursorInFullscreen() const; + bool shouldHideCursor() const; SettingsDialog* getSettingsDialog(); void doSettings(const char* category = nullptr);