~albaguirre/qtubuntu/mir-0.26.1-compat

« back to all changes in this revision

Viewing changes to src/ubuntumirclient/window.cpp

  • Committer: Nick Dedekind
  • Date: 2017-02-08 15:22:51 UTC
  • mfrom: (360.2.6 qtubuntu)
  • Revision ID: nick.dedekind@canonical.com-20170208152251-t0sc5wmyoy6b54h0
merged trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2014-2016 Canonical, Ltd.
 
2
 * Copyright (C) 2014-2017 Canonical, Ltd.
3
3
 *
4
4
 * This program is free software: you can redistribute it and/or modify it under
5
5
 * the terms of the GNU Lesser General Public License version 3, as published by
222
222
    return requiresParent(qtWindowTypeToMirSurfaceType(type));
223
223
}
224
224
 
225
 
bool isMovable(const Qt::WindowType type)
226
 
{
227
 
    auto mirType = qtWindowTypeToMirSurfaceType(type);
228
 
    switch (mirType) {
229
 
    case mir_surface_type_menu:
230
 
    case mir_surface_type_tip:
231
 
        return true;
232
 
    default:
233
 
        return false;
234
 
    }
235
 
}
236
 
 
237
225
Spec makeSurfaceSpec(QWindow *window, MirPixelFormat pixelFormat, UbuntuWindow *parentWindowHandle,
238
226
                     MirConnection *connection)
239
227
{
534
522
 
535
523
void UbuntuSurface::updateGeometry(const QRect &newGeometry)
536
524
{
537
 
    qCDebug(ubuntumirclient,"updateGeometry(window=%p, width=%d, height=%d)", mWindow,
538
 
            newGeometry.width(), newGeometry.height());
539
 
 
540
 
    Spec spec;
541
 
    if (isMovable(mWindow->type())) {
542
 
        spec = Spec{makeSurfaceSpec(mWindow, mPixelFormat, mParentWindowHandle, mConnection)};
 
525
 
 
526
    auto spec = Spec{mir_connection_create_spec_for_changes(mConnection)};
 
527
 
 
528
    mir_surface_spec_set_width(spec.get(), newGeometry.width());
 
529
    mir_surface_spec_set_height(spec.get(), newGeometry.height());
 
530
 
 
531
    MirRectangle mirRect {0,0,0,0};
 
532
 
 
533
    if (mParentWindowHandle) {
 
534
        qCDebug(ubuntumirclient,"updateGeometry(window=%p, x=%d, y=%d, width=%d, height=%d, child)", mWindow,
 
535
                newGeometry.x(), newGeometry.y(), newGeometry.width(), newGeometry.height());
 
536
 
 
537
        mirRect.left = newGeometry.x() - mParentWindowHandle->window()->x();
 
538
        mirRect.top = newGeometry.y() - mParentWindowHandle->window()->y();
 
539
 
543
540
    } else {
544
 
        spec = Spec{mir_connection_create_spec_for_changes(mConnection)};
545
 
        mir_surface_spec_set_width(spec.get(), newGeometry.width());
546
 
        mir_surface_spec_set_height(spec.get(), newGeometry.height());
 
541
        qCDebug(ubuntumirclient,"updateGeometry(window=%p, x=%d, y=%d, width=%d, height=%d, top-level)", mWindow,
 
542
                newGeometry.x(), newGeometry.y(), newGeometry.width(), newGeometry.height());
 
543
 
 
544
        mirRect.left = newGeometry.x();
 
545
        mirRect.top = newGeometry.y();
547
546
    }
 
547
 
 
548
    mir_surface_spec_set_placement(spec.get(), &mirRect,
 
549
            mir_placement_gravity_northwest /* rect_gravity */, mir_placement_gravity_northwest /* surface_gravity */,
 
550
            (MirPlacementHints)0, 0 /* offset_dx */, 0 /* offset_dy */);
 
551
 
548
552
    mir_surface_apply_spec(mMirSurface, spec.get());
549
553
}
550
554
 
712
716
            w, w->screen()->handle(), input, mSurface.get(), qPrintable(window()->title()), roleFor(window()));
713
717
 
714
718
    updatePanelHeightHack(mSurface->state() != mir_surface_state_fullscreen);
 
719
 
 
720
    // queue the windowPropertyChanged signal. If it's emitted directly, the platformWindow will not yet be set for the window.
 
721
    QMetaObject::invokeMethod(mNativeInterface, "windowPropertyChanged", Qt::QueuedConnection,
 
722
                              Q_ARG(QPlatformWindow*, this),
 
723
                              Q_ARG(QString, "persistentSurfaceId"));
715
724
}
716
725
 
717
726
UbuntuWindow::~UbuntuWindow()