Merge lp:~dandrader/qtubuntu/loggingCategory into lp:qtubuntu
- loggingCategory
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Gerry Boland |
Approved revision: | 300 |
Merged at revision: | 308 |
Proposed branch: | lp:~dandrader/qtubuntu/loggingCategory |
Merge into: | lp:qtubuntu |
Diff against target: |
1014 lines (+192/-221) 12 files modified
README (+19/-6) src/ubuntumirclient/clipboard.cpp (+6/-5) src/ubuntumirclient/cursor.cpp (+1/-3) src/ubuntumirclient/glcontext.cpp (+11/-30) src/ubuntumirclient/input.cpp (+12/-24) src/ubuntumirclient/input.h (+1/-0) src/ubuntumirclient/integration.cpp (+4/-4) src/ubuntumirclient/logging.h (+6/-17) src/ubuntumirclient/plugin.cpp (+3/-0) src/ubuntumirclient/screen.cpp (+61/-63) src/ubuntumirclient/window.cpp (+67/-69) src/ubuntumirclient/window.h (+1/-0) |
To merge this branch: | bzr merge lp:~dandrader/qtubuntu/loggingCategory |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gerry Boland (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+279629@code.launchpad.net |
Commit message
Use logging categories and fix coding style (tab length)
So logging can be enabled/disabled at runtime instead of at build time
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
Gerry Boland (gerboland) wrote : | # |
Q_LOGGING_
did you choose the long "ubuntumirclien
+++ src/ubuntumircl
+++ src/ubuntumircl
would prefer you move the logging category declaration into the logging.h file. I think it is handy to see all categories listed in one file.
+++ src/ubuntumircl
you're hiding all these critical clipboard error messages by default. I think those messages are more useful if they're always printed. I'm ok hiding the warnings by default.
+++ src/ubuntumircl
+static void printEglConfig(
whitespace: 2 spaces after 'void'
Please edit README to give instructions on how to enable the logging output.
Gerry Boland (gerboland) wrote : | # |
>+++ src/ubuntumircl
>you're hiding all these critical clipboard error messages by default. I >think those messages are more useful if they're always printed. I'm ok >hiding the warnings by default.
I was wrong, they'll still print, plz ignore
- 298. By Daniel d'Andrada
-
Remove extra space
- 299. By Daniel d'Andrada
-
Move all logging category declarations to logging.h
- 300. By Daniel d'Andrada
-
Update README
Daniel d'Andrada (dandrader) wrote : | # |
On 09/12/2015 09:39, Gerry Boland wrote:
> Review: Needs Fixing
>
> Q_LOGGING_
> did you choose the long "ubuntumirclien
Yes and because that's the name of the library after all.
>
> +++ src/ubuntumircl
> +++ src/ubuntumircl
> would prefer you move the logging category declaration into the logging.h file. I think it is handy to see all categories listed in one file.
Done.
>
> +++ src/ubuntumircl
> you're hiding all these critical clipboard error messages by default. I think those messages are more useful if they're always printed. I'm ok hiding the warnings by default.
No, by default I'm only hiding debug messages.
>
> +++ src/ubuntumircl
> +static void printEglConfig(
> whitespace: 2 spaces after 'void'
>
> Please edit README to give instructions on how to enable the logging output.
Done.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:300
http://
Executed test runs:
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) wrote : | # |
LGTM, let's land it!
Gerry Boland (gerboland) wrote : | # |
Conflict with trunk :(
Daniel d'Andrada (dandrader) wrote : | # |
On 16/12/2015 14:18, Gerry Boland wrote:
> Review: Needs Fixing
>
> Conflict with trunk :(
Fixed.
- 301. By Daniel d'Andrada
-
Merge trunk
[ Daniel d'Andrada ]
* Implement support for application state (LP: #1504776)
* Update panel height hack when window enters or leaves fullscreen
(LP: #1422523)
[ Lukáš Tinkl ]
* Update the panel height hack, orange line is gone
[ Michał Sawicz ]
* Run wrap-and-sort -at
Gerry Boland (gerboland) : | # |
Gerry Boland (gerboland) : | # |
Preview Diff
1 | === modified file 'README' |
2 | --- README 2014-06-18 23:10:00 +0000 |
3 | +++ README 2016-01-05 20:27:18 +0000 |
4 | @@ -1,15 +1,15 @@ |
5 | 1. Description |
6 | 2. Running |
7 | - 3. Building |
8 | - 4. QPA native interface |
9 | - 5. QPA properties |
10 | + 3. Debug messages and logging |
11 | + 4. Building |
12 | + 5. QPA native interface |
13 | |
14 | |
15 | 1. Description |
16 | -------------- |
17 | |
18 | QtUbuntu contains a QPA (Qt Platform Abstraction) plugin based on the Ubuntu |
19 | - Platform API |
20 | + Platform API and Mir client API |
21 | |
22 | |
23 | 2 Running |
24 | @@ -39,7 +39,20 @@ |
25 | QTUBUNTU_ICON_THEME: Specifies the default icon theme name. |
26 | |
27 | |
28 | -3. Building |
29 | +3 Debug messages and logging |
30 | +---------------------------- |
31 | + |
32 | + QtUbuntu uses Qt logging categories (see QLoggingCategory class documentation |
33 | + for more information). By default warnings and critical messages are |
34 | + logged and debug messages are disabled. QtUbuntu provides the following |
35 | + logging categories: |
36 | + |
37 | + * ubuntumirclient.input - Messages related to input and other Mir events. |
38 | + * ubuntumirclient.swapBuffers - Messages related to surface buffer swapping. |
39 | + * ubuntumirclient - For all other messages. |
40 | + |
41 | + |
42 | +4. Building |
43 | ----------- |
44 | |
45 | To compile QtUbuntu, create the makefiles with qmake and build with |
46 | @@ -54,7 +67,7 @@ |
47 | $ qmake CONFIG+=debug |
48 | |
49 | |
50 | -4. QPA native interface |
51 | +5. QPA native interface |
52 | ----------------------- |
53 | |
54 | The QPA plugin exposes a native interface allowing to retrieve |
55 | |
56 | === modified file 'src/ubuntumirclient/clipboard.cpp' |
57 | --- src/ubuntumirclient/clipboard.cpp 2015-11-17 14:49:30 +0000 |
58 | +++ src/ubuntumirclient/clipboard.cpp 2016-01-05 20:27:18 +0000 |
59 | @@ -15,6 +15,7 @@ |
60 | */ |
61 | |
62 | #include "clipboard.h" |
63 | +#include "logging.h" |
64 | |
65 | #include <QtCore/QMimeData> |
66 | #include <QtCore/QStringList> |
67 | @@ -80,7 +81,7 @@ |
68 | |
69 | QDBusPendingReply<QByteArray> reply = *call; |
70 | if (reply.isError()) { |
71 | - qCritical("UbuntuClipboard - Failed to get system clipboard contents via D-Bus. %s, %s", |
72 | + qCCritical(ubuntumirclient, "Failed to get system clipboard contents via D-Bus. %s, %s", |
73 | qPrintable(reply.error().name()), qPrintable(reply.error().message())); |
74 | // TODO: Might try again later a number of times... |
75 | } else { |
76 | @@ -94,7 +95,7 @@ |
77 | { |
78 | QDBusPendingReply<void> reply = *call; |
79 | if (reply.isError()) { |
80 | - qCritical("UbuntuClipboard - Failed to set the system clipboard contents via D-Bus. %s, %s", |
81 | + qCCritical(ubuntumirclient, "Failed to set the system clipboard contents via D-Bus. %s, %s", |
82 | qPrintable(reply.error().name()), qPrintable(reply.error().message())); |
83 | // TODO: Might try again later a number of times... |
84 | } |
85 | @@ -113,7 +114,7 @@ |
86 | mIsOutdated = false; |
87 | emitChanged(QClipboard::Clipboard); |
88 | } else { |
89 | - qWarning("UbuntuClipboard - Got invalid serialized mime data. Ignoring it."); |
90 | + qCWarning(ubuntumirclient) << "Got invalid serialized mime data. Ignoring it."; |
91 | } |
92 | } |
93 | |
94 | @@ -128,7 +129,7 @@ |
95 | QStringLiteral("ContentsChanged"), |
96 | this, SLOT(updateMimeData(QByteArray))); |
97 | if (!ok) { |
98 | - qCritical("UbuntuClipboard - Failed to connect to ContentsChanged signal form the D-Bus system clipboard."); |
99 | + qCCritical(ubuntumirclient) << "Failed to connect to ContentsChanged signal form the D-Bus system clipboard."; |
100 | } |
101 | |
102 | mDBusClipboard = new QDBusInterface(QStringLiteral("com.canonical.QtMir"), |
103 | @@ -176,7 +177,7 @@ |
104 | } |
105 | } |
106 | } else { |
107 | - qWarning("UbuntuClipboard: Not sending contents (%d bytes) to the global clipboard as it's" |
108 | + qCWarning(ubuntumirclient, "Not sending contents (%d bytes) to the global clipboard as it's" |
109 | " bigger than the maximum allowed size of %d bytes", bufferSize, maxBufferSize); |
110 | } |
111 | |
112 | |
113 | === modified file 'src/ubuntumirclient/cursor.cpp' |
114 | --- src/ubuntumirclient/cursor.cpp 2015-11-24 13:12:48 +0000 |
115 | +++ src/ubuntumirclient/cursor.cpp 2016-01-05 20:27:18 +0000 |
116 | @@ -49,7 +49,6 @@ |
117 | } |
118 | |
119 | namespace { |
120 | -#if !defined(QT_NO_DEBUG) |
121 | const char *qtCursorShapeToStr(Qt::CursorShape shape) |
122 | { |
123 | switch(shape) { |
124 | @@ -103,7 +102,6 @@ |
125 | return "???"; |
126 | } |
127 | } |
128 | -#endif // !defined(QT_NO_DEBUG) |
129 | } // anonymous namespace |
130 | |
131 | void UbuntuCursor::changeCursor(QCursor *windowCursor, QWindow *window) |
132 | @@ -120,7 +118,7 @@ |
133 | |
134 | |
135 | if (windowCursor) { |
136 | - DLOG("[ubuntumirclient QPA] changeCursor shape=%s, window=%p\n", qtCursorShapeToStr(windowCursor->shape()), window); |
137 | + qCDebug(ubuntumirclient, "changeCursor shape=%s, window=%p", qtCursorShapeToStr(windowCursor->shape()), window); |
138 | if (!windowCursor->pixmap().isNull()) { |
139 | configureMirCursorWithPixmapQCursor(surface, *windowCursor); |
140 | } else if (windowCursor->shape() == Qt::BitmapCursor) { |
141 | |
142 | === modified file 'src/ubuntumirclient/glcontext.cpp' |
143 | --- src/ubuntumirclient/glcontext.cpp 2015-10-23 19:29:38 +0000 |
144 | +++ src/ubuntumirclient/glcontext.cpp 2016-01-05 20:27:18 +0000 |
145 | @@ -1,5 +1,5 @@ |
146 | /* |
147 | - * Copyright (C) 2014 Canonical, Ltd. |
148 | + * Copyright (C) 2014-2015 Canonical, Ltd. |
149 | * |
150 | * This program is free software: you can redistribute it and/or modify it under |
151 | * the terms of the GNU Lesser General Public License version 3, as published by |
152 | @@ -19,24 +19,22 @@ |
153 | #include "logging.h" |
154 | #include <QtPlatformSupport/private/qeglconvenience_p.h> |
155 | |
156 | -#if !defined(QT_NO_DEBUG) |
157 | static void printOpenGLESConfig() { |
158 | static bool once = true; |
159 | if (once) { |
160 | const char* string = (const char*) glGetString(GL_VENDOR); |
161 | - LOG("OpenGL ES vendor: %s", string); |
162 | + qCDebug(ubuntumirclient, "OpenGL ES vendor: %s", string); |
163 | string = (const char*) glGetString(GL_RENDERER); |
164 | - LOG("OpenGL ES renderer: %s", string); |
165 | + qCDebug(ubuntumirclient, "OpenGL ES renderer: %s", string); |
166 | string = (const char*) glGetString(GL_VERSION); |
167 | - LOG("OpenGL ES version: %s", string); |
168 | + qCDebug(ubuntumirclient, "OpenGL ES version: %s", string); |
169 | string = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION); |
170 | - LOG("OpenGL ES Shading Language version: %s", string); |
171 | + qCDebug(ubuntumirclient, "OpenGL ES Shading Language version: %s", string); |
172 | string = (const char*) glGetString(GL_EXTENSIONS); |
173 | - LOG("OpenGL ES extensions: %s", string); |
174 | + qCDebug(ubuntumirclient, "OpenGL ES extensions: %s", string); |
175 | once = false; |
176 | } |
177 | } |
178 | -#endif |
179 | |
180 | static EGLenum api_in_use() |
181 | { |
182 | @@ -62,7 +60,7 @@ |
183 | |
184 | mEglContext = eglCreateContext(mEglDisplay, screen->eglConfig(), share ? share->eglContext() : EGL_NO_CONTEXT, |
185 | attribs.constData()); |
186 | - DASSERT(mEglContext != EGL_NO_CONTEXT); |
187 | + Q_ASSERT(mEglContext != EGL_NO_CONTEXT); |
188 | } |
189 | |
190 | UbuntuOpenGLContext::~UbuntuOpenGLContext() |
191 | @@ -72,28 +70,20 @@ |
192 | |
193 | bool UbuntuOpenGLContext::makeCurrent(QPlatformSurface* surface) |
194 | { |
195 | - DASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface); |
196 | + Q_ASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface); |
197 | EGLSurface eglSurface = static_cast<UbuntuWindow*>(surface)->eglSurface(); |
198 | -#if defined(QT_NO_DEBUG) |
199 | - eglBindAPI(api_in_use()); |
200 | - eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext); |
201 | -#else |
202 | ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); |
203 | ASSERT(eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext) == EGL_TRUE); |
204 | - printOpenGLESConfig(); |
205 | -#endif |
206 | + if (ubuntumirclient().isDebugEnabled()) { |
207 | + printOpenGLESConfig(); |
208 | + } |
209 | return true; |
210 | } |
211 | |
212 | void UbuntuOpenGLContext::doneCurrent() |
213 | { |
214 | -#if defined(QT_NO_DEBUG) |
215 | - eglBindAPI(api_in_use()); |
216 | - eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
217 | -#else |
218 | ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); |
219 | ASSERT(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) == EGL_TRUE); |
220 | -#endif |
221 | } |
222 | |
223 | void UbuntuOpenGLContext::swapBuffers(QPlatformSurface* surface) |
224 | @@ -101,23 +91,14 @@ |
225 | UbuntuWindow *ubuntuWindow = static_cast<UbuntuWindow*>(surface); |
226 | |
227 | EGLSurface eglSurface = ubuntuWindow->eglSurface(); |
228 | -#if defined(QT_NO_DEBUG) |
229 | - eglBindAPI(api_in_use()); |
230 | - eglSwapBuffers(mEglDisplay, eglSurface); |
231 | -#else |
232 | ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); |
233 | ASSERT(eglSwapBuffers(mEglDisplay, eglSurface) == EGL_TRUE); |
234 | -#endif |
235 | |
236 | ubuntuWindow->onSwapBuffersDone(); |
237 | } |
238 | |
239 | void (*UbuntuOpenGLContext::getProcAddress(const QByteArray& procName)) () |
240 | { |
241 | -#if defined(QT_NO_DEBUG) |
242 | - eglBindAPI(api_in_use()); |
243 | -#else |
244 | ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); |
245 | -#endif |
246 | return eglGetProcAddress(procName.constData()); |
247 | } |
248 | |
249 | === modified file 'src/ubuntumirclient/input.cpp' |
250 | --- src/ubuntumirclient/input.cpp 2015-12-23 13:55:42 +0000 |
251 | +++ src/ubuntumirclient/input.cpp 2016-01-05 20:27:18 +0000 |
252 | @@ -24,9 +24,7 @@ |
253 | #include "orientationchangeevent_p.h" |
254 | |
255 | // Qt |
256 | -#if !defined(QT_NO_DEBUG) |
257 | #include <QtCore/QThread> |
258 | -#endif |
259 | #include <QtCore/qglobal.h> |
260 | #include <QtCore/QCoreApplication> |
261 | #include <private/qguiapplication_p.h> |
262 | @@ -38,7 +36,7 @@ |
263 | |
264 | #include <mir_toolkit/mir_client_library.h> |
265 | |
266 | -#define LOG_EVENTS 0 |
267 | +Q_LOGGING_CATEGORY(ubuntumirclientInput, "ubuntumirclient.input", QtWarningMsg) |
268 | |
269 | // XKB Keysyms which do not map directly to Qt types (i.e. Unicode points) |
270 | static const uint32_t KeyTable[] = { |
271 | @@ -158,7 +156,6 @@ |
272 | // Qt will take care of deleting mTouchDevice. |
273 | } |
274 | |
275 | -#if (LOG_EVENTS != 0) |
276 | static const char* nativeEventTypeToStr(MirEventType t) |
277 | { |
278 | switch (t) |
279 | @@ -180,20 +177,18 @@ |
280 | case mir_event_type_input: |
281 | return "mir_event_type_input"; |
282 | default: |
283 | - DLOG("Invalid event type %d", t); |
284 | return "invalid"; |
285 | } |
286 | } |
287 | -#endif // LOG_EVENTS != 0 |
288 | |
289 | void UbuntuInput::customEvent(QEvent* event) |
290 | { |
291 | - DASSERT(QThread::currentThread() == thread()); |
292 | + Q_ASSERT(QThread::currentThread() == thread()); |
293 | UbuntuEvent* ubuntuEvent = static_cast<UbuntuEvent*>(event); |
294 | const MirEvent *nativeEvent = ubuntuEvent->nativeEvent; |
295 | |
296 | if ((ubuntuEvent->window == nullptr) || (ubuntuEvent->window->window() == nullptr)) { |
297 | - qWarning() << "Attempted to deliver an event to a non-existent window, ignoring."; |
298 | + qCWarning(ubuntumirclient) << "Attempted to deliver an event to a non-existent window, ignoring."; |
299 | return; |
300 | } |
301 | |
302 | @@ -202,13 +197,11 @@ |
303 | if (QWindowSystemInterface::handleNativeEvent( |
304 | ubuntuEvent->window->window(), mEventFilterType, |
305 | const_cast<void *>(static_cast<const void *>(nativeEvent)), &result) == true) { |
306 | - DLOG("event filtered out by native interface"); |
307 | + qCDebug(ubuntumirclient, "event filtered out by native interface"); |
308 | return; |
309 | } |
310 | |
311 | - #if (LOG_EVENTS != 0) |
312 | - LOG("UbuntuInput::customEvent(type=%s)", nativeEventTypeToStr(mir_event_get_type(nativeEvent))); |
313 | - #endif |
314 | + qCDebug(ubuntumirclientInput, "customEvent(type=%s)", nativeEventTypeToStr(mir_event_get_type(nativeEvent))); |
315 | |
316 | // Event dispatching. |
317 | switch (mir_event_get_type(nativeEvent)) |
318 | @@ -248,7 +241,7 @@ |
319 | QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive); |
320 | |
321 | } else if(!mPendingFocusGainedEvents) { |
322 | - DLOG("[ubuntumirclient QPA] No windows have focus"); |
323 | + qCDebug(ubuntumirclient, "No windows have focus"); |
324 | QWindowSystemInterface::handleWindowActivated(nullptr, Qt::ActiveWindowFocusReason); |
325 | QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive); |
326 | } |
327 | @@ -262,7 +255,7 @@ |
328 | QWindowSystemInterface::handleCloseEvent(ubuntuEvent->window->window()); |
329 | break; |
330 | default: |
331 | - DLOG("unhandled event type: %d", static_cast<int>(mir_event_get_type(nativeEvent))); |
332 | + qCDebug(ubuntumirclient, "unhandled event type: %d", static_cast<int>(mir_event_get_type(nativeEvent))); |
333 | } |
334 | } |
335 | |
336 | @@ -426,7 +419,7 @@ |
337 | QKeyEvent qKeyEvent(keyType, sym, modifiers, text, is_auto_rep); |
338 | qKeyEvent.setTimestamp(timestamp); |
339 | if (context->filterEvent(&qKeyEvent)) { |
340 | - DLOG("key event filtered out by input context"); |
341 | + qCDebug(ubuntumirclient, "key event filtered out by input context"); |
342 | return; |
343 | } |
344 | } |
345 | @@ -490,11 +483,10 @@ |
346 | QWindowSystemInterface::handleLeaveEvent(window); |
347 | break; |
348 | default: |
349 | - DLOG("Unrecognized pointer event"); |
350 | + qCDebug(ubuntumirclient, "Unrecognized pointer event"); |
351 | } |
352 | } |
353 | |
354 | -#if (LOG_EVENTS != 0) |
355 | static const char* nativeOrientationDirectionToStr(MirOrientation orientation) |
356 | { |
357 | switch (orientation) { |
358 | @@ -514,18 +506,14 @@ |
359 | return "INVALID!"; |
360 | } |
361 | } |
362 | -#endif |
363 | |
364 | void UbuntuInput::dispatchOrientationEvent(QWindow *window, const MirOrientationEvent *event) |
365 | { |
366 | MirOrientation mir_orientation = mir_orientation_event_get_direction(event); |
367 | - #if (LOG_EVENTS != 0) |
368 | - // Orientation event logging. |
369 | - LOG("ORIENTATION direction: %s", nativeOrientationDirectionToStr(mir_orientation)); |
370 | - #endif |
371 | + qCDebug(ubuntumirclientInput, "orientation direction: %s", nativeOrientationDirectionToStr(mir_orientation)); |
372 | |
373 | if (!window->screen()) { |
374 | - DLOG("Window has no associated screen, dropping orientation event"); |
375 | + qCDebug(ubuntumirclient, "Window has no associated screen, dropping orientation event"); |
376 | return; |
377 | } |
378 | |
379 | @@ -544,7 +532,7 @@ |
380 | orientation = OrientationChangeEvent::RightUp; |
381 | break; |
382 | default: |
383 | - DLOG("No such orientation %d", mir_orientation); |
384 | + qCDebug(ubuntumirclient, "No such orientation %d", mir_orientation); |
385 | return; |
386 | } |
387 | |
388 | |
389 | === modified file 'src/ubuntumirclient/input.h' |
390 | --- src/ubuntumirclient/input.h 2015-10-24 04:56:44 +0000 |
391 | +++ src/ubuntumirclient/input.h 2016-01-05 20:27:18 +0000 |
392 | @@ -20,6 +20,7 @@ |
393 | // Qt |
394 | #include <qpa/qwindowsysteminterface.h> |
395 | #include <QAtomicInt> |
396 | +#include <QLoggingCategory> |
397 | |
398 | #include <mir_toolkit/mir_client_library.h> |
399 | |
400 | |
401 | === modified file 'src/ubuntumirclient/integration.cpp' |
402 | --- src/ubuntumirclient/integration.cpp 2015-11-20 15:43:25 +0000 |
403 | +++ src/ubuntumirclient/integration.cpp 2016-01-05 20:27:18 +0000 |
404 | @@ -45,7 +45,7 @@ |
405 | { |
406 | Q_UNUSED(options) |
407 | Q_UNUSED(context) |
408 | - DASSERT(context != NULL); |
409 | + Q_ASSERT(context != NULL); |
410 | if (qGuiApp->focusWindow()) { |
411 | QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive); |
412 | } else { |
413 | @@ -56,13 +56,13 @@ |
414 | static void aboutToStopCallback(UApplicationArchive *archive, void* context) |
415 | { |
416 | Q_UNUSED(archive) |
417 | - DASSERT(context != NULL); |
418 | + Q_ASSERT(context != NULL); |
419 | UbuntuClientIntegration* integration = static_cast<UbuntuClientIntegration*>(context); |
420 | QPlatformInputContext *inputContext = integration->inputContext(); |
421 | if (inputContext) { |
422 | inputContext->hideInputPanel(); |
423 | } else { |
424 | - qWarning("UbuntuClientIntegration aboutToStopCallback(): no input context"); |
425 | + qCWarning(ubuntumirclient) << "aboutToStopCallback(): no input context"; |
426 | } |
427 | QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationSuspended); |
428 | } |
429 | @@ -184,7 +184,7 @@ |
430 | if (qEnvironmentVariableIsEmpty("QTUBUNTU_NO_THREADED_OPENGL")) { |
431 | return true; |
432 | } else { |
433 | - DLOG("ubuntumirclient: disabled threaded OpenGL"); |
434 | + qCDebug(ubuntumirclient, "disabled threaded OpenGL"); |
435 | return false; |
436 | } |
437 | case MultipleWindows: |
438 | |
439 | === modified file 'src/ubuntumirclient/logging.h' |
440 | --- src/ubuntumirclient/logging.h 2014-06-18 23:10:00 +0000 |
441 | +++ src/ubuntumirclient/logging.h 2016-01-05 20:27:18 +0000 |
442 | @@ -1,5 +1,5 @@ |
443 | /* |
444 | - * Copyright (C) 2014 Canonical, Ltd. |
445 | + * Copyright (C) 2014-2015 Canonical, Ltd. |
446 | * |
447 | * This program is free software: you can redistribute it and/or modify it under |
448 | * the terms of the GNU Lesser General Public License version 3, as published by |
449 | @@ -17,23 +17,12 @@ |
450 | #ifndef QUBUNTULOGGING_H |
451 | #define QUBUNTULOGGING_H |
452 | |
453 | -// Logging and assertion macros. |
454 | -#define LOG(...) qDebug(__VA_ARGS__) |
455 | -#define LOG_IF(cond,...) do { if (cond) qDebug(__VA_ARGS__); } while(0) |
456 | +#include <QLoggingCategory> |
457 | + |
458 | #define ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop()) |
459 | -#define NOT_REACHED() qt_assert("Not reached!",__FILE__,__LINE__) |
460 | |
461 | -// Logging and assertion macros are compiled out for release builds. |
462 | -#if !defined(QT_NO_DEBUG) |
463 | -#define DLOG(...) LOG(__VA_ARGS__) |
464 | -#define DLOG_IF(cond,...) LOG_IF((cond), __VA_ARGS__) |
465 | -#define DASSERT(cond) ASSERT((cond)) |
466 | -#define DNOT_REACHED() NOT_REACHED() |
467 | -#else |
468 | -#define DLOG(...) qt_noop() |
469 | -#define DLOG_IF(cond,...) qt_noop() |
470 | -#define DASSERT(cond) qt_noop() |
471 | -#define DNOT_REACHED() qt_noop() |
472 | -#endif |
473 | +Q_DECLARE_LOGGING_CATEGORY(ubuntumirclient) |
474 | +Q_DECLARE_LOGGING_CATEGORY(ubuntumirclientBufferSwap) |
475 | +Q_DECLARE_LOGGING_CATEGORY(ubuntumirclientInput) |
476 | |
477 | #endif // QUBUNTULOGGING_H |
478 | |
479 | === modified file 'src/ubuntumirclient/plugin.cpp' |
480 | --- src/ubuntumirclient/plugin.cpp 2015-09-29 13:09:01 +0000 |
481 | +++ src/ubuntumirclient/plugin.cpp 2016-01-05 20:27:18 +0000 |
482 | @@ -16,6 +16,9 @@ |
483 | |
484 | #include "plugin.h" |
485 | #include "integration.h" |
486 | +#include "logging.h" |
487 | + |
488 | +Q_LOGGING_CATEGORY(ubuntumirclient, "ubuntumirclient", QtWarningMsg) |
489 | |
490 | QStringList UbuntuMirClientIntegrationPlugin::keys() const |
491 | { |
492 | |
493 | === modified file 'src/ubuntumirclient/screen.cpp' |
494 | --- src/ubuntumirclient/screen.cpp 2015-11-23 11:10:24 +0000 |
495 | +++ src/ubuntumirclient/screen.cpp 2016-01-05 20:27:18 +0000 |
496 | @@ -33,8 +33,6 @@ |
497 | |
498 | static const int kSwapInterval = 1; |
499 | |
500 | -#if !defined(QT_NO_DEBUG) |
501 | - |
502 | static const char *orientationToStr(Qt::ScreenOrientation orientation) { |
503 | switch (orientation) { |
504 | case Qt::PrimaryOrientation: |
505 | @@ -53,53 +51,55 @@ |
506 | } |
507 | |
508 | static void printEglConfig(EGLDisplay display, EGLConfig config) { |
509 | - DASSERT(display != EGL_NO_DISPLAY); |
510 | - DASSERT(config != nullptr); |
511 | - static const struct { const EGLint attrib; const char* name; } kAttribs[] = { |
512 | - { EGL_BUFFER_SIZE, "EGL_BUFFER_SIZE" }, |
513 | - { EGL_ALPHA_SIZE, "EGL_ALPHA_SIZE" }, |
514 | - { EGL_BLUE_SIZE, "EGL_BLUE_SIZE" }, |
515 | - { EGL_GREEN_SIZE, "EGL_GREEN_SIZE" }, |
516 | - { EGL_RED_SIZE, "EGL_RED_SIZE" }, |
517 | - { EGL_DEPTH_SIZE, "EGL_DEPTH_SIZE" }, |
518 | - { EGL_STENCIL_SIZE, "EGL_STENCIL_SIZE" }, |
519 | - { EGL_CONFIG_CAVEAT, "EGL_CONFIG_CAVEAT" }, |
520 | - { EGL_CONFIG_ID, "EGL_CONFIG_ID" }, |
521 | - { EGL_LEVEL, "EGL_LEVEL" }, |
522 | - { EGL_MAX_PBUFFER_HEIGHT, "EGL_MAX_PBUFFER_HEIGHT" }, |
523 | - { EGL_MAX_PBUFFER_PIXELS, "EGL_MAX_PBUFFER_PIXELS" }, |
524 | - { EGL_MAX_PBUFFER_WIDTH, "EGL_MAX_PBUFFER_WIDTH" }, |
525 | - { EGL_NATIVE_RENDERABLE, "EGL_NATIVE_RENDERABLE" }, |
526 | - { EGL_NATIVE_VISUAL_ID, "EGL_NATIVE_VISUAL_ID" }, |
527 | - { EGL_NATIVE_VISUAL_TYPE, "EGL_NATIVE_VISUAL_TYPE" }, |
528 | - { EGL_SAMPLES, "EGL_SAMPLES" }, |
529 | - { EGL_SAMPLE_BUFFERS, "EGL_SAMPLE_BUFFERS" }, |
530 | - { EGL_SURFACE_TYPE, "EGL_SURFACE_TYPE" }, |
531 | - { EGL_TRANSPARENT_TYPE, "EGL_TRANSPARENT_TYPE" }, |
532 | - { EGL_TRANSPARENT_BLUE_VALUE, "EGL_TRANSPARENT_BLUE_VALUE" }, |
533 | - { EGL_TRANSPARENT_GREEN_VALUE, "EGL_TRANSPARENT_GREEN_VALUE" }, |
534 | - { EGL_TRANSPARENT_RED_VALUE, "EGL_TRANSPARENT_RED_VALUE" }, |
535 | - { EGL_BIND_TO_TEXTURE_RGB, "EGL_BIND_TO_TEXTURE_RGB" }, |
536 | - { EGL_BIND_TO_TEXTURE_RGBA, "EGL_BIND_TO_TEXTURE_RGBA" }, |
537 | - { EGL_MIN_SWAP_INTERVAL, "EGL_MIN_SWAP_INTERVAL" }, |
538 | - { EGL_MAX_SWAP_INTERVAL, "EGL_MAX_SWAP_INTERVAL" }, |
539 | - { -1, NULL } |
540 | - }; |
541 | - const char* string = eglQueryString(display, EGL_VENDOR); |
542 | - LOG("EGL vendor: %s", string); |
543 | - string = eglQueryString(display, EGL_VERSION); |
544 | - LOG("EGL version: %s", string); |
545 | - string = eglQueryString(display, EGL_EXTENSIONS); |
546 | - LOG("EGL extensions: %s", string); |
547 | - LOG("EGL configuration attibutes:"); |
548 | - for (int index = 0; kAttribs[index].attrib != -1; index++) { |
549 | - EGLint value; |
550 | - if (eglGetConfigAttrib(display, config, kAttribs[index].attrib, &value)) |
551 | - LOG(" %s: %d", kAttribs[index].name, static_cast<int>(value)); |
552 | - } |
553 | + Q_ASSERT(display != EGL_NO_DISPLAY); |
554 | + Q_ASSERT(config != nullptr); |
555 | + |
556 | + static const struct { const EGLint attrib; const char* name; } kAttribs[] = { |
557 | + { EGL_BUFFER_SIZE, "EGL_BUFFER_SIZE" }, |
558 | + { EGL_ALPHA_SIZE, "EGL_ALPHA_SIZE" }, |
559 | + { EGL_BLUE_SIZE, "EGL_BLUE_SIZE" }, |
560 | + { EGL_GREEN_SIZE, "EGL_GREEN_SIZE" }, |
561 | + { EGL_RED_SIZE, "EGL_RED_SIZE" }, |
562 | + { EGL_DEPTH_SIZE, "EGL_DEPTH_SIZE" }, |
563 | + { EGL_STENCIL_SIZE, "EGL_STENCIL_SIZE" }, |
564 | + { EGL_CONFIG_CAVEAT, "EGL_CONFIG_CAVEAT" }, |
565 | + { EGL_CONFIG_ID, "EGL_CONFIG_ID" }, |
566 | + { EGL_LEVEL, "EGL_LEVEL" }, |
567 | + { EGL_MAX_PBUFFER_HEIGHT, "EGL_MAX_PBUFFER_HEIGHT" }, |
568 | + { EGL_MAX_PBUFFER_PIXELS, "EGL_MAX_PBUFFER_PIXELS" }, |
569 | + { EGL_MAX_PBUFFER_WIDTH, "EGL_MAX_PBUFFER_WIDTH" }, |
570 | + { EGL_NATIVE_RENDERABLE, "EGL_NATIVE_RENDERABLE" }, |
571 | + { EGL_NATIVE_VISUAL_ID, "EGL_NATIVE_VISUAL_ID" }, |
572 | + { EGL_NATIVE_VISUAL_TYPE, "EGL_NATIVE_VISUAL_TYPE" }, |
573 | + { EGL_SAMPLES, "EGL_SAMPLES" }, |
574 | + { EGL_SAMPLE_BUFFERS, "EGL_SAMPLE_BUFFERS" }, |
575 | + { EGL_SURFACE_TYPE, "EGL_SURFACE_TYPE" }, |
576 | + { EGL_TRANSPARENT_TYPE, "EGL_TRANSPARENT_TYPE" }, |
577 | + { EGL_TRANSPARENT_BLUE_VALUE, "EGL_TRANSPARENT_BLUE_VALUE" }, |
578 | + { EGL_TRANSPARENT_GREEN_VALUE, "EGL_TRANSPARENT_GREEN_VALUE" }, |
579 | + { EGL_TRANSPARENT_RED_VALUE, "EGL_TRANSPARENT_RED_VALUE" }, |
580 | + { EGL_BIND_TO_TEXTURE_RGB, "EGL_BIND_TO_TEXTURE_RGB" }, |
581 | + { EGL_BIND_TO_TEXTURE_RGBA, "EGL_BIND_TO_TEXTURE_RGBA" }, |
582 | + { EGL_MIN_SWAP_INTERVAL, "EGL_MIN_SWAP_INTERVAL" }, |
583 | + { EGL_MAX_SWAP_INTERVAL, "EGL_MAX_SWAP_INTERVAL" }, |
584 | + { -1, NULL } |
585 | + }; |
586 | + const char* string = eglQueryString(display, EGL_VENDOR); |
587 | + qCDebug(ubuntumirclient, "EGL vendor: %s", string); |
588 | + |
589 | + string = eglQueryString(display, EGL_VERSION); |
590 | + qCDebug(ubuntumirclient, "EGL version: %s", string); |
591 | + |
592 | + string = eglQueryString(display, EGL_EXTENSIONS); |
593 | + qCDebug(ubuntumirclient, "EGL extensions: %s", string); |
594 | + |
595 | + qCDebug(ubuntumirclient, "EGL configuration attibutes:"); |
596 | + for (int index = 0; kAttribs[index].attrib != -1; index++) { |
597 | + EGLint value; |
598 | + if (eglGetConfigAttrib(display, config, kAttribs[index].attrib, &value)) |
599 | + qCDebug(ubuntumirclient, " %s: %d", kAttribs[index].name, static_cast<int>(value)); |
600 | + } |
601 | } |
602 | -#endif |
603 | - |
604 | |
605 | const QEvent::Type OrientationChangeEvent::mType = |
606 | static_cast<QEvent::Type>(QEvent::registerEventType()); |
607 | @@ -150,7 +150,7 @@ |
608 | mSurfaceFormat.setStencilBufferSize(8); |
609 | if (!qEnvironmentVariableIsEmpty("QTUBUNTU_MULTISAMPLE")) { |
610 | mSurfaceFormat.setSamples(4); |
611 | - DLOG("ubuntumirclient: setting MSAA to 4 samples"); |
612 | + qCDebug(ubuntumirclient, "setting MSAA to 4 samples"); |
613 | } |
614 | #ifdef QTUBUNTU_USE_OPENGL |
615 | mSurfaceFormat.setRenderableType(QSurfaceFormat::OpenGL); |
616 | @@ -159,9 +159,9 @@ |
617 | #endif |
618 | mEglConfig = q_configFromGLFormat(mEglDisplay, mSurfaceFormat, true); |
619 | |
620 | - #if !defined(QT_NO_DEBUG) |
621 | - printEglConfig(mEglDisplay, mEglConfig); |
622 | - #endif |
623 | + if (ubuntumirclient().isDebugEnabled()) { |
624 | + printEglConfig(mEglDisplay, mEglConfig); |
625 | + } |
626 | |
627 | // Set vblank swap interval. |
628 | int swapInterval = kSwapInterval; |
629 | @@ -172,7 +172,7 @@ |
630 | if (!ok) |
631 | swapInterval = kSwapInterval; |
632 | } |
633 | - DLOG("ubuntumirclient: setting swap interval to %d", swapInterval); |
634 | + qCDebug(ubuntumirclient, "setting swap interval to %d", swapInterval); |
635 | eglSwapInterval(mEglDisplay, swapInterval); |
636 | |
637 | // Get screen resolution. |
638 | @@ -187,19 +187,17 @@ |
639 | mOutputId = displayOutput->output_id; |
640 | |
641 | mPhysicalSize = QSizeF(displayOutput->physical_width_mm, displayOutput->physical_height_mm); |
642 | - DLOG("ubuntumirclient: screen physical size: %.2fx%.2f", mPhysicalSize.width(), mPhysicalSize.height()); |
643 | + qCDebug(ubuntumirclient, "screen physical size: %.2fx%.2f", mPhysicalSize.width(), mPhysicalSize.height()); |
644 | |
645 | const MirDisplayMode *mode = &displayOutput->modes[displayOutput->current_mode]; |
646 | const int kScreenWidth = mode->horizontal_resolution; |
647 | const int kScreenHeight = mode->vertical_resolution; |
648 | - DASSERT(kScreenWidth > 0 && kScreenHeight > 0); |
649 | + Q_ASSERT(kScreenWidth > 0 && kScreenHeight > 0); |
650 | |
651 | - DLOG("ubuntumirclient: screen resolution: %dx%d", kScreenWidth, kScreenHeight); |
652 | + qCDebug(ubuntumirclient, "screen resolution: %dx%d", kScreenWidth, kScreenHeight); |
653 | |
654 | mGeometry = QRect(0, 0, kScreenWidth, kScreenHeight); |
655 | |
656 | - DLOG("QUbuntuScreen::QUbuntuScreen (this=%p)", this); |
657 | - |
658 | // Set the default orientation based on the initial screen dimmensions. |
659 | mNativeOrientation = (mGeometry.width() >= mGeometry.height()) ? Qt::LandscapeOrientation : Qt::PortraitOrientation; |
660 | |
661 | @@ -213,7 +211,7 @@ |
662 | } |
663 | |
664 | void UbuntuScreen::customEvent(QEvent* event) { |
665 | - DASSERT(QThread::currentThread() == thread()); |
666 | + Q_ASSERT(QThread::currentThread() == thread()); |
667 | |
668 | OrientationChangeEvent* oReadingEvent = static_cast<OrientationChangeEvent*>(event); |
669 | switch (oReadingEvent->mOrientation) { |
670 | @@ -238,13 +236,13 @@ |
671 | break; |
672 | } |
673 | default: { |
674 | - DLOG("UbuntuScreen::customEvent - Unknown orientation."); |
675 | + qCDebug(ubuntumirclient, "UbuntuScreen::customEvent - Unknown orientation."); |
676 | return; |
677 | } |
678 | } |
679 | |
680 | // Raise the event signal so that client apps know the orientation changed |
681 | - DLOG("UbuntuScreen::customEvent - handling orientation change to %s", orientationToStr(mCurrentOrientation)); |
682 | + qCDebug(ubuntumirclient, "UbuntuScreen::customEvent - handling orientation change to %s", orientationToStr(mCurrentOrientation)); |
683 | QWindowSystemInterface::handleScreenOrientationChange(screen(), mCurrentOrientation); |
684 | } |
685 | |
686 | @@ -265,7 +263,7 @@ |
687 | mGeometry.setWidth(currGeometry.height()); |
688 | mGeometry.setHeight(currGeometry.width()); |
689 | |
690 | - DLOG("UbuntuScreen::handleWindowSurfaceResize - new screen geometry (w=%d, h=%d)", |
691 | + qCDebug(ubuntumirclient, "UbuntuScreen::handleWindowSurfaceResize - new screen geometry (w=%d, h=%d)", |
692 | mGeometry.width(), mGeometry.height()); |
693 | QWindowSystemInterface::handleScreenGeometryChange(screen(), |
694 | mGeometry /* newGeometry */, |
695 | @@ -276,7 +274,7 @@ |
696 | } else { |
697 | mCurrentOrientation = Qt::LandscapeOrientation; |
698 | } |
699 | - DLOG("UbuntuScreen::handleWindowSurfaceResize - new orientation %s",orientationToStr(mCurrentOrientation)); |
700 | + qCDebug(ubuntumirclient, "UbuntuScreen::handleWindowSurfaceResize - new orientation %s",orientationToStr(mCurrentOrientation)); |
701 | QWindowSystemInterface::handleScreenOrientationChange(screen(), mCurrentOrientation); |
702 | } |
703 | } |
704 | |
705 | === modified file 'src/ubuntumirclient/window.cpp' |
706 | --- src/ubuntumirclient/window.cpp 2015-12-16 11:28:09 +0000 |
707 | +++ src/ubuntumirclient/window.cpp 2016-01-05 20:27:18 +0000 |
708 | @@ -34,6 +34,8 @@ |
709 | |
710 | #include <EGL/egl.h> |
711 | |
712 | +Q_LOGGING_CATEGORY(ubuntumirclientBufferSwap, "ubuntumirclient.bufferSwap", QtWarningMsg) |
713 | + |
714 | namespace |
715 | { |
716 | |
717 | @@ -75,12 +77,11 @@ |
718 | case Qt::WindowMinimized: |
719 | return mir_surface_state_minimized; |
720 | default: |
721 | - LOG("Unexpected Qt::WindowState: %d", state); |
722 | + qCWarning(ubuntumirclient, "Unexpected Qt::WindowState: %d", state); |
723 | return mir_surface_state_restored; |
724 | } |
725 | } |
726 | |
727 | -#if !defined(QT_NO_DEBUG) |
728 | const char *qtWindowStateToStr(Qt::WindowState state) |
729 | { |
730 | switch (state) { |
731 | @@ -96,7 +97,6 @@ |
732 | return "!?"; |
733 | } |
734 | } |
735 | -#endif |
736 | |
737 | WId makeId() |
738 | { |
739 | @@ -133,50 +133,50 @@ |
740 | |
741 | Spec makeSurfaceSpec(QWindow *window, UbuntuInput *input, MirConnection *connection) |
742 | { |
743 | - const auto geom = window->geometry(); |
744 | - const int width = geom.width() > 0 ? geom.width() : 1; |
745 | - const int height = geom.height() > 0 ? geom.height() : 1; |
746 | - const auto pixelFormat = defaultPixelFormatFor(connection); |
747 | - |
748 | - if (U_ON_SCREEN_KEYBOARD_ROLE == roleFor(window)) { |
749 | - DLOG("[ubuntumirclient QPA] makeSurfaceSpec(window=%p) - creating input method surface (width=%d, height=%d", window, width, height); |
750 | - return Spec{mir_connection_create_spec_for_input_method(connection, width, height, pixelFormat)}; |
751 | - } |
752 | - |
753 | - const Qt::WindowType type = window->type(); |
754 | - if (type == Qt::Popup) { |
755 | - auto parent = transientParentFor(window); |
756 | - if (parent == nullptr) { |
757 | - //NOTE: We cannot have a parentless popup - |
758 | - //try using the last surface to receive input as that will most likely be |
759 | - //the one that caused this popup to be created |
760 | - parent = input->lastFocusedWindow(); |
761 | - } |
762 | - if (parent) { |
763 | - auto pos = geom.topLeft(); |
764 | - pos -= parent->geometry().topLeft(); |
765 | - MirRectangle location{pos.x(), pos.y(), 0, 0}; |
766 | - DLOG("[ubuntumirclient QPA] makeSurfaceSpec(window=%p) - creating menu surface(width:%d, height:%d)", window, width, height); |
767 | - return Spec{mir_connection_create_spec_for_menu( |
768 | - connection, width, height, pixelFormat, parent->mirSurface(), |
769 | - &location, mir_edge_attachment_any)}; |
770 | - } else { |
771 | - DLOG("[ubuntumirclient QPA] makeSurfaceSpec(window=%p) - cannot create a menu without a parent!", window); |
772 | - } |
773 | - } else if (type == Qt::Dialog) { |
774 | - auto parent = transientParentFor(window); |
775 | - if (parent) { |
776 | - // Modal dialog |
777 | - DLOG("[ubuntumirclient QPA] makeSurfaceSpec(window=%p) - creating modal dialog (width=%d, height=%d", window, width, height); |
778 | - return Spec{mir_connection_create_spec_for_modal_dialog(connection, width, height, pixelFormat, parent->mirSurface())}; |
779 | - } else { |
780 | - // TODO: do Qt parentless dialogs have the same semantics as mir? |
781 | - DLOG("[ubuntumirclient QPA] makeSurfaceSpec(window=%p) - creating parentless dialog (width=%d, height=%d)", window, width, height); |
782 | - return Spec{mir_connection_create_spec_for_dialog(connection, width, height, pixelFormat)}; |
783 | - } |
784 | - } |
785 | - DLOG("[ubuntumirclient QPA] makeSurfaceSpec(window=%p) - creating normal surface(type=0x%x, width=%d, height=%d)", window, type, width, height); |
786 | - return Spec{mir_connection_create_spec_for_normal_surface(connection, width, height, pixelFormat)}; |
787 | + const auto geom = window->geometry(); |
788 | + const int width = geom.width() > 0 ? geom.width() : 1; |
789 | + const int height = geom.height() > 0 ? geom.height() : 1; |
790 | + const auto pixelFormat = defaultPixelFormatFor(connection); |
791 | + |
792 | + if (U_ON_SCREEN_KEYBOARD_ROLE == roleFor(window)) { |
793 | + qCDebug(ubuntumirclient, "makeSurfaceSpec(window=%p) - creating input method surface (width=%d, height=%d", window, width, height); |
794 | + return Spec{mir_connection_create_spec_for_input_method(connection, width, height, pixelFormat)}; |
795 | + } |
796 | + |
797 | + const Qt::WindowType type = window->type(); |
798 | + if (type == Qt::Popup) { |
799 | + auto parent = transientParentFor(window); |
800 | + if (parent == nullptr) { |
801 | + //NOTE: We cannot have a parentless popup - |
802 | + //try using the last surface to receive input as that will most likely be |
803 | + //the one that caused this popup to be created |
804 | + parent = input->lastFocusedWindow(); |
805 | + } |
806 | + if (parent) { |
807 | + auto pos = geom.topLeft(); |
808 | + pos -= parent->geometry().topLeft(); |
809 | + MirRectangle location{pos.x(), pos.y(), 0, 0}; |
810 | + qCDebug(ubuntumirclient, "makeSurfaceSpec(window=%p) - creating menu surface(width:%d, height:%d)", window, width, height); |
811 | + return Spec{mir_connection_create_spec_for_menu( |
812 | + connection, width, height, pixelFormat, parent->mirSurface(), |
813 | + &location, mir_edge_attachment_any)}; |
814 | + } else { |
815 | + qCDebug(ubuntumirclient, "makeSurfaceSpec(window=%p) - cannot create a menu without a parent!", window); |
816 | + } |
817 | + } else if (type == Qt::Dialog) { |
818 | + auto parent = transientParentFor(window); |
819 | + if (parent) { |
820 | + // Modal dialog |
821 | + qCDebug(ubuntumirclient, "makeSurfaceSpec(window=%p) - creating modal dialog (width=%d, height=%d", window, width, height); |
822 | + return Spec{mir_connection_create_spec_for_modal_dialog(connection, width, height, pixelFormat, parent->mirSurface())}; |
823 | + } else { |
824 | + // TODO: do Qt parentless dialogs have the same semantics as mir? |
825 | + qCDebug(ubuntumirclient, "makeSurfaceSpec(window=%p) - creating parentless dialog (width=%d, height=%d)", window, width, height); |
826 | + return Spec{mir_connection_create_spec_for_dialog(connection, width, height, pixelFormat)}; |
827 | + } |
828 | + } |
829 | + qCDebug(ubuntumirclient, "makeSurfaceSpec(window=%p) - creating normal surface(type=0x%x, width=%d, height=%d)", window, type, width, height); |
830 | + return Spec{mir_connection_create_spec_for_normal_surface(connection, width, height, pixelFormat)}; |
831 | } |
832 | |
833 | void setSizingConstraints(MirSurfaceSpec *spec, const QSize& minSize, const QSize& maxSize, const QSize& increment) |
834 | @@ -271,7 +271,7 @@ |
835 | platformWindow->QPlatformWindow::setGeometry(geom); |
836 | QWindowSystemInterface::handleGeometryChange(mWindow, geom); |
837 | |
838 | - DLOG("[ubuntumirclient QPA] created surface at (%d, %d) with size (%d, %d), title '%s', role: '%d'\n", |
839 | + qCDebug(ubuntumirclient, "created surface at (%d, %d) with size (%d, %d), title '%s', role: '%d'\n", |
840 | geom.x(), geom.y(), geom.width(), geom.height(), mWindow->title().toUtf8().constData(), roleFor(mWindow)); |
841 | } |
842 | |
843 | @@ -325,15 +325,15 @@ |
844 | |
845 | void UbuntuSurface::resize(const QSize& size) |
846 | { |
847 | - DLOG("[ubuntumirclient QPA] resize(window=%p, width=%d, height=%d)", mWindow, size.width(), size.height()); |
848 | + qCDebug(ubuntumirclient,"resize(window=%p, width=%d, height=%d)", mWindow, size.width(), size.height()); |
849 | |
850 | if (mWindowState == Qt::WindowFullScreen || mWindowState == Qt::WindowMaximized) { |
851 | - DLOG("[ubuntumirclient QPA] resize(window=%p) - not resizing, window is maximized or fullscreen", mWindow); |
852 | + qCDebug(ubuntumirclient, "resize(window=%p) - not resizing, window is maximized or fullscreen", mWindow); |
853 | return; |
854 | } |
855 | |
856 | if (size.isEmpty()) { |
857 | - DLOG("[ubuntumirclient QPA] resize(window=%p) - not resizing, size is empty", mWindow); |
858 | + qCDebug(ubuntumirclient, "resize(window=%p) - not resizing, size is empty", mWindow); |
859 | return; |
860 | } |
861 | |
862 | @@ -412,10 +412,8 @@ |
863 | |
864 | void UbuntuSurface::onSwapBuffersDone() |
865 | { |
866 | -#if !defined(QT_NO_DEBUG) |
867 | static int sFrameNumber = 0; |
868 | ++sFrameNumber; |
869 | -#endif |
870 | |
871 | EGLint eglSurfaceWidth = -1; |
872 | EGLint eglSurfaceHeight = -1; |
873 | @@ -426,7 +424,7 @@ |
874 | |
875 | if (validSize && (mBufferSize.width() != eglSurfaceWidth || mBufferSize.height() != eglSurfaceHeight)) { |
876 | |
877 | - DLOG("[ubuntumirclient QPA] onSwapBuffersDone(window=%p) [%d] - size changed (%d, %d) => (%d, %d)", |
878 | + qCDebug(ubuntumirclientBufferSwap, "onSwapBuffersDone(window=%p) [%d] - size changed (%d, %d) => (%d, %d)", |
879 | mWindow, sFrameNumber, mBufferSize.width(), mBufferSize.height(), eglSurfaceWidth, eglSurfaceHeight); |
880 | |
881 | mBufferSize.rwidth() = eglSurfaceWidth; |
882 | @@ -438,7 +436,7 @@ |
883 | mPlatformWindow->QPlatformWindow::setGeometry(newGeometry); |
884 | QWindowSystemInterface::handleGeometryChange(mWindow, newGeometry); |
885 | } else { |
886 | - DLOG("[ubuntumirclient QPA] onSwapBuffersDone(window=%p) [%d] - buffer size (%d,%d)", |
887 | + qCDebug(ubuntumirclientBufferSwap, "onSwapBuffersDone(window=%p) [%d] - buffer size (%d,%d)", |
888 | mWindow, sFrameNumber, mBufferSize.width(), mBufferSize.height()); |
889 | } |
890 | } |
891 | @@ -462,7 +460,7 @@ |
892 | const auto resizeEvent = mir_event_get_resize_event(event); |
893 | const auto width = mir_resize_event_get_width(resizeEvent); |
894 | const auto height = mir_resize_event_get_height(resizeEvent); |
895 | - DLOG("[ubuntumirclient QPA] resizeEvent(window=%p, width=%d, height=%d)", mWindow, width, height); |
896 | + qCDebug(ubuntumirclient, "resizeEvent(window=%p, width=%d, height=%d)", mWindow, width, height); |
897 | |
898 | QMutexLocker lock(&mTargetSizeMutex); |
899 | mTargetSize.rwidth() = width; |
900 | @@ -474,14 +472,14 @@ |
901 | |
902 | void UbuntuSurface::updateSurface() |
903 | { |
904 | - DLOG("[ubuntumirclient QPA] updateSurface(window=%p)", mWindow); |
905 | + qCDebug(ubuntumirclient, "updateSurface(window=%p)", mWindow); |
906 | |
907 | if (!mParented && mWindow->type() == Qt::Dialog) { |
908 | // The dialog may have been parented after creation time |
909 | // so morph it into a modal dialog |
910 | auto parent = transientParentFor(mWindow); |
911 | if (parent) { |
912 | - DLOG("[ubuntumirclient QPA] updateSurface(window=%p) dialog now parented", mWindow); |
913 | + qCDebug(ubuntumirclient, "updateSurface(window=%p) dialog now parented", mWindow); |
914 | mParented = true; |
915 | Spec spec{mir_connection_create_spec_for_changes(mConnection)}; |
916 | mir_surface_spec_set_parent(spec.get(), parent->mirSurface()); |
917 | @@ -498,18 +496,18 @@ |
918 | , mClipboard(clipboard) |
919 | , mSurface(new UbuntuSurface{this, screen, input, connection}) |
920 | { |
921 | - DLOG("[ubuntumirclient QPA] UbuntuWindow(window=%p, screen=%p, input=%p, surf=%p)", w, screen, input, mSurface.get()); |
922 | + qCDebug(ubuntumirclient, "UbuntuWindow(window=%p, screen=%p, input=%p, surf=%p)", w, screen, input, mSurface.get()); |
923 | } |
924 | |
925 | UbuntuWindow::~UbuntuWindow() |
926 | { |
927 | - DLOG("[ubuntumirclient QPA] ~UbuntuWindow(window=%p)", this); |
928 | + qCDebug(ubuntumirclient, "~UbuntuWindow(window=%p)", this); |
929 | } |
930 | |
931 | void UbuntuWindow::handleSurfaceResized(int width, int height) |
932 | { |
933 | QMutexLocker lock(&mMutex); |
934 | - DLOG("[ubuntumirclient QPA] handleSurfaceResize(window=%p, width=%d, height=%d)", window(), width, height); |
935 | + qCDebug(ubuntumirclient, "handleSurfaceResize(window=%p, width=%d, height=%d)", window(), width, height); |
936 | |
937 | mSurface->handleSurfaceResized(width, height); |
938 | |
939 | @@ -519,16 +517,16 @@ |
940 | // updated size but it still needs re-rendering so another redraw may be needed. |
941 | // A mir API to drop the currently held buffer would help here, so that we wouldn't have to redraw twice |
942 | auto const numRepaints = mSurface->needsRepaint(); |
943 | - DLOG("[ubuntumirclient QPA] handleSurfaceResize(window=%p) redraw %d times", window(), numRepaints); |
944 | + qCDebug(ubuntumirclient, "handleSurfaceResize(window=%p) redraw %d times", window(), numRepaints); |
945 | for (int i = 0; i < numRepaints; i++) { |
946 | - DLOG("[ubuntumirclient QPA] handleSurfaceResize(window=%p) repainting width=%d, height=%d", window(), geometry().size().width(), geometry().size().height()); |
947 | + qCDebug(ubuntumirclient, "handleSurfaceResize(window=%p) repainting width=%d, height=%d", window(), geometry().size().width(), geometry().size().height()); |
948 | QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); |
949 | } |
950 | } |
951 | |
952 | void UbuntuWindow::handleSurfaceFocused() |
953 | { |
954 | - DLOG("[ubuntumirclient QPA] handleSurfaceFocused(window=%p)", window()); |
955 | + qCDebug(ubuntumirclient, "handleSurfaceFocused(window=%p)", window()); |
956 | |
957 | // System clipboard contents might have changed while this window was unfocused and without |
958 | // this process getting notified about it because it might have been suspended (due to |
959 | @@ -542,7 +540,7 @@ |
960 | void UbuntuWindow::setWindowState(Qt::WindowState state) |
961 | { |
962 | QMutexLocker lock(&mMutex); |
963 | - DLOG("[ubuntumirclient QPA] setWindowState(window=%p, %s)", this, qtWindowStateToStr(state)); |
964 | + qCDebug(ubuntumirclient, "setWindowState(window=%p, %s)", this, qtWindowStateToStr(state)); |
965 | mSurface->setState(state); |
966 | |
967 | updatePanelHeightHack(state); |
968 | @@ -572,7 +570,7 @@ |
969 | void UbuntuWindow::setGeometry(const QRect& rect) |
970 | { |
971 | QMutexLocker lock(&mMutex); |
972 | - DLOG("[ubuntumirclient QPA] setGeometry (window=%p, x=%d, y=%d, width=%d, height=%d)", |
973 | + qCDebug(ubuntumirclient, "setGeometry (window=%p, x=%d, y=%d, width=%d, height=%d)", |
974 | window(), rect.x(), rect.y(), rect.width(), rect.height()); |
975 | |
976 | //NOTE: mir surfaces cannot be moved by the client so ignore the topLeft coordinates |
977 | @@ -587,7 +585,7 @@ |
978 | void UbuntuWindow::setVisible(bool visible) |
979 | { |
980 | QMutexLocker lock(&mMutex); |
981 | - DLOG("[ubuntumirclient QPA] setVisible (window=%p, visible=%s)", window(), visible ? "true" : "false"); |
982 | + qCDebug(ubuntumirclient, "setVisible (window=%p, visible=%s)", window(), visible ? "true" : "false"); |
983 | |
984 | mSurface->setVisible(visible); |
985 | const QRect& exposeRect = visible ? QRect(QPoint(), geometry().size()) : QRect(); |
986 | @@ -600,7 +598,7 @@ |
987 | void UbuntuWindow::setWindowTitle(const QString& title) |
988 | { |
989 | QMutexLocker lock(&mMutex); |
990 | - DLOG("[ubuntumirclient QPA] setWindowTitle(window=%p) title=%s)", window(), title.toUtf8().constData()); |
991 | + qCDebug(ubuntumirclient, "setWindowTitle(window=%p) title=%s)", window(), title.toUtf8().constData()); |
992 | mSurface->updateTitle(title); |
993 | } |
994 | |
995 | @@ -608,7 +606,7 @@ |
996 | { |
997 | QMutexLocker lock(&mMutex); |
998 | const auto win = window(); |
999 | - DLOG("[ubuntumirclient QPA] propagateSizeHints(window=%p) min(%d,%d), max(%d,%d) increment(%d, %d)", |
1000 | + qCDebug(ubuntumirclient, "propagateSizeHints(window=%p) min(%d,%d), max(%d,%d) increment(%d, %d)", |
1001 | win, win->minimumSize().width(), win->minimumSize().height(), |
1002 | win->maximumSize().width(), win->maximumSize().height(), |
1003 | win->sizeIncrement().width(), win->sizeIncrement().height()); |
1004 | |
1005 | === modified file 'src/ubuntumirclient/window.h' |
1006 | --- src/ubuntumirclient/window.h 2015-12-07 16:20:58 +0000 |
1007 | +++ src/ubuntumirclient/window.h 2016-01-05 20:27:18 +0000 |
1008 | @@ -18,6 +18,7 @@ |
1009 | #define UBUNTU_WINDOW_H |
1010 | |
1011 | #include <qpa/qplatformwindow.h> |
1012 | +#include <QLoggingCategory> |
1013 | #include <QSharedPointer> |
1014 | #include <QMutex> |
1015 |
PASSED: Continuous integration, rev:297 jenkins. qa.ubuntu. com/job/ qtubuntu- ci/284/ jenkins. qa.ubuntu. com/job/ qtubuntu- wily-armhf- ci/75 jenkins. qa.ubuntu. com/job/ qtubuntu- wily-armhf- ci/75/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/qtubuntu- ci/284/ rebuild
http://