Skip to content
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

Open
4 of 5 tasks
nbolton opened this issue Sep 23, 2024 · 12 comments
Open
4 of 5 tasks

Client mouse adjustment setting #7582

nbolton opened this issue Sep 23, 2024 · 12 comments
Assignees
Labels
💎 Bounty enhancement A suggested change to improve functionality
Milestone

Comments

@nbolton
Copy link
Member

nbolton commented Sep 23, 2024

Project

Deskflow

Operating systems (OS)

  • Windows
  • macOS
  • Linux
  • BSD-derived
  • Other

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.

@nbolton nbolton added enhancement A suggested change to improve functionality triage Awaiting repro confirmation (bug) or needs accepting (enhancement) unanswered Issue not yet been answered by a maintainer labels Sep 23, 2024
@nbolton
Copy link
Member Author

nbolton commented Sep 23, 2024

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

@nbolton nbolton removed unanswered Issue not yet been answered by a maintainer triage Awaiting repro confirmation (bug) or needs accepting (enhancement) labels Sep 25, 2024
@sithlord48 sithlord48 added this to the v2.0.0 milestone Jan 2, 2025
@nbolton
Copy link
Member Author

nbolton commented Jan 2, 2025

/bounty $200

Copy link

algora-pbc bot commented Jan 2, 2025

💎 $200 bounty • Deskflow

Steps to solve:

  1. Start working: Comment /attempt #7582 with your implementation plan
  2. Submit work: Create a pull request including /claim #7582 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to deskflow/deskflow!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @onyedikachi-david Jan 2, 2025, 9:59:48 PM WIP
🟢 @ologbonowiwi Jan 2, 2025, 10:07:41 PM WIP

@onyedikachi-david
Copy link

onyedikachi-david commented Jan 2, 2025

/attempt #7582

Algora profile Completed bounties Tech Active attempts Options
@onyedikachi-david 14 bounties from 7 projects
TypeScript, Python,
JavaScript & more
Cancel attempt

@ologbonowiwi
Copy link

ologbonowiwi commented Jan 2, 2025

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

Algora profile Completed bounties Tech Active attempts Options
@ologbonowiwi 60 bounties from 8 projects
Rust, TypeScript,
Shell & more
Cancel attempt

@sithlord48
Copy link
Collaborator

Please note the env var is NOT SYNERGY_MOUSE_ADJUSTMENT It's DESKFLOW_MOUSE_ADJUSTMENT

@ologbonowiwi
Copy link

ologbonowiwi commented Jan 2, 2025

Thanks @sithlord48. I tried SYNERGY_ at first but after not finding I went through the file directly 😅

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 open build/bin/Deskflow.app, I get an error saying "Deskflow quit unexpectedly.". Let me know if there's any additional information I can provide.

Is there any additional steps other than what is mentioned on wiki build page?

@sithlord48
Copy link
Collaborator

yeah welcome to the most annoying thing ever macOS..

so i do two things locally

  1. comment out src/apps/deskflow-gui/cmakelists.txt lines 102 - 106 to stop the macdeployqt from running
  2. remove your previous build folder and rebuild
  3. you may need to run xattr -c on the app <build_path>/bin/Deskflow.app
    for some reason when i build locally if i run macdeployqt i can never get it to run proper even with xattr -c

@sithlord48
Copy link
Collaborator

sithlord48 commented Jan 3, 2025

@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

@ologbonowiwi
Copy link

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 🤔

@nbolton
Copy link
Member Author

nbolton commented Jan 8, 2025

accessibility access

Ideas:

@sithlord48
Copy link
Collaborator

should be less of an issue with our selfsigned builds now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💎 Bounty enhancement A suggested change to improve functionality
Projects
None yet
Development

No branches or pull requests

4 participants