on xenial help sign in
Work around (very likely) Qt bug
commit2c54cbdb033c25067682928e00707b5bc642466d authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateFri 16 Oct 2015, 18:56 (11 years ago) parent7de3ac1
2 files changed+27
src/ShellView.cpp+23 src/ShellView.h+4
src/ShellView.cpp+23
@@ -18,6 +18,7 @@
1818
1919// Qt
2020#include <QQmlContext>
21+#include <QQuickItem>
2122
2223// local
2324#include <paths.h>
@@ -33,4 +34,26 @@ ShellView::ShellView(QQmlEngine *engine, QObject *qmlArgs)
3334
3435 QUrl source(::qmlDirectory() + "/OrientedShell.qml");
3536 setSource(source);
37+
38+ connect(this, &QWindow::widthChanged, this, &ShellView::onWidthChanged);
39+ connect(this, &QWindow::heightChanged, this, &ShellView::onHeightChanged);
40+}
41+
42+void ShellView::onWidthChanged(int w)
43+{
44+ // For good measure in case SizeRootObjectToView doesn't fulfill its promise.
45+ //
46+ // There's at least one situation that's know to leave the root object with an outdated size.
47+ // (really looks like Qt bug)
48+ // Happens when starting unity8 with an external monitor already connected.
49+ // The QResizeEvent we get still has the size of the first screen and since the resize move is triggered
50+ // from the resize event handler, the root item doesn't get resized.
51+ // TODO: Confirm the Qt bug and submit a patch upstream
52+ rootObject()->setWidth(w);
53+}
54+
55+void ShellView::onHeightChanged(int h)
56+{
57+ // See comment in ShellView::onWidthChanged()
58+ rootObject()->setHeight(h);
3659}
src/ShellView.h+4
@@ -25,6 +25,10 @@ class ShellView : public QQuickView
2525
2626public:
2727 ShellView(QQmlEngine *engine, QObject *qmlArgs);
28+
29+private Q_SLOTS:
30+ void onWidthChanged(int);
31+ void onHeightChanged(int);
2832};
2933
3034#endif // UNITY_SHELL_VIEW_H