Merge lp:~nick-dedekind/qtubuntu/lp1475678.surface-occlude into lp:qtubuntu

Proposed by Nick Dedekind
Status: Merged
Approved by: Daniel d'Andrada
Approved revision: 284
Merged at revision: 284
Proposed branch: lp:~nick-dedekind/qtubuntu/lp1475678.surface-occlude
Merge into: lp:qtubuntu
Diff against target: 151 lines (+48/-6)
3 files modified
src/ubuntumirclient/input.cpp (+7/-1)
src/ubuntumirclient/window.cpp (+39/-5)
src/ubuntumirclient/window.h (+2/-0)
To merge this branch: bzr merge lp:~nick-dedekind/qtubuntu/lp1475678.surface-occlude
Reviewer Review Type Date Requested Status
Nick Dedekind (community) Abstain
Daniel d'Andrada (community) Needs Fixing
PS Jenkins bot continuous-integration Approve
Review via email: mp+273424@code.launchpad.net

Commit message

Support server->client visibility change to stop rendering (lp:#1475678)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

In src/ubuntumirclient/window.cpp:

"""
+ window()->setVisible(exposed);
"""

You sure this is necessary?

It doesn't look right that a backend is calling the client-side API. Since, QWindow::visible property is under control of application code, it would be weird that it suddenly turn false without app code having explicitly set it (either via setVisible(false) or hide()).

review: Needs Information
284. By Nick Dedekind

better exposure handling

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

> In src/ubuntumirclient/window.cpp:
>
> """
> + window()->setVisible(exposed);
> """
>
> You sure this is necessary?
>
> It doesn't look right that a backend is calling the client-side API. Since,
> QWindow::visible property is under control of application code, it would be
> weird that it suddenly turn false without app code having explicitly set it
> (either via setVisible(false) or hide()).

Apparently not. Looks like it's the isExposed that stops the redraw.
I've fixed it up now.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Code looks ok. Didn't test yet.

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

And works fine.

review: Approve
Revision history for this message
Daniel d'Andrada (dandrader) :
review: Approve
285. By Nick Dedekind

merge with trunk

286. By Nick Dedekind

Exposure initialization

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

something like pendingOcclusion or occlusionCatchup would be clearer than exposeCatchUp as this is meant specifically to occlude the window. Corner cases like this should be well explained.

review: Needs Fixing
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

> something like pendingOcclusion or occlusionCatchup would be clearer than
> exposeCatchUp as this is meant specifically to occlude the window. Corner
> cases like this should be well explained.

Done and added a comment explaining.

review: Disapprove
Revision history for this message
Nick Dedekind (nick-dedekind) :
review: Abstain
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Thanks! But looks like it was too late. This last change didn't show up in the merged branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/ubuntumirclient/input.cpp'
--- src/ubuntumirclient/input.cpp 2015-10-21 11:47:48 +0000
+++ src/ubuntumirclient/input.cpp 2015-11-06 09:06:33 +0000
@@ -232,9 +232,15 @@
232 case mir_event_type_surface:232 case mir_event_type_surface:
233 {233 {
234 auto surfaceEvent = mir_event_get_surface_event(nativeEvent);234 auto surfaceEvent = mir_event_get_surface_event(nativeEvent);
235 if (mir_surface_event_get_attribute(surfaceEvent) == mir_surface_attrib_focus) {235 auto surfaceEventAttribute = mir_surface_event_get_attribute(surfaceEvent);
236
237 if (surfaceEventAttribute == mir_surface_attrib_focus) {
236 ubuntuEvent->window->handleSurfaceFocusChange(mir_surface_event_get_attribute_value(surfaceEvent) ==238 ubuntuEvent->window->handleSurfaceFocusChange(mir_surface_event_get_attribute_value(surfaceEvent) ==
237 mir_surface_focused);239 mir_surface_focused);
240
241 } else if (surfaceEventAttribute == mir_surface_attrib_visibility) {
242 ubuntuEvent->window->handleSurfaceExposeChange(mir_surface_event_get_attribute_value(surfaceEvent) ==
243 mir_surface_visibility_exposed);
238 }244 }
239 break;245 break;
240 }246 }
241247
=== modified file 'src/ubuntumirclient/window.cpp'
--- src/ubuntumirclient/window.cpp 2015-09-29 18:10:51 +0000
+++ src/ubuntumirclient/window.cpp 2015-11-06 09:06:33 +0000
@@ -99,7 +99,9 @@
99 QSize bufferSize;99 QSize bufferSize;
100 QMutex mutex;100 QMutex mutex;
101 QSharedPointer<UbuntuClipboard> clipboard;101 QSharedPointer<UbuntuClipboard> clipboard;
102 bool exposed;
102 int resizeCatchUpAttempts;103 int resizeCatchUpAttempts;
104 bool exposeCatchUp;
103#if !defined(QT_NO_DEBUG)105#if !defined(QT_NO_DEBUG)
104 int frameNumber;106 int frameNumber;
105#endif107#endif
@@ -136,6 +138,8 @@
136 d->connection = connection;138 d->connection = connection;
137 d->clipboard = clipboard;139 d->clipboard = clipboard;
138 d->resizeCatchUpAttempts = 0;140 d->resizeCatchUpAttempts = 0;
141 d->exposed = true;
142 d->exposeCatchUp = false;
139143
140 static int id = 1;144 static int id = 1;
141 d->id = id++;145 d->id = id++;
@@ -283,6 +287,7 @@
283 // Create platform window287 // Create platform window
284 mir_wait_for(mir_surface_create(spec, surfaceCreateCallback, this));288 mir_wait_for(mir_surface_create(spec, surfaceCreateCallback, this));
285 mir_surface_spec_release(spec);289 mir_surface_spec_release(spec);
290 d->exposeCatchUp = mir_surface_get_visibility(d->surface) == mir_surface_visibility_occluded;
286291
287 DASSERT(d->surface != NULL);292 DASSERT(d->surface != NULL);
288 d->createEGLSurface((EGLNativeWindowType)mir_buffer_stream_get_egl_native_window(mir_surface_get_buffer_stream(d->surface)));293 d->createEGLSurface((EGLNativeWindowType)mir_buffer_stream_get_egl_native_window(mir_surface_get_buffer_stream(d->surface)));
@@ -339,7 +344,7 @@
339 // swap more than once to get a buffer with the new size!344 // swap more than once to get a buffer with the new size!
340 d->resizeCatchUpAttempts = 2;345 d->resizeCatchUpAttempts = 2;
341346
342 QWindowSystemInterface::handleExposeEvent(window(), geometry());347 QWindowSystemInterface::handleExposeEvent(window(), d->exposed ? QRect(QPoint(), geometry().size()) : QRect());
343 QWindowSystemInterface::flushWindowSystemEvents();348 QWindowSystemInterface::flushWindowSystemEvents();
344 }349 }
345}350}
@@ -362,6 +367,19 @@
362 QWindowSystemInterface::handleWindowActivated(activatedWindow, Qt::ActiveWindowFocusReason);367 QWindowSystemInterface::handleWindowActivated(activatedWindow, Qt::ActiveWindowFocusReason);
363}368}
364369
370void UbuntuWindow::handleSurfaceExposeChange(bool exposed)
371{
372 QMutexLocker(&d->mutex);
373 DLOG("UbuntuWindow::handleSurfaceExposeChange(exposed=%s)", exposed ? "true" : "false");
374
375 if (d->exposed != exposed) {
376 d->exposed = exposed;
377
378 QWindowSystemInterface::handleExposeEvent(window(), d->exposed ? QRect(QPoint(), geometry().size()) : QRect());
379 QWindowSystemInterface::flushWindowSystemEvents();
380 }
381}
382
365void UbuntuWindow::setWindowState(Qt::WindowState state)383void UbuntuWindow::setWindowState(Qt::WindowState state)
366{384{
367 QMutexLocker(&d->mutex);385 QMutexLocker(&d->mutex);
@@ -399,14 +417,19 @@
399417
400 if (visible) {418 if (visible) {
401 mir_wait_for(mir_surface_set_state(d->surface, qtWindowStateToMirSurfaceState(d->state)));419 mir_wait_for(mir_surface_set_state(d->surface, qtWindowStateToMirSurfaceState(d->state)));
402
403 QWindowSystemInterface::handleExposeEvent(window(), QRect());
404 QWindowSystemInterface::flushWindowSystemEvents();
405 } else {420 } else {
406 // TODO: Use the new mir_surface_state_hidden state instead of mir_surface_state_minimized.421 // TODO: Use the new mir_surface_state_hidden state instead of mir_surface_state_minimized.
407 // Will have to change qtmir and unity8 for that.422 // Will have to change qtmir and unity8 for that.
408 mir_wait_for(mir_surface_set_state(d->surface, mir_surface_state_minimized));423 mir_wait_for(mir_surface_set_state(d->surface, mir_surface_state_minimized));
409 }424 }
425
426 QWindowSystemInterface::handleExposeEvent(window(), d->exposed ? QRect(QPoint(), geometry().size()) : QRect());
427 QWindowSystemInterface::flushWindowSystemEvents();
428}
429
430bool UbuntuWindow::isExposed() const
431{
432 return d->exposed && window()->isVisible();
410}433}
411434
412void UbuntuWindow::setWindowTitle(const QString &title)435void UbuntuWindow::setWindowTitle(const QString &title)
@@ -437,6 +460,13 @@
437 ++d->frameNumber;460 ++d->frameNumber;
438#endif461#endif
439462
463 bool exposureChanged = false;
464 if (d->exposeCatchUp) {
465 d->exposeCatchUp = false;
466 d->exposed = false;
467 exposureChanged = true;
468 }
469
440 if (sizeKnown && (d->bufferSize.width() != newBufferWidth ||470 if (sizeKnown && (d->bufferSize.width() != newBufferWidth ||
441 d->bufferSize.height() != newBufferHeight)) {471 d->bufferSize.height() != newBufferHeight)) {
442 d->resizeCatchUpAttempts = 0;472 d->resizeCatchUpAttempts = 0;
@@ -462,9 +492,13 @@
462 DLOG("UbuntuWindow::onBuffersSwapped_threadSafe [%d] - buffer size (%d,%d). Redrawing to catch up a resized buffer."492 DLOG("UbuntuWindow::onBuffersSwapped_threadSafe [%d] - buffer size (%d,%d). Redrawing to catch up a resized buffer."
463 " resizeCatchUpAttempts=%d",493 " resizeCatchUpAttempts=%d",
464 d->frameNumber, d->bufferSize.width(), d->bufferSize.height(), d->resizeCatchUpAttempts);494 d->frameNumber, d->bufferSize.width(), d->bufferSize.height(), d->resizeCatchUpAttempts);
465 QWindowSystemInterface::handleExposeEvent(window(), geometry());495 QWindowSystemInterface::handleExposeEvent(window(), d->exposed ? QRect(QPoint(), geometry().size()) : QRect());
466 } else {496 } else {
467 DLOG("UbuntuWindow::onBuffersSwapped_threadSafe [%d] - buffer size (%d,%d). resizeCatchUpAttempts=%d",497 DLOG("UbuntuWindow::onBuffersSwapped_threadSafe [%d] - buffer size (%d,%d). resizeCatchUpAttempts=%d",
468 d->frameNumber, d->bufferSize.width(), d->bufferSize.height(), d->resizeCatchUpAttempts);498 d->frameNumber, d->bufferSize.width(), d->bufferSize.height(), d->resizeCatchUpAttempts);
499
500 if (exposureChanged) {
501 QWindowSystemInterface::handleExposeEvent(window(), d->exposed ? QRect(QPoint(), geometry().size()) : QRect());
502 }
469 }503 }
470}504}
471505
=== modified file 'src/ubuntumirclient/window.h'
--- src/ubuntumirclient/window.h 2015-09-29 18:10:51 +0000
+++ src/ubuntumirclient/window.h 2015-11-06 09:06:33 +0000
@@ -40,12 +40,14 @@
40 void setGeometry(const QRect&) override;40 void setGeometry(const QRect&) override;
41 void setWindowState(Qt::WindowState state) override;41 void setWindowState(Qt::WindowState state) override;
42 void setVisible(bool visible) override;42 void setVisible(bool visible) override;
43 bool isExposed() const override;
43 void setWindowTitle(const QString &title) override;44 void setWindowTitle(const QString &title) override;
4445
45 // New methods.46 // New methods.
46 void* eglSurface() const;47 void* eglSurface() const;
47 void handleSurfaceResize(int width, int height);48 void handleSurfaceResize(int width, int height);
48 void handleSurfaceFocusChange(bool focused);49 void handleSurfaceFocusChange(bool focused);
50 void handleSurfaceExposeChange(bool visible);
49 void onBuffersSwapped_threadSafe(int newBufferWidth, int newBufferHeight);51 void onBuffersSwapped_threadSafe(int newBufferWidth, int newBufferHeight);
5052
51 UbuntuWindowPrivate* priv() { return d; }53 UbuntuWindowPrivate* priv() { return d; }

Subscribers

People subscribed via source and target branches