Apply clang-format to source files

This commit is contained in:
Rico Tiongson 2020-04-18 14:41:22 +08:00
parent fb92169a16
commit 7d897ac09e
9 changed files with 127 additions and 149 deletions

View File

@ -16,10 +16,10 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "src/comfortable_swipe.cpp"
#include <ios> // std::ios
#include <iostream> // std::cin, std::cout, std::cerr
#include <string> // std::string
#include "src/comfortable_swipe.cpp"
/* Command-line function. */

View File

@ -39,9 +39,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "service/start.cpp"
#include "service/status.cpp"
#include "service/stop.cpp"
#include "start.cpp"
#include "util/autostart_filename.cpp"
#include "util/conf_filename.cpp"
#include "util/read_config_file.cpp"
#include "start.cpp"
#endif /* __COMFORTABLE_SWIPE__ */

View File

@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif /* COMFORTABLE_SWIPE_PROGRAM */
#ifndef COMFORTABLE_SWIPE_CONFIG
#define COMFORTABLE_SWIPE_CONFIG \
#define COMFORTABLE_SWIPE_CONFIG \
"/usr/local/share/comfortable-swipe/comfortable-swipe.conf"
#endif /* COMFORTABLE_SWIPE_CONFIG */

View File

@ -25,57 +25,52 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
extern "C" {
#endif
namespace comfortable_swipe::gesture
{
class keyboard_swipe_gesture : public swipe_gesture
{
public:
// constructor
keyboard_swipe_gesture(
const float threshold,
const char* left3 /* 000 */,
const char* left4 /* 001 */,
const char* right3 /* 010 */,
const char* right4 /* 011 */,
const char* up3 /* 100 */,
const char* up4 /* 101 */,
const char* down3 /* 110 */,
const char* down4 /* 111 */
);
namespace comfortable_swipe::gesture {
class keyboard_swipe_gesture : public swipe_gesture {
public:
// constructor
keyboard_swipe_gesture(const float threshold, const char *left3 /* 000 */,
const char *left4 /* 001 */,
const char *right3 /* 010 */,
const char *right4 /* 011 */,
const char *up3 /* 100 */, const char *up4 /* 101 */,
const char *down3 /* 110 */,
const char *down4 /* 111 */
);
// destructor
virtual ~keyboard_swipe_gesture();
// destructor
virtual ~keyboard_swipe_gesture();
// hooks that we override
virtual void begin() override;
virtual void update() override;
virtual void end() override;
// 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);
// 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;
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 previous gesture so we don't repeat action
int previous_gesture;
// stores all command strings for xdo to execute
const char ** commands;
// stores all command strings for xdo to execute
const char **commands;
public:
// static enums we will use for gesture matching
static const int FRESH;
static const int MSK_THREE_FINGERS;
static const int MSK_FOUR_FINGERS;
static const int MSK_NEGATIVE;
static const int MSK_POSITIVE;
static const int MSK_HORIZONTAL;
static const int MSK_VERTICAL;
static const char * const command_map[8];
};
}
public:
// static enums we will use for gesture matching
static const int FRESH;
static const int MSK_THREE_FINGERS;
static const int MSK_FOUR_FINGERS;
static const int MSK_NEGATIVE;
static const int MSK_POSITIVE;
static const int MSK_HORIZONTAL;
static const int MSK_VERTICAL;
static const char *const command_map[8];
};
} // namespace comfortable_swipe::gesture
#ifdef __cplusplus
}

View File

@ -25,44 +25,41 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
extern "C" {
#endif
namespace comfortable_swipe::gesture
{
class mouse_hold_gesture : public swipe_gesture
{
public:
// constructor
mouse_hold_gesture(
const char* hold3, // 3 finger mouse down
const char* hold4 // 4 finger mouse down
);
namespace comfortable_swipe::gesture {
class mouse_hold_gesture : public swipe_gesture {
public:
// constructor
mouse_hold_gesture(const char *hold3, // 3 finger mouse down
const char *hold4 // 4 finger mouse down
);
// the button being clicked
int button;
// the button being clicked
int button;
virtual ~mouse_hold_gesture();
virtual ~mouse_hold_gesture();
// override begin and end for mousedown
virtual void begin() override;
virtual void update() override;
virtual void end() override;
// override begin and end for mousedown
virtual void begin() override;
virtual void update() override;
virtual void end() override;
// provide our own mouse functions
virtual void do_mousedown(const char*);
virtual void do_mouseup(const char*);
virtual bool is_mousedown() const;
// provide our own mouse functions
virtual void do_mousedown(const char *);
virtual void do_mouseup(const char *);
virtual bool is_mousedown() const;
// utility method to parse mouse input given config characters
static int parse_mouse_button(const char*);
// 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;
protected:
// command holders
const char *hold3;
const char *hold4;
// flag we can use to check if mouse is down
bool flag_mousedown;
};
}
// flag we can use to check if mouse is down
bool flag_mousedown;
};
} // namespace comfortable_swipe::gesture
#ifdef __cplusplus
}

