diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2012-01-25 14:37:22 +0100 |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2012-02-01 15:11:56 +0100 |
commit | de7e097bbb1d29db63d70bfb1e3a03c5253316fd (patch) | |
tree | 0afb04c51d0d94dbc76b11291f8655a5158eeb2a /src/compositor/wayland_wrapper | |
parent | af9010004a410de60ca44005b261361aff004395 (diff) |
Added reporting of window and content orientation to surface extension.
Change-Id: I6e182c048282f5edd30f49be19dcc0f020679b85
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/compositor/wayland_wrapper')
-rw-r--r-- | src/compositor/wayland_wrapper/wlextendedsurface.cpp | 45 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlextendedsurface.h | 14 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlsurface.cpp | 12 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlsurface.h | 3 |
4 files changed, 73 insertions, 1 deletions
diff --git a/src/compositor/wayland_wrapper/wlextendedsurface.cpp b/src/compositor/wayland_wrapper/wlextendedsurface.cpp index 6278381f9..5ee1f93d9 100644 --- a/src/compositor/wayland_wrapper/wlextendedsurface.cpp +++ b/src/compositor/wayland_wrapper/wlextendedsurface.cpp @@ -77,6 +77,8 @@ void SurfaceExtensionGlobal::get_extended_surface(struct wl_client *client, ExtendedSurface::ExtendedSurface(struct wl_client *client, uint32_t id, Surface *surface) : m_surface(surface) + , m_windowOrientation(Qt::PrimaryOrientation) + , m_contentOrientation(Qt::PrimaryOrientation) { Q_ASSERT(surface->extendedSurface() == 0); surface->setExtendedSurface(this); @@ -124,8 +126,49 @@ void ExtendedSurface::update_generic_property(wl_client *client, wl_resource *ex } +static Qt::ScreenOrientation screenOrientationFromWaylandOrientation(int32_t orientation) +{ + switch (orientation) { + case WL_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION: return Qt::PortraitOrientation; + case WL_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION: return Qt::InvertedPortraitOrientation; + case WL_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION: return Qt::LandscapeOrientation; + case WL_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION: return Qt::InvertedLandscapeOrientation; + default: return Qt::PrimaryOrientation; + } +} + +Qt::ScreenOrientation ExtendedSurface::windowOrientation() const +{ + return m_windowOrientation; +} + +Qt::ScreenOrientation ExtendedSurface::contentOrientation() const +{ + return m_contentOrientation; +} + +void ExtendedSurface::set_window_orientation(struct wl_client *client, + struct wl_resource *extended_surface_resource, + int32_t orientation) +{ + Q_UNUSED(client); + ExtendedSurface *extended_surface = static_cast<ExtendedSurface *>(extended_surface_resource->data); + extended_surface->m_windowOrientation = screenOrientationFromWaylandOrientation(orientation); +} + +void ExtendedSurface::set_content_orientation(struct wl_client *client, + struct wl_resource *extended_surface_resource, + int32_t orientation) +{ + Q_UNUSED(client); + ExtendedSurface *extended_surface = static_cast<ExtendedSurface *>(extended_surface_resource->data); + extended_surface->m_contentOrientation = screenOrientationFromWaylandOrientation(orientation); +} + const struct wl_extended_surface_interface ExtendedSurface::extended_surface_interface = { - ExtendedSurface::update_generic_property + ExtendedSurface::update_generic_property, + ExtendedSurface::set_window_orientation, + ExtendedSurface::set_content_orientation }; } diff --git a/src/compositor/wayland_wrapper/wlextendedsurface.h b/src/compositor/wayland_wrapper/wlextendedsurface.h index 6e1455366..2bc1f6360 100644 --- a/src/compositor/wayland_wrapper/wlextendedsurface.h +++ b/src/compositor/wayland_wrapper/wlextendedsurface.h @@ -87,15 +87,29 @@ public: void setParent(ExtendedSurface *parent); QLinkedList<WaylandSurface *> subSurfaces() const; + Qt::ScreenOrientation windowOrientation() const; + Qt::ScreenOrientation contentOrientation() const; + private: struct wl_resource *m_extended_surface_resource; Surface *m_surface; + Qt::ScreenOrientation m_windowOrientation; + Qt::ScreenOrientation m_contentOrientation; + static void update_generic_property(struct wl_client *client, struct wl_resource *resource, const char *name, struct wl_array *value); + static void set_window_orientation(struct wl_client *client, + struct wl_resource *resource, + int32_t orientation); + + static void set_content_orientation(struct wl_client *client, + struct wl_resource *resource, + int32_t orientation); + static const struct wl_extended_surface_interface extended_surface_interface; }; diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp index b85a54004..107a726c9 100644 --- a/src/compositor/wayland_wrapper/wlsurface.cpp +++ b/src/compositor/wayland_wrapper/wlsurface.cpp @@ -612,6 +612,18 @@ void Surface::setWindowProperty(const QString &name, const QVariant &value, bool } } +Qt::ScreenOrientation Surface::windowOrientation() const +{ + Q_D(const Surface); + return d->extendedSurface ? d->extendedSurface->windowOrientation() : Qt::PrimaryOrientation; +} + +Qt::ScreenOrientation Surface::contentOrientation() const +{ + Q_D(const Surface); + return d->extendedSurface ? d->extendedSurface->contentOrientation() : Qt::PrimaryOrientation; +} + QPoint Surface::lastMousePos() const { Q_D(const Surface); diff --git a/src/compositor/wayland_wrapper/wlsurface.h b/src/compositor/wayland_wrapper/wlsurface.h index 8bb8132dd..b34d7c8cc 100644 --- a/src/compositor/wayland_wrapper/wlsurface.h +++ b/src/compositor/wayland_wrapper/wlsurface.h @@ -114,6 +114,9 @@ public: QVariant windowProperty(const QString &propertyName) const; void setWindowProperty(const QString &name, const QVariant &value, bool writeUpdateToClient = true); + Qt::ScreenOrientation contentOrientation() const; + Qt::ScreenOrientation windowOrientation() const; + QPoint lastMousePos() const; void setExtendedSurface(ExtendedSurface *extendedSurface); |