Skip to content

Commit 2f211dd

Browse files
committed
Qt: Remove HasAnyBindingsForKey() call on double click
1 parent 818476f commit 2f211dd

File tree

7 files changed

+18
-7
lines changed

7 files changed

+18
-7
lines changed

src/duckstation-qt/displaywidget.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ void DisplayWidget::clearWindowInfo()
8585
m_window_info.reset();
8686
}
8787

88+
void DisplayWidget::setIgnoreDoubleClick(bool enabled)
89+
{
90+
m_ignore_double_click = enabled;
91+
}
92+
8893
void DisplayWidget::checkForSizeChange(bool update_refresh_rate)
8994
{
9095
if (!m_window_info.has_value())
@@ -368,8 +373,7 @@ bool DisplayWidget::event(QEvent* event)
368373

369374
// don't toggle fullscreen when we're bound.. that wouldn't end well.
370375
if (static_cast<const QMouseEvent*>(event)->button() == Qt::LeftButton && QtHost::IsSystemValid() &&
371-
((!QtHost::IsSystemPaused() && !m_relative_mouse_enabled &&
372-
!InputManager::HasAnyBindingsForKey(InputManager::MakePointerButtonKey(0, 0))) ||
376+
((!QtHost::IsSystemPaused() && !m_relative_mouse_enabled && !m_ignore_double_click) ||
373377
(QtHost::IsSystemPaused() && !ImGuiManager::WantsMouseInput())) &&
374378
Core::GetBoolSettingValue("Main", "DoubleClickTogglesFullscreen", true))
375379
{

src/duckstation-qt/displaywidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class DisplayWidget final : public QWidget
3636

3737
void updateRelativeMode(bool enabled);
3838
void updateCursor(bool hidden);
39+
void setIgnoreDoubleClick(bool enabled);
3940

4041
void checkForSizeChange(bool update_refresh_rate);
4142
void handleCloseEvent(QCloseEvent* event);
@@ -69,6 +70,7 @@ class DisplayWidget final : public QWidget
6970
#endif
7071
bool m_cursor_hidden = false;
7172
bool m_destroying = false;
73+
bool m_ignore_double_click = false;
7274
bool m_screen_change_registered = false;
7375

7476
RenderAPI m_render_api = RenderAPI::None;

src/duckstation-qt/mainwindow.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ void MainWindow::updateDisplayWidgetCursor()
493493

494494
m_display_widget->updateRelativeMode(s_locals.system_valid && !s_locals.system_paused && m_relative_mouse_mode);
495495
m_display_widget->updateCursor(s_locals.system_valid && !s_locals.system_paused && shouldHideMouseCursor());
496+
m_display_widget->setIgnoreDoubleClick(m_ignore_double_click);
496497
}
497498

498499
void MainWindow::updateDisplayRelatedActions()
@@ -567,10 +568,11 @@ QWidget* MainWindow::getDisplayContainer() const
567568
return (m_display_container ? static_cast<QWidget*>(m_display_container) : static_cast<QWidget*>(m_display_widget));
568569
}
569570

570-
void MainWindow::onMouseModeRequested(bool relative_mode, bool hide_cursor)
571+
void MainWindow::onMouseModeRequested(bool relative_mode, bool hide_cursor, bool ignore_double_click)
571572
{
572573
m_relative_mouse_mode = relative_mode;
573574
m_hide_mouse_cursor = hide_cursor;
575+
m_ignore_double_click = ignore_double_click;
574576
updateDisplayWidgetCursor();
575577
}
576578

src/duckstation-qt/mainwindow.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class MainWindow final : public QMainWindow
234234
Error* error);
235235
void displayResizeRequested(qint32 width, qint32 height);
236236
void releaseRenderWindow();
237-
void onMouseModeRequested(bool relative_mode, bool hide_cursor);
237+
void onMouseModeRequested(bool relative_mode, bool hide_cursor, bool ignore_double_click);
238238

239239
void onSettingsResetToDefault(bool system, bool controller);
240240
void onSystemStarting();
@@ -359,6 +359,7 @@ class MainWindow final : public QMainWindow
359359

360360
bool m_relative_mouse_mode = false;
361361
bool m_hide_mouse_cursor = false;
362+
bool m_ignore_double_click = false;
362363

363364
bool m_exclusive_fullscreen_requested = false;
364365
bool m_was_paused_on_game_list_switch = false;

src/duckstation-qt/qthost.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3214,7 +3214,9 @@ void Host::OnMediaCaptureStopped()
32143214

32153215
void Host::SetMouseMode(bool relative, bool hide_cursor)
32163216
{
3217-
emit g_core_thread->mouseModeRequested(relative, hide_cursor);
3217+
// Disable double-click handling when mouse is bound.
3218+
const bool ignore_double_click = InputManager::HasAnyBindingsForKey(InputManager::MakePointerButtonKey(0, 0));
3219+
emit g_core_thread->mouseModeRequested(relative, hide_cursor, ignore_double_click);
32183220
}
32193221

32203222
void Host::PumpMessagesOnCoreThread()

src/duckstation-qt/qthost.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class CoreThread : public QThread
119119
void onResizeRenderWindowRequested(qint32 width, qint32 height);
120120
void onReleaseRenderWindowRequested();
121121
void inputProfileLoaded();
122-
void mouseModeRequested(bool relative, bool hide_cursor);
122+
void mouseModeRequested(bool relative, bool hide_cursor, bool ignore_double_click);
123123
void fullscreenUIStartedOrStopped(bool running);
124124
void achievementsLoginRequested(Achievements::LoginRequestReason reason);
125125
void achievementsLoginSuccess(const QString& username, quint32 points, quint32 sc_points, quint32 unread_messages);

src/util/input_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ void InputManager::SynchronizePadEffectBindings(InputBindingKey key)
11231123

11241124
bool InputManager::HasAnyBindingsForKey(InputBindingKey key)
11251125
{
1126-
// DebugAssert(Host::IsOnCoreThread());
1126+
DebugAssert(Host::IsOnCoreThread());
11271127

11281128
std::unique_lock lock(s_state.mutex);
11291129
return (s_state.binding_map.find(key.MaskDirection()) != s_state.binding_map.end());

0 commit comments

Comments
 (0)