Qt: Fix hide mouse cursor in fullscreen

This commit is contained in:
Connor McLaughlin 2022-07-26 22:02:16 +10:00
parent 6386004b2c
commit 560df7e06d
3 changed files with 20 additions and 8 deletions

View file

@ -158,9 +158,15 @@ void DisplayWidget::updateCursor(bool master_enable)
m_cursor_hidden = hide; m_cursor_hidden = hide;
if (hide) if (hide)
{
setCursor(Qt::BlankCursor); setCursor(Qt::BlankCursor);
Log_WarningPrint("set blank cursor");
}
else else
{
unsetCursor(); unsetCursor();
Log_WarningPrint("clear blank cursor");
}
} }
void DisplayWidget::updateCenterPos() void DisplayWidget::updateCenterPos()

View file

@ -142,9 +142,9 @@ bool MainWindow::confirmMessage(const QString& title, const QString& message)
return (QMessageBox::question(this, title, message) == QMessageBox::Yes); 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) 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_relative_mouse_mode = relative_mode;
m_mouse_cursor_hidden = hide_cursor; m_mouse_cursor_hidden = hide_cursor;
if (m_display_widget && !s_system_paused) if (m_display_widget)
{ {
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); m_display_widget->updateRelativeMode(m_relative_mouse_mode);
m_display_widget->updateCursor(m_mouse_cursor_hidden);
} }
} }
@ -539,7 +545,7 @@ void MainWindow::onSystemResumed()
if (m_display_widget) if (m_display_widget)
{ {
m_display_widget->updateRelativeMode(m_relative_mouse_mode); 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(); m_display_widget->setFocus();
} }
} }
@ -1722,7 +1728,7 @@ bool MainWindow::isRenderingToMain() const
bool MainWindow::shouldHideMouseCursor() const bool MainWindow::shouldHideMouseCursor() const
{ {
return isRenderingFullscreen() && Host::GetBoolSettingValue("Main", "HideMouseCursor", false); return isRenderingFullscreen() && Host::GetBoolSettingValue("Main", "HideCursorInFullscreen", false);
} }
bool MainWindow::shouldHideMainWindow() const bool MainWindow::shouldHideMainWindow() const

View file

@ -200,7 +200,7 @@ private:
void createDisplayWidget(bool fullscreen, bool render_to_main, bool is_exclusive_fullscreen); void createDisplayWidget(bool fullscreen, bool render_to_main, bool is_exclusive_fullscreen);
void destroyDisplayWidget(bool show_game_list); void destroyDisplayWidget(bool show_game_list);
void setDisplayFullscreen(const std::string& fullscreen_mode); void setDisplayFullscreen(const std::string& fullscreen_mode);
bool shouldHideCursorInFullscreen() const; bool shouldHideCursor() const;
SettingsDialog* getSettingsDialog(); SettingsDialog* getSettingsDialog();
void doSettings(const char* category = nullptr); void doSettings(const char* category = nullptr);