diff --git a/comfortable-swipe-defines.cpp b/comfortable-swipe-defines.cpp
index 9bc6bcf..b749632 100644
--- a/comfortable-swipe-defines.cpp
+++ b/comfortable-swipe-defines.cpp
@@ -22,7 +22,8 @@ along with this program. If not, see .
* COMFORTABLE_SWIPE_CONFIG
*
* This definition points to the location of the configuration file.
- * A warning will be issued to the compiler if you do not define this at compile time.
+ * A warning will be issued to the compiler if you do not define this at compile
+ * time.
*/
#ifndef COMFORTABLE_SWIPE_CONFIG
#pragma message "Please define COMFORTABLE_SWIPE_CONFIG during compilation!"
@@ -33,7 +34,8 @@ along with this program. If not, see .
* COMFORTABLE_SWIPE_AUTOSTART
*
* This definition points to the location of the autostart (.desktop) file.
- * A warning will be issued to the compiler if you do not define this at compile time.
+ * A warning will be issued to the compiler if you do not define this at compile
+ * time.
*/
#ifndef COMFORTABLE_SWIPE_AUTOSTART
#pragma message "Please define COMFORTABLE_SWIPE_AUTOSTART during compilation!"
diff --git a/comfortable-swipe-gesture-swipe-xdokey.cpp b/comfortable-swipe-gesture-swipe-xdokey.cpp
index 36aaada..fbcd2f2 100644
--- a/comfortable-swipe-gesture-swipe-xdokey.cpp
+++ b/comfortable-swipe-gesture-swipe-xdokey.cpp
@@ -19,9 +19,9 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
+#include // std::array
#include // std::cout, std::endl
-#include // std::array
-#include // std::string
+#include // std::string
extern "C" {
#include // xdo_send_keysequence_window
@@ -40,37 +40,38 @@ namespace comfortable_swipe {
* When constructing, please mind the order in the
* `gesture_swipe_xdokey::command_name[]` static array.
*/
-class gesture_swipe_xdokey : public gesture_swipe
-{
+class gesture_swipe_xdokey : public gesture_swipe {
public:
-// stores the 8 command strings for xdo to execute
-std::array commands;
-// constructor
-gesture_swipe_xdokey(const decltype(commands)& commands, float threshold=0);
-// destructor
-virtual ~gesture_swipe_xdokey();
-// hooks that we override
-virtual void begin() override;
-virtual void update() override;
-virtual void end() override;
-// override this when keyboard gesture is to be performed
-virtual void do_keyboard_gesture(int mask);
+ // stores the 8 command strings for xdo to execute
+ std::array commands;
+ // constructor
+ gesture_swipe_xdokey(const decltype(commands) &commands, float threshold = 0);
+ // destructor
+ virtual ~gesture_swipe_xdokey();
+ // hooks that we override
+ virtual void begin() override;
+ virtual void update() override;
+ virtual void end() override;
+ // override this when keyboard gesture is to be performed
+ virtual void do_keyboard_gesture(int mask);
+
protected:
- // stores square of threshold so we can compute faster
- float threshold_squared;
- // stores previous gesture so we don't repeat action
- int previous_gesture;
+ // stores square of threshold so we can compute faster
+ float threshold_squared;
+ // stores previous gesture so we don't repeat action
+ int previous_gesture;
+
public:
-// static enums we will use for gesture matching
-static const int FRESH = -1;
-static const int MSK_THREE_FINGERS = 0;
-static const int MSK_FOUR_FINGERS = 1;
-static const int MSK_NEGATIVE = 0;
-static const int MSK_POSITIVE = 2;
-static const int MSK_HORIZONTAL = 0;
-static const int MSK_VERTICAL = 4;
-// mappings to our command string names
-static const std::string command_name[];
+ // static enums we will use for gesture matching
+ static const int FRESH = -1;
+ static const int MSK_THREE_FINGERS = 0;
+ static const int MSK_FOUR_FINGERS = 1;
+ static const int MSK_NEGATIVE = 0;
+ static const int MSK_POSITIVE = 2;
+ static const int MSK_HORIZONTAL = 0;
+ static const int MSK_VERTICAL = 4;
+ // mappings to our command string names
+ static const std::string command_name[];
};
/**
* Our mapped directional command names. These will be
@@ -81,8 +82,8 @@ static const std::string command_name[];
* Refer to the order of this array for the "commands"
* paramter in the constructor.
*/
-decltype(gesture_swipe_xdokey::command_name)
-gesture_swipe_xdokey::command_name = {
+decltype(
+ gesture_swipe_xdokey::command_name) gesture_swipe_xdokey::command_name = {
// the order of variables is based on bitmasking
// | |
"left3", // 000
@@ -102,13 +103,13 @@ gesture_swipe_xdokey::command_name = {
* scrolling direction (ie. left3 is natural movement of 3 fingers left).
*/
gesture_swipe_xdokey::gesture_swipe_xdokey(
- const decltype(gesture_swipe_xdokey::commands)& commands,
- float threshold
-): gesture_swipe(), commands(commands), threshold_squared(threshold * threshold) {}
+ const decltype(gesture_swipe_xdokey::commands) &commands, float threshold)
+ : gesture_swipe(), commands(commands),
+ threshold_squared(threshold * threshold) {}
/**
* Destructs this keyboard swipe gesture.
*/
-gesture_swipe_xdokey::~gesture_swipe_xdokey() { }
+gesture_swipe_xdokey::~gesture_swipe_xdokey() {}
/**
* Hook on begin of swipe gesture.
*/
@@ -150,8 +151,7 @@ void gesture_swipe_xdokey::update() {
mask |= gesture_swipe_xdokey::MSK_NEGATIVE;
else
mask |= gesture_swipe_xdokey::MSK_POSITIVE;
- }
- else /* std::abs(x) <= std::abs(y) */
+ } else /* std::abs(x) <= std::abs(y) */
{
// gesture is vertical
mask |= gesture_swipe_xdokey::MSK_VERTICAL;
@@ -162,8 +162,7 @@ void gesture_swipe_xdokey::update() {
}
// send command on fresh OR opposite gesture
if (this->previous_gesture == gesture_swipe_xdokey::FRESH ||
- this->previous_gesture ==
- (mask ^ gesture_swipe_xdokey::MSK_POSITIVE)) {
+ this->previous_gesture == (mask ^ gesture_swipe_xdokey::MSK_POSITIVE)) {
// finally, perform keyboard gesture
this->do_keyboard_gesture(mask);
}
@@ -174,7 +173,8 @@ void gesture_swipe_xdokey::update() {
*/
void gesture_swipe_xdokey::do_keyboard_gesture(int mask) {
// perform our keyboard command with xdo_send_keysequence
- xdo_send_keysequence_window(this->xdo, CURRENTWINDOW, commands[mask].data(), 0);
+ xdo_send_keysequence_window(this->xdo, CURRENTWINDOW, commands[mask].data(),
+ 0);
std::cout << "SWIPE " << command_name[mask] << std::endl;
// reset our location variables
this->x = this->y = 0;
@@ -187,5 +187,5 @@ void gesture_swipe_xdokey::end() {
// just call superclass method
gesture_swipe::end();
}
-}
+} // namespace comfortable_swipe
#endif /* __comfortable_swipe_gesture_swipe_xdokey__ */
diff --git a/comfortable-swipe-gesture-swipe-xdomouse.cpp b/comfortable-swipe-gesture-swipe-xdomouse.cpp
index ed136a7..b977a42 100644
--- a/comfortable-swipe-gesture-swipe-xdomouse.cpp
+++ b/comfortable-swipe-gesture-swipe-xdomouse.cpp
@@ -68,7 +68,7 @@ public:
int button;
// constructor
gesture_swipe_xdomouse(const char *hold3, // 3 finger mouse down
- const char *hold4 // 4 finger mouse down
+ const char *hold4 // 4 finger mouse down
);
// destructor
virtual ~gesture_swipe_xdomouse();
@@ -83,10 +83,12 @@ public:
virtual bool is_holding() const;
// utility method to parse mouse input given config characters
static int parse_mouse_button(const char *);
+
protected:
// command holders
const char *hold3;
const char *hold4;
+
private:
// flag we can use to check if mouse is down
bool flag_is_holding;
@@ -94,7 +96,8 @@ private:
/**
* Constructs a new mouse gesture, given "hold3" and "hold4" configurations.
*/
-gesture_swipe_xdomouse::gesture_swipe_xdomouse(const char *hold3, const char *hold4)
+gesture_swipe_xdomouse::gesture_swipe_xdomouse(const char *hold3,
+ const char *hold4)
: gesture_swipe(), button(MOUSE_NONE), hold3(hold3), hold4(hold4),
flag_is_holding(false) {}
/**
@@ -214,6 +217,6 @@ void gesture_swipe_xdomouse::end() {
// call superclass method
gesture_swipe::end();
}
-}
+} // namespace comfortable_swipe
#endif /* __comfortable_swipe_gesture_swipe_xdomouse__ */
diff --git a/comfortable-swipe-gesture-swipe.cpp b/comfortable-swipe-gesture-swipe.cpp
index 8ae6122..08873fe 100644
--- a/comfortable-swipe-gesture-swipe.cpp
+++ b/comfortable-swipe-gesture-swipe.cpp
@@ -70,6 +70,7 @@ public:
virtual void update();
virtual void end();
virtual bool run(const char *);
+
protected:
// xdo container
xdo_t *xdo;
@@ -77,6 +78,7 @@ protected:
int screen_num, ix, iy;
// optimization flag for checking if GESTURE_SWIPE_BEGIN was dispatched
bool flag_swiping;
+
public:
// defined in: comfortable-swipe-gesture-swipe.regex.cpp
static const std::regex GESTURE_SWIPE_BEGIN;
@@ -140,8 +142,7 @@ bool gesture_swipe::run(const char *line) {
this->begin();
return true;
}
- }
- else {
+ } else {
// currently swiping
if (std::regex_match(line, matches, GESTURE_SWIPE_UPDATE) != 0) {
// assign necessary variables for swipe update
@@ -172,14 +173,14 @@ bool gesture_swipe::run(const char *line) {
* ^
* fingers
*/
-const std::regex gesture_swipe::GESTURE_SWIPE_BEGIN(
- "^" // start of string
- "[ -]event\\d+" // event
- "\\s+GESTURE_SWIPE_BEGIN" // gesture
- "\\s+\\S+" // timestamp
- "\\s+(\\d+)" // fingers
- "\\s*$" // end of string
-);
+const std::regex
+ gesture_swipe::GESTURE_SWIPE_BEGIN("^" // start of string
+ "[ -]event\\d+" // event
+ "\\s+GESTURE_SWIPE_BEGIN" // gesture
+ "\\s+\\S+" // timestamp
+ "\\s+(\\d+)" // fingers
+ "\\s*$" // end of string
+ );
/**
* Regex pattern for the libinput entry for the end of swipe.
* Extracts one match for the number of fingers used during the swipe.
@@ -188,14 +189,14 @@ const std::regex gesture_swipe::GESTURE_SWIPE_BEGIN(
* ^
* fingers
*/
-const std::regex gesture_swipe::GESTURE_SWIPE_END(
- "^" // start of string
- "[ -]event\\d+" // event
- "\\s+GESTURE_SWIPE_END" // gesture
- "\\s+\\S+" // timestamp
- "\\s+(\\d+)" // fingers
- "\\s*$" // end of string
-);
+const std::regex
+ gesture_swipe::GESTURE_SWIPE_END("^" // start of string
+ "[ -]event\\d+" // event
+ "\\s+GESTURE_SWIPE_END" // gesture
+ "\\s+\\S+" // timestamp
+ "\\s+(\\d+)" // fingers
+ "\\s*$" // end of string
+ );
// matches signed decimal numbers (eg. "6.02" "-1.1")
#define _NUMBER_REGEX "-?\\d+(?:\\.\\d+)"
// matches and extracts a space-prefixed signed fraction (eg. "-3.00/ 5.12")
@@ -218,8 +219,8 @@ const std::regex gesture_swipe::GESTURE_SWIPE_UPDATE(
"\\s+(\\d+)" // fingers
"\\s+" _NUMBER_DIVISION // speed (dx/dy)
"\\s+\\(" _NUMBER_DIVISION
- "\\s+unaccelerated\\)" // unaccelerated speed (udx/udy)
- "\\s*$" // end of string
+ "\\s+unaccelerated\\)" // unaccelerated speed (udx/udy)
+ "\\s*$" // end of string
);
// clean up temporary macros
#undef _NUMBER_DIVISION
diff --git a/comfortable-swipe-main.cpp b/comfortable-swipe-main.cpp
index 99e2448..007418e 100644
--- a/comfortable-swipe-main.cpp
+++ b/comfortable-swipe-main.cpp
@@ -28,24 +28,24 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-#include // std::ios, std::cin, std::getline
-#include // std::string
-#include