feat: Update onMouseMoveSecondary to allow offset adjustments

This commit is contained in:
James Spurin 2024-09-12 15:36:35 +01:00 committed by Nick Bolton
parent 2e2523d6b8
commit 1003e07854
2 changed files with 32 additions and 7 deletions

View file

@ -145,14 +145,14 @@ jobs:
job: ${{ matrix.target.name }}
- name: Package
if: ${{ vars.CI_ENABLE_PACKAGING && env.PACKAGE_BUILD == 'true' }}
if: ${{ env.PACKAGE_BUILD == 'true' }}
run: python ./scripts/package.py
env:
WINDOWS_PFX_CERTIFICATE: ${{ secrets.WINDOWS_PFX }}
WINDOWS_PFX_PASSWORD: ${{ secrets.WINDOWS_PFX_PASS }}
- name: Upload
if: ${{ vars.CI_ENABLE_PACKAGING && env.PACKAGE_UPLOAD == 'true' }}
if: ${{ env.PACKAGE_UPLOAD == 'true' }}
uses: ./.github/actions/dist-upload
with:
use-github: true
@ -223,7 +223,7 @@ jobs:
job: ${{ matrix.target.name }}
- name: Package
if: ${{ vars.CI_ENABLE_PACKAGING && env.PACKAGE_BUILD == 'true' }}
if: ${{ env.PACKAGE_BUILD == 'true' }}
run: ./scripts/package.py
env:
APPLE_CODESIGN_ID: ${{ secrets.APPLE_CODESIGN_ID }}
@ -234,7 +234,7 @@ jobs:
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
- name: Upload
if: ${{ vars.CI_ENABLE_PACKAGING && env.PACKAGE_UPLOAD == 'true' }}
if: ${{ env.PACKAGE_UPLOAD == 'true' }}
uses: ./.github/actions/dist-upload
with:
use-github: true
@ -308,14 +308,14 @@ jobs:
job: linux-${{ matrix.distro.name }}
- name: Package
if: ${{ vars.CI_ENABLE_PACKAGING && env.PACKAGE_BUILD == 'true' }}
if: ${{ env.PACKAGE_BUILD == 'true' }}
env:
LINUX_EXTRA_PACKAGES: ${{ matrix.distro.extra-packages }}
LINUX_PACKAGE_USER: ${{ matrix.distro.package-user }}
run: ./scripts/package.py
- name: Upload
if: ${{ vars.CI_ENABLE_PACKAGING && env.PACKAGE_UPLOAD == 'true' }}
if: ${{ env.PACKAGE_UPLOAD == 'true' }}
uses: ./.github/actions/dist-upload
with:
use-github: true

View file

@ -42,6 +42,7 @@
#include "server/PrimaryClient.h"
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
@ -1790,7 +1791,31 @@ void Server::sendDragInfo(BaseClientProxy *newScreen) {
}
void Server::onMouseMoveSecondary(SInt32 dx, SInt32 dy) {
LOG((CLOG_DEBUG2 "onMouseMoveSecondary %+d,%+d", dx, dy));
LOG((CLOG_DEBUG2 "onMouseMoveSecondary initial %+d,%+d", dx, dy));
const char *envVal = std::getenv("DESKFLOW_MOUSE_ADJUSTMENT");
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 DESKFLOW_MOUSE_ADJUSTMENT value: %s. Exception: %s",
envVal, e.what()));
}
} else {
LOG(
(CLOG_DEBUG1
"DESKFLOW_MOUSE_ADJUSTMENT not set, using original values %+d,%+d",
dx, dy));
}
// mouse move on secondary (client's) screen
assert(m_active != NULL);