-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client mouse adjustment setting #7582
Comments
Some WIP on this: diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp
index 7d3a34ea..73dad1ee 100644
--- a/src/lib/server/Server.cpp
+++ b/src/lib/server/Server.cpp
@@ -23,6 +23,7 @@
#include "base/Log.h"
#include "base/TMethodEventJob.h"
#include "base/TMethodJob.h"
+#include "common/basic_types.h"
#include "common/stdexcept.h"
#include "deskflow/AppUtil.h"
#include "deskflow/DropHelper.h"
@@ -42,11 +43,11 @@
#include "server/PrimaryClient.h"
#include <climits>
+#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
-#include <cmath>
-
+#include <optional>
using namespace deskflow::license;
using namespace deskflow::server;
@@ -1791,23 +1792,38 @@ void Server::sendDragInfo(BaseClientProxy *newScreen) {
}
}
-void Server::onMouseMoveSecondary(SInt32 dx, SInt32 dy) {
- LOG((CLOG_DEBUG2 "onMouseMoveSecondary initial %+d,%+d", dx, dy));
- const char* envVal = std::getenv("SYNERGY_MOUSE_ADJUSTMENT");
+std::optional<SInt32> getMouseAdjustment() {
+
+ const auto kMouseAdjustmentEnvVar = "SYNERGY_MOUSE_ADJUSTMENT";
+ const auto envVal = std::getenv(kMouseAdjustmentEnvVar);
+
if (envVal != nullptr) {
try {
- double multiplier = std::stod(envVal); // Convert to double
- SInt32 adjustedDx = static_cast<SInt32>(std::round(dx * multiplier)); // Apply multiplier and round
- SInt32 adjustedDy = static_cast<SInt32>(std::round(dy * multiplier));
- LOG((CLOG_DEBUG2 "Adjusted to %+d,%+d using multiplier %.2f", adjustedDx, adjustedDy, multiplier));
- dx = adjustedDx; // Update dx and dy to adjusted values
- dy = adjustedDy;
- } catch (const std::exception& e) {
- // Log the error message from the exception
- LOG((CLOG_ERR "Invalid SYNERGY_MOUSE_ADJUSTMENT value: %s. Exception: %s", envVal, e.what()));
+ return std::stod(envVal);
+ } catch (const std::invalid_argument &e) {
+ LOG_ERR("invalid %s value: %s", kMouseAdjustmentEnvVar, envVal);
+ LOG_ERR("%s", e.what());
+ } catch (const std::out_of_range &e) {
+ LOG_ERR("invalid %s value: %s", kMouseAdjustmentEnvVar, envVal);
+ LOG_ERR("%s", e.what());
}
} else {
- LOG((CLOG_DEBUG1 "SYNERGY_MOUSE_ADJUSTMENT not set, using original values %+d,%+d", dx, dy));
+ LOG_DEBUG2("%s not set", kMouseAdjustmentEnvVar);
+ }
+
+ return std::nullopt;
+}
+
+void Server::onMouseMoveSecondary(SInt32 dx, SInt32 dy) {
+ LOG((CLOG_DEBUG2 "onMouseMoveSecondary initial %+d,%+d", dx, dy));
+
+ const auto adjustment = getMouseAdjustment();
+ if (adjustment.has_value()) {
+ const auto adjustedDx =
+ static_cast<SInt32>(std::round(dx * adjustment.value()));
+ const auto adjustedDy =
+ static_cast<SInt32>(std::round(dy * adjustment.value()));
+ LOG((CLOG_DEBUG2 "onMouseMoveSecondary adjusted %+d,%+d", dx, dy));
}
// mouse move on secondary (client's) screen |
/bounty $200 |
💎 $200 bounty • DeskflowSteps to solve:
Thank you for contributing to deskflow/deskflow! Add a bounty • Share on socials
|
/attempt #7582
|
I have made a few changes, and the changes mentioned in the comment have been applied. I'm working on the GUI now. I was waiting to build the project properly before declaring my /attempt #7582
|
Please note the env var is NOT |
Thanks @sithlord48. I tried Can I get a hand on something else? I'm on Mac M1, tried to run the app with the instructions from the Wiki Build page. Both cmake commands ran without issues or warnings, but after building, when I execute Is there any additional steps other than what is mentioned on wiki build page? |
yeah welcome to the most annoying thing ever macOS.. so i do two things locally
|
@ologbonowiwi I've made a PR to fix the CMake part can you try it to see if this resolves the running issues for you #8037 . With this running as normal should work |
nice @sithlord48, thank you! I was able to run after removing this command, but now I'm stuck on something else. I've tried to add a QSpinBox on the dialog ui, but after I changed the ui XML file, everytime I rebuild and try to open the app, I see only a "alert" asking for accessibility access; I allowed on the settings but kept seeing the same error still. I made some progress yesterday in terms of figuring out the .ui and .cpp files I need to chance to add the new mouse speed multiplier option, but couldn't see it working yet because of this annoying issue. any clue? do I need to have all the cpp changes in place for the app to work? on my first attempt I changed both, still didn't seemed right (the permission window kept popping up). then I restarted and changed only ui files but still found the same issue ps: I never built anything on qt before, so it may be a silly error I caused but I'm not seeing lol ps2: is there any way I can bypass the accessibility permission? this may fix the issue 🤔 |
Ideas:
|
should be less of an issue with our selfsigned builds now |
Project
Deskflow
Operating systems (OS)
OS versions/distros
Any
Deskflow configuration
n/a
What problem are you trying to solve?
The #7511 mouse adjustment env var PR allows the mouse speed to be adjusted on the client, but it requires you to set an env var to do so.
What solution do you propose?
Add a client setting so this can more easily be changed in the GUI.
The text was updated successfully, but these errors were encountered: