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

Proposed by Daniel d'Andrada on 2012-12-05
Status: Merged
Approved by: Stephen M. Webb on 2012-12-05
Approved revision: 113
Merged at revision: 113
Proposed branch: lp:~dandrader/frame/non_x11_accept
Merge into: lp:frame
Diff against target: 341 lines (+181/-13)
11 files modified
configure.ac (+1/-1)
debian/libframe6.symbols (+3/-0)
include/oif/frame.h.in (+37/-0)
include/oif/frame_x11.h (+2/-0)
src/device.cpp (+28/-0)
src/device.h (+3/-0)
src/libframe.ver (+6/-0)
src/x11/device_x11.cpp (+12/-10)
src/x11/device_x11.h (+2/-2)
test/regular/Makefile.am (+1/-0)
test/regular/x11-accept-touch.cpp (+86/-0)
To merge this branch: bzr merge lp:~dandrader/frame/non_x11_accept
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) 2012-12-05 Approve on 2012-12-05
PS Jenkins bot continuous-integration Pending
Review via email: mp+138159@code.launchpad.net

Commit Message

new: frame_accept_touch() and frame_reject_touch()

So that grail code can be completely backend-agnostic.

Description of the Change

new: frame_accept_touch() and frame_reject_touch()

So that grail code can be completely backend-agnostic.

With that in place we can run tests in grail using frame_backend.h instead of a frame mock (as it is currently) to create the frame events.

To post a comment you must log in.
Stephen M. Webb (bregma) wrote :

OK.

I don't see any tests for the case of no X11, but the test coverage there is incomplete anyways.

