From 825db7e265e4e6b5bbab68aeb3e9673ba78f92e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 6 Jun 2012 12:22:49 +0200 Subject: Implemented orientationUpdateMask support in WaylandSurface. Used to find out whether the client wants orientation updates. Change-Id: Ibefc98df7b346cbfe13cb021c932dab3d6c5d758 Reviewed-by: Laszlo Agocs --- extensions/output-extension.xml | 4 +++ src/compositor/compositor_api/waylandsurface.cpp | 6 ++++ src/compositor/compositor_api/waylandsurface.h | 3 ++ src/compositor/wayland_wrapper/wlcompositor.cpp | 9 ++++++ src/compositor/wayland_wrapper/wlcompositor.h | 2 ++ .../wayland_wrapper/wlextendedoutput.cpp | 34 +++++++++++++++++++++- src/compositor/wayland_wrapper/wlextendedoutput.h | 7 +++++ .../platforms/wayland/qwaylandextendedoutput.cpp | 14 +++++++++ .../platforms/wayland/qwaylandextendedoutput.h | 2 ++ src/plugins/platforms/wayland/qwaylandscreen.cpp | 6 ++++ src/plugins/platforms/wayland/qwaylandscreen.h | 2 ++ 11 files changed, 88 insertions(+), 1 deletion(-) diff --git a/extensions/output-extension.xml b/extensions/output-extension.xml index b07f2b656..e3f3389b6 100644 --- a/extensions/output-extension.xml +++ b/extensions/output-extension.xml @@ -56,5 +56,9 @@ + + + + diff --git a/src/compositor/compositor_api/waylandsurface.cpp b/src/compositor/compositor_api/waylandsurface.cpp index 1b56566e2..08b92919f 100644 --- a/src/compositor/compositor_api/waylandsurface.cpp +++ b/src/compositor/compositor_api/waylandsurface.cpp @@ -154,6 +154,12 @@ void WaylandSurface::setSize(const QSize &size) d->surface->setSize(size); } +Qt::ScreenOrientations WaylandSurface::orientationUpdateMask() const +{ + Q_D(const WaylandSurface); + return d->surface->compositor()->orientationUpdateMaskForClient(static_cast(client())); +} + Qt::ScreenOrientation WaylandSurface::contentOrientation() const { Q_D(const WaylandSurface); diff --git a/src/compositor/compositor_api/waylandsurface.h b/src/compositor/compositor_api/waylandsurface.h index fe38ba3cd..c271e2eb4 100644 --- a/src/compositor/compositor_api/waylandsurface.h +++ b/src/compositor/compositor_api/waylandsurface.h @@ -77,6 +77,7 @@ class Q_COMPOSITOR_EXPORT WaylandSurface : public QObject Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation NOTIFY contentOrientationChanged) Q_PROPERTY(int windowRotation READ windowRotation NOTIFY windowRotationChanged) Q_PROPERTY(QString title READ title NOTIFY titleChanged) + Q_PROPERTY(Qt::ScreenOrientations orientationUpdateMask READ orientationUpdateMask NOTIFY orientationUpdateMaskChanged) Q_ENUMS(WindowFlag) Q_FLAGS(WindowFlag WindowFlags) @@ -111,6 +112,7 @@ public: QSize size() const; void setSize(const QSize &size); + Qt::ScreenOrientations orientationUpdateMask() const; Qt::ScreenOrientation contentOrientation() const; Qt::ScreenOrientation windowOrientation() const; int windowRotation() const; @@ -161,6 +163,7 @@ signals: void windowOrientationChanged(); void contentOrientationChanged(); void windowRotationChanged(); + void orientationUpdateMaskChanged(); void extendedSurfaceReady(); void titleChanged(); diff --git a/src/compositor/wayland_wrapper/wlcompositor.cpp b/src/compositor/wayland_wrapper/wlcompositor.cpp index 2364c0843..61ec91eb8 100644 --- a/src/compositor/wayland_wrapper/wlcompositor.cpp +++ b/src/compositor/wayland_wrapper/wlcompositor.cpp @@ -387,6 +387,15 @@ QList Compositor::clients() const return list; } +Qt::ScreenOrientations Compositor::orientationUpdateMaskForClient(wl_client *client) +{ + Output *output = m_output_global.outputForClient(client); + Q_ASSERT(output); + if (output->extendedOutput()) + return output->extendedOutput()->orientationUpdateMask(); + return 0; +} + void Compositor::setScreenOrientation(Qt::ScreenOrientation orientation) { m_orientation = orientation; diff --git a/src/compositor/wayland_wrapper/wlcompositor.h b/src/compositor/wayland_wrapper/wlcompositor.h index e3acad933..3f0f93614 100644 --- a/src/compositor/wayland_wrapper/wlcompositor.h +++ b/src/compositor/wayland_wrapper/wlcompositor.h @@ -129,6 +129,8 @@ public: void setOutputRefreshRate(int rate); int outputRefreshRate() const; + Qt::ScreenOrientations orientationUpdateMaskForClient(wl_client *client); + void setClientFullScreenHint(bool value); TouchExtensionGlobal *touchExtension() { return m_touchExtension; } diff --git a/src/compositor/wayland_wrapper/wlextendedoutput.cpp b/src/compositor/wayland_wrapper/wlextendedoutput.cpp index c3b2dbc03..d6a6d2380 100644 --- a/src/compositor/wayland_wrapper/wlextendedoutput.cpp +++ b/src/compositor/wayland_wrapper/wlextendedoutput.cpp @@ -41,6 +41,7 @@ #include "wlextendedoutput.h" #include "wlcompositor.h" +#include "wlsurface.h" #include "wloutput.h" namespace Wayland { @@ -75,9 +76,12 @@ ExtendedOutput::ExtendedOutput(struct wl_client *client, uint32_t id, Output *ou : m_output(output) , m_compositor(compositor) { + static const struct wl_extended_output_interface extended_output_interface = { + set_orientation_update_mask + }; Q_ASSERT(m_output->extendedOutput() == 0); m_output->setExtendedOutput(this); - m_extended_output_resource = wl_client_add_object(client,&wl_extended_output_interface,0,id,this); + m_extended_output_resource = wl_client_add_object(client,&wl_extended_output_interface,&extended_output_interface,id,this); m_extended_output_resource->destroy = ExtendedOutput::destroy_resource; sendOutputOrientation(m_compositor->screenOrientation()); @@ -90,6 +94,34 @@ void ExtendedOutput::destroy_resource(wl_resource *resource) free(resource); } +void ExtendedOutput::set_orientation_update_mask(struct wl_client *client, + struct wl_resource *resource, + int32_t orientation_update_mask) +{ + ExtendedOutput *output = static_cast(resource->data); + + Qt::ScreenOrientations mask = 0; + if (orientation_update_mask & WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION) + mask |= Qt::PortraitOrientation; + if (orientation_update_mask & WL_EXTENDED_OUTPUT_ROTATION_LANDSCAPEORIENTATION) + mask |= Qt::LandscapeOrientation; + if (orientation_update_mask & WL_EXTENDED_OUTPUT_ROTATION_INVERTEDPORTRAITORIENTATION) + mask |= Qt::InvertedPortraitOrientation; + if (orientation_update_mask & WL_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION) + mask |= Qt::InvertedLandscapeOrientation; + + Qt::ScreenOrientations oldMask = output->m_orientationUpdateMask; + output->m_orientationUpdateMask = mask; + + if (mask != oldMask) { + QList surfaces = output->m_compositor->surfacesForClient(client); + foreach (Surface *surface, surfaces) { + if (surface->waylandSurface()) + emit surface->waylandSurface()->orientationUpdateMaskChanged(); + } + } +} + void ExtendedOutput::sendOutputOrientation(Qt::ScreenOrientation orientation) { int sendOpperation; diff --git a/src/compositor/wayland_wrapper/wlextendedoutput.h b/src/compositor/wayland_wrapper/wlextendedoutput.h index 2d6bf5101..12d90db5b 100644 --- a/src/compositor/wayland_wrapper/wlextendedoutput.h +++ b/src/compositor/wayland_wrapper/wlextendedoutput.h @@ -74,14 +74,21 @@ class ExtendedOutput public: ExtendedOutput(struct wl_client *client, uint32_t id, Output *output, Compositor *compositor); + Qt::ScreenOrientations orientationUpdateMask() { return m_orientationUpdateMask; } + void sendOutputOrientation(Qt::ScreenOrientation orientation); static void destroy_resource(wl_resource *resource); + static void set_orientation_update_mask(struct wl_client *client, + struct wl_resource *resource, + int32_t orientation_update_mask); + private: struct wl_resource *m_extended_output_resource; Output *m_output; Compositor *m_compositor; + Qt::ScreenOrientations m_orientationUpdateMask; }; } diff --git a/src/plugins/platforms/wayland/qwaylandextendedoutput.cpp b/src/plugins/platforms/wayland/qwaylandextendedoutput.cpp index 96eb0ad4f..c0e011adf 100644 --- a/src/plugins/platforms/wayland/qwaylandextendedoutput.cpp +++ b/src/plugins/platforms/wayland/qwaylandextendedoutput.cpp @@ -86,6 +86,20 @@ Qt::ScreenOrientation QWaylandExtendedOutput::currentOrientation() const return m_orientation; } +void QWaylandExtendedOutput::setOrientationUpdateMask(Qt::ScreenOrientations orientations) +{ + int mask = 0; + if (orientations & Qt::PortraitOrientation) + mask |= WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION; + if (orientations & Qt::LandscapeOrientation) + mask |= WL_EXTENDED_OUTPUT_ROTATION_LANDSCAPEORIENTATION; + if (orientations & Qt::InvertedPortraitOrientation) + mask |= WL_EXTENDED_OUTPUT_ROTATION_INVERTEDPORTRAITORIENTATION; + if (orientations & Qt::InvertedLandscapeOrientation) + mask |= WL_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION; + wl_extended_output_set_orientation_update_mask(m_extended_output, mask); +} + void QWaylandExtendedOutput::set_screen_rotation(void *data, wl_extended_output *wl_extended_output, int32_t rotation) { Q_UNUSED(wl_extended_output); diff --git a/src/plugins/platforms/wayland/qwaylandextendedoutput.h b/src/plugins/platforms/wayland/qwaylandextendedoutput.h index 6ca6220b2..5f39d959f 100644 --- a/src/plugins/platforms/wayland/qwaylandextendedoutput.h +++ b/src/plugins/platforms/wayland/qwaylandextendedoutput.h @@ -62,6 +62,8 @@ public: QWaylandExtendedOutput(QWaylandScreen *screen, struct wl_extended_output *extended_output); Qt::ScreenOrientation currentOrientation() const; + void setOrientationUpdateMask(Qt::ScreenOrientations mask); + private: struct wl_extended_output *m_extended_output; QWaylandScreen *m_screen; diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp index 0373239eb..14b8f4eaf 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.cpp +++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp @@ -89,6 +89,12 @@ QImage::Format QWaylandScreen::format() const return mFormat; } +void QWaylandScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) +{ + if (mExtendedOutput) + mExtendedOutput->setOrientationUpdateMask(mask); +} + Qt::ScreenOrientation QWaylandScreen::orientation() const { if (mExtendedOutput) diff --git a/src/plugins/platforms/wayland/qwaylandscreen.h b/src/plugins/platforms/wayland/qwaylandscreen.h index b76b0ed04..d5d267cd1 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.h +++ b/src/plugins/platforms/wayland/qwaylandscreen.h @@ -60,6 +60,8 @@ public: int depth() const; QImage::Format format() const; + void setOrientationUpdateMask(Qt::ScreenOrientations mask); + Qt::ScreenOrientation orientation() const; qreal refreshRate() const; -- cgit v1.2.3