diff --git a/src/3rdparty/wayland/extensions/output-extension.xml b/src/3rdparty/wayland/extensions/output-extension.xml
index 07aa1102cd5..0a7f11a90b6 100644
--- a/src/3rdparty/wayland/extensions/output-extension.xml
+++ b/src/3rdparty/wayland/extensions/output-extension.xml
@@ -46,19 +46,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/3rdparty/wayland/extensions/surface-extension.xml b/src/3rdparty/wayland/extensions/surface-extension.xml
index 31f2862007e..d43b8d8b2ef 100644
--- a/src/3rdparty/wayland/extensions/surface-extension.xml
+++ b/src/3rdparty/wayland/extensions/surface-extension.xml
@@ -74,6 +74,9 @@
+
+
+
diff --git a/src/plugins/platforms/wayland/qwaylandextendedoutput.cpp b/src/plugins/platforms/wayland/qwaylandextendedoutput.cpp
index c79685af43b..c34f5d317e0 100644
--- a/src/plugins/platforms/wayland/qwaylandextendedoutput.cpp
+++ b/src/plugins/platforms/wayland/qwaylandextendedoutput.cpp
@@ -52,49 +52,7 @@ QT_BEGIN_NAMESPACE
QWaylandExtendedOutput::QWaylandExtendedOutput(QWaylandScreen *screen, ::qt_extended_output *extended_output)
: QtWayland::qt_extended_output(extended_output)
, m_screen(screen)
- , m_orientation(m_screen->orientation())
{
}
-Qt::ScreenOrientation QWaylandExtendedOutput::currentOrientation() const
-{
- return m_orientation;
-}
-
-void QWaylandExtendedOutput::setOrientationUpdateMask(Qt::ScreenOrientations orientations)
-{
- int mask = 0;
- if (orientations & Qt::PortraitOrientation)
- mask |= QT_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION;
- if (orientations & Qt::LandscapeOrientation)
- mask |= QT_EXTENDED_OUTPUT_ROTATION_LANDSCAPEORIENTATION;
- if (orientations & Qt::InvertedPortraitOrientation)
- mask |= QT_EXTENDED_OUTPUT_ROTATION_INVERTEDPORTRAITORIENTATION;
- if (orientations & Qt::InvertedLandscapeOrientation)
- mask |= QT_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION;
- set_orientation_update_mask(mask);
-}
-
-void QWaylandExtendedOutput::extended_output_set_screen_rotation(int32_t rotation)
-{
- switch (rotation) {
- case QT_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION:
- m_orientation = Qt::PortraitOrientation;
- break;
- case QT_EXTENDED_OUTPUT_ROTATION_LANDSCAPEORIENTATION:
- m_orientation = Qt::LandscapeOrientation;
- break;
- case QT_EXTENDED_OUTPUT_ROTATION_INVERTEDPORTRAITORIENTATION:
- m_orientation = Qt::InvertedPortraitOrientation;
- break;
- case QT_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION:
- m_orientation = Qt::InvertedLandscapeOrientation;
- break;
- default:
- m_orientation = Qt::PortraitOrientation;
- break;
- }
- QWindowSystemInterface::handleScreenOrientationChange(m_screen->screen(), m_orientation);
-}
-
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/qwaylandextendedoutput_p.h b/src/plugins/platforms/wayland/qwaylandextendedoutput_p.h
index 4295412ec19..71bd3fce295 100644
--- a/src/plugins/platforms/wayland/qwaylandextendedoutput_p.h
+++ b/src/plugins/platforms/wayland/qwaylandextendedoutput_p.h
@@ -56,14 +56,9 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandExtendedOutput : public QtWayland::qt_exte
public:
QWaylandExtendedOutput(QWaylandScreen *screen, struct ::qt_extended_output *extended_output);
- Qt::ScreenOrientation currentOrientation() const;
- void setOrientationUpdateMask(Qt::ScreenOrientations mask);
-
private:
- void extended_output_set_screen_rotation(int32_t rotation) Q_DECL_OVERRIDE;
QWaylandScreen *m_screen;
- Qt::ScreenOrientation m_orientation;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/qwaylandextendedsurface.cpp b/src/plugins/platforms/wayland/qwaylandextendedsurface.cpp
index fe280416232..3155ca6b0d7 100644
--- a/src/plugins/platforms/wayland/qwaylandextendedsurface.cpp
+++ b/src/plugins/platforms/wayland/qwaylandextendedsurface.cpp
@@ -94,6 +94,22 @@ void QWaylandExtendedSurface::setContentOrientation(Qt::ScreenOrientation orient
set_content_orientation(waylandRotationFromScreenOrientation(orientation));
}
+void QWaylandExtendedSurface::setContentOrientationMask(Qt::ScreenOrientations mask)
+{
+ int32_t wlmask = 0;
+ if (mask & Qt::PrimaryOrientation)
+ wlmask |= QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION;
+ if (mask & Qt::PortraitOrientation)
+ wlmask |= QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION;
+ if (mask & Qt::LandscapeOrientation)
+ wlmask |= QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION;
+ if (mask & Qt::InvertedPortraitOrientation)
+ wlmask |= QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION;
+ if (mask & Qt::InvertedLandscapeOrientation)
+ wlmask |= QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION;
+ set_content_orientation_mask(wlmask);
+}
+
QVariantMap QWaylandExtendedSurface::properties() const
{
return m_properties;
diff --git a/src/plugins/platforms/wayland/qwaylandextendedsurface_p.h b/src/plugins/platforms/wayland/qwaylandextendedsurface_p.h
index 00b961d3816..030786472ef 100644
--- a/src/plugins/platforms/wayland/qwaylandextendedsurface_p.h
+++ b/src/plugins/platforms/wayland/qwaylandextendedsurface_p.h
@@ -62,6 +62,7 @@ public:
~QWaylandExtendedSurface();
void setContentOrientation(Qt::ScreenOrientation orientation);
+ void setContentOrientationMask(Qt::ScreenOrientations mask);
void updateGenericProperty(const QString &name, const QVariant &value);
diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp
index 416b320aa6a..cd709f8a835 100644
--- a/src/plugins/platforms/wayland/qwaylandscreen.cpp
+++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp
@@ -44,8 +44,12 @@
#include "qwaylanddisplay_p.h"
#include "qwaylandcursor_p.h"
#include "qwaylandextendedoutput_p.h"
+#include "qwaylandwindow_p.h"
+
+#include
#include
+#include
QT_BEGIN_NAMESPACE
@@ -57,6 +61,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, uint32_t id)
, mRefreshRate(60000)
, mFormat(QImage::Format_ARGB32_Premultiplied)
, mOutputName(QStringLiteral("Screen%1").arg(id))
+ , m_orientation(Qt::PrimaryOrientation)
, mWaylandCursor(new QWaylandCursor(this))
{
// handle case of output extension global being sent after outputs
@@ -99,15 +104,16 @@ QDpi QWaylandScreen::logicalDpi() const
void QWaylandScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask)
{
- if (mExtendedOutput)
- mExtendedOutput->setOrientationUpdateMask(mask);
+ foreach (QWindow *window, QGuiApplication::allWindows()) {
+ QWaylandWindow *w = static_cast(window->handle());
+ if (w && w->screen() == this)
+ w->setOrientationMask(mask);
+ }
}
Qt::ScreenOrientation QWaylandScreen::orientation() const
{
- if (mExtendedOutput)
- return mExtendedOutput->currentOrientation();
- return QPlatformScreen::orientation();
+ return m_orientation;
}
qreal QWaylandScreen::refreshRate() const
@@ -166,7 +172,30 @@ void QWaylandScreen::output_geometry(int32_t x, int32_t y,
{
Q_UNUSED(subpixel);
Q_UNUSED(make);
- Q_UNUSED(transform);
+
+ bool isPortrait = screen() && screen()->primaryOrientation() == Qt::PortraitOrientation;
+ switch (transform) {
+ case WL_OUTPUT_TRANSFORM_NORMAL:
+ m_orientation = isPortrait ? Qt::PortraitOrientation : Qt::LandscapeOrientation;
+ break;
+ case WL_OUTPUT_TRANSFORM_90:
+ m_orientation = isPortrait ? Qt::InvertedLandscapeOrientation : Qt::PortraitOrientation;
+ break;
+ case WL_OUTPUT_TRANSFORM_180:
+ m_orientation = isPortrait ? Qt::InvertedPortraitOrientation : Qt::InvertedLandscapeOrientation;
+ break;
+ case WL_OUTPUT_TRANSFORM_270:
+ m_orientation = isPortrait ? Qt::LandscapeOrientation : Qt::InvertedPortraitOrientation;
+ break;
+ // Ignore these ones, at least for now
+ case WL_OUTPUT_TRANSFORM_FLIPPED:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_90:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_180:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+ break;
+ }
+
+ QWindowSystemInterface::handleScreenOrientationChange(screen(), m_orientation);
if (!model.isEmpty())
mOutputName = model;
diff --git a/src/plugins/platforms/wayland/qwaylandscreen_p.h b/src/plugins/platforms/wayland/qwaylandscreen_p.h
index 42408acf468..5d06227a5d3 100644
--- a/src/plugins/platforms/wayland/qwaylandscreen_p.h
+++ b/src/plugins/platforms/wayland/qwaylandscreen_p.h
@@ -101,6 +101,7 @@ private:
QImage::Format mFormat;
QSize mPhysicalSize;
QString mOutputName;
+ Qt::ScreenOrientation m_orientation;
QWaylandCursor *mWaylandCursor;
};
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp
index d04e76b503d..e7ff8f30049 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow.cpp
+++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp
@@ -130,6 +130,7 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
mShellSurface->setTopLevel();
}
+ setOrientationMask(window->screen()->orientationUpdateMask());
setWindowFlags(window->flags());
setGeometry_helper(window->geometry());
setWindowStateInternal(window->windowState());
@@ -438,6 +439,12 @@ void QWaylandWindow::handleContentOrientationChange(Qt::ScreenOrientation orient
mExtendedWindow->setContentOrientation(orientation);
}
+void QWaylandWindow::setOrientationMask(Qt::ScreenOrientations mask)
+{
+ if (mExtendedWindow)
+ mExtendedWindow->setContentOrientationMask(mask);
+}
+
void QWaylandWindow::setWindowState(Qt::WindowState state)
{
if (setWindowStateInternal(state))
diff --git a/src/plugins/platforms/wayland/qwaylandwindow_p.h b/src/plugins/platforms/wayland/qwaylandwindow_p.h
index dbf76d11f32..2ca47d59070 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow_p.h
+++ b/src/plugins/platforms/wayland/qwaylandwindow_p.h
@@ -128,8 +128,10 @@ public:
QWaylandShellSurface *shellSurface() const;
QWaylandExtendedSurface *extendedWindow() const;
QWaylandSubSurface *subSurfaceWindow() const;
+ QWaylandScreen *screen() const { return mScreen; }
void handleContentOrientationChange(Qt::ScreenOrientation orientation);
+ void setOrientationMask(Qt::ScreenOrientations mask);
void setWindowState(Qt::WindowState state);
void setWindowFlags(Qt::WindowFlags flags);