From 28612f5414f6975411f030ef35701a6daeec3917 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Thu, 9 Aug 2012 11:42:56 -0300 Subject: [PATCH 1/5] Implemented exit from expo screen with only one click. --- plugins/expo/src/expo.cpp | 6 +++++- plugins/expo/src/expo.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/expo/src/expo.cpp b/plugins/expo/src/expo.cpp index 6db2d1ca1..8134528c5 100644 --- a/plugins/expo/src/expo.cpp +++ b/plugins/expo/src/expo.cpp @@ -35,6 +35,7 @@ COMPIZ_PLUGIN_20090315 (expo, ExpoPluginVTable); (sigmoid (1) - sigmoid (0))) #define interpolate(a, b, val) (((val) * (a)) + ((1 - (val)) * (b))) +#define DND_THRESHOLD 5 bool ExpoScreen::dndInit (CompAction *action, @@ -354,6 +355,7 @@ ExpoScreen::handleEvent (XEvent *event) doubleClick = false; } cScreen->damageScreen (); + prevClickPoint = CompPoint(event->xbutton.x, event->xbutton.y); } break; @@ -367,7 +369,9 @@ ExpoScreen::handleEvent (XEvent *event) clickTime = 0; doubleClick = false; } - else if (doubleClick) + else if (doubleClick || + ((abs (prevClickPoint.x () - event->xbutton.x) <= DND_THRESHOLD) && + (abs (prevClickPoint.y () - event->xbutton.y) <= DND_THRESHOLD))) { CompAction& action = optionGetExpoKey (); diff --git a/plugins/expo/src/expo.h b/plugins/expo/src/expo.h index c5167f380..dafd506aa 100644 --- a/plugins/expo/src/expo.h +++ b/plugins/expo/src/expo.h @@ -86,6 +86,7 @@ class ExpoScreen : CompPoint prevCursor; CompPoint newCursor; + CompPoint prevClickPoint; CompPoint origVp; CompPoint selectedVp; -- GitLab From aa076d4b5cb998cac7ddda46d5529d9817289857 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Thu, 9 Aug 2012 16:04:59 -0300 Subject: [PATCH 2/5] Declared DND_THRESHOLD as "static const unsigned int" instead of "define"; --- plugins/expo/src/expo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/expo/src/expo.cpp b/plugins/expo/src/expo.cpp index 8134528c5..d175d8ad4 100644 --- a/plugins/expo/src/expo.cpp +++ b/plugins/expo/src/expo.cpp @@ -35,7 +35,7 @@ COMPIZ_PLUGIN_20090315 (expo, ExpoPluginVTable); (sigmoid (1) - sigmoid (0))) #define interpolate(a, b, val) (((val) * (a)) + ((1 - (val)) * (b))) -#define DND_THRESHOLD 5 +static const unsigned int DND_THRESHOLD = 5; bool ExpoScreen::dndInit (CompAction *action, -- GitLab From 55ca5c4199e7a8e3c96e5ccee84a2550f5548107 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Thu, 9 Aug 2012 17:14:36 -0300 Subject: [PATCH 3/5] =?UTF-8?q?Created=20new=20file=20with=20=C2=A8clickMo?= =?UTF-8?q?vementInThreshold=C2=A8=20function.=20Created=20unit=20test=20f?= =?UTF-8?q?or=20function=20=C2=A8clickMovementInThreshold=C2=A8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/expo/CMakeLists.txt | 6 +- .../expo/src/click_threshold/CMakeLists.txt | 33 +++++++ .../click_threshold/include/click-threshold.h | 38 ++++++++ .../click_threshold/src/click-threshold.cpp | 39 ++++++++ .../src/click_threshold/tests/CMakeLists.txt | 19 ++++ .../tests/test-expo-click-threshold.cpp | 88 +++++++++++++++++++ plugins/expo/src/expo.cpp | 7 +- 7 files changed, 226 insertions(+), 4 deletions(-) create mode 100644 plugins/expo/src/click_threshold/CMakeLists.txt create mode 100644 plugins/expo/src/click_threshold/include/click-threshold.h create mode 100644 plugins/expo/src/click_threshold/src/click-threshold.cpp create mode 100644 plugins/expo/src/click_threshold/tests/CMakeLists.txt create mode 100644 plugins/expo/src/click_threshold/tests/test-expo-click-threshold.cpp diff --git a/plugins/expo/CMakeLists.txt b/plugins/expo/CMakeLists.txt index 3aab4b869..5c477f55e 100644 --- a/plugins/expo/CMakeLists.txt +++ b/plugins/expo/CMakeLists.txt @@ -3,5 +3,9 @@ include (FindOpenGL) include (CompizPlugin) if (OPENGL_GLU_FOUND) - compiz_plugin (expo PLUGINDEPS composite opengl LIBRARIES ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR}) + add_subdirectory (src/click_threshold) + include_directories (src/click_threshold/include) + + compiz_plugin (expo PLUGINDEPS composite opengl LIBRARIES ${OPENGL_glu_LIBRARY} compiz_expo_click_threshold INCDIRS ${OPENGL_INCLUDE_DIR}) endif (OPENGL_GLU_FOUND) + diff --git a/plugins/expo/src/click_threshold/CMakeLists.txt b/plugins/expo/src/click_threshold/CMakeLists.txt new file mode 100644 index 000000000..edcd34ff3 --- /dev/null +++ b/plugins/expo/src/click_threshold/CMakeLists.txt @@ -0,0 +1,33 @@ +INCLUDE_DIRECTORIES ( + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${Boost_INCLUDE_DIRS} + ${GLIBMM_INCLUDE_DIRS} +) + +LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS} ${COMPIZ_LIBRARY_DIRS}) + +SET ( + PRIVATE_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/include/click-threshold.h +) + +SET( + SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/src/click-threshold.cpp +) + +ADD_LIBRARY( + compiz_expo_click_threshold STATIC + ${SRCS} + ${PRIVATE_HEADERS} +) + +if (COMPIZ_BUILD_TESTING) +ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests ) +endif (COMPIZ_BUILD_TESTING) + +TARGET_LINK_LIBRARIES( + compiz_expo_click_threshold + compiz_point +) diff --git a/plugins/expo/src/click_threshold/include/click-threshold.h b/plugins/expo/src/click_threshold/include/click-threshold.h new file mode 100644 index 000000000..6f4c58a1c --- /dev/null +++ b/plugins/expo/src/click_threshold/include/click-threshold.h @@ -0,0 +1,38 @@ +/** + * + * Compiz Expo plugin + * + * click-threshold.h + * + * Copyright © 2012 Canonical Ltd. + * + * Authors: + * Renato Araujo Oliviera Filho + * + * 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 2 + * 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. + * + **/ + +#ifndef _COMPIZ_EXPO_CLICK_THRESHOLD_H +#define _COMPIZ_EXPO_CLICK_THRESHOLD_H + +#include + +namespace compiz +{ + namespace expo + { + bool clickMovementInThreshold(const CompPoint &previousPoint, + int x, int y); + } +} + +#endif diff --git a/plugins/expo/src/click_threshold/src/click-threshold.cpp b/plugins/expo/src/click_threshold/src/click-threshold.cpp new file mode 100644 index 000000000..06bd272b3 --- /dev/null +++ b/plugins/expo/src/click_threshold/src/click-threshold.cpp @@ -0,0 +1,39 @@ +/** + * + * Compiz Expo plugin + * + * click-threshold.cpp + * + * Copyright © 2012 Canonical Ltd. + * + * Authors: + * Renato Araujo Oliviera Filho + * + * 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 2 + * 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. + * + **/ + + +#include "click-threshold.h" +#include + +static const unsigned int DND_THRESHOLD = 5; + +bool +compiz::expo::clickMovementInThreshold(const CompPoint &previousPoint, + int x, int y) +{ + if ((abs (previousPoint.x () - x) <= static_cast(DND_THRESHOLD)) && + (abs (previousPoint.y () - y) <= static_cast(DND_THRESHOLD))) + return true; + else + return false; +} diff --git a/plugins/expo/src/click_threshold/tests/CMakeLists.txt b/plugins/expo/src/click_threshold/tests/CMakeLists.txt new file mode 100644 index 000000000..bb5262792 --- /dev/null +++ b/plugins/expo/src/click_threshold/tests/CMakeLists.txt @@ -0,0 +1,19 @@ +if (NOT GTEST_FOUND) + message ("Google Test not found - cannot build tests!") + set (COMPIZ_BUILD_TESTING OFF) +endif (NOT GTEST_FOUND) + +include_directories (${GTEST_INCLUDE_DIRS}) + +link_directories (${COMPIZ_LIBRARY_DIRS}) + +add_executable (compiz_test_expo_click_threshold + ${CMAKE_CURRENT_SOURCE_DIR}/test-expo-click-threshold.cpp) + +target_link_libraries (compiz_test_expo_click_threshold + compiz_expo_click_threshold + ${GTEST_BOTH_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. + ) + +compiz_discover_tests (compiz_test_expo_click_threshold COVERAGE compiz_expo_click_threshold) diff --git a/plugins/expo/src/click_threshold/tests/test-expo-click-threshold.cpp b/plugins/expo/src/click_threshold/tests/test-expo-click-threshold.cpp new file mode 100644 index 000000000..4068c5dcd --- /dev/null +++ b/plugins/expo/src/click_threshold/tests/test-expo-click-threshold.cpp @@ -0,0 +1,88 @@ +/* + * Copyright © 2012 Canonical Ltd. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of + * Canonical Ltd. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior permission. + * Canonical Ltd. makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Authored by: Renato Araujo Oliveira Filho + */ + + +#include + +#include "click-threshold.h" + +class ExpoClickThresholdTest : + public ::testing::Test +{ +}; + +TEST(ExpoClickThresholdTest, TestNotMove) +{ + CompPoint first(10, 10); + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (first, 10, 10)); +} + +TEST(ExpoClickThresholdTest, TestMoveNearLeft) +{ + CompPoint first(10, 10); + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (first, 8, 8)); +} + +TEST(ExpoClickThresholdTest, TestMoveNearRight) +{ + CompPoint first(10, 10); + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (first, 13, 13)); +} + +TEST(ExpoClickThresholdTest, TestMoveFarLeft) +{ + CompPoint first(10, 10); + EXPECT_FALSE(compiz::expo::clickMovementInThreshold (first, 1, 1)); +} + +TEST(ExpoClickThresholdTest, TestMoveFarRight) +{ + CompPoint first(10, 10); + EXPECT_FALSE(compiz::expo::clickMovementInThreshold (first, 30, 30)); +} + +TEST(ExpoClickThresholdTest, TestMoveNearX) +{ + CompPoint first(10, 10); + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (first, 13, 10)); +} + +TEST(ExpoClickThresholdTest, TestMoveNearY) +{ + CompPoint first(10, 10); + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (first, 10, 13)); +} + +TEST(ExpoClickThresholdTest, TestMoveFarX) +{ + CompPoint first(10, 10); + EXPECT_FALSE(compiz::expo::clickMovementInThreshold (first, 30, 10)); +} + +TEST(ExpoClickThresholdTest, TestMoveFarY) +{ + CompPoint first(10, 10); + EXPECT_FALSE(compiz::expo::clickMovementInThreshold (first, 10, 30)); +} diff --git a/plugins/expo/src/expo.cpp b/plugins/expo/src/expo.cpp index d175d8ad4..1a89d226d 100644 --- a/plugins/expo/src/expo.cpp +++ b/plugins/expo/src/expo.cpp @@ -24,6 +24,7 @@ **/ #include "expo.h" +#include "click-threshold.h" #include #include #include @@ -35,7 +36,6 @@ COMPIZ_PLUGIN_20090315 (expo, ExpoPluginVTable); (sigmoid (1) - sigmoid (0))) #define interpolate(a, b, val) (((val) * (a)) + ((1 - (val)) * (b))) -static const unsigned int DND_THRESHOLD = 5; bool ExpoScreen::dndInit (CompAction *action, @@ -370,8 +370,9 @@ ExpoScreen::handleEvent (XEvent *event) doubleClick = false; } else if (doubleClick || - ((abs (prevClickPoint.x () - event->xbutton.x) <= DND_THRESHOLD) && - (abs (prevClickPoint.y () - event->xbutton.y) <= DND_THRESHOLD))) + compiz::expo::clickMovementInThreshold(prevClickPoint, + event->xbutton.x, + event->xbutton.y)) { CompAction& action = optionGetExpoKey (); -- GitLab From 789acdb874250e806f5ff376af2aaa7831e2cc8f Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Fri, 10 Aug 2012 09:04:58 -0300 Subject: [PATCH 4/5] Used lower case for reserved words in cmake files. --- plugins/expo/src/click_threshold/CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/expo/src/click_threshold/CMakeLists.txt b/plugins/expo/src/click_threshold/CMakeLists.txt index edcd34ff3..45c64cb39 100644 --- a/plugins/expo/src/click_threshold/CMakeLists.txt +++ b/plugins/expo/src/click_threshold/CMakeLists.txt @@ -1,33 +1,33 @@ -INCLUDE_DIRECTORIES ( +include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src ${Boost_INCLUDE_DIRS} ${GLIBMM_INCLUDE_DIRS} ) -LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS} ${COMPIZ_LIBRARY_DIRS}) +link_directories (${GLIBMM_LIBRARY_DIRS} ${COMPIZ_LIBRARY_DIRS}) -SET ( +set ( PRIVATE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/click-threshold.h ) -SET( +set ( SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/click-threshold.cpp ) -ADD_LIBRARY( +add_library ( compiz_expo_click_threshold STATIC ${SRCS} ${PRIVATE_HEADERS} ) if (COMPIZ_BUILD_TESTING) -ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests ) + add_subdirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/tests ) endif (COMPIZ_BUILD_TESTING) -TARGET_LINK_LIBRARIES( +target_link_libraries ( compiz_expo_click_threshold compiz_point ) -- GitLab From 3adbb8a521f4ec79c0b0cf836dc28ec8e0bac202 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Fri, 10 Aug 2012 09:14:07 -0300 Subject: [PATCH 5/5] Changed "clickMovementInThreshold" signature to use int instead of CompPoint. --- .../click_threshold/include/click-threshold.h | 4 +-- .../click_threshold/src/click-threshold.cpp | 10 +++---- .../tests/test-expo-click-threshold.cpp | 27 +++++++------------ plugins/expo/src/expo.cpp | 3 ++- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/plugins/expo/src/click_threshold/include/click-threshold.h b/plugins/expo/src/click_threshold/include/click-threshold.h index 6f4c58a1c..0661b9db9 100644 --- a/plugins/expo/src/click_threshold/include/click-threshold.h +++ b/plugins/expo/src/click_threshold/include/click-threshold.h @@ -30,8 +30,8 @@ namespace compiz { namespace expo { - bool clickMovementInThreshold(const CompPoint &previousPoint, - int x, int y); + bool clickMovementInThreshold(int previousX, int previousY, + int currentX, int currentY); } } diff --git a/plugins/expo/src/click_threshold/src/click-threshold.cpp b/plugins/expo/src/click_threshold/src/click-threshold.cpp index 06bd272b3..0de16dce1 100644 --- a/plugins/expo/src/click_threshold/src/click-threshold.cpp +++ b/plugins/expo/src/click_threshold/src/click-threshold.cpp @@ -25,14 +25,14 @@ #include "click-threshold.h" #include -static const unsigned int DND_THRESHOLD = 5; +static const int DND_THRESHOLD = 5; bool -compiz::expo::clickMovementInThreshold(const CompPoint &previousPoint, - int x, int y) +compiz::expo::clickMovementInThreshold(int previousX, int previousY, + int currentX, int currentY) { - if ((abs (previousPoint.x () - x) <= static_cast(DND_THRESHOLD)) && - (abs (previousPoint.y () - y) <= static_cast(DND_THRESHOLD))) + if ((abs (previousX - currentX) <= DND_THRESHOLD) && + (abs (previousY - currentY) <= DND_THRESHOLD)) return true; else return false; diff --git a/plugins/expo/src/click_threshold/tests/test-expo-click-threshold.cpp b/plugins/expo/src/click_threshold/tests/test-expo-click-threshold.cpp index 4068c5dcd..ea33b9fad 100644 --- a/plugins/expo/src/click_threshold/tests/test-expo-click-threshold.cpp +++ b/plugins/expo/src/click_threshold/tests/test-expo-click-threshold.cpp @@ -35,54 +35,45 @@ class ExpoClickThresholdTest : TEST(ExpoClickThresholdTest, TestNotMove) { - CompPoint first(10, 10); - EXPECT_TRUE(compiz::expo::clickMovementInThreshold (first, 10, 10)); + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (10, 10, 10, 10)); } TEST(ExpoClickThresholdTest, TestMoveNearLeft) { - CompPoint first(10, 10); - EXPECT_TRUE(compiz::expo::clickMovementInThreshold (first, 8, 8)); + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (10, 10, 8, 8)); } TEST(ExpoClickThresholdTest, TestMoveNearRight) { - CompPoint first(10, 10); - EXPECT_TRUE(compiz::expo::clickMovementInThreshold (first, 13, 13)); + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (10, 10, 13, 13)); } TEST(ExpoClickThresholdTest, TestMoveFarLeft) { - CompPoint first(10, 10); - EXPECT_FALSE(compiz::expo::clickMovementInThreshold (first, 1, 1)); + EXPECT_FALSE(compiz::expo::clickMovementInThreshold (10, 10, 1, 1)); } TEST(ExpoClickThresholdTest, TestMoveFarRight) { - CompPoint first(10, 10); - EXPECT_FALSE(compiz::expo::clickMovementInThreshold (first, 30, 30)); + EXPECT_FALSE(compiz::expo::clickMovementInThreshold (10, 10, 30, 30)); } TEST(ExpoClickThresholdTest, TestMoveNearX) { - CompPoint first(10, 10); - EXPECT_TRUE(compiz::expo::clickMovementInThreshold (first, 13, 10)); + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (10, 10, 13, 10)); } TEST(ExpoClickThresholdTest, TestMoveNearY) { - CompPoint first(10, 10); - EXPECT_TRUE(compiz::expo::clickMovementInThreshold (first, 10, 13)); + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (10, 10, 10, 13)); } TEST(ExpoClickThresholdTest, TestMoveFarX) { - CompPoint first(10, 10); - EXPECT_FALSE(compiz::expo::clickMovementInThreshold (first, 30, 10)); + EXPECT_FALSE(compiz::expo::clickMovementInThreshold (10, 10, 30, 10)); } TEST(ExpoClickThresholdTest, TestMoveFarY) { - CompPoint first(10, 10); - EXPECT_FALSE(compiz::expo::clickMovementInThreshold (first, 10, 30)); + EXPECT_FALSE(compiz::expo::clickMovementInThreshold (10, 10, 10, 30)); } diff --git a/plugins/expo/src/expo.cpp b/plugins/expo/src/expo.cpp index 1a89d226d..b98b80e6c 100644 --- a/plugins/expo/src/expo.cpp +++ b/plugins/expo/src/expo.cpp @@ -370,7 +370,8 @@ ExpoScreen::handleEvent (XEvent *event) doubleClick = false; } else if (doubleClick || - compiz::expo::clickMovementInThreshold(prevClickPoint, + compiz::expo::clickMovementInThreshold(prevClickPoint.x (), + prevClickPoint.y (), event->xbutton.x, event->xbutton.y)) { -- GitLab