Merge lp:~smspillaz/unity/unity.gesture_tests_no_sed into lp:unity

Proposed by Sam Spilsbury
Status: Work in progress
Proposed branch: lp:~smspillaz/unity/unity.gesture_tests_no_sed
Merge into: lp:unity
Diff against target: 6804 lines (+3279/-1598)
62 files modified
CMakeLists.txt (+1/-0)
gestures/CMakeLists.txt (+59/-0)
gestures/GesturalWindowSwitcher.cpp (+53/-51)
gestures/GesturalWindowSwitcher.h (+40/-6)
gestures/UnityGestureBroker.cpp (+41/-42)
gestures/UnityGestureBroker.h (+35/-6)
gestures/WindowGestureTarget.cpp (+68/-70)
gestures/WindowGestureTarget.h (+103/-10)
launcher/StandaloneSwitcher.cpp (+42/-30)
launcher/SwitcherController.cpp (+159/-44)
launcher/SwitcherController.h (+119/-16)
launcher/SwitcherView.cpp (+205/-37)
launcher/SwitcherView.h (+132/-34)
plugins/unityshell/CMakeLists.txt (+7/-4)
plugins/unityshell/src/unity-switcher-accessible.cpp (+12/-11)
plugins/unityshell/src/unitya11y.cpp (+1/-1)
plugins/unityshell/src/unityshell.cpp (+115/-8)
plugins/unityshell/src/unityshell.h (+5/-1)
tests/CMakeLists.txt (+1/-0)
tests/MockSwitcherController.h (+62/-0)
tests/MockSwitcherController.h.moved (+64/-0)
tests/MockSwitcherView.h (+56/-0)
tests/MockSwitcherView.h.moved (+56/-0)
tests/MockWindowManager.h (+4/-0)
tests/StubSwitcherController.h (+155/-0)
tests/StubSwitcherController.h.moved (+157/-0)
tests/test-gestures/CMakeLists.txt (+10/-64)
tests/test-gestures/FakeGestureEvent.h (+6/-0)
tests/test-gestures/GesturalWindowSwitcherMock.h (+13/-6)
tests/test-gestures/MockGestureManipulatedWindow.h (+57/-0)
tests/test-gestures/MockGestureTarget.h (+15/-0)
tests/test-gestures/MockMousePointer.h (+17/-0)
tests/test-gestures/NuxMock.h (+0/-27)
tests/test-gestures/PluginAdapterMock.cpp (+0/-33)
tests/test-gestures/PluginAdapterMock.h (+0/-38)
tests/test-gestures/SwitcherControllerMock.h (+0/-97)
tests/test-gestures/UnityGestureTargetMock.h (+0/-15)
tests/test-gestures/WindowGestureTargetMock.h (+16/-9)
tests/test-gestures/X11_mock.cpp (+0/-40)
tests/test-gestures/X11_mock.h (+0/-37)
tests/test-gestures/compiz_mock/core/core.h (+0/-29)
tests/test-gestures/compiz_mock/core/screen.h (+0/-77)
tests/test-gestures/compiz_mock/core/timer.h (+0/-79)
tests/test-gestures/compiz_mock/core/window.h (+0/-79)
tests/test-gestures/sed_script_broker (+0/-12)
tests/test-gestures/sed_script_gesture (+0/-18)
tests/test-gestures/sed_script_switcher (+0/-25)
tests/test-gestures/test_gestural_window_switcher.cpp (+291/-177)
tests/test-gestures/test_gesture_broker.cpp (+180/-64)
tests/test-gestures/test_gestures_main.cpp (+9/-7)
tests/test-gestures/test_window_gesture_target.cpp (+194/-86)
tests/test-gestures/ubus-server-mock.cpp (+0/-32)
tests/test-gestures/ubus-server-mock.h (+0/-35)
tests/test-gestures/unityshell_mock.h (+0/-68)
tests/test_abstract_interface_generator.cpp (+175/-0)
tests/test_switcher_controller.cpp (+38/-69)
unity-shared/AbstractInterfaceGenerator.h (+119/-0)
unity-shared/CMakeLists.txt (+6/-4)
unity-shared/CompizGestureManipulatedWindow.cpp (+137/-0)
unity-shared/CompizGestureManipulatedWindow.h (+66/-0)
unity-shared/CompizX11MousePointer.cpp (+123/-0)
unity-shared/CompizX11MousePointer.h (+55/-0)
To merge this branch: bzr merge lp:~smspillaz/unity/unity.gesture_tests_no_sed
Reviewer Review Type Date Requested Status
Daniel d'Andrada (community) Approve
Tim Penhey Pending
Unity Team Pending
Review via email: mp+136321@code.launchpad.net

This proposal supersedes a proposal from 2012-11-26.

Commit message

DO NOT COMMIT OR MERGE

Description of the change

Get the gesture tests to work without using sed scripts and recompiling files on every build.

This only requires testing to make sure it still works, don't worry about actually reviewing the code because the diff is huge and I plan to split it up into managable chunks anwyays.

I can't test this myself because

1) My hardware doesn't work
2) My drivers don't work

I've only gone on the basis that the tests continue to pass. And even then I had to mess around with the tests too as I switched from evaluating stubs to using google mock.

Requires nux from: https://code.launchpad.net/~smspillaz/nux/nux.gesture-targets-unavailable/+merge/136320

To post a comment you must log in.
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

It doesn't build:

Building CXX object gestures/CMakeFiles/gestures-lib.dir/WindowGestureTarget.cpp.o
/home/dandrader/unity/unity.gesture_tests_no_sed/gestures/WindowGestureTarget.cpp: In member function ‘void WindowGestureTarget::OnManipulatedWindowDestruction()’:
/home/dandrader/unity/unity.gesture_tests_no_sed/gestures/WindowGestureTarget.cpp:67:3: error: ‘on_target_unavailable’ was not declared in this scope
make[2]: *** [gestures/CMakeFiles/gestures-lib.dir/WindowGestureTarget.cpp.o] Error 1
make[1]: *** [gestures/CMakeFiles/gestures-lib.dir/all] Error 2
make: *** [all] Error 2

review: Needs Fixing
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Ah. Sorry. I forgot that this requires a special version of nux. I'll put
that up tomorrow. Sorry about the bother.
On 26/11/2012 10:39 PM, "Daniel d'Andrada" <email address hidden>
wrote:

> Review: Needs Fixing
>
> It doesn't build:
>
> Building CXX object
> gestures/CMakeFiles/gestures-lib.dir/WindowGestureTarget.cpp.o
> /home/dandrader/unity/unity.gesture_tests_no_sed/gestures/WindowGestureTarget.cpp:
> In member function ‘void
> WindowGestureTarget::OnManipulatedWindowDestruction()’:
> /home/dandrader/unity/unity.gesture_tests_no_sed/gestures/WindowGestureTarget.cpp:67:3:
> error: ‘on_target_unavailable’ was not declared in this scope
> make[2]: ***
> [gestures/CMakeFiles/gestures-lib.dir/WindowGestureTarget.cpp.o] Error 1
> make[1]: *** [gestures/CMakeFiles/gestures-lib.dir/all] Error 2
> make: *** [all] Error 2
>
> --
>
> https://code.launchpad.net/~smspillaz/unity/unity.gesture_tests_no_sed/+merge/136108
> You are the owner of lp:~smspillaz/unity/unity.gesture_tests_no_sed.
>

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Thanks for the note. I've resubmitted this now with the conflicts resolved and a link to the nux changes required to get this building. I'll keep cleaning it up as we go I guess.

2814. By Sam Spilsbury

Remove some redundant files, convert GesturalWindowSwitcherMock to gmock

2815. By Sam Spilsbury

Remove CompWindowMock

2816. By Sam Spilsbury

Reason about the effect of SetupAndShowSwitcher through a gmock instead
of tracking the number of calls with ASSERT_EQ

2817. By Sam Spilsbury

Adapt API

2818. By Sam Spilsbury

Merge lp:unity

2819. By Sam Spilsbury

Separate MockSwitcherController and StubSwitcherController

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

When I move a window around with three fingers, I can only move it to the right and it also triggers the grid plugin (half-screen maximization) all the time while doing to.
On top of that, I get a segfault after closing the windows (with alf+f4) I opened during the test mentioned above.

Things still work fine with trunk of unity minus your patches.

review: Needs Fixing
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Thanks for testing :) Ill see if I can get my system into a state where I
can test this manually again so start working on some regression tests for
the areas you identified.
On 29/11/2012 3:54 AM, "Daniel d'Andrada" <email address hidden>
wrote:

> Review: Needs Fixing
>
> When I move a window around with three fingers, I can only move it to the
> right and it also triggers the grid plugin (half-screen maximization) all
> the time while doing to.
> On top of that, I get a segfault after closing the windows (with alf+f4) I
> opened during the test mentioned above.
>
> Things still work fine with trunk of unity minus your patches.
> --
>
> https://code.launchpad.net/~smspillaz/unity/unity.gesture_tests_no_sed/+merge/136321
> You are the owner of lp:~smspillaz/unity/unity.gesture_tests_no_sed.
>

2820. By Sam Spilsbury

[ FAILED ] ApplyDelta.ApplyPosX
[ FAILED ] ApplyDelta.ApplyPosY
[ FAILED ] ApplyDelta.ApplyNegX
[ FAILED ] ApplyDelta.ApplyNegY

2821. By Sam Spilsbury

[ RUN ] ApplyDelta.ApplyPosX
[ OK ] ApplyDelta.ApplyPosX (0 ms)
[ RUN ] ApplyDelta.ApplyPosY
[ OK ] ApplyDelta.ApplyPosY (0 ms)
[ RUN ] ApplyDelta.ApplyNegX
[ OK ] ApplyDelta.ApplyNegX (0 ms)
[ RUN ] ApplyDelta.ApplyNegY
[ OK ] ApplyDelta.ApplyNegY (0 ms)

2822. By Sam Spilsbury

Do not pass XWarpPointer relative co-ordinates

2823. By Sam Spilsbury

Test that indicates broken destroy behaviour of GestureManipulatedWindow
[----------] 7 tests from WindowGestureTargetTest
[ RUN ] WindowGestureTargetTest.GestureManipulatedWindowDeath
pure virtual method called
terminate called without an active exception
Aborted (core dumped)

2824. By Sam Spilsbury

[----------] 7 tests from WindowGestureTargetTest
[ RUN ] WindowGestureTargetTest.GestureManipulatedWindowDeath
[ OK ] WindowGestureTargetTest.GestureManipulatedWindowDeath (0 ms)

Track the manipulated window death, don't call pure virtual methods on it
in that case and store the id so we can still use Equals()

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Okay, I've managed to get a working system back (woo, no more running lxde !) and I've identified and fixed the issues you've described.

The only other problem was that I can't get the gestural window switcher to work, but I can't get it to work on trunk either, and I don't really know what the gesture is to make it work. Is it known to be broken at the moment?

If the behaviour is all good, I'll start splitting this up into bits that don't depend on each other.

2825. By Sam Spilsbury

Merge lp:unity

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

(Ping - let me know once manual testing is ok, and we can discuss how best to break this up into reviewable chunks)

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> [...]
> The only other problem was that I can't get the gestural window switcher to
> work, but I can't get it to work on trunk either, and I don't really know what
> the gesture is to make it work. Is it known to be broken at the moment?
> [...]

The gestures are explained in the documentation of this class. Check GesturalWindowSwitcher.h. And yes, they do work on trunk.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Now gestures are working again.

review: Approve
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

OK, great :)

Now, how do we get this broken up into pieces ... I propose:

1. New mocks (eg, MockWindowManager, MockSwitcherController)
2. Delta restrainment class
3. AbstractInterfaceGenerator
4. "dependency breaking" classes (eg CompizX11MousePointer, CompizGestureManipulatedWindow)
5. Getting the tests working without sed-mocking (probably still going to be huge, but not as huge)

2826. By Sam Spilsbury

Merge lp:unity

2827. By Sam Spilsbury

Actually add the test to the CMakeLists.txt

2828. By Sam Spilsbury

Merge lp:unity

2829. By Sam Spilsbury

Adjust MockWindowManager

2830. By Sam Spilsbury

Merge lp:unity

2831. By Sam Spilsbury

Remove ApplyDelta

2832. By Sam Spilsbury

Merge lp:unity

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

An easier way of getting rid of sed mocking is to add a USE_MOCKS definition and then in the source files just do

#ifdef USE_MOCKS
/* include mock headers. */
#else
/* include original versions. */
#endif

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

Okay, the sed scripts are even more evil than I suspected. But still it should be possible to have a header with stuff like this:

#define ClassName ClassNameMock

which would be slightly less evil.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

On Mon, Dec 17, 2012 at 10:28 PM, Jussi Pakkanen
<email address hidden> wrote:
> Okay, the sed scripts are even more evil than I suspected. But still it should be possible to have a header with stuff like this:
>
> #define ClassName ClassNameMock
>
> which would be slightly less evil.

An even better way is to refactor the code so that it doesn't need to
be recompiled twice :)

> --
> https://code.launchpad.net/~smspillaz/unity/unity.gesture_tests_no_sed/+merge/136321
> You are the owner of lp:~smspillaz/unity/unity.gesture_tests_no_sed.

--
Sam Spilsbury

2833. By Sam Spilsbury

Merge lp:unity

2834. By Sam Spilsbury

Merge from abstract_interaface_generator

2835. By Sam Spilsbury

Should be CompWindow * const &

2836. By Sam Spilsbury

Merge lp:unity

2837. By Sam Spilsbury

Merge new Switcher interface work

2838. By Sam Spilsbury

Initialize accumululated_horizontal_drag

Unmerged revisions

2838. By Sam Spilsbury

Initialize accumululated_horizontal_drag

2837. By Sam Spilsbury

Merge new Switcher interface work

2836. By Sam Spilsbury

Merge lp:unity

2835. By Sam Spilsbury

Should be CompWindow * const &

2834. By Sam Spilsbury

Merge from abstract_interaface_generator

2833. By Sam Spilsbury

Merge lp:unity

2832. By Sam Spilsbury

Merge lp:unity

2831. By Sam Spilsbury

Remove ApplyDelta

2830. By Sam Spilsbury

Merge lp:unity

2829. By Sam Spilsbury