View File

@ -25,46 +25,44 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
extern "C" {
#endif
namespace comfortable_swipe::gesture
{
class swipe_gesture : public xdo_gesture
{
public:
// constructor
swipe_gesture();
namespace comfortable_swipe::gesture {
class swipe_gesture : public xdo_gesture {
public:
// constructor
swipe_gesture();
// destructor
virtual ~swipe_gesture();
// destructor
virtual ~swipe_gesture();
// fields for xdo
int fingers;
// fields for xdo
int fingers;
// normal values (for touchpad mapping)
float x, y, dx, dy;
// normal values (for touchpad mapping)
float x, y, dx, dy;
// unaccelerated values (for screen mapping)
float ux, uy, udx, udy;
// unaccelerated values (for screen mapping)
float ux, uy, udx, udy;
// hooks that we can override (mark as virtual)
virtual void begin();
virtual void update();
virtual void end();
virtual bool parse_line(const char *);
// hooks that we can override (mark as virtual)
virtual void begin();
virtual void update();
virtual void end();
virtual bool parse_line(const char *);
protected:
// location of mouse
int screen_num, ix, iy;
protected:
// location of mouse
int screen_num, ix, iy;
// optimization flag for checking if GESTURE_SWIPE_BEGIN was dispatched
bool flag_swiping;
// optimization flag for checking if GESTURE_SWIPE_BEGIN was dispatched
bool flag_swiping;
public:
// regex patterns
static const char* GESTURE_BEGIN_REGEX_PATTERN;
static const char* GESTURE_UPDATE_REGEX_PATTERN;
static const char* GESTURE_END_REGEX_PATTERN;
};
}
public:
// regex patterns
static const char *GESTURE_BEGIN_REGEX_PATTERN;
static const char *GESTURE_UPDATE_REGEX_PATTERN;
static const char *GESTURE_END_REGEX_PATTERN;
};
} // namespace comfortable_swipe::gesture
#ifdef __cplusplus
}

View File

@ -19,30 +19,26 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
extern "C"
{
#include <xdo.h> // xdo_t
extern "C" {
#include <xdo.h> // xdo_t
}
#ifdef __cplusplus
extern "C" {
#endif
namespace comfortable_swipe
{
namespace gesture
{
class xdo_gesture
{
protected:
xdo_t * xdo;
namespace comfortable_swipe {
namespace gesture {
class xdo_gesture {
protected:
xdo_t *xdo;
public:
xdo_gesture();
virtual ~xdo_gesture();
};
}
}
public:
xdo_gesture();
virtual ~xdo_gesture();
};
} // namespace gesture
} // namespace comfortable_swipe
#ifdef __cplusplus
}

View File

@ -45,31 +45,23 @@ void start() {
// hold3=button1 hold button 1 on 3 fingers
// hold4=button3 hold button 3 (right click) on 3 fingers
// hold3=ignore <do nothing>
const char * const hold3 = config["hold3"].c_str();
const char * const hold4 = config["hold4"].c_str();
const char *const hold3 = config["hold3"].c_str();
const char *const hold4 = config["hold4"].c_str();
comfortable_swipe::gesture::mouse_hold_gesture mouse_hold(hold3, hold4);
// initialize keyboard swipe gesture handler
const float threshold = config.count("threshold") ? std::stof(config["threshold"]) : 0.0;
const char * const left3 = config["left3"].c_str();
const char * const left4 = config["left4"].c_str();
const char * const right3 = config["right3"].c_str();
const char * const right4 = config["right4"].c_str();
const char * const up3 = config["up3"].c_str();
const char * const up4 = config["up4"].c_str();
const char * const down3 = config["down3"].c_str();
const char * const down4 = config["down4"].c_str();
const float threshold =
config.count("threshold") ? std::stof(config["threshold"]) : 0.0;
const char *const left3 = config["left3"].c_str();
const char *const left4 = config["left4"].c_str();
const char *const right3 = config["right3"].c_str();
const char *const right4 = config["right4"].c_str();
const char *const up3 = config["up3"].c_str();
const char *const up4 = config["up4"].c_str();
const char *const down3 = config["down3"].c_str();
const char *const down4 = config["down4"].c_str();
comfortable_swipe::gesture::keyboard_swipe_gesture keyboard_swipe(
threshold,
left3,
left4,
right3,
right4,
up3,
up4,
down3,
down4
);
threshold, left3, left4, right3, right4, up3, up4, down3, down4);
// prepare data containers
std::array<char, 256> line;

View File

@ -2,7 +2,7 @@
#define __COMFORTABLE_SWIPE__start_h__
namespace comfortable_swipe {
void start();
void start();
}
#endif /* __COMFORTABLE_SWIPE__start_h__ */