review: Approve

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-11-29 15:30:50 +0000
3+++ configure.ac 2012-12-05 14:06:20 +0000
4@@ -1,7 +1,7 @@
5 # Initialize Autoconf
6 AC_PREREQ([2.60])
7 AC_INIT([Touch Frame Library],
8- [2.4.4],
9+ [2.5.0],
10 [],
11 [frame])
12 AC_CONFIG_SRCDIR([Makefile.am])
13
14=== modified file 'debian/libframe6.symbols'
15--- debian/libframe6.symbols 2012-11-22 22:16:27 +0000
16+++ debian/libframe6.symbols 2012-12-05 14:06:20 +0000
17@@ -1,6 +1,9 @@
18 libframe.so.6 libframe6 #MINVER#
19 FRAME_2.2@FRAME_2.2 2.2.0
20 FRAME_2.4@FRAME_2.4 2.4.3
21+ FRAME_2.5@FRAME_2.5 2.5.0
22+ frame_accept_touch@FRAME_2.5 2.5.0
23+ frame_reject_touch@FRAME_2.5 2.5.0
24 frame_axis_get_maximum@FRAME_2.2 2.2.4
25 frame_axis_get_minimum@FRAME_2.2 2.2.4
26 frame_axis_get_resolution@FRAME_2.2 2.2.4
27
28=== modified file 'include/oif/frame.h.in'
29--- include/oif/frame.h.in 2012-11-20 14:13:20 +0000
30+++ include/oif/frame.h.in 2012-12-05 14:06:20 +0000
31@@ -741,6 +741,43 @@
32 FRAME_PUBLIC
33 uint64_t frame_touch_get_start_time(UFTouch touch);
34
35+/**
36+ * Accept ownership of a touch
37+ *
38+ * All touches received should be eventally accepted or rejected.
39+ * This decision can come even after they have already ended but
40+ * should be done as soon as possible.
41+ *
42+ * You should accept a touch when you're going to use it and
43+ * reject it if you're not interested in it.
44+ *
45+ * Not all window servers have this concept. Those that do use
46+ * this information to pass rejected touches forward to other
47+ * clients that might want it.
48+ *
49+ * @param [in] device The device object for the touch (const)
50+ * @param [in] window The window to accept the touch for
51+ * @param [in] touch_id The touch ID object for the touch
52+ * @return UFStatusSuccess, UFStatusErrorInvalidTouch
53+ * @see frame_reject_touch
54+ */
55+FRAME_PUBLIC
56+UFStatus frame_accept_touch(UFDevice device, UFWindowId window,
57+ UFTouchId touch_id);
58+
59+/**
60+ * Reject ownership of a touch
61+ *
62+ * @param [in] device The device object for the touch (const)
63+ * @param [in] window The window to reject the touch for
64+ * @param [in] touch_id The touch ID object for the touch
65+ * @return UFStatusSuccess, UFStatusErrorInvalidTouch
66+ * @see frame_accept_touch
67+ */
68+FRAME_PUBLIC
69+UFStatus frame_reject_touch(UFDevice device, UFWindowId window,
70+ UFTouchId touch_id);
71+
72 /** @} */
73
74 #include "frame_internal.h"
75
76=== modified file 'include/oif/frame_x11.h'
77--- include/oif/frame_x11.h 2012-07-24 21:36:05 +0000
78+++ include/oif/frame_x11.h 2012-12-05 14:06:20 +0000
79@@ -71,6 +71,7 @@
80 /**
81 * Accept ownership of a touch
82 *
83+ * @deprecated Use frame_accept_touch instead.
84 * @param [in] device The device object for the touch (const)
85 * @param [in] window The window to accept the touch for
86 * @param [in] touch_id The touch ID object for the touch
87@@ -83,6 +84,7 @@
88 /**
89 * Reject ownership of a touch
90 *
91+ * @deprecated Use frame_reject_touch instead.
92 * @param [in] device The device object for the touch (const)
93 * @param [in] window The window to reject the touch for
94 * @param [in] touch_id The touch ID object for the touch
95
96=== modified file 'src/device.cpp'
97--- src/device.cpp 2012-08-29 18:53:37 +0000
98+++ src/device.cpp 2012-12-05 14:06:20 +0000
99@@ -51,6 +51,20 @@
100 return UFStatusSuccess;
101 }
102
103+UFStatus UFDevice::AcceptTouch(UFWindowId window_id, UFTouchId touch_id)
104+{
105+ (void)window_id;
106+ (void)touch_id;
107+ return UFStatusSuccess;
108+}
109+
110+UFStatus UFDevice::RejectTouch(UFWindowId window_id, UFTouchId touch_id)
111+{
112+ (void)window_id;
113+ (void)touch_id;
114+ return UFStatusSuccess;
115+}
116+
117 } // namespace frame
118 } // namespace oif
119
120@@ -143,6 +157,20 @@
121 return resolution;
122 }
123
124+UFStatus frame_accept_touch(UFDevice device, UFWindowId window_id,
125+ UFTouchId touch_id)
126+{
127+ return static_cast<oif::frame::UFDevice*>(device)->
128+ AcceptTouch(window_id, touch_id);
129+}
130+
131+UFStatus frame_reject_touch(UFDevice device, UFWindowId window_id,
132+ UFTouchId touch_id)
133+{
134+ return static_cast<oif::frame::UFDevice*>(device)->
135+ RejectTouch(window_id, touch_id);
136+}
137+
138 UFBackendDevice frame_backend_device_new()
139 {
140 return new UFBackendDevice_(new oif::frame::UFDevice);
141
142=== modified file 'src/device.h'
143--- src/device.h 2012-08-28 18:20:51 +0000
144+++ src/device.h 2012-12-05 14:06:20 +0000
145@@ -55,6 +55,9 @@
146 typedef std::unique_ptr<UFAxis> UniqueUFAxis;
147
148 std::map<UFAxisType, UniqueUFAxis> axes_;
149+
150+ virtual UFStatus AcceptTouch(UFWindowId window_id, UFTouchId touch_id);
151+ virtual UFStatus RejectTouch(UFWindowId window_id, UFTouchId touch_id);
152 };
153
154 } // namespace frame
155
156=== modified file 'src/libframe.ver'
157--- src/libframe.ver 2012-11-26 19:55:29 +0000
158+++ src/libframe.ver 2012-12-05 14:06:20 +0000
159@@ -103,3 +103,9 @@
160 frame_event_set_frame;
161 frame_event_set_time;
162 } FRAME_2.2;
163+
164+FRAME_2.5 {
165+ global:
166+ frame_accept_touch;
167+ frame_reject_touch;
168+} FRAME_2.4;
169
170=== modified file 'src/x11/device_x11.cpp'
171--- src/x11/device_x11.cpp 2012-08-28 19:25:07 +0000
172+++ src/x11/device_x11.cpp 2012-12-05 14:06:20 +0000
173@@ -179,9 +179,10 @@
174 return false;
175 }
176
177-UFStatus UFDeviceX11::AcceptTouch(::Window window_id,
178- UFTouchId touch_id) const {
179- auto it = windows_.find(window_id);
180+UFStatus UFDeviceX11::AcceptTouch(UFWindowId window_id,
181+ UFTouchId touch_id) {
182+ ::Window x11_window_id = frame_x11_get_window_id(window_id);
183+ auto it = windows_.find(x11_window_id);
184 if (it != windows_.end()) {
185 WindowX11* window = static_cast<WindowX11*>(it->second.get());
186 return window->AcceptTouch(touch_id);
187@@ -190,9 +191,10 @@
188 return UFStatusErrorInvalidTouch;
189 }
190
191-UFStatus UFDeviceX11::RejectTouch(::Window window_id,
192- UFTouchId touch_id) const {
193- auto it = windows_.find(window_id);
194+UFStatus UFDeviceX11::RejectTouch(UFWindowId window_id,
195+ UFTouchId touch_id) {
196+ ::Window x11_window_id = frame_x11_get_window_id(window_id);
197+ auto it = windows_.find(x11_window_id);
198 if (it != windows_.end()) {
199 WindowX11* window = static_cast<WindowX11*>(it->second.get());
200 return window->RejectTouch(touch_id);
201@@ -212,18 +214,18 @@
202
203 extern "C" {
204
205-UFStatus frame_x11_accept_touch(UFDevice device, UFWindowId window,
206+UFStatus frame_x11_accept_touch(UFDevice device, UFWindowId window_id,
207 UFTouchId touch_id) {
208 oif::frame::UFDeviceX11* device_x11 =
209 static_cast<oif::frame::UFDeviceX11*>(device);
210- return device_x11->AcceptTouch(frame_x11_get_window_id(window), touch_id);
211+ return device_x11->AcceptTouch(window_id, touch_id);
212 }
213
214-UFStatus frame_x11_reject_touch(UFDevice device, UFWindowId window,
215+UFStatus frame_x11_reject_touch(UFDevice device, UFWindowId window_id,
216 UFTouchId touch_id) {
217 oif::frame::UFDeviceX11* device_x11 =
218 static_cast<oif::frame::UFDeviceX11*>(device);
219- return device_x11->RejectTouch(frame_x11_get_window_id(window), touch_id);
220+ return device_x11->RejectTouch(window_id, touch_id);
221 }
222
223 } // extern "C"
224
225=== modified file 'src/x11/device_x11.h'
226--- src/x11/device_x11.h 2012-06-21 19:41:40 +0000
227+++ src/x11/device_x11.h 2012-12-05 14:06:20 +0000
228@@ -45,8 +45,8 @@
229 bool HandleDeviceEvent(const XIDeviceEvent* event, SharedUFFrame* frame);
230 bool HandleOwnershipEvent(const XITouchOwnershipEvent* event,
231 SharedUFFrame* frame);
232- UFStatus AcceptTouch(::Window window_id, UFTouchId touch_id) const;
233- UFStatus RejectTouch(::Window window_id, UFTouchId touch_id) const;
234+ virtual UFStatus AcceptTouch(UFWindowId window_id, UFTouchId touch_id);
235+ virtual UFStatus RejectTouch(UFWindowId window_id, UFTouchId touch_id);
236 void ReleaseFrames();
237
238 UFDeviceX11(const UFDeviceX11&) = delete;
239
240=== modified file 'test/regular/Makefile.am'
241--- test/regular/Makefile.am 2012-11-20 14:13:20 +0000
242+++ test/regular/Makefile.am 2012-12-05 14:06:20 +0000
243@@ -46,6 +46,7 @@
244 if HAVE_XINPUT
245 check_regular_SOURCES += \
246 accept-ended-touch.cpp \
247+ x11-accept-touch.cpp \
248 frame-x11-fixture.cpp \
249 frame-x11-fixture.h
250 endif
251
252=== added file 'test/regular/x11-accept-touch.cpp'
253--- test/regular/x11-accept-touch.cpp 1970-01-01 00:00:00 +0000
254+++ test/regular/x11-accept-touch.cpp 2012-12-05 14:06:20 +0000
255@@ -0,0 +1,86 @@
256+#include "frame-x11-fixture.h"
257+#include "x11_mocks.h"
258+
259+class X11TouchAcceptance : public FrameX11Fixture
260+{
261+};
262+
263+/*
264+ Calls frame_accept_touch and check if the corresponding X11 call is made
265+ */
266+TEST_F(X11TouchAcceptance, Accept)
267+{
268+ UFStatus status;
269+ UFDevice device;
270+
271+ xmock_server_time = 1234;
272+
273+ CreateXMockTouchScreenDevice();
274+
275+ Display *display = XOpenDisplay(NULL);
276+
277+ status = frame_x11_new(display, &frame_handle);
278+ ASSERT_EQ(UFStatusSuccess, status);
279+
280+ FetchDeviceAddedEvent(&device);
281+ AssertNoMoreEvents();
282+
283+ SendTouchEvent(XI_TouchBegin, 1, 10.0f, 10.0f);
284+ SendTouchOwnershipEvent(1);
285+
286+ UFWindowId frame_window_id = frame_x11_create_window_id(DefaultRootWindow(display));
287+ status = frame_accept_touch(device, frame_window_id, 1);
288+ ASSERT_EQ(UFStatusSuccess, status);
289+
290+ ASSERT_EQ(XIAcceptTouch,
291+ xmock_get_touch_acceptance(xmock_devices[0].attachment /* device id */,
292+ 1 /* touch id */,
293+ DefaultRootWindow(display)));
294+
295+ frame_x11_delete(frame_handle);
296+ frame_handle = nullptr;
297+
298+ XCloseDisplay(display);
299+
300+ DestroyXMockDevices();
301+}
302+
303+/*
304+ Calls frame_reject_touch and check if the corresponding X11 call is made
305+ */
306+TEST_F(X11TouchAcceptance, Reject)
307+{
308+ UFStatus status;
309+ UFDevice device;
310+
311+ xmock_server_time = 1234;
312+
313+ CreateXMockTouchScreenDevice();
314+
315+ Display *display = XOpenDisplay(NULL);
316+
317+ status = frame_x11_new(display, &frame_handle);
318+ ASSERT_EQ(UFStatusSuccess, status);
319+
320+ FetchDeviceAddedEvent(&device);
321+ AssertNoMoreEvents();
322+
323+ SendTouchEvent(XI_TouchBegin, 1, 10.0f, 10.0f);
324+ SendTouchOwnershipEvent(1);
325+
326+ UFWindowId frame_window_id = frame_x11_create_window_id(DefaultRootWindow(display));
327+ status = frame_reject_touch(device, frame_window_id, 1);
328+ ASSERT_EQ(UFStatusSuccess, status);
329+
330+ ASSERT_EQ(XIRejectTouch,
331+ xmock_get_touch_acceptance(xmock_devices[0].attachment /* device id */,
332+ 1 /* touch id */,
333+ DefaultRootWindow(display)));
334+
335+ frame_x11_delete(frame_handle);
336+ frame_handle = nullptr;
337+
338+ XCloseDisplay(display);
339+
340+ DestroyXMockDevices();
341+}

Subscribers

People subscribed via source and target branches