Merge lp:~mir-team/qtubuntu/port-to-mirclient into lp:qtubuntu
- port-to-mirclient
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Daniel d'Andrada |
Approved revision: | 278 |
Merged at revision: | 256 |
Proposed branch: | lp:~mir-team/qtubuntu/port-to-mirclient |
Merge into: | lp:qtubuntu |
Diff against target: |
969 lines (+345/-276) 7 files modified
debian/control (+2/-1) src/ubuntumirclient/input.cpp (+196/-193) src/ubuntumirclient/input.h (+10/-5) src/ubuntumirclient/integration.cpp (+2/-2) src/ubuntumirclient/ubuntumirclient.pro (+1/-3) src/ubuntumirclient/window.cpp (+129/-69) src/ubuntumirclient/window.h (+5/-3) |
To merge this branch: | bzr merge lp:~mir-team/qtubuntu/port-to-mirclient |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel d'Andrada (community) | Approve | ||
Gerry Boland (community) | Abstain | ||
Michał Sawicz | packaging | Approve | |
Albert Astals Cid (community) | Approve | ||
PS Jenkins bot | continuous-integration | Needs Fixing | |
Josh Arenson (community) | Needs Fixing | ||
Review via email: mp+245164@code.launchpad.net |
Commit message
Port qtubuntu to direct mirclient usage for window creation and input handling.
Description of the change
Port qtubuntu to hybrid usage of PAPI and mirclient as described here: https:/
Thought I would get this early air, though the expose-
Robert Carr (robertcarr) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:260
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Albert Astals Cid (aacid) wrote : | # |
Doesn't build here
../../.
../../.
Robert Carr (robertcarr) wrote : | # |
Trying to land with the dependency: https:/
soon! Please review :)
Robert Carr (robertcarr) wrote : | # |
I should resolve the dependency about adding pointer event support before this lands imo. (lest mild regression of sorts)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:261
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) wrote : | # |
Some package versioning bumping is needed. The required PAPI branch should get a bump, and this should depend on that.
Robert Carr (robertcarr) wrote : | # |
Corrected linkage against PAPI (weirdly wasnt using pkgconfig causing some peoples test builds to fail via not pulling in new PAPI)
Bumped debian dependency on PAPI doesnt seem qmake pkgconfig supports versioning
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:263
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Josh Arenson (josharenson) wrote : | # |
It seems that the OSK doesn't appear for me to enter my passphrase at the greeter. There is a maliit crash log that simply says "ERROR: whoopsie is not running" several times.
Running on mako w/ latest image + expose-
Robert Carr (robertcarr) wrote : | # |
Added pointer event support.
Havent tested on device in a while so I guess I need to try again...can you describe your steps Josh? e.g. build to package, run from /usr, run out of prefix, etc.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:264
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Robert Carr (robertcarr) wrote : | # |
Discovered platform-api was interpreting the OSK role and using it to set mir_surface_
mir_surface_
https:/
Robert Carr (robertcarr) wrote : | # |
Building stuff for test now
Robert Carr (robertcarr) wrote : | # |
Context: This branch breaks the OSK last anyone tested.
Robert Carr (robertcarr) wrote : | # |
With https:/
Robert Carr (robertcarr) wrote : | # |
p.s. pointer events are tested on desktop with qt5 examples.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:266
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:267
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) wrote : | # |
Fails to build with debug on:
qmake CONFIG+=debug QMAKE_CXXFLAGS=
../../.
../../.
LOG("role: '%d'", role);
../../.
#define LOG(...) qDebug(__VA_ARGS__)
Gerry Boland (gerboland) wrote : | # |
+ MirEvent const* nativeEvent = ubuntuEvent-
please use our code style:
const MirEvent *nativeEvent
Bunch of other instances of your more Mir-y style here:
+void UbuntuInput:
+void UbuntuInput:
+void UbuntuInput:
+Qt::MouseButton extract_
+void UbuntuInput:
+void UbuntuInput:
Gerry Boland (gerboland) wrote : | # |
- WindowEvent *nativeEvent = &ubuntuEvent-
+ MirEvent const* nativeEvent = ubuntuEvent-
certain this ok?
Gerry Boland (gerboland) wrote : | # |
it is, ignore that
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:270
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Alberto Aguirre (albaguirre) wrote : | # |
> Fails to build with debug on:
> qmake CONFIG+=debug QMAKE_CXXFLAGS=
>
Fixed.
Alberto Aguirre (albaguirre) wrote : | # |
> + MirEvent const* nativeEvent = ubuntuEvent-
> please use our code style:
> const MirEvent *nativeEvent
>
> Bunch of other instances of your more Mir-y style here:
>
> +void UbuntuInput:
> ev)
> +void UbuntuInput:
> ev)
> +void UbuntuInput:
> +Qt::MouseButton extract_
> +void UbuntuInput:
> ev)
> +void UbuntuInput:
> MirOrientationEvent const* event)
Done.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:271
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Albert Astals Cid (aacid) wrote : | # |
Fails to compile, is that because it needs a newer mir than the one that the debian/ specifies?
Alberto Aguirre (albaguirre) wrote : | # |
> Fails to compile, is that because it needs a newer mir than the one that the
> debian/ specifies?
Yes, mir 0.11 will have the new spec api.
Albert Astals Cid (aacid) wrote : | # |
- if (ubuntuEvent-
+ if (ubuntuEvent-
Should the second one be
if (ubuntuEvent-
To also cover what the previous check was doing?
Albert Astals Cid (aacid) wrote : | # |
- //DLOG(
+ DLOG("UbuntuInp
You sure you want to reenable this debug?
Albert Astals Cid (aacid) wrote : | # |
- DLOG("unhandled event type %d", nativeEvent->type);
+ DLOG("unhandled event type");
Any reason you decided not to include the event type anymore? I think it's nice to have it in the log, otherwise if it ever happens we'll end up wondering which event was and how it could happen.
Albert Astals Cid (aacid) wrote : | # |
In ::postEvent you have two
reinterpret_
that should be removed since event is already a const MirEvent*
Albert Astals Cid (aacid) wrote : | # |
const MirInputEvent *event = reinterpret_
You don't need the cast here either since ev is a const MirInputEvent*
Albert Astals Cid (aacid) wrote : | # |
in
qt_modifiers_
why not make q_modifiers a Qt::KeyboardMod
Albert Astals Cid (aacid) wrote : | # |
in
extract_
why not make q_modifiers a Qt::MouseButton instead of an int so you can save the last static_cast?
Albert Astals Cid (aacid) wrote : | # |
+ // TODO: Update to use MirEvent
+ void postEvent(
This TODO is old?
Albert Astals Cid (aacid) wrote : | # |
Compiled manually and ran some manual tests and could not find anything wrong, looks code sane too (but will wait for giving my approval until the small comments i made above are resolved)
Robert Carr (robertcarr) wrote : | # |
Thanks sorry for all the small errors. I should read the Qt Style Guide.
>>
>> - if (ubuntuEvent-
>> + if (ubuntuEvent-
>> Should the second one be
>> if (ubuntuEvent-
>> To also cover what the previous check was doing?
Fixed.
>> Any reason you decided not to include the event type anymore? I think it's nice to have it in >> the log, otherwise if it ever happens we'll end up wondering which event was and how it could >> happen.
Fixed.
>> reinterpret_
Fixed
>> why not make q_modifiers a Qt::KeyboardMod
>> static_cast?
>> why not make q_modifiers a Qt::MouseButton instead of an int so you can save the last
>> static_cast?
Because operator| casts the Qt::KeyboardMod
>> This TODO is old?
Why yes it is!
>> Compiled manually and ran some manual tests and could not find anything wrong, looks code sane >> too (but will wait for giving my approval until the small comments i made above are resolved)
Yay. Thanks again.
Thanks :)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:272
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Albert Astals Cid (aacid) wrote : | # |
> >> why not make q_modifiers a Qt::KeyboardMod
> can save the last
> >> static_cast?
> >> why not make q_modifiers a Qt::MouseButton instead of an int so you can
> save the last
> >> static_cast?
>
> Because operator| casts the Qt::KeyboardMod
> to assign back to a Qt::Modifier results in an illegal conversion between int
> and enum types. Enums can not be used as flags in C++ without a cast or
> operator overloading.
No, Qt::KeyboardMod
Robert Carr (robertcarr) wrote : | # |
>>No, Qt::KeyboardMod
Whoops! I was using Qt::KeyboardMod
fixed for buttons as well, thanks.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:273
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Albert Astals Cid (aacid) wrote : | # |
Looks good to me both code and testing wise.
Daniel d'Andrada (dandrader) wrote : | # |
In src/ubuntumircl
"""
843 - ua_ui_window_
844 + setWindowState(
845 +
"""
This breaks the use case of applications that start up as fullscreen, such as camera-app and media-player. They are starting as fullscreen but get immediately resized to "non-fullscreen" because setVisible(true) has the side-effect of going out of fullscreen state with the change above.
Daniel d'Andrada (dandrader) wrote : | # |
> In src/ubuntumircl
>
> """
> 843 - ua_ui_window_
> 844 + setWindowState(
> 845 +
> """
>
> This breaks the use case of applications that start up as fullscreen, such as
> camera-app and media-player. They are starting as fullscreen but get
> immediately resized to "non-fullscreen" because setVisible(true) has the side-
> effect of going out of fullscreen state with the change above.
I recall I fixed that very same bug in platform api, becasue mir has no concept of visibility, only window states. So just have to port the fix (or hack) from platform-api to qtubuntu
Daniel d'Andrada (dandrader) wrote : | # |
> > In src/ubuntumircl
> >
> > """
> > 843 - ua_ui_window_
> > 844 + setWindowState(
> > 845 +
> > """
> >
> > This breaks the use case of applications that start up as fullscreen, such
> as
> > camera-app and media-player. They are starting as fullscreen but get
> > immediately resized to "non-fullscreen" because setVisible(true) has the
> side-
> > effect of going out of fullscreen state with the change above.
>
> I recall I fixed that very same bug in platform api, becasue mir has no
> concept of visibility, only window states. So just have to port the fix (or
> hack) from platform-api to qtubuntu
Pushed the fix myself.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:274
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:275
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:276
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Albert Astals Cid (aacid) wrote : | # |
Daniel's code fixes the regression he found
Michał Sawicz (saviq) : | # |
Michał Sawicz (saviq) wrote : | # |
../../.
So yeah, please fix build deps.
Robert Carr (robertcarr) wrote : | # |
r277 fixes version. Thanks :)
Michał Sawicz (saviq) : | # |
Gerry Boland (gerboland) : | # |
Daniel d'Andrada (dandrader) wrote : | # |
I was wondering, now that it's using mirclient api directly, shouldn't it have libmirclient-dev in Build-Depends in debian/control?
Robert Carr (robertcarr) wrote : | # |
Yes, thanks! Corrected, should beretaed.
Preview Diff
1 | === modified file 'debian/control' |
2 | --- debian/control 2014-10-09 05:22:34 +0000 |
3 | +++ debian/control 2015-03-05 19:55:08 +0000 |
4 | @@ -9,7 +9,7 @@ |
5 | libgles2-mesa-dev, |
6 | libglib2.0-dev, |
7 | libmtdev-dev, |
8 | - libubuntu-application-api-dev (>= 2.5.0), |
9 | + libubuntu-application-api-dev (>= 2.9.0), |
10 | libudev-dev, |
11 | libxrender-dev, |
12 | libxkbcommon-dev, |
13 | @@ -17,6 +17,7 @@ |
14 | qtbase5-private-dev, |
15 | qtdeclarative5-dev, |
16 | libqt5sensors5-dev, |
17 | + libmirclient-dev (>= 0.11.0), |
18 | # if you don't have have commit access to this branch but would like to upload |
19 | # directly to Ubuntu, don't worry: your changes will be merged back into the |
20 | # upstream branch |
21 | |
22 | === modified file 'src/ubuntumirclient/input.cpp' |
23 | --- src/ubuntumirclient/input.cpp 2014-12-12 15:43:19 +0000 |
24 | +++ src/ubuntumirclient/input.cpp 2015-03-05 19:55:08 +0000 |
25 | @@ -1,5 +1,5 @@ |
26 | /* |
27 | - * Copyright (C) 2014 Canonical, Ltd. |
28 | + * Copyright (C) 2014-2015 Canonical, Ltd. |
29 | * |
30 | * This program is free software: you can redistribute it and/or modify it under |
31 | * the terms of the GNU Lesser General Public License version 3, as published by |
32 | @@ -36,9 +36,7 @@ |
33 | #include <xkbcommon/xkbcommon.h> |
34 | #include <xkbcommon/xkbcommon-keysyms.h> |
35 | |
36 | -// Platform API |
37 | -#include <ubuntu/application/ui/input/event.h> |
38 | -#include <ubuntu/application/ui/window_orientation.h> |
39 | +#include <mir_toolkit/mir_client_library.h> |
40 | |
41 | #define LOG_EVENTS 0 |
42 | |
43 | @@ -122,23 +120,20 @@ |
44 | 0, 0 |
45 | }; |
46 | |
47 | -// Lookup table for the key types. |
48 | -// FIXME(loicm) Not sure what to do with that multiple thing. |
49 | -static const QEvent::Type kEventType[] = { |
50 | - QEvent::KeyPress, // U_KEY_ACTION_DOWN = 0 |
51 | - QEvent::KeyRelease, // U_KEY_ACTION_UP = 1 |
52 | - QEvent::KeyPress // U_KEY_ACTION_MULTIPLE = 2 |
53 | -}; |
54 | - |
55 | class UbuntuEvent : public QEvent |
56 | { |
57 | public: |
58 | - UbuntuEvent(UbuntuWindow* window, const WindowEvent* event, QEvent::Type type) |
59 | + UbuntuEvent(UbuntuWindow* window, const MirEvent *event, QEvent::Type type) |
60 | : QEvent(type), window(window) { |
61 | - memcpy(&nativeEvent, event, sizeof(WindowEvent)); |
62 | - } |
63 | - UbuntuWindow* window; |
64 | - WindowEvent nativeEvent; |
65 | + nativeEvent = mir_event_ref(event); |
66 | + } |
67 | + ~UbuntuEvent() |
68 | + { |
69 | + mir_event_unref(nativeEvent); |
70 | + } |
71 | + |
72 | + QPointer<UbuntuWindow> window; |
73 | + const MirEvent *nativeEvent; |
74 | }; |
75 | |
76 | UbuntuInput::UbuntuInput(UbuntuClientIntegration* integration) |
77 | @@ -163,124 +158,124 @@ |
78 | } |
79 | |
80 | #ifndef QT_NO_DEBUG |
81 | -/* |
82 | -static const char* nativeEventTypeToStr(int eventType) |
83 | + |
84 | + |
85 | +static const char* nativeEventTypeToStr(MirEventType t) |
86 | { |
87 | - switch (eventType) { |
88 | - case MOTION_WEVENT_TYPE: |
89 | - return "MOTION_WEVENT_TYPE"; |
90 | - break; |
91 | - case KEY_WEVENT_TYPE: |
92 | - return "KEY_WEVENT_TYPE"; |
93 | - break; |
94 | - case RESIZE_WEVENT_TYPE: |
95 | - return "RESIZE_WEVENT_TYPE"; |
96 | - break; |
97 | - case SURFACE_WEVENT_TYPE: |
98 | - return "SURFACE_WEVENT_TYPE"; |
99 | - break; |
100 | - case ORIENTATION_WEVENT_TYPE: |
101 | - return "ORIENTATION_WEVENT_TYPE"; |
102 | - break; |
103 | + switch (t) |
104 | + { |
105 | + case mir_event_type_key: |
106 | + return "mir_event_type_key"; |
107 | + case mir_event_type_motion: |
108 | + return "mir_event_type_motion"; |
109 | + case mir_event_type_surface: |
110 | + return "mir_event_type_surface"; |
111 | + case mir_event_type_resize: |
112 | + return "mir_event_type_resize"; |
113 | + case mir_event_type_prompt_session_state_change: |
114 | + return "mir_event_type_prompt_session_state_change"; |
115 | + case mir_event_type_orientation: |
116 | + return "mir_event_type_orientation"; |
117 | + case mir_event_type_close_surface: |
118 | + return "mir_event_type_close_surface"; |
119 | + case mir_event_type_input: |
120 | + return "mir_event_type_input"; |
121 | default: |
122 | - return "INVALID!"; |
123 | + DLOG("Invalid event type %d", t); |
124 | + return "invalid"; |
125 | } |
126 | } |
127 | -*/ |
128 | + |
129 | + |
130 | #endif |
131 | |
132 | void UbuntuInput::customEvent(QEvent* event) |
133 | { |
134 | DASSERT(QThread::currentThread() == thread()); |
135 | UbuntuEvent* ubuntuEvent = static_cast<UbuntuEvent*>(event); |
136 | - WindowEvent *nativeEvent = &ubuntuEvent->nativeEvent; |
137 | + const MirEvent *nativeEvent = ubuntuEvent->nativeEvent; |
138 | |
139 | - if (ubuntuEvent->window->window() == nullptr) { |
140 | - qWarning() << "Attempted to deliver an event to a non-existant QWindow, ignoring."; |
141 | + if ((ubuntuEvent->window == nullptr) || (ubuntuEvent->window->window() == nullptr)) { |
142 | + qWarning() << "Attempted to deliver an event to a non-existent window, ignoring."; |
143 | return; |
144 | } |
145 | |
146 | // Event filtering. |
147 | long result; |
148 | if (QWindowSystemInterface::handleNativeEvent( |
149 | - ubuntuEvent->window->window(), mEventFilterType, nativeEvent, &result) == true) { |
150 | + ubuntuEvent->window->window(), mEventFilterType, |
151 | + const_cast<void *>(static_cast<const void *>(nativeEvent)), &result) == true) { |
152 | DLOG("event filtered out by native interface"); |
153 | return; |
154 | } |
155 | |
156 | - //DLOG("UbuntuInput::customEvent(type=%s)", nativeEventTypeToStr(nativeEvent->type)); |
157 | + //DLOG("UbuntuInput::customEvent(type=%s)", nativeEventTypeToStr(mir_event_get_type(nativeEvent))); |
158 | |
159 | // Event dispatching. |
160 | - switch (nativeEvent->type) { |
161 | - case MOTION_WEVENT_TYPE: |
162 | - dispatchMotionEvent(ubuntuEvent->window->window(), nativeEvent); |
163 | - break; |
164 | - case KEY_WEVENT_TYPE: |
165 | - dispatchKeyEvent(ubuntuEvent->window->window(), nativeEvent); |
166 | - break; |
167 | - case RESIZE_WEVENT_TYPE: |
168 | - ubuntuEvent->window->handleSurfaceResize(nativeEvent->resize.width, |
169 | - nativeEvent->resize.height); |
170 | - break; |
171 | - case SURFACE_WEVENT_TYPE: |
172 | - if (nativeEvent->surface.attribute == SURFACE_ATTRIBUTE_FOCUS) { |
173 | - ubuntuEvent->window->handleSurfaceFocusChange(nativeEvent->surface.value == 1); |
174 | + switch (mir_event_get_type(nativeEvent)) |
175 | + { |
176 | + case mir_event_type_input: |
177 | + dispatchInputEvent(ubuntuEvent->window->window(), mir_event_get_input_event(nativeEvent)); |
178 | + break; |
179 | + case mir_event_type_resize: |
180 | + { |
181 | + auto resizeEvent = mir_event_get_resize_event(nativeEvent); |
182 | + ubuntuEvent->window->handleSurfaceResize(mir_resize_event_get_width(resizeEvent), |
183 | + mir_resize_event_get_height(resizeEvent)); |
184 | + break; |
185 | + } |
186 | + case mir_event_type_surface: |
187 | + { |
188 | + auto surfaceEvent = mir_event_get_surface_event(nativeEvent); |
189 | + if (mir_surface_event_get_attribute(surfaceEvent) == mir_surface_attrib_focus) { |
190 | + ubuntuEvent->window->handleSurfaceFocusChange(mir_surface_event_get_attribute_value(surfaceEvent) == |
191 | + mir_surface_focused); |
192 | } |
193 | break; |
194 | - case ORIENTATION_WEVENT_TYPE: |
195 | - dispatchOrientationEvent(ubuntuEvent->window->window(), nativeEvent); |
196 | + } |
197 | + case mir_event_type_orientation: |
198 | + dispatchOrientationEvent(ubuntuEvent->window->window(), mir_event_get_orientation_event(nativeEvent)); |
199 | break; |
200 | default: |
201 | - DLOG("unhandled event type %d", nativeEvent->type); |
202 | + DLOG("unhandled event type: %d", static_cast<int>(mir_event_get_type(nativeEvent))); |
203 | } |
204 | } |
205 | |
206 | -void UbuntuInput::postEvent(UbuntuWindow* platformWindow, const void* event) |
207 | +void UbuntuInput::postEvent(UbuntuWindow *platformWindow, const MirEvent *event) |
208 | { |
209 | QWindow *window = platformWindow->window(); |
210 | |
211 | QCoreApplication::postEvent(this, new UbuntuEvent( |
212 | - platformWindow, reinterpret_cast<const WindowEvent*>(event), mEventType)); |
213 | + platformWindow, event, mEventType)); |
214 | |
215 | if ((window->flags() && Qt::WindowTransparentForInput) && window->parent()) { |
216 | QCoreApplication::postEvent(this, new UbuntuEvent( |
217 | static_cast<UbuntuWindow*>(platformWindow->QPlatformWindow::parent()), |
218 | - reinterpret_cast<const WindowEvent*>(event), mEventType)); |
219 | - } |
220 | -} |
221 | - |
222 | -void UbuntuInput::dispatchMotionEvent(QWindow* window, const void* ev) |
223 | -{ |
224 | - const WindowEvent* event = reinterpret_cast<const WindowEvent*>(ev); |
225 | - |
226 | - #if (LOG_EVENTS != 0) |
227 | - // Motion event logging. |
228 | - LOG("MOTION device_id:%d source_id:%d action:%d flags:%d meta_state:%d edge_flags:%d " |
229 | - "button_state:%d x_offset:%.2f y_offset:%.2f x_precision:%.2f y_precision:%.2f " |
230 | - "down_time:%lld event_time:%lld pointer_count:%d {", event->motion.device_id, |
231 | - event->motion.source_id, event->motion.action, |
232 | - event->motion.flags, event->motion.meta_state, |
233 | - event->motion.edge_flags, event->motion.button_state, |
234 | - event->motion.x_offset, event->motion.y_offset, |
235 | - event->motion.x_precision, event->motion.y_precision, |
236 | - event->motion.down_time, event->motion.event_time, |
237 | - event->motion.pointer_count); |
238 | - for (size_t i = 0; i < event->motion.pointer_count; i++) { |
239 | - LOG(" id:%d x:%.2f y:%.2f rx:%.2f ry:%.2f maj:%.2f min:%.2f sz:%.2f press:%.2f", |
240 | - event->motion.pointer_coordinates[i].id, |
241 | - event->motion.pointer_coordinates[i].x, |
242 | - event->motion.pointer_coordinates[i].y, |
243 | - event->motion.pointer_coordinates[i].raw_x, |
244 | - event->motion.pointer_coordinates[i].raw_y, |
245 | - event->motion.pointer_coordinates[i].touch_major, |
246 | - event->motion.pointer_coordinates[i].touch_minor, |
247 | - event->motion.pointer_coordinates[i].size, |
248 | - event->motion.pointer_coordinates[i].pressure |
249 | - // event->motion.pointer_coordinates[i].orientation -> Always 0.0. |
250 | - ); |
251 | - } |
252 | - LOG("}"); |
253 | - #endif |
254 | + event, mEventType)); |
255 | + } |
256 | +} |
257 | + |
258 | +void UbuntuInput::dispatchInputEvent(QWindow *window, const MirInputEvent *ev) |
259 | +{ |
260 | + switch (mir_input_event_get_type(ev)) |
261 | + { |
262 | + case mir_input_event_type_key: |
263 | + dispatchKeyEvent(window, ev); |
264 | + break; |
265 | + case mir_input_event_type_touch: |
266 | + dispatchTouchEvent(window, ev); |
267 | + break; |
268 | + case mir_input_event_type_pointer: |
269 | + dispatchPointerEvent(window, ev); |
270 | + break; |
271 | + default: |
272 | + break; |
273 | + } |
274 | +} |
275 | + |
276 | +void UbuntuInput::dispatchTouchEvent(QWindow *window, const MirInputEvent *ev) |
277 | +{ |
278 | + const MirTouchInputEvent *tev = mir_input_event_get_touch_input_event(ev); |
279 | |
280 | // FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That |
281 | // needs to be fixed as soon as the compat input lib adds query support. |
282 | @@ -291,62 +286,39 @@ |
283 | |
284 | // TODO: Is it worth setting the Qt::TouchPointStationary ones? Currently they are left |
285 | // as Qt::TouchPointMoved |
286 | - const int kPointerCount = event->motion.pointer_count; |
287 | - for (int i = 0; i < kPointerCount; ++i) { |
288 | + const unsigned int kPointerCount = mir_touch_input_event_get_touch_count(tev); |
289 | + for (unsigned int i = 0; i < kPointerCount; ++i) { |
290 | QWindowSystemInterface::TouchPoint touchPoint; |
291 | |
292 | - const float kX = event->motion.pointer_coordinates[i].raw_x + kWindowGeometry.x(); |
293 | - const float kY = event->motion.pointer_coordinates[i].raw_y + kWindowGeometry.y(); // see bug lp:1346633 workaround comments elsewhere |
294 | - const float kW = event->motion.pointer_coordinates[i].touch_major; |
295 | - const float kH = event->motion.pointer_coordinates[i].touch_minor; |
296 | - const float kP = event->motion.pointer_coordinates[i].pressure; |
297 | - touchPoint.id = event->motion.pointer_coordinates[i].id; |
298 | + const float kX = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_x) + kWindowGeometry.x(); |
299 | + const float kY = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_y) + kWindowGeometry.y(); // see bug lp:1346633 workaround comments elsewhere |
300 | + const float kW = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_touch_major); |
301 | + const float kH = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_touch_minor); |
302 | + const float kP = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_pressure); |
303 | + touchPoint.id = mir_touch_input_event_get_touch_id(tev, i); |
304 | touchPoint.normalPosition = QPointF(kX / kWindowGeometry.width(), kY / kWindowGeometry.height()); |
305 | touchPoint.area = QRectF(kX - (kW / 2.0), kY - (kH / 2.0), kW, kH); |
306 | touchPoint.pressure = kP / kMaxPressure; |
307 | - touchPoint.state = Qt::TouchPointMoved; |
308 | + |
309 | + MirTouchInputEventTouchAction touch_action = mir_touch_input_event_get_touch_action(tev, i); |
310 | + switch (touch_action) |
311 | + { |
312 | + case mir_touch_input_event_action_down: |
313 | + touchPoint.state = Qt::TouchPointPressed; |
314 | + break; |
315 | + case mir_touch_input_event_action_up: |
316 | + touchPoint.state = Qt::TouchPointReleased; |
317 | + break; |
318 | + case mir_touch_input_event_action_change: |
319 | + default: |
320 | + touchPoint.state = Qt::TouchPointMoved; |
321 | + } |
322 | |
323 | touchPoints.append(touchPoint); |
324 | } |
325 | |
326 | - switch (event->motion.action & U_MOTION_ACTION_MASK) { |
327 | - case U_MOTION_ACTION_MOVE: |
328 | - // No extra work needed. |
329 | - break; |
330 | - |
331 | - case U_MOTION_ACTION_DOWN: |
332 | - touchPoints[0].state = Qt::TouchPointPressed; |
333 | - break; |
334 | - |
335 | - case U_MOTION_ACTION_UP: |
336 | - touchPoints[0].state = Qt::TouchPointReleased; |
337 | - break; |
338 | - |
339 | - case U_MOTION_ACTION_POINTER_DOWN: { |
340 | - const int index = (event->motion.action & U_MOTION_ACTION_POINTER_INDEX_MASK) >> |
341 | - U_MOTION_ACTION_POINTER_INDEX_SHIFT; |
342 | - touchPoints[index].state = Qt::TouchPointPressed; |
343 | - break; |
344 | - } |
345 | - |
346 | - case U_MOTION_ACTION_CANCEL: |
347 | - case U_MOTION_ACTION_POINTER_UP: { |
348 | - const int index = (event->motion.action & U_MOTION_ACTION_POINTER_INDEX_MASK) >> |
349 | - U_MOTION_ACTION_POINTER_INDEX_SHIFT; |
350 | - touchPoints[index].state = Qt::TouchPointReleased; |
351 | - break; |
352 | - } |
353 | - |
354 | - case U_MOTION_ACTION_OUTSIDE: |
355 | - case U_MOTION_ACTION_HOVER_MOVE: |
356 | - case U_MOTION_ACTION_SCROLL: |
357 | - case U_MOTION_ACTION_HOVER_ENTER: |
358 | - case U_MOTION_ACTION_HOVER_EXIT: |
359 | - default: |
360 | - DLOG("unhandled motion event action %d", event->motion.action & U_MOTION_ACTION_MASK); |
361 | - } |
362 | - |
363 | - QWindowSystemInterface::handleTouchEvent(window, event->motion.event_time / 1000000, |
364 | + ulong timestamp = mir_input_event_get_event_time(ev) / 1000000; |
365 | + QWindowSystemInterface::handleTouchEvent(window, timestamp, |
366 | mTouchDevice, touchPoints); |
367 | } |
368 | |
369 | @@ -368,49 +340,48 @@ |
370 | return toupper(sym); |
371 | } |
372 | |
373 | -void UbuntuInput::dispatchKeyEvent(QWindow* window, const void* ev) |
374 | -{ |
375 | - const WindowEvent* event = reinterpret_cast<const WindowEvent*>(ev); |
376 | - |
377 | - #if (LOG_EVENTS != 0) |
378 | - // Key event logging. |
379 | - LOG("KEY device_id:%d source_id:%d action:%d flags:%d meta_state:%d key_code:%d " |
380 | - "scan_code:%d repeat_count:%d down_time:%lld event_time:%lld is_system_key:%d", |
381 | - event->key.device_id, event->key.source_id, |
382 | - event->key.action, event->key.flags, event->key.meta_state, |
383 | - event->key.key_code, event->key.scan_code, |
384 | - event->key.repeat_count, event->key.down_time, |
385 | - event->key.event_time, event->key.is_system_key); |
386 | - #endif |
387 | - |
388 | - ulong timestamp = event->key.event_time / 1000000; |
389 | - xkb_keysym_t xk_sym = (xkb_keysym_t)event->key.key_code; |
390 | +namespace |
391 | +{ |
392 | +Qt::KeyboardModifiers qt_modifiers_from_mir(MirInputEventModifiers modifiers) |
393 | +{ |
394 | + Qt::KeyboardModifiers q_modifiers = Qt::NoModifier; |
395 | + if (modifiers & mir_input_event_modifier_shift) { |
396 | + q_modifiers |= Qt::ShiftModifier; |
397 | + } |
398 | + if (modifiers & mir_input_event_modifier_ctrl) { |
399 | + q_modifiers |= Qt::ControlModifier; |
400 | + } |
401 | + if (modifiers & mir_input_event_modifier_alt) { |
402 | + q_modifiers |= Qt::AltModifier; |
403 | + } |
404 | + if (modifiers & mir_input_event_modifier_meta) { |
405 | + q_modifiers |= Qt::MetaModifier; |
406 | + } |
407 | + return q_modifiers; |
408 | +} |
409 | +} |
410 | + |
411 | +void UbuntuInput::dispatchKeyEvent(QWindow *window, const MirInputEvent *event) |
412 | +{ |
413 | + const MirKeyInputEvent *key_event = mir_input_event_get_key_input_event(event); |
414 | + |
415 | + ulong timestamp = mir_input_event_get_event_time(event) / 1000000; |
416 | + xkb_keysym_t xk_sym = mir_key_input_event_get_key_code(key_event); |
417 | |
418 | // Key modifier and unicode index mapping. |
419 | - const int kMetaState = event->key.meta_state; |
420 | - Qt::KeyboardModifiers modifiers = Qt::NoModifier; |
421 | - if (kMetaState & U_KEY_MODIFIER_SHIFT) { |
422 | - modifiers |= Qt::ShiftModifier; |
423 | - } |
424 | - if (kMetaState & U_KEY_MODIFIER_CTRL) { |
425 | - modifiers |= Qt::ControlModifier; |
426 | - } |
427 | - if (kMetaState & U_KEY_MODIFIER_ALT) { |
428 | - modifiers |= Qt::AltModifier; |
429 | - } |
430 | - if (kMetaState & U_KEY_MODIFIER_META) { |
431 | - modifiers |= Qt::MetaModifier; |
432 | - } |
433 | + auto modifiers = qt_modifiers_from_mir(mir_key_input_event_get_modifiers(key_event)); |
434 | |
435 | - QEvent::Type keyType = event->key.action == U_KEY_ACTION_DOWN ? QEvent::KeyPress : QEvent::KeyRelease; |
436 | + MirKeyInputEventAction action = mir_key_input_event_get_action(key_event); |
437 | + QEvent::Type keyType = action == mir_key_input_event_action_up |
438 | + ? QEvent::KeyRelease : QEvent::KeyPress; |
439 | |
440 | char s[2]; |
441 | int sym = translateKeysym(xk_sym, s, sizeof(s)); |
442 | QString text = QString::fromLatin1(s); |
443 | |
444 | - bool is_auto_rep = event->key.repeat_count > 0; |
445 | + bool is_auto_rep = action == mir_key_input_event_action_repeat; |
446 | |
447 | - QPlatformInputContext* context = QGuiApplicationPrivate::platformIntegration()->inputContext(); |
448 | + QPlatformInputContext *context = QGuiApplicationPrivate::platformIntegration()->inputContext(); |
449 | if (context) { |
450 | QKeyEvent qKeyEvent(keyType, sym, modifiers, text, is_auto_rep); |
451 | qKeyEvent.setTimestamp(timestamp); |
452 | @@ -423,20 +394,53 @@ |
453 | QWindowSystemInterface::handleKeyEvent(window, timestamp, keyType, sym, modifiers, text, is_auto_rep); |
454 | } |
455 | |
456 | +namespace |
457 | +{ |
458 | +Qt::MouseButtons extract_buttons(const MirPointerInputEvent *pev) |
459 | +{ |
460 | + Qt::MouseButtons buttons = Qt::NoButton; |
461 | + if (mir_pointer_input_event_get_button_state(pev, mir_pointer_input_button_primary)) |
462 | + buttons |= Qt::LeftButton; |
463 | + if (mir_pointer_input_event_get_button_state(pev, mir_pointer_input_button_secondary)) |
464 | + buttons |= Qt::RightButton; |
465 | + if (mir_pointer_input_event_get_button_state(pev, mir_pointer_input_button_tertiary)) |
466 | + buttons |= Qt::MidButton; |
467 | + |
468 | + // TODO: Should mir back and forward buttons exist? |
469 | + // should they be Qt::X button 1 and 2? |
470 | + return buttons; |
471 | +} |
472 | +} |
473 | + |
474 | +void UbuntuInput::dispatchPointerEvent(QWindow *window, const MirInputEvent *ev) |
475 | +{ |
476 | + auto timestamp = mir_input_event_get_event_time(ev) / 1000000; |
477 | + |
478 | + auto pev = mir_input_event_get_pointer_input_event(ev); |
479 | + auto modifiers = qt_modifiers_from_mir(mir_pointer_input_event_get_modifiers(pev)); |
480 | + auto buttons = extract_buttons(pev); |
481 | + |
482 | + auto local_point = QPointF(mir_pointer_input_event_get_axis_value(pev, mir_pointer_input_axis_x), |
483 | + mir_pointer_input_event_get_axis_value(pev, mir_pointer_input_axis_y)); |
484 | + |
485 | + QWindowSystemInterface::handleMouseEvent(window, timestamp, local_point, local_point /* Should we omit global point instead? */, |
486 | + buttons, modifiers); |
487 | +} |
488 | + |
489 | #if (LOG_EVENTS != 0) |
490 | -static const char* nativeOrientationDirectionToStr(const int orientation) |
491 | +static const char* nativeOrientationDirectionToStr(MirOrientation orientation) |
492 | { |
493 | switch (orientation) { |
494 | - case U_ORIENTATION_NORMAL: |
495 | + case mir_orientation_normal: |
496 | return "Normal"; |
497 | break; |
498 | - case U_ORIENTATION_LEFT: |
499 | + case mir_orientation_left: |
500 | return "Left"; |
501 | break; |
502 | - case U_ORIENTATION_INVERTED: |
503 | + case mir_orientation_inverted: |
504 | return "Inverted"; |
505 | break; |
506 | - case U_ORIENTATION_RIGHT: |
507 | + case mir_orientation_right: |
508 | return "Right"; |
509 | break; |
510 | default: |
511 | @@ -445,13 +449,12 @@ |
512 | } |
513 | #endif |
514 | |
515 | -void UbuntuInput::dispatchOrientationEvent(QWindow* window, const void* ev) |
516 | +void UbuntuInput::dispatchOrientationEvent(QWindow *window, const MirOrientationEvent *event) |
517 | { |
518 | - const WindowEvent* event = reinterpret_cast<const WindowEvent*>(ev); |
519 | - |
520 | + MirOrientation mir_orientation = mir_orientation_event_get_direction(event); |
521 | #if (LOG_EVENTS != 0) |
522 | // Orientation event logging. |
523 | - LOG("ORIENTATION direction: %s", nativeOrientationDirectionToStr(event->orientation.direction)); |
524 | + LOG("ORIENTATION direction: %s", nativeOrientationDirectionToStr(mir_orientation)); |
525 | #endif |
526 | |
527 | if (!window->screen()) { |
528 | @@ -460,21 +463,21 @@ |
529 | } |
530 | |
531 | QOrientationReading::Orientation orientation; |
532 | - switch (event->orientation.direction) { |
533 | - case U_ORIENTATION_NORMAL: |
534 | + switch (mir_orientation) { |
535 | + case mir_orientation_normal: |
536 | orientation = QOrientationReading::TopUp; |
537 | break; |
538 | - case U_ORIENTATION_LEFT: |
539 | + case mir_orientation_left: |
540 | orientation = QOrientationReading::LeftUp; |
541 | break; |
542 | - case U_ORIENTATION_INVERTED: |
543 | + case mir_orientation_inverted: |
544 | orientation = QOrientationReading::TopDown; |
545 | break; |
546 | - case U_ORIENTATION_RIGHT: |
547 | + case mir_orientation_right: |
548 | orientation = QOrientationReading::RightUp; |
549 | break; |
550 | default: |
551 | - DLOG("No such orientation %d", event->orientation.direction); |
552 | + DLOG("No such orientation %d", mir_orientation); |
553 | return; |
554 | } |
555 | |
556 | |
557 | === modified file 'src/ubuntumirclient/input.h' |
558 | --- src/ubuntumirclient/input.h 2014-08-25 15:24:02 +0000 |
559 | +++ src/ubuntumirclient/input.h 2015-03-05 19:55:08 +0000 |
560 | @@ -1,5 +1,5 @@ |
561 | /* |
562 | - * Copyright (C) 2014 Canonical, Ltd. |
563 | + * Copyright (C) 2014-2015 Canonical, Ltd. |
564 | * |
565 | * This program is free software: you can redistribute it and/or modify it under |
566 | * the terms of the GNU Lesser General Public License version 3, as published by |
567 | @@ -20,6 +20,8 @@ |
568 | // Qt |
569 | #include <qpa/qwindowsysteminterface.h> |
570 | |
571 | +#include <mir_toolkit/mir_client_library.h> |
572 | + |
573 | class UbuntuClientIntegration; |
574 | class UbuntuWindow; |
575 | |
576 | @@ -34,13 +36,16 @@ |
577 | // QObject methods. |
578 | void customEvent(QEvent* event) override; |
579 | |
580 | - void postEvent(UbuntuWindow* window, const void* event); |
581 | + void postEvent(UbuntuWindow* window, const MirEvent *event); |
582 | UbuntuClientIntegration* integration() const { return mIntegration; } |
583 | |
584 | protected: |
585 | - void dispatchKeyEvent(QWindow* window, const void* event); |
586 | - void dispatchMotionEvent(QWindow* window, const void* event); |
587 | - void dispatchOrientationEvent(QWindow* window, const void* event); |
588 | + void dispatchKeyEvent(QWindow *window, const MirInputEvent *event); |
589 | + void dispatchPointerEvent(QWindow *window, const MirInputEvent *event); |
590 | + void dispatchTouchEvent(QWindow *window, const MirInputEvent *event); |
591 | + void dispatchInputEvent(QWindow *window, const MirInputEvent *event); |
592 | + |
593 | + void dispatchOrientationEvent(QWindow* window, const MirOrientationEvent *event); |
594 | |
595 | private: |
596 | UbuntuClientIntegration* mIntegration; |
597 | |
598 | === modified file 'src/ubuntumirclient/integration.cpp' |
599 | --- src/ubuntumirclient/integration.cpp 2014-10-01 17:20:40 +0000 |
600 | +++ src/ubuntumirclient/integration.cpp 2015-03-05 19:55:08 +0000 |
601 | @@ -1,5 +1,5 @@ |
602 | /* |
603 | - * Copyright (C) 2014 Canonical, Ltd. |
604 | + * Copyright (C) 2014-2015 Canonical, Ltd. |
605 | * |
606 | * This program is free software: you can redistribute it and/or modify it under |
607 | * the terms of the GNU Lesser General Public License version 3, as published by |
608 | @@ -156,7 +156,7 @@ |
609 | QPlatformWindow* UbuntuClientIntegration::createPlatformWindow(QWindow* window) |
610 | { |
611 | QPlatformWindow* platformWindow = new UbuntuWindow( |
612 | - window, mClipboard, static_cast<UbuntuScreen*>(mScreen), mInput, mInstance); |
613 | + window, mClipboard, static_cast<UbuntuScreen*>(mScreen), mInput, u_application_instance_get_mir_connection(mInstance)); |
614 | platformWindow->requestActivateWindow(); |
615 | return platformWindow; |
616 | } |
617 | |
618 | === modified file 'src/ubuntumirclient/ubuntumirclient.pro' |
619 | --- src/ubuntumirclient/ubuntumirclient.pro 2014-10-01 17:20:40 +0000 |
620 | +++ src/ubuntumirclient/ubuntumirclient.pro 2015-03-05 19:55:08 +0000 |
621 | @@ -12,9 +12,7 @@ |
622 | QMAKE_LFLAGS += -std=c++11 -Wl,-no-undefined |
623 | |
624 | CONFIG += link_pkgconfig |
625 | -PKGCONFIG += egl |
626 | - |
627 | -LIBS += -lubuntu_application_api |
628 | +PKGCONFIG += egl mirclient ubuntu-platform-api |
629 | |
630 | SOURCES = \ |
631 | backingstore.cpp \ |
632 | |
633 | === modified file 'src/ubuntumirclient/window.cpp' |
634 | --- src/ubuntumirclient/window.cpp 2014-10-01 17:20:40 +0000 |
635 | +++ src/ubuntumirclient/window.cpp 2015-03-05 19:55:08 +0000 |
636 | @@ -1,5 +1,5 @@ |
637 | /* |
638 | - * Copyright (C) 2014 Canonical, Ltd. |
639 | + * Copyright (C) 2014-2015 Canonical, Ltd. |
640 | * |
641 | * This program is free software: you can redistribute it and/or modify it under |
642 | * the terms of the GNU Lesser General Public License version 3, as published by |
643 | @@ -37,6 +37,53 @@ |
644 | |
645 | #define IS_OPAQUE_FLAG 1 |
646 | |
647 | +namespace |
648 | +{ |
649 | +MirSurfaceState qtWindowStateToMirSurfaceState(Qt::WindowState state) |
650 | +{ |
651 | + switch (state) { |
652 | + case Qt::WindowNoState: |
653 | + return mir_surface_state_restored; |
654 | + |
655 | + case Qt::WindowFullScreen: |
656 | + return mir_surface_state_fullscreen; |
657 | + |
658 | + case Qt::WindowMaximized: |
659 | + return mir_surface_state_maximized; |
660 | + |
661 | + case Qt::WindowMinimized: |
662 | + return mir_surface_state_minimized; |
663 | + |
664 | + default: |
665 | + LOG("Unexpected Qt::WindowState: %d", state); |
666 | + return mir_surface_state_restored; |
667 | + } |
668 | +} |
669 | + |
670 | +#if !defined(QT_NO_DEBUG) |
671 | +const char *qtWindowStateToStr(Qt::WindowState state) |
672 | +{ |
673 | + switch (state) { |
674 | + case Qt::WindowNoState: |
675 | + return "NoState"; |
676 | + |
677 | + case Qt::WindowFullScreen: |
678 | + return "FullScreen"; |
679 | + |
680 | + case Qt::WindowMaximized: |
681 | + return "Maximized"; |
682 | + |
683 | + case Qt::WindowMinimized: |
684 | + return "Minimized"; |
685 | + |
686 | + default: |
687 | + return "!?"; |
688 | + } |
689 | +} |
690 | +#endif |
691 | + |
692 | +} // anonymous namespace |
693 | + |
694 | class UbuntuWindowPrivate |
695 | { |
696 | public: |
697 | @@ -48,26 +95,36 @@ |
698 | EGLSurface eglSurface; |
699 | WId id; |
700 | UbuntuInput* input; |
701 | - UAUiWindow* window; |
702 | Qt::WindowState state; |
703 | QRect geometry; |
704 | - UApplicationInstance* uaInstance; |
705 | - UAUiWindowProperties* wProps; |
706 | + MirConnection *connection; |
707 | + MirSurface* surface; |
708 | QSize bufferSize; |
709 | QSize targetBufferSize; |
710 | QMutex mutex; |
711 | QSharedPointer<UbuntuClipboard> clipboard; |
712 | }; |
713 | |
714 | -static void eventCallback(void* context, const WindowEvent* event) |
715 | +static void eventCallback(MirSurface* surface, const MirEvent *event, void* context) |
716 | { |
717 | + (void) surface; |
718 | DASSERT(context != NULL); |
719 | UbuntuWindow* platformWindow = static_cast<UbuntuWindow*>(context); |
720 | platformWindow->priv()->input->postEvent(platformWindow, event); |
721 | } |
722 | |
723 | +static void surfaceCreateCallback(MirSurface* surface, void* context) |
724 | +{ |
725 | + DASSERT(context != NULL); |
726 | + UbuntuWindow* platformWindow = static_cast<UbuntuWindow*>(context); |
727 | + platformWindow->priv()->surface = surface; |
728 | + |
729 | + MirEventDelegate handler = {eventCallback, context}; |
730 | + mir_surface_set_event_handler(surface, &handler); |
731 | +} |
732 | + |
733 | UbuntuWindow::UbuntuWindow(QWindow* w, QSharedPointer<UbuntuClipboard> clipboard, UbuntuScreen* screen, |
734 | - UbuntuInput* input, UApplicationInstance* instance) |
735 | + UbuntuInput* input, MirConnection* connection) |
736 | : QObject(nullptr), QPlatformWindow(w) |
737 | { |
738 | DASSERT(screen != NULL); |
739 | @@ -77,7 +134,7 @@ |
740 | d->eglSurface = EGL_NO_SURFACE; |
741 | d->input = input; |
742 | d->state = window()->windowState(); |
743 | - d->uaInstance = instance; |
744 | + d->connection = connection; |
745 | d->clipboard = clipboard; |
746 | |
747 | static int id = 1; |
748 | @@ -94,7 +151,9 @@ |
749 | { |
750 | DLOG("UbuntuWindow::~UbuntuWindow"); |
751 | d->destroyEGLSurface(); |
752 | - ua_ui_window_destroy(d->window); |
753 | + |
754 | + mir_surface_release_sync(d->surface); |
755 | + |
756 | delete d; |
757 | } |
758 | |
759 | @@ -136,6 +195,21 @@ |
760 | return gridUnit * 3 + qFloor(densityPixelRatio) * 2; |
761 | } |
762 | |
763 | +namespace |
764 | +{ |
765 | +static MirPixelFormat |
766 | +mir_choose_default_pixel_format(MirConnection *connection) |
767 | +{ |
768 | + MirPixelFormat format[mir_pixel_formats]; |
769 | + unsigned int nformats; |
770 | + |
771 | + mir_connection_get_available_surface_formats(connection, |
772 | + format, mir_pixel_formats, &nformats); |
773 | + |
774 | + return format[0]; |
775 | +} |
776 | +} |
777 | + |
778 | void UbuntuWindow::createWindow() |
779 | { |
780 | DLOG("UbuntuWindow::createWindow (this=%p)", this); |
781 | @@ -154,12 +228,12 @@ |
782 | const QByteArray title = (!window()->title().isNull()) ? window()->title().toUtf8() : "Window 1"; // legacy title |
783 | const int panelHeight = d->panelHeight(); |
784 | |
785 | - #if !defined(QT_NO_DEBUG) |
786 | +#if !defined(QT_NO_DEBUG) |
787 | LOG("panelHeight: '%d'", panelHeight); |
788 | LOG("role: '%d'", role); |
789 | LOG("flags: '%s'", (flags & static_cast<uint>(1)) ? "Opaque" : "NotOpaque"); |
790 | LOG("title: '%s'", title.constData()); |
791 | - #endif |
792 | +#endif |
793 | |
794 | // Get surface geometry. |
795 | QRect geometry; |
796 | @@ -187,32 +261,39 @@ |
797 | DLOG("[ubuntumirclient QPA] creating surface at (%d, %d) with size (%d, %d) with title '%s'\n", |
798 | geometry.x(), geometry.y(), geometry.width(), geometry.height(), title.data()); |
799 | |
800 | - // Setup platform window creation properties |
801 | - d->wProps = ua_ui_window_properties_new_for_normal_window(); |
802 | - ua_ui_window_properties_set_titlen(d->wProps, title.data(), title.size()); |
803 | - ua_ui_window_properties_set_role(d->wProps, static_cast<UAUiWindowRole>(role)); |
804 | - ua_ui_window_properties_set_event_cb_and_ctx(d->wProps, &eventCallback, this); |
805 | - ua_ui_window_properties_set_dimensions(d->wProps, geometry.width(), geometry.height()); |
806 | + MirSurfaceSpec *spec; |
807 | + if (role == U_ON_SCREEN_KEYBOARD_ROLE) |
808 | + { |
809 | + spec = mir_connection_create_spec_for_input_method(d->connection, geometry.width(), |
810 | + geometry.height(), mir_choose_default_pixel_format(d->connection)); |
811 | + } |
812 | + else |
813 | + { |
814 | + spec = mir_connection_create_spec_for_normal_surface(d->connection, geometry.width(), |
815 | + geometry.height(), mir_choose_default_pixel_format(d->connection)); |
816 | + } |
817 | + mir_surface_spec_set_name(spec, title.data()); |
818 | |
819 | // Create platform window |
820 | - d->window = ua_ui_window_new_for_application_with_properties(d->uaInstance, d->wProps); |
821 | - |
822 | - if (geometry.x() != 0 || geometry.y() != 0) |
823 | - ua_ui_window_move(d->window, geometry.x(), geometry.y()); |
824 | - |
825 | - DASSERT(d->window != NULL); |
826 | - d->createEGLSurface(ua_ui_window_get_native_type(d->window)); |
827 | + mir_wait_for(mir_surface_create(spec, surfaceCreateCallback, this)); |
828 | + mir_surface_spec_release(spec); |
829 | + |
830 | + DASSERT(d->surface != NULL); |
831 | + d->createEGLSurface((EGLNativeWindowType)mir_surface_get_egl_native_window(d->surface)); |
832 | + |
833 | if (d->state == Qt::WindowFullScreen) { |
834 | - ua_ui_window_request_fullscreen(d->window); |
835 | + // TODO: We could set this on creation once surface spec supports it (mps already up) |
836 | + mir_wait_for(mir_surface_set_state(d->surface, mir_surface_state_fullscreen)); |
837 | } |
838 | |
839 | // Window manager can give us a final size different from what we asked for |
840 | // so let's check what we ended up getting |
841 | { |
842 | - uint32_t width, height; |
843 | - ua_ui_window_get_size(d->window, &width, &height); |
844 | - geometry.setWidth(width); |
845 | - geometry.setHeight(height); |
846 | + MirSurfaceParameters parameters; |
847 | + mir_surface_get_parameters(d->surface, ¶meters); |
848 | + |
849 | + geometry.setWidth(parameters.width); |
850 | + geometry.setHeight(parameters.height); |
851 | } |
852 | |
853 | DLOG("[ubuntumirclient QPA] created surface has size (%d, %d)", |
854 | @@ -228,13 +309,8 @@ |
855 | |
856 | void UbuntuWindow::moveResize(const QRect& rect) |
857 | { |
858 | - fprintf(stderr, "\nQUbuntuWindow::moveResize (this=%p, x=%d, y=%d, w=%d, h=%d)\n", this, |
859 | - rect.x(), rect.y(), rect.width(), rect.height()); |
860 | - LOG("UbuntuWindow::moveResize(width=%d, height=%d)", rect.width(), rect.height()); |
861 | - ua_ui_window_move(d->window, rect.x(), rect.y()); |
862 | - ua_ui_window_resize(d->window, rect.width(), rect.height()); |
863 | - QWindowSystemInterface::handleGeometryChange(window(), rect); |
864 | - QPlatformWindow::setGeometry(rect); |
865 | + (void) rect; |
866 | + // TODO: Not yet supported by mir. |
867 | } |
868 | |
869 | void UbuntuWindow::handleSurfaceResize(int width, int height) |
870 | @@ -313,34 +389,14 @@ |
871 | void UbuntuWindow::setWindowState(Qt::WindowState state) |
872 | { |
873 | QMutexLocker(&d->mutex); |
874 | + DLOG("UbuntuWindow::setWindowState (this=%p, %s)", this, qtWindowStateToStr(state)); |
875 | + |
876 | if (state == d->state) |
877 | return; |
878 | |
879 | - switch (state) { |
880 | - case Qt::WindowNoState: |
881 | - DLOG("setting window state: 'NoState'"); |
882 | - ua_ui_window_request_state(d->window, U_RESTORED_STATE); |
883 | - d->state = Qt::WindowNoState; |
884 | - break; |
885 | - case Qt::WindowFullScreen: |
886 | - DLOG("setting window state: 'FullScreen'"); |
887 | - ua_ui_window_request_state(d->window, U_FULLSCREEN_STATE); |
888 | - d->state = Qt::WindowFullScreen; |
889 | - break; |
890 | - case Qt::WindowMaximized: |
891 | - DLOG("setting window state: 'Maximized'"); |
892 | - ua_ui_window_request_state(d->window, U_MAXIMIZED_STATE); |
893 | - d->state = Qt::WindowMaximized; |
894 | - break; |
895 | - case Qt::WindowMinimized: |
896 | - DLOG("setting window state: 'Minimized'"); |
897 | - ua_ui_window_request_state(d->window, U_MINIMIZED_STATE); |
898 | - d->state = Qt::WindowMinimized; |
899 | - break; |
900 | - default: |
901 | - DLOG("Unexpected window state"); |
902 | - break; |
903 | - } |
904 | + // TODO: Perhaps we should check if the states are applied? |
905 | + mir_wait_for(mir_surface_set_state(d->surface, qtWindowStateToMirSurfaceState(state))); |
906 | + d->state = state; |
907 | } |
908 | |
909 | void UbuntuWindow::setGeometry(const QRect& rect) |
910 | @@ -362,15 +418,19 @@ |
911 | |
912 | void UbuntuWindow::setVisible(bool visible) |
913 | { |
914 | - DLOG("UbuntuWindow::setVisible (this=%p, visible=%s)", this, visible ? "true" : "false"); |
915 | - |
916 | - if (visible) { |
917 | - ua_ui_window_show(d->window); |
918 | - QWindowSystemInterface::handleExposeEvent(window(), QRect()); |
919 | - QWindowSystemInterface::flushWindowSystemEvents(); |
920 | - } else { |
921 | - ua_ui_window_hide(d->window); |
922 | - } |
923 | + QMutexLocker(&d->mutex); |
924 | + DLOG("UbuntuWindow::setVisible (this=%p, visible=%s)", this, visible ? "true" : "false"); |
925 | + |
926 | + if (visible) { |
927 | + mir_wait_for(mir_surface_set_state(d->surface, qtWindowStateToMirSurfaceState(d->state))); |
928 | + |
929 | + QWindowSystemInterface::handleExposeEvent(window(), QRect()); |
930 | + QWindowSystemInterface::flushWindowSystemEvents(); |
931 | + } else { |
932 | + // TODO: Use the new mir_surface_state_hidden state instead of mir_surface_state_minimized. |
933 | + // Will have to change qtmir and unity8 for that. |
934 | + mir_wait_for(mir_surface_set_state(d->surface, mir_surface_state_minimized)); |
935 | + } |
936 | } |
937 | |
938 | void* UbuntuWindow::eglSurface() const |
939 | |
940 | === modified file 'src/ubuntumirclient/window.h' |
941 | --- src/ubuntumirclient/window.h 2014-09-22 17:29:40 +0000 |
942 | +++ src/ubuntumirclient/window.h 2015-03-05 19:55:08 +0000 |
943 | @@ -1,5 +1,5 @@ |
944 | /* |
945 | - * Copyright (C) 2014 Canonical, Ltd. |
946 | + * Copyright (C) 2014-2015 Canonical, Ltd. |
947 | * |
948 | * This program is free software: you can redistribute it and/or modify it under |
949 | * the terms of the GNU Lesser General Public License version 3, as published by |
950 | @@ -20,6 +20,8 @@ |
951 | #include <qpa/qplatformwindow.h> |
952 | #include <QSharedPointer> |
953 | |
954 | +#include <mir_toolkit/mir_client_library.h> |
955 | + |
956 | class UbuntuClipboard; |
957 | class UbuntuInput; |
958 | class UbuntuScreen; |
959 | @@ -29,8 +31,8 @@ |
960 | { |
961 | Q_OBJECT |
962 | public: |
963 | - UbuntuWindow(QWindow* w, QSharedPointer<UbuntuClipboard> clipboard, UbuntuScreen* screen, |
964 | - UbuntuInput* input, void* instance); |
965 | + UbuntuWindow(QWindow *w, QSharedPointer<UbuntuClipboard> clipboard, UbuntuScreen *screen, |
966 | + UbuntuInput *input, MirConnection *mir_connection); |
967 | virtual ~UbuntuWindow(); |
968 | |
969 | // QPlatformWindow methods. |
Im carrying it around on my phone and it seems to work fine but will get more testing.