Merge lp:~dandrader/frame/missing_backend_funcs into lp:frame

Proposed by Daniel d'Andrada
Status: Needs review
Proposed branch: lp:~dandrader/frame/missing_backend_funcs
Merge into: lp:frame
Diff against target: 240 lines (+116/-1)
9 files modified
configure.ac (+1/-1)
debian/changelog (+7/-0)
debian/libframe6.symbols (+4/-0)
include/oif/frame_backend.h (+30/-0)
src/frame.cpp (+23/-0)
src/frame.h (+1/-0)
src/libframe.ver (+7/-0)
src/touch.cpp (+12/-0)
test/regular/backend.cpp (+31/-0)
To merge this branch: bzr merge lp:~dandrader/frame/missing_backend_funcs
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Open Input Framework Team Pending
Review via email: mp+139447@code.launchpad.net

Commit message

Add some missing functions to frame_backend.h

Namely frame_backend_frame_borrow_touch_by_index(),
frame_backend_touch_set_window_x() and frame_backend_touch_set_window_x().

The later two were added so that we can set the window coordinates independently.
We had only frame_backend_touch_set_window_pos(touch, x, y).

Description of the change

Add some missing functions to frame_backend.h

Namely frame_backend_frame_borrow_touch_by_index(), frame_backend_touch_set_window_x() and frame_backend_touch_set_window_x().

The later two were added so that we can set the window coordinates independently. We had only frame_backend_touch_set_window_pos(touch, x, y).

To post a comment you must log in.
120. By Daniel d'Andrada

Update debian/libframe6.symbols

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

120. By Daniel d'Andrada

Update debian/libframe6.symbols

119. By Daniel d'Andrada

Added frame_backend_frame_borrow_touch_by_index()

118. By Daniel d'Andrada

Added frame_backend_touch_set_window_x() and [...]_y()

