From 1021199512aff0f6769a0ecf45e1dd02f38ec00e Mon Sep 17 00:00:00 2001 From: Ty Lamontagne Date: Sat, 18 Oct 2025 12:22:44 -0400 Subject: [PATCH] Qt: Visually disable the mouse lock button on wayland --- pcsx2-qt/Settings/InterfaceSettingsWidget.cpp | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/pcsx2-qt/Settings/InterfaceSettingsWidget.cpp b/pcsx2-qt/Settings/InterfaceSettingsWidget.cpp index 3aa9ca6478..c5f1b5e065 100644 --- a/pcsx2-qt/Settings/InterfaceSettingsWidget.cpp +++ b/pcsx2-qt/Settings/InterfaceSettingsWidget.cpp @@ -88,13 +88,27 @@ InterfaceSettingsWidget::InterfaceSettingsWidget(SettingsWindow* settings_dialog SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.pauseOnControllerDisconnection, "UI", "PauseOnControllerDisconnection", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.discordPresence, "EmuCore", "EnableDiscordPresence", false); - SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.mouseLock, "EmuCore", "EnableMouseLock", false); - connect(m_ui.mouseLock, &QCheckBox::checkStateChanged, [](Qt::CheckState state) { - if (state == Qt::Checked) - Common::AttachMousePositionCb([](int x, int y) { g_main_window->checkMousePosition(x, y); }); - else - Common::DetachMousePositionCb(); - }); +#ifdef __linux__ // Mouse locking is only supported on X11 + const bool mouse_lock_supported = QGuiApplication::platformName().toLower() == "xcb"; +#else + const bool mouse_lock_supported = true; +#endif + + if(mouse_lock_supported) + { + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.mouseLock, "EmuCore", "EnableMouseLock", false); + connect(m_ui.mouseLock, &QCheckBox::checkStateChanged, [](Qt::CheckState state) { + if (state == Qt::Checked) + Common::AttachMousePositionCb([](int x, int y) { g_main_window->checkMousePosition(x, y); }); + else + Common::DetachMousePositionCb(); + }); + } + else + { + m_ui.mouseLock->setEnabled(false); + } + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.startFullscreen, "UI", "StartFullscreen", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.doubleClickTogglesFullscreen, "UI", "DoubleClickTogglesFullscreen", true); @@ -251,4 +265,4 @@ void InterfaceSettingsWidget::onClearGameListBackgroundTriggered() Host::RemoveBaseSettingValue("UI", "GameListBackgroundPath"); Host::CommitBaseSettingChanges(); emit backgroundChanged(); -} \ No newline at end of file +}