From 5e0584de763854edb7e348d9f1fc43b2f3e6df0c Mon Sep 17 00:00:00 2001 From: Rico Tiongson Date: Thu, 7 Feb 2019 17:11:03 +0800 Subject: [PATCH] Add licenses in headers --- .../gesture/swipe_gesture.cpp | 23 ++++++++++++-- src/comfortable_swipe/gesture/swipe_gesture.h | 25 ++++++++++++---- src/comfortable_swipe/index.cpp | 6 ++-- src/comfortable_swipe/index.hpp | 30 +++++++------------ src/comfortable_swipe/service/autostart.cpp | 18 +++++++++++ src/comfortable_swipe/service/buffer.cpp | 18 +++++++++++ src/comfortable_swipe/service/help.cpp | 18 +++++++++++ src/comfortable_swipe/service/restart.cpp | 18 +++++++++++ src/comfortable_swipe/service/start.cpp | 18 +++++++++++ src/comfortable_swipe/service/stop.cpp | 18 +++++++++++ .../util/autostart_filename.cpp | 18 +++++++++++ src/comfortable_swipe/util/conf_filename.cpp | 18 +++++++++++ .../util/read_config_file.cpp | 22 ++++++++++++++ src/comfortable_swipe/util/regex.cpp | 18 +++++++++++ 14 files changed, 238 insertions(+), 30 deletions(-) diff --git a/src/comfortable_swipe/gesture/swipe_gesture.cpp b/src/comfortable_swipe/gesture/swipe_gesture.cpp index f1f45c5..ca123db 100644 --- a/src/comfortable_swipe/gesture/swipe_gesture.cpp +++ b/src/comfortable_swipe/gesture/swipe_gesture.cpp @@ -1,8 +1,25 @@ #ifndef __COMFORTABLE_SWIPE__gesture_swipe_gesture__ #define __COMFORTABLE_SWIPE__gesture_swipe_gesture__ +/* +Comfortable Swipe +by Rico Tiongson + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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::cout, std::endl -#include // std::abs #include "../index.hpp" extern "C" @@ -72,7 +89,9 @@ namespace comfortable_swipe if (this->fingers == 3) mask |= swipe_gesture::MSK_THREE_FINGERS; else if (this->fingers == 4) mask |= swipe_gesture::MSK_FOUR_FINGERS; - if (std::abs(x) > std::abs(y)) + const float absx = x >= 0 ? x : -x; + const float absy = y >= 0 ? y : -y; + if (absx > absy) { // horizontal mask |= swipe_gesture::MSK_HORIZONTAL; if (x < 0) diff --git a/src/comfortable_swipe/gesture/swipe_gesture.h b/src/comfortable_swipe/gesture/swipe_gesture.h index 7ae66a4..394962d 100644 --- a/src/comfortable_swipe/gesture/swipe_gesture.h +++ b/src/comfortable_swipe/gesture/swipe_gesture.h @@ -1,8 +1,23 @@ #ifndef __COMFORTABLE_SWIPE__gesture_swipe_gesture_h__ #define __COMFORTABLE_SWIPE__gesture_swipe_gesture_h__ -#include -#include +/* +Comfortable Swipe +by Rico Tiongson + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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 . +*/ extern "C" { @@ -34,7 +49,7 @@ namespace comfortable_swipe ~swipe_gesture(); - // fields + // fields for xdo int fingers; float dx, dy, udx, udy; xdo_t * xdo; @@ -47,7 +62,7 @@ namespace comfortable_swipe int previous_gesture; const char ** commands; - // methods + // hooks void update(); void begin(); void end(); @@ -69,4 +84,4 @@ namespace comfortable_swipe } #endif -#endif /* __COMFORTABLE_SWIPE__gesture_swipe_gesture_h__ */ \ No newline at end of file +#endif /* __COMFORTABLE_SWIPE__gesture_swipe_gesture_h__ */ diff --git a/src/comfortable_swipe/index.cpp b/src/comfortable_swipe/index.cpp index af16a54..b474877 100644 --- a/src/comfortable_swipe/index.cpp +++ b/src/comfortable_swipe/index.cpp @@ -1,3 +1,6 @@ +#ifndef __COMFORTABLE_SWIPE__ +#define __COMFORTABLE_SWIPE__ + /* Comfortable Swipe by Rico Tiongson @@ -16,9 +19,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef __COMFORTABLE_SWIPE__ -#define __COMFORTABLE_SWIPE__ - // export all modules here #include "gesture/swipe_gesture.cpp" #include "service/autostart.cpp" diff --git a/src/comfortable_swipe/index.hpp b/src/comfortable_swipe/index.hpp index 2cf0602..e13262e 100644 --- a/src/comfortable_swipe/index.hpp +++ b/src/comfortable_swipe/index.hpp @@ -1,3 +1,6 @@ +#ifndef __COMFORTABLE_SWIPE__index_hpp__ +#define __COMFORTABLE_SWIPE__index_hpp__ + /* Comfortable Swipe by Rico Tiongson @@ -16,10 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef __COMFORTABLE_SWIPE__index_hpp__ -#define __COMFORTABLE_SWIPE__index_hpp__ - -// global definitions +// global defines #ifndef __COMFORTABLE_SWIPE__PROGRAM__ #define __COMFORTABLE_SWIPE__PROGRAM__ "/usr/local/bin/comfortable-swipe" #endif /* __COMFORTABLE_SWIPE__PROGRAM__ */ @@ -28,30 +28,24 @@ along with this program. If not, see . #define __COMFORTABLE_SWIPE__CONFIG__ "/usr/local/share/comfortable-swipe/comfortable-swipe.conf" #endif /* __COMFORTABLE_SWIPE__CONFIG__ */ + #include // std::map #include // std::string #include "gesture/swipe_gesture.h" // other program header files - -#ifdef __cplusplus -// allow function overloading -extern "C" { -#endif - -namespace comfortable_swipe +extern "C" { - namespace util + namespace comfortable_swipe::util { extern const char* GESTURE_SWIPE_BEGIN_REGEX_PATTERN; extern const char* GESTURE_SWIPE_UPDATE_REGEX_PATTERN; extern const char* GESTURE_SWIPE_END_REGEX_PATTERN; - std::map read_config_file(const char*); const char* autostart_filename(); constexpr const char* conf_filename(); + std::map read_config_file(const char*); } - - namespace service + namespace comfortable_swipe::service { void autostart(); void buffer(); @@ -62,8 +56,4 @@ namespace comfortable_swipe } } -#ifdef __cplusplus -} -#endif - -#endif /* __COMFORTABLE_SWIPE__index_hpp__ */ \ No newline at end of file +#endif /* __COMFORTABLE_SWIPE__index_hpp__ */ diff --git a/src/comfortable_swipe/service/autostart.cpp b/src/comfortable_swipe/service/autostart.cpp index e730a06..1a4575f 100644 --- a/src/comfortable_swipe/service/autostart.cpp +++ b/src/comfortable_swipe/service/autostart.cpp @@ -1,6 +1,24 @@ #ifndef __COMFORTABLE_SWIPE__service_autostart__ #define __COMFORTABLE_SWIPE__service_autostart__ +/* +Comfortable Swipe +by Rico Tiongson + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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::cerr, std::cout, std::endl #include // std::ifstream, std::ofstream #include // std::string diff --git a/src/comfortable_swipe/service/buffer.cpp b/src/comfortable_swipe/service/buffer.cpp index 9293df9..c2d7303 100644 --- a/src/comfortable_swipe/service/buffer.cpp +++ b/src/comfortable_swipe/service/buffer.cpp @@ -1,6 +1,24 @@ #ifndef __COMFORTABLE_SWIPE__service_buffer__ #define __COMFORTABLE_SWIPE__service_buffer__ +/* +Comfortable Swipe +by Rico Tiongson + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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::stoi, std::stof #include // std::fgets_unlocked, stdin #include // std::regex, std::regex_match, std::cmatch diff --git a/src/comfortable_swipe/service/help.cpp b/src/comfortable_swipe/service/help.cpp index 1ce9e89..c73baf7 100644 --- a/src/comfortable_swipe/service/help.cpp +++ b/src/comfortable_swipe/service/help.cpp @@ -1,6 +1,24 @@ #ifndef __COMFORTABLE_SWIPE__service_help__ #define __COMFORTABLE_SWIPE__service_help__ +/* +Comfortable Swipe +by Rico Tiongson + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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::puts, std::printf #include "../index.hpp" diff --git a/src/comfortable_swipe/service/restart.cpp b/src/comfortable_swipe/service/restart.cpp index 3cbad55..67bbaf0 100644 --- a/src/comfortable_swipe/service/restart.cpp +++ b/src/comfortable_swipe/service/restart.cpp @@ -1,6 +1,24 @@ #ifndef __COMFORTABLE_SWIPE__service_restart__ #define __COMFORTABLE_SWIPE__service_restart__ +/* +Comfortable Swipe +by Rico Tiongson + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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 "../index.hpp" namespace comfortable_swipe::service diff --git a/src/comfortable_swipe/service/start.cpp b/src/comfortable_swipe/service/start.cpp index 6022fbf..82b8b32 100644 --- a/src/comfortable_swipe/service/start.cpp +++ b/src/comfortable_swipe/service/start.cpp @@ -1,6 +1,24 @@ #ifndef __COMFORTABLE_SWIPE__service_start__ #define __COMFORTABLE_SWIPE__service_start__ +/* +Comfortable Swipe +by Rico Tiongson + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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 "../index.hpp" #include // std::system diff --git a/src/comfortable_swipe/service/stop.cpp b/src/comfortable_swipe/service/stop.cpp index bd726c5..68bc025 100644 --- a/src/comfortable_swipe/service/stop.cpp +++ b/src/comfortable_swipe/service/stop.cpp @@ -4,6 +4,24 @@ #include // std::FILE, std::feof, std::fgets #include // std::atoi, std::system #include // std::string, std::to_string +/* +Comfortable Swipe +by Rico Tiongson + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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::runtime_error #include // popen, pclose, getpid diff --git a/src/comfortable_swipe/util/autostart_filename.cpp b/src/comfortable_swipe/util/autostart_filename.cpp index bca4729..d3b0046 100644 --- a/src/comfortable_swipe/util/autostart_filename.cpp +++ b/src/comfortable_swipe/util/autostart_filename.cpp @@ -1,6 +1,24 @@ #ifndef __COMFORTABLE_SWIPE__util_autostart_filename__ #define __COMFORTABLE_SWIPE__util_autostart_filename__ +/* +Comfortable Swipe +by Rico Tiongson + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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::string #include // getenv diff --git a/src/comfortable_swipe/util/conf_filename.cpp b/src/comfortable_swipe/util/conf_filename.cpp index d6da08f..5de5ae9 100644 --- a/src/comfortable_swipe/util/conf_filename.cpp +++ b/src/comfortable_swipe/util/conf_filename.cpp @@ -1,6 +1,24 @@ #ifndef __COMFORTABLE_SWIPE__util_conf_filename__ #define __COMFORTABLE_SWIPE__util_conf_filename__ +/* +Comfortable Swipe +by Rico Tiongson + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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 "../index.hpp" namespace comfortable_swipe::util diff --git a/src/comfortable_swipe/util/read_config_file.cpp b/src/comfortable_swipe/util/read_config_file.cpp index 2ab2cdb..d3eafb7 100644 --- a/src/comfortable_swipe/util/read_config_file.cpp +++ b/src/comfortable_swipe/util/read_config_file.cpp @@ -1,3 +1,24 @@ +#ifndef __COMFORTABLE_SWIPE__util_read_config_file__ +#define __COMFORTABLE_SWIPE__util_read_config_file__ + +/* +Comfortable Swipe +by Rico Tiongson + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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::map #include // std::string #include // std::ifstream @@ -76,3 +97,4 @@ namespace comfortable_swipe::util return conf; } } +#endif /* __COMFORTABLE_SWIPE__util_read_config_file__ */ diff --git a/src/comfortable_swipe/util/regex.cpp b/src/comfortable_swipe/util/regex.cpp index 9dc12e3..b0556ce 100644 --- a/src/comfortable_swipe/util/regex.cpp +++ b/src/comfortable_swipe/util/regex.cpp @@ -1,6 +1,24 @@ #ifndef __COMFORTABLE_SWIPE__util_regex__ #define __COMFORTABLE_SWIPE__util_regex__ +/* +Comfortable Swipe +by Rico Tiongson + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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 . +*/ + namespace comfortable_swipe::util { /**