summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/client/qwaylandextendedsurface.cpp16
-rw-r--r--src/client/qwaylandextendedsurface_p.h1
-rw-r--r--src/client/qwaylandwindow.cpp24
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.cpp4
-rw-r--r--src/compositor/wayland_wrapper/qwlextendedsurface.cpp26
-rw-r--r--src/compositor/wayland_wrapper/qwlextendedsurface_p.h4
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface.cpp31
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface_p.h4
-rw-r--r--src/extensions/surface-extension.xml3
9 files changed, 58 insertions, 55 deletions
diff --git a/src/client/qwaylandextendedsurface.cpp b/src/client/qwaylandextendedsurface.cpp
index 3155ca6b0..b2b22688c 100644
--- a/src/client/qwaylandextendedsurface.cpp
+++ b/src/client/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/client/qwaylandextendedsurface_p.h b/src/client/qwaylandextendedsurface_p.h
index 030786472..2b559a93b 100644
--- a/src/client/qwaylandextendedsurface_p.h
+++ b/src/client/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/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index e7ff8f300..c61574529 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/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)
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp
index 862393059..15ed6af72 100644
--- a/src/compositor/compositor_api/qwaylandsurface.cpp
+++ b/src/compositor/compositor_api/qwaylandsurface.cpp
@@ -175,9 +175,7 @@ Qt::ScreenOrientations QWaylandSurface::orientationUpdateMask() const
Qt::ScreenOrientation QWaylandSurface::contentOrientation() const
{
Q_D(const QWaylandSurface);
- if (!d->extendedSurface())
- return Qt::PrimaryOrientation;
- return d->extendedSurface()->contentOrientation();
+ return d->contentOrientation();
}
QWaylandSurface::WindowFlags QWaylandSurface::windowFlags() const
diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp b/src/compositor/wayland_wrapper/qwlextendedsurface.cpp
index f8dea98d5..d4dfbaefd 100644
--- a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlextendedsurface.cpp
@@ -64,7 +64,6 @@ ExtendedSurface::ExtendedSurface(struct wl_client *client, uint32_t id, Surface
: QWaylandSurfaceInterface(surface->waylandSurface())
, QtWaylandServer::qt_extended_surface(client,id)
, m_surface(surface)
- , m_contentOrientation(Qt::PrimaryOrientation)
, m_windowFlags(0)
, m_visibility(QWindow::Hidden)
{
@@ -126,36 +125,11 @@ void ExtendedSurface::extended_surface_update_generic_property(Resource *resourc
setWindowProperty(name,variantValue,false);
}
-static Qt::ScreenOrientation screenOrientationFromWaylandOrientation(int32_t orientation)
-{
- switch (orientation) {
- case QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION: return Qt::PortraitOrientation;
- case QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION: return Qt::InvertedPortraitOrientation;
- case QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION: return Qt::LandscapeOrientation;
- case QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION: return Qt::InvertedLandscapeOrientation;
- default: return Qt::PrimaryOrientation;
- }
-}
-
-Qt::ScreenOrientation ExtendedSurface::contentOrientation() const
-{
- return m_contentOrientation;
-}
-
Qt::ScreenOrientations ExtendedSurface::contentOrientationMask() const
{
return m_contentOrientationMask;
}
-void ExtendedSurface::extended_surface_set_content_orientation(Resource *resource, int32_t orientation)
-{
- Q_UNUSED(resource);
- Qt::ScreenOrientation oldOrientation = m_contentOrientation;
- m_contentOrientation = screenOrientationFromWaylandOrientation(orientation);
- if (m_contentOrientation != oldOrientation)
- emit m_surface->waylandSurface()->contentOrientationChanged();
-}
-
void ExtendedSurface::extended_surface_set_content_orientation_mask(Resource *resource, int32_t orientation)
{
Q_UNUSED(resource);
diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface_p.h b/src/compositor/wayland_wrapper/qwlextendedsurface_p.h
index 333f6eeff..6a1e5ffbd 100644
--- a/src/compositor/wayland_wrapper/qwlextendedsurface_p.h
+++ b/src/compositor/wayland_wrapper/qwlextendedsurface_p.h
@@ -89,7 +89,6 @@ public:
void setParent(ExtendedSurface *parent);
QLinkedList<QWaylandSurface *> subSurfaces() const;
- Qt::ScreenOrientation contentOrientation() const;
Qt::ScreenOrientations contentOrientationMask() const;
QWaylandSurface::WindowFlags windowFlags() const { return m_windowFlags; }
@@ -104,7 +103,6 @@ protected:
private:
Surface *m_surface;
- Qt::ScreenOrientation m_contentOrientation;
Qt::ScreenOrientations m_contentOrientationMask;
QWaylandSurface::WindowFlags m_windowFlags;
@@ -117,8 +115,6 @@ private:
const QString &name,
struct wl_array *value) Q_DECL_OVERRIDE;
- void extended_surface_set_content_orientation(Resource *resource,
- int32_t orientation) Q_DECL_OVERRIDE;
void extended_surface_set_content_orientation_mask(Resource *resource,
int32_t orientation) Q_DECL_OVERRIDE;
diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp
index 12a25b0df..af78b3cc7 100644
--- a/src/compositor/wayland_wrapper/qwlsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlsurface.cpp
@@ -51,6 +51,8 @@
#include <QtCore/QDebug>
#include <QTouchEvent>
+#include <QGuiApplication>
+#include <QScreen>
#include <wayland-server.h>
@@ -117,6 +119,7 @@ Surface::Surface(struct wl_client *client, uint32_t id, QWaylandCompositor *comp
, m_transientInactive(false)
, m_isCursorSurface(false)
, m_destroyed(false)
+ , m_contentOrientation(Qt::PrimaryOrientation)
{
m_pending.buffer = 0;
m_pending.newlyAttached = false;
@@ -320,6 +323,11 @@ SurfaceBuffer *Surface::createSurfaceBuffer(struct ::wl_resource *buffer)
return newBuffer;
}
+Qt::ScreenOrientation Surface::contentOrientation() const
+{
+ return m_contentOrientation;
+}
+
void Surface::surface_destroy_resource(Resource *)
{
if (m_extendedSurface) {
@@ -395,6 +403,29 @@ void Surface::surface_commit(Resource *)
emit m_waylandSurface->redraw();
}
+void Surface::surface_set_buffer_transform(Resource *resource, int32_t orientation)
+{
+ Q_UNUSED(resource);
+ QScreen *screen = QGuiApplication::primaryScreen();
+ bool isPortrait = screen->primaryOrientation() == Qt::PortraitOrientation;
+ Qt::ScreenOrientation oldOrientation = m_contentOrientation;
+ switch (orientation) {
+ case WL_OUTPUT_TRANSFORM_90:
+ m_contentOrientation = isPortrait ? Qt::InvertedLandscapeOrientation : Qt::PortraitOrientation;
+ break;
+ case WL_OUTPUT_TRANSFORM_180:
+ m_contentOrientation = isPortrait ? Qt::InvertedPortraitOrientation : Qt::InvertedLandscapeOrientation;
+ break;
+ case WL_OUTPUT_TRANSFORM_270:
+ m_contentOrientation = isPortrait ? Qt::LandscapeOrientation : Qt::InvertedPortraitOrientation;
+ break;
+ default:
+ m_contentOrientation = Qt::PrimaryOrientation;
+ }
+ if (m_contentOrientation != oldOrientation)
+ emit waylandSurface()->contentOrientationChanged();
+}
+
void Surface::frameStarted()
{
foreach (FrameCallback *c, m_frameCallbacks)
diff --git a/src/compositor/wayland_wrapper/qwlsurface_p.h b/src/compositor/wayland_wrapper/qwlsurface_p.h
index 016ed7553..a59a20101 100644
--- a/src/compositor/wayland_wrapper/qwlsurface_p.h
+++ b/src/compositor/wayland_wrapper/qwlsurface_p.h
@@ -130,6 +130,8 @@ public:
inline bool isDestroyed() const { return m_destroyed; }
+ Qt::ScreenOrientation contentOrientation() const;
+
protected:
void surface_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
@@ -145,6 +147,7 @@ protected:
void surface_set_input_region(Resource *resource,
struct wl_resource *region) Q_DECL_OVERRIDE;
void surface_commit(Resource *resource) Q_DECL_OVERRIDE;
+ void surface_set_buffer_transform(Resource *resource, int32_t transform) Q_DECL_OVERRIDE;
Q_DISABLE_COPY(Surface)
@@ -185,6 +188,7 @@ protected:
bool m_transientInactive;
bool m_isCursorSurface;
bool m_destroyed;
+ Qt::ScreenOrientation m_contentOrientation;
void setBackBuffer(SurfaceBuffer *buffer);
SurfaceBuffer *createSurfaceBuffer(struct ::wl_resource *buffer);
diff --git a/src/extensions/surface-extension.xml b/src/extensions/surface-extension.xml
index d43b8d8b2..680a6acca 100644
--- a/src/extensions/surface-extension.xml
+++ b/src/extensions/surface-extension.xml
@@ -71,9 +71,6 @@
<entry name="InvertedLandscapeOrientation" value="8"/>
</enum>
- <request name="set_content_orientation">
- <arg name="orientation" type="int"/>
- </request>
<request name="set_content_orientation_mask">
<arg name="orientation" type="int"/>
</request>