Commit 743d3cfdc5df9dd096bdda63060f50ecfa95a618

Authored by unknown
2 parents a09a7ed6 b45e0497

Import upstream version 0.9.8+bzr3307

plugins/expo/CMakeLists.txt
... ... @@ -3,5 +3,9 @@ include (FindOpenGL)
3 3 include (CompizPlugin)
4 4  
5 5 if (OPENGL_GLU_FOUND)
6   - compiz_plugin (expo PLUGINDEPS composite opengl LIBRARIES ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
  6 + add_subdirectory (src/click_threshold)
  7 + include_directories (src/click_threshold/include)
  8 +
  9 + compiz_plugin (expo PLUGINDEPS composite opengl LIBRARIES ${OPENGL_glu_LIBRARY} compiz_expo_click_threshold INCDIRS ${OPENGL_INCLUDE_DIR})
7 10 endif (OPENGL_GLU_FOUND)
  11 +
... ...
plugins/expo/src/click_threshold/CMakeLists.txt 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +include_directories (
  2 + ${CMAKE_CURRENT_SOURCE_DIR}/include
  3 + ${CMAKE_CURRENT_SOURCE_DIR}/src
  4 + ${Boost_INCLUDE_DIRS}
  5 + ${GLIBMM_INCLUDE_DIRS}
  6 +)
  7 +
  8 +link_directories (${GLIBMM_LIBRARY_DIRS} ${COMPIZ_LIBRARY_DIRS})
  9 +
  10 +set (
  11 + PRIVATE_HEADERS
  12 + ${CMAKE_CURRENT_SOURCE_DIR}/include/click-threshold.h
  13 +)
  14 +
  15 +set (
  16 + SRCS
  17 + ${CMAKE_CURRENT_SOURCE_DIR}/src/click-threshold.cpp
  18 +)
  19 +
  20 +add_library (
  21 + compiz_expo_click_threshold STATIC
  22 + ${SRCS}
  23 + ${PRIVATE_HEADERS}
  24 +)
  25 +
  26 +if (COMPIZ_BUILD_TESTING)
  27 + add_subdirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/tests )
  28 +endif (COMPIZ_BUILD_TESTING)
  29 +
  30 +target_link_libraries (
  31 + compiz_expo_click_threshold
  32 + compiz_point
  33 +)
... ...
plugins/expo/src/click_threshold/include/click-threshold.h 0 → 100644
... ... @@ -0,0 +1,38 @@
  1 +/**
  2 + *
  3 + * Compiz Expo plugin
  4 + *
  5 + * click-threshold.h
  6 + *
  7 + * Copyright © 2012 Canonical Ltd.
  8 + *
  9 + * Authors:
  10 + * Renato Araujo Oliviera Filho <renato@canonical.com>
  11 + *
  12 + * This program is free software; you can redistribute it and/or
  13 + * modify it under the terms of the GNU General Public License
  14 + * as published by the Free Software Foundation; either version 2
  15 + * of the License, or (at your option) any later version.
  16 + *
  17 + * This program is distributed in the hope that it will be useful,
  18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20 + * GNU General Public License for more details.
  21 + *
  22 + **/
  23 +
  24 +#ifndef _COMPIZ_EXPO_CLICK_THRESHOLD_H
  25 +#define _COMPIZ_EXPO_CLICK_THRESHOLD_H
  26 +
  27 +#include <core/point.h>
  28 +
  29 +namespace compiz
  30 +{
  31 + namespace expo
  32 + {
  33 + bool clickMovementInThreshold(int previousX, int previousY,
  34 + int currentX, int currentY);
  35 + }
  36 +}
  37 +
  38 +#endif
... ...
plugins/expo/src/click_threshold/src/click-threshold.cpp 0 → 100644
... ... @@ -0,0 +1,39 @@
  1 +/**
  2 + *
  3 + * Compiz Expo plugin
  4 + *
  5 + * click-threshold.cpp
  6 + *
  7 + * Copyright © 2012 Canonical Ltd.
  8 + *
  9 + * Authors:
  10 + * Renato Araujo Oliviera Filho <renato@canonical.com>
  11 + *
  12 + * This program is free software; you can redistribute it and/or
  13 + * modify it under the terms of the GNU General Public License
  14 + * as published by the Free Software Foundation; either version 2
  15 + * of the License, or (at your option) any later version.
  16 + *
  17 + * This program is distributed in the hope that it will be useful,
  18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20 + * GNU General Public License for more details.
  21 + *
  22 + **/
  23 +
  24 +
  25 +#include "click-threshold.h"
  26 +#include <stdlib.h>
  27 +
  28 +static const int DND_THRESHOLD = 5;
  29 +
  30 +bool
  31 +compiz::expo::clickMovementInThreshold(int previousX, int previousY,
  32 + int currentX, int currentY)
  33 +{
  34 + if ((abs (previousX - currentX) <= DND_THRESHOLD) &&
  35 + (abs (previousY - currentY) <= DND_THRESHOLD))
  36 + return true;
  37 + else
  38 + return false;
  39 +}
