From 2e45aab9a50f598f48d0c0233f7f7b8d95a562b3 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Sun, 8 Jun 2025 18:18:40 -0700 Subject: [PATCH 01/15] Reposition cursor after gesture. --- src/daemon/daemon-client.cpp | 76 +++++++++++++++++-- src/daemon/daemon-server.cpp | 63 ++++++++++++--- src/daemon/dbus.h | 9 +++ src/gesture-controller/gesture-controller.cpp | 30 ++++++++ .../libinput-device-handler.cpp | 18 ++--- .../libinput-device-handler.h | 3 +- .../libinput-touch-handler.cpp | 13 +++- src/gesture/gesture.h | 40 ++++++++++ src/utils/pixel-conversions.cpp | 6 ++ src/utils/pixel-conversions.h | 6 ++ src/window-system/window-system.h | 7 ++ src/window-system/x11.cpp | 54 +++++++++++++ src/window-system/x11.h | 3 + 13 files changed, 301 insertions(+), 27 deletions(-) create mode 100644 src/utils/pixel-conversions.cpp create mode 100644 src/utils/pixel-conversions.h diff --git a/src/daemon/daemon-client.cpp b/src/daemon/daemon-client.cpp index 2f8d25a9..99dcbe7c 100644 --- a/src/daemon/daemon-client.cpp +++ b/src/daemon/daemon-client.cpp @@ -126,11 +126,73 @@ std::unique_ptr DaemonClient::makeGestureFromSignalParams( int fingers = -1; DeviceType deviceType = DeviceType::UNKNOWN; uint64_t elapsedTime = -1; - - g_variant_get(signalParameters, // NOLINT - "(uudiut)", &type, &direction, &percentage, &fingers, - &deviceType, &elapsedTime); - - return std::make_unique(type, direction, percentage, fingers, - deviceType, elapsedTime); + XYPosition endPosition = {-1, -1}; + double endPositionX = -2, endPositionY = -2; + + if (g_variant_check_format_string(signalParameters, "(uuudiut)", false)) { + g_variant_get(signalParameters, // NOLINT + "(uuudiut)", &type, &direction, &axis, &percentage, &fingers, + &deviceType, &elapsedTime); + } else { + //GVariant *maybeEndPosition; + gboolean maybeEndPosition; + g_variant_get(signalParameters, // NOLINT + //"(uuudiutuu)", &type, &direction, &axis, &percentage, &fingers, + //"(uuudiutx)", &type, &direction, &axis, &percentage, &fingers, + "(uuudiutdd)", &type, &direction, &axis, &percentage, &fingers, + //"(uuudiut(dd))", &type, &direction, &axis, &percentage, &fingers, + //&deviceType, &elapsedTime, &endPosition); + //&deviceType, &elapsedTime, &(endPosition.x), &(endPosition.y)); + &deviceType, &elapsedTime, &endPositionX, &endPositionY); + //"(uuudiutm*)", &type, &direction, &axis, &percentage, &fingers, + //&deviceType, &elapsedTime, &maybeEndPosition); + //"(uuudiutm(dd))", &type, &direction, &axis, &percentage, &fingers, + //&deviceType, &elapsedTime, &maybeEndPosition, &endPositionX, &endPositionY); + //if (maybeEndPosition != NULL) { + // g_variant_get(maybeEndPosition, "(dd)", &endPositionX, &endPositionY); + // endPosition.x = endPositionX; + // endPosition.y = endPositionY; + // g_variant_unref(maybeEndPosition); + //} + //if (maybeEndPosition) { + endPosition.x = endPositionX; + endPosition.y = endPositionY; + //} + std::cout << "Got endPosition (from signal): " << endPosition.x << ", " << endPosition.y << std::endl; + } + //if (g_variant_check_format_string(signalParameters, "(uuudiutdd)", false)) { + ////if (!g_variant_check_format_string(signalParameters, "(uuudiutdd)", false)) { + // //GVariant *maybeEndPosition; + // gboolean maybeEndPosition; + // g_variant_get(signalParameters, // NOLINT + // //"(uuudiutuu)", &type, &direction, &axis, &percentage, &fingers, + // //"(uuudiutx)", &type, &direction, &axis, &percentage, &fingers, + // "(uuudiutdd)", &type, &direction, &axis, &percentage, &fingers, + // //"(uuudiut(dd))", &type, &direction, &axis, &percentage, &fingers, + // //&deviceType, &elapsedTime, &endPosition); + // //&deviceType, &elapsedTime, &(endPosition.x), &(endPosition.y)); + // &deviceType, &elapsedTime, &endPositionX, &endPositionY); + // //"(uuudiutm*)", &type, &direction, &axis, &percentage, &fingers, + // //&deviceType, &elapsedTime, &maybeEndPosition); + // //"(uuudiutm(dd))", &type, &direction, &axis, &percentage, &fingers, + // //&deviceType, &elapsedTime, &maybeEndPosition, &endPositionX, &endPositionY); + // //if (maybeEndPosition != NULL) { + // // g_variant_get(maybeEndPosition, "(dd)", &endPositionX, &endPositionY); + // // endPosition.x = endPositionX; + // // endPosition.y = endPositionY; + // // g_variant_unref(maybeEndPosition); + // //} + // //if (maybeEndPosition) { + // endPosition.x = endPositionX; + // endPosition.y = endPositionY; + // //} + // std::cout << "Got endPosition (from signal): " << endPosition.x << ", " << endPosition.y << std::endl; + //} else { + // g_variant_get(signalParameters, // NOLINT + // "(uuudiut)", &type, &direction, &axis, &percentage, &fingers, + // &deviceType, &elapsedTime); + //} + + return std::make_unique(type, direction, axis, percentage, fingers, + deviceType, elapsedTime, endPosition); } diff --git a/src/daemon/daemon-server.cpp b/src/daemon/daemon-server.cpp index 0fbb25cb..a7384d77 100644 --- a/src/daemon/daemon-server.cpp +++ b/src/daemon/daemon-server.cpp @@ -115,15 +115,60 @@ void DaemonServer::send(const std::string &signalName, std::vector closedConnections{}; // Copy every gesture field into the signal parameters for serialization - GVariant *signalParams = - g_variant_new("(uudiut)", // NOLINT - static_cast(gesture->type()), // u - static_cast(gesture->direction()), // u - gesture->percentage(), // d - gesture->fingers(), // i - static_cast(gesture->performedOnDeviceType()), // u - gesture->elapsedTime()); // t - g_variant_ref_sink(signalParams); + // Offer signal versions in order from oldest to newest + //signalParams[i] = { + // //g_variant_new("(uudiutuu)", // NOLINT + // //g_variant_new("(uudiutx)", // NOLINT + // g_variant_new("(uudiutdd)", // NOLINT + // //g_variant_new("(uudiut(dd))", // NOLINT + // static_cast(gesture->type()), // u + // static_cast(gesture->direction()), // u + // gesture->percentage(), // d + // gesture->fingers(), // i + // static_cast(gesture->performedOnDeviceType()), // u + // gesture->elapsedTime(), // t + // gesture->endPosition())}; // uu + //g_variant_ref_sink(signalParams[i++]); + //if (gesture->endPosition().x > -1 || gesture->endPosition().y > -1) { + if (signalName == DBUS_ON_GESTURE_END) { + std::cout << "Emitting signal with endPosition: " << gesture->endPosition().x << ", " << gesture->endPosition().y << std::endl; + signalParams[i] = { + //g_variant_new("(uuudiutuu)", // NOLINT + //g_variant_new("(uuudiutx)", // NOLINT + g_variant_new("(uuudiutdd)", // NOLINT + //g_variant_new("(uuudiut(dd))", // NOLINT + //g_variant_new("(uuudiutm@(dd))", // NOLINT + //g_variant_new("(uuudiutm(dd))", // NOLINT + static_cast(gesture->type()), // u + static_cast(gesture->direction()), // u + static_cast(gesture->axis()), // u + gesture->percentage(), // d + gesture->fingers(), // i + static_cast(gesture->performedOnDeviceType()), // u + gesture->elapsedTime(), // t + //gesture->endPosition())}; // dd + //gesture->endPosition())}; // m@(dd) // Currently always send. Make optional. + //TRUE, // m // Currently always send. Make optional. + gesture->endPosition().x, // d + gesture->endPosition().y)}; // d + } else { + signalParams[i] = { + g_variant_new("(uuudiut)", // NOLINT + //g_variant_new("(uuudiutm@(dd))", // NOLINT + //g_variant_new("(uuudiutm(dd))", // NOLINT + static_cast(gesture->type()), // u + static_cast(gesture->direction()), // u + static_cast(gesture->axis()), // u + gesture->percentage(), // d + gesture->fingers(), // i + static_cast(gesture->performedOnDeviceType()), // u + gesture->elapsedTime())}; // t + //gesture->elapsedTime(), // t + //NULL)}; // m@(dd) + //FALSE, NULL, NULL)}; // m(dd) + //FALSE, -1, -1)}; // m(dd) + } + g_variant_ref_sink(signalParams[i++]); // Send the message to every client for (auto *connection : this->connections) { diff --git a/src/daemon/dbus.h b/src/daemon/dbus.h index 9e9f1924..2e6da1e2 100644 --- a/src/daemon/dbus.h +++ b/src/daemon/dbus.h @@ -58,6 +58,15 @@ constexpr auto DBUS_INTROSPECTION_XML = " " " " " " + //" " + //" " + " " + //" " + //" " + //" " + //" " + //" " + //" " " " " " ""; diff --git a/src/gesture-controller/gesture-controller.cpp b/src/gesture-controller/gesture-controller.cpp index 5801c963..3003735e 100755 --- a/src/gesture-controller/gesture-controller.cpp +++ b/src/gesture-controller/gesture-controller.cpp @@ -85,6 +85,12 @@ void GestureController::onGestureUpdate(std::unique_ptr gesture) { } void GestureController::onGestureEnd(std::unique_ptr gesture) { + XYPosition curPos = gesture->endPosition(); + std::cout << "cursorEndPosition: {" << curPos.x << ", " << curPos.y << "}" << std::endl; + if (curPos.x >= 0 && curPos.y >= 0) { + this->windowSystem.positionCursor(curPos.x, curPos.y); + } + if (this->executeAction) { tlg::debug << "Gesture end detected" << std::endl; gesture->setDirection(this->rotatedDirection); @@ -94,6 +100,23 @@ void GestureController::onGestureEnd(std::unique_ptr gesture) { this->action.reset(); this->rotatedDirection = GestureDirection::UNKNOWN; } +//void GestureController::onGestureEnd(std::unique_ptr gesture, int cur_x, int cur_y) { +// if (this->executeAction) { +// tlg::debug << "Gesture end detected" << std::endl; +// gesture->setDirection(this->rotatedDirection); +// this->action->onGestureEnd(*gesture); +// } +// +// this->action.reset(); +// this->rotatedDirection = GestureDirection::UNKNOWN; +// +// switch (gesture->type()) { +// case GestureType::SWIPE : +// case GestureType::TAP : +// this->windowSystem.positionCursor(cur_x, cur_y); +// break; +// } +//} std::unique_ptr GestureController::getActionForGesture( const Gesture &gesture, const WindowT &window) const { @@ -128,6 +151,13 @@ std::unique_ptr GestureController::getActionForGesture( ActionType actionType = pair.first; std::unordered_map actionSettings = pair.second; + //switch (gesture.type()) { + // case GestureType::SWIPE : + // case GestureType::TAP : + // this.windowSystem.positionCursor(); + // break; + //} + return ActionFactory::buildAction(actionType, std::move(actionSettings), this->windowSystem, *this->window, this->config); diff --git a/src/gesture-gatherer/libinput-device-handler.cpp b/src/gesture-gatherer/libinput-device-handler.cpp index 1e39e165..e7b6354b 100644 --- a/src/gesture-gatherer/libinput-device-handler.cpp +++ b/src/gesture-gatherer/libinput-device-handler.cpp @@ -123,19 +123,19 @@ void LininputDeviceHandler::calculateTouchpadThreshold( double minSize = std::min(widthMm, heightMm); outInfo->startThreshold = - ((LininputDeviceHandler::mmToDpi(minSize) * START_PERCENTAGE) / 100); + ((mmToDpi(minSize) * START_PERCENTAGE) / 100); outInfo->finishThresholdHorizontal = - ((LininputDeviceHandler::mmToDpi(widthMm) * FINISH_PERCENTAGE) / 100); + ((mmToDpi(widthMm) * FINISH_PERCENTAGE) / 100); outInfo->finishThresholdVertical = - ((LininputDeviceHandler::mmToDpi(heightMm) * FINISH_PERCENTAGE) / 100); + ((mmToDpi(heightMm) * FINISH_PERCENTAGE) / 100); } -double LininputDeviceHandler::mmToDpi(double mm) { - constexpr double mmInOneInch = 25.4; // 1 inch == 25.4 mm - double inches = mm / mmInOneInch; - double dpi = (inches * 1000); - return dpi; -} +//double LininputDeviceHandler::mmToDpi(double mm) { +// constexpr double mmInOneInch = 25.4; // 1 inch == 25.4 mm +// double inches = mm / mmInOneInch; +// double dpi = (inches * 1000); +// return dpi; +//} void LininputDeviceHandler::calculateTouchscreenThreshold( double widthMm, double heightMm, LibinputDeviceInfo *outInfo) { diff --git a/src/gesture-gatherer/libinput-device-handler.h b/src/gesture-gatherer/libinput-device-handler.h index 20fbbe9b..929182dd 100644 --- a/src/gesture-gatherer/libinput-device-handler.h +++ b/src/gesture-gatherer/libinput-device-handler.h @@ -23,6 +23,7 @@ #include "gesture-controller/gesture-controller-delegate.h" #include "gesture-gatherer/libinput-handler.h" #include "gesture/gesture-direction.h" +#include "utils/pixel-conversions.h" /** * Class to handle libinput devices: @@ -56,7 +57,7 @@ class LininputDeviceHandler : public LininputHandler { */ static void calculateTouchpadThreshold(double widthMm, double heightMm, LibinputDeviceInfo *outInfo); - static double mmToDpi(double mm); + //static double mmToDpi(double mm); /** * Calculates LibinputDeviceInfo on touchscreens. diff --git a/src/gesture-gatherer/libinput-touch-handler.cpp b/src/gesture-gatherer/libinput-touch-handler.cpp index 2f8b3837..e67e836d 100644 --- a/src/gesture-gatherer/libinput-touch-handler.cpp +++ b/src/gesture-gatherer/libinput-touch-handler.cpp @@ -23,6 +23,7 @@ #include #include #include +#include // Debugging. #include "gesture/device-type.h" #include "gesture/gesture.h" @@ -90,9 +91,19 @@ void LibinputTouchHandler::handleTouchUp(struct libinput_event *event) { : LininputHandler::calculatePinchAnimationPercentage( this->state.direction, this->getPinchDelta()); + std::cout << "Assigning current XY values: " << this->state.currentX[slot] << ", " << this->state.currentY[slot] << std::endl; + //Rectangle screenSize = auto gesture = std::make_unique( this->state.type, this->state.direction, percentage, - this->state.startFingers, DeviceType::TOUCHSCREEN, elapsedTime); + this->state.startFingers, DeviceType::TOUCHSCREEN, elapsedTime, + XYPosition{this->state.currentX[slot], this->state.currentY[slot]}); + //Rectangle { + //XYPosition{ + // libinput_event_touch_get_x(tEvent), + // libinput_event_touch_get_y(tEvent) + // libinput_event_touch_get_x_transformed(tEvent, ), + // libinput_event_touch_get_y_transformed(tEvent, ) + //}); this->gestureController->onGestureEnd(std::move(gesture)); this->state.reset(); diff --git a/src/gesture/gesture.h b/src/gesture/gesture.h index 8a7e320d..892d0c00 100644 --- a/src/gesture/gesture.h +++ b/src/gesture/gesture.h @@ -24,6 +24,16 @@ #include "gesture/gesture-direction.h" #include "gesture/gesture-type.h" +//struct XYPosition { +// int x; +// int y; +//}; +struct XYPosition { + double x; + double y; +}; +//#include "utils/rectangle.h" + /** * Gestures implementations change depending on the driver/backend. This is the * basic interface of a gesture. @@ -38,6 +48,28 @@ class Gesture { gestureFingers(fingers), deviceType(performedOnDeviceType), gestureElapsedTime(elapsedTime) {} + Gesture(GestureType type, GestureDirection direction, double percentage, + int fingers, DeviceType performedOnDeviceType, uint64_t elapsedTime, + XYPosition cursorEndPosition) + : gestureType(type), + gestureDirection(direction), + gestureAxis(gestureAxisFromDirection(direction)), + gesturePercentage(percentage), + gestureFingers(fingers), + deviceType(performedOnDeviceType), + gestureElapsedTime(elapsedTime), + gestureEndPosition(cursorEndPosition) {} + Gesture(GestureType type, GestureDirection direction, GestureAxis axis, + double percentage, int fingers, DeviceType performedOnDeviceType, + uint64_t elapsedTime, XYPosition cursorEndPosition) + : gestureType(type), + gestureDirection(direction), + gestureAxis(axis), + gesturePercentage(percentage), + gestureFingers(fingers), + deviceType(performedOnDeviceType), + gestureElapsedTime(elapsedTime), + gestureEndPosition(cursorEndPosition) {} /** * @returns The gesture type. @@ -73,6 +105,12 @@ class Gesture { */ uint64_t elapsedTime() const { return this->gestureElapsedTime; } + /** + * Position to set cursor when gesture ends.. + * @returns A struct containing X and Y position integers. + */ + XYPosition endPosition() const { return this->gestureEndPosition; } + /** * Set the gesture direction. * @see GestureDirection @@ -88,6 +126,8 @@ class Gesture { int gestureFingers = -1; DeviceType deviceType = DeviceType::UNKNOWN; uint64_t gestureElapsedTime = -1; + XYPosition gestureEndPosition {-1, -1}; + //Rectangle cursorPosition {0, 0, 0, 0}; }; #endif // GESTURE_GESTURE_H_ diff --git a/src/utils/pixel-conversions.cpp b/src/utils/pixel-conversions.cpp new file mode 100644 index 00000000..6ca9ee41 --- /dev/null +++ b/src/utils/pixel-conversions.cpp @@ -0,0 +1,6 @@ +double mmToDpi(double mm) { + constexpr double mmInOneInch = 25.4; // 1 inch == 25.4 mm + double inches = mm / mmInOneInch; + double dpi = (inches * 1000); + return dpi; +} diff --git a/src/utils/pixel-conversions.h b/src/utils/pixel-conversions.h new file mode 100644 index 00000000..e3f23cfe --- /dev/null +++ b/src/utils/pixel-conversions.h @@ -0,0 +1,6 @@ +#ifndef UTILS_PIXEL_CONVERSIONS_H_ +#define UTILS_PIXEL_CONVERSIONS_H_ + +double mmToDpi(double mm); + +#endif // UTILS_PIXEL_CONVERSIONS_H_ diff --git a/src/window-system/window-system.h b/src/window-system/window-system.h index 0c9fd75c..05118eb8 100644 --- a/src/window-system/window-system.h +++ b/src/window-system/window-system.h @@ -150,6 +150,13 @@ class WindowSystem { */ virtual void sendMouseUp(int button) const = 0; + /** + * Directly positions cursor. + * Only one movement event should be triggered. + * No button click events should be sent. + */ + virtual void positionCursor(double x, double y) const = 0; + /** * @returns The size of the desktop workarea, ie, the area of the desktop not * used by system elements like docks, panels, etc. diff --git a/src/window-system/x11.cpp b/src/window-system/x11.cpp index 3001ec32..e50e3602 100644 --- a/src/window-system/x11.cpp +++ b/src/window-system/x11.cpp @@ -476,6 +476,60 @@ void X11::sendMouseUp(int button) const { XFlush(this->display); } +void X11::positionCursor(double xMm, double yMm) const { + std::cout << "Attempting to reposition cursor." << std::endl; + int screen = DefaultScreen(this->display); + + // Note: These values are subject to system configuration (e.g. D.P.I.). + // https://bbs.archlinux.org/viewtopic.php?id=227324 + double dwMM = DisplayWidthMM(this->display, screen); + double dhMM = DisplayHeightMM(this->display, screen); + double dwPixels = DisplayWidth(this->display, screen); + double dhPixels = DisplayHeight(this->display, screen); + std::cout + << " Gesture offset X (mm): " << xMm << '\n' + << " Gesture offset Y (mm): " << yMm << '\n' + << " Display width (mm): " << dwMM << '\n' + << " Display height (mm): " << dhMM << '\n' + << " Display width (pixels): " << dwPixels << '\n' + << "Display height (pixels): " << dhPixels << '\n' + << std::endl; + // + // These need the screen structure, not I.D. integer. + //if (dwMM != WidthMMOfScreen(screen)) std::cout << "Width (mm) of screen and display do not match. Screen claims: " << WidthMMOfScreen(screen) << std::endl; + //if (dhMM != HeightMMOfScreen(screen)) std::cout << "Height (mm) of screen and display do not match. Screen claims: " << HeightMMOfScreen(screen) << std::endl; + //if (dwMM != WidthOfScreen(screen)) std::cout << "Width (pixels) of screen and display do not match. Screen claims: " << WidthOfScreen(screen) << std::endl; + //if (dhMM != HeightOfScreen(screen)) std::cout << "Height (pixels) of screen and display do not match. Screen claims: " << HeightOfScreen(screen) << std::endl; + + int targetX = (xMm / dwMM) * dwPixels; + int targetY = (yMm / dhMM) * dhPixels; + std::cout << " Cursor target: " << targetX << ", " << targetY << std::endl; + + // Get current cursor position. + Window rootWindow = None; + Window childWindow = None; + int pointerX = 0; + int pointerY = 0; + int childX = 0; + int childY = 0; + unsigned int mask = 0; + int success = XQueryPointer(this->display, XDefaultRootWindow(this->display), &rootWindow, + &childWindow, &pointerX, &pointerY, &childX, &childY, &mask); + if (!success) { + std::cout << "Failed to query pointer. Cursor will not be repositioned." << std::endl; + return; + } + std::cout << "Current cursor position: " << pointerX << ", " << pointerY << std::endl; + + // Not sure if useful. + // Move cursor to origin (0, 0). This is necessary because we are warping with relative positioning, irrespective of windows. + //XWarpPointer(this->display, None, None, 0, 0, 0, 0, -pointerX, -pointerY); + //XWarpPointer(this->display, None, None, 0, 0, 0, 0, targetX, targetY); + + XWarpPointer(this->display, None, None, 0, 0, 0, 0, targetX - pointerX, targetY - pointerY); + XFlush(this->display); +} + Rectangle X11::getDesktopWorkarea() const { // When multiple physical screens are connected, the root window's size is the // sum of all of them. Use Xrandr to get the screen size of the physical diff --git a/src/window-system/x11.h b/src/window-system/x11.h index a2713ee0..b07a3c51 100644 --- a/src/window-system/x11.h +++ b/src/window-system/x11.h @@ -29,6 +29,7 @@ #include #include "window-system/window-system.h" +#include "utils/pixel-conversions.h" /** * X11 WindowT implementation, just a Window as defined in . @@ -68,6 +69,8 @@ class X11 : public WindowSystem { bool isPress) const override; void sendMouseDown(int button) const override; void sendMouseUp(int button) const override; + void positionCursor(double x, double y) const override; + Rectangle getDesktopWorkarea() const override; void changeDesktop(ActionDirection direction, bool cyclic) const override; From 4801cfd589abfdd1e04cccb9202189ab3f52f61f Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Sun, 8 Jun 2025 19:27:21 -0700 Subject: [PATCH 02/15] Fixes, formatting, and some clean-up. --- src/daemon/daemon-client.cpp | 128 ++++++++++-------- src/daemon/daemon-server.cpp | 92 ++++++------- src/gesture-controller/gesture-controller.cpp | 47 ++++--- .../libinput-device-handler.cpp | 15 +- .../libinput-device-handler.h | 2 +- .../libinput-gesture-gatherer.h | 7 +- .../libinput-touch-handler.cpp | 21 +-- src/gesture/gesture.h | 30 ++-- src/window-system/x11.cpp | 59 +++++--- src/window-system/x11.h | 3 +- 10 files changed, 206 insertions(+), 198 deletions(-) mode change 100755 => 100644 src/gesture-controller/gesture-controller.cpp mode change 100755 => 100644 src/gesture-gatherer/libinput-gesture-gatherer.h diff --git a/src/daemon/daemon-client.cpp b/src/daemon/daemon-client.cpp index 99dcbe7c..a68e2d15 100644 --- a/src/daemon/daemon-client.cpp +++ b/src/daemon/daemon-client.cpp @@ -129,70 +129,84 @@ std::unique_ptr DaemonClient::makeGestureFromSignalParams( XYPosition endPosition = {-1, -1}; double endPositionX = -2, endPositionY = -2; - if (g_variant_check_format_string(signalParameters, "(uuudiut)", false)) { + if (g_variant_check_format_string(signalParameters, "(uudiut)", false)) { g_variant_get(signalParameters, // NOLINT - "(uuudiut)", &type, &direction, &axis, &percentage, &fingers, - &deviceType, &elapsedTime); + "(uudiut)", &type, &direction, &percentage, &fingers, + &deviceType, &elapsedTime); } else { - //GVariant *maybeEndPosition; + // GVariant *maybeEndPosition; gboolean maybeEndPosition; - g_variant_get(signalParameters, // NOLINT - //"(uuudiutuu)", &type, &direction, &axis, &percentage, &fingers, - //"(uuudiutx)", &type, &direction, &axis, &percentage, &fingers, - "(uuudiutdd)", &type, &direction, &axis, &percentage, &fingers, - //"(uuudiut(dd))", &type, &direction, &axis, &percentage, &fingers, - //&deviceType, &elapsedTime, &endPosition); - //&deviceType, &elapsedTime, &(endPosition.x), &(endPosition.y)); - &deviceType, &elapsedTime, &endPositionX, &endPositionY); - //"(uuudiutm*)", &type, &direction, &axis, &percentage, &fingers, - //&deviceType, &elapsedTime, &maybeEndPosition); - //"(uuudiutm(dd))", &type, &direction, &axis, &percentage, &fingers, - //&deviceType, &elapsedTime, &maybeEndPosition, &endPositionX, &endPositionY); - //if (maybeEndPosition != NULL) { - // g_variant_get(maybeEndPosition, "(dd)", &endPositionX, &endPositionY); - // endPosition.x = endPositionX; - // endPosition.y = endPositionY; - // g_variant_unref(maybeEndPosition); - //} - //if (maybeEndPosition) { - endPosition.x = endPositionX; - endPosition.y = endPositionY; + g_variant_get( + signalParameters, // NOLINT + //"(uudiutuu)", &type, &direction, + //&percentage, &fingers, + //"(uudiutx)", &type, &direction, + //&percentage, &fingers, + "(uudiutdd)", &type, &direction, &percentage, &fingers, + //"(uudiut(dd))", &type, &direction, &percentage, &fingers, + //&deviceType, &elapsedTime, &endPosition); + //&deviceType, &elapsedTime, &(endPosition.x), &(endPosition.y)); + &deviceType, &elapsedTime, &endPositionX, &endPositionY); + //"(uudiutm*)", &type, &direction, &percentage, &fingers, + //&deviceType, &elapsedTime, &maybeEndPosition); + //"(uudiutm(dd))", &type, &direction, &percentage, &fingers + //&deviceType, &elapsedTime, &maybeEndPosition, &endPositionX, + //&endPositionY); + // if (maybeEndPosition != NULL) { + // g_variant_get(maybeEndPosition, "(dd)", &endPositionX, &endPositionY); + // endPosition.x = endPositionX; + // endPosition.y = endPositionY; + // g_variant_unref(maybeEndPosition); + // } + // if (maybeEndPosition) { + endPosition.x = endPositionX; + endPosition.y = endPositionY; //} - std::cout << "Got endPosition (from signal): " << endPosition.x << ", " << endPosition.y << std::endl; + std::cout << "Got endPosition (from signal): " << endPosition.x << ", " + << endPosition.y << std::endl; } - //if (g_variant_check_format_string(signalParameters, "(uuudiutdd)", false)) { - ////if (!g_variant_check_format_string(signalParameters, "(uuudiutdd)", false)) { - // //GVariant *maybeEndPosition; - // gboolean maybeEndPosition; - // g_variant_get(signalParameters, // NOLINT - // //"(uuudiutuu)", &type, &direction, &axis, &percentage, &fingers, - // //"(uuudiutx)", &type, &direction, &axis, &percentage, &fingers, - // "(uuudiutdd)", &type, &direction, &axis, &percentage, &fingers, - // //"(uuudiut(dd))", &type, &direction, &axis, &percentage, &fingers, - // //&deviceType, &elapsedTime, &endPosition); - // //&deviceType, &elapsedTime, &(endPosition.x), &(endPosition.y)); - // &deviceType, &elapsedTime, &endPositionX, &endPositionY); - // //"(uuudiutm*)", &type, &direction, &axis, &percentage, &fingers, - // //&deviceType, &elapsedTime, &maybeEndPosition); - // //"(uuudiutm(dd))", &type, &direction, &axis, &percentage, &fingers, - // //&deviceType, &elapsedTime, &maybeEndPosition, &endPositionX, &endPositionY); - // //if (maybeEndPosition != NULL) { - // // g_variant_get(maybeEndPosition, "(dd)", &endPositionX, &endPositionY); - // // endPosition.x = endPositionX; - // // endPosition.y = endPositionY; - // // g_variant_unref(maybeEndPosition); - // //} - // //if (maybeEndPosition) { - // endPosition.x = endPositionX; - // endPosition.y = endPositionY; - // //} - // std::cout << "Got endPosition (from signal): " << endPosition.x << ", " << endPosition.y << std::endl; + // if (g_variant_check_format_string(signalParameters, "(uudiutdd)", false)) + // { + ////if (!g_variant_check_format_string(signalParameters, "(uudiutdd)", + /// false)) { + // //GVariant *maybeEndPosition; + // gboolean maybeEndPosition; + // g_variant_get(signalParameters, // NOLINT + // //"(uudiutuu)", &type, &direction, &percentage, + //&fingers, + // //"(uudiutx)", &type, &direction, &percentage, &fingers, + // "(uudiutdd)", &type, &direction, &percentage, &fingers, + // //"(uudiut(dd))", &type, &direction, &percentage, + //&fingers, + // //&deviceType, &elapsedTime, &endPosition); + // //&deviceType, &elapsedTime, &(endPosition.x), + //&(endPosition.y)); &deviceType, &elapsedTime, &endPositionX, + //&endPositionY); + // //"(uudiutm*)", &type, &direction, &percentage, + //&fingers, + // //&deviceType, &elapsedTime, &maybeEndPosition); + // //"(uudiutm(dd))", &type, &direction, &percentage, + //&fingers, + // //&deviceType, &elapsedTime, &maybeEndPosition, &endPositionX, + //&endPositionY); + // //if (maybeEndPosition != NULL) { + // // g_variant_get(maybeEndPosition, "(dd)", &endPositionX, &endPositionY); + // // endPosition.x = endPositionX; + // // endPosition.y = endPositionY; + // // g_variant_unref(maybeEndPosition); + // //} + // //if (maybeEndPosition) { + // endPosition.x = endPositionX; + // endPosition.y = endPositionY; + // //} + // std::cout << "Got endPosition (from signal): " << endPosition.x << ", " << + // endPosition.y << std::endl; //} else { - // g_variant_get(signalParameters, // NOLINT - // "(uuudiut)", &type, &direction, &axis, &percentage, &fingers, - // &deviceType, &elapsedTime); + // g_variant_get(signalParameters, // NOLINT + // "(uudiut)", &type, &direction, &percentage, &fingers, + // &deviceType, &elapsedTime); //} - return std::make_unique(type, direction, axis, percentage, fingers, + return std::make_unique(type, direction, percentage, fingers, deviceType, elapsedTime, endPosition); } diff --git a/src/daemon/daemon-server.cpp b/src/daemon/daemon-server.cpp index a7384d77..14ab976c 100644 --- a/src/daemon/daemon-server.cpp +++ b/src/daemon/daemon-server.cpp @@ -115,60 +115,50 @@ void DaemonServer::send(const std::string &signalName, std::vector closedConnections{}; // Copy every gesture field into the signal parameters for serialization - // Offer signal versions in order from oldest to newest - //signalParams[i] = { - // //g_variant_new("(uudiutuu)", // NOLINT - // //g_variant_new("(uudiutx)", // NOLINT - // g_variant_new("(uudiutdd)", // NOLINT - // //g_variant_new("(uudiut(dd))", // NOLINT - // static_cast(gesture->type()), // u - // static_cast(gesture->direction()), // u - // gesture->percentage(), // d - // gesture->fingers(), // i - // static_cast(gesture->performedOnDeviceType()), // u - // gesture->elapsedTime(), // t - // gesture->endPosition())}; // uu - //g_variant_ref_sink(signalParams[i++]); - //if (gesture->endPosition().x > -1 || gesture->endPosition().y > -1) { + // if (gesture->endPosition().x > -1 || gesture->endPosition().y > -1) { + GVariant *signalParams; if (signalName == DBUS_ON_GESTURE_END) { - std::cout << "Emitting signal with endPosition: " << gesture->endPosition().x << ", " << gesture->endPosition().y << std::endl; - signalParams[i] = { - //g_variant_new("(uuudiutuu)", // NOLINT - //g_variant_new("(uuudiutx)", // NOLINT - g_variant_new("(uuudiutdd)", // NOLINT - //g_variant_new("(uuudiut(dd))", // NOLINT - //g_variant_new("(uuudiutm@(dd))", // NOLINT - //g_variant_new("(uuudiutm(dd))", // NOLINT - static_cast(gesture->type()), // u - static_cast(gesture->direction()), // u - static_cast(gesture->axis()), // u - gesture->percentage(), // d - gesture->fingers(), // i - static_cast(gesture->performedOnDeviceType()), // u - gesture->elapsedTime(), // t - //gesture->endPosition())}; // dd - //gesture->endPosition())}; // m@(dd) // Currently always send. Make optional. - //TRUE, // m // Currently always send. Make optional. - gesture->endPosition().x, // d - gesture->endPosition().y)}; // d + std::cout << "Emitting signal with endPosition: " + << gesture->endPosition().x << ", " << gesture->endPosition().y + << std::endl; + signalParams = { + // g_variant_new("(uudiutuu)", // NOLINT + // g_variant_new("(uudiutx)", // NOLINT + g_variant_new( + "(uudiutdd)", // NOLINT + // g_variant_new("(uuudiut(dd))", // NOLINT + // g_variant_new("(uuudiutm@(dd))", // NOLINT + // g_variant_new("(uuudiutm(dd))", // NOLINT + static_cast(gesture->type()), // u + static_cast(gesture->direction()), // u + gesture->percentage(), // d + gesture->fingers(), // i + static_cast(gesture->performedOnDeviceType()), // u + gesture->elapsedTime(), // t + // gesture->endPosition())}; // dd + // gesture->endPosition())}; // m@(dd) + // // Currently always send. Make optional. + // TRUE, // m // Currently always + // send. Make optional. + gesture->endPosition().x, // d + gesture->endPosition().y)}; // d } else { - signalParams[i] = { - g_variant_new("(uuudiut)", // NOLINT - //g_variant_new("(uuudiutm@(dd))", // NOLINT - //g_variant_new("(uuudiutm(dd))", // NOLINT - static_cast(gesture->type()), // u - static_cast(gesture->direction()), // u - static_cast(gesture->axis()), // u - gesture->percentage(), // d - gesture->fingers(), // i - static_cast(gesture->performedOnDeviceType()), // u - gesture->elapsedTime())}; // t - //gesture->elapsedTime(), // t - //NULL)}; // m@(dd) - //FALSE, NULL, NULL)}; // m(dd) - //FALSE, -1, -1)}; // m(dd) + signalParams = {g_variant_new( + "(uudiut)", // NOLINT + // g_variant_new("(uuudiutm@(dd))", // NOLINT + // g_variant_new("(uuudiutm(dd))", // NOLINT + static_cast(gesture->type()), // u + static_cast(gesture->direction()), // u + gesture->percentage(), // d + gesture->fingers(), // i + static_cast(gesture->performedOnDeviceType()), // u + gesture->elapsedTime())}; // t + // gesture->elapsedTime(), // t + // NULL)}; // m@(dd) + // FALSE, NULL, NULL)}; // m(dd) + // FALSE, -1, -1)}; // m(dd) } - g_variant_ref_sink(signalParams[i++]); + g_variant_ref_sink(signalParams); // Send the message to every client for (auto *connection : this->connections) { diff --git a/src/gesture-controller/gesture-controller.cpp b/src/gesture-controller/gesture-controller.cpp old mode 100755 new mode 100644 index 3003735e..01d9d146 --- a/src/gesture-controller/gesture-controller.cpp +++ b/src/gesture-controller/gesture-controller.cpp @@ -86,8 +86,10 @@ void GestureController::onGestureUpdate(std::unique_ptr gesture) { void GestureController::onGestureEnd(std::unique_ptr gesture) { XYPosition curPos = gesture->endPosition(); - std::cout << "cursorEndPosition: {" << curPos.x << ", " << curPos.y << "}" << std::endl; + std::cout << "cursorEndPosition: {" << curPos.x << ", " << curPos.y << "}" + << std::endl; if (curPos.x >= 0 && curPos.y >= 0) { + // Move cursor to position where gesture ended. this->windowSystem.positionCursor(curPos.x, curPos.y); } @@ -100,23 +102,24 @@ void GestureController::onGestureEnd(std::unique_ptr gesture) { this->action.reset(); this->rotatedDirection = GestureDirection::UNKNOWN; } -//void GestureController::onGestureEnd(std::unique_ptr gesture, int cur_x, int cur_y) { -// if (this->executeAction) { -// tlg::debug << "Gesture end detected" << std::endl; -// gesture->setDirection(this->rotatedDirection); -// this->action->onGestureEnd(*gesture); -// } +// void GestureController::onGestureEnd(std::unique_ptr gesture, int +// cur_x, int cur_y) { +// if (this->executeAction) { +// tlg::debug << "Gesture end detected" << std::endl; +// gesture->setDirection(this->rotatedDirection); +// this->action->onGestureEnd(*gesture); +// } // -// this->action.reset(); -// this->rotatedDirection = GestureDirection::UNKNOWN; +// this->action.reset(); +// this->rotatedDirection = GestureDirection::UNKNOWN; // -// switch (gesture->type()) { -// case GestureType::SWIPE : -// case GestureType::TAP : -// this->windowSystem.positionCursor(cur_x, cur_y); -// break; -// } -//} +// switch (gesture->type()) { +// case GestureType::SWIPE : +// case GestureType::TAP : +// this->windowSystem.positionCursor(cur_x, cur_y); +// break; +// } +// } std::unique_ptr GestureController::getActionForGesture( const Gesture &gesture, const WindowT &window) const { @@ -151,12 +154,12 @@ std::unique_ptr GestureController::getActionForGesture( ActionType actionType = pair.first; std::unordered_map actionSettings = pair.second; - //switch (gesture.type()) { - // case GestureType::SWIPE : - // case GestureType::TAP : - // this.windowSystem.positionCursor(); - // break; - //} + // switch (gesture.type()) { + // case GestureType::SWIPE : + // case GestureType::TAP : + // this.windowSystem.positionCursor(); + // break; + // } return ActionFactory::buildAction(actionType, std::move(actionSettings), this->windowSystem, *this->window, diff --git a/src/gesture-gatherer/libinput-device-handler.cpp b/src/gesture-gatherer/libinput-device-handler.cpp index e7b6354b..44baed8e 100644 --- a/src/gesture-gatherer/libinput-device-handler.cpp +++ b/src/gesture-gatherer/libinput-device-handler.cpp @@ -122,20 +122,19 @@ void LininputDeviceHandler::calculateTouchpadThreshold( #endif double minSize = std::min(widthMm, heightMm); - outInfo->startThreshold = - ((mmToDpi(minSize) * START_PERCENTAGE) / 100); + outInfo->startThreshold = ((mmToDpi(minSize) * START_PERCENTAGE) / 100); outInfo->finishThresholdHorizontal = ((mmToDpi(widthMm) * FINISH_PERCENTAGE) / 100); outInfo->finishThresholdVertical = ((mmToDpi(heightMm) * FINISH_PERCENTAGE) / 100); } -//double LininputDeviceHandler::mmToDpi(double mm) { -// constexpr double mmInOneInch = 25.4; // 1 inch == 25.4 mm -// double inches = mm / mmInOneInch; -// double dpi = (inches * 1000); -// return dpi; -//} +// double LininputDeviceHandler::mmToDpi(double mm) { +// constexpr double mmInOneInch = 25.4; // 1 inch == 25.4 mm +// double inches = mm / mmInOneInch; +// double dpi = (inches * 1000); +// return dpi; +// } void LininputDeviceHandler::calculateTouchscreenThreshold( double widthMm, double heightMm, LibinputDeviceInfo *outInfo) { diff --git a/src/gesture-gatherer/libinput-device-handler.h b/src/gesture-gatherer/libinput-device-handler.h index 929182dd..06b550ad 100644 --- a/src/gesture-gatherer/libinput-device-handler.h +++ b/src/gesture-gatherer/libinput-device-handler.h @@ -57,7 +57,7 @@ class LininputDeviceHandler : public LininputHandler { */ static void calculateTouchpadThreshold(double widthMm, double heightMm, LibinputDeviceInfo *outInfo); - //static double mmToDpi(double mm); + // static double mmToDpi(double mm); /** * Calculates LibinputDeviceInfo on touchscreens. diff --git a/src/gesture-gatherer/libinput-gesture-gatherer.h b/src/gesture-gatherer/libinput-gesture-gatherer.h old mode 100755 new mode 100644 index 765198c3..f69dd548 --- a/src/gesture-gatherer/libinput-gesture-gatherer.h +++ b/src/gesture-gatherer/libinput-gesture-gatherer.h @@ -73,10 +73,9 @@ class LibinputGestureGatherer : public GestureGatherer { /** * libinput structure with pointers to the open/close callbacks. */ - struct libinput_interface libinputInterface { - LibinputGestureGatherer::openRestricted, - LibinputGestureGatherer::closeRestricted - }; + struct libinput_interface libinputInterface{ + LibinputGestureGatherer::openRestricted, + LibinputGestureGatherer::closeRestricted}; static int openRestricted(const char *path, int flags, void *userData); static void closeRestricted(int fd, void *userData); }; diff --git a/src/gesture-gatherer/libinput-touch-handler.cpp b/src/gesture-gatherer/libinput-touch-handler.cpp index e67e836d..17b2cd42 100644 --- a/src/gesture-gatherer/libinput-touch-handler.cpp +++ b/src/gesture-gatherer/libinput-touch-handler.cpp @@ -20,10 +20,10 @@ #include #include +#include // Debugging. #include #include #include -#include // Debugging. #include "gesture/device-type.h" #include "gesture/gesture.h" @@ -91,19 +91,20 @@ void LibinputTouchHandler::handleTouchUp(struct libinput_event *event) { : LininputHandler::calculatePinchAnimationPercentage( this->state.direction, this->getPinchDelta()); - std::cout << "Assigning current XY values: " << this->state.currentX[slot] << ", " << this->state.currentY[slot] << std::endl; - //Rectangle screenSize = + std::cout << "Assigning current XY values: " << this->state.currentX[slot] + << ", " << this->state.currentY[slot] << std::endl; + // Rectangle screenSize = auto gesture = std::make_unique( this->state.type, this->state.direction, percentage, this->state.startFingers, DeviceType::TOUCHSCREEN, elapsedTime, XYPosition{this->state.currentX[slot], this->state.currentY[slot]}); - //Rectangle { - //XYPosition{ - // libinput_event_touch_get_x(tEvent), - // libinput_event_touch_get_y(tEvent) - // libinput_event_touch_get_x_transformed(tEvent, ), - // libinput_event_touch_get_y_transformed(tEvent, ) - //}); + // Rectangle { + // XYPosition{ + // libinput_event_touch_get_x(tEvent), + // libinput_event_touch_get_y(tEvent) + // libinput_event_touch_get_x_transformed(tEvent, ), + // libinput_event_touch_get_y_transformed(tEvent, ) + // }); this->gestureController->onGestureEnd(std::move(gesture)); this->state.reset(); diff --git a/src/gesture/gesture.h b/src/gesture/gesture.h index 892d0c00..f629cd7b 100644 --- a/src/gesture/gesture.h +++ b/src/gesture/gesture.h @@ -24,15 +24,15 @@ #include "gesture/gesture-direction.h" #include "gesture/gesture-type.h" -//struct XYPosition { -// int x; -// int y; -//}; +// struct XYPosition { +// int x; +// int y; +// }; struct XYPosition { double x; double y; }; -//#include "utils/rectangle.h" +// #include "utils/rectangle.h" /** * Gestures implementations change depending on the driver/backend. This is the @@ -50,26 +50,14 @@ class Gesture { gestureElapsedTime(elapsedTime) {} Gesture(GestureType type, GestureDirection direction, double percentage, int fingers, DeviceType performedOnDeviceType, uint64_t elapsedTime, - XYPosition cursorEndPosition) + XYPosition cursorEndPosition) : gestureType(type), gestureDirection(direction), - gestureAxis(gestureAxisFromDirection(direction)), gesturePercentage(percentage), gestureFingers(fingers), deviceType(performedOnDeviceType), gestureElapsedTime(elapsedTime), - gestureEndPosition(cursorEndPosition) {} - Gesture(GestureType type, GestureDirection direction, GestureAxis axis, - double percentage, int fingers, DeviceType performedOnDeviceType, - uint64_t elapsedTime, XYPosition cursorEndPosition) - : gestureType(type), - gestureDirection(direction), - gestureAxis(axis), - gesturePercentage(percentage), - gestureFingers(fingers), - deviceType(performedOnDeviceType), - gestureElapsedTime(elapsedTime), - gestureEndPosition(cursorEndPosition) {} + gestureEndPosition(cursorEndPosition) {} /** * @returns The gesture type. @@ -126,8 +114,8 @@ class Gesture { int gestureFingers = -1; DeviceType deviceType = DeviceType::UNKNOWN; uint64_t gestureElapsedTime = -1; - XYPosition gestureEndPosition {-1, -1}; - //Rectangle cursorPosition {0, 0, 0, 0}; + XYPosition gestureEndPosition{-1, -1}; + // Rectangle cursorPosition {0, 0, 0, 0}; }; #endif // GESTURE_GESTURE_H_ diff --git a/src/window-system/x11.cpp b/src/window-system/x11.cpp index e50e3602..f8ab48b3 100644 --- a/src/window-system/x11.cpp +++ b/src/window-system/x11.cpp @@ -486,24 +486,29 @@ void X11::positionCursor(double xMm, double yMm) const { double dhMM = DisplayHeightMM(this->display, screen); double dwPixels = DisplayWidth(this->display, screen); double dhPixels = DisplayHeight(this->display, screen); - std::cout - << " Gesture offset X (mm): " << xMm << '\n' - << " Gesture offset Y (mm): " << yMm << '\n' - << " Display width (mm): " << dwMM << '\n' - << " Display height (mm): " << dhMM << '\n' - << " Display width (pixels): " << dwPixels << '\n' - << "Display height (pixels): " << dhPixels << '\n' - << std::endl; + std::cout << " Gesture offset X (mm): " << xMm << '\n' + << " Gesture offset Y (mm): " << yMm << '\n' + << " Display width (mm): " << dwMM << '\n' + << " Display height (mm): " << dhMM << '\n' + << " Display width (pixels): " << dwPixels << '\n' + << "Display height (pixels): " << dhPixels << '\n' + << std::endl; // // These need the screen structure, not I.D. integer. - //if (dwMM != WidthMMOfScreen(screen)) std::cout << "Width (mm) of screen and display do not match. Screen claims: " << WidthMMOfScreen(screen) << std::endl; - //if (dhMM != HeightMMOfScreen(screen)) std::cout << "Height (mm) of screen and display do not match. Screen claims: " << HeightMMOfScreen(screen) << std::endl; - //if (dwMM != WidthOfScreen(screen)) std::cout << "Width (pixels) of screen and display do not match. Screen claims: " << WidthOfScreen(screen) << std::endl; - //if (dhMM != HeightOfScreen(screen)) std::cout << "Height (pixels) of screen and display do not match. Screen claims: " << HeightOfScreen(screen) << std::endl; + // if (dwMM != WidthMMOfScreen(screen)) std::cout << "Width (mm) of screen and + // display do not match. Screen claims: " << WidthMMOfScreen(screen) << + // std::endl; if (dhMM != HeightMMOfScreen(screen)) std::cout << "Height (mm) + // of screen and display do not match. Screen claims: " << + // HeightMMOfScreen(screen) << std::endl; if (dwMM != WidthOfScreen(screen)) + // std::cout << "Width (pixels) of screen and display do not match. Screen + // claims: " << WidthOfScreen(screen) << std::endl; if (dhMM != + // HeightOfScreen(screen)) std::cout << "Height (pixels) of screen and display + // do not match. Screen claims: " << HeightOfScreen(screen) << std::endl; int targetX = (xMm / dwMM) * dwPixels; int targetY = (yMm / dhMM) * dhPixels; - std::cout << " Cursor target: " << targetX << ", " << targetY << std::endl; + std::cout << " Cursor target: " << targetX << ", " << targetY + << std::endl; // Get current cursor position. Window rootWindow = None; @@ -513,20 +518,30 @@ void X11::positionCursor(double xMm, double yMm) const { int childX = 0; int childY = 0; unsigned int mask = 0; - int success = XQueryPointer(this->display, XDefaultRootWindow(this->display), &rootWindow, - &childWindow, &pointerX, &pointerY, &childX, &childY, &mask); + int success = XQueryPointer(this->display, XDefaultRootWindow(this->display), + &rootWindow, &childWindow, &pointerX, &pointerY, + &childX, &childY, &mask); if (!success) { - std::cout << "Failed to query pointer. Cursor will not be repositioned." << std::endl; + std::cout << "Failed to query pointer. Cursor will not be repositioned." + << std::endl; return; } - std::cout << "Current cursor position: " << pointerX << ", " << pointerY << std::endl; + std::cout << "Current cursor position: " << pointerX << ", " << pointerY + << std::endl; // Not sure if useful. - // Move cursor to origin (0, 0). This is necessary because we are warping with relative positioning, irrespective of windows. - //XWarpPointer(this->display, None, None, 0, 0, 0, 0, -pointerX, -pointerY); - //XWarpPointer(this->display, None, None, 0, 0, 0, 0, targetX, targetY); - - XWarpPointer(this->display, None, None, 0, 0, 0, 0, targetX - pointerX, targetY - pointerY); + // Move cursor to origin (0, 0). This is necessary because we are warping with + // relative positioning, irrespective of windows. + // XWarpPointer(this->display, None, None, 0, 0, 0, 0, -pointerX, -pointerY); + // XWarpPointer(this->display, None, None, 0, 0, 0, 0, targetX, targetY); + + //targetX = targetX > pointerX ? targetX - pointerX : pointerX - targetX; + //targetY = targetY > pointerY ? targetY - pointerY : pointerY - targetY; + targetX = targetX - pointerX; + targetY = targetY - pointerY; + std::cout << " Relative distance: " << targetX << ", " << targetY + << std::endl; + XWarpPointer(this->display, None, None, 0, 0, 0, 0, targetX, targetY); XFlush(this->display); } diff --git a/src/window-system/x11.h b/src/window-system/x11.h index b07a3c51..22fe710d 100644 --- a/src/window-system/x11.h +++ b/src/window-system/x11.h @@ -28,8 +28,8 @@ #include #include -#include "window-system/window-system.h" #include "utils/pixel-conversions.h" +#include "window-system/window-system.h" /** * X11 WindowT implementation, just a Window as defined in . @@ -71,7 +71,6 @@ class X11 : public WindowSystem { void sendMouseUp(int button) const override; void positionCursor(double x, double y) const override; - Rectangle getDesktopWorkarea() const override; void changeDesktop(ActionDirection direction, bool cyclic) const override; void showDesktop(bool show) const override; From 10514e566370cdcb7eae153f3e703f1683a76826 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Sun, 8 Jun 2025 19:46:55 -0700 Subject: [PATCH 03/15] Made repositioning of cursor optional. --- src/config/config.cpp | 1 + src/gesture-controller/gesture-controller.cpp | 7 +++++-- src/gesture-controller/gesture-controller.h | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/config/config.cpp b/src/config/config.cpp index 666aaaa7..222dc45d 100755 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -73,6 +73,7 @@ Config::getGestureConfig(const std::string &application, void Config::loadDefaultGlobalSettings() { this->globalSettings["animation_delay"] = "150"; this->globalSettings["action_execute_threshold"] = "20"; + this->globalSettings["reposition_cursor"] = "false"; } std::string Config::getConfigKey(const std::string &application, diff --git a/src/gesture-controller/gesture-controller.cpp b/src/gesture-controller/gesture-controller.cpp index 01d9d146..ecac1313 100644 --- a/src/gesture-controller/gesture-controller.cpp +++ b/src/gesture-controller/gesture-controller.cpp @@ -33,7 +33,7 @@ GestureController::GestureController(const Config &config, const WindowSystem &windowSystem) - : config(config), windowSystem(windowSystem) {} + : config(config), windowSystem(windowSystem), repositionCursor(config.getGlobalSetting("reposition_cursor") == "true") {} void GestureController::onGestureBegin(std::unique_ptr gesture) { tlg::debug << "Gesture begin detected" << std::endl; @@ -88,7 +88,10 @@ void GestureController::onGestureEnd(std::unique_ptr gesture) { XYPosition curPos = gesture->endPosition(); std::cout << "cursorEndPosition: {" << curPos.x << ", " << curPos.y << "}" << std::endl; - if (curPos.x >= 0 && curPos.y >= 0) { + if ( + repositionCursor && + curPos.x >= 0 && curPos.y >= 0 + ) { // Move cursor to position where gesture ended. this->windowSystem.positionCursor(curPos.x, curPos.y); } diff --git a/src/gesture-controller/gesture-controller.h b/src/gesture-controller/gesture-controller.h index e9dc6bdc..9179a1b5 100755 --- a/src/gesture-controller/gesture-controller.h +++ b/src/gesture-controller/gesture-controller.h @@ -44,6 +44,8 @@ class GestureController : public GestureControllerDelegate { const Config &config; const WindowSystem &windowSystem; + bool repositionCursor; + /** * The action to perform. */ From 8b35243d82cd4d78d4a80b9d51000653ae0a0e09 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Sun, 8 Jun 2025 22:54:09 -0700 Subject: [PATCH 04/15] Support repositioning cursor on gesture end, update, both, or neither. --- src/config/config.cpp | 2 +- src/daemon/daemon-client.cpp | 56 +++++++------- src/daemon/daemon-server.cpp | 20 +++-- src/daemon/dbus.h | 9 +++ src/gesture-controller/gesture-controller.cpp | 75 +++++++++++-------- src/gesture-controller/gesture-controller.h | 5 +- .../libinput-touch-handler.cpp | 3 +- src/gesture/gesture.h | 6 +- src/utils/reposition-cursor.cpp | 6 ++ src/utils/reposition-cursor.h | 37 +++++++++ src/window-system/x11.cpp | 2 +- 11 files changed, 144 insertions(+), 77 deletions(-) create mode 100644 src/utils/reposition-cursor.cpp create mode 100644 src/utils/reposition-cursor.h diff --git a/src/config/config.cpp b/src/config/config.cpp index 222dc45d..f0b6cd3e 100755 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -73,7 +73,7 @@ Config::getGestureConfig(const std::string &application, void Config::loadDefaultGlobalSettings() { this->globalSettings["animation_delay"] = "150"; this->globalSettings["action_execute_threshold"] = "20"; - this->globalSettings["reposition_cursor"] = "false"; + this->globalSettings["reposition_cursor"] = "0"; // Never (none). } std::string Config::getConfigKey(const std::string &application, diff --git a/src/daemon/daemon-client.cpp b/src/daemon/daemon-client.cpp index a68e2d15..37de9148 100644 --- a/src/daemon/daemon-client.cpp +++ b/src/daemon/daemon-client.cpp @@ -126,8 +126,8 @@ std::unique_ptr DaemonClient::makeGestureFromSignalParams( int fingers = -1; DeviceType deviceType = DeviceType::UNKNOWN; uint64_t elapsedTime = -1; - XYPosition endPosition = {-1, -1}; - double endPositionX = -2, endPositionY = -2; + XYPosition cursorPosition = {-1, -1}; + double cursorPositionX = -2, cursorPositionY = -2; if (g_variant_check_format_string(signalParameters, "(uudiut)", false)) { g_variant_get(signalParameters, // NOLINT @@ -144,26 +144,26 @@ std::unique_ptr DaemonClient::makeGestureFromSignalParams( //&percentage, &fingers, "(uudiutdd)", &type, &direction, &percentage, &fingers, //"(uudiut(dd))", &type, &direction, &percentage, &fingers, - //&deviceType, &elapsedTime, &endPosition); - //&deviceType, &elapsedTime, &(endPosition.x), &(endPosition.y)); - &deviceType, &elapsedTime, &endPositionX, &endPositionY); + //&deviceType, &elapsedTime, &cursorPosition); + //&deviceType, &elapsedTime, &(cursorPosition.x), &(cursorPosition.y)); + &deviceType, &elapsedTime, &cursorPositionX, &cursorPositionY); //"(uudiutm*)", &type, &direction, &percentage, &fingers, //&deviceType, &elapsedTime, &maybeEndPosition); //"(uudiutm(dd))", &type, &direction, &percentage, &fingers - //&deviceType, &elapsedTime, &maybeEndPosition, &endPositionX, - //&endPositionY); + //&deviceType, &elapsedTime, &maybeEndPosition, &cursorPositionX, + //&cursorPositionY); // if (maybeEndPosition != NULL) { - // g_variant_get(maybeEndPosition, "(dd)", &endPositionX, &endPositionY); - // endPosition.x = endPositionX; - // endPosition.y = endPositionY; + // g_variant_get(maybeEndPosition, "(dd)", &cursorPositionX, &cursorPositionY); + // cursorPosition.x = cursorPositionX; + // cursorPosition.y = cursorPositionY; // g_variant_unref(maybeEndPosition); // } // if (maybeEndPosition) { - endPosition.x = endPositionX; - endPosition.y = endPositionY; + cursorPosition.x = cursorPositionX; + cursorPosition.y = cursorPositionY; //} - std::cout << "Got endPosition (from signal): " << endPosition.x << ", " - << endPosition.y << std::endl; + std::cout << "Got cursorPosition (from signal): " << cursorPosition.x << ", " + << cursorPosition.y << std::endl; } // if (g_variant_check_format_string(signalParameters, "(uudiutdd)", false)) // { @@ -178,29 +178,29 @@ std::unique_ptr DaemonClient::makeGestureFromSignalParams( // "(uudiutdd)", &type, &direction, &percentage, &fingers, // //"(uudiut(dd))", &type, &direction, &percentage, //&fingers, - // //&deviceType, &elapsedTime, &endPosition); - // //&deviceType, &elapsedTime, &(endPosition.x), - //&(endPosition.y)); &deviceType, &elapsedTime, &endPositionX, - //&endPositionY); + // //&deviceType, &elapsedTime, &cursorPosition); + // //&deviceType, &elapsedTime, &(cursorPosition.x), + //&(cursorPosition.y)); &deviceType, &elapsedTime, &cursorPositionX, + //&cursorPositionY); // //"(uudiutm*)", &type, &direction, &percentage, //&fingers, // //&deviceType, &elapsedTime, &maybeEndPosition); // //"(uudiutm(dd))", &type, &direction, &percentage, //&fingers, - // //&deviceType, &elapsedTime, &maybeEndPosition, &endPositionX, - //&endPositionY); + // //&deviceType, &elapsedTime, &maybeEndPosition, &cursorPositionX, + //&cursorPositionY); // //if (maybeEndPosition != NULL) { - // // g_variant_get(maybeEndPosition, "(dd)", &endPositionX, &endPositionY); - // // endPosition.x = endPositionX; - // // endPosition.y = endPositionY; + // // g_variant_get(maybeEndPosition, "(dd)", &cursorPositionX, &cursorPositionY); + // // cursorPosition.x = cursorPositionX; + // // cursorPosition.y = cursorPositionY; // // g_variant_unref(maybeEndPosition); // //} // //if (maybeEndPosition) { - // endPosition.x = endPositionX; - // endPosition.y = endPositionY; + // cursorPosition.x = cursorPositionX; + // cursorPosition.y = cursorPositionY; // //} - // std::cout << "Got endPosition (from signal): " << endPosition.x << ", " << - // endPosition.y << std::endl; + // std::cout << "Got cursorPosition (from signal): " << cursorPosition.x << ", " << + // cursorPosition.y << std::endl; //} else { // g_variant_get(signalParameters, // NOLINT // "(uudiut)", &type, &direction, &percentage, &fingers, @@ -208,5 +208,5 @@ std::unique_ptr DaemonClient::makeGestureFromSignalParams( //} return std::make_unique(type, direction, percentage, fingers, - deviceType, elapsedTime, endPosition); + deviceType, elapsedTime, cursorPosition); } diff --git a/src/daemon/daemon-server.cpp b/src/daemon/daemon-server.cpp index 14ab976c..3f8bacad 100644 --- a/src/daemon/daemon-server.cpp +++ b/src/daemon/daemon-server.cpp @@ -115,11 +115,15 @@ void DaemonServer::send(const std::string &signalName, std::vector closedConnections{}; // Copy every gesture field into the signal parameters for serialization - // if (gesture->endPosition().x > -1 || gesture->endPosition().y > -1) { + // if (gesture->cursorPosition().x > -1 || gesture->cursorPosition().y > -1) { GVariant *signalParams; - if (signalName == DBUS_ON_GESTURE_END) { - std::cout << "Emitting signal with endPosition: " - << gesture->endPosition().x << ", " << gesture->endPosition().y + //if (signalName == DBUS_ON_GESTURE_END) { + if ( + signalName == DBUS_ON_GESTURE_END + || signalName == DBUS_ON_GESTURE_UPDATE + ) { + std::cout << "Emitting signal with cursorPosition: " + << gesture->cursorPosition().x << ", " << gesture->cursorPosition().y << std::endl; signalParams = { // g_variant_new("(uudiutuu)", // NOLINT @@ -135,13 +139,13 @@ void DaemonServer::send(const std::string &signalName, gesture->fingers(), // i static_cast(gesture->performedOnDeviceType()), // u gesture->elapsedTime(), // t - // gesture->endPosition())}; // dd - // gesture->endPosition())}; // m@(dd) + // gesture->cursorPosition())}; // dd + // gesture->cursorPosition())}; // m@(dd) // // Currently always send. Make optional. // TRUE, // m // Currently always // send. Make optional. - gesture->endPosition().x, // d - gesture->endPosition().y)}; // d + gesture->cursorPosition().x, // d + gesture->cursorPosition().y)}; // d } else { signalParams = {g_variant_new( "(uudiut)", // NOLINT diff --git a/src/daemon/dbus.h b/src/daemon/dbus.h index 2e6da1e2..a1b82d0f 100644 --- a/src/daemon/dbus.h +++ b/src/daemon/dbus.h @@ -50,6 +50,15 @@ constexpr auto DBUS_INTROSPECTION_XML = " " " " " " + //" " + //" " + " " + //" " + //" " + //" " + //" " + //" " + //" " " " " " " " diff --git a/src/gesture-controller/gesture-controller.cpp b/src/gesture-controller/gesture-controller.cpp index ecac1313..fc20793a 100644 --- a/src/gesture-controller/gesture-controller.cpp +++ b/src/gesture-controller/gesture-controller.cpp @@ -33,7 +33,30 @@ GestureController::GestureController(const Config &config, const WindowSystem &windowSystem) - : config(config), windowSystem(windowSystem), repositionCursor(config.getGlobalSetting("reposition_cursor") == "true") {} + : config(config), windowSystem(windowSystem), + //repositionCursor(std::stoi(config.getGlobalSetting("reposition_cursor"))) {} + repositionCursor(static_cast(std::stoi(config.getGlobalSetting("reposition_cursor")))) {} +// : config(config), windowSystem(windowSystem) { +// // Aggregate bitmask values for repositionCursor. +// const RepositionCursorOpt buffer = static_cast(std::stoi(config.getGlobalSetting("reposition_cursor"))); +// for (auto i = 0; i < 8*sizeof(RepositionCursorOpt); i++) { +// //for (RepositionCursorOpt i = static_cast(0); i < 8*sizeof(RepositionCursorOpt); i++) { +// //repositionCursor += (buffer & i); +// //repositionCursor += static_cast(buffer & i); +// //repositionCursor = static_cast(buffer & i) | repositionCursor; +// //repositionCursor += reinterpret_cast(buffer & i); +// //repositionCursor += (RepositionCursorOpt)(buffer & i); +// //repositionCursor += (RepositionCursorOpt)((buffer & i) | RepositionCursorOpt::NEVER); +// //repositionCursor += buffer & (1<(1); +// //repositionCursor |= static_cast(buffer & i); +// //repositionCursor |= reinterpret_cast(buffer & i); +// //repositionCursor |= (RepositionCursorOpt)(buffer & i); +// //repositionCursor <<= (buffer & i); +// //repositionCursor <<= (RepositionCursorOpt)((buffer & (RepositionCursorOpt)(i))); +// } +//} void GestureController::onGestureBegin(std::unique_ptr gesture) { tlg::debug << "Gesture begin detected" << std::endl; @@ -76,6 +99,18 @@ void GestureController::onGestureBegin(std::unique_ptr gesture) { } void GestureController::onGestureUpdate(std::unique_ptr gesture) { + // Move cursor to gesture update position, if setting is enabled. + XYPosition curPos = gesture->cursorPosition(); + if ( + (repositionCursor & RepositionCursorOpt::GESTURE_UPDATE) + && (curPos.x >= 0 && curPos.y >= 0) + ) { + tlg::debug << "cursorPosition (GestureUpdate): {" + << curPos.x << ", " << curPos.y + << "}" << std::endl; + this->windowSystem.positionCursor(curPos.x, curPos.y); + } + if (this->executeAction) { tlg::debug << "Gesture update detected (" << gesture->percentage() << "%)" << std::endl; @@ -85,14 +120,15 @@ void GestureController::onGestureUpdate(std::unique_ptr gesture) { } void GestureController::onGestureEnd(std::unique_ptr gesture) { - XYPosition curPos = gesture->endPosition(); - std::cout << "cursorEndPosition: {" << curPos.x << ", " << curPos.y << "}" - << std::endl; + // Move cursor to position where gesture ended, if setting is enabled. + XYPosition curPos = gesture->cursorPosition(); if ( - repositionCursor && - curPos.x >= 0 && curPos.y >= 0 + (repositionCursor & RepositionCursorOpt::GESTURE_END) + && (curPos.x >= 0 && curPos.y >= 0) ) { - // Move cursor to position where gesture ended. + tlg::debug << "cursorPosition (GestureEnd): {" + << curPos.x << ", " << curPos.y + << "}" << std::endl; this->windowSystem.positionCursor(curPos.x, curPos.y); } @@ -105,24 +141,6 @@ void GestureController::onGestureEnd(std::unique_ptr gesture) { this->action.reset(); this->rotatedDirection = GestureDirection::UNKNOWN; } -// void GestureController::onGestureEnd(std::unique_ptr gesture, int -// cur_x, int cur_y) { -// if (this->executeAction) { -// tlg::debug << "Gesture end detected" << std::endl; -// gesture->setDirection(this->rotatedDirection); -// this->action->onGestureEnd(*gesture); -// } -// -// this->action.reset(); -// this->rotatedDirection = GestureDirection::UNKNOWN; -// -// switch (gesture->type()) { -// case GestureType::SWIPE : -// case GestureType::TAP : -// this->windowSystem.positionCursor(cur_x, cur_y); -// break; -// } -// } std::unique_ptr GestureController::getActionForGesture( const Gesture &gesture, const WindowT &window) const { @@ -157,13 +175,6 @@ std::unique_ptr GestureController::getActionForGesture( ActionType actionType = pair.first; std::unordered_map actionSettings = pair.second; - // switch (gesture.type()) { - // case GestureType::SWIPE : - // case GestureType::TAP : - // this.windowSystem.positionCursor(); - // break; - // } - return ActionFactory::buildAction(actionType, std::move(actionSettings), this->windowSystem, *this->window, this->config); diff --git a/src/gesture-controller/gesture-controller.h b/src/gesture-controller/gesture-controller.h index 9179a1b5..3a1d98c2 100755 --- a/src/gesture-controller/gesture-controller.h +++ b/src/gesture-controller/gesture-controller.h @@ -22,6 +22,7 @@ #include "actions/action.h" #include "gesture-controller/gesture-controller-delegate.h" +#include "utils/reposition-cursor.h" class Config; class Gesture; class WindowSystem; @@ -44,7 +45,9 @@ class GestureController : public GestureControllerDelegate { const Config &config; const WindowSystem &windowSystem; - bool repositionCursor; + // Setting values cached for efficient access: + //RepositionCursorOpt repositionCursor; + RepositionCursorOpt repositionCursor; // Bitmask. /** * The action to perform. diff --git a/src/gesture-gatherer/libinput-touch-handler.cpp b/src/gesture-gatherer/libinput-touch-handler.cpp index 17b2cd42..aafa86ba 100644 --- a/src/gesture-gatherer/libinput-touch-handler.cpp +++ b/src/gesture-gatherer/libinput-touch-handler.cpp @@ -164,7 +164,8 @@ void LibinputTouchHandler::handleTouchMotion(struct libinput_event *event) { auto gesture = std::make_unique( this->state.type, this->state.direction, percentage, - this->state.startFingers, DeviceType::TOUCHSCREEN, elapsedTime); + this->state.startFingers, DeviceType::TOUCHSCREEN, elapsedTime, + XYPosition{this->state.currentX[slot], this->state.currentY[slot]}); this->gestureController->onGestureUpdate(std::move(gesture)); } } diff --git a/src/gesture/gesture.h b/src/gesture/gesture.h index f629cd7b..ff9ef6ff 100644 --- a/src/gesture/gesture.h +++ b/src/gesture/gesture.h @@ -24,10 +24,6 @@ #include "gesture/gesture-direction.h" #include "gesture/gesture-type.h" -// struct XYPosition { -// int x; -// int y; -// }; struct XYPosition { double x; double y; @@ -97,7 +93,7 @@ class Gesture { * Position to set cursor when gesture ends.. * @returns A struct containing X and Y position integers. */ - XYPosition endPosition() const { return this->gestureEndPosition; } + XYPosition cursorPosition() const { return this->gestureEndPosition; } /** * Set the gesture direction. diff --git a/src/utils/reposition-cursor.cpp b/src/utils/reposition-cursor.cpp new file mode 100644 index 00000000..12a27493 --- /dev/null +++ b/src/utils/reposition-cursor.cpp @@ -0,0 +1,6 @@ +#include "reposition-cursor.h" + +bool RepositionCursor::isDefined() { + return (x >= 0 && y >= 0); +}; + diff --git a/src/utils/reposition-cursor.h b/src/utils/reposition-cursor.h new file mode 100644 index 00000000..ad06eca4 --- /dev/null +++ b/src/utils/reposition-cursor.h @@ -0,0 +1,37 @@ +#ifndef UTILS_REPOSITION_CURSOR_H_ +#define UTILS_REPOSITION_CURSOR_H_ + +// Bitmask representing options for when cursor should be repositioned. +enum RepositionCursorOpt { + NEVER = 0b00, // 0 + GESTURE_END = 0b01, // 1 + GESTURE_UPDATE = 0b10 // 2 + //GESTURE_UPDATE_AND_END = 0b11 // 3 +}; + +//bool operator!(RepositionCursorOpt e) { +// return e == static_cast(0); +//} +//bool operator!(RepositionCursorOpt e) { +// return e == static_cast(0); +//} +//inline RepositionCursorOpt operator|(RepositionCursorOpt a, RepositionCursorOpt b) { +// return static_cast(static_cast(a) | static_cast(b)); +//} +//inline RepositionCursorOpt operator&(RepositionCursorOpt a, RepositionCursorOpt b) { +// return static_cast(static_cast(a) & static_cast(b)); +//} +//inline RepositionCursorOpt operator+(RepositionCursorOpt a, RepositionCursorOpt b) { +// return static_cast(static_cast(a) + static_cast(b)); +//} + +/*class CursorPosition { + public: + // Absolute position on display in millimeters. + double x; + double y; + + bool isDefined(); +};*/ + +#endif // UTILS_REPOSITION_CURSOR_H_ diff --git a/src/window-system/x11.cpp b/src/window-system/x11.cpp index f8ab48b3..0ce76783 100644 --- a/src/window-system/x11.cpp +++ b/src/window-system/x11.cpp @@ -539,7 +539,7 @@ void X11::positionCursor(double xMm, double yMm) const { //targetY = targetY > pointerY ? targetY - pointerY : pointerY - targetY; targetX = targetX - pointerX; targetY = targetY - pointerY; - std::cout << " Relative distance: " << targetX << ", " << targetY + std::cout << " Relative distance: " << targetX << ", " << targetY << std::endl; XWarpPointer(this->display, None, None, 0, 0, 0, 0, targetX, targetY); XFlush(this->display); From 3f0d22dafcc21fb7e77601c7c98e5278ed074e9d Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Sun, 8 Jun 2025 23:09:13 -0700 Subject: [PATCH 05/15] Centralised gesture type check for cursor repositioning. --- .../.gesture-controller.cpp.swp | Bin 0 -> 24576 bytes src/gesture-controller/gesture-controller.cpp | 4 ++-- src/utils/.reposition-cursor.h.swp | Bin 0 -> 12288 bytes src/utils/reposition-cursor.h | 12 ++++++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/gesture-controller/.gesture-controller.cpp.swp create mode 100644 src/utils/.reposition-cursor.h.swp diff --git a/src/gesture-controller/.gesture-controller.cpp.swp b/src/gesture-controller/.gesture-controller.cpp.swp new file mode 100644 index 0000000000000000000000000000000000000000..7e0452f6d02d371f0e4d6c87c2fcac08244d4303 GIT binary patch literal 24576 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 gesture) { XYPosition curPos = gesture->cursorPosition(); if ( (repositionCursor & RepositionCursorOpt::GESTURE_UPDATE) - && (curPos.x >= 0 && curPos.y >= 0) + && gestureTypeSupportsCursorReposition(gesture->type()) ) { tlg::debug << "cursorPosition (GestureUpdate): {" << curPos.x << ", " << curPos.y @@ -124,7 +124,7 @@ void GestureController::onGestureEnd(std::unique_ptr gesture) { XYPosition curPos = gesture->cursorPosition(); if ( (repositionCursor & RepositionCursorOpt::GESTURE_END) - && (curPos.x >= 0 && curPos.y >= 0) + && gestureTypeSupportsCursorReposition(gesture->type()) ) { tlg::debug << "cursorPosition (GestureEnd): {" << curPos.x << ", " << curPos.y diff --git a/src/utils/.reposition-cursor.h.swp b/src/utils/.reposition-cursor.h.swp new file mode 100644 index 0000000000000000000000000000000000000000..6c5e5bd030fd2437efaa53c05870135b22810688 GIT binary patch literal 12288 zcmeI2O>YxN7{`Ymkiu(4RUyP>NF?L{@vaF6NC=W4F16G;u3yrlwJ&4uzrz4JWt_8ZSiPR6y@ z>tFISnrVOk#*Q_KGjfX_RM=kdLGq#GF^17v^< zkO4A42FL&zAOmE843Ggb@E#g)e8$8KW7S<4JpTVb{{8=WKVuKU1Moe#2O3}z90vdH zW9&EZ0Ne+^fJ@*ja0(m(JHg+38T$kL4xWI=;Ae0XTmwyT7#swT_Au55F4zrz+RfOH zU>*E}@%;t<1W&-P;0JIQ+yS@25CmWV^7*`n>p?>%17v^YR$EFy;EOn^e%K;?X_0#^B!ZH%f~Fnak)x`TC;igwb-01O(w_)1ds?ImL;PQ^W#%m;wl!2V^ngyG%f0!m|Dr5$EaV=ppU-FppU+#LEm_lLEm`kK^I>R z!Bvfx})lRKfZLIccjn$bIZo8Gr47T?ohO;$k zW)!uv=*fv_R&NxuD<`sG1;Ivbz1Bi;UdOica+`@L9Zub&*#_n3r5QT}K2 z8eq$3N7*&+tAt+(M8rpj+PMx?8v5K7S$gqy5`G!Sb7ka(sW13!F?FlBFBq&tIhaL? SpT9z1^wyn|{RmkvO8E~GYcRh6 literal 0 HcmV?d00001 diff --git a/src/utils/reposition-cursor.h b/src/utils/reposition-cursor.h index ad06eca4..9f985936 100644 --- a/src/utils/reposition-cursor.h +++ b/src/utils/reposition-cursor.h @@ -1,6 +1,8 @@ #ifndef UTILS_REPOSITION_CURSOR_H_ #define UTILS_REPOSITION_CURSOR_H_ +#include "gesture/gesture-type.h" + // Bitmask representing options for when cursor should be repositioned. enum RepositionCursorOpt { NEVER = 0b00, // 0 @@ -9,6 +11,16 @@ enum RepositionCursorOpt { //GESTURE_UPDATE_AND_END = 0b11 // 3 }; +inline bool gestureTypeSupportsCursorReposition(GestureType gestureType) { + switch (gestureType) { + case GestureType::SWIPE: + case GestureType::TAP: + return true; + default: + return false; + } +}; + //bool operator!(RepositionCursorOpt e) { // return e == static_cast(0); //} From 387d22151e5a8ec65237611aa6bf58eda50f9720 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Mon, 9 Jun 2025 15:13:51 -0700 Subject: [PATCH 06/15] Use textual setting value in config file. --- src/config/config.cpp | 2 +- src/gesture-controller/gesture-controller.cpp | 24 +------- src/utils/reposition-cursor.cpp | 6 -- src/utils/reposition-cursor.h | 56 ++++++++++--------- 4 files changed, 33 insertions(+), 55 deletions(-) delete mode 100644 src/utils/reposition-cursor.cpp diff --git a/src/config/config.cpp b/src/config/config.cpp index f0b6cd3e..5d9e4681 100755 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -73,7 +73,7 @@ Config::getGestureConfig(const std::string &application, void Config::loadDefaultGlobalSettings() { this->globalSettings["animation_delay"] = "150"; this->globalSettings["action_execute_threshold"] = "20"; - this->globalSettings["reposition_cursor"] = "0"; // Never (none). + this->globalSettings["reposition_cursor"] = "NEVER"; } std::string Config::getConfigKey(const std::string &application, diff --git a/src/gesture-controller/gesture-controller.cpp b/src/gesture-controller/gesture-controller.cpp index 43112161..83969aad 100644 --- a/src/gesture-controller/gesture-controller.cpp +++ b/src/gesture-controller/gesture-controller.cpp @@ -34,29 +34,7 @@ GestureController::GestureController(const Config &config, const WindowSystem &windowSystem) : config(config), windowSystem(windowSystem), - //repositionCursor(std::stoi(config.getGlobalSetting("reposition_cursor"))) {} - repositionCursor(static_cast(std::stoi(config.getGlobalSetting("reposition_cursor")))) {} -// : config(config), windowSystem(windowSystem) { -// // Aggregate bitmask values for repositionCursor. -// const RepositionCursorOpt buffer = static_cast(std::stoi(config.getGlobalSetting("reposition_cursor"))); -// for (auto i = 0; i < 8*sizeof(RepositionCursorOpt); i++) { -// //for (RepositionCursorOpt i = static_cast(0); i < 8*sizeof(RepositionCursorOpt); i++) { -// //repositionCursor += (buffer & i); -// //repositionCursor += static_cast(buffer & i); -// //repositionCursor = static_cast(buffer & i) | repositionCursor; -// //repositionCursor += reinterpret_cast(buffer & i); -// //repositionCursor += (RepositionCursorOpt)(buffer & i); -// //repositionCursor += (RepositionCursorOpt)((buffer & i) | RepositionCursorOpt::NEVER); -// //repositionCursor += buffer & (1<(1); -// //repositionCursor |= static_cast(buffer & i); -// //repositionCursor |= reinterpret_cast(buffer & i); -// //repositionCursor |= (RepositionCursorOpt)(buffer & i); -// //repositionCursor <<= (buffer & i); -// //repositionCursor <<= (RepositionCursorOpt)((buffer & (RepositionCursorOpt)(i))); -// } -//} + repositionCursor(repositionCursorOptFromStr(config.getGlobalSetting("reposition_cursor"))) {} void GestureController::onGestureBegin(std::unique_ptr gesture) { tlg::debug << "Gesture begin detected" << std::endl; diff --git a/src/utils/reposition-cursor.cpp b/src/utils/reposition-cursor.cpp deleted file mode 100644 index 12a27493..00000000 --- a/src/utils/reposition-cursor.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "reposition-cursor.h" - -bool RepositionCursor::isDefined() { - return (x >= 0 && y >= 0); -}; - diff --git a/src/utils/reposition-cursor.h b/src/utils/reposition-cursor.h index 9f985936..a56ed70b 100644 --- a/src/utils/reposition-cursor.h +++ b/src/utils/reposition-cursor.h @@ -1,14 +1,15 @@ #ifndef UTILS_REPOSITION_CURSOR_H_ #define UTILS_REPOSITION_CURSOR_H_ +#include #include "gesture/gesture-type.h" // Bitmask representing options for when cursor should be repositioned. enum RepositionCursorOpt { NEVER = 0b00, // 0 GESTURE_END = 0b01, // 1 - GESTURE_UPDATE = 0b10 // 2 - //GESTURE_UPDATE_AND_END = 0b11 // 3 + GESTURE_UPDATE = 0b10, // 2 + GESTURE_UPDATE_AND_END = 0b11 // 3 }; inline bool gestureTypeSupportsCursorReposition(GestureType gestureType) { @@ -21,29 +22,34 @@ inline bool gestureTypeSupportsCursorReposition(GestureType gestureType) { } }; -//bool operator!(RepositionCursorOpt e) { -// return e == static_cast(0); -//} -//bool operator!(RepositionCursorOpt e) { -// return e == static_cast(0); -//} -//inline RepositionCursorOpt operator|(RepositionCursorOpt a, RepositionCursorOpt b) { -// return static_cast(static_cast(a) | static_cast(b)); -//} -//inline RepositionCursorOpt operator&(RepositionCursorOpt a, RepositionCursorOpt b) { -// return static_cast(static_cast(a) & static_cast(b)); -//} -//inline RepositionCursorOpt operator+(RepositionCursorOpt a, RepositionCursorOpt b) { -// return static_cast(static_cast(a) + static_cast(b)); -//} - -/*class CursorPosition { - public: - // Absolute position on display in millimeters. - double x; - double y; +inline std::string repositionCursorOptToStr(RepositionCursorOpt repositionCursorOpt) { + switch (repositionCursorOpt) { + case RepositionCursorOpt::NEVER: + return "NEVER"; + case RepositionCursorOpt::GESTURE_END: + return "GESTURE_END"; + case RepositionCursorOpt::GESTURE_UPDATE: + return "GESTURE_UPDATE"; + case RepositionCursorOpt::GESTURE_UPDATE_AND_END: + return "GESTURE_UPDATE_AND_END"; + default: + return "NEVER"; + } +} - bool isDefined(); -};*/ +inline RepositionCursorOpt repositionCursorOptFromStr(const std::string &str) { + constexpr auto prefixLength = sizeof("GESTURE_")-1; // -1 for terminating null. + if (!str.compare(prefixLength, std::string::npos, "END")) { + return RepositionCursorOpt::GESTURE_END; + } + if (!str.compare(prefixLength, std::string::npos, "UPDATE")) { + return RepositionCursorOpt::GESTURE_UPDATE; + } + if (!str.compare(prefixLength, std::string::npos, "UPDATE_AND_END")) { + return RepositionCursorOpt::GESTURE_UPDATE_AND_END; + } + // Consider warning user if (str != "NEVER") ... + return RepositionCursorOpt::NEVER; +} #endif // UTILS_REPOSITION_CURSOR_H_ From 6e29be7c5dab4c9a883d85713120710827ed9248 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Mon, 9 Jun 2025 19:32:09 -0700 Subject: [PATCH 07/15] Clean-up: D-bus does not yet support nullable types. --- src/daemon/daemon-client.cpp | 72 +----------------------------------- src/daemon/daemon-server.cpp | 29 +++------------ src/daemon/dbus.h | 20 +--------- 3 files changed, 9 insertions(+), 112 deletions(-) diff --git a/src/daemon/daemon-client.cpp b/src/daemon/daemon-client.cpp index 37de9148..561b532c 100644 --- a/src/daemon/daemon-client.cpp +++ b/src/daemon/daemon-client.cpp @@ -127,85 +127,17 @@ std::unique_ptr DaemonClient::makeGestureFromSignalParams( DeviceType deviceType = DeviceType::UNKNOWN; uint64_t elapsedTime = -1; XYPosition cursorPosition = {-1, -1}; - double cursorPositionX = -2, cursorPositionY = -2; if (g_variant_check_format_string(signalParameters, "(uudiut)", false)) { g_variant_get(signalParameters, // NOLINT "(uudiut)", &type, &direction, &percentage, &fingers, &deviceType, &elapsedTime); } else { - // GVariant *maybeEndPosition; - gboolean maybeEndPosition; g_variant_get( signalParameters, // NOLINT - //"(uudiutuu)", &type, &direction, - //&percentage, &fingers, - //"(uudiutx)", &type, &direction, - //&percentage, &fingers, - "(uudiutdd)", &type, &direction, &percentage, &fingers, - //"(uudiut(dd))", &type, &direction, &percentage, &fingers, - //&deviceType, &elapsedTime, &cursorPosition); - //&deviceType, &elapsedTime, &(cursorPosition.x), &(cursorPosition.y)); - &deviceType, &elapsedTime, &cursorPositionX, &cursorPositionY); - //"(uudiutm*)", &type, &direction, &percentage, &fingers, - //&deviceType, &elapsedTime, &maybeEndPosition); - //"(uudiutm(dd))", &type, &direction, &percentage, &fingers - //&deviceType, &elapsedTime, &maybeEndPosition, &cursorPositionX, - //&cursorPositionY); - // if (maybeEndPosition != NULL) { - // g_variant_get(maybeEndPosition, "(dd)", &cursorPositionX, &cursorPositionY); - // cursorPosition.x = cursorPositionX; - // cursorPosition.y = cursorPositionY; - // g_variant_unref(maybeEndPosition); - // } - // if (maybeEndPosition) { - cursorPosition.x = cursorPositionX; - cursorPosition.y = cursorPositionY; - //} - std::cout << "Got cursorPosition (from signal): " << cursorPosition.x << ", " - << cursorPosition.y << std::endl; + "(uudiut(dd))", &type, &direction, &percentage, &fingers, + &deviceType, &elapsedTime, &(cursorPosition.x), &(cursorPosition.y)); } - // if (g_variant_check_format_string(signalParameters, "(uudiutdd)", false)) - // { - ////if (!g_variant_check_format_string(signalParameters, "(uudiutdd)", - /// false)) { - // //GVariant *maybeEndPosition; - // gboolean maybeEndPosition; - // g_variant_get(signalParameters, // NOLINT - // //"(uudiutuu)", &type, &direction, &percentage, - //&fingers, - // //"(uudiutx)", &type, &direction, &percentage, &fingers, - // "(uudiutdd)", &type, &direction, &percentage, &fingers, - // //"(uudiut(dd))", &type, &direction, &percentage, - //&fingers, - // //&deviceType, &elapsedTime, &cursorPosition); - // //&deviceType, &elapsedTime, &(cursorPosition.x), - //&(cursorPosition.y)); &deviceType, &elapsedTime, &cursorPositionX, - //&cursorPositionY); - // //"(uudiutm*)", &type, &direction, &percentage, - //&fingers, - // //&deviceType, &elapsedTime, &maybeEndPosition); - // //"(uudiutm(dd))", &type, &direction, &percentage, - //&fingers, - // //&deviceType, &elapsedTime, &maybeEndPosition, &cursorPositionX, - //&cursorPositionY); - // //if (maybeEndPosition != NULL) { - // // g_variant_get(maybeEndPosition, "(dd)", &cursorPositionX, &cursorPositionY); - // // cursorPosition.x = cursorPositionX; - // // cursorPosition.y = cursorPositionY; - // // g_variant_unref(maybeEndPosition); - // //} - // //if (maybeEndPosition) { - // cursorPosition.x = cursorPositionX; - // cursorPosition.y = cursorPositionY; - // //} - // std::cout << "Got cursorPosition (from signal): " << cursorPosition.x << ", " << - // cursorPosition.y << std::endl; - //} else { - // g_variant_get(signalParameters, // NOLINT - // "(uudiut)", &type, &direction, &percentage, &fingers, - // &deviceType, &elapsedTime); - //} return std::make_unique(type, direction, percentage, fingers, deviceType, elapsedTime, cursorPosition); diff --git a/src/daemon/daemon-server.cpp b/src/daemon/daemon-server.cpp index 3f8bacad..576c1a6e 100644 --- a/src/daemon/daemon-server.cpp +++ b/src/daemon/daemon-server.cpp @@ -115,52 +115,33 @@ void DaemonServer::send(const std::string &signalName, std::vector closedConnections{}; // Copy every gesture field into the signal parameters for serialization - // if (gesture->cursorPosition().x > -1 || gesture->cursorPosition().y > -1) { GVariant *signalParams; - //if (signalName == DBUS_ON_GESTURE_END) { if ( - signalName == DBUS_ON_GESTURE_END - || signalName == DBUS_ON_GESTURE_UPDATE + signalName == DBUS_ON_GESTURE_UPDATE + || signalName == DBUS_ON_GESTURE_END ) { std::cout << "Emitting signal with cursorPosition: " << gesture->cursorPosition().x << ", " << gesture->cursorPosition().y << std::endl; signalParams = { - // g_variant_new("(uudiutuu)", // NOLINT - // g_variant_new("(uudiutx)", // NOLINT - g_variant_new( - "(uudiutdd)", // NOLINT - // g_variant_new("(uuudiut(dd))", // NOLINT - // g_variant_new("(uuudiutm@(dd))", // NOLINT - // g_variant_new("(uuudiutm(dd))", // NOLINT + g_variant_new( + "(uudiut(dd))", // NOLINT static_cast(gesture->type()), // u static_cast(gesture->direction()), // u gesture->percentage(), // d gesture->fingers(), // i static_cast(gesture->performedOnDeviceType()), // u gesture->elapsedTime(), // t - // gesture->cursorPosition())}; // dd - // gesture->cursorPosition())}; // m@(dd) - // // Currently always send. Make optional. - // TRUE, // m // Currently always - // send. Make optional. - gesture->cursorPosition().x, // d - gesture->cursorPosition().y)}; // d + gesture->cursorPosition())}; // dd } else { signalParams = {g_variant_new( "(uudiut)", // NOLINT - // g_variant_new("(uuudiutm@(dd))", // NOLINT - // g_variant_new("(uuudiutm(dd))", // NOLINT static_cast(gesture->type()), // u static_cast(gesture->direction()), // u gesture->percentage(), // d gesture->fingers(), // i static_cast(gesture->performedOnDeviceType()), // u gesture->elapsedTime())}; // t - // gesture->elapsedTime(), // t - // NULL)}; // m@(dd) - // FALSE, NULL, NULL)}; // m(dd) - // FALSE, -1, -1)}; // m(dd) } g_variant_ref_sink(signalParams); diff --git a/src/daemon/dbus.h b/src/daemon/dbus.h index a1b82d0f..ae90b65d 100644 --- a/src/daemon/dbus.h +++ b/src/daemon/dbus.h @@ -50,15 +50,7 @@ constexpr auto DBUS_INTROSPECTION_XML = " " " " " " - //" " - //" " - " " - //" " - //" " - //" " - //" " - //" " - //" " + " " " " " " " " @@ -67,15 +59,7 @@ constexpr auto DBUS_INTROSPECTION_XML = " " " " " " - //" " - //" " - " " - //" " - //" " - //" " - //" " - //" " - //" " + " " " " " " ""; From c86e69d12cc06d872f53d6f3f4f97c5343aea6fd Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Mon, 9 Jun 2025 19:55:29 -0700 Subject: [PATCH 08/15] Removed more comments. --- src/gesture-controller/gesture-controller.h | 1 - .../libinput-gesture-gatherer.h | 3 ++- src/window-system/x11.cpp | 20 ------------------- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/gesture-controller/gesture-controller.h b/src/gesture-controller/gesture-controller.h index 3a1d98c2..8909de5c 100755 --- a/src/gesture-controller/gesture-controller.h +++ b/src/gesture-controller/gesture-controller.h @@ -46,7 +46,6 @@ class GestureController : public GestureControllerDelegate { const WindowSystem &windowSystem; // Setting values cached for efficient access: - //RepositionCursorOpt repositionCursor; RepositionCursorOpt repositionCursor; // Bitmask. /** diff --git a/src/gesture-gatherer/libinput-gesture-gatherer.h b/src/gesture-gatherer/libinput-gesture-gatherer.h index f69dd548..9690a1a1 100644 --- a/src/gesture-gatherer/libinput-gesture-gatherer.h +++ b/src/gesture-gatherer/libinput-gesture-gatherer.h @@ -75,7 +75,8 @@ class LibinputGestureGatherer : public GestureGatherer { */ struct libinput_interface libinputInterface{ LibinputGestureGatherer::openRestricted, - LibinputGestureGatherer::closeRestricted}; + LibinputGestureGatherer::closeRestricted + }; static int openRestricted(const char *path, int flags, void *userData); static void closeRestricted(int fd, void *userData); }; diff --git a/src/window-system/x11.cpp b/src/window-system/x11.cpp index 0ce76783..b2998465 100644 --- a/src/window-system/x11.cpp +++ b/src/window-system/x11.cpp @@ -481,7 +481,6 @@ void X11::positionCursor(double xMm, double yMm) const { int screen = DefaultScreen(this->display); // Note: These values are subject to system configuration (e.g. D.P.I.). - // https://bbs.archlinux.org/viewtopic.php?id=227324 double dwMM = DisplayWidthMM(this->display, screen); double dhMM = DisplayHeightMM(this->display, screen); double dwPixels = DisplayWidth(this->display, screen); @@ -493,17 +492,6 @@ void X11::positionCursor(double xMm, double yMm) const { << " Display width (pixels): " << dwPixels << '\n' << "Display height (pixels): " << dhPixels << '\n' << std::endl; - // - // These need the screen structure, not I.D. integer. - // if (dwMM != WidthMMOfScreen(screen)) std::cout << "Width (mm) of screen and - // display do not match. Screen claims: " << WidthMMOfScreen(screen) << - // std::endl; if (dhMM != HeightMMOfScreen(screen)) std::cout << "Height (mm) - // of screen and display do not match. Screen claims: " << - // HeightMMOfScreen(screen) << std::endl; if (dwMM != WidthOfScreen(screen)) - // std::cout << "Width (pixels) of screen and display do not match. Screen - // claims: " << WidthOfScreen(screen) << std::endl; if (dhMM != - // HeightOfScreen(screen)) std::cout << "Height (pixels) of screen and display - // do not match. Screen claims: " << HeightOfScreen(screen) << std::endl; int targetX = (xMm / dwMM) * dwPixels; int targetY = (yMm / dhMM) * dhPixels; @@ -529,14 +517,6 @@ void X11::positionCursor(double xMm, double yMm) const { std::cout << "Current cursor position: " << pointerX << ", " << pointerY << std::endl; - // Not sure if useful. - // Move cursor to origin (0, 0). This is necessary because we are warping with - // relative positioning, irrespective of windows. - // XWarpPointer(this->display, None, None, 0, 0, 0, 0, -pointerX, -pointerY); - // XWarpPointer(this->display, None, None, 0, 0, 0, 0, targetX, targetY); - - //targetX = targetX > pointerX ? targetX - pointerX : pointerX - targetX; - //targetY = targetY > pointerY ? targetY - pointerY : pointerY - targetY; targetX = targetX - pointerX; targetY = targetY - pointerY; std::cout << " Relative distance: " << targetX << ", " << targetY From 7f41644524049db0dfab08adbf4927ce75f504e8 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 10 Jun 2025 12:33:18 -0700 Subject: [PATCH 09/15] Minor clean-up. --- src/daemon/daemon-server.cpp | 2 +- src/gesture-gatherer/libinput-touch-handler.cpp | 8 -------- src/gesture/gesture.h | 6 ++++-- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/daemon/daemon-server.cpp b/src/daemon/daemon-server.cpp index 576c1a6e..bfd3ca6b 100644 --- a/src/daemon/daemon-server.cpp +++ b/src/daemon/daemon-server.cpp @@ -132,7 +132,7 @@ void DaemonServer::send(const std::string &signalName, gesture->fingers(), // i static_cast(gesture->performedOnDeviceType()), // u gesture->elapsedTime(), // t - gesture->cursorPosition())}; // dd + gesture->cursorPosition())}; // dd } else { signalParams = {g_variant_new( "(uudiut)", // NOLINT diff --git a/src/gesture-gatherer/libinput-touch-handler.cpp b/src/gesture-gatherer/libinput-touch-handler.cpp index aafa86ba..c567f4e9 100644 --- a/src/gesture-gatherer/libinput-touch-handler.cpp +++ b/src/gesture-gatherer/libinput-touch-handler.cpp @@ -93,18 +93,10 @@ void LibinputTouchHandler::handleTouchUp(struct libinput_event *event) { std::cout << "Assigning current XY values: " << this->state.currentX[slot] << ", " << this->state.currentY[slot] << std::endl; - // Rectangle screenSize = auto gesture = std::make_unique( this->state.type, this->state.direction, percentage, this->state.startFingers, DeviceType::TOUCHSCREEN, elapsedTime, XYPosition{this->state.currentX[slot], this->state.currentY[slot]}); - // Rectangle { - // XYPosition{ - // libinput_event_touch_get_x(tEvent), - // libinput_event_touch_get_y(tEvent) - // libinput_event_touch_get_x_transformed(tEvent, ), - // libinput_event_touch_get_y_transformed(tEvent, ) - // }); this->gestureController->onGestureEnd(std::move(gesture)); this->state.reset(); diff --git a/src/gesture/gesture.h b/src/gesture/gesture.h index ff9ef6ff..30280c44 100644 --- a/src/gesture/gesture.h +++ b/src/gesture/gesture.h @@ -24,11 +24,14 @@ #include "gesture/gesture-direction.h" #include "gesture/gesture-type.h" +/** + * Intended to store absolute position on display in millimeters. + * Useful to export position from Libinput, which seems unaware of pixels. + */ struct XYPosition { double x; double y; }; -// #include "utils/rectangle.h" /** * Gestures implementations change depending on the driver/backend. This is the @@ -111,7 +114,6 @@ class Gesture { DeviceType deviceType = DeviceType::UNKNOWN; uint64_t gestureElapsedTime = -1; XYPosition gestureEndPosition{-1, -1}; - // Rectangle cursorPosition {0, 0, 0, 0}; }; #endif // GESTURE_GESTURE_H_ From 7de8b3a16715b5e38dd85898484d2397fa455c9e Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 10 Jun 2025 12:57:57 -0700 Subject: [PATCH 10/15] Reverted unnecessary changes to mmToDpi. --- .../libinput-device-handler.cpp | 19 ++++++++++--------- .../libinput-device-handler.h | 3 +-- src/utils/pixel-conversions.cpp | 6 ------ src/utils/pixel-conversions.h | 6 ------ src/window-system/x11.h | 1 - 5 files changed, 11 insertions(+), 24 deletions(-) delete mode 100644 src/utils/pixel-conversions.cpp delete mode 100644 src/utils/pixel-conversions.h diff --git a/src/gesture-gatherer/libinput-device-handler.cpp b/src/gesture-gatherer/libinput-device-handler.cpp index 44baed8e..1e39e165 100644 --- a/src/gesture-gatherer/libinput-device-handler.cpp +++ b/src/gesture-gatherer/libinput-device-handler.cpp @@ -122,19 +122,20 @@ void LininputDeviceHandler::calculateTouchpadThreshold( #endif double minSize = std::min(widthMm, heightMm); - outInfo->startThreshold = ((mmToDpi(minSize) * START_PERCENTAGE) / 100); + outInfo->startThreshold = + ((LininputDeviceHandler::mmToDpi(minSize) * START_PERCENTAGE) / 100); outInfo->finishThresholdHorizontal = - ((mmToDpi(widthMm) * FINISH_PERCENTAGE) / 100); + ((LininputDeviceHandler::mmToDpi(widthMm) * FINISH_PERCENTAGE) / 100); outInfo->finishThresholdVertical = - ((mmToDpi(heightMm) * FINISH_PERCENTAGE) / 100); + ((LininputDeviceHandler::mmToDpi(heightMm) * FINISH_PERCENTAGE) / 100); } -// double LininputDeviceHandler::mmToDpi(double mm) { -// constexpr double mmInOneInch = 25.4; // 1 inch == 25.4 mm -// double inches = mm / mmInOneInch; -// double dpi = (inches * 1000); -// return dpi; -// } +double LininputDeviceHandler::mmToDpi(double mm) { + constexpr double mmInOneInch = 25.4; // 1 inch == 25.4 mm + double inches = mm / mmInOneInch; + double dpi = (inches * 1000); + return dpi; +} void LininputDeviceHandler::calculateTouchscreenThreshold( double widthMm, double heightMm, LibinputDeviceInfo *outInfo) { diff --git a/src/gesture-gatherer/libinput-device-handler.h b/src/gesture-gatherer/libinput-device-handler.h index 06b550ad..20fbbe9b 100644 --- a/src/gesture-gatherer/libinput-device-handler.h +++ b/src/gesture-gatherer/libinput-device-handler.h @@ -23,7 +23,6 @@ #include "gesture-controller/gesture-controller-delegate.h" #include "gesture-gatherer/libinput-handler.h" #include "gesture/gesture-direction.h" -#include "utils/pixel-conversions.h" /** * Class to handle libinput devices: @@ -57,7 +56,7 @@ class LininputDeviceHandler : public LininputHandler { */ static void calculateTouchpadThreshold(double widthMm, double heightMm, LibinputDeviceInfo *outInfo); - // static double mmToDpi(double mm); + static double mmToDpi(double mm); /** * Calculates LibinputDeviceInfo on touchscreens. diff --git a/src/utils/pixel-conversions.cpp b/src/utils/pixel-conversions.cpp deleted file mode 100644 index 6ca9ee41..00000000 --- a/src/utils/pixel-conversions.cpp +++ /dev/null @@ -1,6 +0,0 @@ -double mmToDpi(double mm) { - constexpr double mmInOneInch = 25.4; // 1 inch == 25.4 mm - double inches = mm / mmInOneInch; - double dpi = (inches * 1000); - return dpi; -} diff --git a/src/utils/pixel-conversions.h b/src/utils/pixel-conversions.h deleted file mode 100644 index e3f23cfe..00000000 --- a/src/utils/pixel-conversions.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef UTILS_PIXEL_CONVERSIONS_H_ -#define UTILS_PIXEL_CONVERSIONS_H_ - -double mmToDpi(double mm); - -#endif // UTILS_PIXEL_CONVERSIONS_H_ diff --git a/src/window-system/x11.h b/src/window-system/x11.h index 22fe710d..de29eee0 100644 --- a/src/window-system/x11.h +++ b/src/window-system/x11.h @@ -28,7 +28,6 @@ #include #include -#include "utils/pixel-conversions.h" #include "window-system/window-system.h" /** From 72ab6255064e5ce1f14b03d730797d6c85086f24 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 10 Jun 2025 12:59:40 -0700 Subject: [PATCH 11/15] Removed accidentally added swap files. --- .../.gesture-controller.cpp.swp | Bin 24576 -> 0 bytes src/utils/.reposition-cursor.h.swp | Bin 12288 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/gesture-controller/.gesture-controller.cpp.swp delete mode 100644 src/utils/.reposition-cursor.h.swp diff --git a/src/gesture-controller/.gesture-controller.cpp.swp b/src/gesture-controller/.gesture-controller.cpp.swp deleted file mode 100644 index 7e0452f6d02d371f0e4d6c87c2fcac08244d4303..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24576 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 SpT9z1^wyn|{RmkvO8E~GYcRh6 From e0f2fb2a57fdb07ccbf47786307d74c3913133c9 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 10 Jun 2025 13:12:13 -0700 Subject: [PATCH 12/15] Reduced debug output. --- src/daemon/daemon-server.cpp | 3 --- .../libinput-touch-handler.cpp | 3 --- src/window-system/x11.cpp | 22 +++++++++---------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/daemon/daemon-server.cpp b/src/daemon/daemon-server.cpp index bfd3ca6b..f8d132ff 100644 --- a/src/daemon/daemon-server.cpp +++ b/src/daemon/daemon-server.cpp @@ -120,9 +120,6 @@ void DaemonServer::send(const std::string &signalName, signalName == DBUS_ON_GESTURE_UPDATE || signalName == DBUS_ON_GESTURE_END ) { - std::cout << "Emitting signal with cursorPosition: " - << gesture->cursorPosition().x << ", " << gesture->cursorPosition().y - << std::endl; signalParams = { g_variant_new( "(uudiut(dd))", // NOLINT diff --git a/src/gesture-gatherer/libinput-touch-handler.cpp b/src/gesture-gatherer/libinput-touch-handler.cpp index c567f4e9..72bd453b 100644 --- a/src/gesture-gatherer/libinput-touch-handler.cpp +++ b/src/gesture-gatherer/libinput-touch-handler.cpp @@ -20,7 +20,6 @@ #include #include -#include // Debugging. #include #include #include @@ -91,8 +90,6 @@ void LibinputTouchHandler::handleTouchUp(struct libinput_event *event) { : LininputHandler::calculatePinchAnimationPercentage( this->state.direction, this->getPinchDelta()); - std::cout << "Assigning current XY values: " << this->state.currentX[slot] - << ", " << this->state.currentY[slot] << std::endl; auto gesture = std::make_unique( this->state.type, this->state.direction, percentage, this->state.startFingers, DeviceType::TOUCHSCREEN, elapsedTime, diff --git a/src/window-system/x11.cpp b/src/window-system/x11.cpp index b2998465..9209b3d1 100644 --- a/src/window-system/x11.cpp +++ b/src/window-system/x11.cpp @@ -32,6 +32,7 @@ #include #include "window-system/x11-cairo-surface.h" +#include "utils/logger.h" X11::X11() { this->display = XOpenDisplay(nullptr); @@ -477,7 +478,6 @@ void X11::sendMouseUp(int button) const { } void X11::positionCursor(double xMm, double yMm) const { - std::cout << "Attempting to reposition cursor." << std::endl; int screen = DefaultScreen(this->display); // Note: These values are subject to system configuration (e.g. D.P.I.). @@ -485,17 +485,17 @@ void X11::positionCursor(double xMm, double yMm) const { double dhMM = DisplayHeightMM(this->display, screen); double dwPixels = DisplayWidth(this->display, screen); double dhPixels = DisplayHeight(this->display, screen); - std::cout << " Gesture offset X (mm): " << xMm << '\n' - << " Gesture offset Y (mm): " << yMm << '\n' - << " Display width (mm): " << dwMM << '\n' - << " Display height (mm): " << dhMM << '\n' - << " Display width (pixels): " << dwPixels << '\n' - << "Display height (pixels): " << dhPixels << '\n' - << std::endl; + tlg::debug << " Gesture offset X (mm): " << xMm << '\n' + << " Gesture offset Y (mm): " << yMm << '\n' + << " Display width (mm): " << dwMM << '\n' + << " Display height (mm): " << dhMM << '\n' + << " Display width (pixels): " << dwPixels << '\n' + << "Display height (pixels): " << dhPixels << '\n' + << std::endl; int targetX = (xMm / dwMM) * dwPixels; int targetY = (yMm / dhMM) * dhPixels; - std::cout << " Cursor target: " << targetX << ", " << targetY + tlg::debug << " Cursor target: " << targetX << ", " << targetY << std::endl; // Get current cursor position. @@ -514,12 +514,12 @@ void X11::positionCursor(double xMm, double yMm) const { << std::endl; return; } - std::cout << "Current cursor position: " << pointerX << ", " << pointerY + tlg::debug << "Current cursor position: " << pointerX << ", " << pointerY << std::endl; targetX = targetX - pointerX; targetY = targetY - pointerY; - std::cout << " Relative distance: " << targetX << ", " << targetY + tlg::debug << " Relative distance: " << targetX << ", " << targetY << std::endl; XWarpPointer(this->display, None, None, 0, 0, 0, 0, targetX, targetY); XFlush(this->display); From eb7e49e2606eb1fd1e79ece5937c2819d0cfff28 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 10 Jun 2025 13:30:22 -0700 Subject: [PATCH 13/15] Fixed change to indentation. --- src/gesture-gatherer/libinput-gesture-gatherer.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gesture-gatherer/libinput-gesture-gatherer.h b/src/gesture-gatherer/libinput-gesture-gatherer.h index 9690a1a1..765198c3 100644 --- a/src/gesture-gatherer/libinput-gesture-gatherer.h +++ b/src/gesture-gatherer/libinput-gesture-gatherer.h @@ -73,9 +73,9 @@ class LibinputGestureGatherer : public GestureGatherer { /** * libinput structure with pointers to the open/close callbacks. */ - struct libinput_interface libinputInterface{ - LibinputGestureGatherer::openRestricted, - LibinputGestureGatherer::closeRestricted + struct libinput_interface libinputInterface { + LibinputGestureGatherer::openRestricted, + LibinputGestureGatherer::closeRestricted }; static int openRestricted(const char *path, int flags, void *userData); static void closeRestricted(int fd, void *userData); From 8f79bcbc993aa7bfb7158772502ad2d941cad57f Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 10 Jun 2025 15:31:49 -0700 Subject: [PATCH 14/15] Added note and made minor adjustments to output when reloading config file. --- src/config/xml-config-loader.cpp | 22 +++++++++++++--------- src/config/xml-config-loader.h | 4 ++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/config/xml-config-loader.cpp b/src/config/xml-config-loader.cpp index b708d267..53250c7a 100644 --- a/src/config/xml-config-loader.cpp +++ b/src/config/xml-config-loader.cpp @@ -59,35 +59,39 @@ std::filesystem::path XmlConfigLoader::getConfigFilePath() { if (!std::filesystem::exists(usrConfigFile)) { throw std::runtime_error{ - "File /usr/share/touchegg/touchegg.conf not found.\n" - "Reinstall Touchégg to solve this issue"}; + "File \"/usr/share/touchegg/touchegg.conf\" not found.\n" + "\tReinstall Touchégg to solve this issue."}; } return std::filesystem::exists(homeConfigFile) ? homeConfigFile : usrConfigFile; } -void XmlConfigLoader::parseConfig() { +void XmlConfigLoader::parseConfig(bool isReload) { std::filesystem::path configPath = XmlConfigLoader::getConfigFilePath(); - tlg::info << "Using configuration file " << configPath << std::endl; + tlg::info << "\tUsing configuration file: " << configPath << std::endl; pugi::xml_document doc; pugi::xml_parse_result parsedSuccessfully = doc.load_file(configPath.c_str()); if (!parsedSuccessfully) { - throw std::runtime_error{"Error parsing configuration file"}; + throw std::runtime_error{"Error parsing configuration file."}; } pugi::xml_node rootNode = doc.document_element(); - this->parseGlobalSettings(rootNode); + this->parseGlobalSettings(rootNode, isReload); this->parseApplicationXmlNodes(rootNode); } -void XmlConfigLoader::parseGlobalSettings(const pugi::xml_node &rootNode) { +void XmlConfigLoader::parseGlobalSettings(const pugi::xml_node &rootNode, bool isReload) { pugi::xml_node settingsNode = rootNode.child("settings"); for (pugi::xml_node propertyNode : settingsNode.children("property")) { const std::string property = propertyNode.attribute("name").value(); const std::string value = propertyNode.child_value(); + if (isReload && property == "reposition_cursor") { + tlg::info << "\tNote: Changing \"reposition_cursor\" currently requires" + " restarting the client service.\n" << std::endl; + } this->config->saveGlobalSetting(property, value); } } @@ -168,10 +172,10 @@ void XmlConfigLoader::watchConfig() { } if (reloadSettings) { - tlg::info << "Your configuration file changed, reloading your settings" + tlg::info << "Your configuration file changed. Reloading your settings..." << std::endl; this->config->clear(); - this->parseConfig(); + this->parseConfig(true); } } }}; diff --git a/src/config/xml-config-loader.h b/src/config/xml-config-loader.h index 4155d7f4..34ccb8a9 100755 --- a/src/config/xml-config-loader.h +++ b/src/config/xml-config-loader.h @@ -64,13 +64,13 @@ class XmlConfigLoader { /** * Parse the XML configuration file placed in path. */ - void parseConfig(); + void parseConfig(bool isReload = false); /** * Parse the global settings. * @param rootNode XML root node, usually named "touchégg". */ - void parseGlobalSettings(const pugi::xml_node &rootNode); + void parseGlobalSettings(const pugi::xml_node &rootNode, bool isReload); /** * Parse the "application" nodes in the XML. From 7139d0e499e59d823f9e9e4c56929d869ddab3cd Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 10 Jun 2025 22:32:54 -0700 Subject: [PATCH 15/15] Reduced debug output. --- src/gesture-controller/gesture-controller.cpp | 4 ++- src/window-system/window-system.h | 2 +- src/window-system/x11.cpp | 27 +++++++++---------- src/window-system/x11.h | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/gesture-controller/gesture-controller.cpp b/src/gesture-controller/gesture-controller.cpp index 83969aad..bde050e0 100644 --- a/src/gesture-controller/gesture-controller.cpp +++ b/src/gesture-controller/gesture-controller.cpp @@ -107,7 +107,9 @@ void GestureController::onGestureEnd(std::unique_ptr gesture) { tlg::debug << "cursorPosition (GestureEnd): {" << curPos.x << ", " << curPos.y << "}" << std::endl; - this->windowSystem.positionCursor(curPos.x, curPos.y); + this->windowSystem.positionCursor(curPos.x, curPos.y, + // Extra verbose debugging if set to *only* GESTURE_END. + (repositionCursor == RepositionCursorOpt::GESTURE_END)); } if (this->executeAction) { diff --git a/src/window-system/window-system.h b/src/window-system/window-system.h index 05118eb8..3884e888 100644 --- a/src/window-system/window-system.h +++ b/src/window-system/window-system.h @@ -155,7 +155,7 @@ class WindowSystem { * Only one movement event should be triggered. * No button click events should be sent. */ - virtual void positionCursor(double x, double y) const = 0; + virtual void positionCursor(double x, double y, bool verboseDebug = false) const = 0; /** * @returns The size of the desktop workarea, ie, the area of the desktop not diff --git a/src/window-system/x11.cpp b/src/window-system/x11.cpp index 9209b3d1..ff88d756 100644 --- a/src/window-system/x11.cpp +++ b/src/window-system/x11.cpp @@ -477,7 +477,7 @@ void X11::sendMouseUp(int button) const { XFlush(this->display); } -void X11::positionCursor(double xMm, double yMm) const { +void X11::positionCursor(double xMm, double yMm, bool verboseDebug) const { int screen = DefaultScreen(this->display); // Note: These values are subject to system configuration (e.g. D.P.I.). @@ -485,18 +485,9 @@ void X11::positionCursor(double xMm, double yMm) const { double dhMM = DisplayHeightMM(this->display, screen); double dwPixels = DisplayWidth(this->display, screen); double dhPixels = DisplayHeight(this->display, screen); - tlg::debug << " Gesture offset X (mm): " << xMm << '\n' - << " Gesture offset Y (mm): " << yMm << '\n' - << " Display width (mm): " << dwMM << '\n' - << " Display height (mm): " << dhMM << '\n' - << " Display width (pixels): " << dwPixels << '\n' - << "Display height (pixels): " << dhPixels << '\n' - << std::endl; int targetX = (xMm / dwMM) * dwPixels; int targetY = (yMm / dhMM) * dhPixels; - tlg::debug << " Cursor target: " << targetX << ", " << targetY - << std::endl; // Get current cursor position. Window rootWindow = None; @@ -514,13 +505,21 @@ void X11::positionCursor(double xMm, double yMm) const { << std::endl; return; } - tlg::debug << "Current cursor position: " << pointerX << ", " << pointerY - << std::endl; targetX = targetX - pointerX; targetY = targetY - pointerY; - tlg::debug << " Relative distance: " << targetX << ", " << targetY - << std::endl; + + if (verboseDebug) tlg::debug + << " Gesture offset X (mm): " << xMm << '\n' + << " Gesture offset Y (mm): " << yMm << '\n' + << " Display width (mm): " << dwMM << '\n' + << " Display height (mm): " << dhMM << '\n' + << " Display width (pixels): " << dwPixels << '\n' + << "Display height (pixels): " << dhPixels << '\n' + << " Cursor target: " << targetX << ", " << targetY + << "Current cursor position: " << pointerX << ", " << pointerY + << " Relative distance: " << targetX << ", " << targetY + << std::endl; XWarpPointer(this->display, None, None, 0, 0, 0, 0, targetX, targetY); XFlush(this->display); } diff --git a/src/window-system/x11.h b/src/window-system/x11.h index de29eee0..44a2176f 100644 --- a/src/window-system/x11.h +++ b/src/window-system/x11.h @@ -68,7 +68,7 @@ class X11 : public WindowSystem { bool isPress) const override; void sendMouseDown(int button) const override; void sendMouseUp(int button) const override; - void positionCursor(double x, double y) const override; + void positionCursor(double xMm, double yMm, bool verboseDebug = false) const override; Rectangle getDesktopWorkarea() const override; void changeDesktop(ActionDirection direction, bool cyclic) const override;