Merge lp:~brandontschaefer/unity/move-pointer-barrier-to-xi-1.6.99.1 into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Merged at revision: 3407
Proposed branch: lp:~brandontschaefer/unity/move-pointer-barrier-to-xi-1.6.99.1
Merge into: lp:unity
Diff against target: 703 lines (+261/-152)
8 files modified
CMakeLists.txt (+2/-1)
debian/changelog (+4/-3)
debian/control (+1/-0)
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:~brandontschaefer/unity/move-pointer-barrier-to-xi-1.6.99.1
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Andrea Azzarone (community) Approve
Review via email: mp+150175@code.launchpad.net

Commit message

Move unity to the new libxi changes, along with the new 1.14 xserver.

Description of the change

Some big changes. Updating pointer barrier logic new versions of xfixes and xi (1.6.99.1).

Had to move a bunch of things around, due to the fact that we didn't handle any kind of XI2 events before. Also re worked somethings so they only run once now...before we had a bunch of things being ran every time a barrier was being created that was not necessary.

So now the new logic, simplified:
Mouse hits barrier, XIBarrierEvent generated and sent off.
Nux receives XEvent and passes it back to EdgeBarrierController.cpp::HandleEventCB
In HandleEventCB we check to see of the opcode matches, if so pass it to HandleEvent
In HandleEvent we check if its a type XI_BarrierHit
If so, then find the barrier wrapper the event belongs to.
(XGetEventData works onces per event, so the logic we had before didn't work).
From here we pass it to PointerBarrier.cpp::HandleBarrierEvent,
Here we are pretty much back to where we were before the changed :).

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) :
review: Approve
Revision history for this message
Sebastien Bacher (seb128) wrote :

trying to build with the old libxfixes it fails on:

"/usr/include/X11/extensions/XInput2.h:173:22: error: conflicting declaration ‘typedef unsigned int BarrierEventID’
  typedef unsigned int BarrierEventID;

the requirement/build-depends on that one should probably be bumped as well

works fine otherwise ;-)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:3175
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~brandontschaefer/unity/move-pointer-barrier-to-xi-1.6.99.1/+merge/150175/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/unity-ci/182/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity-saucy-amd64-ci/70/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity-saucy-armhf-ci/70/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity-saucy-i386-ci/70/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/unity-ci/182/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

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