~unity-team/qtubuntu/DPR

« back to all changes in this revision

Viewing changes to src/ubuntumirclient/window.cpp

  • Committer: Gerry Boland
  • Date: 2015-12-16 12:38:43 UTC
  • Revision ID: gerry.boland@canonical.com-20151216123843-3y8iljde6d9c21fg
Fix bug in panel-height hack where fullscreen surface could actually have the hack enabled. Also do little renaming & typo fix

Show diffs side-by-side

added added

removed removed

Lines of Context:
272
272
        mBufferSizePx.rwidth() = parameters.width;
273
273
        mBufferSizePx.rheight() = parameters.height;
274
274
 
275
 
        DLOG("[ubuntumirclient QPA] created surface with size=(%dx%d)px\n", parameters.width, parameters.width);
276
 
        mPlatformWindow->updateWindowGeometry(parameters.width, parameters.height);
 
275
        DLOG("[ubuntumirclient QPA] created surface with size=(%dx%d)px\n", parameters.width, parameters.height);
 
276
        mPlatformWindow->updateWindowSize(parameters.width, parameters.height);
277
277
    }
278
278
 
279
279
    ~UbuntuSurface()
433
433
        mBufferSizePx.rwidth() = eglSurfaceWidthPx;
434
434
        mBufferSizePx.rheight() = eglSurfaceHeightPx;
435
435
 
436
 
        mPlatformWindow->updateWindowGeometry(eglSurfaceWidthPx, eglSurfaceHeightPx);
 
436
        mPlatformWindow->updateWindowSize(eglSurfaceWidthPx, eglSurfaceHeightPx);
437
437
    } else {
438
438
        DLOG("[ubuntumirclient QPA] onSwapBuffersDone(window=%p) [%d] - buffer size=(%dx%d)px",
439
439
               mWindow, sFrameNumber, mBufferSizePx.width(), mBufferSizePx.height());
497
497
{
498
498
    DLOG("[ubuntumirclient QPA] UbuntuWindow(window=%p, screen=%p, input=%p, surf=%p) with title '%s', role: '%d'",
499
499
        w, screen, input, mSurface.get(), qPrintable(window()->title()), roleFor(window()));
 
500
 
 
501
    enablePanelHeightHack(w->windowState() != Qt::WindowFullScreen);
500
502
}
501
503
 
502
504
UbuntuWindow::~UbuntuWindow()
504
506
    DLOG("[ubuntumirclient QPA] ~UbuntuWindow(window=%p)", this);
505
507
}
506
508
 
507
 
void UbuntuWindow::updateWindowGeometry(int widthPx, int heightPx) // after when Mir has resized the surface
 
509
void UbuntuWindow::updateWindowSize(int widthPx, int heightPx) // after when Mir has resized the surface
508
510
{
509
511
    const float dpr = devicePixelRatio();
510
512
    auto geom = geometry();
557
559
    DLOG("[ubuntumirclient QPA] setWindowState(window=%p, %s)", this, qtWindowStateToStr(state));
558
560
    mSurface->setState(state);
559
561
 
560
 
    updatePanelHeightHack(state);
 
562
    enablePanelHeightHack(state != Qt::WindowFullScreen);
561
563
}
562
564
 
563
565
/*
566
568
    window is always on the top-left corner, right below the indicators panel if not
567
569
    in fullscreen.
568
570
 */
569
 
void UbuntuWindow::updatePanelHeightHack(Qt::WindowState state)
 
571
void UbuntuWindow::enablePanelHeightHack(bool enable)
570
572
{
571
 
    if (state == Qt::WindowFullScreen && geometry().y() != 0) {
572
 
        QRect newGeometry = geometry();
 
573
    QRect newGeometry = geometry();
 
574
    if (enable) {
 
575
        newGeometry.setY(panelHeight());
 
576
    } else {
573
577
        newGeometry.setY(0);
574
 
        QWindowSystemInterface::handleGeometryChange(window(), newGeometry);
575
 
    } else if (geometry().y() == 0) {
576
 
        QRect newGeometry = geometry();
577
 
        newGeometry.setY(divideAndRoundUp(panelHeight(), devicePixelRatio()));
 
578
    }
 
579
 
 
580
    if (newGeometry != geometry()) {
 
581
        QPlatformWindow::setGeometry(newGeometry);
578
582
        QWindowSystemInterface::handleGeometryChange(window(), newGeometry);
579
583
    }
580
584
}