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

@ -25,22 +25,17 @@ 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:
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 */
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
@ -54,7 +49,7 @@ namespace comfortable_swipe::gesture
// override this when keyboard gesture is to be performed
virtual void do_keyboard_gesture(int mask);
protected:
protected:
// stores square of threshold so we can compute faster
float threshold_squared;
@ -62,9 +57,9 @@ namespace comfortable_swipe::gesture
int previous_gesture;
// stores all command strings for xdo to execute
const char ** commands;
const char **commands;
public:
public:
// static enums we will use for gesture matching
static const int FRESH;
static const int MSK_THREE_FINGERS;
@ -73,9 +68,9 @@ namespace comfortable_swipe::gesture
static const int MSK_POSITIVE;
static const int MSK_HORIZONTAL;
static const int MSK_VERTICAL;
static const char * const command_map[8];
};
}
static const char *const command_map[8];
};
} // namespace comfortable_swipe::gesture
#ifdef __cplusplus
}

View File

@ -25,15 +25,12 @@ 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:
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
mouse_hold_gesture(const char *hold3, // 3 finger mouse down
const char *hold4 // 4 finger mouse down
);
// the button being clicked
@ -47,22 +44,22 @@ namespace comfortable_swipe::gesture
virtual void end() override;
// provide our own mouse functions
virtual void do_mousedown(const char*);
virtual void do_mouseup(const char*);
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*);
static int parse_mouse_button(const char *);
protected:
protected:
// command holders
const char * hold3;
const char * hold4;
const char *hold3;
const char *hold4;
// flag we can use to check if mouse is down
bool flag_mousedown;
};
}
};
} // namespace comfortable_swipe::gesture
#ifdef __cplusplus
}

View File

@ -25,11 +25,9 @@ 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:
namespace comfortable_swipe::gesture {
class swipe_gesture : public xdo_gesture {
public:
// constructor
swipe_gesture();
@ -51,20 +49,20 @@ namespace comfortable_swipe::gesture
virtual void end();
virtual bool parse_line(const char *);
protected:
protected:
// location of mouse
int screen_num, ix, iy;
// optimization flag for checking if GESTURE_SWIPE_BEGIN was dispatched
bool flag_swiping;
public:
public:
// regex patterns
static const char* GESTURE_BEGIN_REGEX_PATTERN;
static const char* GESTURE_UPDATE_REGEX_PATTERN;
static const char* GESTURE_END_REGEX_PATTERN;
};
}
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:
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__ */