Merge lp:~unity-team/unity/edge-barrier-autohide-fix into lp:unity
- edge-barrier-autohide-fix
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Brandon Schaefer |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3140 |
Proposed branch: | lp:~unity-team/unity/edge-barrier-autohide-fix |
Merge into: | lp:unity |
Diff against target: |
776 lines (+320/-117) 9 files modified
launcher/EdgeBarrierController.cpp (+55/-48) launcher/EdgeBarrierController.h (+10/-4) launcher/EdgeBarrierControllerPrivate.h (+57/-0) launcher/Launcher.cpp (+9/-7) launcher/Launcher.h (+1/-1) launcher/PointerBarrier.cpp (+1/-0) launcher/PointerBarrier.h (+1/-0) tests/test_edge_barrier_controller.cpp (+114/-41) tests/test_launcher.cpp (+72/-16) |
To merge this branch: | bzr merge lp:~unity-team/unity/edge-barrier-autohide-fix |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brandon Schaefer (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Review via email: mp+147252@code.launchpad.net |
This proposal supersedes a proposal from 2013-02-06.
Commit message
EdgeBarrierCont
Now when sticky keys are disabled, and the launcher is set to autohide, the mouse will hit both sides of the screen (instead of just the left side of the barrier); at that point we'll release the events coming from the launcher-less side of the monitor, but we'll use them to temporary keep the barrier "broken".
Description of the change
=== Problem ===
When sticky keys are set to off only the left side of the barrier blocks the mouse. This means when moving the mouse from the LEFT screen to the RIGHT screen it will skip the barrier.
=== Fix ===
Just use direction::BOTH for both cases.
So we'll release the events coming from the launcher-less side of the monitor, but we'll use them to temporary keep the barrier "broken".
Initially based on lp:~brandontschaefer/unity/lp.1064945-fix
=== Test ===
Added new unit tests, updated old ones.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
Approved revid is not set in launchpad (maybe a permission problem?).
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Brandon Schaefer (brandontschaefer) : | # |
Preview Diff
1 | === modified file 'launcher/EdgeBarrierController.cpp' | |||
2 | --- launcher/EdgeBarrierController.cpp 2012-12-11 23:38:30 +0000 | |||
3 | +++ launcher/EdgeBarrierController.cpp 2013-02-08 01:02:23 +0000 | |||
4 | @@ -19,6 +19,7 @@ | |||
5 | 19 | */ | 19 | */ |
6 | 20 | 20 | ||
7 | 21 | #include "EdgeBarrierController.h" | 21 | #include "EdgeBarrierController.h" |
8 | 22 | #include "EdgeBarrierControllerPrivate.h" | ||
9 | 22 | #include "Decaymulator.h" | 23 | #include "Decaymulator.h" |
10 | 23 | #include "unity-shared/UScreen.h" | 24 | #include "unity-shared/UScreen.h" |
11 | 24 | #include "UnityCore/GLibSource.h" | 25 | #include "UnityCore/GLibSource.h" |
12 | @@ -26,23 +27,6 @@ | |||
13 | 26 | namespace unity { | 27 | namespace unity { |
14 | 27 | namespace ui { | 28 | namespace ui { |
15 | 28 | 29 | ||
16 | 29 | struct EdgeBarrierController::Impl | ||
17 | 30 | { | ||
18 | 31 | Impl(EdgeBarrierController *parent); | ||
19 | 32 | |||
20 | 33 | void ResizeBarrierList(std::vector<nux::Geometry> const& layout); | ||
21 | 34 | void SetupBarriers(std::vector<nux::Geometry> const& layout); | ||
22 | 35 | |||
23 | 36 | void OnPointerBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event); | ||
24 | 37 | void BarrierRelease(PointerBarrierWrapper* owner, int event); | ||
25 | 38 | |||
26 | 39 | std::vector<PointerBarrierWrapper::Ptr> barriers_; | ||
27 | 40 | std::vector<EdgeBarrierSubscriber*> subscribers_; | ||
28 | 41 | Decaymulator decaymulator_; | ||
29 | 42 | glib::Source::UniquePtr release_timeout_; | ||
30 | 43 | float edge_overcome_pressure_; | ||
31 | 44 | EdgeBarrierController* parent_; | ||
32 | 45 | }; | ||
33 | 46 | 30 | ||
34 | 47 | EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent) | 31 | EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent) |
35 | 48 | : edge_overcome_pressure_(0) | 32 | : edge_overcome_pressure_(0) |
36 | @@ -106,7 +90,7 @@ | |||
37 | 106 | 90 | ||
38 | 107 | barrier->DestroyBarrier(); | 91 | barrier->DestroyBarrier(); |
39 | 108 | 92 | ||
41 | 109 | if (!edge_resist && (subscribers_[i] == nullptr || parent_->options()->hide_mode() == launcher::LauncherHideMode::LAUNCHER_HIDE_NEVER)) | 93 | if (!edge_resist && parent_->options()->hide_mode() == launcher::LauncherHideMode::LAUNCHER_HIDE_NEVER) |
42 | 110 | continue; | 94 | continue; |
43 | 111 | 95 | ||
44 | 112 | barrier->x1 = monitor.x; | 96 | barrier->x1 = monitor.x; |
45 | @@ -118,11 +102,6 @@ | |||
46 | 118 | barrier->threshold = parent_->options()->edge_stop_velocity(); | 102 | barrier->threshold = parent_->options()->edge_stop_velocity(); |
47 | 119 | barrier->max_velocity_multiplier = parent_->options()->edge_responsiveness(); | 103 | barrier->max_velocity_multiplier = parent_->options()->edge_responsiveness(); |
48 | 120 | 104 | ||
49 | 121 | if (edge_resist) | ||
50 | 122 | barrier->direction = BarrierDirection::BOTH; | ||
51 | 123 | else | ||
52 | 124 | barrier->direction = BarrierDirection::LEFT; | ||
53 | 125 | |||
54 | 126 | barrier->ConstructBarrier(); | 105 | barrier->ConstructBarrier(); |
55 | 127 | } | 106 | } |
56 | 128 | 107 | ||
57 | @@ -133,7 +112,22 @@ | |||
58 | 133 | edge_overcome_pressure_ = parent_->options()->edge_overcome_pressure() * overcome_responsiveness_mult; | 112 | edge_overcome_pressure_ = parent_->options()->edge_overcome_pressure() * overcome_responsiveness_mult; |
59 | 134 | } | 113 | } |
60 | 135 | 114 | ||
62 | 136 | void EdgeBarrierController::Impl::OnPointerBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) | 115 | void EdgeBarrierController::Impl::BarrierReset() |
63 | 116 | { | ||
64 | 117 | decaymulator_.value = 0; | ||
65 | 118 | } | ||
66 | 119 | |||
67 | 120 | void EdgeBarrierController::Impl::BarrierPush(PointerBarrierWrapper* owner, BarrierEvent::Ptr const& event) | ||
68 | 121 | { | ||
69 | 122 | decaymulator_.value = decaymulator_.value + event->velocity; | ||
70 | 123 | |||
71 | 124 | if (decaymulator_.value > edge_overcome_pressure_) | ||
72 | 125 | { | ||
73 | 126 | BarrierRelease(owner, event->event_id); | ||
74 | 127 | } | ||
75 | 128 | } | ||
76 | 129 | |||
77 | 130 | void EdgeBarrierController::Impl::OnPointerBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr const& event) | ||
78 | 137 | { | 131 | { |
79 | 138 | if (owner->released) | 132 | if (owner->released) |
80 | 139 | { | 133 | { |
81 | @@ -142,28 +136,41 @@ | |||
82 | 142 | } | 136 | } |
83 | 143 | 137 | ||
84 | 144 | unsigned int monitor = owner->index; | 138 | unsigned int monitor = owner->index; |
86 | 145 | bool process = true; | 139 | auto result = EdgeBarrierSubscriber::Result::IGNORED; |
87 | 146 | 140 | ||
88 | 147 | if (monitor < subscribers_.size()) | 141 | if (monitor < subscribers_.size()) |
89 | 148 | { | 142 | { |
90 | 149 | auto subscriber = subscribers_[monitor]; | 143 | auto subscriber = subscribers_[monitor]; |
91 | 150 | 144 | ||
94 | 151 | if (subscriber && subscriber->HandleBarrierEvent(owner, event)) | 145 | if (subscriber) |
95 | 152 | process = false; | 146 | result = subscriber->HandleBarrierEvent(owner, event); |
96 | 153 | } | 147 | } |
97 | 154 | 148 | ||
99 | 155 | if (process && owner->x1 > 0) | 149 | switch (result) |
100 | 156 | { | 150 | { |
105 | 157 | decaymulator_.value = decaymulator_.value + event->velocity; | 151 | case EdgeBarrierSubscriber::Result::HANDLED: |
106 | 158 | 152 | BarrierReset(); | |
107 | 159 | if (decaymulator_.value > edge_overcome_pressure_ || (!parent_->sticky_edges() && !subscribers_[monitor])) | 153 | break; |
108 | 160 | { | 154 | |
109 | 155 | case EdgeBarrierSubscriber::Result::ALREADY_HANDLED: | ||
110 | 156 | BarrierPush(owner, event); | ||
111 | 157 | break; | ||
112 | 158 | |||
113 | 159 | case EdgeBarrierSubscriber::Result::IGNORED: | ||
114 | 160 | if (parent_->sticky_edges()) | ||
115 | 161 | { | ||
116 | 162 | BarrierPush(owner, event); | ||
117 | 163 | } | ||
118 | 164 | else | ||
119 | 165 | { | ||
120 | 166 | owner->release_once = true; | ||
121 | 167 | BarrierRelease(owner, event->event_id); | ||
122 | 168 | } | ||
123 | 169 | break; | ||
124 | 170 | |||
125 | 171 | case EdgeBarrierSubscriber::Result::NEEDS_RELEASE: | ||
126 | 161 | BarrierRelease(owner, event->event_id); | 172 | BarrierRelease(owner, event->event_id); |
132 | 162 | } | 173 | break; |
128 | 163 | } | ||
129 | 164 | else | ||
130 | 165 | { | ||
131 | 166 | decaymulator_.value = 0; | ||
133 | 167 | } | 174 | } |
134 | 168 | } | 175 | } |
135 | 169 | 176 | ||
136 | @@ -171,13 +178,18 @@ | |||
137 | 171 | { | 178 | { |
138 | 172 | owner->ReleaseBarrier(event); | 179 | owner->ReleaseBarrier(event); |
139 | 173 | owner->released = true; | 180 | owner->released = true; |
141 | 174 | decaymulator_.value = 0; | 181 | BarrierReset(); |
142 | 175 | 182 | ||
148 | 176 | unsigned duration = parent_->options()->edge_passed_disabled_ms; | 183 | if (!owner->release_once() || |
149 | 177 | release_timeout_.reset(new glib::Timeout(duration, [owner] { | 184 | (owner->release_once() && (!release_timeout_ || !release_timeout_->IsRunning()))) |
150 | 178 | owner->released = false; | 185 | { |
151 | 179 | return false; | 186 | unsigned duration = parent_->options()->edge_passed_disabled_ms; |
152 | 180 | })); | 187 | release_timeout_.reset(new glib::Timeout(duration, [owner] { |
153 | 188 | owner->released = false; | ||
154 | 189 | owner->release_once = false; | ||
155 | 190 | return false; | ||
156 | 191 | })); | ||
157 | 192 | } | ||
158 | 181 | } | 193 | } |
159 | 182 | 194 | ||
160 | 183 | EdgeBarrierController::EdgeBarrierController() | 195 | EdgeBarrierController::EdgeBarrierController() |
161 | @@ -217,10 +229,5 @@ | |||
162 | 217 | return pimpl->subscribers_[monitor]; | 229 | return pimpl->subscribers_[monitor]; |
163 | 218 | } | 230 | } |
164 | 219 | 231 | ||
165 | 220 | void EdgeBarrierController::ProcessBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) | ||
166 | 221 | { | ||
167 | 222 | pimpl->OnPointerBarrierEvent(owner, event); | ||
168 | 223 | } | ||
169 | 224 | |||
170 | 225 | } | 232 | } |
171 | 226 | } | 233 | } |
172 | 227 | 234 | ||
173 | === modified file 'launcher/EdgeBarrierController.h' | |||
174 | --- launcher/EdgeBarrierController.h 2012-11-23 02:11:30 +0000 | |||
175 | +++ launcher/EdgeBarrierController.h 2013-02-08 01:02:23 +0000 | |||
176 | @@ -28,7 +28,15 @@ | |||
177 | 28 | 28 | ||
178 | 29 | struct EdgeBarrierSubscriber | 29 | struct EdgeBarrierSubscriber |
179 | 30 | { | 30 | { |
181 | 31 | virtual bool HandleBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) = 0; | 31 | enum class Result |
182 | 32 | { | ||
183 | 33 | IGNORED, | ||
184 | 34 | HANDLED, | ||
185 | 35 | ALREADY_HANDLED, | ||
186 | 36 | NEEDS_RELEASE | ||
187 | 37 | }; | ||
188 | 38 | |||
189 | 39 | virtual Result HandleBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) = 0; | ||
190 | 32 | }; | 40 | }; |
191 | 33 | 41 | ||
192 | 34 | class EdgeBarrierController : public sigc::trackable | 42 | class EdgeBarrierController : public sigc::trackable |
193 | @@ -44,12 +52,10 @@ | |||
194 | 44 | void Unsubscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor); | 52 | void Unsubscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor); |
195 | 45 | EdgeBarrierSubscriber* GetSubscriber(unsigned int monitor); | 53 | EdgeBarrierSubscriber* GetSubscriber(unsigned int monitor); |
196 | 46 | 54 | ||
197 | 47 | protected: | ||
198 | 48 | void ProcessBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event); | ||
199 | 49 | |||
200 | 50 | private: | 55 | private: |
201 | 51 | struct Impl; | 56 | struct Impl; |
202 | 52 | std::unique_ptr<Impl> pimpl; | 57 | std::unique_ptr<Impl> pimpl; |
203 | 58 | friend class TestEdgeBarrierController; | ||
204 | 53 | }; | 59 | }; |
205 | 54 | 60 | ||
206 | 55 | } | 61 | } |
207 | 56 | 62 | ||
208 | === added file 'launcher/EdgeBarrierControllerPrivate.h' | |||
209 | --- launcher/EdgeBarrierControllerPrivate.h 1970-01-01 00:00:00 +0000 | |||
210 | +++ launcher/EdgeBarrierControllerPrivate.h 2013-02-08 01:02:23 +0000 | |||
211 | @@ -0,0 +1,57 @@ | |||
212 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
213 | 2 | /* | ||
214 | 3 | * Copyright (C) 2012-2013 Canonical Ltd | ||
215 | 4 | * | ||
216 | 5 | * This program is free software: you can redistribute it and/or modify | ||
217 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
218 | 7 | * published by the Free Software Foundation. | ||
219 | 8 | * | ||
220 | 9 | * This program is distributed in the hope that it will be useful, | ||
221 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
222 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
223 | 12 | * GNU General Public License for more details. | ||
224 | 13 | * | ||
225 | 14 | * You should have received a copy of the GNU General Public License | ||
226 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
227 | 16 | * | ||
228 | 17 | * Authored by: Jason Smith <jason.smith@canonical.com> | ||
229 | 18 | * Marco Trevisan <marco.trevisan@canonical.com> | ||
230 | 19 | */ | ||
231 | 20 | |||
232 | 21 | #ifndef EDGE_BARRIER_CONTROLLER_IMPL_PRIVATE | ||
233 | 22 | #define EDGE_BARRIER_CONTROLLER_IMPL_PRIVATE | ||
234 | 23 | |||
235 | 24 | #include "Decaymulator.h" | ||
236 | 25 | #include "UnityCore/GLibSource.h" | ||
237 | 26 | |||
238 | 27 | namespace unity | ||
239 | 28 | { | ||
240 | 29 | namespace ui | ||
241 | 30 | { | ||
242 | 31 | |||
243 | 32 | // NOTE: This private header is not part of the public interface | ||
244 | 33 | struct EdgeBarrierController::Impl | ||
245 | 34 | { | ||
246 | 35 | Impl(EdgeBarrierController *parent); | ||
247 | 36 | |||
248 | 37 | void ResizeBarrierList(std::vector<nux::Geometry> const& layout); | ||
249 | 38 | void SetupBarriers(std::vector<nux::Geometry> const& layout); | ||
250 | 39 | |||
251 | 40 | void OnPointerBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr const& event); | ||
252 | 41 | void BarrierPush(PointerBarrierWrapper* owner, BarrierEvent::Ptr const& event); | ||
253 | 42 | void BarrierRelease(PointerBarrierWrapper* owner, int event); | ||
254 | 43 | void BarrierReset(); | ||
255 | 44 | |||
256 | 45 | std::vector<PointerBarrierWrapper::Ptr> barriers_; | ||
257 | 46 | std::vector<EdgeBarrierSubscriber*> subscribers_; | ||
258 | 47 | Decaymulator decaymulator_; | ||
259 | 48 | glib::Source::UniquePtr release_timeout_; | ||
260 | 49 | float edge_overcome_pressure_; | ||
261 | 50 | EdgeBarrierController* parent_; | ||
262 | 51 | }; | ||
263 | 52 | |||
264 | 53 | } //namespace ui | ||
265 | 54 | } //namespace unity | ||
266 | 55 | |||
267 | 56 | |||
268 | 57 | #endif // EDGE_BARRIER_CONTROLLER_IMPL_PRIVATE | ||
269 | 0 | 58 | ||
270 | === modified file 'launcher/Launcher.cpp' | |||
271 | --- launcher/Launcher.cpp 2013-02-01 22:53:42 +0000 | |||
272 | +++ launcher/Launcher.cpp 2013-02-08 01:02:23 +0000 | |||
273 | @@ -2252,19 +2252,21 @@ | |||
274 | 2252 | 2252 | ||
275 | 2253 | #ifdef USE_X11 | 2253 | #ifdef USE_X11 |
276 | 2254 | 2254 | ||
278 | 2255 | bool Launcher::HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event) | 2255 | ui::EdgeBarrierSubscriber::Result Launcher::HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event) |
279 | 2256 | { | 2256 | { |
280 | 2257 | if (_hide_machine.GetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE)) | 2257 | if (_hide_machine.GetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE)) |
281 | 2258 | { | 2258 | { |
284 | 2259 | owner->ReleaseBarrier(event->event_id); | 2259 | return ui::EdgeBarrierSubscriber::Result::NEEDS_RELEASE; |
283 | 2260 | return true; | ||
285 | 2261 | } | 2260 | } |
286 | 2262 | 2261 | ||
287 | 2263 | nux::Geometry const& abs_geo = GetAbsoluteGeometry(); | 2262 | nux::Geometry const& abs_geo = GetAbsoluteGeometry(); |
288 | 2264 | 2263 | ||
289 | 2265 | bool apply_to_reveal = false; | 2264 | bool apply_to_reveal = false; |
291 | 2266 | if (_hidden && event->x >= abs_geo.x && event->x <= abs_geo.x + abs_geo.width) | 2265 | if (event->x >= abs_geo.x && event->x <= abs_geo.x + abs_geo.width) |
292 | 2267 | { | 2266 | { |
293 | 2267 | if (!_hidden) | ||
294 | 2268 | return ui::EdgeBarrierSubscriber::Result::ALREADY_HANDLED; | ||
295 | 2269 | |||
296 | 2268 | if (options()->reveal_trigger == RevealTrigger::EDGE) | 2270 | if (options()->reveal_trigger == RevealTrigger::EDGE) |
297 | 2269 | { | 2271 | { |
298 | 2270 | if (event->y >= abs_geo.y) | 2272 | if (event->y >= abs_geo.y) |
299 | @@ -2288,15 +2290,15 @@ | |||
300 | 2288 | &root_y_return, &win_x_return, &win_y_return, &mask_return)) | 2290 | &root_y_return, &win_x_return, &win_y_return, &mask_return)) |
301 | 2289 | { | 2291 | { |
302 | 2290 | if (mask_return & (Button1Mask | Button3Mask)) | 2292 | if (mask_return & (Button1Mask | Button3Mask)) |
304 | 2291 | apply_to_reveal = false; | 2293 | return ui::EdgeBarrierSubscriber::Result::NEEDS_RELEASE; |
305 | 2292 | } | 2294 | } |
306 | 2293 | } | 2295 | } |
307 | 2294 | 2296 | ||
308 | 2295 | if (!apply_to_reveal) | 2297 | if (!apply_to_reveal) |
310 | 2296 | return false; | 2298 | return ui::EdgeBarrierSubscriber::Result::IGNORED; |
311 | 2297 | 2299 | ||
312 | 2298 | _hide_machine.AddRevealPressure(event->velocity); | 2300 | _hide_machine.AddRevealPressure(event->velocity); |
314 | 2299 | return true; | 2301 | return ui::EdgeBarrierSubscriber::Result::HANDLED; |
315 | 2300 | } | 2302 | } |
316 | 2301 | 2303 | ||
317 | 2302 | #endif | 2304 | #endif |
318 | 2303 | 2305 | ||
319 | === modified file 'launcher/Launcher.h' | |||
320 | --- launcher/Launcher.h 2013-02-01 22:53:42 +0000 | |||
321 | +++ launcher/Launcher.h 2013-02-08 01:02:23 +0000 | |||
322 | @@ -210,7 +210,7 @@ | |||
323 | 210 | #endif | 210 | #endif |
324 | 211 | 211 | ||
325 | 212 | #ifdef USE_X11 | 212 | #ifdef USE_X11 |
327 | 213 | bool HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event); | 213 | ui::EdgeBarrierSubscriber::Result HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event); |
328 | 214 | #endif | 214 | #endif |
329 | 215 | 215 | ||
330 | 216 | void OnPluginStateChanged(); | 216 | void OnPluginStateChanged(); |
331 | 217 | 217 | ||
332 | === modified file 'launcher/PointerBarrier.cpp' | |||
333 | --- launcher/PointerBarrier.cpp 2012-07-19 01:22:13 +0000 | |||
334 | +++ launcher/PointerBarrier.cpp 2013-02-08 01:02:23 +0000 | |||
335 | @@ -38,6 +38,7 @@ | |||
336 | 38 | PointerBarrierWrapper::PointerBarrierWrapper() | 38 | PointerBarrierWrapper::PointerBarrierWrapper() |
337 | 39 | : active(false) | 39 | : active(false) |
338 | 40 | , released(false) | 40 | , released(false) |
339 | 41 | , release_once(false) | ||
340 | 41 | , smoothing(75) | 42 | , smoothing(75) |
341 | 42 | , max_velocity_multiplier(1.0f) | 43 | , max_velocity_multiplier(1.0f) |
342 | 43 | , direction(BOTH) | 44 | , direction(BOTH) |
343 | 44 | 45 | ||
344 | === modified file 'launcher/PointerBarrier.h' | |||
345 | --- launcher/PointerBarrier.h 2012-07-19 01:22:13 +0000 | |||
346 | +++ launcher/PointerBarrier.h 2013-02-08 01:02:23 +0000 | |||
347 | @@ -70,6 +70,7 @@ | |||
348 | 70 | 70 | ||
349 | 71 | nux::Property<bool> active; | 71 | nux::Property<bool> active; |
350 | 72 | nux::Property<bool> released; | 72 | nux::Property<bool> released; |
351 | 73 | nux::Property<bool> release_once; | ||
352 | 73 | 74 | ||
353 | 74 | nux::Property<int> smoothing; | 75 | nux::Property<int> smoothing; |
354 | 75 | 76 | ||
355 | 76 | 77 | ||
356 | === modified file 'tests/test_edge_barrier_controller.cpp' | |||
357 | --- tests/test_edge_barrier_controller.cpp 2012-09-13 10:56:42 +0000 | |||
358 | +++ tests/test_edge_barrier_controller.cpp 2013-02-08 01:02:23 +0000 | |||
359 | @@ -23,6 +23,7 @@ | |||
360 | 23 | #include "test_uscreen_mock.h" | 23 | #include "test_uscreen_mock.h" |
361 | 24 | 24 | ||
362 | 25 | #include "EdgeBarrierController.h" | 25 | #include "EdgeBarrierController.h" |
363 | 26 | #include "EdgeBarrierControllerPrivate.h" | ||
364 | 26 | 27 | ||
365 | 27 | using namespace unity; | 28 | using namespace unity; |
366 | 28 | using namespace unity::ui; | 29 | using namespace unity::ui; |
367 | @@ -46,35 +47,25 @@ | |||
368 | 46 | MOCK_METHOD1(ReleaseBarrier, void(int)); | 47 | MOCK_METHOD1(ReleaseBarrier, void(int)); |
369 | 47 | }; | 48 | }; |
370 | 48 | 49 | ||
371 | 49 | class MockEdgeBarrierController : public EdgeBarrierController | ||
372 | 50 | { | ||
373 | 51 | public: | ||
374 | 52 | void ProcessBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) | ||
375 | 53 | { | ||
376 | 54 | EdgeBarrierController::ProcessBarrierEvent(owner, event); | ||
377 | 55 | } | ||
378 | 56 | |||
379 | 57 | EdgeBarrierSubscriber* GetSubscriber(unsigned int monitor) | ||
380 | 58 | { | ||
381 | 59 | return EdgeBarrierController::GetSubscriber(monitor); | ||
382 | 60 | } | ||
383 | 61 | }; | ||
384 | 62 | |||
385 | 63 | class TestBarrierSubscriber : public EdgeBarrierSubscriber | 50 | class TestBarrierSubscriber : public EdgeBarrierSubscriber |
386 | 64 | { | 51 | { |
387 | 65 | public: | 52 | public: |
390 | 66 | TestBarrierSubscriber(bool handles = false) | 53 | TestBarrierSubscriber(EdgeBarrierSubscriber::Result result = EdgeBarrierSubscriber::Result::IGNORED) |
391 | 67 | : handles_(handles) | 54 | : handle_result_(result) |
392 | 68 | {} | 55 | {} |
393 | 69 | 56 | ||
395 | 70 | bool HandleBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) | 57 | EdgeBarrierSubscriber::Result HandleBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) |
396 | 71 | { | 58 | { |
398 | 72 | return handles_; | 59 | return handle_result_; |
399 | 73 | } | 60 | } |
400 | 74 | 61 | ||
402 | 75 | bool handles_; | 62 | EdgeBarrierSubscriber::Result handle_result_; |
403 | 76 | }; | 63 | }; |
404 | 77 | 64 | ||
405 | 65 | } // namespace | ||
406 | 66 | |||
407 | 67 | namespace unity { | ||
408 | 68 | namespace ui { | ||
409 | 78 | class TestEdgeBarrierController : public Test | 69 | class TestEdgeBarrierController : public Test |
410 | 79 | { | 70 | { |
411 | 80 | public: | 71 | public: |
412 | @@ -93,16 +84,32 @@ | |||
413 | 93 | } | 84 | } |
414 | 94 | } | 85 | } |
415 | 95 | 86 | ||
416 | 87 | void ProcessBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) | ||
417 | 88 | { | ||
418 | 89 | GetPrivateImpl()->OnPointerBarrierEvent(owner, event); | ||
419 | 90 | } | ||
420 | 91 | |||
421 | 92 | EdgeBarrierController::Impl* GetPrivateImpl() const | ||
422 | 93 | { | ||
423 | 94 | return bc.pimpl.get(); | ||
424 | 95 | } | ||
425 | 96 | |||
426 | 96 | BarrierEvent::Ptr MakeBarrierEvent(int id, bool breaker) | 97 | BarrierEvent::Ptr MakeBarrierEvent(int id, bool breaker) |
427 | 97 | { | 98 | { |
428 | 98 | int velocity = breaker ? std::numeric_limits<int>::max() : bc.options()->edge_overcome_pressure() - 1; | 99 | int velocity = breaker ? std::numeric_limits<int>::max() : bc.options()->edge_overcome_pressure() - 1; |
429 | 99 | return std::make_shared<BarrierEvent>(0, 1, velocity, id); | 100 | return std::make_shared<BarrierEvent>(0, 1, velocity, id); |
430 | 100 | } | 101 | } |
431 | 101 | 102 | ||
432 | 103 | |||
433 | 102 | TestBarrierSubscriber subscribers_[max_num_monitors]; | 104 | TestBarrierSubscriber subscribers_[max_num_monitors]; |
434 | 103 | MockUScreen uscreen; | 105 | MockUScreen uscreen; |
436 | 104 | MockEdgeBarrierController bc; | 106 | EdgeBarrierController bc; |
437 | 105 | }; | 107 | }; |
438 | 108 | } // namespace ui | ||
439 | 109 | } // namespace unity | ||
440 | 110 | |||
441 | 111 | namespace | ||
442 | 112 | { | ||
443 | 106 | 113 | ||
444 | 107 | TEST_F(TestEdgeBarrierController, Construction) | 114 | TEST_F(TestEdgeBarrierController, Construction) |
445 | 108 | { | 115 | { |
446 | @@ -129,7 +136,7 @@ | |||
447 | 129 | 136 | ||
448 | 130 | TEST_F(TestEdgeBarrierController, SubscriberReplace) | 137 | TEST_F(TestEdgeBarrierController, SubscriberReplace) |
449 | 131 | { | 138 | { |
451 | 132 | TestBarrierSubscriber handling_subscriber(true); | 139 | TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED); |
452 | 133 | bc.Subscribe(&handling_subscriber, 0); | 140 | bc.Subscribe(&handling_subscriber, 0); |
453 | 134 | EXPECT_EQ(bc.GetSubscriber(0), &handling_subscriber); | 141 | EXPECT_EQ(bc.GetSubscriber(0), &handling_subscriber); |
454 | 135 | } | 142 | } |
455 | @@ -138,28 +145,29 @@ | |||
456 | 138 | { | 145 | { |
457 | 139 | int monitor = 0; | 146 | int monitor = 0; |
458 | 140 | 147 | ||
460 | 141 | TestBarrierSubscriber handling_subscriber(true); | 148 | TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED); |
461 | 142 | bc.Subscribe(&handling_subscriber, monitor); | 149 | bc.Subscribe(&handling_subscriber, monitor); |
462 | 143 | 150 | ||
463 | 144 | MockPointerBarrier owner(monitor); | 151 | MockPointerBarrier owner(monitor); |
464 | 145 | auto breaking_barrier_event = MakeBarrierEvent(0, true); | 152 | auto breaking_barrier_event = MakeBarrierEvent(0, true); |
465 | 146 | 153 | ||
466 | 147 | EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0); | 154 | EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0); |
468 | 148 | bc.ProcessBarrierEvent(&owner, breaking_barrier_event); | 155 | ProcessBarrierEvent(&owner, breaking_barrier_event); |
469 | 156 | EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0); | ||
470 | 149 | } | 157 | } |
471 | 150 | 158 | ||
472 | 151 | TEST_F(TestEdgeBarrierController, ProcessHandledEventOnReleasedBarrier) | 159 | TEST_F(TestEdgeBarrierController, ProcessHandledEventOnReleasedBarrier) |
473 | 152 | { | 160 | { |
474 | 153 | int monitor = max_num_monitors-1; | 161 | int monitor = max_num_monitors-1; |
475 | 154 | 162 | ||
477 | 155 | TestBarrierSubscriber handling_subscriber(true); | 163 | TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED); |
478 | 156 | bc.Subscribe(&handling_subscriber, monitor); | 164 | bc.Subscribe(&handling_subscriber, monitor); |
479 | 157 | 165 | ||
480 | 158 | MockPointerBarrier owner(monitor, true); | 166 | MockPointerBarrier owner(monitor, true); |
481 | 159 | auto breaking_barrier_event = MakeBarrierEvent(5, true); | 167 | auto breaking_barrier_event = MakeBarrierEvent(5, true); |
482 | 160 | 168 | ||
483 | 161 | EXPECT_CALL(owner, ReleaseBarrier(5)).Times(1); | 169 | EXPECT_CALL(owner, ReleaseBarrier(5)).Times(1); |
485 | 162 | bc.ProcessBarrierEvent(&owner, breaking_barrier_event); | 170 | ProcessBarrierEvent(&owner, breaking_barrier_event); |
486 | 163 | } | 171 | } |
487 | 164 | 172 | ||
488 | 165 | TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrier) | 173 | TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrier) |
489 | @@ -171,7 +179,7 @@ | |||
490 | 171 | auto breaking_barrier_event = MakeBarrierEvent(breaking_id, true); | 179 | auto breaking_barrier_event = MakeBarrierEvent(breaking_id, true); |
491 | 172 | 180 | ||
492 | 173 | EXPECT_CALL(owner, ReleaseBarrier(breaking_id)); | 181 | EXPECT_CALL(owner, ReleaseBarrier(breaking_id)); |
494 | 174 | bc.ProcessBarrierEvent(&owner, breaking_barrier_event); | 182 | ProcessBarrierEvent(&owner, breaking_barrier_event); |
495 | 175 | } | 183 | } |
496 | 176 | 184 | ||
497 | 177 | TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierOnMaxMonitor) | 185 | TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierOnMaxMonitor) |
498 | @@ -181,11 +189,8 @@ | |||
499 | 181 | MockPointerBarrier owner(monitor); | 189 | MockPointerBarrier owner(monitor); |
500 | 182 | auto breaking_barrier_event = MakeBarrierEvent(0, true); | 190 | auto breaking_barrier_event = MakeBarrierEvent(0, true); |
501 | 183 | 191 | ||
502 | 184 | // This was leading to a crash, see bug #1020075 | ||
503 | 185 | // you can reproduce this repeating this test multiple times using the | ||
504 | 186 | // --gtest_repeat=X command line | ||
505 | 187 | EXPECT_CALL(owner, ReleaseBarrier(_)); | 192 | EXPECT_CALL(owner, ReleaseBarrier(_)); |
507 | 188 | bc.ProcessBarrierEvent(&owner, breaking_barrier_event); | 193 | ProcessBarrierEvent(&owner, breaking_barrier_event); |
508 | 189 | } | 194 | } |
509 | 190 | 195 | ||
510 | 191 | TEST_F(TestEdgeBarrierController, ProcessUnHandledEventNotBreakingBarrier) | 196 | TEST_F(TestEdgeBarrierController, ProcessUnHandledEventNotBreakingBarrier) |
511 | @@ -197,7 +202,7 @@ | |||
512 | 197 | auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false); | 202 | auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false); |
513 | 198 | 203 | ||
514 | 199 | EXPECT_CALL(owner, ReleaseBarrier(not_breaking_id)).Times(0); | 204 | EXPECT_CALL(owner, ReleaseBarrier(not_breaking_id)).Times(0); |
516 | 200 | bc.ProcessBarrierEvent(&owner, not_breaking_barrier_event); | 205 | ProcessBarrierEvent(&owner, not_breaking_barrier_event); |
517 | 201 | } | 206 | } |
518 | 202 | 207 | ||
519 | 203 | TEST_F(TestEdgeBarrierController, ProcessUnHandledEventOnReleasedBarrier) | 208 | TEST_F(TestEdgeBarrierController, ProcessUnHandledEventOnReleasedBarrier) |
520 | @@ -209,7 +214,69 @@ | |||
521 | 209 | auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false); | 214 | auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false); |
522 | 210 | 215 | ||
523 | 211 | EXPECT_CALL(owner, ReleaseBarrier(not_breaking_id)); | 216 | EXPECT_CALL(owner, ReleaseBarrier(not_breaking_id)); |
525 | 212 | bc.ProcessBarrierEvent(&owner, not_breaking_barrier_event); | 217 | ProcessBarrierEvent(&owner, not_breaking_barrier_event); |
526 | 218 | } | ||
527 | 219 | |||
528 | 220 | TEST_F(TestEdgeBarrierController, ProcessAlreadyHandledEvent) | ||
529 | 221 | { | ||
530 | 222 | int monitor = g_random_int_range(0, max_num_monitors); | ||
531 | 223 | |||
532 | 224 | MockPointerBarrier owner(monitor); | ||
533 | 225 | subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::ALREADY_HANDLED; | ||
534 | 226 | |||
535 | 227 | auto event = MakeBarrierEvent(g_random_int(), false); | ||
536 | 228 | |||
537 | 229 | EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0); | ||
538 | 230 | ProcessBarrierEvent(&owner, event); | ||
539 | 231 | EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity); | ||
540 | 232 | } | ||
541 | 233 | |||
542 | 234 | TEST_F(TestEdgeBarrierController, ProcessIgnoredEventWithStickyEdges) | ||
543 | 235 | { | ||
544 | 236 | int monitor = g_random_int_range(0, max_num_monitors); | ||
545 | 237 | |||
546 | 238 | bc.sticky_edges = true; | ||
547 | 239 | MockPointerBarrier owner(monitor); | ||
548 | 240 | subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED; | ||
549 | 241 | |||
550 | 242 | auto event = MakeBarrierEvent(g_random_int(), false); | ||
551 | 243 | |||
552 | 244 | EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0); | ||
553 | 245 | ProcessBarrierEvent(&owner, event); | ||
554 | 246 | EXPECT_FALSE(owner.released()); | ||
555 | 247 | EXPECT_FALSE(owner.release_once()); | ||
556 | 248 | EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity); | ||
557 | 249 | } | ||
558 | 250 | |||
559 | 251 | TEST_F(TestEdgeBarrierController, ProcessIgnoredEventWithOutStickyEdges) | ||
560 | 252 | { | ||
561 | 253 | int monitor = g_random_int_range(0, max_num_monitors); | ||
562 | 254 | |||
563 | 255 | bc.sticky_edges = false; | ||
564 | 256 | MockPointerBarrier owner(monitor); | ||
565 | 257 | subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED; | ||
566 | 258 | |||
567 | 259 | auto event = MakeBarrierEvent(g_random_int(), false); | ||
568 | 260 | |||
569 | 261 | EXPECT_CALL(owner, ReleaseBarrier(event->event_id)); | ||
570 | 262 | ProcessBarrierEvent(&owner, event); | ||
571 | 263 | EXPECT_TRUE(owner.released()); | ||
572 | 264 | EXPECT_TRUE(owner.release_once()); | ||
573 | 265 | EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0); | ||
574 | 266 | } | ||
575 | 267 | |||
576 | 268 | TEST_F(TestEdgeBarrierController, ProcessNeedsReleaseEvent) | ||
577 | 269 | { | ||
578 | 270 | int monitor = g_random_int_range(0, max_num_monitors); | ||
579 | 271 | |||
580 | 272 | MockPointerBarrier owner(monitor); | ||
581 | 273 | subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::NEEDS_RELEASE; | ||
582 | 274 | |||
583 | 275 | auto event = MakeBarrierEvent(g_random_int(), false); | ||
584 | 276 | |||
585 | 277 | EXPECT_CALL(owner, ReleaseBarrier(event->event_id)); | ||
586 | 278 | ProcessBarrierEvent(&owner, event); | ||
587 | 279 | EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0); | ||
588 | 213 | } | 280 | } |
589 | 214 | 281 | ||
590 | 215 | TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrier) | 282 | TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrier) |
591 | @@ -217,7 +284,7 @@ | |||
592 | 217 | MockPointerBarrier owner; | 284 | MockPointerBarrier owner; |
593 | 218 | 285 | ||
594 | 219 | EXPECT_CALL(owner, ReleaseBarrier(1)); | 286 | EXPECT_CALL(owner, ReleaseBarrier(1)); |
596 | 220 | bc.ProcessBarrierEvent(&owner, MakeBarrierEvent(1, true)); | 287 | ProcessBarrierEvent(&owner, MakeBarrierEvent(1, true)); |
597 | 221 | ASSERT_TRUE(owner.released()); | 288 | ASSERT_TRUE(owner.released()); |
598 | 222 | 289 | ||
599 | 223 | Utils::WaitForTimeoutMSec(bc.options()->edge_passed_disabled_ms); | 290 | Utils::WaitForTimeoutMSec(bc.options()->edge_passed_disabled_ms); |
600 | @@ -228,30 +295,30 @@ | |||
601 | 228 | { | 295 | { |
602 | 229 | MockPointerBarrier owner; | 296 | MockPointerBarrier owner; |
603 | 230 | int monitor = 0; | 297 | int monitor = 0; |
605 | 231 | subscribers_[monitor].handles_ = false; | 298 | subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED; |
606 | 232 | 299 | ||
607 | 233 | EXPECT_CALL(owner, ReleaseBarrier(5)); | 300 | EXPECT_CALL(owner, ReleaseBarrier(5)); |
609 | 234 | bc.ProcessBarrierEvent(&owner, MakeBarrierEvent(5, true)); | 301 | ProcessBarrierEvent(&owner, MakeBarrierEvent(5, true)); |
610 | 235 | ASSERT_TRUE(owner.released()); | 302 | ASSERT_TRUE(owner.released()); |
611 | 236 | 303 | ||
613 | 237 | subscribers_[monitor].handles_ = false; | 304 | subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED; |
614 | 238 | EXPECT_CALL(owner, ReleaseBarrier(6)); | 305 | EXPECT_CALL(owner, ReleaseBarrier(6)); |
616 | 239 | bc.ProcessBarrierEvent(&owner, MakeBarrierEvent(6, false)); | 306 | ProcessBarrierEvent(&owner, MakeBarrierEvent(6, false)); |
617 | 240 | } | 307 | } |
618 | 241 | 308 | ||
619 | 242 | TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForHandledEvents) | 309 | TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForHandledEvents) |
620 | 243 | { | 310 | { |
621 | 244 | MockPointerBarrier owner; | 311 | MockPointerBarrier owner; |
622 | 245 | int monitor = 0; | 312 | int monitor = 0; |
624 | 246 | subscribers_[monitor].handles_ = false; | 313 | subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED; |
625 | 247 | 314 | ||
626 | 248 | EXPECT_CALL(owner, ReleaseBarrier(5)); | 315 | EXPECT_CALL(owner, ReleaseBarrier(5)); |
628 | 249 | bc.ProcessBarrierEvent(&owner, MakeBarrierEvent(5, true)); | 316 | ProcessBarrierEvent(&owner, MakeBarrierEvent(5, true)); |
629 | 250 | ASSERT_TRUE(owner.released()); | 317 | ASSERT_TRUE(owner.released()); |
630 | 251 | 318 | ||
632 | 252 | subscribers_[monitor].handles_ = true; | 319 | subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::HANDLED; |
633 | 253 | EXPECT_CALL(owner, ReleaseBarrier(6)).Times(1); | 320 | EXPECT_CALL(owner, ReleaseBarrier(6)).Times(1); |
635 | 254 | bc.ProcessBarrierEvent(&owner, MakeBarrierEvent(6, true)); | 321 | ProcessBarrierEvent(&owner, MakeBarrierEvent(6, true)); |
636 | 255 | } | 322 | } |
637 | 256 | 323 | ||
638 | 257 | TEST_F(TestEdgeBarrierController, StickyEdgePropertyProxiesLauncherOption) | 324 | TEST_F(TestEdgeBarrierController, StickyEdgePropertyProxiesLauncherOption) |
639 | @@ -269,4 +336,10 @@ | |||
640 | 269 | EXPECT_TRUE(bc.options()->edge_resist()); | 336 | EXPECT_TRUE(bc.options()->edge_resist()); |
641 | 270 | } | 337 | } |
642 | 271 | 338 | ||
643 | 339 | TEST_F(TestEdgeBarrierController, TestTheDirectionIsAlawysSetToBothSides) | ||
644 | 340 | { | ||
645 | 341 | for (auto barrier : GetPrivateImpl()->barriers_) | ||
646 | 342 | ASSERT_EQ(barrier->direction, BarrierDirection::BOTH); | ||
647 | 343 | } | ||
648 | 344 | |||
649 | 272 | } | 345 | } |
650 | 273 | 346 | ||
651 | === modified file 'tests/test_launcher.cpp' | |||
652 | --- tests/test_launcher.cpp 2013-02-01 22:53:42 +0000 | |||
653 | +++ tests/test_launcher.cpp 2013-02-08 01:02:23 +0000 | |||
654 | @@ -54,11 +54,6 @@ | |||
655 | 54 | MOCK_METHOD1(Stick, void(bool)); | 54 | MOCK_METHOD1(Stick, void(bool)); |
656 | 55 | }; | 55 | }; |
657 | 56 | 56 | ||
658 | 57 | struct MockPointerBarrierWrapper : ui::PointerBarrierWrapper | ||
659 | 58 | { | ||
660 | 59 | MOCK_METHOD1(ReleaseBarrier, void(int event_id)); | ||
661 | 60 | }; | ||
662 | 61 | |||
663 | 62 | } | 57 | } |
664 | 63 | 58 | ||
665 | 64 | class TestLauncher : public Test | 59 | class TestLauncher : public Test |
666 | @@ -96,10 +91,12 @@ | |||
667 | 96 | using Launcher::ProcessDndLeave; | 91 | using Launcher::ProcessDndLeave; |
668 | 97 | using Launcher::ProcessDndMove; | 92 | using Launcher::ProcessDndMove; |
669 | 98 | using Launcher::ProcessDndDrop; | 93 | using Launcher::ProcessDndDrop; |
670 | 99 | using Launcher::_drag_icon_position; | ||
671 | 100 | |||
672 | 101 | using Launcher::IconStartingBlinkValue; | 94 | using Launcher::IconStartingBlinkValue; |
673 | 102 | using Launcher::IconStartingPulseValue; | 95 | using Launcher::IconStartingPulseValue; |
674 | 96 | using Launcher::HandleBarrierEvent; | ||
675 | 97 | using Launcher::SetHidden; | ||
676 | 98 | using Launcher::_drag_icon_position; | ||
677 | 99 | |||
678 | 103 | 100 | ||
679 | 104 | void FakeProcessDndMove(int x, int y, std::list<std::string> uris) | 101 | void FakeProcessDndMove(int x, int y, std::list<std::string> uris) |
680 | 105 | { | 102 | { |
681 | @@ -119,11 +116,6 @@ | |||
682 | 119 | 116 | ||
683 | 120 | _dnd_hovered_icon = MouseIconIntersection(x, y); | 117 | _dnd_hovered_icon = MouseIconIntersection(x, y); |
684 | 121 | } | 118 | } |
685 | 122 | |||
686 | 123 | bool HandleBarrierEvent(ui::PointerBarrierWrapper* barrier, ui::BarrierEvent::Ptr event) | ||
687 | 124 | { | ||
688 | 125 | return Launcher::HandleBarrierEvent(barrier, event); | ||
689 | 126 | } | ||
690 | 127 | }; | 119 | }; |
691 | 128 | 120 | ||
692 | 129 | TestLauncher() | 121 | TestLauncher() |
693 | @@ -454,15 +446,79 @@ | |||
694 | 454 | EXPECT_FALSE(mouse_entered); | 446 | EXPECT_FALSE(mouse_entered); |
695 | 455 | } | 447 | } |
696 | 456 | 448 | ||
698 | 457 | TEST_F(TestLauncher, EdgeResistDuringDnd) | 449 | TEST_F(TestLauncher, EdgeReleasesDuringDnd) |
699 | 458 | { | 450 | { |
701 | 459 | auto barrier = std::make_shared<MockPointerBarrierWrapper>(); | 451 | auto barrier = std::make_shared<ui::PointerBarrierWrapper>(); |
702 | 460 | auto event = std::make_shared<ui::BarrierEvent>(0, 0, 0, 100); | 452 | auto event = std::make_shared<ui::BarrierEvent>(0, 0, 0, 100); |
703 | 461 | 453 | ||
704 | 462 | launcher_->DndStarted(""); | 454 | launcher_->DndStarted(""); |
705 | 463 | 455 | ||
708 | 464 | EXPECT_CALL(*barrier, ReleaseBarrier(100)); | 456 | EXPECT_EQ(launcher_->HandleBarrierEvent(barrier.get(), event), |
709 | 465 | EXPECT_TRUE(launcher_->HandleBarrierEvent(barrier.get(), event)); | 457 | ui::EdgeBarrierSubscriber::Result::NEEDS_RELEASE); |
710 | 458 | } | ||
711 | 459 | |||
712 | 460 | TEST_F(TestLauncher, EdgeBarriersIgnoreEvents) | ||
713 | 461 | { | ||
714 | 462 | auto const& launcher_geo = launcher_->GetAbsoluteGeometry(); | ||
715 | 463 | auto barrier = std::make_shared<ui::PointerBarrierWrapper>(); | ||
716 | 464 | auto event = std::make_shared<ui::BarrierEvent>(0, 0, 0, 100); | ||
717 | 465 | launcher_->SetHidden(true); | ||
718 | 466 | |||
719 | 467 | event->x = launcher_geo.x-1; | ||
720 | 468 | event->y = launcher_geo.y; | ||
721 | 469 | EXPECT_EQ(launcher_->HandleBarrierEvent(barrier.get(), event), | ||
722 | 470 | ui::EdgeBarrierSubscriber::Result::IGNORED); | ||
723 | 471 | |||
724 | 472 | event->x = launcher_geo.x+launcher_geo.width+1; | ||
725 | 473 | event->y = launcher_geo.y; | ||
726 | 474 | EXPECT_EQ(launcher_->HandleBarrierEvent(barrier.get(), event), | ||
727 | 475 | ui::EdgeBarrierSubscriber::Result::IGNORED); | ||
728 | 476 | |||
729 | 477 | options_->reveal_trigger = RevealTrigger::EDGE; | ||
730 | 478 | event->x = launcher_geo.x+launcher_geo.width/2; | ||
731 | 479 | event->y = launcher_geo.y - 1; | ||
732 | 480 | EXPECT_EQ(launcher_->HandleBarrierEvent(barrier.get(), event), | ||
733 | 481 | ui::EdgeBarrierSubscriber::Result::IGNORED); | ||
734 | 482 | |||
735 | 483 | options_->reveal_trigger = RevealTrigger::CORNER; | ||
736 | 484 | event->x = launcher_geo.x+launcher_geo.width/2; | ||
737 | 485 | event->y = launcher_geo.y; | ||
738 | 486 | EXPECT_EQ(launcher_->HandleBarrierEvent(barrier.get(), event), | ||
739 | 487 | ui::EdgeBarrierSubscriber::Result::IGNORED); | ||
740 | 488 | } | ||
741 | 489 | |||
742 | 490 | TEST_F(TestLauncher, EdgeBarriersHandlesEvent) | ||
743 | 491 | { | ||
744 | 492 | auto const& launcher_geo = launcher_->GetAbsoluteGeometry(); | ||
745 | 493 | auto barrier = std::make_shared<ui::PointerBarrierWrapper>(); | ||
746 | 494 | auto event = std::make_shared<ui::BarrierEvent>(0, 0, 0, 100); | ||
747 | 495 | launcher_->SetHidden(true); | ||
748 | 496 | |||
749 | 497 | options_->reveal_trigger = RevealTrigger::EDGE; | ||
750 | 498 | |||
751 | 499 | for (int x = launcher_geo.x; x < launcher_geo.x+launcher_geo.width; ++x) | ||
752 | 500 | { | ||
753 | 501 | for (int y = launcher_geo.y; y < launcher_geo.y+launcher_geo.height; ++y) | ||
754 | 502 | { | ||
755 | 503 | event->x = x; | ||
756 | 504 | event->y = y; | ||
757 | 505 | ASSERT_EQ(launcher_->HandleBarrierEvent(barrier.get(), event), | ||
758 | 506 | ui::EdgeBarrierSubscriber::Result::HANDLED); | ||
759 | 507 | } | ||
760 | 508 | } | ||
761 | 509 | |||
762 | 510 | options_->reveal_trigger = RevealTrigger::CORNER; | ||
763 | 511 | |||
764 | 512 | for (int x = launcher_geo.x; x < launcher_geo.x+launcher_geo.width; ++x) | ||
765 | 513 | { | ||
766 | 514 | for (int y = launcher_geo.y-10; y < launcher_geo.y; ++y) | ||
767 | 515 | { | ||
768 | 516 | event->x = x; | ||
769 | 517 | event->y = y; | ||
770 | 518 | ASSERT_EQ(launcher_->HandleBarrierEvent(barrier.get(), event), | ||
771 | 519 | ui::EdgeBarrierSubscriber::Result::HANDLED); | ||
772 | 520 | } | ||
773 | 521 | } | ||
774 | 466 | } | 522 | } |
775 | 467 | 523 | ||
776 | 468 | TEST_F(TestLauncher, DndIsSpecialRequest) | 524 | TEST_F(TestLauncher, DndIsSpecialRequest) |
Awesome, looks good, and works well :).