From 261335d6c3cbd53ad60d8373bf584757063e73bb Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Mon, 15 Jun 2026 20:03:46 -0400 Subject: [PATCH] refactor(Settings): move switchDoubleTap to general settings --- docs/user/configuration.md | 7 ++++--- src/lib/common/Settings.cpp | 2 +- src/lib/common/Settings.h | 3 +++ src/lib/gui/config/ServerConfig.cpp | 8 -------- src/lib/gui/config/ServerConfig.h | 9 --------- src/lib/gui/dialogs/ServerConfigDialog.cpp | 13 +++++++++---- src/lib/gui/dialogs/ServerConfigDialog.h | 1 + src/lib/server/Config.cpp | 10 ++++++---- 8 files changed, 24 insertions(+), 29 deletions(-) diff --git a/docs/user/configuration.md b/docs/user/configuration.md index e022652d0..aab178c6c 100644 --- a/docs/user/configuration.md +++ b/docs/user/configuration.md @@ -149,11 +149,14 @@ This section contains options used when in server mode it will begin with `[serv | externalConfigFile | Filepath | Path the server config file if it does not exist the GUI will it generated based on the `internalConfig` section.| | gridHeight | int | Height of the server's intenal grid used for the computer layout (default: 3)| | gridWidth | int | Width of the server's intenal grid used for the computer layout (default: 5) | -| heartbeat | int | The server will expect each client to send a message no less than every `N` milliseconds. If no message arrives from a client within `3N` seconds the server forces that client to disconnect. If deskflow fails to detect clients disconnecting while the server is sleeping or vice versa, try using this option. | +| heartbeat | int | The server will expect each client to send a message no less than every `N` milliseconds. If no message arrives from a client within `3N` seconds the server forces that client to disconnect. If deskflow fails to detect clients disconnecting while the server is sleeping or vice versa, try using this option.| | protocol | `barrier` or `synergy` | The protocol to use when saying hello to clients. Can be set to barrier or synergy. If not set barrier is used as the default | | switchDelay | int | Deskflow won't switch computers when the mouse reaches edge of a computer unless it stays on the edge for `N` milliseconds. This helps prevent unintentional switching when working near an edge. (default: 250)| +| switchDoubleTap | int | Deskflow won't switch computers when the mouse reaches the edge of a computer unless it's moved away from the edge and then back to the edge within `N` milliseconds. With the option you have to quickly tap the edge twice to switch. This helps prevent unintentional switching when working near the edge.| | xdpRestoreToken | UUID | Restore token provided by XDG portals | + - You can use both the ''switchDelay'' and ''switchDoubleTap'' options at the same time. Deskflow will switch when either requirement is satisfied. + ### InternalConfig This section contains options used when in server mode it will begin with `[internalConfig]` @@ -278,7 +281,6 @@ switchCornerArray\3\switchCorner=false switchCornerArray\4\switchCorner=false switchCornerArray\size=4 switchCornerSize=0 -switchDoubleTap=250 win32KeepForeground=false ``` @@ -400,7 +402,6 @@ end |:--------|:-----------:|:-----------| |switchCorners | none top-left top-right bottom-left bottom-right left right top bottom all | Deskflow won't switch computers when the mouse reaches the edge of the computer if it's in a listed corner. The size of all corners is given by the `switchCornerSize` option. The first name in the list is one of the above names and defines the initial set of corners. Subsequent names are prefixed with + or - to add the corner to or remove the corner from the set, respectively. For example: `all -left +top-left` starts will all corners, removes the left corners (top and bottom) then adds the top-left back in, resulting in the top-left, bottom-left and bottom-right corners.| |switchCornerSize | integer (N) | Sets the size of all corners in pixels. The cursor must be within `N` pixels of the corner to be considered to be in the corner.| -|switchDoubleTap| integer(N) | Deskflow won't switch computers when the mouse reaches the edge of a computer unless it's moved away from the edge and then back to the edge within `N` milliseconds. With the option you have to quickly tap the edge twice to switch. This helps prevent unintentional switching when working near the edge.| |screenSaverSync| `true` or `false`| ''Note: Removed in v1.14.1'' If set to ''false'' then Deskflow won't synchronize screen savers. Client screen savers will start according to their individual configurations. The server screen saver won't start if there is input, even if that input is directed toward a client computer.| |relativeMouseMoves| `true` or `false`| If set to ''true'' then secondary computers move the mouse using relative rather than absolute mouse moves when and only when the cursor is locked to the computer (by ''Scroll Lock'' or a configured hot key). This is intended to make Deskflow work better with certain games. If set to ''false'' or not set then all mouse moves are absolute.| |clipboardSharing| `true` or `false`|If set to ''true'' then clipboard sharing will be enabled and the ''clipboardSharingSize'' setting will be used. If set to false, then clipboard sharing will be disabled and the the ''clipboardSharingSize'' setting will be ignored.| diff --git a/src/lib/common/Settings.cpp b/src/lib/common/Settings.cpp index 06d587f67..7296fdb1a 100644 --- a/src/lib/common/Settings.cpp +++ b/src/lib/common/Settings.cpp @@ -219,7 +219,7 @@ QVariant Settings::defaultValue(const QString &key) if (key == Server::Heartbeat) return 5000; - if (key == Server::SwitchDelay) + if (key == Server::SwitchDelay || key == Server::SwitchDoubleTap) return 250; return QVariant(); diff --git a/src/lib/common/Settings.h b/src/lib/common/Settings.h index 8e3a8e84c..592a76d19 100644 --- a/src/lib/common/Settings.h +++ b/src/lib/common/Settings.h @@ -114,6 +114,7 @@ public: inline static const auto Heartbeat = QStringLiteral("server/heartbeat"); inline static const auto Protocol = QStringLiteral("server/protocol"); inline static const auto SwitchDelay = QStringLiteral("server/switchDelay"); + inline static const auto SwitchDoubleTap = QStringLiteral("server/switchDoubleTap"); inline static const auto XdpRestoreToken = QStringLiteral("server/xdpRestoreToken"); }; @@ -258,6 +259,7 @@ private: , Settings::Server::Heartbeat , Settings::Server::Protocol , Settings::Server::SwitchDelay + , Settings::Server::SwitchDoubleTap , Settings::Server::XdpRestoreToken }; @@ -314,6 +316,7 @@ private: , QStringLiteral("internalConfig/numColumns") , QStringLiteral("internalConfig/numRows") , QStringLiteral("internalConfig/switchDelay") + , QStringLiteral("internalConfig/switchDoubleTap") }; // clang-format on }; diff --git a/src/lib/gui/config/ServerConfig.cpp b/src/lib/gui/config/ServerConfig.cpp index 3fc193a9c..f19e4d9de 100644 --- a/src/lib/gui/config/ServerConfig.cpp +++ b/src/lib/gui/config/ServerConfig.cpp @@ -55,7 +55,6 @@ bool ServerConfig::operator==(const ServerConfig &sc) const return m_Screens == sc.m_Screens && // m_RelativeMouseMoves == sc.m_RelativeMouseMoves && // m_Win32KeepForeground == sc.m_Win32KeepForeground && // - m_SwitchDoubleTap == sc.m_SwitchDoubleTap && // m_SwitchCornerSize == sc.m_SwitchCornerSize && // m_SwitchCorners == sc.m_SwitchCorners && // m_Hotkeys == sc.m_Hotkeys && // @@ -96,7 +95,6 @@ void ServerConfig::commit() settings().setValue("relativeMouseMoves", relativeMouseMoves()); settings().setValue("win32KeepForeground", win32KeepForeground()); - settings().setValue("switchDoubleTap", switchDoubleTap()); settings().setValue("switchCornerSize", switchCornerSize()); settings().setValue("defaultLockToScreenState", defaultLockToScreenState()); settings().setValue("disableLockToScreen", disableLockToScreen()); @@ -142,7 +140,6 @@ void ServerConfig::recall() setRelativeMouseMoves(settings().value("relativeMouseMoves", false).toBool()); setWin32KeepForeground(settings().value("win32KeepForeground", false).toBool()); - setSwitchDoubleTap(settings().value("switchDoubleTap", 250).toInt()); setSwitchCornerSize(settings().value("switchCornerSize").toInt()); setDefaultLockToScreenState(settings().value("defaultLockToScreenState", false).toBool()); setDisableLockToScreen(settings().value("disableLockToScreen", false).toBool()); @@ -244,11 +241,6 @@ QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config) << "clipboardSharing = " << (config.clipboardSharing() ? "true" : "false") << Qt::endl; outStream << "\t" << "clipboardSharingSize = " << config.clipboardSharingSize() << Qt::endl; - - if (Settings::value(Settings::Server::EnableSwitchDoubleTap).toBool()) - outStream << "\t" - << "switchDoubleTap = " << config.switchDoubleTap() << Qt::endl; - outStream << "\t" << "switchCorners = none "; for (int i = 0; i < config.switchCorners().size(); i++) diff --git a/src/lib/gui/config/ServerConfig.h b/src/lib/gui/config/ServerConfig.h index c7a3d17b6..2e3d1ba5a 100644 --- a/src/lib/gui/config/ServerConfig.h +++ b/src/lib/gui/config/ServerConfig.h @@ -48,10 +48,6 @@ public: { return m_Win32KeepForeground; } - int switchDoubleTap() const - { - return m_SwitchDoubleTap; - } bool switchCorner(int c) const { return m_SwitchCorners[c]; @@ -122,10 +118,6 @@ private: { m_Win32KeepForeground = on; } - void setSwitchDoubleTap(int val) - { - m_SwitchDoubleTap = val; - } void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; @@ -164,7 +156,6 @@ private: private: bool m_RelativeMouseMoves = false; bool m_Win32KeepForeground = false; - int m_SwitchDoubleTap = 0; int m_SwitchCornerSize = 0; bool m_DefaultLockToScreenState = false; bool m_DisableLockToScreen = false; diff --git a/src/lib/gui/dialogs/ServerConfigDialog.cpp b/src/lib/gui/dialogs/ServerConfigDialog.cpp index a3bd39265..66490d630 100644 --- a/src/lib/gui/dialogs/ServerConfigDialog.cpp +++ b/src/lib/gui/dialogs/ServerConfigDialog.cpp @@ -81,6 +81,7 @@ void ServerConfigDialog::accept() Settings::setValue(Settings::Server::EnableSwitchDelay, m_enableSwitchDelay); Settings::setValue(Settings::Server::SwitchDelay, m_switchDelay); Settings::setValue(Settings::Server::EnableSwitchDoubleTap, m_enableSwitchDoubleTap); + Settings::setValue(Settings::Server::SwitchDoubleTap, m_switchDoubleTap); QDialog::accept(); } @@ -300,7 +301,9 @@ void ServerConfigDialog::toggleSwitchDoubleTap(bool enable) void ServerConfigDialog::setSwitchDoubleTap(int within) { - serverConfig().setSwitchDoubleTap(within); + if (m_switchDoubleTap == within) + return; + m_switchDoubleTap = within; onChange(); } @@ -355,7 +358,6 @@ void ServerConfigDialog::toggleExternalConfig(bool checked) ui->tabWidget->setTabEnabled(1, !checked); ui->groupMisc->setEnabled(!checked); ui->groupCorners->setEnabled(!checked); - ui->sbSwitchDoubleTap->setEnabled(!checked); serverConfig().setUseExternalConfig(checked); onChange(); } @@ -406,9 +408,11 @@ void ServerConfigDialog::loadFromConfig() m_enableSwitchDoubleTap = Settings::value(Settings::Server::EnableSwitchDoubleTap).toBool(); ui->cbSwitchDoubleTap->setChecked(m_enableSwitchDoubleTap); - ui->sbSwitchDoubleTap->setValue(serverConfig().switchDoubleTap()); ui->sbSwitchDoubleTap->setEnabled(ui->cbSwitchDoubleTap->isChecked()); + m_switchDoubleTap = Settings::value(Settings::Server::SwitchDoubleTap).toInt(); + ui->sbSwitchDoubleTap->setValue(m_switchDoubleTap); + ui->groupExternalConfig->setChecked(serverConfig().useExternalConfig()); ui->widgetExternalConfigControls->setEnabled(ui->groupExternalConfig->isChecked()); @@ -529,7 +533,8 @@ void ServerConfigDialog::onChange() m_heartbeatRate == Settings::value(Settings::Server::Heartbeat).toInt() && m_enableSwitchDelay == Settings::value(Settings::Server::EnableSwitchDelay).toBool() && m_switchDelay == Settings::value(Settings::Server::SwitchDelay).toInt() && - m_enableSwitchDoubleTap == Settings::value(Settings::Server::EnableSwitchDoubleTap).toBool(); + m_enableSwitchDoubleTap == Settings::value(Settings::Server::EnableSwitchDoubleTap).toBool() && + m_switchDoubleTap == Settings::value(Settings::Server::SwitchDoubleTap).toInt(); ui->buttonBox->button(QDialogButtonBox::Ok) ->setEnabled(!isAppConfigDataEqual || !(m_originalServerConfig == m_serverConfig)); } diff --git a/src/lib/gui/dialogs/ServerConfigDialog.h b/src/lib/gui/dialogs/ServerConfigDialog.h index fc5f1db4c..73a307396 100644 --- a/src/lib/gui/dialogs/ServerConfigDialog.h +++ b/src/lib/gui/dialogs/ServerConfigDialog.h @@ -107,6 +107,7 @@ private: bool m_enableHeartbeat; int m_heartbeatRate; int m_switchDelay; + int m_switchDoubleTap; bool m_enableSwitchDelay; bool m_enableSwitchDoubleTap; bool m_originalServerConfigIsExternal; diff --git a/src/lib/server/Config.cpp b/src/lib/server/Config.cpp index b43f184b4..f09acc1f5 100644 --- a/src/lib/server/Config.cpp +++ b/src/lib/server/Config.cpp @@ -636,8 +636,8 @@ void Config::readSectionOptions(ConfigReadContext &s) bool handled = true; - // Skip old protocol name - if (name == "protocol" || name == "heartbeat" || name == "switchDelay") { + // Skip old option names + if (name == "protocol" || name == "heartbeat" || name == "switchDelay" || name == "switchDoubleTap") { continue; } @@ -652,8 +652,6 @@ void Config::readSectionOptions(ConfigReadContext &s) addOption("", kOptionScreenSwitchCorners, s.parseCorners(value)); } else if (name == "switchCornerSize") { addOption("", kOptionScreenSwitchCornerSize, s.parseInt(value)); - } else if (name == "switchDoubleTap") { - addOption("", kOptionScreenSwitchTwoTap, s.parseInt(value)); } else if (name == "switchNeedsShift") { addOption("", kOptionScreenSwitchNeedsShift, s.parseBoolean(value)); } else if (name == "switchNeedsControl") { @@ -728,6 +726,10 @@ void Config::readSectionOptions(ConfigReadContext &s) addOption("", kOptionScreenSwitchDelay, Settings::value(Settings::Server::SwitchDelay).toInt()); } + if (Settings::value(Settings::Server::EnableSwitchDoubleTap).toBool()) { + addOption("", kOptionScreenSwitchTwoTap, Settings::value(Settings::Server::SwitchDoubleTap).toInt()); + } + throw ServerConfigReadException(s, "unexpected end of options section"); }