From 1cb65e556c9a31b6669202a6d382e9ab60e7422e Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Mon, 9 Jun 2014 22:52:29 +0300 Subject: [PATCH] Use wl_surface.set_buffer_transform to signal surface rotation Drop the custom request in the surface extension, and use the wayland core mechanism. Change-Id: I580f56c90bcd3b2c5a6da08d1a033b10790ac330 Reviewed-by: Gunnar Sletta --- .../wayland/extensions/surface-extension.xml | 3 --- .../wayland/qwaylandextendedsurface.cpp | 16 ------------- .../wayland/qwaylandextendedsurface_p.h | 1 - .../platforms/wayland/qwaylandwindow.cpp | 24 +++++++++++++++++-- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/3rdparty/wayland/extensions/surface-extension.xml b/src/3rdparty/wayland/extensions/surface-extension.xml index d43b8d8b2ef..680a6accab6 100644 --- a/src/3rdparty/wayland/extensions/surface-extension.xml +++ b/src/3rdparty/wayland/extensions/surface-extension.xml @@ -71,9 +71,6 @@ - - - diff --git a/src/plugins/platforms/wayland/qwaylandextendedsurface.cpp b/src/plugins/platforms/wayland/qwaylandextendedsurface.cpp index 3155ca6b0d7..b2b22688c19 100644 --- a/src/plugins/platforms/wayland/qwaylandextendedsurface.cpp +++ b/src/plugins/platforms/wayland/qwaylandextendedsurface.cpp @@ -78,22 +78,6 @@ void QWaylandExtendedSurface::updateGenericProperty(const QString &name, const Q nativeInterface->emitWindowPropertyChanged(m_window, name); } -static int32_t waylandRotationFromScreenOrientation(Qt::ScreenOrientation orientation) -{ - switch (orientation) { - case Qt::PortraitOrientation: return QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION; - case Qt::InvertedPortraitOrientation: return QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION; - case Qt::LandscapeOrientation: return QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION; - case Qt::InvertedLandscapeOrientation: return QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION; - default: return QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION; - } -} - -void QWaylandExtendedSurface::setContentOrientation(Qt::ScreenOrientation orientation) -{ - set_content_orientation(waylandRotationFromScreenOrientation(orientation)); -} - void QWaylandExtendedSurface::setContentOrientationMask(Qt::ScreenOrientations mask) { int32_t wlmask = 0; diff --git a/src/plugins/platforms/wayland/qwaylandextendedsurface_p.h b/src/plugins/platforms/wayland/qwaylandextendedsurface_p.h index 030786472ef..2b559a93be2 100644 --- a/src/plugins/platforms/wayland/qwaylandextendedsurface_p.h +++ b/src/plugins/platforms/wayland/qwaylandextendedsurface_p.h @@ -61,7 +61,6 @@ public: QWaylandExtendedSurface(QWaylandWindow *window, struct ::qt_extended_surface *extended_surface); ~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/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index e7ff8f30049..c6157452964 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -435,8 +435,28 @@ QWaylandSubSurface *QWaylandWindow::subSurfaceWindow() const void QWaylandWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation) { - if (mExtendedWindow) - mExtendedWindow->setContentOrientation(orientation); + wl_output_transform transform; + bool isPortrait = window()->screen() && window()->screen()->primaryOrientation() == Qt::PortraitOrientation; + switch (orientation) { + case Qt::PrimaryOrientation: + transform = WL_OUTPUT_TRANSFORM_NORMAL; + break; + case Qt::LandscapeOrientation: + transform = isPortrait ? WL_OUTPUT_TRANSFORM_270 : WL_OUTPUT_TRANSFORM_NORMAL; + break; + case Qt::PortraitOrientation: + transform = isPortrait ? WL_OUTPUT_TRANSFORM_NORMAL : WL_OUTPUT_TRANSFORM_90; + break; + case Qt::InvertedLandscapeOrientation: + transform = isPortrait ? WL_OUTPUT_TRANSFORM_90 : WL_OUTPUT_TRANSFORM_180; + break; + case Qt::InvertedPortraitOrientation: + transform = isPortrait ? WL_OUTPUT_TRANSFORM_180 : WL_OUTPUT_TRANSFORM_270; + break; + } + set_buffer_transform(transform); + // set_buffer_transform is double buffered, we need to commit. + commit(); } void QWaylandWindow::setOrientationMask(Qt::ScreenOrientations mask)