Merge lp:~unity-team/platform-api/devel-for-qtmircompositor into lp:platform-api

Proposed by Gerry Boland
Status: Merged
Approved by: Ricardo Mendoza
Approved revision: 233
Merged at revision: 247
Proposed branch: lp:~unity-team/platform-api/devel-for-qtmircompositor
Merge into: lp:platform-api
Diff against target: 1086 lines (+476/-138)
27 files modified
CMakeLists.txt (+1/-1)
android/default/default_ubuntu_application_ui.cpp (+5/-0)
debian/changelog (+7/-0)
debian/libubuntu-application-api2.symbols (+2/-0)
examples/test_c_api.cpp (+2/-2)
examples/test_multiple_surfaces_event_delivery.cpp (+3/-3)
include/ubuntu/application/ui/input/CMakeLists.txt (+4/-8)
include/ubuntu/application/ui/input/event.h (+102/-72)
include/ubuntu/application/ui/input/event_deprecated.h (+98/-0)
include/ubuntu/application/ui/window.h (+8/-1)
include/ubuntu/application/ui/window_properties.h (+12/-2)
src/ubuntu/application/base_module.h (+1/-1)
src/ubuntu/application/common/mirclient/ubuntu_application_api_mirclient.cpp (+15/-3)
src/ubuntu/application/common/mirclient/window_mirclient.cpp (+60/-21)
src/ubuntu/application/common/mirclient/window_mirclient_priv.h (+26/-4)
src/ubuntu/application/common/mirclient/window_properties_mirclient.cpp (+22/-10)
src/ubuntu/application/common/mirclient/window_properties_mirclient_priv.h (+14/-3)
src/ubuntu/application/common/mircommon/event_helpers_mir.cpp (+70/-2)
src/ubuntu/application/common/mircommon/event_helpers_mir.h (+2/-1)
src/ubuntu/application/common/mirserver/ubuntu_application_api_mirserver.cpp (+4/-0)
src/ubuntu/application/common/mirserver/window_mirserver.cpp (+1/-1)
src/ubuntu/application/desktop/module_version.h (+1/-1)
src/ubuntu/application/testbackend/module_version.h (+1/-1)
src/ubuntu/application/testbackend/test_stubs.cpp (+9/-0)
src/ubuntu/application/touch/hybris/ubuntu_application_api_hybris.cpp (+3/-0)
src/ubuntu/application/touch/module_version.h (+1/-1)
src/ubuntu/application/ubuntu_application_api.cpp (+2/-0)
To merge this branch: bzr merge lp:~unity-team/platform-api/devel-for-qtmircompositor
Reviewer Review Type Date Requested Status
Ricardo Mendoza (community) Approve
PS Jenkins bot continuous-integration Approve
Robert Carr (community) Approve
Review via email: mp+225320@code.launchpad.net

Commit message

Add window resize & focus handling. Involves renaming "input event" to just "event"

A window resize event is not an "input event", hence the rename

Needed for QtCompositor. By Daniel d'Andrada

Description of the change

Add window resize & focus handling

Needed for QtCompositor

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
228. By Gerry Boland

Merge trunk

229. By Gerry Boland

Restore racarr's comment

230. By Gerry Boland

Add comment to clarify code that is phone/tablet specific

231. By Gerry Boland

Bump library so number

Revision history for this message
Robert Carr (robertcarr) wrote :

Thanks :) LGTM now.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
232. By Gerry Boland

Update soname of test base to match soname, fix test fails

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ricardo Mendoza (ricmm) wrote :

Few things:

1. If we can avoid breaking ABI, lets avoid breaking ABI. Please lets just add new functions for window event handling in addition to the existing input event ones, just mark them as deprecated in their comments. Not a big commitment to ABI stability, but in this case it looks relatively easy to *not* break it.

2. All new functions need to have stubs provided in the other modules (testbackend, for example). They also need to be added to the base ubuntu_application_api.cpp source that builds the base SO from macros. window_is_focused is not there.

3. All module_version.h files need to be updated the reflect the version. Same goes for base_module.h, neither of these are modified in here.

review: Needs Fixing
Revision history for this message
Ricardo Mendoza (ricmm) wrote :

> Few things:
>
> 1. If we can avoid breaking ABI, lets avoid breaking ABI. Please lets just add
> new functions for window event handling in addition to the existing input
> event ones, just mark them as deprecated in their comments. Not a big
> commitment to ABI stability, but in this case it looks relatively easy to
> *not* break it.
>
> 2. All new functions need to have stubs provided in the other modules
> (testbackend, for example). They also need to be added to the base
> ubuntu_application_api.cpp source that builds the base SO from macros.
> window_is_focused is not there.
>
> 3. All module_version.h files need to be updated the reflect the version. Same
> goes for base_module.h, neither of these are modified in here.

Some of these things are commented in line

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> Few things:
>
> 1. If we can avoid breaking ABI, lets avoid breaking ABI. Please lets just add
> new functions for window event handling in addition to the existing input
> event ones, just mark them as deprecated in their comments. Not a big
> commitment to ABI stability, but in this case it looks relatively easy to
> *not* break it.

And what are we gaining by keeping ABI compatibility? We are the sole consumers of platform-api currently, thus I don't see any real gain.

But I do see a big drawback of keeping ABI compatibility in this MP, which is ending up with clunkier API.

Take mir as an example: It's constantly breaking its API and ABI because it's a new project that is rapidly and constantly evolving. Freezing its API so early would severely hamper its evolution. I see the same for platform-api, as it's a thin wrapper of mir & others. It's an illusion to think you will get the API right right off the bat. So it's a moot point to enforce ABI stability right now IMHO.

Revision history for this message
kevin gunn (kgunn72) wrote :

> > Few things:
> >
> > 1. If we can avoid breaking ABI, lets avoid breaking ABI. Please lets just
> add
> > new functions for window event handling in addition to the existing input
> > event ones, just mark them as deprecated in their comments. Not a big
> > commitment to ABI stability, but in this case it looks relatively easy to
> > *not* break it.
>
> And what are we gaining by keeping ABI compatibility? We are the sole
> consumers of platform-api currently, thus I don't see any real gain.
>
> But I do see a big drawback of keeping ABI compatibility in this MP, which is
> ending up with clunkier API.
>
> Take mir as an example: It's constantly breaking its API and ABI because it's
> a new project that is rapidly and constantly evolving. Freezing its API so
> early would severely hamper its evolution. I see the same for platform-api, as
> it's a thin wrapper of mir & others. It's an illusion to think you will get
> the API right right off the bat. So it's a moot point to enforce ABI stability
> right now IMHO.

I have to agree, I don't get it either. If we own the clients, why keep the deprecated methods in place & working ? How many clients are there ? just 1 (qtubuntu)?

233. By Daniel d'Andrada

Changes as per code review feedback

1 - not breaking the ABI anymore. Instead of replacing symbols we're deprecating
    them and adding new ones instead

2 - adding stubs for new functions in other modules

3 - updating versions throughout the source tree so they all match

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> Few things:
>
> 1. If we can avoid breaking ABI, lets avoid breaking ABI. Please lets just add
> new functions for window event handling in addition to the existing input
> event ones, just mark them as deprecated in their comments. Not a big
> commitment to ABI stability, but in this case it looks relatively easy to
> *not* break it.
>
> 2. All new functions need to have stubs provided in the other modules
> (testbackend, for example). They also need to be added to the base
> ubuntu_application_api.cpp source that builds the base SO from macros.
> window_is_focused is not there.
>
> 3. All module_version.h files need to be updated the reflect the version. Same
> goes for base_module.h, neither of these are modified in here.

Anyway, all 3 points have been implemented now.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ricardo Mendoza (ricmm) wrote :

Thanks.

review: Approve
234. By Gerry Boland