... ...
plugins/expo/src/click_threshold/tests/CMakeLists.txt 0 → 100644
... ... @@ -0,0 +1,19 @@
  1 +if (NOT GTEST_FOUND)
  2 + message ("Google Test not found - cannot build tests!")
  3 + set (COMPIZ_BUILD_TESTING OFF)
  4 +endif (NOT GTEST_FOUND)
  5 +
  6 +include_directories (${GTEST_INCLUDE_DIRS})
  7 +
  8 +link_directories (${COMPIZ_LIBRARY_DIRS})
  9 +
  10 +add_executable (compiz_test_expo_click_threshold
  11 + ${CMAKE_CURRENT_SOURCE_DIR}/test-expo-click-threshold.cpp)
  12 +
  13 +target_link_libraries (compiz_test_expo_click_threshold
  14 + compiz_expo_click_threshold
  15 + ${GTEST_BOTH_LIBRARIES}
  16 + ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
  17 + )
  18 +
  19 +compiz_discover_tests (compiz_test_expo_click_threshold COVERAGE compiz_expo_click_threshold)
... ...
plugins/expo/src/click_threshold/tests/test-expo-click-threshold.cpp 0 → 100644
... ... @@ -0,0 +1,79 @@
  1 +/*
  2 + * Copyright © 2012 Canonical Ltd.
  3 + *
  4 + * Permission to use, copy, modify, distribute, and sell this software
  5 + * and its documentation for any purpose is hereby granted without
  6 + * fee, provided that the above copyright notice appear in all copies
  7 + * and that both that copyright notice and this permission notice
  8 + * appear in supporting documentation, and that the name of
  9 + * Canonical Ltd. not be used in advertising or publicity pertaining to
  10 + * distribution of the software without specific, written prior permission.
  11 + * Canonical Ltd. makes no representations about the suitability of this
  12 + * software for any purpose. It is provided "as is" without express or
  13 + * implied warranty.
  14 + *
  15 + * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  16 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
  17 + * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  18 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
  19 + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  20 + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  21 + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22 + *
  23 + * Authored by: Renato Araujo Oliveira Filho <renato@canonical.com>
  24 + */
  25 +
  26 +
  27 +#include <gtest/gtest.h>
  28 +
  29 +#include "click-threshold.h"
  30 +
  31 +class ExpoClickThresholdTest :
  32 + public ::testing::Test
  33 +{
  34 +};
  35 +
  36 +TEST(ExpoClickThresholdTest, TestNotMove)
  37 +{
  38 + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (10, 10, 10, 10));
  39 +}
  40 +
  41 +TEST(ExpoClickThresholdTest, TestMoveNearLeft)
  42 +{
  43 + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (10, 10, 8, 8));
  44 +}
  45 +
  46 +TEST(ExpoClickThresholdTest, TestMoveNearRight)
  47 +{
  48 + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (10, 10, 13, 13));
  49 +}
  50 +
  51 +TEST(ExpoClickThresholdTest, TestMoveFarLeft)
  52 +{
  53 + EXPECT_FALSE(compiz::expo::clickMovementInThreshold (10, 10, 1, 1));
  54 +}
  55 +
  56 +TEST(ExpoClickThresholdTest, TestMoveFarRight)
  57 +{
  58 + EXPECT_FALSE(compiz::expo::clickMovementInThreshold (10, 10, 30, 30));
  59 +}
  60 +
  61 +TEST(ExpoClickThresholdTest, TestMoveNearX)
  62 +{
  63 + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (10, 10, 13, 10));
  64 +}
  65 +
  66 +TEST(ExpoClickThresholdTest, TestMoveNearY)
  67 +{
  68 + EXPECT_TRUE(compiz::expo::clickMovementInThreshold (10, 10, 10, 13));
  69 +}
  70 +
  71 +TEST(ExpoClickThresholdTest, TestMoveFarX)
  72 +{
  73 + EXPECT_FALSE(compiz::expo::clickMovementInThreshold (10, 10, 30, 10));
  74 +}
  75 +
  76 +TEST(ExpoClickThresholdTest, TestMoveFarY)
  77 +{
  78 + EXPECT_FALSE(compiz::expo::clickMovementInThreshold (10, 10, 10, 30));
  79 +}
... ...
plugins/expo/src/expo.cpp
... ... @@ -24,6 +24,7 @@
24 24 **/
25 25  
26 26 #include "expo.h"
  27 +#include "click-threshold.h"
27 28 #include <math.h>
28 29 #include <GL/glu.h>
29 30 #include <X11/cursorfont.h>
... ... @@ -354,6 +355,7 @@ ExpoScreen::handleEvent (XEvent *event)
354 355 doubleClick = false;
355 356 }
356 357 cScreen->damageScreen ();
  358 + prevClickPoint = CompPoint(event->xbutton.x, event->xbutton.y);
357 359 }
358 360 break;
359 361  
... ... @@ -367,7 +369,11 @@ ExpoScreen::handleEvent (XEvent *event)
367 369 clickTime = 0;
368 370 doubleClick = false;
369 371 }
370   - else if (doubleClick)
  372 + else if (doubleClick ||
  373 + compiz::expo::clickMovementInThreshold(prevClickPoint.x (),
  374 + prevClickPoint.y (),
  375 + event->xbutton.x,
  376 + event->xbutton.y))
371 377 {
372 378 CompAction& action = optionGetExpoKey ();
373 379  
... ...
plugins/expo/src/expo.h
... ... @@ -86,6 +86,7 @@ class ExpoScreen :
86 86  
87 87 CompPoint prevCursor;
88 88 CompPoint newCursor;
  89 + CompPoint prevClickPoint;
89 90  
90 91 CompPoint origVp;
91 92 CompPoint selectedVp;
... ...