~ci-train-bot/qtubuntu/qtubuntu-ubuntu-xenial-landing-005

« back to all changes in this revision

Viewing changes to src/ubuntumirclient/window.cpp

  • Committer: CI Train Bot
  • Author(s): Nick Dedekind
  • Date: 2015-11-05 16:56:40 UTC
  • mfrom: (280.2.6 qtubuntu)
  • Revision ID: ci-train-bot@canonical.com-20151105165640-fr65a7y3x5yhbio2
Support server->client visibility change to stop rendering (lp:#1475678) Fixes: #1475678
Approved by: PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
    QSize bufferSize;
100
100
    QMutex mutex;
101
101
    QSharedPointer<UbuntuClipboard> clipboard;
 
102
    bool exposed;
102
103
    int resizeCatchUpAttempts;
 
104
    bool exposeCatchUp;
103
105
#if !defined(QT_NO_DEBUG)
104
106
    int frameNumber;
105
107
#endif
136
138
    d->connection = connection;
137
139
    d->clipboard = clipboard;
138
140
    d->resizeCatchUpAttempts = 0;
 
141
    d->exposed = true;
 
142
    d->exposeCatchUp = false;
139
143
 
140
144
    static int id = 1;
141
145
    d->id = id++;
283
287
    // Create platform window
284
288
    mir_wait_for(mir_surface_create(spec, surfaceCreateCallback, this));
285
289
    mir_surface_spec_release(spec);
 
290
    d->exposeCatchUp = mir_surface_get_visibility(d->surface) == mir_surface_visibility_occluded;
286
291
 
287
292
    DASSERT(d->surface != NULL);
288
293
    d->createEGLSurface((EGLNativeWindowType)mir_buffer_stream_get_egl_native_window(mir_surface_get_buffer_stream(d->surface)));
339
344
        // swap more than once to get a buffer with the new size!
340
345
        d->resizeCatchUpAttempts = 2;
341
346
 
342
 
        QWindowSystemInterface::handleExposeEvent(window(), geometry());
 
347
        QWindowSystemInterface::handleExposeEvent(window(), d->exposed ? QRect(QPoint(), geometry().size()) : QRect());
343
348
        QWindowSystemInterface::flushWindowSystemEvents();
344
349
    }
345
350
}
362
367
    QWindowSystemInterface::handleWindowActivated(activatedWindow, Qt::ActiveWindowFocusReason);
363
368
}
364
369
 
 
370
void 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
 
365
383
void UbuntuWindow::setWindowState(Qt::WindowState state)
366
384
{
367
385
    QMutexLocker(&d->mutex);
399
417
 
400
418
    if (visible) {
401
419
        mir_wait_for(mir_surface_set_state(d->surface, qtWindowStateToMirSurfaceState(d->state)));
402
 
 
403
 
        QWindowSystemInterface::handleExposeEvent(window(), QRect());
404
 
        QWindowSystemInterface::flushWindowSystemEvents();
405
420
    } else {
406
421
        // TODO: Use the new mir_surface_state_hidden state instead of mir_surface_state_minimized.
407
422
        //       Will have to change qtmir and unity8 for that.
408
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
 
 
430
bool UbuntuWindow::isExposed() const
 
431
{
 
432
    return d->exposed && window()->isVisible();
410
433
}
411
434
 
412
435
void UbuntuWindow::setWindowTitle(const QString &title)
437
460
    ++d->frameNumber;
438
461
#endif
439
462
 
 
463
    bool exposureChanged = false;
 
464
    if (d->exposeCatchUp) {
 
465
        d->exposeCatchUp = false;
 
466
        d->exposed = false;
 
467
        exposureChanged = true;
 
468
    }
 
469
 
440
470
    if (sizeKnown && (d->bufferSize.width() != newBufferWidth ||
441
471
                d->bufferSize.height() != newBufferHeight)) {
442
472
        d->resizeCatchUpAttempts = 0;
462
492
        DLOG("UbuntuWindow::onBuffersSwapped_threadSafe [%d] - buffer size (%d,%d). Redrawing to catch up a resized buffer."
463
493
               " resizeCatchUpAttempts=%d",
464
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
496
    } else {
467
497
        DLOG("UbuntuWindow::onBuffersSwapped_threadSafe [%d] - buffer size (%d,%d). resizeCatchUpAttempts=%d",
468
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
}