Adjust MockWindowManager

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2012-12-13 07:56:59 +0000
3+++ CMakeLists.txt 2012-12-19 14:00:32 +0000
4@@ -222,6 +222,7 @@
5 pkg_check_modules (CACHED_UNITY_DEPS REQUIRED ${UNITY_PLUGIN_DEPS})
6 pkg_check_modules (CACHED_UNITY_PRIVATE_DEPS REQUIRED ${UNITY_PROTOCOL_PRIVATE_DEPS})
7 add_subdirectory(unity-shared)
8+add_subdirectory(gestures)
9 add_subdirectory(dash)
10 add_subdirectory(launcher)
11 if (ENABLE_X_SUPPORT)
12
13=== added directory 'gestures'
14=== added file 'gestures/CMakeLists.txt'
15--- gestures/CMakeLists.txt 1970-01-01 00:00:00 +0000
16+++ gestures/CMakeLists.txt 2012-12-19 14:00:32 +0000
17@@ -0,0 +1,59 @@
18+set(UNITY_SRC ../plugins/unityshell/src)
19+set(UNITY_SHARED_SRC ../unity-shared)
20+set(UNITY_SWITCHER_SRC ../launcher)
21+set(UNITY_CORE_SRC ../UnityCore)
22+set(SERVICES_SRC ../services)
23+set(TOP_SRC_DIR ${CMAKE_SOURCE_DIR})
24+set(TOP_BINARY_DIR ${CMAKE_BINARY_DIR})
25+
26+find_package (PkgConfig)
27+
28+set (CFLAGS
29+ ${CACHED_UNITY_DEPS_CFLAGS}
30+ ${CACHED_UNITY_DEPS_CFLAGS_OTHER}
31+ ${MAINTAINER_CFLAGS}
32+ "-fPIC"
33+ "-DGETTEXT_PACKAGE=\"unity\""
34+ "-I${CMAKE_CURRENT_BINARY_DIR}"
35+ )
36+
37+if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
38+ set (CFLAGS ${CFLAGS} "-fPIC")
39+endif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
40+
41+add_definitions (${CFLAGS})
42+
43+set (LIBS ${CACHED_UNITY_DEPS_LIBRARIES} ${UNITY_STANDALONE_LADD})
44+set (LIB_PATHS ${CACHED_UNITY_DEPS_LIBRARY_DIRS})
45+
46+link_directories (${CMAKE_BINARY_DIR}/UnityCore
47+ ${LIB_PATHS})
48+
49+include_directories (${CMAKE_CURRENT_SOURCE_DIR}
50+ ${UNITY_SRC}
51+ ${UNITY_CORE_SRC}
52+ ${UNITY_SWITCHER_SRC}
53+ ${UNITY_SHARED_SRC}
54+ ${SERVICES_SRC}
55+ ${TOP_SRC_DIR}
56+ ${TOP_BINARY_DIR})
57+
58+#
59+# Headers & Sources
60+#
61+set (GESTURES_SOURCES
62+ WindowGestureTarget.cpp
63+ UnityGestureBroker.cpp
64+ CompoundGestureRecognizer.cpp
65+ CompoundGestureRecognizer.h
66+ GesturalWindowSwitcher.cpp
67+ GesturalWindowSwitcher.h
68+ )
69+
70+add_library (gestures-lib STATIC ${GESTURES_SOURCES})
71+target_link_libraries (gestures-lib
72+ unity-shared
73+ unity-core-${UNITY_API_VERSION}
74+ unity-shared
75+ switcher-lib
76+ ${LIBS})
77
78=== renamed file 'plugins/unityshell/src/CompoundGestureRecognizer.cpp' => 'gestures/CompoundGestureRecognizer.cpp'
79=== renamed file 'plugins/unityshell/src/CompoundGestureRecognizer.h' => 'gestures/CompoundGestureRecognizer.h'
80=== renamed file 'plugins/unityshell/src/GesturalWindowSwitcher.cpp' => 'gestures/GesturalWindowSwitcher.cpp'
81--- plugins/unityshell/src/GesturalWindowSwitcher.cpp 2012-10-29 09:34:54 +0000
82+++ gestures/GesturalWindowSwitcher.cpp 2012-12-19 14:00:32 +0000
83@@ -20,25 +20,29 @@
84 * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
85 */
86
87+#include <tuple>
88 #include "GesturalWindowSwitcher.h"
89 #include <Nux/Nux.h>
90 #include <NuxCore/Logger.h>
91-#include "unityshell.h"
92+#include <UnityCore/GLibSource.h>
93
94 DECLARE_LOGGER(logger, "unity.gesture.switcher");
95
96 using namespace nux;
97 using namespace unity;
98
99-const float GesturalWindowSwitcher::DRAG_DELTA_FOR_CHANGING_SELECTION = 100.0f;
100-const float GesturalWindowSwitcher::MOUSE_DRAG_THRESHOLD = 20.0f;
101+const float GesturalWindowSwitcherImpl::DRAG_DELTA_FOR_CHANGING_SELECTION = 100.0f;
102+const float GesturalWindowSwitcherImpl::MOUSE_DRAG_THRESHOLD = 20.0f;
103
104 namespace unity
105 {
106 class GesturalWindowSwitcherPrivate
107 {
108 public:
109- GesturalWindowSwitcherPrivate();
110+ typedef GesturalWindowSwitcherImpl::SetUpAndShowSwitcherFunc SetUpAndShowSwitcherFunc;
111+ GesturalWindowSwitcherPrivate(const unity::switcher::Controller::Ptr &switcher_controller,
112+ const SetUpAndShowSwitcherFunc &set_up_and_show_switcher,
113+ const GesturalWindowSwitcherActionInvokerFactory &action_invoker_factory);
114 virtual ~GesturalWindowSwitcherPrivate();
115
116 void CloseSwitcherAfterTimeout(int timeout);
117@@ -82,43 +86,44 @@
118 WaitingMandatorySwitcherClose,
119 } state;
120
121- unity::UnityScreen* unity_screen;
122 unity::switcher::Controller::Ptr switcher_controller;
123+ GesturalWindowSwitcherImpl::SetUpAndShowSwitcherFunc set_up_and_show_switcher_;
124+ GesturalWindowSwitcherActionInvoker::Ptr action_invoker_;
125 CompoundGestureRecognizer gesture_recognizer;
126- CompTimer timer_close_switcher;
127 float accumulated_horizontal_drag;
128 int index_icon_hit;
129
130 sigc::connection view_built_connection;
131- sigc::connection mouse_down_connection;
132- sigc::connection mouse_up_connection;
133- sigc::connection mouse_drag_connection;
134+ unity::switcher::View::MouseEventConnections mouse_connections_;
135 };
136 }
137
138 ///////////////////////////////////////////
139 // private class
140
141-GesturalWindowSwitcherPrivate::GesturalWindowSwitcherPrivate()
142+GesturalWindowSwitcherPrivate::GesturalWindowSwitcherPrivate(const unity::switcher::Controller::Ptr &switcher_controller,
143+ const SetUpAndShowSwitcherFunc &set_up_and_show_switcher,
144+ const GesturalWindowSwitcherActionInvokerFactory &action_invoker_factory) :
145+ switcher_controller (switcher_controller),
146+ set_up_and_show_switcher_ (set_up_and_show_switcher),
147+ action_invoker_ (action_invoker_factory.CreateActionInvoker(std::bind (&GesturalWindowSwitcherPrivate::OnCloseSwitcherTimeout,
148+ this))),
149+ accumulated_horizontal_drag(0.0f)
150 {
151 state = State::WaitingCompoundGesture;
152
153- unity_screen = unity::UnityScreen::get(screen);
154- switcher_controller = unity_screen->switcher_controller();
155-
156- timer_close_switcher.setCallback(
157- boost::bind(&GesturalWindowSwitcherPrivate::OnCloseSwitcherTimeout, this));
158-
159- view_built_connection = switcher_controller->view_built.connect(
160- sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ConnectToSwitcherViewMouseEvents));
161+ action_invoker_->StopPendingInvocation();;
162+
163+ view_built_connection = switcher_controller->ConnectToViewBuilt(
164+ sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ConnectToSwitcherViewMouseEvents));
165 }
166
167 GesturalWindowSwitcherPrivate::~GesturalWindowSwitcherPrivate()
168 {
169 view_built_connection.disconnect();
170- mouse_down_connection.disconnect();
171- mouse_up_connection.disconnect();
172- mouse_drag_connection.disconnect();
173+ std::get <0> (mouse_connections_).disconnect();
174+ std::get <1> (mouse_connections_).disconnect();
175+ std::get <2> (mouse_connections_).disconnect();
176 }
177
178 GestureDeliveryRequest GesturalWindowSwitcherPrivate::GestureEvent(nux::GestureEvent const& event)
179@@ -165,7 +170,7 @@
180 break;
181 case RecognitionResult::DOUBLE_TAP_RECOGNIZED:
182 InitiateSwitcherNext();
183- CloseSwitcherAfterTimeout(GesturalWindowSwitcher::SWITCHER_TIME_AFTER_DOUBLE_TAP);
184+ CloseSwitcherAfterTimeout(GesturalWindowSwitcherImpl::SWITCHER_TIME_AFTER_DOUBLE_TAP);
185 break;
186 default: // RecognitionResult::TAP_AND_HOLD_RECOGNIZED:
187 InitiateSwitcherNext();
188@@ -197,7 +202,7 @@
189 }
190 else // event.type == EVENT_GESTURE_END
191 {
192- CloseSwitcherAfterTimeout(GesturalWindowSwitcher::SWITCHER_TIME_AFTER_HOLD_RELEASED);
193+ CloseSwitcherAfterTimeout(GesturalWindowSwitcherImpl::SWITCHER_TIME_AFTER_HOLD_RELEASED);
194 state = State::WaitingSwitcherManipulation;
195 }
196
197@@ -218,7 +223,7 @@
198 if (event.GetGestureClasses() & nux::DRAG_GESTURE)
199 {
200 state = State::DraggingSwitcher;
201- timer_close_switcher.stop();
202+ action_invoker_->StopPendingInvocation();
203 DraggingSwitcher(event);
204 }
205
206@@ -273,11 +278,7 @@
207
208 void GesturalWindowSwitcherPrivate::CloseSwitcherAfterTimeout(int timeout)
209 {
210- timer_close_switcher.stop();
211- // min and max timeouts
212- timer_close_switcher.setTimes(timeout,
213- timeout+50);
214- timer_close_switcher.start();
215+ action_invoker_->InvokeOnTimeout (timeout);
216 }
217
218 bool GesturalWindowSwitcherPrivate::OnCloseSwitcherTimeout()
219@@ -299,24 +300,24 @@
220
221 void GesturalWindowSwitcherPrivate::CloseSwitcher()
222 {
223- switcher_controller->Hide();
224+ switcher_controller->Hide(true);
225 }
226
227 void GesturalWindowSwitcherPrivate::InitiateSwitcherNext()
228 {
229- timer_close_switcher.stop();
230+ action_invoker_->StopPendingInvocation();;
231
232 if (switcher_controller->Visible())
233 switcher_controller->Next();
234 else
235 {
236- unity_screen->SetUpAndShowSwitcher();
237+ set_up_and_show_switcher_ ();
238 }
239 }
240
241 void GesturalWindowSwitcherPrivate::InitiateSwitcherPrevious()
242 {
243- timer_close_switcher.stop();
244+ action_invoker_->StopPendingInvocation();;
245
246 if (switcher_controller->Visible())
247 {
248@@ -331,11 +332,13 @@
249 return;
250
251 // Don't close the switcher while the mouse is pressed over it
252- timer_close_switcher.stop();
253+ action_invoker_->StopPendingInvocation();;
254
255 state = State::RecognizingMouseClickOrDrag;
256
257- index_icon_hit = switcher_controller->GetView()->IconIndexAt(x, y);
258+ unity::switcher::View *view = switcher_controller->GetView();
259+
260+ index_icon_hit = view->IconIndexAt(x, y);
261 accumulated_horizontal_drag = 0.0f;
262 }
263
264@@ -350,7 +353,7 @@
265 // it was a click after all.
266 switcher_controller->Select(index_icon_hit);
267 // it was not a double tap gesture but we use the same timeout
268- CloseSwitcherAfterTimeout(GesturalWindowSwitcher::SWITCHER_TIME_AFTER_DOUBLE_TAP);
269+ CloseSwitcherAfterTimeout(GesturalWindowSwitcherImpl::SWITCHER_TIME_AFTER_DOUBLE_TAP);
270 state = State::WaitingMandatorySwitcherClose;
271 }
272 else
273@@ -377,7 +380,7 @@
274 case State::RecognizingMouseClickOrDrag:
275 accumulated_horizontal_drag += dx;
276 if (fabsf(accumulated_horizontal_drag) >=
277- GesturalWindowSwitcher::MOUSE_DRAG_THRESHOLD)
278+ GesturalWindowSwitcherImpl::MOUSE_DRAG_THRESHOLD)
279 {
280 state = State::DraggingSwitcherWithMouse;
281 ProcessAccumulatedHorizontalDrag();
282@@ -396,13 +399,13 @@
283 void GesturalWindowSwitcherPrivate::ProcessAccumulatedHorizontalDrag()
284 {
285 if (accumulated_horizontal_drag >=
286- GesturalWindowSwitcher::DRAG_DELTA_FOR_CHANGING_SELECTION)
287+ GesturalWindowSwitcherImpl::DRAG_DELTA_FOR_CHANGING_SELECTION)
288 {
289 InitiateSwitcherNext();
290 accumulated_horizontal_drag = 0.0f;
291 }
292 else if (accumulated_horizontal_drag <=
293- -GesturalWindowSwitcher::DRAG_DELTA_FOR_CHANGING_SELECTION)
294+ -GesturalWindowSwitcherImpl::DRAG_DELTA_FOR_CHANGING_SELECTION)
295 {
296 InitiateSwitcherPrevious();
297 accumulated_horizontal_drag = 0.0f;
298@@ -411,33 +414,32 @@
299
300 void GesturalWindowSwitcherPrivate::ConnectToSwitcherViewMouseEvents()
301 {
302- unity::switcher::SwitcherView *switcher_view = switcher_controller->GetView();
303+ unity::switcher::View *switcher_view = switcher_controller->GetView();
304 g_assert(switcher_view);
305
306- mouse_down_connection = switcher_view->mouse_down.connect(
307- sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseDown));
308-
309- mouse_up_connection = switcher_view->mouse_up.connect(
310- sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseUp));
311-
312- mouse_drag_connection = switcher_view->mouse_drag.connect(
313+ mouse_connections_ =
314+ switcher_view->ConnectToMouseEvents(sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseDown),
315+ sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseUp),
316 sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseDrag));
317+
318 }
319
320 ///////////////////////////////////////////
321 // public class
322
323-GesturalWindowSwitcher::GesturalWindowSwitcher()
324- : p(new GesturalWindowSwitcherPrivate)
325+GesturalWindowSwitcherImpl::GesturalWindowSwitcherImpl(const unity::switcher::Controller::Ptr &switcher_controller,
326+ const SetUpAndShowSwitcherFunc &set_up_and_show_switcher,
327+ const GesturalWindowSwitcherActionInvokerFactory &action_invoker_factory)
328+ : p(new GesturalWindowSwitcherPrivate (switcher_controller, set_up_and_show_switcher, action_invoker_factory))
329 {
330 }
331
332-GesturalWindowSwitcher::~GesturalWindowSwitcher()
333+GesturalWindowSwitcherImpl::~GesturalWindowSwitcherImpl()
334 {
335 delete p;
336 }
337
338-GestureDeliveryRequest GesturalWindowSwitcher::GestureEvent(nux::GestureEvent const& event)
339+GestureDeliveryRequest GesturalWindowSwitcherImpl::GestureEvent(nux::GestureEvent const& event)
340 {
341 return p->GestureEvent(event);
342 }
343
344=== renamed file 'plugins/unityshell/src/GesturalWindowSwitcher.h' => 'gestures/GesturalWindowSwitcher.h'
345--- plugins/unityshell/src/GesturalWindowSwitcher.h 2012-08-14 13:57:32 +0000
346+++ gestures/GesturalWindowSwitcher.h 2012-12-19 14:00:32 +0000
347@@ -55,11 +55,45 @@
348 - tap on some window icon -> selects that icon and closes the switcher
349
350 */
351-class GesturalWindowSwitcher : public nux::GestureTarget
352-{
353- public:
354- GesturalWindowSwitcher();
355- virtual ~GesturalWindowSwitcher();
356+class GesturalWindowSwitcherInterface : public nux::GestureTarget
357+{
358+ public:
359+
360+ virtual ~GesturalWindowSwitcherInterface () {}
361+ virtual nux::GestureDeliveryRequest GestureEvent(nux::GestureEvent const& event) = 0;
362+};
363+
364+class GesturalWindowSwitcherActionInvoker
365+{
366+ public:
367+
368+ typedef std::shared_ptr <GesturalWindowSwitcherActionInvoker> Ptr;
369+
370+ virtual ~GesturalWindowSwitcherActionInvoker () {}
371+
372+ virtual void InvokeOnTimeout (int timeout) = 0;
373+ virtual void StopPendingInvocation () = 0;
374+};
375+
376+class GesturalWindowSwitcherActionInvokerFactory
377+{
378+ public:
379+
380+ virtual ~GesturalWindowSwitcherActionInvokerFactory () {}
381+
382+ virtual GesturalWindowSwitcherActionInvoker::Ptr
383+ CreateActionInvoker (const std::function <bool ()> &) const = 0;
384+};
385+
386+class GesturalWindowSwitcherImpl : public GesturalWindowSwitcherInterface
387+{
388+ public:
389+ typedef std::function <void ()> SetUpAndShowSwitcherFunc;
390+
391+ GesturalWindowSwitcherImpl(const unity::switcher::Controller::Ptr &switcher_controller,
392+ const SetUpAndShowSwitcherFunc &set_up_and_show_switcher,
393+ const GesturalWindowSwitcherActionInvokerFactory &action_invoker_factory);
394+ virtual ~GesturalWindowSwitcherImpl();
395
396 // in milliseconds
397 static const int SWITCHER_TIME_AFTER_DOUBLE_TAP = 350;
398@@ -78,7 +112,7 @@
399 private:
400 GesturalWindowSwitcherPrivate* p;
401 };
402-typedef std::shared_ptr<GesturalWindowSwitcher> ShPtGesturalWindowSwitcher;
403+typedef std::shared_ptr<GesturalWindowSwitcherInterface> ShPtGesturalWindowSwitcher;
404
405 } // namespace unity
406
407
408=== renamed file 'plugins/unityshell/src/UnityGestureBroker.cpp' => 'gestures/UnityGestureBroker.cpp'
409--- plugins/unityshell/src/UnityGestureBroker.cpp 2012-08-14 12:51:45 +0000
410+++ gestures/UnityGestureBroker.cpp 2012-12-19 14:00:32 +0000
411@@ -19,30 +19,32 @@
412 * Foundation, Inc., 51 Franklin St, Fifth Floor,
413 * Boston, MA 02110-1301 USA
414 */
415-
416+#include <cstdio>
417+#include <memory>
418 #include "UnityGestureBroker.h"
419 #include "UnityGestureTarget.h"
420 #include "WindowGestureTarget.h"
421
422-#include <X11/cursorfont.h>
423+namespace ug = unity::gestures;
424
425-UnityGestureBroker::UnityGestureBroker()
426- : nux::GestureBroker()
427+UnityGestureBroker::UnityGestureBroker(const std::shared_ptr <unity::gestures::MousePointer> &ptr,
428+ const GetWindowGeneratorFunc &client_list,
429+ const GetWindowGeneratorFunc &all_windows,
430+ const unity::ShPtGesturalWindowSwitcher &gestural_switcher,
431+ const nux::ShPtGestureTarget &unity_target,
432+ const ug::WindowGestureTargetFactory::Ptr &gesture_target_factory)
433+ : nux::GestureBroker(),
434+ gestural_window_switcher_ (gestural_switcher),
435+ mouse_pointer_ (ptr),
436+ current_client_list_(client_list),
437+ current_all_windows_(all_windows),
438+ unity_target_ (unity_target),
439+ gesture_target_factory_ (gesture_target_factory)
440 {
441- g_assert(WindowGestureTarget::fleur_cursor == 0);
442- WindowGestureTarget::fleur_cursor = XCreateFontCursor (screen->dpy (), XC_fleur);
443-
444- unity_target.reset(new UnityGestureTarget);
445- gestural_window_switcher_.reset(new unity::GesturalWindowSwitcher);
446 }
447
448 UnityGestureBroker::~UnityGestureBroker()
449 {
450- if (WindowGestureTarget::fleur_cursor)
451- {
452- XFreeCursor (screen->dpy (), WindowGestureTarget::fleur_cursor);
453- WindowGestureTarget::fleur_cursor = 0;
454- }
455 }
456
457 std::vector<nux::ShPtGestureTarget>
458@@ -54,33 +56,35 @@
459
460 if (touches.size() == 4)
461 {
462- targets.push_back(unity_target);
463+ targets.push_back(unity_target_);
464 }
465 else if (touches.size() == 3)
466 {
467 targets.push_back(gestural_window_switcher_);
468
469- CompWindow *window = FindWindowHitByGesture(event);
470+ ug::GestureManipulatedWindow *window = FindWindowHitByGesture(event);
471 if (window)
472 {
473- targets.push_back(nux::ShPtGestureTarget(new WindowGestureTarget(window)));
474+ ug::MousePointer::Weak mouse_pointer_weak (mouse_pointer_);
475+ targets.push_back(gesture_target_factory_->CreateGestureTarget (*window,
476+ mouse_pointer_weak));
477 }
478 }
479
480 return targets;
481 }
482
483-CompWindow *UnityGestureBroker::FindWindowHitByGesture(const nux::GestureEvent &event)
484+ug::GestureManipulatedWindow * UnityGestureBroker::FindWindowHitByGesture(const nux::GestureEvent &event)
485 {
486 if (event.IsDirectTouch())
487 {
488 /* If a direct device is being used (e.g., a touchscreen), all touch
489 points must hit the same window */
490- CompWindow *last_window = nullptr;
491+ ug::GestureManipulatedWindow *last_window = nullptr;
492 const std::vector<nux::TouchPoint> &touches = event.GetTouches();
493 for (auto touch : touches)
494 {
495- CompWindow *window = FindCompWindowAtPos(touch.x, touch.y);
496+ ug::GestureManipulatedWindow *window = FindCompWindowAtPos(touch.x, touch.y);
497 if (last_window)
498 {
499 if (window != last_window)
500@@ -107,27 +111,22 @@
501 }
502 }
503
504-CompWindow* UnityGestureBroker::FindCompWindowAtPos(int pos_x, int pos_y)
505+ug::GestureManipulatedWindow * UnityGestureBroker::FindCompWindowAtPos(int pos_x, int pos_y)
506 {
507- const CompWindowVector& client_list_stacking = screen->clientList(true);
508-
509- for (auto iter = client_list_stacking.rbegin(),
510- end = client_list_stacking.rend();
511- iter != end; ++iter)
512- {
513- CompWindow* window = *iter;
514-
515- if (window->minimized())
516- continue;
517-
518- if (window->state() & CompWindowStateHiddenMask)
519- continue;
520-
521- if (pos_x >= window->x() && pos_x <= (window->width() + window->x())
522- &&
523- pos_y >= window->y() && pos_y <= (window->height() + window->y()))
524- return window;
525- }
526-
527- return nullptr;
528+ ug::GestureManipulatedWindow *manipulated_window = nullptr;
529+ current_client_list_ ()->VisitEachInterfaceReverse ([&](ug::GestureManipulatedWindow &item)
530+ {
531+ if (manipulated_window)
532+ return;
533+
534+ if (!item.Visible())
535+ return;
536+
537+ const compiz::window::Geometry &geom(item.Geometry());
538+
539+ if (geom.contains(CompPoint(pos_x, pos_y)))
540+ manipulated_window = &item;
541+ });
542+
543+ return manipulated_window;
544 }
545
546=== renamed file 'plugins/unityshell/src/UnityGestureBroker.h' => 'gestures/UnityGestureBroker.h'
547--- plugins/unityshell/src/UnityGestureBroker.h 2012-08-14 12:48:21 +0000
548+++ gestures/UnityGestureBroker.h 2012-12-19 14:00:32 +0000
549@@ -23,30 +23,59 @@
550 #ifndef UNITY_GESTURE_BROKER
551 #define UNITY_GESTURE_BROKER
552
553-#include <core/core.h>
554+#include <memory>
555+#include <functional>
556
557 #include <Nux/GestureBroker.h>
558+#include <AbstractInterfaceGenerator.h>
559 #include "GesturalWindowSwitcher.h"
560+#include "WindowGestureTarget.h"
561+
562+class GesturalWindowSwitcher;
563+
564+namespace unity
565+{
566+namespace gestures
567+{
568+class GestureManipulatedWindow;
569+class MousePointer;
570+}
571+}
572
573 class UnityGestureBroker : public nux::GestureBroker
574 {
575 public:
576- UnityGestureBroker();
577+
578+ typedef unity::gestures::GestureManipulatedWindow GestureWindow;
579+ typedef unity::AbstractInterfaceGenerator <GestureWindow> WindowGen;
580+ typedef std::shared_ptr <WindowGen> WindowGenPtr;
581+ typedef std::function <WindowGenPtr ()> GetWindowGeneratorFunc;
582+
583+ UnityGestureBroker(const std::shared_ptr <unity::gestures::MousePointer> &ptr,
584+ const GetWindowGeneratorFunc &client_list,
585+ const GetWindowGeneratorFunc &all_windows,
586+ const unity::ShPtGesturalWindowSwitcher &gestural_switcher,
587+ const nux::ShPtGestureTarget &unity_target,
588+ const unity::gestures::WindowGestureTargetFactory::Ptr &gesture_target_factory);
589 virtual ~UnityGestureBroker();
590
591 private:
592 std::vector<nux::ShPtGestureTarget>
593 virtual FindGestureTargets(const nux::GestureEvent &event);
594
595- CompWindow *FindWindowHitByGesture(const nux::GestureEvent &event);
596+ unity::gestures::GestureManipulatedWindow * FindWindowHitByGesture(const nux::GestureEvent &event);
597
598 /*!
599 Returns the top-most CompWindow at the given position, if any.
600 */
601- CompWindow* FindCompWindowAtPos(int pos_x, int pos_y);
602+ unity::gestures::GestureManipulatedWindow * FindCompWindowAtPos(int pos_x, int pos_y);
603
604- nux::ShPtGestureTarget unity_target;
605- unity::ShPtGesturalWindowSwitcher gestural_window_switcher_;
606+ unity::ShPtGesturalWindowSwitcher gestural_window_switcher_;
607+ std::shared_ptr <unity::gestures::MousePointer> mouse_pointer_;
608+ GetWindowGeneratorFunc current_client_list_;
609+ GetWindowGeneratorFunc current_all_windows_;
610+ nux::ShPtGestureTarget unity_target_;
611+ unity::gestures::WindowGestureTargetFactory::Ptr gesture_target_factory_;
612 };
613
614 #endif // UNITY_GESTURE_BROKER
615
616=== renamed file 'plugins/unityshell/src/UnityGestureTarget.h' => 'gestures/UnityGestureTarget.h'
617=== renamed file 'plugins/unityshell/src/WindowGestureTarget.cpp' => 'gestures/WindowGestureTarget.cpp'
618--- plugins/unityshell/src/WindowGestureTarget.cpp 2012-10-11 01:44:15 +0000
619+++ gestures/WindowGestureTarget.cpp 2012-12-19 14:00:32 +0000
620@@ -23,52 +23,64 @@
621 #include "WindowGestureTarget.h"
622
623 #include <Nux/Nux.h> // otherwise unityshell.h inclusion will cause failures
624-#include "unityshell.h"
625
626 // To make the gesture tests pass, this has to be a local include.
627 #include "PluginAdapter.h"
628
629 using namespace nux;
630-
631-Cursor WindowGestureTarget::fleur_cursor = 0;
632-
633-WindowGestureTarget::WindowGestureTarget(CompWindow *window)
634- : window_(window), drag_grab_(0), started_window_move_(false),
635- window_restored_by_pinch_(false)
636-{
637- // A workaround for the lack of weak pointers.
638- unity::UnityWindow *unity_window = unity::UnityWindow::get(window);
639-
640+namespace ug = unity::gestures;
641+namespace ugi = unity::gestures::impl;
642+
643+ug::GestureManipulatedWindow::~GestureManipulatedWindow ()
644+{
645+ on_destruction_.emit ();
646+}
647+
648+nux::ShPtGestureTarget
649+ugi::WindowGestureTargetFactory::CreateGestureTarget (GestureManipulatedWindow &win,
650+ const MousePointer::Weak &mp) const
651+{
652+ return std::make_shared <WindowGestureTarget> (win, mp);
653+}
654+
655+WindowGestureTarget::WindowGestureTarget(ug::GestureManipulatedWindow &manipulated_window,
656+ const ug::MousePointer::Weak &mouse_pointer_observer)
657+ : manipulated_window_ (manipulated_window),
658+ mouse_pointer_ (mouse_pointer_observer),
659+ started_window_move_(false),
660+ window_restored_by_pinch_(false),
661+ stored_manipulated_window_id_(manipulated_window.GetIdentifier()),
662+ manipulated_window_dead_(false)
663+{
664 connection_window_destruction =
665- unity_window->being_destroyed.connect(
666- sigc::mem_fun(this, &WindowGestureTarget::NullifyWindowPointer));
667+ manipulated_window.on_destruction_.connect(sigc::mem_fun(this,
668+ &WindowGestureTarget::OnManipulatedWindowDestruction));
669 }
670
671 WindowGestureTarget::~WindowGestureTarget()
672 {
673+ /* Since we only have manipulated_window_ by
674+ * reference, it is unsafe to call virtual methods
675+ * on it if it might have been destroyed, so don't
676+ * do that here */
677+ if (!manipulated_window_dead_)
678+ manipulated_window_.Ungrab();
679+ mouse_pointer_.lock ()->MakeUngrabbedForMovement();
680 connection_window_destruction.disconnect();
681- if (drag_grab_)
682- {
683- if (window_)
684- window_->ungrabNotify();
685- screen->removeGrab(drag_grab_, NULL);
686- }
687 }
688
689-void WindowGestureTarget::NullifyWindowPointer()
690+void WindowGestureTarget::OnManipulatedWindowDestruction()
691 {
692- window_ = nullptr;
693+ manipulated_window_dead_ = true;
694+ died.emit(*this);
695 }
696
697 GestureDeliveryRequest WindowGestureTarget::GestureEvent(const nux::GestureEvent &event)
698 {
699- if (!window_)
700- return GestureDeliveryRequest::NONE;
701-
702 switch (event.type)
703 {
704 case nux::EVENT_GESTURE_BEGIN:
705- PluginAdapter::Default().ShowGrabHandles(window_, false);
706+ manipulated_window_.ShowGrabHandles (ug::GestureManipulatedWindow::HideMode::HideOnRequest);
707 break;
708 case EVENT_GESTURE_UPDATE:
709 if (event.GetGestureClasses() & PINCH_GESTURE)
710@@ -92,7 +104,7 @@
711 EndWindowMove(event);
712 started_window_move_ = false;
713 }
714- PluginAdapter::Default().ShowGrabHandles(window_, true);
715+ manipulated_window_.ShowGrabHandles (ug::GestureManipulatedWindow::HideMode::HideOnTimeout);
716 break;
717 };
718
719@@ -101,11 +113,12 @@
720
721 bool WindowGestureTarget::WindowCanMove()
722 {
723- if (!(window_->actions() & CompWindowActionMoveMask))
724+ if (!(manipulated_window_.IsMovable()))
725 return false;
726
727 /* Don't allow windows to be dragged if completely maximized */
728- if ((window_->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE)
729+ if (manipulated_window_.IsHorizontallyMaximized() &&
730+ manipulated_window_.IsVerticallyMaximized())
731 return false;
732
733 /* Don't start moving a window that has just been restored. The user is likely
734@@ -120,15 +133,14 @@
735 {
736 if (event.GetRadius() > 1.25f)
737 {
738- window_->maximize(MAXIMIZE_STATE);
739+ manipulated_window_.MaximizeVerticallyAndHorizontally();
740 RemoveDragGrab();
741 window_restored_by_pinch_ = false;
742 }
743 else if (event.GetRadius() < 0.8f)
744 {
745- if (window_->state() & MAXIMIZE_STATE)
746+ if (manipulated_window_.Demaximize())
747 {
748- window_->maximize(0);
749 RemoveDragGrab();
750 window_restored_by_pinch_ = true;
751 }
752@@ -139,75 +151,61 @@
753 {
754 if (!event.IsDirectTouch())
755 {
756- drag_grab_ = screen->pushGrab(fleur_cursor, "unity");
757- window_->grabNotify(window_->serverGeometry().x(),
758- window_->serverGeometry().y(),
759- 0,
760- CompWindowGrabMoveMask | CompWindowGrabButtonMask);
761+ mouse_pointer_.lock ()->MakeGrabbedForMovement ();
762+ manipulated_window_.Grab ();
763 }
764 }
765
766 void WindowGestureTarget::MoveWindow(const nux::GestureEvent &event)
767 {
768 const nux::Point2D<float> &delta = event.GetDelta();
769-
770- unsigned int px = std::max(std::min(pointerX + static_cast<int>(delta.x),
771- screen->width()),
772- 0);
773-
774- unsigned int py = std::max(std::min(pointerY + static_cast<int>(delta.y),
775- screen->height()),
776- 0);
777-
778- if (window_->state() & CompWindowStateMaximizedVertMask)
779- py = pointerY;
780- if (window_->state() & CompWindowStateMaximizedHorzMask)
781- px = pointerX;
782+ int px = static_cast<int> (delta.x);
783+ int py = static_cast<int> (delta.y);
784+
785+ mouse_pointer_.lock ()->RestrainDeltaToScreenSize (px, py);
786+
787+ if (manipulated_window_.IsVerticallyMaximized())
788+ py = 0;
789+ if (manipulated_window_.IsHorizontallyMaximized())
790+ px = 0;
791+
792+ nux::Point2D<int> p (px, py);
793
794 if (!event.IsDirectTouch())
795 {
796 /* FIXME: CompScreen::warpPointer filters out motion events which
797 other plugins may need to process, but for most cases in core
798 they should be filtered out. */
799- XWarpPointer(screen->dpy (),
800- None, screen->root (),
801- 0, 0, 0, 0,
802- px, py);
803+ mouse_pointer_.lock ()->WarpPositionByDelta (p);
804 }
805-
806- XSync(screen->dpy (), false);
807- window_->move(px - pointerX, py - pointerY, false);
808-
809- pointerX = px;
810- pointerY = py;
811+ manipulated_window_.MoveByDelta (p);
812 }
813
814 void WindowGestureTarget::EndWindowMove(const nux::GestureEvent &event)
815 {
816- window_->ungrabNotify();
817+ manipulated_window_.Ungrab ();
818 RemoveDragGrab();
819- window_->syncPosition();
820 }
821
822 void WindowGestureTarget::RemoveDragGrab()
823 {
824- if (drag_grab_)
825- {
826- screen->removeGrab(drag_grab_, NULL);
827- drag_grab_ = 0;
828- }
829+ mouse_pointer_.lock ()->MakeUngrabbedForMovement ();
830 }
831
832 bool WindowGestureTarget::Equals(const nux::GestureTarget& other) const
833 {
834 const WindowGestureTarget *window_target = dynamic_cast<const WindowGestureTarget *>(&other);
835
836+ /* Do not use GetIdentifier () here
837+ * Equals () is indirectly called here from ~GestureManipulatedWindow (), by
838+ * that time, the vptr will have gone away and calling any methods on
839+ * a reference to GestureManipulatedWindow will result in a pure virtual
840+ * method call
841+ */
842 if (window_target)
843 {
844- if (window_ && window_target->window_)
845- return window_->id() == window_target->window_->id();
846- else
847- return window_ == window_target->window_;
848+ return stored_manipulated_window_id_ ==
849+ window_target->stored_manipulated_window_id_;
850 }
851 else
852 {
853
854=== renamed file 'plugins/unityshell/src/WindowGestureTarget.h' => 'gestures/WindowGestureTarget.h'
855--- plugins/unityshell/src/WindowGestureTarget.h 2012-07-27 20:20:29 +0000
856+++ gestures/WindowGestureTarget.h 2012-12-19 14:00:32 +0000
857@@ -23,21 +23,91 @@
858 #ifndef WINDOW_GESTURE_TARGET_H
859 #define WINDOW_GESTURE_TARGET_H
860
861+#include <memory>
862+#include <sigc++/signal.h>
863 #include <Nux/Gesture.h>
864
865-#include <core/core.h> // compiz stuff
866+#include <core/windowgeometry.h>
867+
868+class WindowGestureTarget;
869+
870+namespace unity
871+{
872+namespace gestures
873+{
874+
875+class GestureManipulatedWindow
876+{
877+ public:
878+
879+ typedef std::shared_ptr <GestureManipulatedWindow> Ptr;
880+
881+ enum class HideMode
882+ {
883+ HideOnRequest,
884+ HideOnTimeout
885+ };
886+
887+ virtual ~GestureManipulatedWindow ();
888+
889+ virtual void MaximizeVerticallyAndHorizontally () = 0;
890+ virtual bool Demaximize () = 0;
891+ virtual void Grab () = 0;
892+ virtual void Ungrab () = 0;
893+ virtual void MoveByDelta (const nux::Point &p) = 0;
894+ virtual bool IsVerticallyMaximized () const = 0;
895+ virtual bool IsHorizontallyMaximized () const = 0;
896+ virtual bool IsMovable () const = 0;
897+ virtual bool Visible () const = 0;
898+ virtual const compiz::window::Geometry & Geometry () const = 0;
899+ virtual void ShowGrabHandles (HideMode) = 0;
900+
901+ /* This kind of information should not be exposed to users
902+ * of this interface, but nux::GestureTarget::Equals is designed
903+ * with dynamic casts in mind */
904+ virtual unsigned long GetIdentifier () const = 0;
905+
906+ sigc::signal <void> on_destruction_;
907+};
908+
909+class MousePointer
910+{
911+ public:
912+
913+ typedef std::shared_ptr <MousePointer> Ptr;
914+ typedef std::weak_ptr <MousePointer> Weak;
915+
916+ virtual ~MousePointer () {}
917+
918+ virtual void MakeGrabbedForMovement () = 0;
919+ virtual void MakeUngrabbedForMovement () = 0;
920+ virtual void WarpPositionByDelta (const nux::Point &p) = 0;
921+ virtual void RestrainDeltaToScreenSize (int &x, int &y) const = 0;
922+};
923+
924+class WindowGestureTargetFactory
925+{
926+ public:
927+
928+ typedef std::shared_ptr <WindowGestureTargetFactory> Ptr;
929+
930+ virtual ~WindowGestureTargetFactory () {}
931+
932+ virtual nux::ShPtGestureTarget
933+ CreateGestureTarget (GestureManipulatedWindow &,
934+ const MousePointer::Weak &) const = 0;
935+};
936+}
937+}
938
939 class WindowGestureTarget : public nux::GestureTarget
940 {
941 public:
942- WindowGestureTarget(CompWindow *window);
943+ WindowGestureTarget(unity::gestures::GestureManipulatedWindow &manipulated_window,
944+ const unity::gestures::MousePointer::Weak &mouse_pointer_observer);
945 virtual ~WindowGestureTarget();
946-
947 virtual nux::GestureDeliveryRequest GestureEvent(const nux::GestureEvent &event);
948
949- static Cursor fleur_cursor;
950-
951- CompWindow *window() {return window_;}
952 private:
953 virtual bool Equals(const nux::GestureTarget& other) const;
954 void StartWindowMove(const nux::GestureEvent &event);
955@@ -45,13 +115,36 @@
956 void EndWindowMove(const nux::GestureEvent &event);
957 void MaximizeOrRestoreWindowDueToPinch(const nux::GestureEvent &event);
958 bool WindowCanMove();
959- void NullifyWindowPointer();
960+ void OnManipulatedWindowDestruction();
961 void RemoveDragGrab();
962- CompWindow *window_;
963- CompScreen::GrabHandle drag_grab_;
964+
965+ unity::gestures::GestureManipulatedWindow &manipulated_window_;
966+ unity::gestures::MousePointer::Weak mouse_pointer_;
967+
968 bool started_window_move_;
969 bool window_restored_by_pinch_;
970 sigc::connection connection_window_destruction;
971-};
972+ unsigned long stored_manipulated_window_id_;
973+ bool manipulated_window_dead_;
974+};
975+
976+namespace unity
977+{
978+namespace gestures
979+{
980+namespace impl
981+{
982+class WindowGestureTargetFactory :
983+ public unity::gestures::WindowGestureTargetFactory
984+{
985+ public:
986+
987+ nux::ShPtGestureTarget
988+ CreateGestureTarget (GestureManipulatedWindow &,
989+ const MousePointer::Weak &) const;
990+};
991+}
992+}
993+}
994
995 #endif // WINDOW_GESTURE_TARGET_H
996
997=== modified file 'launcher/StandaloneSwitcher.cpp'
998--- launcher/StandaloneSwitcher.cpp 2012-11-12 17:27:48 +0000
999+++ launcher/StandaloneSwitcher.cpp 2012-12-19 14:00:32 +0000
1000@@ -43,7 +43,18 @@
1001
1002 static bool enable_flipping = false;
1003
1004-static Controller *view;
1005+class StandaloneController : public ShellController
1006+{
1007+ public:
1008+
1009+ StandaloneController() :
1010+ ShellController()
1011+ {
1012+ timeout_length = 0;
1013+ }
1014+};
1015+
1016+static Controller::Ptr controller;
1017
1018 static gboolean on_timeout(gpointer data)
1019 {
1020@@ -63,73 +74,74 @@
1021
1022 void OnBorderSizeChanged (nux::RangeValueInteger *self)
1023 {
1024- view->GetView ()->border_size = self->GetValue ();
1025- view->GetView ()->QueueDraw ();
1026+ controller->GetView ()->SetBorderSize(self->GetValue ());
1027+ controller->GetView ()->QueueDraw ();
1028 }
1029
1030 void OnFlatSpacingSizeChanged (nux::RangeValueInteger *self)
1031 {
1032- view->GetView ()->flat_spacing = self->GetValue ();
1033- view->GetView ()->QueueDraw ();
1034+ controller->GetView ()->SetFlatSpacing(self->GetValue ());
1035+ controller->GetView ()->QueueDraw ();
1036 }
1037
1038 void OnTextSizeChanged (nux::RangeValueInteger *self)
1039 {
1040- view->GetView ()->text_size = self->GetValue ();
1041- view->GetView ()->QueueDraw ();
1042+ controller->GetView ()->SetTextSize(self->GetValue ());
1043+ controller->GetView ()->QueueDraw ();
1044 }
1045
1046 void OnIconSizeChanged (nux::RangeValueInteger *self)
1047 {
1048- view->GetView ()->icon_size = self->GetValue ();
1049- view->GetView ()->QueueDraw ();
1050+ controller->GetView ()->SetIconSize(self->GetValue ());
1051+ controller->GetView ()->QueueDraw ();
1052 }
1053
1054 void OnTileSizeChanged (nux::RangeValueInteger *self)
1055 {
1056- view->GetView ()->tile_size = self->GetValue ();
1057- view->GetView ()->QueueDraw ();
1058+ controller->GetView ()->SetTileSize(self->GetValue ());
1059+ controller->GetView ()->QueueDraw ();
1060 }
1061
1062 void OnAnimationLengthChanged (nux::RangeValueInteger *self)
1063 {
1064- view->GetView ()->animation_length = self->GetValue ();
1065- view->GetView ()->QueueDraw ();
1066+ controller->GetView ()->SetAnimationLength(self->GetValue ());
1067+ controller->GetView ()->QueueDraw ();
1068 }
1069
1070 void OnNumIconsChanged (nux::SpinBox *self)
1071 {
1072- view->Hide();
1073+ controller->Hide();
1074
1075 std::vector<nux::ObjectPtr<AbstractLauncherIcon>> icons;
1076 for (int i = 0; i < self->GetValue (); i++)
1077 icons.push_back(nux::ObjectPtr<AbstractLauncherIcon>(new MockLauncherIcon()));
1078
1079- view->Show(ShowMode::ALL, SortMode::FOCUS_ORDER, icons);
1080+ controller->Show(ShowMode::ALL, SortMode::FOCUS_ORDER, icons);
1081 }
1082
1083 void OnNextClicked (nux::View *sender)
1084 {
1085- view->Next ();
1086+ controller->Next ();
1087 }
1088
1089 void OnDetailClicked (nux::View *sender)
1090 {
1091- view->NextDetail ();
1092+ controller->NextDetail ();
1093 }
1094
1095 void OnPreviousClicked (nux::View *sender)
1096 {
1097- view->Prev();
1098+ controller->Prev();
1099 }
1100
1101 void ThreadWidgetInit(nux::NThread* thread, void* InitData)
1102 {
1103 nux::VLayout* layout = new nux::VLayout(TEXT(""), NUX_TRACKER_LOCATION);
1104
1105- view = new Controller();
1106- view->timeout_length = 0;
1107- view->SetWorkspace(nux::Geometry(0, 0, 900, 600), 0);
1108+ controller = std::make_shared<Controller>([]{
1109+ return Controller::ImplPtr(new StandaloneController());
1110+ });
1111+ controller->SetWorkspace(nux::Geometry(0, 0, 900, 600), 0);
1112
1113 layout->SetContentDistribution(nux::MAJOR_POSITION_CENTER);
1114 layout->SetHorizontalExternalMargin (10);
1115@@ -139,9 +151,9 @@
1116 for (int i = 0; i < 9; i++)
1117 icons.push_back(nux::ObjectPtr<AbstractLauncherIcon>(new MockLauncherIcon()));
1118
1119- view->Show(ShowMode::ALL, SortMode::FOCUS_ORDER, icons);
1120+ controller->Show(ShowMode::ALL, SortMode::FOCUS_ORDER, icons);
1121
1122- view->GetView ()->render_boxes = true;
1123+ controller->GetView ()->SetRenderBoxes(true);
1124
1125 nux::CheckBox* flipping_check = new nux::CheckBox(TEXT("Enable Automatic Flipping"), false, NUX_TRACKER_LOCATION);
1126 flipping_check->SetMaximumWidth(250);
1127@@ -173,7 +185,7 @@
1128 nux::StaticText* border_label = new nux::StaticText(TEXT("Border Size:"), NUX_TRACKER_LOCATION);
1129 border_layout->AddView(border_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
1130
1131- nux::RangeValueInteger * border_size_range = new nux::RangeValueInteger (view->GetView ()->border_size, 0, 200, NUX_TRACKER_LOCATION);
1132+ nux::RangeValueInteger * border_size_range = new nux::RangeValueInteger (controller->GetView ()->GetBorderSize(), 0, 200, NUX_TRACKER_LOCATION);
1133 border_size_range->sigValueChanged.connect (sigc::ptr_fun (OnBorderSizeChanged));
1134 border_layout->AddView(border_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
1135
1136@@ -189,7 +201,7 @@
1137 nux::StaticText* flat_spacing_label = new nux::StaticText(TEXT("Flat Spacing:"), NUX_TRACKER_LOCATION);
1138 flat_spacing_layout->AddView(flat_spacing_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
1139
1140- nux::RangeValueInteger * flat_spacing_size_range = new nux::RangeValueInteger (view->GetView ()->flat_spacing, 0, 200, NUX_TRACKER_LOCATION);
1141+ nux::RangeValueInteger * flat_spacing_size_range = new nux::RangeValueInteger (controller->GetView ()->GetFlatSpacing(), 0, 200, NUX_TRACKER_LOCATION);
1142 flat_spacing_size_range->sigValueChanged.connect (sigc::ptr_fun (OnFlatSpacingSizeChanged));
1143 flat_spacing_layout->AddView(flat_spacing_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
1144
1145@@ -204,7 +216,7 @@
1146 nux::StaticText* text_size_label = new nux::StaticText(TEXT("Text Size:"), NUX_TRACKER_LOCATION);
1147 text_size_layout->AddView(text_size_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
1148
1149- nux::RangeValueInteger * text_size_size_range = new nux::RangeValueInteger (view->GetView ()->text_size, 0, 200, NUX_TRACKER_LOCATION);
1150+ nux::RangeValueInteger * text_size_size_range = new nux::RangeValueInteger (controller->GetView ()->GetTextSize(), 0, 200, NUX_TRACKER_LOCATION);
1151 text_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnTextSizeChanged));
1152 text_size_layout->AddView(text_size_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
1153
1154@@ -219,7 +231,7 @@
1155 nux::StaticText* icon_size_label = new nux::StaticText(TEXT("Icon Size:"), NUX_TRACKER_LOCATION);
1156 icon_size_layout->AddView(icon_size_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
1157
1158- nux::RangeValueInteger * icon_size_size_range = new nux::RangeValueInteger (view->GetView ()->icon_size, 0, 200, NUX_TRACKER_LOCATION);
1159+ nux::RangeValueInteger * icon_size_size_range = new nux::RangeValueInteger (controller->GetView ()->GetIconSize(), 0, 200, NUX_TRACKER_LOCATION);
1160 icon_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnIconSizeChanged));
1161 icon_size_layout->AddView(icon_size_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
1162
1163@@ -234,7 +246,7 @@
1164 nux::StaticText* tile_size_label = new nux::StaticText(TEXT("Tile Size:"), NUX_TRACKER_LOCATION);
1165 tile_size_layout->AddView(tile_size_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
1166
1167- nux::RangeValueInteger * tile_size_size_range = new nux::RangeValueInteger (view->GetView ()->tile_size, 0, 200, NUX_TRACKER_LOCATION);
1168+ nux::RangeValueInteger * tile_size_size_range = new nux::RangeValueInteger (controller->GetView ()->GetTileSize(), 0, 200, NUX_TRACKER_LOCATION);
1169 tile_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnTileSizeChanged));
1170 tile_size_layout->AddView(tile_size_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
1171
1172@@ -249,7 +261,7 @@
1173 nux::StaticText* animation_length_label = new nux::StaticText(TEXT("Animation Length:"), NUX_TRACKER_LOCATION);
1174 animation_length_layout->AddView(animation_length_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
1175
1176- nux::RangeValueInteger * animation_length_size_range = new nux::RangeValueInteger (view->GetView ()->animation_length, 0, 2000, NUX_TRACKER_LOCATION);
1177+ nux::RangeValueInteger * animation_length_size_range = new nux::RangeValueInteger (controller->GetView ()->GetAnimationLength(), 0, 2000, NUX_TRACKER_LOCATION);
1178 animation_length_size_range->sigValueChanged.connect (sigc::ptr_fun (OnAnimationLengthChanged));
1179 animation_length_layout->AddView(animation_length_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
1180
1181@@ -282,7 +294,7 @@
1182 nux::GetGraphicsDisplay()->GetGpuDevice()->backup_texture0_ = background->GetDeviceTexture();
1183
1184
1185- g_timeout_add(1500, on_timeout, view);
1186+ g_timeout_add(1500, on_timeout, controller.get());
1187 }
1188
1189 int main(int argc, char** argv)
1190
1191=== modified file 'launcher/SwitcherController.cpp'
1192--- launcher/SwitcherController.cpp 2012-11-23 04:05:35 +0000
1193+++ launcher/SwitcherController.cpp 2012-12-19 14:00:32 +0000
1194@@ -43,9 +43,116 @@
1195 namespace switcher
1196 {
1197
1198-Controller::Controller(unsigned int load_timeout)
1199+/* Delegation to impl */
1200+Controller::Controller(CreateImplFunc const& create)
1201+ : impl_(create())
1202+{
1203+}
1204+
1205+bool Controller::CanShowSwitcher(const std::vector<AbstractLauncherIcon::Ptr>& results) const
1206+{
1207+ return impl_->CanShowSwitcher(results);
1208+}
1209+
1210+void Controller::Show(ShowMode show,
1211+ SortMode sort,
1212+ std::vector<AbstractLauncherIcon::Ptr> results)
1213+{
1214+ impl_->Show(show, sort, results);
1215+}
1216+
1217+void Controller::Select(int index)
1218+{
1219+ impl_->Select(index);
1220+}
1221+
1222+void Controller::SetWorkspace(nux::Geometry geo, int monitor)
1223+{
1224+ impl_->SetWorkspace(geo, monitor);
1225+}
1226+
1227+void Controller::Hide(bool accept_state)
1228+{
1229+ impl_->Hide(accept_state);
1230+}
1231+
1232+bool Controller::Visible()
1233+{
1234+ return impl_->Visible();
1235+}
1236+
1237+void Controller::Next()
1238+{
1239+ impl_->Next();
1240+}
1241+
1242+void Controller::Prev()
1243+{
1244+ impl_->Prev();
1245+}
1246+
1247+View* Controller::GetView()
1248+{
1249+ return impl_->GetView();
1250+}
1251+
1252+void Controller::SetDetail(bool value, unsigned int min_windows)
1253+{
1254+ impl_->SetDetail(value, min_windows);
1255+}
1256+
1257+void Controller::NextDetail()
1258+{
1259+ impl_->NextDetail();
1260+}
1261+
1262+void Controller::PrevDetail()
1263+{
1264+ impl_->PrevDetail();
1265+}
1266+
1267+LayoutWindow::Vector Controller::ExternalRenderTargets()
1268+{
1269+ return impl_->ExternalRenderTargets();
1270+}
1271+
1272+guint Controller::GetSwitcherInputWindowId() const
1273+{
1274+ return impl_->GetSwitcherInputWindowId();
1275+}
1276+
1277+bool Controller::IsShowDesktopDisabled() const
1278+{
1279+ return impl_->IsShowDesktopDisabled();
1280+}
1281+
1282+void Controller::SetShowDesktopDisabled(bool disabled)
1283+{
1284+ impl_->SetShowDesktopDisabled(disabled);
1285+}
1286+
1287+int Controller::StartIndex() const
1288+{
1289+ return impl_->StartIndex();
1290+}
1291+
1292+void Controller::SelectFirstItem()
1293+{
1294+ impl_->SelectFirstItem();
1295+}
1296+
1297+sigc::connection Controller::ConnectToViewBuilt(const sigc::slot<void> &f)
1298+{
1299+ return impl_->view_built.connect(f);
1300+}
1301+
1302+void Controller::SetDetailOnTimeout(bool timeout)
1303+{
1304+ impl_->detail_on_timeout = timeout;
1305+}
1306+
1307+ShellController::ShellController(unsigned int load_timeout)
1308 : timeout_length(75)
1309- , detail_on_timeout(true)
1310 , detail_timeout_length(500)
1311 , initial_detail_timeout_length(1500)
1312 , construct_timeout_(load_timeout)
1313@@ -55,29 +162,30 @@
1314 , show_desktop_disabled_(false)
1315 , bg_color_(0, 0, 0, 0.5)
1316 {
1317- ubus_manager_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, sigc::mem_fun(this, &Controller::OnBackgroundUpdate));
1318+ detail_on_timeout = true;
1319+ ubus_manager_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, sigc::mem_fun(this, &ShellController::OnBackgroundUpdate));
1320
1321 sources_.AddTimeoutSeconds(construct_timeout_, [&] { ConstructWindow(); return false; }, LAZY_TIMEOUT);
1322 }
1323
1324-void Controller::OnBackgroundUpdate(GVariant* data)
1325+void ShellController::OnBackgroundUpdate(GVariant* data)
1326 {
1327 gdouble red, green, blue, alpha;
1328 g_variant_get(data, "(dddd)", &red, &green, &blue, &alpha);
1329 bg_color_ = nux::Color(red, green, blue, alpha);
1330
1331 if (view_)
1332- view_->background_color = bg_color_;
1333+ view_->SetBackgroundColor(bg_color_);
1334 }
1335
1336-bool Controller::CanShowSwitcher(const std::vector<AbstractLauncherIcon::Ptr>& results) const
1337+bool ShellController::CanShowSwitcher(const std::vector<AbstractLauncherIcon::Ptr>& results) const
1338 {
1339 bool empty = (show_desktop_disabled_ ? results.empty() : results.size() == 1);
1340
1341 return (!empty && !WindowManager::Default().IsWallActive());
1342 }
1343
1344-void Controller::Show(ShowMode show, SortMode sort, std::vector<AbstractLauncherIcon::Ptr> results)
1345+void ShellController::Show(ShowMode show, SortMode sort, std::vector<AbstractLauncherIcon::Ptr> results)
1346 {
1347 if (results.empty())
1348 return;
1349@@ -89,7 +197,7 @@
1350
1351 model_.reset(new SwitcherModel(results));
1352 AddChild(model_.get());
1353- model_->selection_changed.connect(sigc::mem_fun(this, &Controller::OnModelSelectionChanged));
1354+ model_->selection_changed.connect(sigc::mem_fun(this, &ShellController::OnModelSelectionChanged));
1355 model_->only_detail_on_viewport = (show == ShowMode::CURRENT_VIEWPORT);
1356
1357 SelectFirstItem();
1358@@ -113,7 +221,7 @@
1359
1360 if (detail_on_timeout)
1361 {
1362- auto cb_func = sigc::mem_fun(this, &Controller::OnDetailTimer);
1363+ auto cb_func = sigc::mem_fun(this, &ShellController::OnDetailTimer);
1364 sources_.AddTimeout(initial_detail_timeout_length, cb_func, DETAIL_TIMEOUT);
1365 }
1366
1367@@ -121,13 +229,13 @@
1368 ubus_manager_.SendMessage(UBUS_SWITCHER_SHOWN, g_variant_new("(bi)", true, monitor_));
1369 }
1370
1371-void Controller::Select(int index)
1372+void ShellController::Select(int index)
1373 {
1374 if (visible_)
1375 model_->Select(index);
1376 }
1377
1378-bool Controller::OnDetailTimer()
1379+bool ShellController::OnDetailTimer()
1380 {
1381 if (visible_ && !model_->detail_selection)
1382 {
1383@@ -138,11 +246,11 @@
1384 return false;
1385 }
1386
1387-void Controller::OnModelSelectionChanged(AbstractLauncherIcon::Ptr const& icon)
1388+void ShellController::OnModelSelectionChanged(AbstractLauncherIcon::Ptr const& icon)
1389 {
1390 if (detail_on_timeout)
1391 {
1392- auto cb_func = sigc::mem_fun(this, &Controller::OnDetailTimer);
1393+ auto cb_func = sigc::mem_fun(this, &ShellController::OnDetailTimer);
1394 sources_.AddTimeout(detail_timeout_length, cb_func, DETAIL_TIMEOUT);
1395 }
1396
1397@@ -158,7 +266,7 @@
1398 }
1399 }
1400
1401-void Controller::ShowView()
1402+void ShellController::ShowView()
1403 {
1404 if (!visible_)
1405 return;
1406@@ -177,7 +285,7 @@
1407 }
1408 }
1409
1410-void Controller::ConstructWindow()
1411+void ShellController::ConstructWindow()
1412 {
1413 sources_.Remove(LAZY_TIMEOUT);
1414
1415@@ -196,39 +304,44 @@
1416 }
1417 }
1418
1419-void Controller::ConstructView()
1420+void ShellController::ConstructView()
1421 {
1422 if (view_ || !model_)
1423 return;
1424
1425 sources_.Remove(VIEW_CONSTRUCT_IDLE);
1426
1427- view_ = SwitcherView::Ptr(new SwitcherView());
1428- AddChild(view_.GetPointer());
1429+ view_.reset (new switcher::View ([this]{
1430+ switcher::NuxView *p(new switcher::NuxView());
1431+ introspectable_view_ = p;
1432+ nux_view_ = p;
1433+ return std::unique_ptr<switcher::View::Impl>(p);
1434+ }));
1435+ AddChild(introspectable_view_);
1436 view_->SetModel(model_);
1437- view_->background_color = bg_color_;
1438- view_->monitor = monitor_;
1439+ view_->SetBackgroundColor(bg_color_);
1440+ view_->SetMonitor(monitor_);
1441 view_->SetupBackground();
1442
1443 ConstructWindow();
1444- main_layout_->AddView(view_.GetPointer(), 1);
1445- view_window_->SetEnterFocusInputArea(view_.GetPointer());
1446+ main_layout_->AddView(nux_view_, 1);
1447+ view_window_->SetEnterFocusInputArea(nux_view_);
1448 view_window_->SetGeometry(workarea_);
1449 view_window_->SetOpacity(0.0f);
1450
1451 view_built.emit();
1452 }
1453
1454-void Controller::SetWorkspace(nux::Geometry geo, int monitor)
1455+void ShellController::SetWorkspace(nux::Geometry geo, int monitor)
1456 {
1457 monitor_ = monitor;
1458 workarea_ = geo;
1459
1460 if (view_)
1461- view_->monitor = monitor_;
1462+ view_->SetMonitor(monitor_);
1463 }
1464
1465-void Controller::Hide(bool accept_state)
1466+void ShellController::Hide(bool accept_state)
1467 {
1468 if (!visible_)
1469 return;
1470@@ -267,7 +380,7 @@
1471 visible_ = false;
1472
1473 if (view_)
1474- main_layout_->RemoveChildObject(view_.GetPointer());
1475+ main_layout_->RemoveChildObject(nux_view_);
1476
1477 if (view_window_)
1478 {
1479@@ -281,15 +394,17 @@
1480
1481 last_active_selection_ = nullptr;
1482
1483- view_.Release();
1484+ view_.reset();
1485+ nux_view_ = nullptr;
1486+ introspectable_view_ = nullptr;
1487 }
1488
1489-bool Controller::Visible()
1490+bool ShellController::Visible()
1491 {
1492 return visible_;
1493 }
1494
1495-void Controller::Next()
1496+void ShellController::Next()
1497 {
1498 if (!model_)
1499 return;
1500@@ -318,7 +433,7 @@
1501 }
1502 }
1503
1504-void Controller::Prev()
1505+void ShellController::Prev()
1506 {
1507 if (!model_)
1508 return;
1509@@ -347,12 +462,12 @@
1510 }
1511 }
1512
1513-SwitcherView* Controller::GetView()
1514+View *ShellController::GetView()
1515 {
1516- return view_.GetPointer();
1517+ return view_.get();
1518 }
1519
1520-void Controller::SetDetail(bool value, unsigned int min_windows)
1521+void ShellController::SetDetail(bool value, unsigned int min_windows)
1522 {
1523 if (value && model_->DetailXids().size () >= min_windows)
1524 {
1525@@ -365,7 +480,7 @@
1526 }
1527 }
1528
1529-void Controller::NextDetail()
1530+void ShellController::NextDetail()
1531 {
1532 if (!model_)
1533 return;
1534@@ -381,7 +496,7 @@
1535 }
1536 }
1537
1538-void Controller::PrevDetail()
1539+void ShellController::PrevDetail()
1540 {
1541 if (!model_)
1542 return;
1543@@ -398,7 +513,7 @@
1544 }
1545 }
1546
1547-LayoutWindow::Vector Controller::ExternalRenderTargets()
1548+LayoutWindow::Vector ShellController::ExternalRenderTargets()
1549 {
1550 if (!view_)
1551 {
1552@@ -408,27 +523,27 @@
1553 return view_->ExternalTargets();
1554 }
1555
1556-guint Controller::GetSwitcherInputWindowId() const
1557+guint ShellController::GetSwitcherInputWindowId() const
1558 {
1559 return view_window_->GetInputWindowId();
1560 }
1561
1562-bool Controller::IsShowDesktopDisabled() const
1563+bool ShellController::IsShowDesktopDisabled() const
1564 {
1565 return show_desktop_disabled_;
1566 }
1567
1568-void Controller::SetShowDesktopDisabled(bool disabled)
1569+void ShellController::SetShowDesktopDisabled(bool disabled)
1570 {
1571 show_desktop_disabled_ = disabled;
1572 }
1573
1574-int Controller::StartIndex() const
1575+int ShellController::StartIndex() const
1576 {
1577 return (show_desktop_disabled_ ? 0 : 1);
1578 }
1579
1580-bool Controller::CompareSwitcherItemsPriority(AbstractLauncherIcon::Ptr const& first,
1581+bool ShellController::CompareSwitcherItemsPriority(AbstractLauncherIcon::Ptr const& first,
1582 AbstractLauncherIcon::Ptr const& second)
1583 {
1584 if (first->GetIconType() == second->GetIconType())
1585@@ -443,7 +558,7 @@
1586 return first->GetIconType() < second->GetIconType();
1587 }
1588
1589-void Controller::SelectFirstItem()
1590+void ShellController::SelectFirstItem()
1591 {
1592 if (!model_)
1593 return;
1594@@ -500,13 +615,13 @@
1595
1596 /* Introspection */
1597 std::string
1598-Controller::GetName() const
1599+ShellController::GetName() const
1600 {
1601 return "SwitcherController";
1602 }
1603
1604 void
1605-Controller::AddProperties(GVariantBuilder* builder)
1606+ShellController::AddProperties(GVariantBuilder* builder)
1607 {
1608 unity::variant::BuilderWrapper(builder)
1609 .add("timeout_length", timeout_length())
1610
1611=== modified file 'launcher/SwitcherController.h'
1612--- launcher/SwitcherController.h 2012-11-16 15:58:49 +0000
1613+++ launcher/SwitcherController.h 2012-12-19 14:00:32 +0000
1614@@ -20,6 +20,8 @@
1615 #ifndef SWITCHERCONTROLLER_H
1616 #define SWITCHERCONTROLLER_H
1617
1618+#include <memory>
1619+
1620 #include <UnityCore/Variant.h>
1621 #include <UnityCore/GLibSource.h>
1622
1623@@ -54,33 +56,134 @@
1624 CURRENT_VIEWPORT,
1625 };
1626
1627-
1628-class Controller : public debug::Introspectable, public sigc::trackable
1629+class Controller
1630+{
1631+ public:
1632+
1633+ class Impl;
1634+ typedef std::unique_ptr<Impl> ImplPtr;
1635+ typedef std::function<ImplPtr()> CreateImplFunc;
1636+ typedef std::shared_ptr<Controller> Ptr;
1637+
1638+ public:
1639+
1640+ Controller(CreateImplFunc const&);
1641+
1642+ void Show(ShowMode show,
1643+ SortMode sort,
1644+ std::vector<launcher::AbstractLauncherIcon::Ptr> results);
1645+ void Hide(bool accept_state=true);
1646+
1647+ bool CanShowSwitcher(const std::vector<launcher::AbstractLauncherIcon::Ptr>& resutls) const;
1648+
1649+ bool Visible();
1650+
1651+ void Next();
1652+ void Prev();
1653+
1654+ void NextDetail();
1655+ void PrevDetail();
1656+
1657+ void Select(int index);
1658+
1659+ void SetDetail(bool detail,
1660+ unsigned int min_windows = 1);
1661+
1662+ void SelectFirstItem();
1663+
1664+ void SetWorkspace(nux::Geometry geo,
1665+ int monitor);
1666+
1667+ View * GetView ();
1668+
1669+ ui::LayoutWindow::Vector ExternalRenderTargets ();
1670+
1671+ guint GetSwitcherInputWindowId() const;
1672+
1673+ bool IsShowDesktopDisabled() const;
1674+ void SetShowDesktopDisabled(bool disabled);
1675+ int StartIndex() const;
1676+
1677+ sigc::connection ConnectToViewBuilt (sigc::slot<void> const&);
1678+ void SetDetailOnTimeout(bool timeout);
1679+
1680+ private:
1681+ ImplPtr impl_;
1682+};
1683+
1684+class Controller::Impl
1685+{
1686+ public:
1687+
1688+ virtual ~Impl () {}
1689+
1690+ virtual void Show(ShowMode show,
1691+ SortMode sort,
1692+ std::vector<launcher::AbstractLauncherIcon::Ptr> results) = 0;
1693+
1694+ virtual void Hide(bool accept_state) = 0;
1695+
1696+ virtual bool CanShowSwitcher(const std::vector<launcher::AbstractLauncherIcon::Ptr>& resutls) const = 0;
1697+
1698+ virtual bool Visible() = 0;
1699+
1700+ virtual void Next() = 0;
1701+ virtual void Prev() = 0;
1702+
1703+ virtual void NextDetail() = 0;
1704+ virtual void PrevDetail() = 0;
1705+
1706+ virtual void Select(int index) = 0;
1707+
1708+ virtual void SetDetail(bool detail,
1709+ unsigned int min_windows) = 0;
1710+
1711+ virtual void SelectFirstItem() = 0;
1712+
1713+ virtual void SetWorkspace(nux::Geometry geo,
1714+ int monitor) = 0;
1715+
1716+ virtual View * GetView () = 0;
1717+
1718+ virtual ui::LayoutWindow::Vector ExternalRenderTargets () = 0;
1719+
1720+ virtual guint GetSwitcherInputWindowId() const = 0;
1721+
1722+ virtual bool IsShowDesktopDisabled() const = 0;
1723+ virtual void SetShowDesktopDisabled(bool disabled) = 0;
1724+ virtual int StartIndex() const = 0;
1725+
1726+ sigc::signal<void> view_built;
1727+ nux::Property<bool> detail_on_timeout;
1728+};
1729+
1730+class ShellController : public Controller::Impl,
1731+ public debug::Introspectable,
1732+ public sigc::trackable
1733 {
1734 public:
1735- typedef std::shared_ptr<Controller> Ptr;
1736-
1737- Controller(unsigned int load_timeout = 20);
1738+ typedef std::shared_ptr<ShellController> Ptr;
1739
1740 nux::Property<int> timeout_length;
1741- nux::Property<bool> detail_on_timeout;
1742 nux::Property<int> detail_timeout_length;
1743 nux::Property<int> initial_detail_timeout_length;
1744
1745- void Show(ShowMode show, SortMode sort, std::vector<launcher::AbstractLauncherIcon::Ptr> results);
1746- void Hide(bool accept_state=true);
1747+ ShellController(unsigned int load_timeout = 20);
1748+
1749+ virtual void Show(ShowMode show, SortMode sort, std::vector<launcher::AbstractLauncherIcon::Ptr> results);
1750+ virtual void Hide(bool accept_state);
1751
1752 bool CanShowSwitcher(const std::vector<launcher::AbstractLauncherIcon::Ptr>& resutls) const;
1753
1754- bool Visible();
1755+ virtual bool Visible();
1756
1757- void Next();
1758- void Prev();
1759+ virtual void Next();
1760+ virtual void Prev();
1761
1762 void NextDetail();
1763 void PrevDetail();
1764
1765- void Select (int index);
1766+ virtual void Select (int index);
1767
1768 void SetDetail(bool detail, unsigned int min_windows = 1);
1769
1770@@ -88,7 +191,7 @@
1771
1772 void SetWorkspace(nux::Geometry geo, int monitor);
1773
1774- SwitcherView * GetView ();
1775+ virtual View* GetView();
1776
1777 ui::LayoutWindow::Vector ExternalRenderTargets ();
1778
1779@@ -98,8 +201,6 @@
1780 void SetShowDesktopDisabled(bool disabled);
1781 int StartIndex() const;
1782
1783- sigc::signal<void> view_built;
1784-
1785 protected:
1786 // Introspectable methods
1787 std::string GetName() const;
1788@@ -126,7 +227,9 @@
1789 static bool CompareSwitcherItemsPriority(launcher::AbstractLauncherIcon::Ptr const& first, launcher::AbstractLauncherIcon::Ptr const& second);
1790
1791 SwitcherModel::Ptr model_;
1792- SwitcherView::Ptr view_;
1793+ debug::Introspectable *introspectable_view_;
1794+ NuxView *nux_view_;
1795+ View::Ptr view_;
1796
1797 nux::Geometry workarea_;
1798 nux::ObjectPtr<nux::BaseWindow> view_window_;
1799
1800=== modified file 'launcher/SwitcherView.cpp'
1801--- launcher/SwitcherView.cpp 2012-12-14 12:14:34 +0000
1802+++ launcher/SwitcherView.cpp 2012-12-19 14:00:32 +0000
1803@@ -32,9 +32,137 @@
1804 namespace switcher
1805 {
1806
1807-NUX_IMPLEMENT_OBJECT_TYPE(SwitcherView);
1808-
1809-SwitcherView::SwitcherView()
1810+View::View(const ViewFactoryFunc &create)
1811+ : impl_(create())
1812+{
1813+}
1814+
1815+
1816+ui::LayoutWindow::Vector View::ExternalTargets()
1817+{
1818+ return impl_->ExternalTargets();
1819+}
1820+
1821+void View::SetModel(SwitcherModel::Ptr model)
1822+{
1823+ impl_->SetModel(model);
1824+}
1825+
1826+SwitcherModel::Ptr View::GetModel()
1827+{
1828+ return impl_->GetModel();
1829+}
1830+
1831+View::MouseEventConnections
1832+View::ConnectToMouseEvents(const View::MouseButtonCallback &mouse_down_callback,
1833+ const View::MouseButtonCallback &mouse_up_callback,
1834+ const View::MouseDragCallback &mouse_drag_callback)
1835+{
1836+ return impl_->ConnectToMouseEvents(mouse_down_callback,
1837+ mouse_up_callback,
1838+ mouse_drag_callback);
1839+}
1840+
1841+void View::QueueDraw()
1842+{
1843+ impl_->QueueDraw();
1844+}
1845+
1846+nux::Geometry View::GetAbsoluteGeometry() const
1847+{
1848+ return impl_->GetAbsoluteGeometry();
1849+}
1850+
1851+// Returns the index of the icon at the given position, in window coordinates.
1852+// If there's no icon there, -1 is returned.
1853+int View::IconIndexAt(int x, int y)
1854+{
1855+ return impl_->IconIndexAt(x, y);
1856+}
1857+
1858+// Property setters
1859+void View::SetBackgroundColor(nux::Color const& color)
1860+{
1861+ impl_->SetBackgroundColor(color);
1862+}
1863+
1864+void View::SetMonitor(unsigned int monitor)
1865+{
1866+ impl_->monitor = monitor;
1867+}
1868+
1869+void View::SetBorderSize(unsigned int size)
1870+{
1871+ impl_->border_size = size;
1872+}
1873+
1874+void View::SetFlatSpacing(int spacing)
1875+{
1876+ impl_->flat_spacing = spacing;
1877+}
1878+
1879+void View::SetTextSize(unsigned int size)
1880+{
1881+ impl_->text_size = size;
1882+}
1883+
1884+void View::SetIconSize(unsigned int size)
1885+{
1886+ impl_->icon_size = size;
1887+}
1888+
1889+void View::SetTileSize(unsigned int size)
1890+{
1891+ impl_->tile_size = size;
1892+}
1893+
1894+void View::SetAnimationLength(unsigned int length)
1895+{
1896+ impl_->animation_length = length;
1897+}
1898+
1899+void View::SetRenderBoxes(bool render)
1900+{
1901+ impl_->render_boxes = render;
1902+}
1903+
1904+// Property getters
1905+unsigned int View::GetBorderSize()
1906+{
1907+ return impl_->border_size;
1908+}
1909+
1910+unsigned int View::GetFlatSpacing()
1911+{
1912+ return impl_->flat_spacing;
1913+}
1914+
1915+unsigned int View::GetTextSize()
1916+{
1917+ return impl_->text_size;
1918+}
1919+
1920+unsigned int View::GetIconSize()
1921+{
1922+ return impl_->icon_size;
1923+}
1924+
1925+unsigned int View::GetTileSize()
1926+{
1927+ return impl_->tile_size;
1928+}
1929+
1930+unsigned int View::GetAnimationLength()
1931+{
1932+ return impl_->animation_length;
1933+}
1934+
1935+void View::SetupBackground(bool enabled)
1936+{
1937+ return impl_->SetupBackground(enabled);
1938+}
1939+
1940+View::Impl::Impl()
1941 : render_boxes(false)
1942 , border_size(50)
1943 , flat_spacing(10)
1944@@ -46,6 +174,14 @@
1945 , animation_length(250)
1946 , monitor(-1)
1947 , spread_size(3.5f)
1948+{
1949+}
1950+
1951+NUX_IMPLEMENT_OBJECT_TYPE(NuxView);
1952+
1953+NuxView::NuxView()
1954+ : UnityWindowView()
1955+ , switcher::View::Impl ()
1956 , icon_renderer_(std::make_shared<IconRenderer>())
1957 , text_view_(new StaticCairoText(""))
1958 , animation_draw_(false)
1959@@ -60,18 +196,28 @@
1960 text_view_->SetTextColor(nux::color::White);
1961 text_view_->SetFont("Ubuntu Bold 10");
1962
1963- icon_size.changed.connect (sigc::mem_fun (this, &SwitcherView::OnIconSizeChanged));
1964- tile_size.changed.connect (sigc::mem_fun (this, &SwitcherView::OnTileSizeChanged));
1965+ icon_size.changed.connect (sigc::mem_fun (this, &NuxView::OnIconSizeChanged));
1966+ tile_size.changed.connect (sigc::mem_fun (this, &NuxView::OnTileSizeChanged));
1967
1968 CaptureMouseDownAnyWhereElse(true);
1969 }
1970
1971-std::string SwitcherView::GetName() const
1972+void NuxView::SetBackgroundColor(nux::Color const& color)
1973+{
1974+ background_color = color;
1975+}
1976+
1977+void NuxView::SetupBackground(bool enabled)
1978+{
1979+ UnityWindowView::SetupBackground(enabled);
1980+}
1981+
1982+std::string NuxView::GetName() const
1983 {
1984 return "SwitcherView";
1985 }
1986
1987-void SwitcherView::AddProperties(GVariantBuilder* builder)
1988+void NuxView::AddProperties(GVariantBuilder* builder)
1989 {
1990 unity::variant::BuilderWrapper(builder)
1991 .add("render-boxes", render_boxes)
1992@@ -88,17 +234,17 @@
1993 .add("label_visible", text_view_->IsVisible());
1994 }
1995
1996-LayoutWindow::Vector SwitcherView::ExternalTargets ()
1997+LayoutWindow::Vector NuxView::ExternalTargets ()
1998 {
1999 return render_targets_;
2000 }
2001
2002-void SwitcherView::SetModel(SwitcherModel::Ptr model)
2003+void NuxView::SetModel(SwitcherModel::Ptr model)
2004 {
2005 model_ = model;
2006- model->selection_changed.connect(sigc::mem_fun(this, &SwitcherView::OnSelectionChanged));
2007- model->detail_selection.changed.connect (sigc::mem_fun (this, &SwitcherView::OnDetailSelectionChanged));
2008- model->detail_selection_index.changed.connect (sigc::mem_fun (this, &SwitcherView::OnDetailSelectionIndexChanged));
2009+ model->selection_changed.connect(sigc::mem_fun(this, &NuxView::OnSelectionChanged));
2010+ model->detail_selection.changed.connect (sigc::mem_fun (this, &NuxView::OnDetailSelectionChanged));
2011+ model->detail_selection_index.changed.connect (sigc::mem_fun (this, &NuxView::OnDetailSelectionIndexChanged));
2012
2013 if (!model->Selection())
2014 return;
2015@@ -109,30 +255,30 @@
2016 text_view_->SetText(model->Selection()->tooltip_text());
2017 }
2018
2019-void SwitcherView::OnIconSizeChanged (int size)
2020+void NuxView::OnIconSizeChanged (int size)
2021 {
2022 icon_renderer_->SetTargetSize(tile_size, icon_size, 10);
2023 }
2024
2025-void SwitcherView::OnTileSizeChanged (int size)
2026+void NuxView::OnTileSizeChanged (int size)
2027 {
2028 icon_renderer_->SetTargetSize(tile_size, icon_size, 10);
2029 vertical_size = tile_size + 80;
2030 }
2031
2032-void SwitcherView::SaveLast ()
2033+void NuxView::SaveLast ()
2034 {
2035 saved_args_ = last_args_;
2036 saved_background_ = last_background_;
2037 clock_gettime(CLOCK_MONOTONIC, &save_time_);
2038 }
2039
2040-void SwitcherView::OnDetailSelectionIndexChanged(unsigned int index)
2041+void NuxView::OnDetailSelectionIndexChanged(unsigned int index)
2042 {
2043 QueueDraw ();
2044 }
2045
2046-void SwitcherView::OnDetailSelectionChanged(bool detail)
2047+void NuxView::OnDetailSelectionChanged (bool detail)
2048 {
2049 text_view_->SetVisible(!detail);
2050
2051@@ -143,7 +289,7 @@
2052 QueueDraw();
2053 }
2054
2055-void SwitcherView::OnSelectionChanged(AbstractLauncherIcon::Ptr const& selection)
2056+void NuxView::OnSelectionChanged(AbstractLauncherIcon::Ptr const& selection)
2057 {
2058 if (selection)
2059 text_view_->SetText(selection->tooltip_text());
2060@@ -152,12 +298,12 @@
2061 QueueDraw();
2062 }
2063
2064-SwitcherModel::Ptr SwitcherView::GetModel()
2065+SwitcherModel::Ptr NuxView::GetModel()
2066 {
2067 return model_;
2068 }
2069
2070-RenderArg SwitcherView::CreateBaseArgForIcon(AbstractLauncherIcon::Ptr const& icon)
2071+RenderArg NuxView::CreateBaseArgForIcon(AbstractLauncherIcon::Ptr const& icon)
2072 {
2073 RenderArg arg;
2074 arg.icon = icon.GetPointer();
2075@@ -185,7 +331,7 @@
2076 return arg;
2077 }
2078
2079-RenderArg SwitcherView::InterpolateRenderArgs(RenderArg const& start, RenderArg const& end, float progress)
2080+RenderArg NuxView::InterpolateRenderArgs(RenderArg const& start, RenderArg const& end, float progress)
2081 {
2082 // easing
2083 progress = -pow(progress - 1.0f, 2) + 1;
2084@@ -205,7 +351,7 @@
2085 return result;
2086 }
2087
2088-nux::Geometry SwitcherView::InterpolateBackground (nux::Geometry const& start, nux::Geometry const& end, float progress)
2089+nux::Geometry NuxView::InterpolateBackground (nux::Geometry const& start, nux::Geometry const& end, float progress)
2090 {
2091 progress = -pow(progress - 1.0f, 2) + 1;
2092
2093@@ -219,7 +365,7 @@
2094 return result;
2095 }
2096
2097-nux::Geometry SwitcherView::UpdateRenderTargets(nux::Point const& center, timespec const& current)
2098+nux::Geometry NuxView::UpdateRenderTargets (nux::Point const& center, timespec const& current)
2099 {
2100 std::vector<Window> const& xids = model_->DetailXids();
2101
2102@@ -262,7 +408,7 @@
2103 return final_bounds;
2104 }
2105
2106-void SwitcherView::OffsetRenderTargets (int x, int y)
2107+void NuxView::OffsetRenderTargets (int x, int y)
2108 {
2109 for (LayoutWindow::Ptr const& target : render_targets_)
2110 {
2111@@ -271,7 +417,7 @@
2112 }
2113 }
2114
2115-nux::Size SwitcherView::SpreadSize()
2116+nux::Size NuxView::SpreadSize()
2117 {
2118 nux::Geometry const& base = GetGeometry();
2119 nux::Size result(base.width - border_size * 2, base.height - border_size * 2);
2120@@ -282,13 +428,13 @@
2121 return result;
2122 }
2123
2124-void SwitcherView::GetFlatIconPositions (int n_flat_icons,
2125- int size,
2126- int selection,
2127- int &first_flat,
2128- int &last_flat,
2129- int &half_fold_left,
2130- int &half_fold_right)
2131+void NuxView::GetFlatIconPositions(int n_flat_icons,
2132+ int size,
2133+ int selection,
2134+ int &first_flat,
2135+ int &last_flat,
2136+ int &half_fold_left,
2137+ int &half_fold_right)
2138 {
2139 half_fold_left = -1;
2140 half_fold_right = -1;
2141@@ -356,7 +502,9 @@
2142 }
2143 }
2144
2145-std::list<RenderArg> SwitcherView::RenderArgsFlat(nux::Geometry& background_geo, int selection, timespec const& current)
2146+std::list<RenderArg> NuxView::RenderArgsFlat(nux::Geometry& background_geo,
2147+ int selection,
2148+ timespec const& current)
2149 {
2150 std::list<RenderArg> results;
2151 nux::Geometry const& base = GetGeometry();
2152@@ -506,7 +654,7 @@
2153 return results;
2154 }
2155
2156-void SwitcherView::PreDraw(nux::GraphicsEngine& GfxContext, bool force_draw)
2157+void NuxView::PreDraw(nux::GraphicsEngine& GfxContext, bool force_draw)
2158 {
2159 clock_gettime(CLOCK_MONOTONIC, &current_);
2160
2161@@ -523,12 +671,22 @@
2162 icon_renderer_->PreprocessIcons(last_args_, GetGeometry());
2163 }
2164
2165-nux::Geometry SwitcherView::GetBackgroundGeometry()
2166+nux::Geometry NuxView::GetBackgroundGeometry()
2167 {
2168 return last_background_;
2169 }
2170
2171-void SwitcherView::DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw, nux::Geometry internal_clip)
2172+void NuxView::QueueDraw()
2173+{
2174+ ui::UnityWindowView::QueueDraw();
2175+}
2176+
2177+nux::Geometry NuxView::GetAbsoluteGeometry() const
2178+{
2179+ return ui::UnityWindowView::GetAbsoluteGeometry();
2180+}
2181+
2182+void NuxView::DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw, nux::Geometry internal_clip)
2183 {
2184 nux::Geometry base = GetGeometry();
2185
2186@@ -600,7 +758,7 @@
2187 animation_draw_ = false;
2188 }
2189
2190-int SwitcherView::IconIndexAt(int x, int y)
2191+int NuxView::IconIndexAt(int x, int y)
2192 {
2193 int half_size = icon_size.Get() / 2;
2194 int icon_index = -1;
2195@@ -633,5 +791,15 @@
2196 return icon_index;
2197 }
2198
2199+NuxView::MouseEventConnections
2200+NuxView::ConnectToMouseEvents(const MouseButtonCallback &mouse_down_callback,
2201+ const MouseButtonCallback &mouse_up_callback,
2202+ const MouseDragCallback &mouse_drag_callback)
2203+{
2204+ return NuxView::MouseEventConnections
2205+ (mouse_down.connect (mouse_down_callback),
2206+ mouse_up.connect (mouse_up_callback),
2207+ mouse_drag.connect (mouse_drag_callback));
2208+}
2209 }
2210 }
2211
2212=== modified file 'launcher/SwitcherView.h'
2213--- launcher/SwitcherView.h 2012-12-14 12:14:34 +0000
2214+++ launcher/SwitcherView.h 2012-12-19 14:00:32 +0000
2215@@ -20,6 +20,8 @@
2216 #ifndef SWITCHERVIEW_H
2217 #define SWITCHERVIEW_H
2218
2219+#include <tuple>
2220+
2221 #include "SwitcherModel.h"
2222 #include "unity-shared/AbstractIconRenderer.h"
2223 #include "unity-shared/StaticCairoText.h"
2224@@ -41,19 +43,93 @@
2225 }
2226 namespace switcher
2227 {
2228-
2229-class SwitcherView : public ui::UnityWindowView
2230-{
2231- NUX_DECLARE_OBJECT_TYPE(SwitcherView, ui::UnityWindowView);
2232+class View
2233+{
2234+ public:
2235+
2236+ typedef sigc::slot<void, int, int, int, int> MouseButtonCallback;
2237+ typedef sigc::slot <void, int, int, int, int, unsigned int, unsigned int> MouseDragCallback;
2238+
2239+ typedef std::tuple <sigc::connection,
2240+ sigc::connection,
2241+ sigc::connection> MouseEventConnections;
2242+
2243+ class Impl;
2244+ typedef std::unique_ptr<Impl> ImplPtr;
2245+ typedef std::shared_ptr<View> Ptr;
2246+ typedef std::function<ImplPtr()> ViewFactoryFunc;
2247+
2248+ View(ViewFactoryFunc const&);
2249+
2250+ ui::LayoutWindow::Vector ExternalTargets();
2251+
2252+ void SetModel(SwitcherModel::Ptr model);
2253+ SwitcherModel::Ptr GetModel();
2254+
2255+ MouseEventConnections ConnectToMouseEvents(const MouseButtonCallback &mouse_down_callback,
2256+ const MouseButtonCallback &mouse_up_callback,
2257+ const MouseDragCallback &mouse_drag_callback);
2258+ void QueueDraw();
2259+ nux::Geometry GetAbsoluteGeometry() const;
2260+
2261+ // Returns the index of the icon at the given position, in window coordinates.
2262+ // If there's no icon there, -1 is returned.
2263+ int IconIndexAt(int x, int y);
2264+
2265+ // Property setters
2266+ void SetBackgroundColor(nux::Color const& color);
2267+ void SetMonitor(unsigned int monitor);
2268+ void SetBorderSize(unsigned int);
2269+ void SetFlatSpacing(int);
2270+ void SetTextSize(unsigned int);
2271+ void SetIconSize(unsigned int);
2272+ void SetTileSize(unsigned int);
2273+ void SetAnimationLength(unsigned int);
2274+ void SetRenderBoxes(bool);
2275+
2276+ // Property getters
2277+ unsigned int GetBorderSize();
2278+ unsigned int GetFlatSpacing();
2279+ unsigned int GetTextSize();
2280+ unsigned int GetIconSize();
2281+ unsigned int GetTileSize();
2282+ unsigned int GetAnimationLength();
2283+
2284+ void SetupBackground(bool enabled = true);
2285+
2286+ private:
2287+ std::unique_ptr<Impl> impl_;
2288+};
2289+
2290+class View::Impl
2291+{
2292 public:
2293- typedef nux::ObjectPtr<SwitcherView> Ptr;
2294-
2295- SwitcherView();
2296-
2297- ui::LayoutWindow::Vector ExternalTargets();
2298-
2299- void SetModel(SwitcherModel::Ptr model);
2300- SwitcherModel::Ptr GetModel();
2301+
2302+ typedef switcher::View::MouseButtonCallback MouseButtonCallback;
2303+ typedef switcher::View::MouseDragCallback MouseDragCallback;
2304+ typedef switcher::View::MouseEventConnections MouseEventConnections;
2305+
2306+ Impl();
2307+
2308+ virtual ~Impl() {};
2309+
2310+ virtual ui::LayoutWindow::Vector ExternalTargets() = 0;
2311+
2312+ virtual void SetModel(SwitcherModel::Ptr model) = 0;
2313+ virtual SwitcherModel::Ptr GetModel() = 0;
2314+
2315+ virtual MouseEventConnections ConnectToMouseEvents(const MouseButtonCallback &mouse_down_callback,
2316+ const MouseButtonCallback &mouse_up_callback,
2317+ const MouseDragCallback &mouse_drag_callback) = 0;
2318+ virtual void QueueDraw() = 0;
2319+ virtual nux::Geometry GetAbsoluteGeometry() const = 0;
2320+
2321+ // Returns the index of the icon at the given position, in window coordinates.
2322+ // If there's no icon there, -1 is returned.
2323+ virtual int IconIndexAt(int x, int y) = 0;
2324+
2325+ virtual void SetBackgroundColor(nux::Color const&) = 0;
2326+ virtual void SetupBackground(bool enabled) = 0;
2327
2328 nux::Property<bool> render_boxes;
2329 nux::Property<int> border_size;
2330@@ -66,48 +142,71 @@
2331 nux::Property<int> animation_length;
2332 nux::Property<int> monitor;
2333 nux::Property<double> spread_size;
2334+};
2335+
2336+class NuxView : public ui::UnityWindowView,
2337+ public unity::switcher::View::Impl
2338+{
2339+ NUX_DECLARE_OBJECT_TYPE(NuxView, ui::UnityWindowView);
2340+public:
2341+ typedef nux::ObjectPtr<NuxView> Ptr;
2342+
2343+ NuxView();
2344+
2345+ ui::LayoutWindow::Vector ExternalTargets();
2346+
2347+ void SetModel(SwitcherModel::Ptr model);
2348+ SwitcherModel::Ptr GetModel();
2349
2350 // Returns the index of the icon at the given position, in window coordinates.
2351 // If there's no icon there, -1 is returned.
2352 int IconIndexAt(int x, int y);
2353
2354+ MouseEventConnections ConnectToMouseEvents(MouseButtonCallback const& mouse_down_callback,
2355+ MouseButtonCallback const& mouse_up_callback,
2356+ MouseDragCallback const& mouse_drag_callback);
2357+
2358 protected:
2359 // Introspectable methods
2360+ void SetBackgroundColor(const nux::Color &);
2361+ void SetupBackground(bool enabled);
2362 std::string GetName() const;
2363 void AddProperties(GVariantBuilder* builder);
2364
2365 void PreDraw(nux::GraphicsEngine& GfxContext, bool force_draw);
2366 void DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw, nux::Geometry clip);
2367+ void QueueDraw();
2368+ nux::Geometry GetAbsoluteGeometry() const;
2369 nux::Geometry GetBackgroundGeometry();
2370
2371 ui::RenderArg InterpolateRenderArgs(ui::RenderArg const& start, ui::RenderArg const& end, float progress);
2372- nux::Geometry InterpolateBackground (nux::Geometry const& start, nux::Geometry const& end, float progress);
2373+ nux::Geometry InterpolateBackground(nux::Geometry const& start, nux::Geometry const& end, float progress);
2374
2375 std::list<ui::RenderArg> RenderArgsFlat(nux::Geometry& background_geo, int selection, timespec const& current);
2376
2377 ui::RenderArg CreateBaseArgForIcon(launcher::AbstractLauncherIcon::Ptr const& icon);
2378 private:
2379 void OnSelectionChanged(launcher::AbstractLauncherIcon::Ptr const& selection);
2380- void OnDetailSelectionChanged (bool detail);
2381- void OnDetailSelectionIndexChanged (unsigned int index);
2382-
2383- void OnIconSizeChanged (int size);
2384- void OnTileSizeChanged (int size);
2385-
2386- nux::Geometry UpdateRenderTargets (nux::Point const& center, timespec const& current);
2387- void OffsetRenderTargets (int x, int y);
2388-
2389- nux::Size SpreadSize ();
2390-
2391- void GetFlatIconPositions (int n_flat_icons,
2392- int size,
2393- int selection,
2394- int &first_flat,
2395- int &last_flat,
2396- int &half_fold_left,
2397- int &half_fold_right);
2398-
2399- void SaveLast ();
2400+ void OnDetailSelectionChanged(bool detail);
2401+ void OnDetailSelectionIndexChanged(unsigned int index);
2402+
2403+ void OnIconSizeChanged(int size);
2404+ void OnTileSizeChanged(int size);
2405+
2406+ nux::Geometry UpdateRenderTargets(nux::Point const& center, timespec const& current);
2407+ void OffsetRenderTargets(int x, int y);
2408+
2409+ nux::Size SpreadSize();
2410+
2411+ void GetFlatIconPositions(int n_flat_icons,
2412+ int size,
2413+ int selection,
2414+ int &first_flat,
2415+ int &last_flat,
2416+ int &half_fold_left,
2417+ int &half_fold_right);
2418+
2419+ void SaveLast();
2420
2421 SwitcherModel::Ptr model_;
2422 ui::LayoutSystem layout_system_;
2423@@ -131,7 +230,6 @@
2424
2425 glib::Source::UniquePtr redraw_idle_;
2426 };
2427-
2428 }
2429 }
2430
2431
2432=== modified file 'plugins/unityshell/CMakeLists.txt'
2433--- plugins/unityshell/CMakeLists.txt 2012-11-28 07:58:44 +0000
2434+++ plugins/unityshell/CMakeLists.txt 2012-12-19 14:00:32 +0000
2435@@ -7,11 +7,14 @@
2436 compiz_plugin (unityshell
2437 PKGDEPS ${UNITY_PLUGIN_DEPS}
2438 PLUGINDEPS composite opengl compiztoolbox scale
2439- CFLAGSADD "-DINSTALLPREFIX='\"${CMAKE_INSTALL_PREFIX}\"' -DPKGDATADIR='\"${PKGDATADIR}\"' -I${CMAKE_BINARY_DIR} -I${CMAKE_SOURCE_DIR} ${BOOT_LOGGER_FLAG} -DGETTEXT_PACKAGE='\"unity\"' ${MAINTAINER_CXXFLAGS} -I${CMAKE_SOURCE_DIR}/dash/ -I${CMAKE_SOURCE_DIR}/launcher/ -I${CMAKE_SOURCE_DIR}/hud/ -I${CMAKE_SOURCE_DIR}/panel/ -I${CMAKE_SOURCE_DIR}/shortcuts/ -I${CMAKE_SOURCE_DIR}/unity-shared/"
2440- LIBDIRS "${CMAKE_BINARY_DIR}/UnityCore"
2441+ CFLAGSADD "-DINSTALLPREFIX='\"${CMAKE_INSTALL_PREFIX}\"' -DPKGDATADIR='\"${PKGDATADIR}\"' -I${CMAKE_BINARY_DIR} -I${CMAKE_SOURCE_DIR} ${BOOT_LOGGER_FLAG} -DGETTEXT_PACKAGE='\"unity\"' ${MAINTAINER_CXXFLAGS} -I${CMAKE_SOURCE_DIR}/dash/ -I${CMAKE_SOURCE_DIR}/launcher/ -I${CMAKE_SOURCE_DIR}/hud/ -I${CMAKE_SOURCE_DIR}/panel/ -I${CMAKE_SOURCE_DIR}/shortcuts/ -I${CMAKE_SOURCE_DIR}/unity-shared/ -I${CMAKE_SOURCE_DIR}/gestures/"
2442+ LIBDIRS "${CMAKE_BINARY_DIR}/UnityCore" "${CMAKE_BINARY_DIR}/gestures"
2443+ LIBRARIES unity-core-${UNITY_API_VERSION} launcher-lib dash-lib gestures-lib switcher-lib hud-lib panel-lib shortcuts-lib unity-shared unity-shared-compiz
2444 )
2445-add_dependencies(unityshell unity-core-${UNITY_API_VERSION} dash-lib launcher-lib switcher-lib hud-lib panel-lib shortcuts-lib unity-shared unity-shared-compiz)
2446-target_link_libraries(unityshell unity-core-${UNITY_API_VERSION} launcher-lib dash-lib switcher-lib hud-lib panel-lib shortcuts-lib unity-shared unity-shared-bamf unity-shared-compiz)
2447+
2448+add_dependencies(unityshell unity-core-${UNITY_API_VERSION} dash-lib gestures-lib launcher-lib switcher-lib hud-lib panel-lib shortcuts-lib unity-shared unity-shared-compiz)
2449+target_link_libraries(unityshell unity-core-${UNITY_API_VERSION} launcher-lib dash-lib switcher-lib hud-lib panel-lib shortcuts-lib unity-shared unity-shared-bamf unity-shared-compiz gestures-lib)
2450+
2451 set_target_properties(unityshell
2452 PROPERTIES INSTALL_RPATH "${CACHED_UNITY_PRIVATE_DEPS_LIBRARY_DIRS}"
2453 INSTALL_RPATH_USE_LINK_PATH TRUE)
2454
2455=== modified file 'plugins/unityshell/src/unity-switcher-accessible.cpp'
2456--- plugins/unityshell/src/unity-switcher-accessible.cpp 2012-10-11 01:44:15 +0000
2457+++ plugins/unityshell/src/unity-switcher-accessible.cpp 2012-12-19 14:00:32 +0000
2458@@ -139,7 +139,7 @@
2459 {
2460 AtkObject* accessible = NULL;
2461
2462- g_return_val_if_fail(dynamic_cast<SwitcherView*>(object), NULL);
2463+ g_return_val_if_fail(dynamic_cast<View*>(object), NULL);
2464
2465 accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_SWITCHER_ACCESSIBLE, NULL));
2466
2467@@ -154,7 +154,7 @@
2468 unity_switcher_accessible_initialize(AtkObject* accessible,
2469 gpointer data)
2470 {
2471- SwitcherView* switcher = NULL;
2472+ View* switcher = NULL;
2473 nux::Object* nux_object = NULL;
2474 UnitySwitcherAccessible* self = NULL;
2475 SwitcherModel::Ptr model;
2476@@ -165,7 +165,8 @@
2477
2478 self = UNITY_SWITCHER_ACCESSIBLE(accessible);
2479 nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
2480- switcher = dynamic_cast<SwitcherView*>(nux_object);
2481+ switcher = dynamic_cast<View*>(nux_object);
2482+
2483 if (switcher == NULL)
2484 return;
2485
2486@@ -276,7 +277,7 @@
2487 unity_switcher_accessible_ref_selection(AtkSelection* selection,
2488 gint i)
2489 {
2490- SwitcherView* switcher = NULL;
2491+ View* switcher = NULL;
2492 SwitcherModel::Ptr switcher_model;
2493 nux::Object* nux_object = NULL;
2494 gint selected_index = 0;
2495@@ -292,7 +293,7 @@
2496 if (!nux_object) /* state is defunct */
2497 return 0;
2498
2499- switcher = dynamic_cast<SwitcherView*>(nux_object);
2500+ switcher = dynamic_cast<View*>(nux_object);
2501
2502 switcher_model = switcher->GetModel();
2503 selected_index = switcher_model->SelectionIndex();
2504@@ -309,7 +310,7 @@
2505 static gint
2506 unity_switcher_accessible_get_selection_count(AtkSelection* selection)
2507 {
2508- SwitcherView* switcher = NULL;
2509+ View* switcher = NULL;
2510 SwitcherModel::Ptr switcher_model;
2511 nux::Object* nux_object = NULL;
2512
2513@@ -319,7 +320,7 @@
2514 if (!nux_object) /* state is defunct */
2515 return 0;
2516
2517- switcher = dynamic_cast<SwitcherView*>(nux_object);
2518+ switcher = dynamic_cast<View*>(nux_object);
2519 switcher_model = switcher->GetModel();
2520
2521 if (!switcher_model->Selection())
2522@@ -332,7 +333,7 @@
2523 unity_switcher_accessible_is_child_selected(AtkSelection* selection,
2524 gint i)
2525 {
2526- SwitcherView* switcher = NULL;
2527+ View* switcher = NULL;
2528 SwitcherModel::Ptr switcher_model;
2529 SwitcherModel::iterator it;
2530 nux::Object* nux_object = NULL;
2531@@ -344,7 +345,7 @@
2532 if (!nux_object) /* state is defunct */
2533 return 0;
2534
2535- switcher = dynamic_cast<SwitcherView*>(nux_object);
2536+ switcher = dynamic_cast<View*>(nux_object);
2537 switcher_model = switcher->GetModel();
2538 selected_index = switcher_model->SelectionIndex();
2539
2540@@ -385,7 +386,7 @@
2541 {
2542 gint index = 0;
2543 nux::Object* nux_object = NULL;
2544- SwitcherView* switcher = NULL;
2545+ View* switcher = NULL;
2546 SwitcherModel::iterator it;
2547 AtkObject* child_accessible = NULL;
2548
2549@@ -393,7 +394,7 @@
2550 if (!nux_object) /* state is defunct */
2551 return;
2552
2553- switcher = dynamic_cast<SwitcherView*>(nux_object);
2554+ switcher = dynamic_cast<View*>(nux_object);
2555 SwitcherModel::Ptr const& switcher_model = switcher->GetModel();
2556
2557 if (!switcher_model)
2558
2559=== modified file 'plugins/unityshell/src/unitya11y.cpp'
2560--- plugins/unityshell/src/unitya11y.cpp 2012-12-14 12:14:34 +0000
2561+++ plugins/unityshell/src/unitya11y.cpp 2012-12-19 14:00:32 +0000
2562@@ -183,7 +183,7 @@
2563 if (object->Type().IsDerivedFromType(unity::SearchBar::StaticObjectType))
2564 return unity_search_bar_accessible_new(object);
2565
2566- if (object->Type().IsDerivedFromType(unity::switcher::SwitcherView::StaticObjectType))
2567+ if (object->Type().IsDerivedFromType(unity::switcher::NuxView::StaticObjectType))
2568 return unity_switcher_accessible_new(object);
2569
2570 /* NUX classes */
2571
2572=== modified file 'plugins/unityshell/src/unityshell.cpp'
2573--- plugins/unityshell/src/unityshell.cpp 2012-12-18 01:21:03 +0000
2574+++ plugins/unityshell/src/unityshell.cpp 2012-12-19 14:00:32 +0000
2575@@ -32,6 +32,7 @@
2576 #include "Launcher.h"
2577 #include "LauncherIcon.h"
2578 #include "LauncherController.h"
2579+#include "SwitcherController.h"
2580 #include "PluginAdapter.h"
2581 #include "QuicklistManager.h"
2582 #include "StartupNotifyService.h"
2583@@ -41,6 +42,9 @@
2584 #include "unityshell.h"
2585 #include "BackgroundEffectHelper.h"
2586 #include "UnityGestureBroker.h"
2587+#include "UnityGestureTarget.h"
2588+#include "CompizX11MousePointer.h"
2589+#include "CompizGestureManipulatedWindow.h"
2590 #include "launcher/XdndCollectionWindowImp.h"
2591 #include "launcher/XdndManagerImp.h"
2592 #include "launcher/XdndStartStopNotifierImp.h"
2593@@ -74,6 +78,9 @@
2594 /* Set up vtable symbols */
2595 COMPIZ_PLUGIN_20090315(unityshell, unity::UnityPluginVTable);
2596
2597+namespace ug = unity::gestures;
2598+namespace ugi = unity::gestures::impl;
2599+
2600 namespace unity
2601 {
2602 using namespace launcher;
2603@@ -374,7 +381,7 @@
2604 auto init_plugins_cb = sigc::mem_fun(this, &UnityScreen::initPluginActions);
2605 sources_.Add(std::make_shared<glib::Idle>(init_plugins_cb, glib::Source::Priority::DEFAULT));
2606
2607- InitGesturesSupport();
2608+ InitGesturesSupport (screen->dpy (), screen);
2609
2610 CompString name(PKGDATADIR"/panel-shadow.png");
2611 CompString pname("unityshell");
2612@@ -1140,6 +1147,12 @@
2613 return ret;
2614 }
2615
2616+unity::gestures::GestureManipulatedWindow &
2617+UnityWindow::GestureWindow ()
2618+{
2619+ return *gesture_window_;
2620+}
2621+
2622 unsigned int
2623 UnityWindow::GetNoCoreInstanceMask ()
2624 {
2625@@ -1437,7 +1450,7 @@
2626
2627 if (switcher_controller_ && switcher_controller_->Visible())
2628 {
2629- unity::switcher::SwitcherView* view = switcher_controller_->GetView();
2630+ unity::switcher::View* view = switcher_controller_->GetView();
2631
2632 if (G_LIKELY(view))
2633 {
2634@@ -2980,7 +2993,7 @@
2635 launcher_controller_->UpdateSuperTapDuration(optionGetDashTapDuration());
2636 break;
2637 case UnityshellOptions::AltTabTimeout:
2638- switcher_controller_->detail_on_timeout = optionGetAltTabTimeout();
2639+ switcher_controller_->SetDetailOnTimeout(optionGetAltTabTimeout());
2640 case UnityshellOptions::AltTabBiasViewport:
2641 PluginAdapter::Default().bias_active_to_viewport = optionGetAltTabBiasViewport();
2642 break;
2643@@ -3117,8 +3130,12 @@
2644 launcher_controller_->UpdateSuperTapDuration(optionGetDashTapDuration());
2645 AddChild(launcher_controller_.get());
2646
2647- switcher_controller_ = std::make_shared<switcher::Controller>();
2648- AddChild(switcher_controller_.get());
2649+ switcher_controller_ = std::make_shared<switcher::Controller>([this]{
2650+ std::unique_ptr<switcher::ShellController> p(new switcher::ShellController());
2651+ introspectable_switcher_controller_ = p.get();
2652+ return p;
2653+ });
2654+ AddChild(introspectable_switcher_controller_);
2655
2656 LOG_INFO(logger) << "initLauncher-Launcher " << timer.ElapsedSeconds() << "s";
2657
2658@@ -3436,9 +3453,98 @@
2659 COMPIZ_RESIZE_OPTION_INITIATE_BUTTON));
2660 }
2661
2662-void UnityScreen::InitGesturesSupport()
2663-{
2664- std::unique_ptr<nux::GestureBroker> gesture_broker(new UnityGestureBroker);
2665+namespace
2666+{
2667+gestures::GestureManipulatedWindow &
2668+getGestureWindowFromCompWindow (CompWindow * &w)
2669+{
2670+ return UnityWindow::get (w)->GestureWindow ();
2671+}
2672+
2673+class GesturalWindowSwitcherActionInvokerGLib : public unity::GesturalWindowSwitcherActionInvoker
2674+{
2675+ public:
2676+
2677+ GesturalWindowSwitcherActionInvokerGLib (const std::function <bool ()> &func) :
2678+ callback_ (func)
2679+ {
2680+ }
2681+
2682+ void InvokeOnTimeout (int timeout)
2683+ {
2684+ source_.reset (new glib::Timeout (timeout, callback_));
2685+ }
2686+
2687+ void StopPendingInvocation ()
2688+ {
2689+ source_.reset ();
2690+ }
2691+
2692+ private:
2693+
2694+ std::function <bool ()> callback_;
2695+ unity::glib::Source::Ptr source_;
2696+};
2697+
2698+class GesturalWindowSwitcherActionInvokerFactoryGLib : public unity::GesturalWindowSwitcherActionInvokerFactory
2699+{
2700+ public:
2701+
2702+ GesturalWindowSwitcherActionInvoker::Ptr
2703+ CreateActionInvoker(const std::function<bool ()> &func) const
2704+ {
2705+ return std::make_shared <GesturalWindowSwitcherActionInvokerGLib> (func);
2706+ }
2707+};
2708+}
2709+
2710+void UnityScreen::InitGesturesSupport (Display *dpy, CompScreen *screen)
2711+{
2712+ typedef gestures::GestureManipulatedWindow GestureWindow;
2713+ typedef unity::AbstractInterfaceCollectionGenerator<GestureWindow, CompWindowList> WindowListGenerator;
2714+ typedef unity::AbstractInterfaceCollectionGenerator<GestureWindow, CompWindowVector> WindowVectorGenerator;
2715+ typedef unity::AbstractInterfaceGenerator<GestureWindow> GestureWindowGenerator;
2716+ typedef std::shared_ptr <GestureWindowGenerator> GestureWindowGeneratorPtr;
2717+
2718+ auto get_gesture_window_from_window =
2719+ [](CompWindow * const& w) -> GestureWindow &
2720+ {
2721+ return UnityWindow::get (w)->GestureWindow ();
2722+ };
2723+
2724+ gestures::MousePointer::Ptr pointer (
2725+ std::make_shared<gestures::impl::CompX11MousePointer>(dpy, screen));
2726+
2727+ UnityGestureBroker::GetWindowGeneratorFunc client_list_func
2728+ ([screen, &get_gesture_window_from_window]() -> GestureWindowGeneratorPtr
2729+ {
2730+ return std::make_shared <WindowVectorGenerator>(screen->clientList(),
2731+ get_gesture_window_from_window);
2732+ });
2733+ UnityGestureBroker::GetWindowGeneratorFunc all_windows_func
2734+ ([screen, &get_gesture_window_from_window]() -> GestureWindowGeneratorPtr
2735+ {
2736+ return std::make_shared <WindowListGenerator>(screen->windows(),
2737+ get_gesture_window_from_window);
2738+ });
2739+
2740+ GesturalWindowSwitcherActionInvokerFactoryGLib gesture_action_invoker_factory;
2741+ const unity::switcher::Controller::Ptr controller_interface (switcher_controller ());
2742+ auto gestural_window_switcher (std::make_shared <GesturalWindowSwitcherImpl> (controller_interface,
2743+ std::bind (&UnityScreen::SetUpAndShowSwitcher,
2744+ this,
2745+ switcher::ShowMode::CURRENT_VIEWPORT),
2746+ gesture_action_invoker_factory));
2747+
2748+ auto unity_gesture_target (std::make_shared <UnityGestureTarget> ());
2749+ auto gesture_target_factory (std::make_shared <ugi::WindowGestureTargetFactory> ());
2750+
2751+ std::unique_ptr<nux::GestureBroker> gesture_broker(new UnityGestureBroker (pointer,
2752+ client_list_func,
2753+ all_windows_func,
2754+ gestural_window_switcher,
2755+ unity_gesture_target,
2756+ gesture_target_factory));
2757 wt->GetWindowCompositor().SetGestureBroker(std::move(gesture_broker));
2758
2759 gestures_sub_launcher_.reset(new nux::GesturesSubscription);
2760@@ -3536,6 +3642,7 @@
2761 , PluginClassHandler<UnityWindow, CompWindow>(window)
2762 , window(window)
2763 , gWindow(GLWindow::get(window))
2764+ , gesture_window_ (new gestures::impl::CompGestureManipulatedWindow(window))
2765 {
2766 WindowInterface::setHandler(window);
2767 GLWindowInterface::setHandler(gWindow);
2768
2769=== modified file 'plugins/unityshell/src/unityshell.h'
2770--- plugins/unityshell/src/unityshell.h 2012-12-13 06:52:18 +0000
2771+++ plugins/unityshell/src/unityshell.h 2012-12-19 14:00:32 +0000
2772@@ -55,6 +55,7 @@
2773 #include "UnityshellPrivate.h"
2774 #include "UnityShowdesktopHandler.h"
2775 #include "ThumbnailGenerator.h"
2776+#include "WindowGestureTarget.h"
2777
2778 #include "compizminimizedwindowhandler.h"
2779 #include "BGHash.h"
2780@@ -244,7 +245,7 @@
2781
2782 void OnPanelStyleChanged();
2783
2784- void InitGesturesSupport();
2785+ void InitGesturesSupport (Display *dpy, CompScreen *screen);
2786
2787 void DrawTopPanelBackground();
2788 bool TopPanelBackgroundTextureNeedsUpdate() const;
2789@@ -267,6 +268,7 @@
2790 launcher::Controller::Ptr launcher_controller_;
2791 dash::Controller::Ptr dash_controller_;
2792 panel::Controller::Ptr panel_controller_;
2793+ debug::Introspectable *introspectable_switcher_controller_;
2794 switcher::Controller::Ptr switcher_controller_;
2795 hud::Controller::Ptr hud_controller_;
2796 shortcut::Controller::Ptr shortcut_controller_;
2797@@ -404,6 +406,7 @@
2798 //! Emited when CompWindowNotifyBeforeDestroy is received
2799 sigc::signal<void> being_destroyed;
2800
2801+ gestures::GestureManipulatedWindow & GestureWindow();
2802
2803 protected:
2804 std::string GetName() const;
2805@@ -483,6 +486,7 @@
2806 nux::Geometry close_button_geo_;
2807 bool middle_clicked_;
2808 glib::Source::UniquePtr focus_desktop_timeout_;
2809+ unity::gestures::GestureManipulatedWindow::Ptr gesture_window_;
2810
2811 friend class UnityScreen;
2812 };
2813
2814=== modified file 'tests/CMakeLists.txt'
2815--- tests/CMakeLists.txt 2012-12-17 19:35:34 +0000
2816+++ tests/CMakeLists.txt 2012-12-19 14:00:32 +0000
2817@@ -106,6 +106,7 @@
2818 # The actual test executable (xless) - do not put anything that requires X in here
2819 set (GTEST_XLESS_SOURCES
2820 test_main_xless.cpp
2821+ test_abstract_interface_generator.cpp
2822 test_launcher_model.cpp
2823 test_glib_object.cpp
2824 test_glib_object_utils.cpp
2825
2826=== added file 'tests/MockSwitcherController.h'
2827--- tests/MockSwitcherController.h 1970-01-01 00:00:00 +0000
2828+++ tests/MockSwitcherController.h 2012-12-19 14:00:32 +0000
2829@@ -0,0 +1,62 @@
2830+/*
2831+ * Copyright 2012 Canonical Ltd.
2832+ *
2833+ * This program is free software: you can redistribute it and/or modify it
2834+ * under the terms of the GNU General Public License version 3, as published
2835+ * by the Free Software Foundation.
2836+ *
2837+ * This program is distributed in the hope that it will be useful, but
2838+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2839+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
2840+ * PURPOSE. See the GNU General Public License for more details.
2841+ *
2842+ * You should have received a copy of the GNU General Public License
2843+ * version 3 along with this program. If not, see
2844+ * <http://www.gnu.org/licenses/>
2845+ *
2846+ * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
2847+ *
2848+ */
2849+#ifndef _UNITY_MOCK_SWITCHER_CONTROLLER_H
2850+#define _UNITY_MOCK_SWITCHER_CONTROLLER_H
2851+
2852+#include <memory>
2853+
2854+#include <gmock/gmock.h>
2855+
2856+#include <SwitcherController.h>
2857+#include <SwitcherView.h>
2858+#include <AbstractLauncherIcon.h>
2859+
2860+namespace unity
2861+{
2862+namespace switcher
2863+{
2864+class MockSwitcherController : public Controller::Impl
2865+{
2866+public:
2867+ typedef std::shared_ptr <MockSwitcherController> Ptr;
2868+
2869+ MOCK_METHOD3(Show, void(ShowMode, SortMode, std::vector<launcher::AbstractLauncherIcon::Ptr>));
2870+ MOCK_METHOD1(Hide, void(bool));
2871+ MOCK_METHOD0(Visible, bool());
2872+ MOCK_METHOD0(Next, void());
2873+ MOCK_METHOD0(Prev, void());
2874+ MOCK_METHOD1(Select, void(int));
2875+ MOCK_METHOD0(GetView, unity::switcher::View * ());
2876+ MOCK_CONST_METHOD1(CanShowSwitcher, bool(const std::vector<launcher::AbstractLauncherIcon::Ptr> &));
2877+ MOCK_METHOD0(NextDetail, void());
2878+ MOCK_METHOD0(PrevDetail, void());
2879+ MOCK_METHOD2(SetDetail, void(bool, unsigned int));
2880+ MOCK_METHOD0(SelectFirstItem, void());
2881+ MOCK_METHOD2(SetWorkspace, void(nux::Geometry, int));
2882+ MOCK_METHOD0(ExternalRenderTargets, unity::ui::LayoutWindow::Vector ());
2883+ MOCK_CONST_METHOD0(GetSwitcherInputWindowId, guint());
2884+ MOCK_CONST_METHOD0(IsShowDesktopDisabled, bool());
2885+ MOCK_METHOD1(SetShowDesktopDisabled, void(bool));
2886+ MOCK_CONST_METHOD0(StartIndex, int());
2887+};
2888+}
2889+}
2890+
2891+#endif
2892
2893=== added file 'tests/MockSwitcherController.h.moved'
2894--- tests/MockSwitcherController.h.moved 1970-01-01 00:00:00 +0000
2895+++ tests/MockSwitcherController.h.moved 2012-12-19 14:00:32 +0000
2896@@ -0,0 +1,64 @@
2897+/*
2898+ * Copyright 2012 Canonical Ltd.
2899+ *
2900+ * This program is free software: you can redistribute it and/or modify it
2901+ * under the terms of the GNU General Public License version 3, as published
2902+ * by the Free Software Foundation.
2903+ *
2904+ * This program is distributed in the hope that it will be useful, but
2905+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2906+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
2907+ * PURPOSE. See the GNU General Public License for more details.
2908+ *
2909+ * You should have received a copy of the GNU General Public License
2910+ * version 3 along with this program. If not, see
2911+ * <http://www.gnu.org/licenses/>
2912+ *
2913+ * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
2914+ *
2915+ */
2916+#ifndef _UNITY_MOCK_SWITCHER_CONTROLLER_H
2917+#define _UNITY_MOCK_SWITCHER_CONTROLLER_H
2918+
2919+#include <memory>
2920+
2921+#include <gmock/gmock.h>
2922+
2923+#include <time.h>
2924+
2925+#include <SwitcherController.h>
2926+#include <SwitcherView.h>
2927+#include <AbstractLauncherIcon.h>
2928+
2929+namespace unity
2930+{
2931+namespace switcher
2932+{
2933+class MockSwitcherController : public ControllerInterface
2934+{
2935+public:
2936+ typedef std::shared_ptr <MockSwitcherController> Ptr;
2937+
2938+ MOCK_METHOD3(Show, void(ShowMode, SortMode, std::vector<launcher::AbstractLauncherIcon::Ptr>));
2939+ MOCK_METHOD1(Hide, void(bool));
2940+ MOCK_METHOD0(Visible, bool());
2941+ MOCK_METHOD0(Next, void());
2942+ MOCK_METHOD0(Prev, void());
2943+ MOCK_METHOD1(Select, void(int));
2944+ MOCK_METHOD0(GetView, unity::switcher::SwitcherViewInterface * ());
2945+ MOCK_CONST_METHOD1(CanShowSwitcher, bool(const std::vector<launcher::AbstractLauncherIcon::Ptr> &));
2946+ MOCK_METHOD0(NextDetail, void());
2947+ MOCK_METHOD0(PrevDetail, void());
2948+ MOCK_METHOD2(SetDetail, void(bool, unsigned int));
2949+ MOCK_METHOD0(SelectFirstItem, void());
2950+ MOCK_METHOD2(SetWorkspace, void(nux::Geometry, int));
2951+ MOCK_METHOD0(ExternalRenderTargets, unity::ui::LayoutWindow::Vector ());
2952+ MOCK_CONST_METHOD0(GetSwitcherInputWindowId, guint());
2953+ MOCK_CONST_METHOD0(IsShowDesktopDisabled, bool());
2954+ MOCK_METHOD1(SetShowDesktopDisabled, void(bool));
2955+ MOCK_CONST_METHOD0(StartIndex, int());
2956+};
2957+}
2958+}
2959+
2960+#endif
2961
2962=== added file 'tests/MockSwitcherView.h'
2963--- tests/MockSwitcherView.h 1970-01-01 00:00:00 +0000
2964+++ tests/MockSwitcherView.h 2012-12-19 14:00:32 +0000
2965@@ -0,0 +1,56 @@
2966+/*
2967+ * Copyright 2012 Canonical Ltd.
2968+ *
2969+ * This program is free software: you can redistribute it and/or modify it
2970+ * under the terms of the GNU General Public License version 3, as published
2971+ * by the Free Software Foundation.
2972+ *
2973+ * This program is distributed in the hope that it will be useful, but
2974+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2975+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
2976+ * PURPOSE. See the GNU General Public License for more details.
2977+ *
2978+ * You should have received a copy of the GNU General Public License
2979+ * version 3 along with this program. If not, see
2980+ * <http://www.gnu.org/licenses/>
2981+ *
2982+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
2983+ *
2984+ */
2985+#ifndef _UNITY_MOCK_SWITCHER_VIEW_H
2986+#define _UNITY_MOCK_SWITCHER_VIEW_H
2987+
2988+#include <gtest/gtest.h>
2989+#include <gmock/gmock.h>
2990+
2991+#include <memory>
2992+
2993+#include <SwitcherView.h>
2994+#include <AbstractLauncherIcon.h>
2995+
2996+namespace unity
2997+{
2998+namespace switcher
2999+{
3000+class MockSwitcherView :
3001+ public View::Impl
3002+{
3003+ public:
3004+
3005+ MOCK_METHOD0(ExternalTargets, ui::LayoutWindow::Vector ());
3006+ MOCK_METHOD1(SetModel, void (SwitcherModel::Ptr));
3007+ MOCK_METHOD0(GetModel, SwitcherModel::Ptr ());
3008+ MOCK_METHOD3(ConnectToMouseEvents,
3009+ View::MouseEventConnections (const View::MouseButtonCallback &mouse_down_callback,
3010+ const View::MouseButtonCallback &mouse_up_callback,
3011+ const View::MouseDragCallback &mouse_drag_callback));
3012+ MOCK_METHOD0(QueueDraw, void ());
3013+ MOCK_CONST_METHOD0(GetAbsoluteGeometry, nux::Geometry ());
3014+ MOCK_METHOD2(IconIndexAt, int (int, int));
3015+ MOCK_METHOD1(SetBackgroundColor, void(nux::Color const&));
3016+ MOCK_METHOD1(SetupBackground, void(bool));
3017+};
3018+}
3019+}
3020+
3021+#endif
3022
3023=== added file 'tests/MockSwitcherView.h.moved'
3024--- tests/MockSwitcherView.h.moved 1970-01-01 00:00:00 +0000
3025+++ tests/MockSwitcherView.h.moved 2012-12-19 14:00:32 +0000
3026@@ -0,0 +1,56 @@
3027+/*
3028+ * Copyright 2012 Canonical Ltd.
3029+ *
3030+ * This program is free software: you can redistribute it and/or modify it
3031+ * under the terms of the GNU General Public License version 3, as published
3032+ * by the Free Software Foundation.
3033+ *
3034+ * This program is distributed in the hope that it will be useful, but
3035+ * WITHOUT ANY WARRANTY; without even the implied warranties of
3036+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
3037+ * PURPOSE. See the GNU General Public License for more details.
3038+ *
3039+ * You should have received a copy of the GNU General Public License
3040+ * version 3 along with this program. If not, see
3041+ * <http://www.gnu.org/licenses/>
3042+ *
3043+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
3044+ *
3045+ */
3046+#ifndef _UNITY_MOCK_SWITCHER_VIEW_H
3047+#define _UNITY_MOCK_SWITCHER_VIEW_H
3048+
3049+#include <gtest/gtest.h>
3050+#include <gmock/gmock.h>
3051+
3052+#include <memory>
3053+
3054+#include <time.h>
3055+
3056+#include <SwitcherController.h>
3057+#include <AbstractLauncherIcon.h>
3058+
3059+namespace unity
3060+{
3061+namespace switcher
3062+{
3063+class MockSwitcherView :
3064+ public SwitcherViewInterface
3065+{
3066+ public:
3067+
3068+ MOCK_METHOD0 (ExternalTargets, ui::LayoutWindow::Vector ());
3069+ MOCK_METHOD1 (SetModel, void (SwitcherModel::Ptr));
3070+ MOCK_METHOD0 (GetModel, SwitcherModel::Ptr ());
3071+ MOCK_METHOD3 (ConnectToMouseEvents,
3072+ SwitcherViewInterface::MouseEventConnections (const SwitcherViewInterface::MouseButtonCallback &mouse_down_callback,
3073+ const SwitcherViewInterface::MouseButtonCallback &mouse_up_callback,
3074+ const SwitcherViewInterface::MouseDragCallback &mouse_drag_callback));
3075+ MOCK_METHOD0 (QueueDraw, void ());
3076+ MOCK_CONST_METHOD0 (GetAbsoluteGeometry, nux::Geometry ());
3077+ MOCK_METHOD2 (IconIndexAt, int (int, int));
3078+};
3079+}
3080+}
3081+
3082+#endif
3083
3084=== modified file 'tests/MockWindowManager.h'
3085--- tests/MockWindowManager.h 2012-12-04 09:04:06 +0000
3086+++ tests/MockWindowManager.h 2012-12-19 14:00:32 +0000
3087@@ -99,6 +99,10 @@
3088 MOCK_CONST_METHOD1(GetWindowName, std::string(Window));
3089
3090 MOCK_METHOD1(AddProperties, void(GVariantBuilder*));
3091+
3092+ MOCK_CONST_METHOD0 (GetCurrentViewport, nux::Point ());
3093+ MOCK_CONST_METHOD0 (GetViewportHSize, int ());
3094+ MOCK_CONST_METHOD0 (GetViewportVSize, int ());
3095 };
3096 }
3097
3098
3099=== added file 'tests/StubSwitcherController.h'
3100--- tests/StubSwitcherController.h 1970-01-01 00:00:00 +0000
3101+++ tests/StubSwitcherController.h 2012-12-19 14:00:32 +0000
3102@@ -0,0 +1,155 @@
3103+/*
3104+ * Copyright 2012 Canonical Ltd.
3105+ *
3106+ * This program is free software: you can redistribute it and/or modify it
3107+ * under the terms of the GNU General Public License version 3, as published
3108+ * by the Free Software Foundation.
3109+ *
3110+ * This program is distributed in the hope that it will be useful, but
3111+ * WITHOUT ANY WARRANTY; without even the implied warranties of
3112+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
3113+ * PURPOSE. See the GNU General Public License for more details.
3114+ *
3115+ * You should have received a copy of the GNU General Public License
3116+ * version 3 along with this program. If not, see
3117+ * <http://www.gnu.org/licenses/>
3118+ *
3119+ * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
3120+ *
3121+ */
3122+#ifndef _UNITY_STUB_SWITCHER_CONTROLLER_H
3123+#define _UNITY_STUB_SWITCHER_CONTROLLER_H
3124+
3125+#include <memory>
3126+
3127+#include <gmock/gmock.h>
3128+
3129+#include <SwitcherController.h>
3130+#include <SwitcherView.h>
3131+#include <AbstractLauncherIcon.h>
3132+
3133+namespace unity
3134+{
3135+namespace switcher
3136+{
3137+class StubSwitcherController : public ShellController
3138+{
3139+ public:
3140+ typedef std::shared_ptr <StubSwitcherController> Ptr;
3141+
3142+ StubSwitcherController()
3143+ : ShellController()
3144+ , window_constructed_(false)
3145+ , view_constructed_(false)
3146+ , view_shown_(false)
3147+ , detail_timeout_reached_(false)
3148+ , mock_view_ (nullptr)
3149+ {
3150+ Reset ();
3151+ };
3152+
3153+ StubSwitcherController(unsigned int load_timeout)
3154+ : ShellController(load_timeout)
3155+ , window_constructed_(false)
3156+ , view_constructed_(false)
3157+ , view_shown_(false)
3158+ , detail_timeout_reached_(false)
3159+ , mock_view_ (nullptr)
3160+ {
3161+ Reset ();
3162+ };
3163+
3164+ void SetView (View *view)
3165+ {
3166+ mock_view_ = view;
3167+ }
3168+
3169+ View * GetView ()
3170+ {
3171+ return mock_view_;
3172+ }
3173+
3174+ virtual void ConstructWindow()
3175+ {
3176+ window_constructed_ = true;
3177+ }
3178+
3179+ virtual void ConstructView()
3180+ {
3181+ view_constructed_ = true;
3182+ }
3183+
3184+ virtual void ShowView()
3185+ {
3186+ view_shown_ = true;
3187+ }
3188+
3189+ virtual bool OnDetailTimer()
3190+ {
3191+ detail_timeout_reached_ = true;
3192+ clock_gettime(CLOCK_MONOTONIC, &detail_timespec_);
3193+ return false;
3194+ }
3195+
3196+ void Reset()
3197+ {
3198+ is_visible_ = false;
3199+ prev_count_ = 0;
3200+ next_count_ = 0;
3201+ index_selected_ = -1;
3202+ }
3203+
3204+ void Next()
3205+ {
3206+ ++next_count_;
3207+ }
3208+
3209+ void Prev()
3210+ {
3211+ ++prev_count_;
3212+ }
3213+
3214+ void Select(int index)
3215+ {
3216+ index_selected_ = index;
3217+ }
3218+
3219+ bool Visible()
3220+ {
3221+ return is_visible_;
3222+ }
3223+
3224+ void Hide(bool accept_state = true)
3225+ {
3226+ is_visible_ = false;
3227+ }
3228+
3229+ unsigned int GetConstructTimeout() const
3230+ {
3231+ return construct_timeout_;
3232+ }
3233+
3234+ void FakeSelectionChange()
3235+ {
3236+ unity::launcher::AbstractLauncherIcon::Ptr icon;
3237+ OnModelSelectionChanged(icon);
3238+ }
3239+
3240+ bool window_constructed_;
3241+ bool view_constructed_;
3242+ bool view_shown_;
3243+ bool detail_timeout_reached_;
3244+ struct timespec detail_timespec_;
3245+
3246+ bool is_visible_;
3247+ int prev_count_;
3248+ int next_count_;
3249+ int index_selected_;
3250+
3251+ private:
3252+ View *mock_view_;
3253+};
3254+}
3255+}
3256+
3257+#endif
3258
3259=== added file 'tests/StubSwitcherController.h.moved'
3260--- tests/StubSwitcherController.h.moved 1970-01-01 00:00:00 +0000
3261+++ tests/StubSwitcherController.h.moved 2012-12-19 14:00:32 +0000
3262@@ -0,0 +1,157 @@
3263+/*
3264+ * Copyright 2012 Canonical Ltd.
3265+ *
3266+ * This program is free software: you can redistribute it and/or modify it
3267+ * under the terms of the GNU General Public License version 3, as published
3268+ * by the Free Software Foundation.
3269+ *
3270+ * This program is distributed in the hope that it will be useful, but
3271+ * WITHOUT ANY WARRANTY; without even the implied warranties of
3272+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
3273+ * PURPOSE. See the GNU General Public License for more details.
3274+ *
3275+ * You should have received a copy of the GNU General Public License
3276+ * version 3 along with this program. If not, see
3277+ * <http://www.gnu.org/licenses/>
3278+ *
3279+ * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
3280+ *
3281+ */
3282+#ifndef _UNITY_STUB_SWITCHER_CONTROLLER_H
3283+#define _UNITY_STUB_SWITCHER_CONTROLLER_H
3284+
3285+#include <memory>
3286+
3287+#include <gmock/gmock.h>
3288+
3289+#include <time.h>
3290+
3291+#include <SwitcherController.h>
3292+#include <SwitcherView.h>
3293+#include <AbstractLauncherIcon.h>
3294+
3295+namespace unity
3296+{
3297+namespace switcher
3298+{
3299+class StubSwitcherController : public Controller
3300+{
3301+ public:
3302+ typedef std::shared_ptr <StubSwitcherController> Ptr;
3303+
3304+ StubSwitcherController()
3305+ : Controller()
3306+ , window_constructed_(false)
3307+ , view_constructed_(false)
3308+ , view_shown_(false)
3309+ , detail_timeout_reached_(false)
3310+ , mock_view_ (nullptr)
3311+ {
3312+ Reset ();
3313+ };
3314+
3315+ StubSwitcherController(unsigned int load_timeout)
3316+ : Controller(load_timeout)
3317+ , window_constructed_(false)
3318+ , view_constructed_(false)
3319+ , view_shown_(false)
3320+ , detail_timeout_reached_(false)
3321+ , mock_view_ (nullptr)
3322+ {
3323+ Reset ();
3324+ };
3325+
3326+ void SetView (SwitcherViewInterface *view)
3327+ {
3328+ mock_view_ = view;
3329+ }
3330+
3331+ SwitcherViewInterface * GetView ()
3332+ {
3333+ return mock_view_;
3334+ }
3335+
3336+ virtual void ConstructWindow()
3337+ {
3338+ window_constructed_ = true;
3339+ }
3340+
3341+ virtual void ConstructView()
3342+ {
3343+ view_constructed_ = true;
3344+ }
3345+
3346+ virtual void ShowView()
3347+ {
3348+ view_shown_ = true;
3349+ }
3350+
3351+ virtual bool OnDetailTimer()
3352+ {
3353+ detail_timeout_reached_ = true;
3354+ clock_gettime(CLOCK_MONOTONIC, &detail_timespec_);
3355+ return false;
3356+ }
3357+
3358+ void Reset()
3359+ {
3360+ is_visible_ = false;
3361+ prev_count_ = 0;
3362+ next_count_ = 0;
3363+ index_selected_ = -1;
3364+ }
3365+
3366+ void Next()
3367+ {
3368+ ++next_count_;
3369+ }
3370+
3371+ void Prev()
3372+ {
3373+ ++prev_count_;
3374+ }
3375+
3376+ void Select(int index)
3377+ {
3378+ index_selected_ = index;
3379+ }
3380+
3381+ bool Visible()
3382+ {
3383+ return is_visible_;
3384+ }
3385+
3386+ void Hide(bool accept_state = true)
3387+ {
3388+ is_visible_ = false;
3389+ }
3390+
3391+ unsigned int GetConstructTimeout() const
3392+ {
3393+ return construct_timeout_;
3394+ }
3395+
3396+ void FakeSelectionChange()
3397+ {
3398+ unity::launcher::AbstractLauncherIcon::Ptr icon;
3399+ OnModelSelectionChanged(icon);
3400+ }
3401+
3402+ bool window_constructed_;
3403+ bool view_constructed_;
3404+ bool view_shown_;
3405+ bool detail_timeout_reached_;
3406+ struct timespec detail_timespec_;
3407+
3408+ bool is_visible_;
3409+ int prev_count_;
3410+ int next_count_;
3411+ int index_selected_;
3412+
3413+ private:
3414+ SwitcherViewInterface *mock_view_;
3415+};
3416+}
3417+}
3418+
3419+#endif
3420
3421=== modified file 'tests/test-gestures/CMakeLists.txt'
3422--- tests/test-gestures/CMakeLists.txt 2012-12-17 15:26:26 +0000
3423+++ tests/test-gestures/CMakeLists.txt 2012-12-19 14:00:32 +0000
3424@@ -1,57 +1,6 @@
3425 if (GTEST_SRC_DIR)
3426 set(UNITY_SRC ${CMAKE_SOURCE_DIR}/plugins/unityshell/src)
3427-
3428- add_custom_command(OUTPUT CompoundGestureRecognizer.cpp
3429- CompoundGestureRecognizer.h
3430- GesturalWindowSwitcher.cpp
3431- GesturalWindowSwitcher.h
3432- UnityGestureBroker.cpp
3433- UnityGestureBroker.h
3434- UBusMessages.h
3435- WindowGestureTarget.h
3436- WindowGestureTarget.cpp
3437-
3438- COMMAND cp ${UNITY_SRC}/CompoundGestureRecognizer.cpp
3439- ${UNITY_SRC}/CompoundGestureRecognizer.h
3440- ${CMAKE_CURRENT_BINARY_DIR}
3441-
3442- COMMAND sed -f ${CMAKE_CURRENT_SOURCE_DIR}/sed_script_broker
3443- ${UNITY_SRC}/UnityGestureBroker.cpp >
3444- ${CMAKE_CURRENT_BINARY_DIR}/UnityGestureBroker.cpp
3445-
3446- COMMAND sed -f ${CMAKE_CURRENT_SOURCE_DIR}/sed_script_broker
3447- ${UNITY_SRC}/UnityGestureBroker.h >
3448- ${CMAKE_CURRENT_BINARY_DIR}/UnityGestureBroker.h
3449-
3450- COMMAND sed -f ${CMAKE_CURRENT_SOURCE_DIR}/sed_script_gesture
3451- ${UNITY_SRC}/WindowGestureTarget.h >
3452- ${CMAKE_CURRENT_BINARY_DIR}/WindowGestureTarget.h
3453-
3454- COMMAND sed -f ${CMAKE_CURRENT_SOURCE_DIR}/sed_script_gesture
3455- ${UNITY_SRC}/WindowGestureTarget.cpp >
3456- ${CMAKE_CURRENT_BINARY_DIR}/WindowGestureTarget.cpp
3457-
3458- COMMAND sed -f ${CMAKE_CURRENT_SOURCE_DIR}/sed_script_switcher
3459- ${UNITY_SRC}/GesturalWindowSwitcher.cpp >
3460- ${CMAKE_CURRENT_BINARY_DIR}/GesturalWindowSwitcher.cpp
3461-
3462- COMMAND sed -f ${CMAKE_CURRENT_SOURCE_DIR}/sed_script_switcher
3463- ${UNITY_SRC}/GesturalWindowSwitcher.h >
3464- ${CMAKE_CURRENT_BINARY_DIR}/GesturalWindowSwitcher.h
3465-
3466- DEPENDS ${UNITY_SRC}/CompoundGestureRecognizer.cpp
3467- ${UNITY_SRC}/CompoundGestureRecognizer.h
3468- ${UNITY_SRC}/GesturalWindowSwitcher.cpp
3469- ${UNITY_SRC}/GesturalWindowSwitcher.h
3470- ${UNITY_SRC}/UnityGestureBroker.cpp
3471- ${UNITY_SRC}/UnityGestureBroker.h
3472- ${CMAKE_SOURCE_DIR}/unity-shared/UBusMessages.h
3473- ${UNITY_SRC}/WindowGestureTarget.h
3474- ${UNITY_SRC}/WindowGestureTarget.cpp
3475- sed_script_broker
3476- sed_script_gesture
3477-
3478- COMMENT "Copying and modifying sources under test.")
3479+ set(UNITY_SHARED_SRC ${CMAKE_SOURCE_DIR}/unity-shared)
3480
3481 # Clean-up includes and definitions made in ../CmakeLists.txt
3482 remove_definitions(${CFLAGS})
3483@@ -59,38 +8,35 @@
3484
3485 include_directories (${CMAKE_SOURCE_DIR})
3486 include_directories (${CMAKE_SOURCE_DIR}/unity-shared)
3487+ include_directories (${CMAKE_SOURCE_DIR}/gestures)
3488
3489 # And make our own
3490 pkg_check_modules (TEST_GESTURES_DEPS REQUIRED QUIET "${UNITY_PLUGIN_DEPS}")
3491 set(TEST_GESTURES_CFLAGS
3492 "-g"
3493 "-I${CMAKE_CURRENT_SOURCE_DIR}"
3494+ "-I${CMAKE_SOURCE_DIR}/tests"
3495 "-I${CMAKE_CURRENT_BINARY_DIR}"
3496+ "-I${CMAKE_SOURCE_DIR}/unity-shared"
3497+ "-I${CMAKE_SOURCE_DIR}/launcher"
3498+ "-I${CMAKE_SOURCE_DIR}"
3499+ "-I${CMAKE_BINARY_DIR}"
3500+ "-I${CMAKE_SOURCE_DIR}/gestures"
3501 ${TEST_GESTURES_DEPS_CFLAGS}
3502 )
3503 add_definitions(${TEST_GESTURES_CFLAGS})
3504
3505 pkg_check_modules (COMPIZ REQUIRED QUIET compiz)
3506- link_directories (${COMPIZ_LIBDIR})
3507+ link_directories (${COMPIZ_LIBDIR} ${CMAKE_BINARY_DIR}/unity-shared ${CMAKE_BINARY_DIR}/gestures)
3508
3509 add_executable(test-gestures
3510- CompoundGestureRecognizer.cpp
3511- CompoundGestureRecognizer.h
3512- GesturalWindowSwitcher.cpp
3513- GesturalWindowSwitcher.h
3514 test_compound_gesture_recognizer.cpp
3515 test_gestural_window_switcher.cpp
3516 test_gestures_main.cpp
3517 test_gesture_broker.cpp
3518 test_window_gesture_target.cpp
3519- X11_mock.cpp
3520- UnityGestureBroker.cpp
3521- WindowGestureTarget.cpp
3522- PluginAdapterMock.cpp
3523- ubus-server-mock.cpp
3524- UnityGestureTargetMock.h
3525 )
3526- target_link_libraries(test-gestures gtest ${TEST_GESTURES_DEPS_LIBRARIES} compiz_core)
3527+ target_link_libraries(test-gestures gtest gmock gmock_main unity_mock_window_manager ${TEST_GESTURES_DEPS_LIBRARIES} compiz_core unity-shared gestures-lib switcher-lib launcher-lib)
3528 add_test(UnityGTestGestures test-gestures)
3529 add_dependencies(test-gestures gtest unity-core-${UNITY_API_VERSION})
3530
3531
3532=== modified file 'tests/test-gestures/FakeGestureEvent.h'
3533--- tests/test-gestures/FakeGestureEvent.h 2012-07-27 20:20:29 +0000
3534+++ tests/test-gestures/FakeGestureEvent.h 2012-12-19 14:00:32 +0000
3535@@ -4,6 +4,12 @@
3536 #include <NuxGraphics/GestureEvent.h>
3537 #include <map>
3538
3539+#define CompWindowStateMaximizedVertMask (1 << 1)
3540+#define CompWindowStateMaximizedHorzMask (1 << 2)
3541+#define CompWindowStateHiddenMask (1 << 3)
3542+#define CompWindowActionMoveMask (1 << 4)
3543+#define MAXIMIZE_STATE (CompWindowStateMaximizedVertMask | CompWindowStateMaximizedHorzMask)
3544+
3545 namespace nux {
3546 class FakeGestureEvent
3547 {
3548
3549=== modified file 'tests/test-gestures/GesturalWindowSwitcherMock.h'
3550--- tests/test-gestures/GesturalWindowSwitcherMock.h 2012-08-14 12:48:21 +0000
3551+++ tests/test-gestures/GesturalWindowSwitcherMock.h 2012-12-19 14:00:32 +0000
3552@@ -19,22 +19,29 @@
3553 #ifndef GESTURAL_WINDOW_SWITCHER_MOCK_H
3554 #define GESTURAL_WINDOW_SWITCHER_MOCK_H
3555
3556+#include <gtest/gtest.h>
3557+#include <gmock/gmock.h>
3558+
3559 #include <Nux/Gesture.h>
3560+#include <GesturalWindowSwitcher.h>
3561+
3562+using ::testing::_;
3563+using ::testing::Return;
3564
3565 namespace unity
3566 {
3567
3568-class GesturalWindowSwitcherMock : public nux::GestureTarget
3569+class GesturalWindowSwitcherMock : public GesturalWindowSwitcherInterface
3570 {
3571 public:
3572- GesturalWindowSwitcherMock() {}
3573-
3574- virtual nux::GestureDeliveryRequest GestureEvent(const nux::GestureEvent &event)
3575+
3576+ MOCK_METHOD1(GestureEvent, nux::GestureDeliveryRequest(nux::GestureEvent const &));
3577+
3578+ GesturalWindowSwitcherMock ()
3579 {
3580- return nux::GestureDeliveryRequest::NONE;
3581+ ON_CALL(*this, GestureEvent (_)).WillByDefault (Return(nux::GestureDeliveryRequest::NONE));
3582 }
3583 };
3584-typedef std::shared_ptr<GesturalWindowSwitcherMock> ShPtGesturalWindowSwitcherMock;
3585
3586 } //namespace unity
3587 #endif // GESTURAL_WINDOW_SWITCHER_MOCK_H
3588
3589=== added file 'tests/test-gestures/MockGestureManipulatedWindow.h'
3590--- tests/test-gestures/MockGestureManipulatedWindow.h 1970-01-01 00:00:00 +0000
3591+++ tests/test-gestures/MockGestureManipulatedWindow.h 2012-12-19 14:00:32 +0000
3592@@ -0,0 +1,57 @@
3593+/*
3594+ * Copyright 2012 Canonical Ltd.
3595+ *
3596+ * This program is free software: you can redistribute it and/or modify it
3597+ * under the terms of the GNU General Public License version 3, as published
3598+ * by the Free Software Foundation.
3599+ *
3600+ * This program is distributed in the hope that it will be useful, but
3601+ * WITHOUT ANY WARRANTY; without even the implied warranties of
3602+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
3603+ * PURPOSE. See the GNU General Public License for more details.
3604+ *
3605+ * You should have received a copy of the GNU General Public License
3606+ * version 3 along with this program. If not, see
3607+ * <http://www.gnu.org/licenses/>
3608+ *
3609+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
3610+ *
3611+ */
3612+#ifndef _UNITY_MOCK_GESTURE_MANIPULATED_WINDOW_H
3613+#define _UNITY_MOCK_GESTURE_MANIPULATED_WINDOW_H
3614+
3615+#include <memory>
3616+
3617+#include <gtest/gtest.h>
3618+#include <gmock/gmock.h>
3619+#include <WindowGestureTarget.h>
3620+
3621+using ::testing::AtLeast;
3622+
3623+class MockGestureManipulatedWindow :
3624+ public unity::gestures::GestureManipulatedWindow
3625+{
3626+ public:
3627+
3628+ MockGestureManipulatedWindow()
3629+ {
3630+ EXPECT_CALL (*this, GetIdentifier()).Times(AtLeast(0));
3631+ }
3632+
3633+ typedef std::shared_ptr <MockGestureManipulatedWindow> Ptr;
3634+
3635+ MOCK_METHOD1 (MoveByDelta, void (const nux::Point &));
3636+ MOCK_METHOD0 (MaximizeVerticallyAndHorizontally, void ());
3637+ MOCK_METHOD0 (Demaximize, bool ());
3638+ MOCK_METHOD0 (Grab, void ());
3639+ MOCK_METHOD0 (Ungrab, void ());
3640+ MOCK_METHOD1 (ShowGrabHandles, void (HideMode));
3641+ MOCK_CONST_METHOD0 (Geometry, const compiz::window::Geometry & ());
3642+ MOCK_CONST_METHOD0 (IsVerticallyMaximized, bool ());
3643+ MOCK_CONST_METHOD0 (IsHorizontallyMaximized, bool ());
3644+ MOCK_CONST_METHOD0 (IsMovable, bool ());
3645+ MOCK_CONST_METHOD0 (Visible, bool ());
3646+ MOCK_CONST_METHOD0 (GetIdentifier, unsigned long ());
3647+};
3648+
3649+#endif
3650
3651=== added file 'tests/test-gestures/MockGestureTarget.h'
3652--- tests/test-gestures/MockGestureTarget.h 1970-01-01 00:00:00 +0000
3653+++ tests/test-gestures/MockGestureTarget.h 2012-12-19 14:00:32 +0000
3654@@ -0,0 +1,15 @@
3655+#ifndef UNITY_MOCK_GESTURE_TARGET_H
3656+#define UNITY_MOCK_GESTURE_TARGET_H
3657+
3658+#include <memory>
3659+#include <Nux/Gesture.h>
3660+
3661+class MockGestureTarget : public nux::GestureTarget
3662+{
3663+ public:
3664+
3665+ MOCK_METHOD1 (GestureEvent, nux::GestureDeliveryRequest (const nux::GestureEvent &event));
3666+ MOCK_CONST_METHOD1 (Equals, bool (const nux::GestureTarget &other));
3667+};
3668+
3669+#endif // UNITY_MOCK_GESTURE_TARGET_H
3670
3671=== added file 'tests/test-gestures/MockMousePointer.h'
3672--- tests/test-gestures/MockMousePointer.h 1970-01-01 00:00:00 +0000
3673+++ tests/test-gestures/MockMousePointer.h 2012-12-19 14:00:32 +0000
3674@@ -0,0 +1,17 @@
3675+#ifndef _UNITY_MOCK_MOUSE_POINTER_H
3676+#define _UNITY_MOCK_MOUSE_POINTER_H
3677+
3678+#include <WindowGestureTarget.h>
3679+
3680+class MockMousePointer :
3681+ public unity::gestures::MousePointer
3682+{
3683+ public:
3684+
3685+ MOCK_METHOD0 (MakeGrabbedForMovement, void ());
3686+ MOCK_METHOD0 (MakeUngrabbedForMovement, void ());
3687+ MOCK_METHOD1 (WarpPositionByDelta, void (const nux::Point &));
3688+ MOCK_CONST_METHOD2 (RestrainDeltaToScreenSize, void (int &, int &));
3689+};
3690+
3691+#endif
3692
3693=== removed file 'tests/test-gestures/NuxMock.h'
3694--- tests/test-gestures/NuxMock.h 2012-07-27 20:24:01 +0000
3695+++ tests/test-gestures/NuxMock.h 1970-01-01 00:00:00 +0000
3696@@ -1,27 +0,0 @@
3697-#ifndef NUX_MOCK_H
3698-#define NUX_MOCK_H
3699-
3700-#include <Nux/Nux.h>
3701-
3702-namespace nux
3703-{
3704-
3705-class InputAreaMock : public Object
3706-{
3707- public:
3708- void GestureEvent(const GestureEvent &event)
3709- {
3710- }
3711-};
3712-
3713-class ViewMock : public InputAreaMock
3714-{
3715- public:
3716- sigc::signal<void, int, int, unsigned long, unsigned long> mouse_down;
3717- sigc::signal<void, int, int, unsigned long, unsigned long> mouse_up;
3718- sigc::signal<void, int, int, int, int, unsigned long, unsigned long> mouse_drag;
3719-};
3720-
3721-} // namespace nux
3722-
3723-#endif // NUX_MOCK_H
3724
3725=== removed file 'tests/test-gestures/PluginAdapterMock.cpp'
3726--- tests/test-gestures/PluginAdapterMock.cpp 2012-10-11 01:44:15 +0000
3727+++ tests/test-gestures/PluginAdapterMock.cpp 1970-01-01 00:00:00 +0000
3728@@ -1,33 +0,0 @@
3729-/*
3730- * Copyright 2012 Canonical Ltd.
3731- *
3732- * This program is free software: you can redistribute it and/or modify it
3733- * under the terms of the GNU General Public License version 3, as published
3734- * by the Free Software Foundation.
3735- *
3736- * This program is distributed in the hope that it will be useful, but
3737- * WITHOUT ANY WARRANTY; without even the implied warranties of
3738- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
3739- * PURPOSE. See the GNU General Public License for more details.
3740- *
3741- * You should have received a copy of the GNU General Public License
3742- * version 3 along with this program. If not, see
3743- * <http://www.gnu.org/licenses/>
3744- *
3745- * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
3746- *
3747- */
3748-
3749-#include "PluginAdapterMock.h"
3750-
3751-PluginAdapterMock *PluginAdapterMock::_default = 0;
3752-
3753-PluginAdapterMock& PluginAdapterMock::Default() {
3754- if (!_default) {
3755- _default = new PluginAdapterMock;
3756- }
3757- return *_default;
3758-}
3759-
3760-void PluginAdapterMock::ShowGrabHandles(CompWindowMock* window, bool use_timer) {
3761-}
3762
3763=== removed file 'tests/test-gestures/PluginAdapterMock.h'
3764--- tests/test-gestures/PluginAdapterMock.h 2012-10-11 01:44:15 +0000
3765+++ tests/test-gestures/PluginAdapterMock.h 1970-01-01 00:00:00 +0000
3766@@ -1,38 +0,0 @@
3767-/*
3768- * Copyright 2012 Canonical Ltd.
3769- *
3770- * This program is free software: you can redistribute it and/or modify it
3771- * under the terms of the GNU General Public License version 3, as published
3772- * by the Free Software Foundation.
3773- *
3774- * This program is distributed in the hope that it will be useful, but
3775- * WITHOUT ANY WARRANTY; without even the implied warranties of
3776- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
3777- * PURPOSE. See the GNU General Public License for more details.
3778- *
3779- * You should have received a copy of the GNU General Public License
3780- * version 3 along with this program. If not, see
3781- * <http://www.gnu.org/licenses/>
3782- *
3783- * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
3784- *
3785- */
3786-
3787-#ifndef PLUGINADAPTER_MOCK_H
3788-#define PLUGINADAPTER_MOCK_H
3789-
3790-#include <compiz_mock/core/core.h>
3791-
3792-
3793-class PluginAdapterMock {
3794-public:
3795- static PluginAdapterMock& Default();
3796-
3797- void ShowGrabHandles(CompWindowMock* window, bool use_timer);
3798-
3799-private:
3800- PluginAdapterMock() {}
3801- static PluginAdapterMock* _default;
3802-};
3803-
3804-#endif
3805
3806=== removed file 'tests/test-gestures/SwitcherControllerMock.h'
3807--- tests/test-gestures/SwitcherControllerMock.h 2012-08-03 13:26:22 +0000
3808+++ tests/test-gestures/SwitcherControllerMock.h 1970-01-01 00:00:00 +0000
3809@@ -1,97 +0,0 @@
3810-/*
3811- * Copyright (C) 2012 Canonical Ltd
3812- *
3813- * This program is free software: you can redistribute it and/or modify
3814- * it under the terms of the GNU General Public License version 3 as
3815- * published by the Free Software Foundation.
3816- *
3817- * This program is distributed in the hope that it will be useful,
3818- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3819- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3820- * GNU General Public License for more details.
3821- *
3822- * You should have received a copy of the GNU General Public License
3823- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3824- *
3825- * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
3826- */
3827-
3828-#ifndef SWITCHER_CONTROLLER_MOCK_H
3829-#define SWITCHER_CONTROLLER_MOCK_H
3830-
3831-#include "NuxMock.h"
3832-
3833-namespace unity {
3834-namespace switcher {
3835-
3836-class SwitcherViewMock : public nux::ViewMock
3837-{
3838-public:
3839- int IconIndexAt(int x, int y)
3840- {
3841- return x*y;
3842- }
3843-};
3844-
3845-class ControllerMock
3846-{
3847-public:
3848- ControllerMock()
3849- {
3850- Reset();
3851- }
3852-
3853- void Reset()
3854- {
3855- is_visible_ = false;
3856- prev_count_ = 0;
3857- next_count_ = 0;
3858- index_selected_ = -1;
3859- }
3860-
3861- typedef std::shared_ptr<ControllerMock> Ptr;
3862-
3863- sigc::signal<void> view_built;
3864-
3865- void Next()
3866- {
3867- ++next_count_;
3868- }
3869-
3870- void Prev()
3871- {
3872- ++prev_count_;
3873- }
3874-
3875- void Select(int index)
3876- {
3877- index_selected_ = index;
3878- }
3879-
3880- bool Visible()
3881- {
3882- return is_visible_;
3883- }
3884-
3885- void Hide()
3886- {
3887- is_visible_ = false;
3888- }
3889-
3890- SwitcherViewMock *GetView()
3891- {
3892- return &view_;
3893- }
3894-
3895- bool is_visible_;
3896- SwitcherViewMock view_;
3897- int prev_count_;
3898- int next_count_;
3899- int index_selected_;
3900-};
3901-
3902-} // namespace switcher
3903-} // namespace unity
3904-
3905-
3906-#endif // SWITCHER_CONTROLLER_MOCK_H
3907
3908=== removed file 'tests/test-gestures/UnityGestureTargetMock.h'
3909--- tests/test-gestures/UnityGestureTargetMock.h 2012-07-27 20:20:29 +0000
3910+++ tests/test-gestures/UnityGestureTargetMock.h 1970-01-01 00:00:00 +0000
3911@@ -1,15 +0,0 @@
3912-#ifndef UNITY_GESTURE_TARGET_MOCK_H
3913-#define UNITY_GESTURE_TARGET_MOCK_H
3914-
3915-#include <Nux/Gesture.h>
3916-
3917-class UnityGestureTargetMock : public nux::GestureTarget
3918-{
3919- public:
3920- virtual nux::GestureDeliveryRequest GestureEvent(const nux::GestureEvent &event)
3921- {
3922- return nux::GestureDeliveryRequest::NONE;
3923- }
3924-};
3925-
3926-#endif // UNITY_GESTURE_TARGET_MOCK_H
3927
3928=== modified file 'tests/test-gestures/WindowGestureTargetMock.h'
3929--- tests/test-gestures/WindowGestureTargetMock.h 2012-07-27 20:20:29 +0000
3930+++ tests/test-gestures/WindowGestureTargetMock.h 2012-12-19 14:00:32 +0000
3931@@ -1,9 +1,19 @@
3932 #ifndef WINDOW_GESTURE_TARGET_MOCK_H
3933 #define WINDOW_GESTURE_TARGET_MOCK_H
3934
3935+#include <memory>
3936+#include <set>
3937 #include <Nux/Gesture.h>
3938+#include <WindowGestureTarget.h>
3939
3940-#include <set>
3941+namespace unity
3942+{
3943+namespace gestures
3944+{
3945+class GestureManipulatedWindow;
3946+class MousePointer;
3947+}
3948+}
3949
3950 class CompWindowMock;
3951 class WindowGestureTargetMock;
3952@@ -13,7 +23,8 @@
3953 class WindowGestureTargetMock : public nux::GestureTarget
3954 {
3955 public:
3956- WindowGestureTargetMock(CompWindowMock *window) : window(window)
3957+ WindowGestureTargetMock(unity::gestures::GestureManipulatedWindow &manipulated,
3958+ const std::weak_ptr <unity::gestures::MousePointer> &mc) : manipulated_window (manipulated), pointer(mc)
3959 {
3960 g_window_target_mocks.insert(this);
3961 }
3962@@ -29,10 +40,9 @@
3963 return nux::GestureDeliveryRequest::NONE;
3964 }
3965
3966- CompWindowMock *window;
3967 std::list<nux::GestureEvent> events_received;
3968-
3969- static Cursor fleur_cursor;
3970+ unity::gestures::GestureManipulatedWindow &manipulated_window;
3971+ const std::weak_ptr <unity::gestures::MousePointer> &pointer;
3972 private:
3973 virtual bool Equals(const nux::GestureTarget& other) const
3974 {
3975@@ -40,10 +50,7 @@
3976
3977 if (window_target)
3978 {
3979- if (window && window_target->window)
3980- return window->id() == window_target->window->id();
3981- else
3982- return window == window_target->window;
3983+ return manipulated_window.GetIdentifier () == window_target->manipulated_window.GetIdentifier ();
3984 }
3985 else
3986 {
3987
3988=== removed file 'tests/test-gestures/X11_mock.cpp'
3989--- tests/test-gestures/X11_mock.cpp 2012-04-04 14:33:07 +0000
3990+++ tests/test-gestures/X11_mock.cpp 1970-01-01 00:00:00 +0000
3991@@ -1,40 +0,0 @@
3992-/*
3993- * Copyright 2012 Canonical Ltd.
3994- *
3995- * This program is free software: you can redistribute it and/or modify it
3996- * under the terms of the GNU General Public License version 3, as published
3997- * by the Free Software Foundation.
3998- *
3999- * This program is distributed in the hope that it will be useful, but
4000- * WITHOUT ANY WARRANTY; without even the implied warranties of
4001- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
4002- * PURPOSE. See the GNU General Public License for more details.
4003- *
4004- * You should have received a copy of the GNU General Public License
4005- * version 3 along with this program. If not, see
4006- * <http://www.gnu.org/licenses/>
4007- *
4008- * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
4009- *
4010- */
4011-
4012-#include <X11/Xlib.h>
4013-
4014-Cursor XCreateFontCursorMock(Display * /*display*/, unsigned int /*shape*/) {
4015- return 1;
4016-}
4017-
4018-int XFreeCursorMock(Display * /*display*/, Cursor /*cursor*/) {
4019- return 1;
4020-}
4021-
4022-int XSyncMock(Display *display, Bool discard) {
4023- return 1;
4024-}
4025-
4026-int XWarpPointerMock(Display *display, Window src_w, Window dest_w,
4027- int src_x, int src_y,
4028- unsigned int src_width, unsigned int src_height,
4029- int dest_x, int dest_y) {
4030- return 1;
4031-}
4032
4033=== removed file 'tests/test-gestures/X11_mock.h'
4034--- tests/test-gestures/X11_mock.h 2012-04-04 14:33:07 +0000
4035+++ tests/test-gestures/X11_mock.h 1970-01-01 00:00:00 +0000
4036@@ -1,37 +0,0 @@
4037-/*
4038- * Copyright 2012 Canonical Ltd.
4039- *
4040- * This program is free software: you can redistribute it and/or modify it
4041- * under the terms of the GNU General Public License version 3, as published
4042- * by the Free Software Foundation.
4043- *
4044- * This program is distributed in the hope that it will be useful, but
4045- * WITHOUT ANY WARRANTY; without even the implied warranties of
4046- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
4047- * PURPOSE. See the GNU General Public License for more details.
4048- *
4049- * You should have received a copy of the GNU General Public License
4050- * version 3 along with this program. If not, see
4051- * <http://www.gnu.org/licenses/>
4052- *
4053- * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
4054- *
4055- */
4056-
4057-#ifndef X11_MOCK_H
4058-#define X11_MOCK_H
4059-
4060-#include <X11/Xlib.h>
4061-
4062-Cursor XCreateFontCursorMock(Display *display, unsigned int shape);
4063-
4064-int XFreeCursorMock(Display *display, Cursor cursor);
4065-
4066-int XSyncMock(Display *display, Bool discard);
4067-
4068-int XWarpPointerMock(Display *display, Window src_w, Window dest_w,
4069- int src_x, int src_y,
4070- unsigned int src_width, unsigned int src_height,
4071- int dest_x, int dest_y);
4072-
4073-#endif // X11_MOCK_H
4074
4075=== removed directory 'tests/test-gestures/compiz_mock'
4076=== removed directory 'tests/test-gestures/compiz_mock/core'
4077=== removed file 'tests/test-gestures/compiz_mock/core/core.h'
4078--- tests/test-gestures/compiz_mock/core/core.h 2012-04-04 14:33:07 +0000
4079+++ tests/test-gestures/compiz_mock/core/core.h 1970-01-01 00:00:00 +0000
4080@@ -1,29 +0,0 @@
4081-/*
4082- * Copyright 2012 Canonical Ltd.
4083- *
4084- * This program is free software: you can redistribute it and/or modify it
4085- * under the terms of the GNU General Public License version 3, as published
4086- * by the Free Software Foundation.
4087- *
4088- * This program is distributed in the hope that it will be useful, but
4089- * WITHOUT ANY WARRANTY; without even the implied warranties of
4090- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
4091- * PURPOSE. See the GNU General Public License for more details.
4092- *
4093- * You should have received a copy of the GNU General Public License
4094- * version 3 along with this program. If not, see
4095- * <http://www.gnu.org/licenses/>
4096- *
4097- * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
4098- *
4099- */
4100-
4101-#ifndef COMPIZ_CORE_MOCK_H
4102-#define COMPIZ_CORE_MOCK_H
4103-
4104-#include <X11_mock.h>
4105-
4106-#include <compiz_mock/core/window.h>
4107-#include <compiz_mock/core/screen.h>
4108-
4109-#endif
4110
4111=== removed file 'tests/test-gestures/compiz_mock/core/screen.h'
4112--- tests/test-gestures/compiz_mock/core/screen.h 2012-07-27 20:20:29 +0000
4113+++ tests/test-gestures/compiz_mock/core/screen.h 1970-01-01 00:00:00 +0000
4114@@ -1,77 +0,0 @@
4115-/*
4116- * Copyright 2012 Canonical Ltd.
4117- *
4118- * This program is free software: you can redistribute it and/or modify it
4119- * under the terms of the GNU General Public License version 3, as published
4120- * by the Free Software Foundation.
4121- *
4122- * This program is distributed in the hope that it will be useful, but
4123- * WITHOUT ANY WARRANTY; without even the implied warranties of
4124- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
4125- * PURPOSE. See the GNU General Public License for more details.
4126- *
4127- * You should have received a copy of the GNU General Public License
4128- * version 3 along with this program. If not, see
4129- * <http://www.gnu.org/licenses/>
4130- *
4131- * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
4132- *
4133- */
4134-
4135-#ifndef COMPIZ_SCREEN_MOCK_H
4136-#define COMPIZ_SCREEN_MOCK_H
4137-
4138-#include <X11/Xlib.h>
4139-#include <vector>
4140-
4141-// The real CompScreen
4142-#include <core/screen.h>
4143-
4144-typedef std::vector<CompWindowMock*> CompWindowMockVector;
4145-
4146-class CompScreenMock {
4147-public:
4148- CompScreenMock() : grab_count_(0), next_grab_handle_(1) {}
4149-
4150- typedef int GrabHandle;
4151-
4152- int width() const {return width_;}
4153- int height() const {return height_;}
4154-
4155- Display *dpy() {return dpy_;}
4156-
4157- const CompWindowMockVector & clientList(bool stackingOrder = true) {
4158- if (stackingOrder)
4159- return client_list_stacking_;
4160- else
4161- return client_list_;
4162- }
4163-
4164- Window root() {return root_;}
4165-
4166- GrabHandle pushGrab(Cursor cursor, const char *name) {
4167- grab_count_++;
4168- return next_grab_handle_++;
4169- }
4170- void removeGrab(GrabHandle handle, CompPoint *restorePointer) {
4171- grab_count_--;
4172- }
4173-
4174- Cursor invisibleCursor() {return 1;}
4175-
4176- int width_;
4177- int height_;
4178- Display *dpy_;
4179- CompWindowMockVector client_list_;
4180- CompWindowMockVector client_list_stacking_;
4181- Window root_;
4182- int grab_count_;
4183- int next_grab_handle_;
4184-};
4185-
4186-extern CompScreenMock *screen_mock;
4187-extern int pointerX_mock;
4188-extern int pointerY_mock;
4189-
4190-#endif
4191-
4192
4193=== removed file 'tests/test-gestures/compiz_mock/core/timer.h'
4194--- tests/test-gestures/compiz_mock/core/timer.h 2012-07-27 20:24:01 +0000
4195+++ tests/test-gestures/compiz_mock/core/timer.h 1970-01-01 00:00:00 +0000
4196@@ -1,79 +0,0 @@
4197-/*
4198- * Copyright 2012 Canonical Ltd.
4199- *
4200- * This program is free software: you can redistribute it and/or modify it
4201- * under the terms of the GNU General Public License version 3, as published
4202- * by the Free Software Foundation.
4203- *
4204- * This program is distributed in the hope that it will be useful, but
4205- * WITHOUT ANY WARRANTY; without even the implied warranties of
4206- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
4207- * PURPOSE. See the GNU General Public License for more details.
4208- *
4209- * You should have received a copy of the GNU General Public License
4210- * version 3 along with this program. If not, see
4211- * <http://www.gnu.org/licenses/>
4212- *
4213- * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
4214- *
4215- */
4216-
4217-#ifndef COMPIZ_TIMER_MOCK_H
4218-#define COMPIZ_TIMER_MOCK_H
4219-
4220-#include <boost/function.hpp>
4221-
4222-class CompTimerMock
4223-{
4224- public:
4225- typedef boost::function<bool ()> CallBack;
4226-
4227- CompTimerMock()
4228- {
4229- is_running = false;
4230- callback = NULL;
4231-
4232- // OBS: no support for more than one simultaneous timer
4233- instance = this;
4234- }
4235-
4236- virtual ~CompTimerMock()
4237- {
4238- instance = nullptr;
4239- }
4240-
4241- void setCallback (CallBack callback)
4242- {
4243- this->callback = callback;
4244- }
4245-
4246- void setTimes(unsigned int min, unsigned int max = 0)
4247- {
4248- }
4249-
4250- void start()
4251- {
4252- is_running = true;
4253- }
4254-
4255- void stop()
4256- {
4257- is_running = false;
4258- }
4259-
4260- void ForceTimeout()
4261- {
4262- if (is_running && callback)
4263- {
4264- callback();
4265- is_running = false;
4266- }
4267- }
4268-
4269- CallBack callback;
4270- bool is_running;
4271-
4272- static CompTimerMock *instance;
4273-};
4274-
4275-#endif // COMPIZ_TIMER_MOCK_H
4276
4277=== removed file 'tests/test-gestures/compiz_mock/core/window.h'
4278--- tests/test-gestures/compiz_mock/core/window.h 2012-07-27 20:20:29 +0000
4279+++ tests/test-gestures/compiz_mock/core/window.h 1970-01-01 00:00:00 +0000
4280@@ -1,79 +0,0 @@
4281-/*
4282- * Copyright 2012 Canonical Ltd.
4283- *
4284- * This program is free software: you can redistribute it and/or modify it
4285- * under the terms of the GNU General Public License version 3, as published
4286- * by the Free Software Foundation.
4287- *
4288- * This program is distributed in the hope that it will be useful, but
4289- * WITHOUT ANY WARRANTY; without even the implied warranties of
4290- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
4291- * PURPOSE. See the GNU General Public License for more details.
4292- *
4293- * You should have received a copy of the GNU General Public License
4294- * version 3 along with this program. If not, see
4295- * <http://www.gnu.org/licenses/>
4296- *
4297- * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
4298- *
4299- */
4300-
4301-#ifndef COMPIZ_WINDOW_MOCK_H
4302-#define COMPIZ_WINDOW_MOCK_H
4303-
4304-/* The real CompWindow */
4305-#include <core/window.h>
4306-
4307-class CompWindowMock
4308-{
4309-public:
4310- CompWindowMock() : moved_(false), maximize_count_(0), maximize_state_(0),
4311- minimized_(false) {}
4312-
4313- int x() const {return geometry_.x();}
4314- int y() const {return geometry_.y();}
4315- int width() const {return geometry_.width() + (geometry_.border()*2);}
4316- int height() const {return geometry_.height() + (geometry_.border()*2);}
4317- int id() { return id_; }
4318-
4319- void move(int dx, int dy, bool immediate = true)
4320- {
4321- moved_ = true;
4322- movement_x_ = dx;
4323- movement_y_ = dy;
4324- }
4325-
4326- unsigned int actions () {return actions_;}
4327-
4328- bool minimized() { return minimized_; }
4329-
4330- void maximize(int state) {++maximize_count_; maximize_state_ = state;}
4331-
4332- /* OBS: I wonder why it returns a reference */
4333- unsigned int &state() {return state_;}
4334-
4335- void grabNotify(int x, int y, unsigned int state, unsigned int mask) {}
4336- void ungrabNotify() {}
4337-
4338- void syncPosition() {}
4339-
4340- compiz::window::Geometry &serverGeometry() {return server_geometry_;}
4341-
4342- unsigned int actions_;
4343- unsigned int state_;
4344- compiz::window::Geometry server_geometry_;
4345- compiz::window::Geometry geometry_;
4346-
4347- bool moved_;
4348- int movement_x_;
4349- int movement_y_;
4350-
4351- int maximize_count_;
4352- int maximize_state_;
4353-
4354- int id_;
4355-
4356- bool minimized_;
4357-};
4358-
4359-#endif
4360
4361=== removed file 'tests/test-gestures/sed_script_broker'
4362--- tests/test-gestures/sed_script_broker 2012-07-27 20:24:01 +0000
4363+++ tests/test-gestures/sed_script_broker 1970-01-01 00:00:00 +0000
4364@@ -1,12 +0,0 @@
4365-s|<core/core.h>|<compiz_mock/core/core.h>|
4366-s|\<CompScreen\>|CompScreenMock|g
4367-s|\<CompWindow\>|CompWindowMock|g
4368-s|\<CompWindowVector\>|CompWindowMockVector|g
4369-s|\<screen\>|screen_mock|g
4370-s|\<pointerX\>|pointerX_mock|g
4371-s|\<pointerY\>|pointerY_mock|g
4372-s|\<XFreeCursor\>|XFreeCursorMock|g
4373-s|\<XCreateFontCursor\>|XCreateFontCursorMock|g
4374-s|\<WindowGestureTarget\>|WindowGestureTargetMock|g
4375-s|\<UnityGestureTarget\>|UnityGestureTargetMock|g
4376-s|GesturalWindowSwitcher|GesturalWindowSwitcherMock|g
4377
4378=== removed file 'tests/test-gestures/sed_script_gesture'
4379--- tests/test-gestures/sed_script_gesture 2012-07-27 20:20:29 +0000
4380+++ tests/test-gestures/sed_script_gesture 1970-01-01 00:00:00 +0000
4381@@ -1,18 +0,0 @@
4382-s|<core/core.h>|<compiz_mock/core/core.h>|
4383-s|\<CompScreen\>|CompScreenMock|g
4384-s|\<CompWindow\>|CompWindowMock|g
4385-s|\<CompWindowVector\>|CompWindowMockVector|g
4386-s|\<screen\>|screen_mock|g
4387-s|\<pointerX\>|pointerX_mock|g
4388-s|\<pointerY\>|pointerY_mock|g
4389-s|\<XSync\>|XSyncMock|g
4390-s|\<XWarpPointer\>|XWarpPointerMock|g
4391-s|\<XFreeCursor\>|XFreeCursorMock|g
4392-s|\<XCreateFontCursor\>|XCreateFontCursorMock|g
4393-s|\<ubus-server.h\>|ubus-server-mock.h|g
4394-s|\<unityshell.h\>|unityshell_mock.h|g
4395-s|\<PluginAdapter\>|PluginAdapterMock|g
4396-s|\<UnityWindow\>|UnityWindowMock|g
4397-s|\<UnityScreen\>|UnityScreenMock|g
4398-s|\<InputArea\>|InputAreaMock|g
4399-s|\<Nux/Nux\.h\>|NuxMock.h|g
4400
4401=== removed file 'tests/test-gestures/sed_script_switcher'
4402--- tests/test-gestures/sed_script_switcher 2012-07-27 20:24:01 +0000
4403+++ tests/test-gestures/sed_script_switcher 1970-01-01 00:00:00 +0000
4404@@ -1,25 +0,0 @@
4405-s|<core/core.h>|<compiz_mock/core/core.h>|
4406-s|<core/timer.h>|<compiz_mock/core/timer.h>|
4407-s|\<CompScreen\>|CompScreenMock|g
4408-s|\<CompWindow\>|CompWindowMock|g
4409-s|\<CompWindowVector\>|CompWindowMockVector|g
4410-s|\<screen\>|screen_mock|g
4411-s|\<pointerX\>|pointerX_mock|g
4412-s|\<pointerY\>|pointerY_mock|g
4413-s|\<XSync\>|XSyncMock|g
4414-s|\<XWarpPointer\>|XWarpPointerMock|g
4415-s|\<XFreeCursor\>|XFreeCursorMock|g
4416-s|\<XCreateFontCursor\>|XCreateFontCursorMock|g
4417-s|\<ubus-server.h\>|ubus-server-mock.h|g
4418-s|\<unityshell.h\>|unityshell_mock.h|g
4419-s|\<PluginAdapter\>|PluginAdapterMock|g
4420-s|\<UnityWindow\>|UnityWindowMock|g
4421-s|\<UnityScreen\>|UnityScreenMock|g
4422-s|\<InputArea\>|InputAreaMock|g
4423-s|\<Nux/Nux\.h\>|NuxMock.h|g
4424-s|\<CompTimer\>|CompTimerMock|g
4425-s|\<LauncherController\>|LauncherControllerMock|g
4426-s|\<SwitcherController\>|SwitcherControllerMock|g
4427-s|\<switcher\:\:Controller\>|switcher\:\:ControllerMock|g
4428-s|\<launcher\:\:Controller\>|launcher\:\:ControllerMock|g
4429-s|\<SwitcherView\>|SwitcherViewMock|g
4430
4431=== modified file 'tests/test-gestures/test_gestural_window_switcher.cpp'
4432--- tests/test-gestures/test_gestural_window_switcher.cpp 2012-08-14 12:48:21 +0000
4433+++ tests/test-gestures/test_gestural_window_switcher.cpp 2012-12-19 14:00:32 +0000
4434@@ -19,205 +19,327 @@
4435 * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
4436 */
4437
4438+#include <tuple>
4439+
4440+#include <glib.h>
4441+
4442 #include <gtest/gtest.h>
4443+#include "MockSwitcherController.h"
4444+#include "MockSwitcherView.h"
4445 #include "GesturalWindowSwitcher.h"
4446 #include "FakeGestureEvent.h"
4447-#include "unityshell_mock.h"
4448-#include "compiz_mock/core/timer.h"
4449
4450 using namespace unity;
4451+namespace us = unity::switcher;
4452+
4453+using ::testing::Invoke;
4454+using ::testing::Return;
4455+using ::testing::AtLeast;
4456+using ::testing::StrictMock;
4457+using ::testing::_;
4458+
4459+class ForcedActionInvoker : public GesturalWindowSwitcherActionInvoker
4460+{
4461+ public:
4462+
4463+ void SetCallbackToInvoke (const std::function <bool ()> &callback)
4464+ {
4465+ callback_ = callback;
4466+ }
4467+
4468+ void InvokeCallbackAndExpectResult (bool expected_result)
4469+ {
4470+ ASSERT_TRUE (active_);
4471+
4472+ bool result = false;
4473+ EXPECT_NO_THROW ({
4474+ result = callback_ ();
4475+ });
4476+ EXPECT_EQ (expected_result, result);
4477+
4478+ if (!result)
4479+ callback_ = std::function <bool ()> ();
4480+ }
4481+
4482+ void InvokeOnTimeout(int timeout)
4483+ {
4484+ active_ = true;
4485+ }
4486+
4487+ void StopPendingInvocation()
4488+ {
4489+ active_ = false;
4490+ }
4491+
4492+ private:
4493+
4494+ std::function <bool ()> callback_;
4495+ bool active_;
4496+};
4497+
4498+class MockGesturalWindowSwitcherActionInvoker : public GesturalWindowSwitcherActionInvoker
4499+{
4500+ public:
4501+
4502+ typedef std::shared_ptr <MockGesturalWindowSwitcherActionInvoker> Ptr;
4503+
4504+ MOCK_METHOD1(InvokeOnTimeout, void(int));
4505+ MOCK_METHOD0(StopPendingInvocation, void());
4506+
4507+ MockGesturalWindowSwitcherActionInvoker (ForcedActionInvoker &forced_invoker) :
4508+ forced_invoker_ (forced_invoker)
4509+ {
4510+ ON_CALL (*this, InvokeOnTimeout(_))
4511+ .WillByDefault(Invoke (&forced_invoker_,
4512+ &ForcedActionInvoker::InvokeOnTimeout));
4513+ ON_CALL (*this, StopPendingInvocation())
4514+ .WillByDefault(Invoke (&forced_invoker_,
4515+ &ForcedActionInvoker::StopPendingInvocation));
4516+
4517+ /* FIXME: Not sure where from though */
4518+ EXPECT_CALL (*this, StopPendingInvocation()).Times (AtLeast (0));
4519+ }
4520+
4521+ void SetCallbackToInvoke (const std::function <bool ()> &callback)
4522+ {
4523+ forced_invoker_.SetCallbackToInvoke(callback);
4524+ }
4525+
4526+ private:
4527+
4528+ ForcedActionInvoker &forced_invoker_;
4529+};
4530+
4531+class GesturalWindowSwitcherActionInvokerFactoryMock : public GesturalWindowSwitcherActionInvokerFactory
4532+{
4533+ public:
4534+
4535+ GesturalWindowSwitcherActionInvokerFactoryMock (const MockGesturalWindowSwitcherActionInvoker::Ptr &mock_invoker) :
4536+ mock_action_invoker_ (mock_invoker)
4537+ {
4538+ }
4539+
4540+ GesturalWindowSwitcherActionInvoker::Ptr
4541+ CreateActionInvoker(const std::function<bool ()> &callback) const
4542+ {
4543+ mock_action_invoker_->SetCallbackToInvoke (callback);
4544+ return mock_action_invoker_;
4545+ }
4546+
4547+ private:
4548+
4549+ mutable MockGesturalWindowSwitcherActionInvoker::Ptr mock_action_invoker_;
4550+};
4551
4552 class GesturalWindowSwitcherTest: public ::testing::Test
4553 {
4554- public:
4555- virtual void SetUp()
4556- {
4557- unity_screen = unity::UnityScreenMock::get(screen_mock);
4558- unity_screen->Reset();
4559-
4560- fake_event.gesture_id = 0;
4561- fake_event.timestamp = 12345; // some arbitrary, big value
4562-
4563- unity_screen->switcher_controller()->view_built.emit();
4564- }
4565-
4566- void PerformTap()
4567- {
4568- fake_event.type = nux::EVENT_GESTURE_BEGIN;
4569- fake_event.gesture_id += 1;
4570- fake_event.gesture_classes = nux::TOUCH_GESTURE;
4571- gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4572-
4573- fake_event.type = nux::EVENT_GESTURE_UPDATE;
4574- fake_event.timestamp += 0.2 * CompoundGestureRecognizer::MAX_TAP_TIME;
4575- gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4576-
4577- fake_event.type = nux::EVENT_GESTURE_END;
4578- fake_event.timestamp += 0.6 * CompoundGestureRecognizer::MAX_TAP_TIME;
4579- gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4580- }
4581-
4582- void PerformTapAndHold()
4583- {
4584- PerformTap();
4585-
4586- // Hold
4587-
4588- fake_event.type = nux::EVENT_GESTURE_BEGIN;
4589- fake_event.gesture_id += 1;
4590- fake_event.timestamp += 0.6 * CompoundGestureRecognizer::MAX_TIME_BETWEEN_GESTURES;
4591- gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4592-
4593- fake_event.type = nux::EVENT_GESTURE_UPDATE;
4594- fake_event.timestamp += 0.2 * CompoundGestureRecognizer::MAX_TAP_TIME;
4595- gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4596-
4597- fake_event.type = nux::EVENT_GESTURE_UPDATE;
4598- fake_event.timestamp += 1.0 * CompoundGestureRecognizer::HOLD_TIME;
4599- gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4600- }
4601-
4602- GesturalWindowSwitcher gestural_switcher;
4603- nux::FakeGestureEvent fake_event;
4604- unity::UnityScreenMock *unity_screen;
4605+ public:
4606+
4607+ GesturalWindowSwitcherTest ()
4608+ : mock_action_invoker_ (new MockGesturalWindowSwitcherActionInvoker (forced_action_invoker_))
4609+ , mock_action_invoker_factory_ (mock_action_invoker_)
4610+ , mock_switcher_controller (new StrictMock <unity::switcher::MockSwitcherController> ())
4611+ , mock_switcher_view (new unity::switcher::MockSwitcherView)
4612+ , switcher_view (new unity::switcher::View ([this](){
4613+ return unity::switcher::View::ImplPtr(mock_switcher_view);
4614+ }))
4615+ , gestural_switcher (std::unique_ptr<unity::switcher::Controller> (new unity::switcher::Controller ([this](){
4616+ return std::unique_ptr<unity::switcher::Controller::Impl> (
4617+ mock_switcher_controller);
4618+ })),
4619+ std::bind (&GesturalWindowSwitcherTest::SetupAndShowSwitcher, this),
4620+ mock_action_invoker_factory_)
4621+ {
4622+ ON_CALL (*mock_switcher_view, ConnectToMouseEvents (_, _, _))
4623+ .WillByDefault (Invoke (this, &GesturalWindowSwitcherTest::ConnectToMouseEventsDelegate));
4624+ ON_CALL (*mock_switcher_controller, GetView ()).WillByDefault (Return(switcher_view.get()));
4625+
4626+ EXPECT_CALL(*mock_switcher_controller, GetView ()).Times(AtLeast(0));
4627+ }
4628+
4629+ MOCK_METHOD0(SetupAndShowSwitcher, void());
4630+
4631+ virtual void SetUp()
4632+ {
4633+ fake_event.gesture_id = 0;
4634+ fake_event.timestamp = 12345; // some arbitrary, big value
4635+
4636+ // Expect a call to ConnectToMouseEvents
4637+ EXPECT_CALL (*mock_switcher_view, ConnectToMouseEvents (_, _, _));
4638+ mock_switcher_controller->view_built.emit();
4639+ }
4640+
4641+ void PerformTap()
4642+ {
4643+ fake_event.type = nux::EVENT_GESTURE_BEGIN;
4644+ fake_event.gesture_id += 1;
4645+ fake_event.gesture_classes = nux::TOUCH_GESTURE;
4646+ gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4647+
4648+ fake_event.type = nux::EVENT_GESTURE_UPDATE;
4649+ fake_event.timestamp += 0.2 * CompoundGestureRecognizer::MAX_TAP_TIME;
4650+ gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4651+
4652+ fake_event.type = nux::EVENT_GESTURE_END;
4653+ fake_event.timestamp += 0.6 * CompoundGestureRecognizer::MAX_TAP_TIME;
4654+ gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4655+ }
4656+
4657+ void PerformTapAndHold()
4658+ {
4659+ PerformTap();
4660+
4661+ // Hold
4662+
4663+ fake_event.type = nux::EVENT_GESTURE_BEGIN;
4664+ fake_event.gesture_id += 1;
4665+ fake_event.timestamp += 0.6 * CompoundGestureRecognizer::MAX_TIME_BETWEEN_GESTURES;
4666+ gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4667+
4668+ fake_event.type = nux::EVENT_GESTURE_UPDATE;
4669+ fake_event.timestamp += 0.2 * CompoundGestureRecognizer::MAX_TAP_TIME;
4670+ gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4671+
4672+ fake_event.type = nux::EVENT_GESTURE_UPDATE;
4673+ fake_event.timestamp += 1.0 * CompoundGestureRecognizer::HOLD_TIME;
4674+ gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4675+ }
4676+
4677+ us::View::MouseEventConnections
4678+ ConnectToMouseEventsDelegate (const us::View::MouseButtonCallback &mouse_down_f,
4679+ const us::View::MouseButtonCallback &mouse_up_f,
4680+ const us::View::MouseDragCallback &mouse_drag_f)
4681+ {
4682+ return std::make_tuple (mouse_down.connect (mouse_down_f),
4683+ mouse_up.connect (mouse_up_f),
4684+ mouse_drag.connect (mouse_drag_f));
4685+ }
4686+
4687+ ForcedActionInvoker forced_action_invoker_;
4688+ MockGesturalWindowSwitcherActionInvoker::Ptr mock_action_invoker_;
4689+ GesturalWindowSwitcherActionInvokerFactoryMock mock_action_invoker_factory_;
4690+ unity::switcher::MockSwitcherController *mock_switcher_controller;
4691+
4692+ /* MockSwitcherView is owned by switcher_view */
4693+ unity::switcher::MockSwitcherView *mock_switcher_view;
4694+ unity::switcher::View::Ptr switcher_view;
4695+ GesturalWindowSwitcherImpl gestural_switcher;
4696+ nux::FakeGestureEvent fake_event;
4697+
4698+ sigc::signal<void, int, int, unsigned long, unsigned long> mouse_down;
4699+ sigc::signal<void, int, int, unsigned long, unsigned long> mouse_up;
4700+ sigc::signal<void, int, int, int, int, unsigned long, unsigned long> mouse_drag;
4701+
4702 };
4703
4704 TEST_F(GesturalWindowSwitcherTest, DoubleTapSwitchesWindow)
4705 {
4706+ EXPECT_CALL(*mock_action_invoker_, InvokeOnTimeout (GesturalWindowSwitcherImpl::SWITCHER_TIME_AFTER_DOUBLE_TAP));
4707+
4708+ // Show the switcher
4709+ EXPECT_CALL(*mock_switcher_controller, Visible ()).WillOnce (Return(false));
4710+ EXPECT_CALL(*this, SetupAndShowSwitcher());
4711+
4712 PerformTap();
4713 fake_event.timestamp += 0.6 * CompoundGestureRecognizer::MAX_TIME_BETWEEN_GESTURES;
4714 PerformTap();
4715
4716- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4717- ASSERT_EQ(0, unity_screen->switcher_controller()->next_count_);
4718- ASSERT_EQ(0, unity_screen->switcher_controller()->prev_count_);
4719- ASSERT_TRUE(unity_screen->switcher_controller()->is_visible_);
4720+ // Hide the switcher
4721+ EXPECT_CALL(*mock_switcher_controller, Hide (true));
4722
4723 // simulate that enough time has passed
4724- if (CompTimerMock::instance)
4725- CompTimerMock::instance->ForceTimeout();
4726-
4727- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4728- ASSERT_EQ(0, unity_screen->switcher_controller()->next_count_);
4729- ASSERT_EQ(0, unity_screen->switcher_controller()->prev_count_);
4730- ASSERT_FALSE(unity_screen->switcher_controller()->is_visible_);
4731+ forced_action_invoker_.InvokeCallbackAndExpectResult(false);
4732 }
4733
4734 TEST_F(GesturalWindowSwitcherTest, TapAndHoldShowsSwitcher)
4735 {
4736+ // Show the switcher
4737+ EXPECT_CALL(*mock_switcher_controller, Visible ()).WillOnce (Return(false));
4738+ EXPECT_CALL(*this, SetupAndShowSwitcher());
4739+
4740 PerformTapAndHold();
4741
4742- // switcher should show up
4743- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4744- ASSERT_EQ(0, unity_screen->switcher_controller()->next_count_);
4745- ASSERT_EQ(0, unity_screen->switcher_controller()->prev_count_);
4746- ASSERT_TRUE(unity_screen->switcher_controller()->is_visible_);
4747-
4748- // simulate that enough idle time has passed
4749- if (CompTimerMock::instance)
4750- CompTimerMock::instance->ForceTimeout();
4751-
4752- // nothing should change
4753- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4754- ASSERT_EQ(0, unity_screen->switcher_controller()->next_count_);
4755- ASSERT_EQ(0, unity_screen->switcher_controller()->prev_count_);
4756- ASSERT_TRUE(unity_screen->switcher_controller()->is_visible_);
4757+ EXPECT_CALL (*mock_action_invoker_,
4758+ InvokeOnTimeout (GesturalWindowSwitcherImpl::SWITCHER_TIME_AFTER_HOLD_RELEASED));
4759
4760 // lift fingers. End hold.
4761 fake_event.type = nux::EVENT_GESTURE_END;
4762 fake_event.timestamp += 0.1 * CompoundGestureRecognizer::HOLD_TIME;
4763+
4764 gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4765
4766- // nothing should change
4767- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4768- ASSERT_EQ(0, unity_screen->switcher_controller()->next_count_);
4769- ASSERT_EQ(0, unity_screen->switcher_controller()->prev_count_);
4770- ASSERT_TRUE(unity_screen->switcher_controller()->is_visible_);
4771+ // switcher will be closed
4772+ EXPECT_CALL(*mock_switcher_controller, Hide (true));
4773
4774 // simulate that enough idle time has passed
4775- if (CompTimerMock::instance)
4776- CompTimerMock::instance->ForceTimeout();
4777-
4778- // switcher should finally be closed
4779- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4780- ASSERT_EQ(0, unity_screen->switcher_controller()->next_count_);
4781- ASSERT_EQ(0, unity_screen->switcher_controller()->prev_count_);
4782- ASSERT_FALSE(unity_screen->switcher_controller()->is_visible_);
4783+ forced_action_invoker_.InvokeCallbackAndExpectResult(false);
4784 }
4785
4786 TEST_F(GesturalWindowSwitcherTest, TapAndHoldAndDragSelectsNextWindow)
4787 {
4788+ // Show the switcher
4789+ EXPECT_CALL(*mock_switcher_controller, Visible ()).WillOnce (Return(false));
4790+ EXPECT_CALL(*this, SetupAndShowSwitcher());
4791+
4792 PerformTapAndHold();
4793
4794- if (CompTimerMock::instance)
4795- CompTimerMock::instance->ForceTimeout();
4796-
4797- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4798- ASSERT_EQ(0, unity_screen->switcher_controller()->next_count_);
4799- ASSERT_EQ(0, unity_screen->switcher_controller()->prev_count_);
4800- ASSERT_TRUE(unity_screen->switcher_controller()->is_visible_);
4801+ // Expect a call to Next ()
4802+ EXPECT_CALL(*mock_switcher_controller, Visible ()).WillOnce (Return(true));
4803+ EXPECT_CALL (*mock_switcher_controller, Next ());
4804
4805 // Drag far enough to the right.
4806 fake_event.type = nux::EVENT_GESTURE_UPDATE;
4807 fake_event.gesture_classes = nux::TOUCH_GESTURE | nux::DRAG_GESTURE;
4808 fake_event.timestamp += 0.1 * CompoundGestureRecognizer::HOLD_TIME;
4809- fake_event.delta.x = 0.6 * GesturalWindowSwitcher::DRAG_DELTA_FOR_CHANGING_SELECTION;
4810+ fake_event.delta.x = 0.6 * GesturalWindowSwitcherImpl::DRAG_DELTA_FOR_CHANGING_SELECTION;
4811 gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4812
4813 fake_event.timestamp += 0.1 * CompoundGestureRecognizer::HOLD_TIME;
4814- fake_event.delta.x = 0.6 * GesturalWindowSwitcher::DRAG_DELTA_FOR_CHANGING_SELECTION;
4815+ fake_event.delta.x = 0.6 * GesturalWindowSwitcherImpl::DRAG_DELTA_FOR_CHANGING_SELECTION;
4816 gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4817
4818- // Selection should have jumped to the next window
4819- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4820- ASSERT_EQ(1, unity_screen->switcher_controller()->next_count_);
4821- ASSERT_EQ(0, unity_screen->switcher_controller()->prev_count_);
4822- ASSERT_TRUE(unity_screen->switcher_controller()->is_visible_);
4823+ // Expect a call to Prev ()
4824+ EXPECT_CALL(*mock_switcher_controller, Visible ()).WillOnce (Return(true));
4825+ EXPECT_CALL (*mock_switcher_controller, Prev ());
4826
4827 // Drag far enough to the left.
4828 fake_event.timestamp += 0.1 * CompoundGestureRecognizer::HOLD_TIME;
4829- fake_event.delta.x = -0.6 * GesturalWindowSwitcher::DRAG_DELTA_FOR_CHANGING_SELECTION;
4830+ fake_event.delta.x = -0.6 * GesturalWindowSwitcherImpl::DRAG_DELTA_FOR_CHANGING_SELECTION;
4831 gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4832
4833 fake_event.timestamp += 0.1 * CompoundGestureRecognizer::HOLD_TIME;
4834- fake_event.delta.x = -0.6 * GesturalWindowSwitcher::DRAG_DELTA_FOR_CHANGING_SELECTION;
4835+ fake_event.delta.x = -0.6 * GesturalWindowSwitcherImpl::DRAG_DELTA_FOR_CHANGING_SELECTION;
4836 gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4837
4838- // Selection should have jumped to the previous window
4839- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4840- ASSERT_EQ(1, unity_screen->switcher_controller()->next_count_);
4841- ASSERT_EQ(1, unity_screen->switcher_controller()->prev_count_);
4842- ASSERT_TRUE(unity_screen->switcher_controller()->is_visible_);
4843+ // Expect a call to Hide ()
4844+ EXPECT_CALL (*mock_switcher_controller, Hide (true));
4845
4846 // End gesture
4847 fake_event.type = nux::EVENT_GESTURE_END;
4848 fake_event.timestamp += 0.1 * CompoundGestureRecognizer::HOLD_TIME;
4849 gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4850-
4851- // Switcher should have been closed at once
4852- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4853- ASSERT_EQ(1, unity_screen->switcher_controller()->next_count_);
4854- ASSERT_EQ(1, unity_screen->switcher_controller()->prev_count_);
4855- ASSERT_FALSE(unity_screen->switcher_controller()->is_visible_);
4856 }
4857
4858 TEST_F(GesturalWindowSwitcherTest, NewDragAfterTapAndHoldSelectsNextWindow)
4859 {
4860+ // Show the switcher
4861+ EXPECT_CALL(*mock_switcher_controller, Visible ()).WillOnce (Return(false));
4862+ EXPECT_CALL(*this, SetupAndShowSwitcher());
4863+
4864 PerformTapAndHold();
4865
4866- if (CompTimerMock::instance)
4867- CompTimerMock::instance->ForceTimeout();
4868-
4869- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4870- ASSERT_EQ(0, unity_screen->switcher_controller()->next_count_);
4871- ASSERT_EQ(0, unity_screen->switcher_controller()->prev_count_);
4872- ASSERT_TRUE(unity_screen->switcher_controller()->is_visible_);
4873+ EXPECT_CALL (*mock_action_invoker_,
4874+ InvokeOnTimeout (GesturalWindowSwitcherImpl::SWITCHER_TIME_AFTER_HOLD_RELEASED));
4875
4876 // End hold gesture
4877 fake_event.type = nux::EVENT_GESTURE_END;
4878 fake_event.timestamp += 0.1 * CompoundGestureRecognizer::HOLD_TIME;
4879 gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4880
4881+ // Expect a call to Next ()
4882+ EXPECT_CALL(*mock_switcher_controller, Visible ()).WillOnce (Return(true));
4883+ EXPECT_CALL (*mock_switcher_controller, Next ());
4884+
4885 // Start a new gesture and drag far enough to the right.
4886
4887 fake_event.type = nux::EVENT_GESTURE_BEGIN;
4888@@ -229,95 +351,87 @@
4889 fake_event.type = nux::EVENT_GESTURE_UPDATE;
4890 fake_event.gesture_classes |= nux::DRAG_GESTURE;
4891 fake_event.timestamp += 0.1 * CompoundGestureRecognizer::HOLD_TIME;
4892- fake_event.delta.x = 0.6 * GesturalWindowSwitcher::DRAG_DELTA_FOR_CHANGING_SELECTION;
4893+ fake_event.delta.x = 0.6 * GesturalWindowSwitcherImpl::DRAG_DELTA_FOR_CHANGING_SELECTION;
4894 gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4895
4896 fake_event.timestamp += 0.1 * CompoundGestureRecognizer::HOLD_TIME;
4897- fake_event.delta.x = 0.6 * GesturalWindowSwitcher::DRAG_DELTA_FOR_CHANGING_SELECTION;
4898+ fake_event.delta.x = 0.6 * GesturalWindowSwitcherImpl::DRAG_DELTA_FOR_CHANGING_SELECTION;
4899 gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4900
4901- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4902- ASSERT_EQ(1, unity_screen->switcher_controller()->next_count_);
4903- ASSERT_EQ(0, unity_screen->switcher_controller()->prev_count_);
4904- ASSERT_TRUE(unity_screen->switcher_controller()->is_visible_);
4905+ // Expect a call to Hide ()
4906+ EXPECT_CALL (*mock_switcher_controller, Hide (true));
4907
4908 fake_event.type = nux::EVENT_GESTURE_END;
4909 fake_event.timestamp += 0.1 * CompoundGestureRecognizer::HOLD_TIME;
4910 gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4911-
4912- // switcher should have been closed
4913- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4914- ASSERT_EQ(1, unity_screen->switcher_controller()->next_count_);
4915- ASSERT_EQ(0, unity_screen->switcher_controller()->prev_count_);
4916- ASSERT_FALSE(unity_screen->switcher_controller()->is_visible_);
4917 }
4918
4919 TEST_F(GesturalWindowSwitcherTest, ClickAfterTapAndHoldSelectsWindow)
4920 {
4921+ // Show the switcher
4922+ EXPECT_CALL(*mock_switcher_controller, Visible ()).WillOnce (Return(false));
4923+ EXPECT_CALL(*this, SetupAndShowSwitcher());
4924+
4925 PerformTapAndHold();
4926
4927- if (CompTimerMock::instance)
4928- CompTimerMock::instance->ForceTimeout();
4929+ const int x_click = 12;
4930+ const int y_click = 23;
4931+ const int index = 2;
4932
4933- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4934- ASSERT_EQ(0, unity_screen->switcher_controller()->next_count_);
4935- ASSERT_EQ(0, unity_screen->switcher_controller()->prev_count_);
4936- ASSERT_TRUE(unity_screen->switcher_controller()->is_visible_);
4937+ // Expect a call to Select () with index
4938+ EXPECT_CALL (*mock_switcher_view, IconIndexAt (x_click, y_click))
4939+ .WillOnce (Return (index));
4940+ EXPECT_CALL (*mock_switcher_controller, Select (index));
4941+ EXPECT_CALL (*mock_action_invoker_, InvokeOnTimeout (GesturalWindowSwitcherImpl::SWITCHER_TIME_AFTER_HOLD_RELEASED));
4942
4943 // lift fingers. End hold.
4944 fake_event.type = nux::EVENT_GESTURE_END;
4945 fake_event.timestamp += 0.1 * CompoundGestureRecognizer::HOLD_TIME;
4946 gestural_switcher.GestureEvent(fake_event.ToGestureEvent());
4947
4948+ EXPECT_CALL (*mock_action_invoker_, InvokeOnTimeout (GesturalWindowSwitcherImpl::SWITCHER_TIME_AFTER_DOUBLE_TAP));
4949+
4950 // click on position (12, 23)
4951- unity_screen->switcher_controller()->view_.mouse_down.emit(12, 23, 0, 0);
4952- unity_screen->switcher_controller()->view_.mouse_up.emit(12, 23, 0, 0);
4953+ mouse_down.emit(x_click, y_click, 0, 0);
4954+ mouse_up.emit(x_click, y_click, 0, 0);
4955
4956- // Should have selected the icon index corresponding to the
4957- // position clicked.
4958- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4959- ASSERT_EQ(0, unity_screen->switcher_controller()->next_count_);
4960- ASSERT_EQ(0, unity_screen->switcher_controller()->prev_count_);
4961- ASSERT_TRUE(unity_screen->switcher_controller()->is_visible_);
4962- ASSERT_EQ(12*23, unity_screen->switcher_controller()->index_selected_);
4963+ // Expect the switcher to close
4964+ EXPECT_CALL (*mock_switcher_controller, Hide (true));
4965
4966 // simulate that enough time has passed
4967- if (CompTimerMock::instance)
4968- CompTimerMock::instance->ForceTimeout();
4969-
4970- ASSERT_FALSE(unity_screen->switcher_controller()->is_visible_);
4971+ forced_action_invoker_.InvokeCallbackAndExpectResult(false);
4972 }
4973
4974 TEST_F(GesturalWindowSwitcherTest, MouseDragAfterTapAndHoldSelectsNextWindow)
4975 {
4976- unity::switcher::SwitcherViewMock &switcher_view =
4977- unity_screen->switcher_controller()->view_;
4978- int drag_delta = GesturalWindowSwitcher::DRAG_DELTA_FOR_CHANGING_SELECTION * 1.5f;
4979+ int drag_delta = GesturalWindowSwitcherImpl::DRAG_DELTA_FOR_CHANGING_SELECTION * 1.5f;
4980+
4981+ // Show the switcher
4982+ EXPECT_CALL(*mock_switcher_controller, Visible ()).WillOnce (Return(false));
4983+ EXPECT_CALL(*this, SetupAndShowSwitcher());
4984
4985 PerformTapAndHold();
4986
4987- if (CompTimerMock::instance)
4988- CompTimerMock::instance->ForceTimeout();
4989-
4990- ASSERT_EQ(1, unity_screen->SetUpAndShowSwitcher_count_);
4991- ASSERT_EQ(0, unity_screen->switcher_controller()->next_count_);
4992- ASSERT_EQ(0, unity_screen->switcher_controller()->prev_count_);
4993- ASSERT_TRUE(unity_screen->switcher_controller()->is_visible_);
4994+ // Expect a call to Next () and then Hide ()
4995+ EXPECT_CALL(*mock_switcher_controller, Visible ()).WillOnce (Return(true));
4996+ EXPECT_CALL (*mock_action_invoker_, InvokeOnTimeout (GesturalWindowSwitcherImpl::SWITCHER_TIME_AFTER_HOLD_RELEASED));
4997
4998 // lift fingers. End hold.
4999 fake_event.type = nux::EVENT_GESTURE_END;
5000 fake_event.timestamp += 0.1 * CompoundGestureRecognizer::HOLD_TIME;
The diff has been truncated for viewing.