Merge lp:~timo-jyrinki/unity/move-pointer-barries-to-xi-1.6.99.1_try2 into lp:unity
- move-pointer-barries-to-xi-1.6.99.1_try2
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 3407 |
Proposed branch: | lp:~timo-jyrinki/unity/move-pointer-barries-to-xi-1.6.99.1_try2 |
Merge into: | lp:unity |
Diff against target: |
714 lines (+264/-153) 8 files modified
CMakeLists.txt (+2/-1) debian/changelog (+4/-3) debian/control (+4/-1) launcher/EdgeBarrierController.cpp (+126/-3) launcher/EdgeBarrierControllerPrivate.h (+9/-0) launcher/PointerBarrier.cpp (+82/-94) launcher/PointerBarrier.h (+7/-5) tests/test_pointer_barrier.cpp (+30/-46) |
To merge this branch: | bzr merge lp:~timo-jyrinki/unity/move-pointer-barries-to-xi-1.6.99.1_try2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Sebastien Bacher | Approve | ||
Review via email: mp+172975@code.launchpad.net |
Commit message
Move unity to the new libxi changes, along with the new 1.14 xserver.
Description of the change
Move unity to the new libxi changes, along with the new 1.14 xserver.
(continuation from https:/
PS Jenkins bot (ps-jenkins) wrote : | # |
Sebastien Bacher (seb128) wrote : | # |
looks good and the new libraries are in saucy proposed
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2013-06-26 14:29:55 +0000 |
3 | +++ CMakeLists.txt 2013-07-04 09:08:30 +0000 |
4 | @@ -10,7 +10,7 @@ |
5 | set (PROJECT_NAME "unity") |
6 | set (UNITY_MAJOR 7) |
7 | set (UNITY_MINOR 0) |
8 | -set (UNITY_MICRO 1) |
9 | +set (UNITY_MICRO 2) |
10 | set (UNITY_VERSION "${UNITY_MAJOR}.${UNITY_MINOR}.${UNITY_MICRO}") |
11 | set (UNITY_API_VERSION "6.0") |
12 | set (UNITY_COMPONENTS_VERSION "6") |
13 | @@ -244,6 +244,7 @@ |
14 | libgeis |
15 | x11 |
16 | xfixes |
17 | + xi>=1.6.99.1 |
18 | xrender>=0.9 |
19 | ) |
20 | endif () |
21 | |
22 | === modified file 'debian/changelog' |
23 | --- debian/changelog 2013-07-03 04:03:34 +0000 |
24 | +++ debian/changelog 2013-07-04 09:08:30 +0000 |
25 | @@ -401,9 +401,6 @@ |
26 | unity (7.0.0daily13.05.08ubuntu.unity.next-0ubuntu1) raring; urgency=low |
27 | |
28 | * Automatic snapshot from revision 3317 (ubuntu-unity/next) |
29 | - |
30 | - -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 08 May 2013 04:57:49 +0000 |
31 | - |
32 | unity (7.0.0daily13.05.01.1ubuntu.unity.next-0ubuntu1) raring; urgency=low |
33 | |
34 | [ Sebastien Bacher ] |
35 | @@ -942,6 +939,10 @@ |
36 | [ Automatic PS uploader ] |
37 | * Automatic snapshot from revision 3140 |
38 | |
39 | + [ Brandon Schaefer ] |
40 | + * Moved PointerBarrier logic to the new xserver 1.14 (libXi 1.6.99.1) |
41 | + version. |
42 | + |
43 | -- Automatic PS uploader <ps-jenkins@lists.canonical.com> Fri, 08 Feb 2013 04:02:00 +0000 |
44 | |
45 | unity (6.12.0daily13.02.07-0ubuntu1) raring; urgency=low |
46 | |
47 | === modified file 'debian/control' |
48 | --- debian/control 2013-07-02 09:30:43 +0000 |
49 | +++ debian/control 2013-07-04 09:08:30 +0000 |
50 | @@ -43,7 +43,8 @@ |
51 | libunity-dev (>= 7.0.2), |
52 | libunity-scopes-json-def-desktop, |
53 | libzeitgeist-dev (>= 0.3.18), |
54 | - libxfixes-dev (>= 1:5.0-4ubuntu4), |
55 | + libxfixes-dev (>= 1:5.0.1-1), |
56 | + libxi-dev (>= 2:1.6.99.1), |
57 | libxpathselect-dev (>=1.3), |
58 | libgtest-dev, |
59 | google-mock, |
60 | @@ -70,6 +71,8 @@ |
61 | dconf-cli, |
62 | unity-asset-pool (>= 0.8.18), |
63 | bamfdaemon, |
64 | + libxfixes3 (>= 1:5.0.1-1), |
65 | + libxi6 (>= 2:1.6.99.1), |
66 | Provides: indicator-renderer |
67 | Recommends: gnome-control-center-unity, |
68 | ${unity-default-masterscopes} |
69 | |
70 | === modified file 'launcher/EdgeBarrierController.cpp' |
71 | --- launcher/EdgeBarrierController.cpp 2013-04-02 01:57:03 +0000 |
72 | +++ launcher/EdgeBarrierController.cpp 2013-07-04 09:08:30 +0000 |
73 | @@ -21,6 +21,7 @@ |
74 | #include "EdgeBarrierController.h" |
75 | #include "EdgeBarrierControllerPrivate.h" |
76 | #include "Decaymulator.h" |
77 | +#include <NuxCore/Logger.h> |
78 | #include "unity-shared/UScreen.h" |
79 | #include "UnityCore/GLibSource.h" |
80 | |
81 | @@ -32,11 +33,50 @@ |
82 | namespace |
83 | { |
84 | int const Y_BREAK_BUFFER = 20; |
85 | -} |
86 | - |
87 | + int const MAJOR = 2; |
88 | + int const MINOR = 3; |
89 | +} |
90 | + |
91 | +DECLARE_LOGGER(logger, "unity.edge_barrier_controller"); |
92 | + |
93 | +int GetXI2OpCode() |
94 | +{ |
95 | + Display *dpy = nux::GetGraphicsDisplay()->GetX11Display(); |
96 | + |
97 | + int opcode, event_base, error_base; |
98 | + if (!XQueryExtension(dpy, "XFIXES", |
99 | + &opcode, |
100 | + &event_base, |
101 | + &error_base)) |
102 | + { |
103 | + LOG_ERROR(logger) << "Missing XFixes"; |
104 | + return -1; |
105 | + } |
106 | + |
107 | + if (!XQueryExtension (dpy, "XInputExtension", |
108 | + &opcode, |
109 | + &event_base, |
110 | + &error_base)) |
111 | + { |
112 | + LOG_ERROR(logger) << "Missing XInput"; |
113 | + return -1; |
114 | + } |
115 | + |
116 | + int maj = MAJOR; |
117 | + int min = MINOR; |
118 | + |
119 | + if (XIQueryVersion(dpy, &maj, &min) == BadRequest) |
120 | + { |
121 | + LOG_ERROR(logger) << "Need XInput version 2.3"; |
122 | + return -1; |
123 | + } |
124 | + |
125 | + return opcode; |
126 | +} |
127 | |
128 | EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent) |
129 | - : edge_overcome_pressure_(0) |
130 | + : xi2_opcode_(-1) |
131 | + , edge_overcome_pressure_(0) |
132 | , parent_(parent) |
133 | { |
134 | UScreen *uscreen = UScreen::GetDefault(); |
135 | @@ -68,6 +108,13 @@ |
136 | }); |
137 | SetupBarriers(UScreen::GetDefault()->GetMonitors()); |
138 | }); |
139 | + |
140 | + xi2_opcode_ = GetXI2OpCode(); |
141 | +} |
142 | + |
143 | +EdgeBarrierController::Impl::~Impl() |
144 | +{ |
145 | + nux::GetGraphicsDisplay()->RemoveEventFilter(this); |
146 | } |
147 | |
148 | void EdgeBarrierController::Impl::ResizeBarrierList(std::vector<nux::Geometry> const& layout) |
149 | @@ -86,6 +133,18 @@ |
150 | } |
151 | } |
152 | |
153 | +void SetupXI2Events() |
154 | +{ |
155 | + Display *dpy = nux::GetGraphicsDisplay()->GetX11Display(); |
156 | + |
157 | + unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 }; |
158 | + XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits }; |
159 | + |
160 | + XISetMask(mask.mask, XI_BarrierHit); |
161 | + XISetMask(mask.mask, XI_BarrierLeave); |
162 | + XISelectEvents (dpy, DefaultRootWindow(dpy), &mask, 1); |
163 | +} |
164 | + |
165 | void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const& layout) |
166 | { |
167 | bool edge_resist = parent_->sticky_edges(); |
168 | @@ -112,6 +171,9 @@ |
169 | barrier->ConstructBarrier(); |
170 | } |
171 | |
172 | + SetupXI2Events(); |
173 | + AddEventFilter(); |
174 | + |
175 | float decay_responsiveness_mult = ((parent_->options()->edge_responsiveness() - 1) * .3f) + 1; |
176 | decaymulator_.rate_of_decay = parent_->options()->edge_decay_rate() * decay_responsiveness_mult; |
177 | |
178 | @@ -119,6 +181,67 @@ |
179 | edge_overcome_pressure_ = parent_->options()->edge_overcome_pressure() * overcome_responsiveness_mult; |
180 | } |
181 | |
182 | +void EdgeBarrierController::Impl::AddEventFilter() |
183 | +{ |
184 | + // Remove an old one, if it exists |
185 | + nux::GetGraphicsDisplay()->RemoveEventFilter(this); |
186 | + |
187 | + nux::GraphicsDisplay::EventFilterArg event_filter; |
188 | + event_filter.filter = &HandleEventCB; |
189 | + event_filter.data = this; |
190 | + |
191 | + nux::GetGraphicsDisplay()->AddEventFilter(event_filter); |
192 | +} |
193 | + |
194 | +bool EdgeBarrierController::Impl::HandleEvent(XEvent xevent) |
195 | +{ |
196 | + Display *dpy = nux::GetGraphicsDisplay()->GetX11Display(); |
197 | + XGenericEventCookie *cookie = &xevent.xcookie; |
198 | + bool ret = false; |
199 | + |
200 | + switch (cookie->evtype) |
201 | + { |
202 | + case (XI_BarrierHit): |
203 | + { |
204 | + if (XGetEventData(dpy, cookie)) |
205 | + { |
206 | + XIBarrierEvent* barrier_event = (XIBarrierEvent*)cookie->data; |
207 | + PointerBarrierWrapper::Ptr wrapper = FindBarrierEventOwner(barrier_event); |
208 | + |
209 | + if (wrapper) |
210 | + ret = wrapper->HandleBarrierEvent(barrier_event); |
211 | + } |
212 | + |
213 | + XFreeEventData(dpy, cookie); |
214 | + break; |
215 | + } |
216 | + default: |
217 | + break; |
218 | + } |
219 | + |
220 | + return ret; |
221 | +} |
222 | + |
223 | +bool EdgeBarrierController::Impl::HandleEventCB(XEvent xevent, void* data) |
224 | +{ |
225 | + auto edge_barrier_controller = static_cast<EdgeBarrierController::Impl*>(data); |
226 | + int const xi2_opcode = edge_barrier_controller->xi2_opcode_; |
227 | + |
228 | + if (xevent.type != GenericEvent || xevent.xcookie.extension != xi2_opcode) |
229 | + return false; |
230 | + |
231 | + return edge_barrier_controller->HandleEvent(xevent); |
232 | +} |
233 | + |
234 | +PointerBarrierWrapper::Ptr EdgeBarrierController::Impl::FindBarrierEventOwner(XIBarrierEvent* barrier_event) |
235 | +{ |
236 | + for (auto barrier : barriers_) |
237 | + if (barrier->OwnsBarrierEvent(barrier_event->barrier)) |
238 | + return barrier; |
239 | + |
240 | + return nullptr; |
241 | +} |
242 | + |
243 | void EdgeBarrierController::Impl::BarrierReset() |
244 | { |
245 | decaymulator_.value = 0; |
246 | |
247 | === modified file 'launcher/EdgeBarrierControllerPrivate.h' |
248 | --- launcher/EdgeBarrierControllerPrivate.h 2013-02-13 19:21:49 +0000 |
249 | +++ launcher/EdgeBarrierControllerPrivate.h 2013-07-04 09:08:30 +0000 |
250 | @@ -33,6 +33,7 @@ |
251 | struct EdgeBarrierController::Impl |
252 | { |
253 | Impl(EdgeBarrierController *parent); |
254 | + ~Impl(); |
255 | |
256 | void ResizeBarrierList(std::vector<nux::Geometry> const& layout); |
257 | void SetupBarriers(std::vector<nux::Geometry> const& layout); |
258 | @@ -44,10 +45,18 @@ |
259 | |
260 | bool EventIsInsideYBreakZone(BarrierEvent::Ptr const& event); |
261 | |
262 | + void AddEventFilter(); |
263 | + |
264 | + PointerBarrierWrapper::Ptr FindBarrierEventOwner(XIBarrierEvent* barrier_event); |
265 | + |
266 | + static bool HandleEventCB(XEvent event, void* data); |
267 | + bool HandleEvent(XEvent event); |
268 | + |
269 | std::vector<PointerBarrierWrapper::Ptr> barriers_; |
270 | std::vector<EdgeBarrierSubscriber*> subscribers_; |
271 | Decaymulator decaymulator_; |
272 | glib::Source::UniquePtr release_timeout_; |
273 | + int xi2_opcode_; |
274 | float edge_overcome_pressure_; |
275 | EdgeBarrierController* parent_; |
276 | }; |
277 | |
278 | === modified file 'launcher/PointerBarrier.cpp' |
279 | --- launcher/PointerBarrier.cpp 2013-02-11 23:57:09 +0000 |
280 | +++ launcher/PointerBarrier.cpp 2013-07-04 09:08:30 +0000 |
281 | @@ -13,12 +13,14 @@ |
282 | * |
283 | * You should have received a copy of the GNU General Public License |
284 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
285 | +* |
286 | +* Authored by: Jason Smith <jason.smith@canonical.com> |
287 | +* Brandon Schaefer <brandon.schaefer@canonical.com> |
288 | +* |
289 | */ |
290 | |
291 | #include <unistd.h> |
292 | #include <stdlib.h> |
293 | -#include <stdio.h> |
294 | -#include <X11/extensions/Xfixes.h> |
295 | |
296 | #include "PointerBarrier.h" |
297 | |
298 | @@ -27,14 +29,6 @@ |
299 | namespace ui |
300 | { |
301 | |
302 | -namespace local |
303 | -{ |
304 | -namespace |
305 | -{ |
306 | - bool is_selected_for = false; |
307 | -} |
308 | -} |
309 | - |
310 | PointerBarrierWrapper::PointerBarrierWrapper() |
311 | : active(false) |
312 | , released(false) |
313 | @@ -42,10 +36,11 @@ |
314 | , smoothing(75) |
315 | , max_velocity_multiplier(1.0f) |
316 | , direction(BOTH) |
317 | - , event_base_(0) |
318 | + , xi2_opcode_(0) |
319 | , last_event_(0) |
320 | + , current_device_(0) |
321 | , first_event_(false) |
322 | - , barrier(0) |
323 | + , barrier_(0) |
324 | , smoothing_count_(0) |
325 | , smoothing_accum_(0) |
326 | {} |
327 | @@ -62,34 +57,14 @@ |
328 | |
329 | Display *dpy = nux::GetGraphicsDisplay()->GetX11Display(); |
330 | |
331 | - int error_base; |
332 | - XFixesQueryExtension(dpy, &event_base_, &error_base); |
333 | - |
334 | - int maj,min; |
335 | - XFixesQueryVersion(dpy, &maj, &min); |
336 | - |
337 | - barrier = XFixesCreatePointerBarrierVelocity(dpy, |
338 | - DefaultRootWindow(dpy), |
339 | - x1, y1, |
340 | - x2, y2, |
341 | - static_cast<int>(direction), |
342 | - threshold, |
343 | - 0, |
344 | - NULL); |
345 | - |
346 | - if (!local::is_selected_for) |
347 | - { |
348 | - XFixesSelectBarrierInput(dpy, DefaultRootWindow(dpy), 0xdeadbeef); |
349 | - local::is_selected_for = true; |
350 | - } |
351 | + barrier_ = XFixesCreatePointerBarrier(dpy, |
352 | + DefaultRootWindow(dpy), |
353 | + x1, y1, |
354 | + x2, y2, |
355 | + static_cast<int>(direction), |
356 | + 0, NULL); |
357 | |
358 | active = true; |
359 | - |
360 | - nux::GraphicsDisplay::EventFilterArg event_filter; |
361 | - event_filter.filter = &PointerBarrierWrapper::HandleEventWrapper; |
362 | - event_filter.data = this; |
363 | - |
364 | - nux::GetGraphicsDisplay()->AddEventFilter(event_filter); |
365 | } |
366 | |
367 | void PointerBarrierWrapper::DestroyBarrier() |
368 | @@ -100,14 +75,13 @@ |
369 | active = false; |
370 | |
371 | Display *dpy = nux::GetGraphicsDisplay()->GetX11Display(); |
372 | - XFixesDestroyPointerBarrier(dpy, barrier); |
373 | - |
374 | - nux::GetGraphicsDisplay()->RemoveEventFilter(this); |
375 | + XFixesDestroyPointerBarrier(dpy, barrier_); |
376 | } |
377 | |
378 | void PointerBarrierWrapper::ReleaseBarrier(int event_id) |
379 | { |
380 | - XFixesBarrierReleasePointer(nux::GetGraphicsDisplay()->GetX11Display(), barrier, event_id); |
381 | + Display *dpy = nux::GetGraphicsDisplay()->GetX11Display(); |
382 | + XIBarrierReleasePointer(dpy, current_device_, barrier_, event_id); |
383 | } |
384 | |
385 | void PointerBarrierWrapper::EmitCurrentData(int event_id, int x, int y) |
386 | @@ -134,63 +108,77 @@ |
387 | return first_event_; |
388 | } |
389 | |
390 | -bool PointerBarrierWrapper::HandleEvent(XEvent xevent) |
391 | -{ |
392 | - if (xevent.type - event_base_ == XFixesBarrierNotify) |
393 | - { |
394 | - auto notify_event = reinterpret_cast<XFixesBarrierNotifyEvent*>(&xevent); |
395 | - |
396 | - if (notify_event->barrier == barrier && notify_event->subtype == XFixesBarrierHitNotify) |
397 | +int GetEventVelocity(XIBarrierEvent* event) |
398 | +{ |
399 | + double dx, dy; |
400 | + double speed; |
401 | + unsigned int millis; |
402 | + |
403 | + dx = event->dx; |
404 | + dy = event->dy; |
405 | + |
406 | + // Sometimes dtime is 0, if so we don't want to divide by zero! |
407 | + millis = event->dtime ?: 1; |
408 | + |
409 | + speed = sqrt(dx * dx + dy * dy) / millis * 1000; |
410 | + |
411 | + return speed; |
412 | +} |
413 | + |
414 | +bool PointerBarrierWrapper::OwnsBarrierEvent(PointerBarrier const barrier) const |
415 | +{ |
416 | + return barrier_ == barrier; |
417 | +} |
418 | + |
419 | +bool PointerBarrierWrapper::HandleBarrierEvent(XIBarrierEvent* barrier_event) |
420 | +{ |
421 | + int velocity = GetEventVelocity(barrier_event); |
422 | + smoothing_accum_ += velocity; |
423 | + smoothing_count_++; |
424 | + |
425 | + current_device_ = barrier_event->deviceid; |
426 | + |
427 | + if (velocity > threshold) |
428 | + { |
429 | + smoothing_timeout_.reset(); |
430 | + ReleaseBarrier(barrier_event->eventid); |
431 | + } |
432 | + else if (released) |
433 | + { |
434 | + /* If the barrier is released, just emit the current event without |
435 | + * waiting, so there won't be any delay on releasing the barrier. */ |
436 | + smoothing_timeout_.reset(); |
437 | + |
438 | + SendBarrierEvent(barrier_event->root_x, barrier_event->root_y, |
439 | + velocity, barrier_event->eventid); |
440 | + } |
441 | + else if (!smoothing_timeout_) |
442 | + { |
443 | + int x = barrier_event->root_x; |
444 | + int y = barrier_event->root_y; |
445 | + int event = barrier_event->eventid; |
446 | + |
447 | + // If we are a new event, don't delay sending the first event |
448 | + if (last_event_ != event) |
449 | { |
450 | - smoothing_accum_ += notify_event->velocity; |
451 | - smoothing_count_++; |
452 | - |
453 | - if (released) |
454 | - { |
455 | - /* If the barrier is released, just emit the current event without |
456 | - * waiting, so there won't be any delay on releasing the barrier. */ |
457 | - smoothing_timeout_.reset(); |
458 | - |
459 | - SendBarrierEvent(notify_event->x, notify_event->y, |
460 | - notify_event->velocity, notify_event->event_id); |
461 | - } |
462 | - else if (!smoothing_timeout_) |
463 | - { |
464 | - int x = notify_event->x; |
465 | - int y = notify_event->y; |
466 | - int event = notify_event->event_id; |
467 | - |
468 | - // If we are a new event, don't delay sending the first event |
469 | - if (last_event_ != event) |
470 | - { |
471 | - first_event_ = true; |
472 | - last_event_ = event; |
473 | - |
474 | - SendBarrierEvent(notify_event->x, notify_event->y, |
475 | - notify_event->velocity, notify_event->event_id); |
476 | - |
477 | - first_event_ = false; |
478 | - } |
479 | - |
480 | - smoothing_timeout_.reset(new glib::Timeout(smoothing, [this, event, x, y] () { |
481 | - EmitCurrentData(event, x, y); |
482 | - |
483 | - smoothing_timeout_.reset(); |
484 | - return false; |
485 | - })); |
486 | - } |
487 | + first_event_ = true; |
488 | + last_event_ = event; |
489 | + |
490 | + SendBarrierEvent(barrier_event->root_x, barrier_event->root_y, |
491 | + velocity, barrier_event->eventid); |
492 | + |
493 | + first_event_ = false; |
494 | } |
495 | |
496 | - return notify_event->barrier == barrier; |
497 | + smoothing_timeout_.reset(new glib::Timeout(smoothing, [this, event, x, y] () { |
498 | + EmitCurrentData(event, x, y); |
499 | + |
500 | + smoothing_timeout_.reset(); |
501 | + return false; |
502 | + })); |
503 | } |
504 | |
505 | - return false; |
506 | -} |
507 | - |
508 | -bool PointerBarrierWrapper::HandleEventWrapper(XEvent event, void* data) |
509 | -{ |
510 | - PointerBarrierWrapper* wrapper = (PointerBarrierWrapper*)data; |
511 | - return wrapper->HandleEvent(event); |
512 | + return true; |
513 | } |
514 | |
515 | } |
516 | |
517 | === modified file 'launcher/PointerBarrier.h' |
518 | --- launcher/PointerBarrier.h 2013-02-11 23:57:09 +0000 |
519 | +++ launcher/PointerBarrier.h 2013-07-04 09:08:30 +0000 |
520 | @@ -23,6 +23,7 @@ |
521 | #include <Nux/Nux.h> |
522 | #include <X11/Xlib.h> |
523 | #include <X11/extensions/Xfixes.h> |
524 | +#include <X11/extensions/XInput2.h> |
525 | #include <UnityCore/GLibSource.h> |
526 | |
527 | namespace unity |
528 | @@ -88,19 +89,20 @@ |
529 | |
530 | bool IsFirstEvent() const; |
531 | |
532 | + bool OwnsBarrierEvent(PointerBarrier const barrier) const; |
533 | + bool HandleBarrierEvent(XIBarrierEvent* barrier_event); |
534 | + |
535 | protected: |
536 | void EmitCurrentData(int event_id, int x, int y); |
537 | - bool HandleEvent(XEvent event); |
538 | |
539 | private: |
540 | - static bool HandleEventWrapper(XEvent event, void* data); |
541 | - |
542 | void SendBarrierEvent(int x, int y, int velocity, int event_id); |
543 | |
544 | - int event_base_; |
545 | + int xi2_opcode_; |
546 | int last_event_; |
547 | + int current_device_; |
548 | bool first_event_; |
549 | - PointerBarrier barrier; |
550 | + PointerBarrier barrier_; |
551 | |
552 | int smoothing_count_; |
553 | int smoothing_accum_; |
554 | |
555 | === modified file 'tests/test_pointer_barrier.cpp' |
556 | --- tests/test_pointer_barrier.cpp 2013-02-12 23:48:23 +0000 |
557 | +++ tests/test_pointer_barrier.cpp 2013-07-04 09:08:30 +0000 |
558 | @@ -15,6 +15,7 @@ |
559 | * <http://www.gnu.org/licenses/> |
560 | * |
561 | * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com> |
562 | + * Brandon Schaefer <brandon.schaefer@canonical.com> |
563 | * |
564 | */ |
565 | |
566 | @@ -32,20 +33,21 @@ |
567 | class MockPointerBarrier : public PointerBarrierWrapper |
568 | { |
569 | public: |
570 | - bool HandleEvent(XEvent ev) { return PointerBarrierWrapper::HandleEvent(ev); } |
571 | + bool HandleBarrierEvent(XIBarrierEvent* b_ev) { return PointerBarrierWrapper::HandleBarrierEvent(b_ev); } |
572 | }; |
573 | |
574 | -XFixesBarrierNotifyEvent GetGenericEvent (unsigned int id) |
575 | +XIBarrierEvent GetGenericEvent (unsigned int id) |
576 | { |
577 | - XFixesBarrierNotifyEvent ev; |
578 | + XIBarrierEvent ev; |
579 | |
580 | - ev.type = XFixesBarrierNotify; |
581 | - ev.subtype = XFixesBarrierHitNotify; |
582 | + ev.evtype = GenericEvent; |
583 | ev.barrier = 0; |
584 | - ev.event_id = id; |
585 | - ev.x = 555; |
586 | - ev.y = 333; |
587 | - ev.velocity = std::numeric_limits<int>::max(); |
588 | + ev.eventid = id; |
589 | + ev.root_x = 555; |
590 | + ev.root_y = 333; |
591 | + ev.dx = 10; |
592 | + ev.dy = 10; |
593 | + ev.dtime = 15; |
594 | |
595 | return ev; |
596 | } |
597 | @@ -70,29 +72,11 @@ |
598 | EXPECT_EQ(bev.event_id, 4); |
599 | } |
600 | |
601 | -TEST(TestPointerBarrier, HandleInvalidEvents) |
602 | -{ |
603 | - MockPointerBarrier pb; |
604 | - XFixesBarrierNotifyEvent ev; |
605 | - auto xev = reinterpret_cast<XEvent*>(&ev); |
606 | - |
607 | - ev.type = XFixesBarrierNotify + 1; |
608 | - EXPECT_FALSE(pb.HandleEvent(*xev)); |
609 | - |
610 | - ev.type = XFixesBarrierNotify; |
611 | - ev.subtype = XFixesBarrierHitNotify + 1; |
612 | - ev.barrier = 1; |
613 | - EXPECT_FALSE(pb.HandleEvent(*xev)); |
614 | - |
615 | - ev.barrier = 0; |
616 | - EXPECT_TRUE(pb.HandleEvent(*xev)); |
617 | -} |
618 | - |
619 | TEST(TestPointerBarrier, HandleHitNotifyEvents) |
620 | { |
621 | MockPointerBarrier pb; |
622 | - XFixesBarrierNotifyEvent ev = GetGenericEvent(0xdeadbeef); |
623 | - auto xev = reinterpret_cast<XEvent*>(&ev); |
624 | + pb.threshold = 1000; |
625 | + XIBarrierEvent ev = GetGenericEvent(0xdeadbeef); |
626 | |
627 | bool got_event = false; |
628 | |
629 | @@ -102,14 +86,14 @@ |
630 | got_event = true; |
631 | |
632 | EXPECT_EQ(pbw, &pb); |
633 | - EXPECT_EQ(bev->x, ev.x); |
634 | - EXPECT_EQ(bev->y, ev.y); |
635 | + EXPECT_EQ(bev->x, ev.root_x); |
636 | + EXPECT_EQ(bev->y, ev.root_y); |
637 | EXPECT_EQ(bev->velocity, 600 * pb.max_velocity_multiplier); |
638 | - EXPECT_EQ(bev->event_id, ev.event_id); |
639 | + EXPECT_EQ(bev->event_id, ev.eventid); |
640 | } |
641 | }); |
642 | |
643 | - EXPECT_TRUE(pb.HandleEvent(*xev)); |
644 | + EXPECT_TRUE(pb.HandleBarrierEvent(&ev)); |
645 | EXPECT_FALSE(got_event); |
646 | |
647 | Utils::WaitForTimeoutMSec(pb.smoothing()); |
648 | @@ -120,30 +104,30 @@ |
649 | TEST(TestPointerBarrier, HandleHitNotifyReleasedEvents) |
650 | { |
651 | MockPointerBarrier pb; |
652 | - XFixesBarrierNotifyEvent ev = GetGenericEvent(0xabba); |
653 | - auto xev = reinterpret_cast<XEvent*>(&ev); |
654 | + pb.threshold = 1000; |
655 | + XIBarrierEvent ev = GetGenericEvent(0xabba); |
656 | bool got_event = false; |
657 | |
658 | pb.barrier_event.connect([&] (PointerBarrierWrapper* pbw, BarrierEvent::Ptr bev) { |
659 | got_event = true; |
660 | |
661 | EXPECT_EQ(pbw, &pb); |
662 | - EXPECT_EQ(bev->x, ev.x); |
663 | - EXPECT_EQ(bev->y, ev.y); |
664 | - EXPECT_EQ(bev->velocity, ev.velocity); |
665 | - EXPECT_EQ(bev->event_id, ev.event_id); |
666 | + EXPECT_EQ(bev->x, ev.root_x); |
667 | + EXPECT_EQ(bev->y, ev.root_y); |
668 | + EXPECT_GT(bev->velocity, 0); |
669 | + EXPECT_EQ(bev->event_id, ev.eventid); |
670 | }); |
671 | |
672 | pb.released = true; |
673 | - EXPECT_TRUE(pb.HandleEvent(*xev)); |
674 | + EXPECT_TRUE(pb.HandleBarrierEvent(&ev)); |
675 | EXPECT_TRUE(got_event); |
676 | } |
677 | |
678 | TEST(TestPointerBarrier, ReciveFirstEvent) |
679 | { |
680 | MockPointerBarrier pb; |
681 | - XFixesBarrierNotifyEvent ev = GetGenericEvent(0xabba); |
682 | - auto xev = reinterpret_cast<XEvent*>(&ev); |
683 | + pb.threshold = 1000; |
684 | + XIBarrierEvent ev = GetGenericEvent(0xabba); |
685 | |
686 | bool first_is_true = false; |
687 | |
688 | @@ -151,15 +135,15 @@ |
689 | first_is_true = true; |
690 | }); |
691 | |
692 | - EXPECT_TRUE(pb.HandleEvent(*xev)); |
693 | + EXPECT_TRUE(pb.HandleBarrierEvent(&ev)); |
694 | EXPECT_TRUE(first_is_true); |
695 | } |
696 | |
697 | TEST(TestPointerBarrier, ReciveSecondEventFirstFalse) |
698 | { |
699 | MockPointerBarrier pb; |
700 | - XFixesBarrierNotifyEvent ev = GetGenericEvent(0xabba); |
701 | - auto xev = reinterpret_cast<XEvent*>(&ev); |
702 | + pb.threshold = 1000; |
703 | + XIBarrierEvent ev = GetGenericEvent(0xabba); |
704 | int events_recived = 0; |
705 | |
706 | pb.barrier_event.connect([&] (PointerBarrierWrapper* pbw, BarrierEvent::Ptr bev) { |
707 | @@ -171,7 +155,7 @@ |
708 | EXPECT_FALSE(pbw->IsFirstEvent()); |
709 | }); |
710 | |
711 | - EXPECT_TRUE(pb.HandleEvent(*xev)); |
712 | + EXPECT_TRUE(pb.HandleBarrierEvent(&ev)); |
713 | |
714 | Utils::WaitForTimeoutMSec(pb.smoothing()); |
715 |
FAILED: Continuous integration, rev:3177 jenkins. qa.ubuntu. com/job/ unity-ci/ 188/ jenkins. qa.ubuntu. com/job/ unity-saucy- amd64-ci/ 76/console jenkins. qa.ubuntu. com/job/ unity-saucy- armhf-ci/ 76/console jenkins. qa.ubuntu. com/job/ unity-saucy- i386-ci/ 76/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ unity-ci/ 188/rebuild
http://