diff options
author | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2014-06-09 22:52:29 +0300 |
---|---|---|
committer | Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> | 2014-07-31 19:06:41 +0200 |
commit | c18c3bee1e0bc6a570bff703ab5c47ce8cb90c91 (patch) | |
tree | b4e79cdb68b7ecdb8093d98598b6f308db823d10 | |
parent | 00d7933816d37f5e7bb8d61624c4d4ca38bb014f (diff) | |
download | qtwayland-c18c3bee1e0bc6a570bff703ab5c47ce8cb90c91.tar.gz |
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 <gunnar.sletta@jollamobile.com>
-rw-r--r-- | src/client/qwaylandextendedsurface.cpp | 16 | ||||
-rw-r--r-- | src/client/qwaylandextendedsurface_p.h | 1 | ||||
-rw-r--r-- | src/client/qwaylandwindow.cpp | 24 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandsurface.cpp | 4 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/qwlextendedsurface.cpp | 26 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/qwlextendedsurface_p.h | 4 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/qwlsurface.cpp | 31 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/qwlsurface_p.h | 4 | ||||
-rw-r--r-- | src/extensions/surface-extension.xml | 3 |
9 files changed, 58 insertions, 55 deletions
diff --git a/src/client/qwaylandextendedsurface.cpp b/src/client/qwaylandextendedsurface.cpp index 3155ca6b..b2b22688 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 03078647..2b559a93 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 e7ff8f30..c6157452 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 86239305..15ed6af7 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 f8dea98d..d4dfbaef 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 333f6eef..6a1e5ffb 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 12a25b0d..af78b3cc 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 016ed755..a59a2010 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 d43b8d8b..680a6acc 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> |