So that we can set the window coordinates independently.
We had only frame_backend_touch_set_window_pos(touch, x, y), and it's not
uncommon for events out of /dev/event/input* to update only one coordinate
(i.e. only one coordinate between EV_SYNCs)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2012-12-04 18:46:01 +0000
3+++ configure.ac 2012-12-12 11:49:20 +0000
4@@ -1,7 +1,7 @@
5 # Initialize Autoconf
6 AC_PREREQ([2.60])
7 AC_INIT([Touch Frame Library],
8- [2.5.0],
9+ [2.6.0],
10 [],
11 [frame])
12 AC_CONFIG_SRCDIR([Makefile.am])
13
14=== modified file 'debian/changelog'
15--- debian/changelog 2012-12-07 06:37:45 +0000
16+++ debian/changelog 2012-12-12 11:49:20 +0000
17@@ -1,3 +1,10 @@
18+frame (2.6.0daily12.12.11.1-0ubuntu1) UNRELEASED; urgency=low
19+
20+ * Added frame_backend_touch_set_window_x() and [...]_y()
21+ * Added frame_backend_frame_borrow_touch_by_index()
22+
23+ -- Daniel d'Andrada <daniel.dandrada@canonical.com> Tue, 11 Dec 2012 12:06:51 -0200
24+
25 frame (2.5.0daily12.12.07.1-0ubuntu1) raring; urgency=low
26
27 [ Daniel d'Andrada ]
28
29=== modified file 'debian/libframe6.symbols'
30--- debian/libframe6.symbols 2012-12-04 18:46:01 +0000
31+++ debian/libframe6.symbols 2012-12-12 11:49:20 +0000
32@@ -2,6 +2,10 @@
33 FRAME_2.2@FRAME_2.2 2.2.0
34 FRAME_2.4@FRAME_2.4 2.4.3
35 FRAME_2.5@FRAME_2.5 2.5.0
36+ FRAME_2.6@FRAME_2.6 2.6.0
37+ frame_backend_frame_borrow_touch_by_index@FRAME_2.6 2.6.0
38+ frame_backend_touch_set_window_x@FRAME_2.6 2.6.0
39+ frame_backend_touch_set_window_y@FRAME_2.6 2.6.0
40 frame_accept_touch@FRAME_2.5 2.5.0
41 frame_reject_touch@FRAME_2.5 2.5.0
42 frame_axis_get_maximum@FRAME_2.2 2.2.4
43
44=== modified file 'include/oif/frame_backend.h'
45--- include/oif/frame_backend.h 2012-12-11 13:49:50 +0000
46+++ include/oif/frame_backend.h 2012-12-12 11:49:20 +0000
47@@ -175,11 +175,26 @@
48 * will be made upon the first change made to it.
49 *
50 * Possible errors: UFStatusErrorInvalidTouch
51+ * \sa frame_backend_frame_borrow_touch_by_index
52 */
53 FRAME_PUBLIC
54 UFStatus frame_backend_frame_borrow_touch_by_id(UFBackendFrame frame,
55 UFTouchId id,
56 UFBackendTouch *touch);
57+/**
58+ * Gets a UFBackendTouch for the UFTouch in the specified index in the frame.
59+ *
60+ * Just like frame_backend_frame_borrow_touch_by_id, with the difference that
61+ * you specify a index inside the given frame instead of the id of the touch
62+ * you're interested in.
63+ *
64+ * Possible errors: UFStatusErrorInvalidTouch
65+ * \sa frame_backend_frame_borrow_touch_by_id
66+ */
67+FRAME_PUBLIC
68+UFStatus frame_backend_frame_borrow_touch_by_index(UFBackendFrame frame,
69+ unsigned int index,
70+ UFBackendTouch *touch);
71
72 /**
73 * Sets the "Device" property of the given frame
74@@ -257,11 +272,26 @@
75
76 /**
77 * Sets the "WindowX" and "WindowY" properties of the given touch
78+ * \sa frame_backend_touch_set_window_x, frame_backend_touch_set_window_y
79 */
80 FRAME_PUBLIC
81 void frame_backend_touch_set_window_pos(UFBackendTouch touch, float x, float y);
82
83 /**
84+ * Sets the "WindowX" property of the given touch
85+ * \sa frame_backend_touch_set_window_x, frame_backend_touch_set_window_pos
86+ */
87+FRAME_PUBLIC
88+void frame_backend_touch_set_window_x(UFBackendTouch touch, float x);
89+
90+/**
91+ * Sets the "WindowY" property of the given touch
92+ * \sa frame_backend_touch_set_window_pos, frame_backend_touch_set_window_y
93+ */
94+FRAME_PUBLIC
95+void frame_backend_touch_set_window_y(UFBackendTouch touch, float y);
96+
97+/**
98 * Sets the "Time" property of the given touch
99 */
100 FRAME_PUBLIC
101
102=== modified file 'src/frame.cpp'
103--- src/frame.cpp 2012-08-31 19:07:05 +0000
104+++ src/frame.cpp 2012-12-12 11:49:20 +0000
105@@ -180,6 +180,13 @@
106 return prev_->touches_array_[it->second]->GetValue(type, value);
107 }
108
109+SharedUFTouch* UFFrame::GetSharedTouchByIndex(unsigned int index) {
110+ if (index >= touches_array_.size())
111+ return nullptr;
112+ else
113+ return &(touches_array_[index]);
114+}
115+
116 UFStatus UFFrame::GetTouchByIndex(unsigned int index, ::UFTouch* touch) const {
117 if (index >= touches_array_.size())
118 return UFStatusErrorInvalidTouch;
119@@ -367,6 +374,22 @@
120 }
121 }
122
123+UFStatus frame_backend_frame_borrow_touch_by_index(UFBackendFrame frame,
124+ unsigned int index,
125+ UFBackendTouch *touch)
126+{
127+ oif::frame::UFFrame* ufframe =
128+ static_cast<oif::frame::UFFrame*>(frame->shared_ptr.get());
129+
130+ oif::frame::SharedUFTouch *shared_touch = ufframe->GetSharedTouchByIndex(index);
131+ if (shared_touch) {
132+ *touch = new UFBackendTouch_(*shared_touch);
133+ return UFStatusSuccess;
134+ } else {
135+ return UFStatusErrorInvalidTouch;
136+ }
137+}
138+
139 void frame_backend_frame_set_device(UFBackendFrame frame, UFBackendDevice device)
140 {
141 static_cast<oif::frame::UFFrame*>(frame->shared_ptr.get())->
142
143=== modified file 'src/frame.h'
144--- src/frame.h 2012-08-31 17:04:43 +0000
145+++ src/frame.h 2012-12-12 11:49:20 +0000
146@@ -58,6 +58,7 @@
147 float* value) const;
148 UFStatus GetPreviousTouchProperty(const UFTouch* touch,
149 UFTouchProperty property, void* value) const;
150+ SharedUFTouch* GetSharedTouchByIndex(unsigned int index);
151 UFStatus GetTouchByIndex(unsigned int index, ::UFTouch* touch) const;
152 SharedUFTouch* GetSharedTouchById(UFTouchId touch_id);
153 UFStatus GetTouchById(UFTouchId touch_id, ::UFTouch* touch) const;
154
155=== modified file 'src/libframe.ver'
156--- src/libframe.ver 2012-12-04 18:46:01 +0000
157+++ src/libframe.ver 2012-12-12 11:49:20 +0000
158@@ -109,3 +109,10 @@
159 frame_accept_touch;
160 frame_reject_touch;
161 } FRAME_2.4;
162+
163+FRAME_2.6 {
164+ global:
165+ frame_backend_frame_borrow_touch_by_index;
166+ frame_backend_touch_set_window_x;
167+ frame_backend_touch_set_window_y;
168+} FRAME_2.5;
169
170=== modified file 'src/touch.cpp'
171--- src/touch.cpp 2012-08-31 17:04:43 +0000
172+++ src/touch.cpp 2012-12-12 11:49:20 +0000
173@@ -264,6 +264,18 @@
174 touch->InsertProperty(UFTouchPropertyWindowY, new oif::frame::Value(y));
175 }
176
177+void frame_backend_touch_set_window_x(UFBackendTouch touch_backend, float x)
178+{
179+ oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch();
180+ touch->InsertProperty(UFTouchPropertyWindowX, new oif::frame::Value(x));
181+}
182+
183+void frame_backend_touch_set_window_y(UFBackendTouch touch_backend, float y)
184+{
185+ oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch();
186+ touch->InsertProperty(UFTouchPropertyWindowY, new oif::frame::Value(y));
187+}
188+
189 void frame_backend_touch_set_time(UFBackendTouch touch_backend, uint64_t time)
190 {
191 oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch();
192
193=== modified file 'test/regular/backend.cpp'
194--- test/regular/backend.cpp 2012-08-31 19:26:43 +0000
195+++ test/regular/backend.cpp 2012-12-12 11:49:20 +0000
196@@ -23,6 +23,12 @@
197 ASSERT_EQ(1.2f, frame_touch_get_window_x(touch));
198 ASSERT_EQ(3.4f, frame_touch_get_window_y(touch));
199
200+ frame_backend_touch_set_window_x(touch_backend, 5.6f);
201+ ASSERT_EQ(5.6f, frame_touch_get_window_x(touch));
202+
203+ frame_backend_touch_set_window_y(touch_backend, 7.8f);
204+ ASSERT_EQ(7.8f, frame_touch_get_window_y(touch));
205+
206 frame_backend_touch_set_time(touch_backend, 852);
207 ASSERT_EQ(852, frame_touch_get_time(touch));
208
209@@ -191,6 +197,31 @@
210 frame_backend_frame_delete(frame_backend);
211 }
212
213+TEST(Backend, FrameBorrowTouchByIndex)
214+{
215+ UFStatus status;
216+
217+ UFBackendFrame frame_backend = frame_backend_frame_new();
218+
219+ UFBackendTouch touch_backend = frame_backend_touch_new();
220+ frame_backend_touch_set_id(touch_backend, 12);
221+
222+ status = frame_backend_frame_give_touch(frame_backend, &touch_backend);
223+ ASSERT_EQ(UFStatusSuccess, status);
224+
225+ status = frame_backend_frame_borrow_touch_by_index(frame_backend, 0, &touch_backend);
226+ ASSERT_EQ(UFStatusSuccess, status);
227+
228+ UFTouch touch = frame_backend_touch_get_touch(touch_backend);
229+ ASSERT_EQ(12, frame_touch_get_id(touch));
230+
231+ status = frame_backend_frame_give_touch(frame_backend, &touch_backend);
232+ ASSERT_EQ(UFStatusSuccess, status);
233+
234+ /* clean up */
235+ frame_backend_frame_delete(frame_backend);
236+}
237+
238 TEST(Backend, FrameCreateNext)
239 {
240 UFStatus status;

Subscribers

People subscribed via source and target branches