Merge trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-06-20 14:54:35 +0000
+++ CMakeLists.txt 2014-07-24 12:27:07 +0000
@@ -3,7 +3,7 @@
3project(ubuntu-platform-api)3project(ubuntu-platform-api)
44
5set(UBUNTU_PLATFORM_API_VERSION_MAJOR 2)5set(UBUNTU_PLATFORM_API_VERSION_MAJOR 2)
6set(UBUNTU_PLATFORM_API_VERSION_MINOR 1)6set(UBUNTU_PLATFORM_API_VERSION_MINOR 2)
7set(UBUNTU_PLATFORM_API_VERSION_PATCH 0)7set(UBUNTU_PLATFORM_API_VERSION_PATCH 0)
88
9set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")9set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
1010
=== modified file 'android/default/default_ubuntu_application_ui.cpp'
--- android/default/default_ubuntu_application_ui.cpp 2013-12-11 06:11:34 +0000
+++ android/default/default_ubuntu_application_ui.cpp 2014-07-24 12:27:07 +0000
@@ -229,6 +229,11 @@
229}229}
230230
231void231void
232ua_ui_window_properties_set_event_cb_and_ctx(UAUiWindowProperties*, UAUiWindowEventCb, void *)
233{
234}
235
236void
232ua_ui_window_properties_set_dimensions(237ua_ui_window_properties_set_dimensions(
233 UAUiWindowProperties *properties,238 UAUiWindowProperties *properties,
234 uint32_t width,239 uint32_t width,
235240
=== modified file 'debian/changelog'
--- debian/changelog 2014-07-21 08:47:18 +0000
+++ debian/changelog 2014-07-24 12:27:07 +0000
@@ -1,3 +1,10 @@
1platform-api (2.2.0) UNRELEASED; urgency=medium
2
3 * Add window resize support
4 * Add window focus event
5
6 -- Gerry Boland <gerry.boland@canonical.com> Wed, 02 Jul 2014 14:07:05 +0100
7
1platform-api (2.1.0+14.10.20140721-0ubuntu1) utopic; urgency=low8platform-api (2.1.0+14.10.20140721-0ubuntu1) utopic; urgency=low
29
3 [ thomas-voss ]10 [ thomas-voss ]
411
=== modified file 'debian/libubuntu-application-api2.symbols'
--- debian/libubuntu-application-api2.symbols 2014-06-30 08:54:25 +0000
+++ debian/libubuntu-application-api2.symbols 2014-07-24 12:27:07 +0000
@@ -117,6 +117,7 @@
117 ua_ui_window_get_native_type@Base 0.18.1daily13.06.21117 ua_ui_window_get_native_type@Base 0.18.1daily13.06.21
118 ua_ui_window_get_size@Base 2.0.0+14.10.20140612118 ua_ui_window_get_size@Base 2.0.0+14.10.20140612
119 ua_ui_window_hide@Base 0.18.1daily13.06.21119 ua_ui_window_hide@Base 0.18.1daily13.06.21
120 ua_ui_window_is_focused@Base 0replaceme
120 ua_ui_window_move@Base 0.18.1daily13.06.21121 ua_ui_window_move@Base 0.18.1daily13.06.21
121 ua_ui_window_new_for_application_with_properties@Base 0.18.1daily13.06.21122 ua_ui_window_new_for_application_with_properties@Base 0.18.1daily13.06.21
122 ua_ui_window_properties_destroy@Base 0.18.1daily13.06.21123 ua_ui_window_properties_destroy@Base 0.18.1daily13.06.21
@@ -124,6 +125,7 @@
124 ua_ui_window_properties_new_for_normal_window@Base 0.18.1daily13.06.21125 ua_ui_window_properties_new_for_normal_window@Base 0.18.1daily13.06.21
125 ua_ui_window_properties_set_dimensions@Base 2.0.0+14.10.20140612126 ua_ui_window_properties_set_dimensions@Base 2.0.0+14.10.20140612
126 ua_ui_window_properties_set_input_cb_and_ctx@Base 0.18.1daily13.06.21127 ua_ui_window_properties_set_input_cb_and_ctx@Base 0.18.1daily13.06.21
128 ua_ui_window_properties_set_event_cb_and_ctx@Base 0replaceme
127 ua_ui_window_properties_set_role@Base 0.18.1daily13.06.21129 ua_ui_window_properties_set_role@Base 0.18.1daily13.06.21
128 ua_ui_window_properties_set_titlen@Base 0.18.1daily13.06.21130 ua_ui_window_properties_set_titlen@Base 0.18.1daily13.06.21
129 ua_ui_window_request_fullscreen@Base 0.18.1daily13.06.21131 ua_ui_window_request_fullscreen@Base 0.18.1daily13.06.21
130132
=== modified file 'examples/test_c_api.cpp'
--- examples/test_c_api.cpp 2014-06-11 12:19:37 +0000
+++ examples/test_c_api.cpp 2014-07-24 12:27:07 +0000
@@ -83,7 +83,7 @@
83 const GLfloat * color_data;83 const GLfloat * color_data;
84};84};
8585
86void on_new_event(void* ctx, const Event* ev)86void on_new_event(void* ctx, const WindowEvent* ev)
87{87{
88}88}
8989
@@ -110,7 +110,7 @@
110 UAUiWindowProperties* wprops = ua_ui_window_properties_new_for_normal_window();110 UAUiWindowProperties* wprops = ua_ui_window_properties_new_for_normal_window();
111 ua_ui_window_properties_set_titlen(wprops, "Window 1", 8);111 ua_ui_window_properties_set_titlen(wprops, "Window 1", 8);
112 ua_ui_window_properties_set_role(wprops, U_MAIN_ROLE);112 ua_ui_window_properties_set_role(wprops, U_MAIN_ROLE);
113 ua_ui_window_properties_set_input_cb_and_ctx(wprops, on_new_event, NULL);113 ua_ui_window_properties_set_event_cb_and_ctx(wprops, on_new_event, NULL);
114 114
115 UAUiWindow* surface = ua_ui_window_new_for_application_with_properties(instance, wprops);115 UAUiWindow* surface = ua_ui_window_new_for_application_with_properties(instance, wprops);
116 116
117117
=== modified file 'examples/test_multiple_surfaces_event_delivery.cpp'
--- examples/test_multiple_surfaces_event_delivery.cpp 2014-06-11 12:19:37 +0000
+++ examples/test_multiple_surfaces_event_delivery.cpp 2014-07-24 12:27:07 +0000
@@ -83,7 +83,7 @@
83 const GLfloat * color_data;83 const GLfloat * color_data;
84};84};
8585
86void on_new_event(void* ctx, const Event* ev)86void on_new_event(void* ctx, const WindowEvent* ev)
87{87{
88 int* surface = (int*) ctx;88 int* surface = (int*) ctx;
8989
@@ -115,14 +115,14 @@
115 UAUiWindowProperties* wprops1 = ua_ui_window_properties_new_for_normal_window();115 UAUiWindowProperties* wprops1 = ua_ui_window_properties_new_for_normal_window();
116 ua_ui_window_properties_set_titlen(wprops1, "Window 1", 8);116 ua_ui_window_properties_set_titlen(wprops1, "Window 1", 8);
117 ua_ui_window_properties_set_role(wprops1, U_MAIN_ROLE);117 ua_ui_window_properties_set_role(wprops1, U_MAIN_ROLE);
118 ua_ui_window_properties_set_input_cb_and_ctx(wprops1, on_new_event, &i);118 ua_ui_window_properties_set_event_cb_and_ctx(wprops1, on_new_event, &i);
119 119
120 UAUiWindow* surface1 = ua_ui_window_new_for_application_with_properties(instance, wprops1);120 UAUiWindow* surface1 = ua_ui_window_new_for_application_with_properties(instance, wprops1);
121 121
122 UAUiWindowProperties* wprops2 = ua_ui_window_properties_new_for_normal_window();122 UAUiWindowProperties* wprops2 = ua_ui_window_properties_new_for_normal_window();
123 ua_ui_window_properties_set_titlen(wprops2, "Window 2", 8);123 ua_ui_window_properties_set_titlen(wprops2, "Window 2", 8);
124 ua_ui_window_properties_set_role(wprops2, U_MAIN_ROLE);124 ua_ui_window_properties_set_role(wprops2, U_MAIN_ROLE);
125 ua_ui_window_properties_set_input_cb_and_ctx(wprops2, on_new_event, &j);125 ua_ui_window_properties_set_event_cb_and_ctx(wprops2, on_new_event, &j);
126 126
127 UAUiWindow* surface2 = ua_ui_window_new_for_application_with_properties(instance, wprops2);127 UAUiWindow* surface2 = ua_ui_window_new_for_application_with_properties(instance, wprops2);
128128
129129
=== modified file 'include/ubuntu/application/ui/input/CMakeLists.txt'
--- include/ubuntu/application/ui/input/CMakeLists.txt 2013-07-18 09:08:17 +0000
+++ include/ubuntu/application/ui/input/CMakeLists.txt 2014-07-24 12:27:07 +0000
@@ -1,9 +1,5 @@
1set(1install(
2 UBUNTU_APPLICATION_UI_INPUT_HEADERS2 DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
3 event.h3 DESTINATION include/ubuntu/application/ui
4 FILES_MATCHING PATTERN "*.h"
4)5)
5
6install(
7 FILES ${UBUNTU_APPLICATION_UI_INPUT_HEADERS}
8 DESTINATION include/ubuntu/application/ui/input
9)
10\ No newline at end of file6\ No newline at end of file
117
=== modified file 'include/ubuntu/application/ui/input/event.h'
--- include/ubuntu/application/ui/input/event.h 2013-08-22 06:32:14 +0000
+++ include/ubuntu/application/ui/input/event.h 2014-07-24 12:27:07 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as5 * it under the terms of the GNU Lesser General Public License version 3 as
@@ -14,6 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 * Daniel d'Andrada <daniel.dandrada@canonical.com>
17 */18 */
18#ifndef UBUNTU_APPLICATION_UI_INPUT_EVENT_H_19#ifndef UBUNTU_APPLICATION_UI_INPUT_EVENT_H_
19#define UBUNTU_APPLICATION_UI_INPUT_EVENT_H_20#define UBUNTU_APPLICATION_UI_INPUT_EVENT_H_
@@ -102,82 +103,111 @@
102} UMotionButtonMask;103} UMotionButtonMask;
103104
104105
105 /** Maximum number of pointers reported within one input event. */106 /** Maximum number of pointers reported within one event. */
106#define UBUNTU_APPLICATION_UI_INPUT_EVENT_MAX_POINTER_COUNT (16)107#define UBUNTU_APPLICATION_UI_INPUT_EVENT_MAX_POINTER_COUNT (16)
107108
108 /** Reference timebase, nanoseconds as measured by CLOCK_MONOTONIC. */109/** Reference timebase, nanoseconds as measured by CLOCK_MONOTONIC. */
109 typedef int64_t nsecs_t;110typedef int64_t nsecs_t;
110111
111 /** Describes the different event types. */112typedef enum
112 typedef enum113{
113 {114 SURFACE_ATTRIBUTE_FOCUS
114 KEY_EVENT_TYPE, ///< Event originates from a keyboard.115} SurfaceAttributeType;
115 MOTION_EVENT_TYPE, ///< Event originates from something moving, e.g., a wheel, a mouse, a finger on a touchpad.116
116 HW_SWITCH_EVENT_TYPE ///< Event originates from an additional button attached to the device's HW, e.g., power button.117/** Describes the different event types. */
117 } EventType;118typedef enum
118119{
119 /** Models an input event. */120 KEY_WEVENT_TYPE, ///< Event originates from a keyboard.
120 typedef struct121 MOTION_WEVENT_TYPE, ///< Event originates from something moving, e.g., a wheel, a mouse, a finger on a touchpad.
121 {122 RESIZE_WEVENT_TYPE, ///< Surface has been resized
122 EventType type; ///< Type of the event.123 SURFACE_WEVENT_TYPE //< A surface attribute has changed its value
123 int32_t device_id; ///< Device that this event originated from.124} WindowEventType;
124 int32_t source_id; ///< Source that this event originated from.125
125 int32_t action; ///< Action signalled by this event.126/** Information describing an event originating from a keyboard key. */
126 int32_t flags; ///< Flags associated with this event.127typedef struct
127 int32_t meta_state; ///< State of the meta modifiers (ALT, CTRL, SHIFT).128{
128 /** Information specific to key/motion event types. */129 WindowEventType type;
129 union130
130 {131 int32_t device_id; ///< Device that this event originated from.
131 /** Information describing an event originating from a HW switch. */132 int32_t source_id; ///< Source that this event originated from.
132 struct HardwareSwitchEvent133 int32_t action; ///< Action signalled by this event.
133 {134 int32_t flags; ///< Flags associated with this event.
134 nsecs_t event_time; ///< Timestamp when the event happened.135 int32_t meta_state; ///< State of the meta modifiers (ALT, CTRL, SHIFT).
135 uint32_t policy_flags; ///< Policy flags.136
136 int32_t switch_code; ///< The scan code of the switch.137 int32_t key_code;
137 int32_t switch_value; ///< The value reported by the switch.138 int32_t scan_code;
138 } hw_switch;139 int32_t repeat_count;
139 /** Information describing an event originating from a keyboard key. */140 nsecs_t down_time;
140 struct KeyEvent141 nsecs_t event_time;
141 {142 int is_system_key; ///< \deprecated Do not use.
142 int32_t key_code; 143} KeyEvent;
143 int32_t scan_code;144
144 int32_t repeat_count;145/** Information describing an event originating from a
145 nsecs_t down_time;146 * "moving" device, e.g., a mouse, a mouse-wheel, a finger
146 nsecs_t event_time;147 * on a touchpad.
147 int is_system_key; ///< \deprecated Do not use.148 */
148 } key;149typedef struct
149 /** Information describing an event originating from a150{
150 * "moving" device, e.g., a mouse, a mouse-wheel, a finger151 WindowEventType type;
151 * on a touchpad. 152
152 */153 int32_t device_id; ///< Device that this event originated from.
153 struct MotionEvent154 int32_t source_id; ///< Source that this event originated from.
154 {155 int32_t action; ///< Action signalled by this event.
155 int32_t edge_flags; ///< Set for touches intersecting a touchscreen's edges, requires HW support.156 int32_t flags; ///< Flags associated with this event.
156 int32_t button_state; ///< State of buttons of the device157 int32_t meta_state; ///< State of the meta modifiers (ALT, CTRL, SHIFT).
157 float x_offset; ///< Movement in x direction since down event158
158 float y_offset; ///< Movement in y direction since down event159 int32_t edge_flags; ///< Set for touches intersecting a touchscreen's edges, requires HW support.
159 float x_precision; ///< Sampling precision in x direction160 int32_t button_state; ///< State of buttons of the device
160 float y_precision; ///< Sampling precision in y direction161 float x_offset; ///< Movement in x direction since down event
161 nsecs_t down_time; ///< Timestamp that marks the down event162 float y_offset; ///< Movement in y direction since down event
162 nsecs_t event_time; ///< Timestamp that marks when this event happened163 float x_precision; ///< Sampling precision in x direction
163 size_t pointer_count; ///< Number of pointers reported in this event164 float y_precision; ///< Sampling precision in y direction
164 struct PointerCoordinate165 nsecs_t down_time; ///< Timestamp that marks the down event
165 {166 nsecs_t event_time; ///< Timestamp that marks when this event happened
166 int id; ///< Unique id of the pointer167 size_t pointer_count; ///< Number of pointers reported in this event
167 float x, raw_x; ///< Processed and raw x coordinates168 struct PointerCoordinate
168 float y, raw_y; ///< Processed and raw y coordinates169 {
169 float touch_major; ///< Touch major coordinate170 int id; ///< Unique id of the pointer
170 float touch_minor; ///< Touch minor coordinate171 float x, raw_x; ///< Processed and raw x coordinates
171 float size; ///< Size of the pointer/touch172 float y, raw_y; ///< Processed and raw y coordinates
172 float pressure; ///< Pressure of the touch173 float touch_major; ///< Touch major coordinate
173 float orientation; ///< Orientation174 float touch_minor; ///< Touch minor coordinate
174 } pointer_coordinates[UBUNTU_APPLICATION_UI_INPUT_EVENT_MAX_POINTER_COUNT]; ///< Pointer information, valid from [0,pointer_count).175 float size; ///< Size of the pointer/touch
175 } motion;176 float pressure; ///< Pressure of the touch
176 } details;177 float orientation; ///< Orientation
177 } Event;178 } pointer_coordinates[UBUNTU_APPLICATION_UI_INPUT_EVENT_MAX_POINTER_COUNT]; ///< Pointer information, valid from [0,pointer_count).
179} MotionEvent;
180
181typedef struct
182{
183 WindowEventType type;
184
185 SurfaceAttributeType attribute; ///< The surface attribute that has changed
186 int32_t value; ///< The new value of that surface attribute.
187} SurfaceEvent;
188
189/** Information describing a surface resize event. */
190typedef struct
191{
192 WindowEventType type;
193
194 int32_t width; ///< The new surface width
195 int32_t height; ///< The new surface height.
196} ResizeEvent;
197
198typedef union
199{
200 WindowEventType type;
201 KeyEvent key;
202 MotionEvent motion;
203 SurfaceEvent surface;
204 ResizeEvent resize;
205} WindowEvent;
178206
179#ifdef __cplusplus207#ifdef __cplusplus
180}208}
181#endif209#endif
182210
211#include "event_deprecated.h"
212
183#endif // UBUNTU_APPLICATION_UI_INPUT_EVENT_H_213#endif // UBUNTU_APPLICATION_UI_INPUT_EVENT_H_
184214
=== added file 'include/ubuntu/application/ui/input/event_deprecated.h'
--- include/ubuntu/application/ui/input/event_deprecated.h 1970-01-01 00:00:00 +0000
+++ include/ubuntu/application/ui/input/event_deprecated.h 2014-07-24 12:27:07 +0000
@@ -0,0 +1,98 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18
19#ifndef UBUNTU_APPLICATION_UI__EVENT_DEPRECATED_H_
20#define UBUNTU_APPLICATION_UI__EVENT_DEPRECATED_H_
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26 /** Describes the different event types. */
27 typedef enum
28 {
29 KEY_EVENT_TYPE, ///< Event originates from a keyboard.
30 MOTION_EVENT_TYPE, ///< Event originates from something moving, e.g., a wheel, a mouse, a finger on a touchpad.
31 HW_SWITCH_EVENT_TYPE ///< Event originates from an additional button attached to the device's HW, e.g., power button.
32 } EventType;
33
34 /** Models an input event. */
35 typedef struct
36 {
37 EventType type; ///< Type of the event.
38 int32_t device_id; ///< Device that this event originated from.
39 int32_t source_id; ///< Source that this event originated from.
40 int32_t action; ///< Action signalled by this event.
41 int32_t flags; ///< Flags associated with this event.
42 int32_t meta_state; ///< State of the meta modifiers (ALT, CTRL, SHIFT).
43 /** Information specific to key/motion event types. */
44 union
45 {
46 /** Information describing an event originating from a HW switch. */
47 struct HardwareSwitchEvent
48 {
49 nsecs_t event_time; ///< Timestamp when the event happened.
50 uint32_t policy_flags; ///< Policy flags.
51 int32_t switch_code; ///< The scan code of the switch.
52 int32_t switch_value; ///< The value reported by the switch.
53 } hw_switch;
54 /** Information describing an event originating from a keyboard key. */
55 struct KeyEvent
56 {
57 int32_t key_code;
58 int32_t scan_code;
59 int32_t repeat_count;
60 nsecs_t down_time;
61 nsecs_t event_time;
62 int is_system_key; ///< \deprecated Do not use.
63 } key;
64 /** Information describing an event originating from a
65 * "moving" device, e.g., a mouse, a mouse-wheel, a finger
66 * on a touchpad.
67 */
68 struct MotionEvent
69 {
70 int32_t edge_flags; ///< Set for touches intersecting a touchscreen's edges, requires HW support.
71 int32_t button_state; ///< State of buttons of the device
72 float x_offset; ///< Movement in x direction since down event
73 float y_offset; ///< Movement in y direction since down event
74 float x_precision; ///< Sampling precision in x direction
75 float y_precision; ///< Sampling precision in y direction
76 nsecs_t down_time; ///< Timestamp that marks the down event
77 nsecs_t event_time; ///< Timestamp that marks when this event happened
78 size_t pointer_count; ///< Number of pointers reported in this event
79 struct PointerCoordinate
80 {
81 int id; ///< Unique id of the pointer
82 float x, raw_x; ///< Processed and raw x coordinates
83 float y, raw_y; ///< Processed and raw y coordinates
84 float touch_major; ///< Touch major coordinate
85 float touch_minor; ///< Touch minor coordinate
86 float size; ///< Size of the pointer/touch
87 float pressure; ///< Pressure of the touch
88 float orientation; ///< Orientation
89 } pointer_coordinates[UBUNTU_APPLICATION_UI_INPUT_EVENT_MAX_POINTER_COUNT]; ///< Pointer information, valid from [0,pointer_count).
90 } motion;
91 } details;
92 } Event;
93
94#ifdef __cplusplus
95}
96#endif
97
98#endif // UBUNTU_APPLICATION_UI__EVENT_DEPRECATED_H_
099
=== modified file 'include/ubuntu/application/ui/window.h'
--- include/ubuntu/application/ui/window.h 2014-05-07 12:21:22 +0000
+++ include/ubuntu/application/ui/window.h 2014-07-24 12:27:07 +0000
@@ -34,7 +34,10 @@
3434
35 typedef void UAUiWindow;35 typedef void UAUiWindow;
36 typedef int32_t UAUiWindowId;36 typedef int32_t UAUiWindowId;
37 37
38 /*
39 Ownership of properties is given to the returned UAUiWindow
40 */
38 UBUNTU_DLL_PUBLIC UAUiWindow*41 UBUNTU_DLL_PUBLIC UAUiWindow*
39 ua_ui_window_new_for_application_with_properties(42 ua_ui_window_new_for_application_with_properties(
40 UApplicationInstance *instance,43 UApplicationInstance *instance,
@@ -82,6 +85,10 @@
82 ua_ui_window_get_native_type(85 ua_ui_window_get_native_type(
83 UAUiWindow *window);86 UAUiWindow *window);
8487
88 UBUNTU_DLL_PUBLIC int
89 ua_ui_window_is_focused(
90 UAUiWindow *window);
91
85#ifdef __cplusplus92#ifdef __cplusplus
86}93}
87#endif94#endif
8895
=== modified file 'include/ubuntu/application/ui/window_properties.h'
--- include/ubuntu/application/ui/window_properties.h 2013-12-11 04:56:15 +0000
+++ include/ubuntu/application/ui/window_properties.h 2014-07-24 12:27:07 +0000
@@ -39,10 +39,13 @@
39 U_SHUTDOWN_DIALOG_ROLE,39 U_SHUTDOWN_DIALOG_ROLE,
40 } UAUiWindowRole;40 } UAUiWindowRole;
4141
4242 // Deprecated! Use UAUiWindowEventCb instead
43 typedef void (*input_event_cb)(void* ctx, const Event* ev);43 typedef void (*input_event_cb)(void* ctx, const Event* ev);
44 typedef input_event_cb UAUiWindowInputEventCb;44 typedef input_event_cb UAUiWindowInputEventCb;
4545
46 typedef void (*event_cb)(void* ctx, const WindowEvent* ev);
47 typedef event_cb UAUiWindowEventCb;
48
46 typedef void UAUiWindowProperties;49 typedef void UAUiWindowProperties;
47 50
48 UBUNTU_DLL_PUBLIC UAUiWindowProperties*51 UBUNTU_DLL_PUBLIC UAUiWindowProperties*
@@ -70,7 +73,8 @@
70 UBUNTU_DLL_PUBLIC UAUiWindowRole73 UBUNTU_DLL_PUBLIC UAUiWindowRole
71 ua_ui_window_properties_get_role(74 ua_ui_window_properties_get_role(
72 UAUiWindowProperties *properties);75 UAUiWindowProperties *properties);
73 76
77 // Deprecated! Use ua_ui_window_properties_set_event_cb_and_ctx instead.
74 UBUNTU_DLL_PUBLIC void78 UBUNTU_DLL_PUBLIC void
75 ua_ui_window_properties_set_input_cb_and_ctx(79 ua_ui_window_properties_set_input_cb_and_ctx(
76 UAUiWindowProperties *properties,80 UAUiWindowProperties *properties,
@@ -78,6 +82,12 @@
78 void *ctx);82 void *ctx);
7983
80 UBUNTU_DLL_PUBLIC void84 UBUNTU_DLL_PUBLIC void
85 ua_ui_window_properties_set_event_cb_and_ctx(
86 UAUiWindowProperties *properties,
87 UAUiWindowEventCb cb,
88 void *ctx);
89
90 UBUNTU_DLL_PUBLIC void
81 ua_ui_window_properties_set_dimensions(91 ua_ui_window_properties_set_dimensions(
82 UAUiWindowProperties *properties,92 UAUiWindowProperties *properties,
83 uint32_t width,93 uint32_t width,
8494
=== modified file 'src/ubuntu/application/base_module.h'
--- src/ubuntu/application/base_module.h 2014-06-20 14:54:35 +0000
+++ src/ubuntu/application/base_module.h 2014-07-24 12:27:07 +0000
@@ -28,7 +28,7 @@
28 */28 */
2929
30#define API_VERSION_MAJOR "2"30#define API_VERSION_MAJOR "2"
31#define API_VERSION_MINOR "1"31#define API_VERSION_MINOR "2"
32#define API_VERSION_PATCH "0"32#define API_VERSION_PATCH "0"
33#define SO_SUFFIX ".so." API_VERSION_MAJOR "." API_VERSION_MINOR "." API_VERSION_PATCH33#define SO_SUFFIX ".so." API_VERSION_MAJOR "." API_VERSION_MINOR "." API_VERSION_PATCH
3434
3535
=== modified file 'src/ubuntu/application/common/mirclient/ubuntu_application_api_mirclient.cpp'
--- src/ubuntu/application/common/mirclient/ubuntu_application_api_mirclient.cpp 2014-05-20 09:29:12 +0000
+++ src/ubuntu/application/common/mirclient/ubuntu_application_api_mirclient.cpp 2014-07-24 12:27:07 +0000
@@ -299,6 +299,12 @@
299 properties->set_input_cb_and_ctx(cb, ctx);299 properties->set_input_cb_and_ctx(cb, ctx);
300}300}
301301
302void ua_ui_window_properties_set_event_cb_and_ctx(UAUiWindowProperties* u_properties, UAUiWindowEventCb cb, void* ctx)
303{
304 auto properties = uamc::WindowProperties::from_u_window_properties(u_properties);
305 properties->set_event_cb_and_ctx(cb, ctx);
306}
307
302void ua_ui_window_properties_set_dimensions(UAUiWindowProperties *u_properties, uint32_t width, uint32_t height)308void ua_ui_window_properties_set_dimensions(UAUiWindowProperties *u_properties, uint32_t width, uint32_t height)
303{309{
304 auto properties = uamc::WindowProperties::from_u_window_properties(u_properties);310 auto properties = uamc::WindowProperties::from_u_window_properties(u_properties);
@@ -347,21 +353,21 @@
347UStatus ua_ui_window_hide(UAUiWindow* u_window)353UStatus ua_ui_window_hide(UAUiWindow* u_window)
348{354{
349 auto window = uamc::Window::from_u_window(u_window);355 auto window = uamc::Window::from_u_window(u_window);
350 window->set_state(U_MINIMIZED_STATE);356 window->hide();
351 return (UStatus) 0;357 return (UStatus) 0;
352}358}
353359
354UStatus ua_ui_window_show(UAUiWindow* u_window)360UStatus ua_ui_window_show(UAUiWindow* u_window)
355{361{
356 auto window = uamc::Window::from_u_window(u_window);362 auto window = uamc::Window::from_u_window(u_window);
357 window->set_state(U_MAXIMIZED_STATE);363 window->show();
358 return (UStatus) 0;364 return (UStatus) 0;
359}365}
360366
361void ua_ui_window_request_fullscreen(UAUiWindow* u_window)367void ua_ui_window_request_fullscreen(UAUiWindow* u_window)
362{368{
363 auto window = uamc::Window::from_u_window(u_window);369 auto window = uamc::Window::from_u_window(u_window);
364 window->set_state(U_FULLSCREEN_STATE);370 window->request_fullscreen();
365}371}
366372
367EGLNativeWindowType ua_ui_window_get_native_type(UAUiWindow* u_window)373EGLNativeWindowType ua_ui_window_get_native_type(UAUiWindow* u_window)
@@ -370,5 +376,11 @@
370 return window->get_native_type();376 return window->get_native_type();
371}377}
372378
379int ua_ui_window_is_focused(UAUiWindow *u_window)
380{
381 auto window = uamc::Window::from_u_window(u_window);
382 return window->is_focused();
383}
384
373// TODO: Sensors385// TODO: Sensors
374}386}
375387
=== modified file 'src/ubuntu/application/common/mirclient/window_mirclient.cpp'
--- src/ubuntu/application/common/mirclient/window_mirclient.cpp 2014-05-20 09:29:12 +0000
+++ src/ubuntu/application/common/mirclient/window_mirclient.cpp 2014-07-24 12:27:07 +0000
@@ -35,27 +35,38 @@
35namespace client35namespace client
36{36{
3737
38struct InputContext
39{
40 UAUiWindowInputEventCb cb;
41 void *ctx;
42};
43
44static void38static void
45ua_ui_window_mir_handle_event(MirSurface* surface, MirEvent const* mir_ev, void* ctx)39ua_ui_window_mir_handle_event(MirSurface* surface, MirEvent const* mir_ev, void* ctx)
46{40{
47 // TODO<mir>: Perhaps this indicates that mirclient library should not pass a surface argument here.41 // TODO<mir>: Perhaps this indicates that mirclient library should not pass a surface argument here.
48 (void) surface;42 (void) surface;
4943
50 Event ubuntu_ev;44 WindowEvent ubuntu_ev;
51 auto translated_event = uaum::event_to_ubuntu_event(mir_ev, ubuntu_ev);45
52 46 bool translated_event = uaum::event_to_ubuntu_event(mir_ev, ubuntu_ev);
53 // Mir sends some events such as focus gained/lost which the platform API does not represent as input events.47
54 if (translated_event)48 // Mir sends some events which platform API does not represent as platform-api events.
55 {49 if (!translated_event)
56 auto mir_ctx = static_cast<uamc::InputContext*>(ctx);50 return;
57 mir_ctx->cb(mir_ctx->ctx, &ubuntu_ev);51
52 auto window = static_cast<uamc::Window*>(ctx);
53 window->process_event(ubuntu_ev);
54
55 UAUiWindowEventCb user_callback = window->get_user_callback();
56 if (user_callback != nullptr) {
57 user_callback(window->get_user_callback_context(), &ubuntu_ev);
58 } else {
59 // Fallback to the old, deprecated, API for handling events
60 Event ubuntu_deprecated_ev;
61
62 bool ok = uaum::event_to_ubuntu_deprecated_event(mir_ev, ubuntu_deprecated_ev);
63
64 if (ok) {
65 UAUiWindowInputEventCb user_input_callback = window->get_user_input_callback();
66 user_input_callback(window->get_user_callback_context(), &ubuntu_deprecated_ev);
67 }
58 }68 }
69
59}70}
6071
61}72}
@@ -84,8 +95,13 @@
8495
85uamc::Window::Window(uamc::Instance& instance,96uamc::Window::Window(uamc::Instance& instance,
86 uamc::WindowProperties* properties)97 uamc::WindowProperties* properties)
87 : instance(instance)98 : instance(instance),
99 focused(0)
88{100{
101 user_event_callback = properties->event_cb();
102 user_event_callback_context = properties->event_cb_context();
103 user_input_callback = properties->input_cb();
104
89 window_properties = WindowPropertiesPtr(properties,105 window_properties = WindowPropertiesPtr(properties,
90 [](uamc::WindowProperties *p)106 [](uamc::WindowProperties *p)
91 {107 {
@@ -98,11 +114,6 @@
98114
99 auto mir_surface = mir_connection_create_surface_sync(connection, &parameters);115 auto mir_surface = mir_connection_create_surface_sync(connection, &parameters);
100 // TODO: create_surface_sync is unsafe as there is a race between setting the event handler and receiving surfaces116 // TODO: create_surface_sync is unsafe as there is a race between setting the event handler and receiving surfaces
101 input_ctx = InputContextPtr(new uamc::InputContext{properties->input_cb(), properties->input_context()},
102 [](InputContext *c)
103 {
104 delete c;
105 });
106117
107 if (properties->surface_type()) {118 if (properties->surface_type()) {
108 // TODO: Should I bother checking the result?119 // TODO: Should I bother checking the result?
@@ -112,7 +123,7 @@
112 MirEventDelegate delegate = 123 MirEventDelegate delegate =
113 { 124 {
114 uamc::ua_ui_window_mir_handle_event,125 uamc::ua_ui_window_mir_handle_event,
115 input_ctx.get()126 this
116 };127 };
117 mir_surface_set_event_handler(mir_surface, &delegate);128 mir_surface_set_event_handler(mir_surface, &delegate);
118 surface = SurfacePtr(mir_surface, 129 surface = SurfacePtr(mir_surface,
@@ -120,6 +131,9 @@
120 {131 {
121 mir_surface_release_sync(s);132 mir_surface_release_sync(s);
122 });133 });
134
135 // FIXME: this only really applicable for phone & tablet case
136 state_before_hiding = U_MAXIMIZED_STATE;
123}137}
124138
125UAUiWindow* uamc::Window::as_u_window()139UAUiWindow* uamc::Window::as_u_window()
@@ -154,3 +168,28 @@
154 *width = parameters.width;168 *width = parameters.width;
155 *height = parameters.height;169 *height = parameters.height;
156}170}
171
172void uamc::Window::hide()
173{
174 state_before_hiding = state();
175 set_state(U_MINIMIZED_STATE);
176}
177
178void uamc::Window::show()
179{
180 if (state() == U_MINIMIZED_STATE) {
181 set_state(state_before_hiding);
182 }
183}
184
185void uamc::Window::request_fullscreen()
186{
187 set_state(U_FULLSCREEN_STATE);
188}
189
190void uamc::Window::process_event(const WindowEvent &ev)
191{
192 if (ev.type == SURFACE_WEVENT_TYPE && ev.surface.attribute == SURFACE_ATTRIBUTE_FOCUS) {
193 focused = ev.surface.value;
194 }
195}
157196
=== modified file 'src/ubuntu/application/common/mirclient/window_mirclient_priv.h'
--- src/ubuntu/application/common/mirclient/window_mirclient_priv.h 2014-05-20 09:29:12 +0000
+++ src/ubuntu/application/common/mirclient/window_mirclient_priv.h 2014-07-24 12:27:07 +0000
@@ -41,7 +41,6 @@
41{41{
42class Instance;42class Instance;
43class WindowProperties;43class WindowProperties;
44struct InputContext;
4544
46class Window45class Window
47{46{
@@ -55,24 +54,47 @@
55 EGLNativeWindowType get_native_type();54 EGLNativeWindowType get_native_type();
5655
57 UApplicationUiWindowState state() const;56 UApplicationUiWindowState state() const;
58 void set_state(const UApplicationUiWindowState);57
58 void hide();
59 void show();
60 void request_fullscreen();
5961
60 void get_size(uint32_t *width, uint32_t *height);62 void get_size(uint32_t *width, uint32_t *height);
6163
64 void process_event(const WindowEvent &ev);
65 int is_focused() const { return focused; }
66
67 // user as in "platform-api user"
68 UAUiWindowEventCb get_user_callback() { return user_event_callback;}
69 void *get_user_callback_context() { return user_event_callback_context; }
70
71 // Deprecated! Use get_user_callback() instead
72 UAUiWindowInputEventCb get_user_input_callback() { return user_input_callback;}
73
62protected:74protected:
63 Window(Window const&) = delete;75 Window(Window const&) = delete;
64 Window& operator=(Window const&) = delete;76 Window& operator=(Window const&) = delete;
6577
66private:78private:
79 void set_state(const UApplicationUiWindowState);
80
67 Instance& instance;81 Instance& instance;
6882
69 typedef std::unique_ptr<WindowProperties, std::function<void(WindowProperties*)>> WindowPropertiesPtr;83 typedef std::unique_ptr<WindowProperties, std::function<void(WindowProperties*)>> WindowPropertiesPtr;
70 typedef std::unique_ptr<MirSurface, std::function<void(MirSurface*)>> SurfacePtr;84 typedef std::unique_ptr<MirSurface, std::function<void(MirSurface*)>> SurfacePtr;
71 typedef std::unique_ptr<InputContext, std::function<void(InputContext*)>> InputContextPtr;
7285
73 WindowPropertiesPtr window_properties;86 WindowPropertiesPtr window_properties;
74 InputContextPtr input_ctx;
75 SurfacePtr surface;87 SurfacePtr surface;
88
89 UAUiWindowEventCb user_event_callback;
90 void *user_event_callback_context;
91
92 // Deprecated! Replaced by user_event_callback
93 UAUiWindowInputEventCb user_input_callback;
94
95 UApplicationUiWindowState state_before_hiding;
96
97 int focused;
76};98};
77 99
78}100}
79101
=== modified file 'src/ubuntu/application/common/mirclient/window_properties_mirclient.cpp'
--- src/ubuntu/application/common/mirclient/window_properties_mirclient.cpp 2013-12-11 04:36:18 +0000
+++ src/ubuntu/application/common/mirclient/window_properties_mirclient.cpp 2014-07-24 12:27:07 +0000
@@ -23,8 +23,9 @@
23uamc::WindowProperties::WindowProperties()23uamc::WindowProperties::WindowProperties()
24 : parameters(),24 : parameters(),
25 type(mir_surface_type_normal),25 type(mir_surface_type_normal),
26 cb(nullptr),26 _input_cb(nullptr),
27 input_ctx(nullptr)27 _event_cb(nullptr),
28 _event_cb_ctx(nullptr)
28{29{
29 parameters.name = nullptr;30 parameters.name = nullptr;
30 parameters.width = 0;31 parameters.width = 0;
@@ -50,8 +51,14 @@
5051
51void uamc::WindowProperties::set_input_cb_and_ctx(UAUiWindowInputEventCb callback, void* ctx)52void uamc::WindowProperties::set_input_cb_and_ctx(UAUiWindowInputEventCb callback, void* ctx)
52{53{
53 cb = callback;54 _input_cb = callback;
54 input_ctx = ctx;55 _event_cb_ctx = ctx;
56}
57
58void uamc::WindowProperties::set_event_cb_and_ctx(UAUiWindowEventCb callback, void* ctx)
59{
60 _event_cb = callback;
61 _event_cb_ctx = ctx;
55}62}
5663
57void uamc::WindowProperties::set_dimensions(uint32_t width, uint32_t height)64void uamc::WindowProperties::set_dimensions(uint32_t width, uint32_t height)
@@ -80,10 +87,15 @@
8087
81UAUiWindowInputEventCb uamc::WindowProperties::input_cb() const88UAUiWindowInputEventCb uamc::WindowProperties::input_cb() const
82{89{
83 return cb;90 return _input_cb;
84}91}
8592
86void* uamc::WindowProperties::input_context() const93UAUiWindowEventCb uamc::WindowProperties::event_cb() const
87{94{
88 return input_ctx;95 return _event_cb;
96}
97
98void* uamc::WindowProperties::event_cb_context() const
99{
100 return _event_cb_ctx;
89}101}
90102
=== modified file 'src/ubuntu/application/common/mirclient/window_properties_mirclient_priv.h'
--- src/ubuntu/application/common/mirclient/window_properties_mirclient_priv.h 2013-12-11 02:20:26 +0000
+++ src/ubuntu/application/common/mirclient/window_properties_mirclient_priv.h 2014-07-24 12:27:07 +0000
@@ -46,14 +46,24 @@
46 static WindowProperties* from_u_window_properties(UAUiWindowProperties* u_properties);46 static WindowProperties* from_u_window_properties(UAUiWindowProperties* u_properties);
47 47
48 void set_title(char const* title, size_t length);48 void set_title(char const* title, size_t length);
49
50 // Deprecated! Use set_event_cb_and_ctx()
49 void set_input_cb_and_ctx(UAUiWindowInputEventCb cb, void* ctx);51 void set_input_cb_and_ctx(UAUiWindowInputEventCb cb, void* ctx);
52
53 // sets event callback and callback context
54 void set_event_cb_and_ctx(UAUiWindowEventCb cb, void* ctx);
55
50 void set_dimensions(uint32_t width, uint32_t height);56 void set_dimensions(uint32_t width, uint32_t height);
51 void set_role(UAUiWindowRole role); 57 void set_role(UAUiWindowRole role);
52 58
53 MirSurfaceParameters const& surface_parameters() const;59 MirSurfaceParameters const& surface_parameters() const;
54 MirSurfaceType surface_type() const;60 MirSurfaceType surface_type() const;
61
62 // Deprecated! Use event_cb()
55 UAUiWindowInputEventCb input_cb() const;63 UAUiWindowInputEventCb input_cb() const;
56 void* input_context() const;64
65 UAUiWindowEventCb event_cb() const;
66 void* event_cb_context() const;
57 67
58protected:68protected:
59 WindowProperties(WindowProperties const&) = delete;69 WindowProperties(WindowProperties const&) = delete;
@@ -65,8 +75,9 @@
6575
66 std::string title;76 std::string title;
6777
68 UAUiWindowInputEventCb cb;78 UAUiWindowInputEventCb _input_cb; // Deprecated! Replaced by _event_cb
69 void *input_ctx;79 UAUiWindowEventCb _event_cb;
80 void *_event_cb_ctx;
70};81};
71 82
72}83}
7384
=== modified file 'src/ubuntu/application/common/mircommon/event_helpers_mir.cpp'
--- src/ubuntu/application/common/mircommon/event_helpers_mir.cpp 2013-10-14 21:22:49 +0000
+++ src/ubuntu/application/common/mircommon/event_helpers_mir.cpp 2014-07-24 12:27:07 +0000
@@ -20,10 +20,78 @@
2020
21namespace uaum = ubuntu::application::ui::mir;21namespace uaum = ubuntu::application::ui::mir;
2222
23// TODO<mir>: This begs the question: Why does MirEvent exist? It's difficult to ensure this function is kept in sync 23// TODO<mir>: This begs the question: Why does MirEvent exist? It's difficult to ensure this function is kept in sync
24// at the unit test level.24// at the unit test level.
25bool25bool
26uaum::event_to_ubuntu_event(MirEvent const* mir_event, Event& ubuntu_ev)26uaum::event_to_ubuntu_event(MirEvent const* mir_event, WindowEvent& ubuntu_ev)
27{
28 switch (mir_event->type)
29 {
30 case mir_event_type_key:
31 ubuntu_ev.key.type = KEY_WEVENT_TYPE;
32 ubuntu_ev.key.device_id = mir_event->key.device_id;
33 ubuntu_ev.key.source_id = mir_event->key.source_id;
34 ubuntu_ev.key.action = mir_event->key.action;
35 ubuntu_ev.key.flags = mir_event->key.flags;
36 ubuntu_ev.key.meta_state = mir_event->key.modifiers;
37 ubuntu_ev.key.key_code = mir_event->key.key_code;
38 ubuntu_ev.key.scan_code = mir_event->key.scan_code;
39 ubuntu_ev.key.repeat_count = mir_event->key.repeat_count;
40 ubuntu_ev.key.down_time = mir_event->key.down_time;
41 ubuntu_ev.key.event_time = mir_event->key.event_time;
42 ubuntu_ev.key.is_system_key = mir_event->key.is_system_key;
43 return true;
44 case mir_event_type_motion:
45 ubuntu_ev.motion.type = MOTION_WEVENT_TYPE;
46 ubuntu_ev.motion.device_id = mir_event->motion.device_id;
47 ubuntu_ev.motion.source_id = mir_event->motion.source_id;
48 ubuntu_ev.motion.action = mir_event->motion.action;
49 ubuntu_ev.motion.flags = mir_event->motion.flags;
50 ubuntu_ev.motion.meta_state = mir_event->motion.modifiers;
51 ubuntu_ev.motion.edge_flags = mir_event->motion.edge_flags;
52 ubuntu_ev.motion.button_state = mir_event->motion.button_state;
53 ubuntu_ev.motion.x_offset = mir_event->motion.x_offset;
54 ubuntu_ev.motion.y_offset = mir_event->motion.y_offset;
55 ubuntu_ev.motion.x_precision = mir_event->motion.x_precision;
56 ubuntu_ev.motion.y_precision = mir_event->motion.y_precision;
57 ubuntu_ev.motion.down_time = mir_event->motion.down_time;
58 ubuntu_ev.motion.event_time = mir_event->motion.event_time;
59 ubuntu_ev.motion.pointer_count = mir_event->motion.pointer_count;
60 for (int i = 0; i < mir_event->motion.pointer_count; i++)
61 {
62 ubuntu_ev.motion.pointer_coordinates[i].id = mir_event->motion.pointer_coordinates[i].id;
63 ubuntu_ev.motion.pointer_coordinates[i].x = mir_event->motion.pointer_coordinates[i].x;
64 ubuntu_ev.motion.pointer_coordinates[i].raw_x = mir_event->motion.pointer_coordinates[i].raw_x;
65 ubuntu_ev.motion.pointer_coordinates[i].y = mir_event->motion.pointer_coordinates[i].y;
66 ubuntu_ev.motion.pointer_coordinates[i].raw_y = mir_event->motion.pointer_coordinates[i].raw_y;
67 ubuntu_ev.motion.pointer_coordinates[i].touch_major = mir_event->motion.pointer_coordinates[i].touch_major;
68 ubuntu_ev.motion.pointer_coordinates[i].touch_minor = mir_event->motion.pointer_coordinates[i].touch_minor;
69 ubuntu_ev.motion.pointer_coordinates[i].size = mir_event->motion.pointer_coordinates[i].size;
70 ubuntu_ev.motion.pointer_coordinates[i].pressure = mir_event->motion.pointer_coordinates[i].pressure;
71 ubuntu_ev.motion.pointer_coordinates[i].orientation = mir_event->motion.pointer_coordinates[i].orientation;
72 }
73 return true;
74 case mir_event_type_resize:
75 ubuntu_ev.resize.type = RESIZE_WEVENT_TYPE;
76 ubuntu_ev.resize.width = mir_event->resize.width;
77 ubuntu_ev.resize.height = mir_event->resize.height;
78 return true;
79 case mir_event_type_surface:
80 ubuntu_ev.surface.type = SURFACE_WEVENT_TYPE;
81 if (mir_event->surface.attrib == mir_surface_attrib_focus) {
82 ubuntu_ev.surface.attribute = SURFACE_ATTRIBUTE_FOCUS;
83 ubuntu_ev.surface.value = mir_event->surface.value == mir_surface_focused;
84 return true;
85 } else {
86 return false;
87 }
88 default:
89 return false;
90 }
91}
92
93bool
94uaum::event_to_ubuntu_deprecated_event(MirEvent const* mir_event, Event& ubuntu_ev)
27{95{
28 switch (mir_event->type)96 switch (mir_event->type)
29 {97 {
3098
=== modified file 'src/ubuntu/application/common/mircommon/event_helpers_mir.h'
--- src/ubuntu/application/common/mircommon/event_helpers_mir.h 2013-10-14 21:22:49 +0000
+++ src/ubuntu/application/common/mircommon/event_helpers_mir.h 2014-07-24 12:27:07 +0000
@@ -30,7 +30,8 @@
30{30{
31namespace mir31namespace mir
32{32{
33bool event_to_ubuntu_event(MirEvent const* mir_event, Event& ubuntu_ev);33bool event_to_ubuntu_event(MirEvent const* mir_event, WindowEvent& ubuntu_ev);
34bool event_to_ubuntu_deprecated_event(MirEvent const* mir_event, Event& ubuntu_ev);
34}35}
35}36}
36}37}
3738
=== modified file 'src/ubuntu/application/common/mirserver/ubuntu_application_api_mirserver.cpp'
--- src/ubuntu/application/common/mirserver/ubuntu_application_api_mirserver.cpp 2014-05-20 09:26:33 +0000
+++ src/ubuntu/application/common/mirserver/ubuntu_application_api_mirserver.cpp 2014-07-24 12:27:07 +0000
@@ -255,6 +255,10 @@
255 (void) role;255 (void) role;
256}256}
257257
258void ua_ui_window_properties_set_event_cb_and_ctx(UAUiWindowProperties*, UAUiWindowEventCb, void*)
259{
260}
261
258void ua_ui_window_properties_set_input_cb_and_ctx(UAUiWindowProperties* u_properties, UAUiWindowInputEventCb cb, void* ctx)262void ua_ui_window_properties_set_input_cb_and_ctx(UAUiWindowProperties* u_properties, UAUiWindowInputEventCb cb, void* ctx)
259{263{
260 auto properties = uams::WindowProperties::from_u_window_properties(u_properties);264 auto properties = uams::WindowProperties::from_u_window_properties(u_properties);
261265
=== modified file 'src/ubuntu/application/common/mirserver/window_mirserver.cpp'
--- src/ubuntu/application/common/mirserver/window_mirserver.cpp 2014-04-04 10:38:36 +0000
+++ src/ubuntu/application/common/mirserver/window_mirserver.cpp 2014-07-24 12:27:07 +0000
@@ -43,7 +43,7 @@
43static void ua_ui_window_handle_event(UAUiWindowInputEventCb cb, void* ctx, MirEvent* mir_event)43static void ua_ui_window_handle_event(UAUiWindowInputEventCb cb, void* ctx, MirEvent* mir_event)
44{44{
45 Event ubuntu_ev;45 Event ubuntu_ev;
46 auto translated_event = uaum::event_to_ubuntu_event(mir_event, ubuntu_ev);46 auto translated_event = uaum::event_to_ubuntu_deprecated_event(mir_event, ubuntu_ev);
47 if (translated_event)47 if (translated_event)
48 cb(ctx, &ubuntu_ev);48 cb(ctx, &ubuntu_ev);
49}49}
5050
=== modified file 'src/ubuntu/application/desktop/module_version.h'
--- src/ubuntu/application/desktop/module_version.h 2014-06-20 14:54:35 +0000
+++ src/ubuntu/application/desktop/module_version.h 2014-07-24 12:27:07 +0000
@@ -1,3 +1,3 @@
1#define MODULE_VERSION_MAJOR 21#define MODULE_VERSION_MAJOR 2
2#define MODULE_VERSION_MINOR 12#define MODULE_VERSION_MINOR 2
3#define MODULE_VERSION_PATCH 03#define MODULE_VERSION_PATCH 0
44
=== modified file 'src/ubuntu/application/testbackend/module_version.h'
--- src/ubuntu/application/testbackend/module_version.h 2014-06-20 14:54:35 +0000
+++ src/ubuntu/application/testbackend/module_version.h 2014-07-24 12:27:07 +0000
@@ -1,3 +1,3 @@
1#define MODULE_VERSION_MAJOR 21#define MODULE_VERSION_MAJOR 2
2#define MODULE_VERSION_MINOR 12#define MODULE_VERSION_MINOR 2
3#define MODULE_VERSION_PATCH 03#define MODULE_VERSION_PATCH 0
44
=== modified file 'src/ubuntu/application/testbackend/test_stubs.cpp'
--- src/ubuntu/application/testbackend/test_stubs.cpp 2014-05-29 14:14:31 +0000
+++ src/ubuntu/application/testbackend/test_stubs.cpp 2014-07-24 12:27:07 +0000
@@ -210,6 +210,10 @@
210{210{
211}211}
212212
213void ua_ui_window_properties_set_event_cb_and_ctx(UAUiWindowProperties*, UAUiWindowEventCb, void*)
214{
215}
216
213void ua_ui_window_properties_set_dimensions(UAUiWindowProperties*, uint32_t, uint32_t)217void ua_ui_window_properties_set_dimensions(UAUiWindowProperties*, uint32_t, uint32_t)
214{218{
215}219}
@@ -243,6 +247,11 @@
243 return U_STATUS_ERROR;247 return U_STATUS_ERROR;
244}248}
245249
250int ua_ui_window_is_focused(UAUiWindow *window)
251{
252 return 0;
253}
254
246UStatus ua_ui_window_show(UAUiWindow*)255UStatus ua_ui_window_show(UAUiWindow*)
247{256{
248 return U_STATUS_ERROR;257 return U_STATUS_ERROR;
249258
=== modified file 'src/ubuntu/application/touch/hybris/ubuntu_application_api_hybris.cpp'
--- src/ubuntu/application/touch/hybris/ubuntu_application_api_hybris.cpp 2014-05-20 12:45:42 +0000
+++ src/ubuntu/application/touch/hybris/ubuntu_application_api_hybris.cpp 2014-07-24 12:27:07 +0000
@@ -92,11 +92,14 @@
92IMPLEMENT_FUNCTION1(const char*, ua_ui_window_properties_get_title, UAUiWindowProperties*);92IMPLEMENT_FUNCTION1(const char*, ua_ui_window_properties_get_title, UAUiWindowProperties*);
93IMPLEMENT_VOID_FUNCTION2(ua_ui_window_properties_set_role, UAUiWindowProperties*, UAUiWindowRole);93IMPLEMENT_VOID_FUNCTION2(ua_ui_window_properties_set_role, UAUiWindowProperties*, UAUiWindowRole);
94IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_input_cb_and_ctx, UAUiWindowProperties*, UAUiWindowInputEventCb, void*);94IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_input_cb_and_ctx, UAUiWindowProperties*, UAUiWindowInputEventCb, void*);
95IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_event_cb_and_ctx, UAUiWindowProperties*, UAUiWindowEventCb, void*);
95IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_dimensions, UAUiWindowProperties*, uint32_t, uint32_t);96IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_dimensions, UAUiWindowProperties*, uint32_t, uint32_t);
9697
97// UAUiWindow98// UAUiWindow
98IMPLEMENT_FUNCTION2(UAUiWindow*, ua_ui_window_new_for_application_with_properties, UApplicationInstance*, UAUiWindowProperties*);99IMPLEMENT_FUNCTION2(UAUiWindow*, ua_ui_window_new_for_application_with_properties, UApplicationInstance*, UAUiWindowProperties*);
99IMPLEMENT_VOID_FUNCTION1(ua_ui_window_destroy, UAUiWindow*);100IMPLEMENT_VOID_FUNCTION1(ua_ui_window_destroy, UAUiWindow*);
101IMPLEMENT_VOID_FUNCTION3(ua_ui_window_get_size, UAUiWindow*, uint32_t*, uint32_t*);
102IMPLEMENT_FUNCTION1(int, ua_ui_window_is_focused, UAUiWindow*);
100IMPLEMENT_FUNCTION3(UStatus, ua_ui_window_move, UAUiWindow*, uint32_t, uint32_t);103IMPLEMENT_FUNCTION3(UStatus, ua_ui_window_move, UAUiWindow*, uint32_t, uint32_t);
101IMPLEMENT_FUNCTION3(UStatus, ua_ui_window_resize, UAUiWindow*, uint32_t, uint32_t);104IMPLEMENT_FUNCTION3(UStatus, ua_ui_window_resize, UAUiWindow*, uint32_t, uint32_t);
102IMPLEMENT_FUNCTION1(UStatus, ua_ui_window_hide, UAUiWindow*);105IMPLEMENT_FUNCTION1(UStatus, ua_ui_window_hide, UAUiWindow*);
103106
=== modified file 'src/ubuntu/application/touch/module_version.h'
--- src/ubuntu/application/touch/module_version.h 2014-06-20 14:54:35 +0000
+++ src/ubuntu/application/touch/module_version.h 2014-07-24 12:27:07 +0000
@@ -1,3 +1,3 @@
1#define MODULE_VERSION_MAJOR 21#define MODULE_VERSION_MAJOR 2
2#define MODULE_VERSION_MINOR 12#define MODULE_VERSION_MINOR 2
3#define MODULE_VERSION_PATCH 03#define MODULE_VERSION_PATCH 0
44
=== modified file 'src/ubuntu/application/ubuntu_application_api.cpp'
--- src/ubuntu/application/ubuntu_application_api.cpp 2014-06-24 11:09:30 +0000
+++ src/ubuntu/application/ubuntu_application_api.cpp 2014-07-24 12:27:07 +0000
@@ -107,12 +107,14 @@
107IMPLEMENT_FUNCTION1(const char*, ua_ui_window_properties_get_title, UAUiWindowProperties*);107IMPLEMENT_FUNCTION1(const char*, ua_ui_window_properties_get_title, UAUiWindowProperties*);
108IMPLEMENT_VOID_FUNCTION2(ua_ui_window_properties_set_role, UAUiWindowProperties*, UAUiWindowRole);108IMPLEMENT_VOID_FUNCTION2(ua_ui_window_properties_set_role, UAUiWindowProperties*, UAUiWindowRole);
109IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_input_cb_and_ctx, UAUiWindowProperties*, UAUiWindowInputEventCb, void*);109IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_input_cb_and_ctx, UAUiWindowProperties*, UAUiWindowInputEventCb, void*);
110IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_event_cb_and_ctx, UAUiWindowProperties*, UAUiWindowEventCb, void*);
110IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_dimensions, UAUiWindowProperties*, uint32_t, uint32_t);111IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_dimensions, UAUiWindowProperties*, uint32_t, uint32_t);
111112
112// UAUiWindow113// UAUiWindow
113IMPLEMENT_FUNCTION2(UAUiWindow*, ua_ui_window_new_for_application_with_properties, UApplicationInstance*, UAUiWindowProperties*);114IMPLEMENT_FUNCTION2(UAUiWindow*, ua_ui_window_new_for_application_with_properties, UApplicationInstance*, UAUiWindowProperties*);
114IMPLEMENT_VOID_FUNCTION1(ua_ui_window_destroy, UAUiWindow*);115IMPLEMENT_VOID_FUNCTION1(ua_ui_window_destroy, UAUiWindow*);
115IMPLEMENT_VOID_FUNCTION3(ua_ui_window_get_size, UAUiWindow*, uint32_t*, uint32_t*);116IMPLEMENT_VOID_FUNCTION3(ua_ui_window_get_size, UAUiWindow*, uint32_t*, uint32_t*);
117IMPLEMENT_FUNCTION1(int, ua_ui_window_is_focused, UAUiWindow*);
116IMPLEMENT_FUNCTION3(UStatus, ua_ui_window_move, UAUiWindow*, uint32_t, uint32_t);118IMPLEMENT_FUNCTION3(UStatus, ua_ui_window_move, UAUiWindow*, uint32_t, uint32_t);
117IMPLEMENT_FUNCTION3(UStatus, ua_ui_window_resize, UAUiWindow*, uint32_t, uint32_t);119IMPLEMENT_FUNCTION3(UStatus, ua_ui_window_resize, UAUiWindow*, uint32_t, uint32_t);
118IMPLEMENT_FUNCTION1(UStatus, ua_ui_window_hide, UAUiWindow*);120IMPLEMENT_FUNCTION1(UStatus, ua_ui_window_hide, UAUiWindow*);

Subscribers

People subscribed via source and target branches