diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2012-06-06 12:22:49 +0200 |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2012-06-06 13:53:54 +0200 |
commit | 825db7e265e4e6b5bbab68aeb3e9673ba78f92e5 (patch) | |
tree | 4ad3118f50488d0822143e1c2d596e9f5a0b74c7 | |
parent | 077067bc8f68a3146430b941ea0f0daa61781f91 (diff) | |
download | qtwayland-825db7e265e4e6b5bbab68aeb3e9673ba78f92e5.tar.gz |
Implemented orientationUpdateMask support in WaylandSurface.
Used to find out whether the client wants orientation updates.
Change-Id: Ibefc98df7b346cbfe13cb021c932dab3d6c5d758
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
-rw-r--r-- | extensions/output-extension.xml | 4 | ||||
-rw-r--r-- | src/compositor/compositor_api/waylandsurface.cpp | 6 | ||||
-rw-r--r-- | src/compositor/compositor_api/waylandsurface.h | 3 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlcompositor.cpp | 9 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlcompositor.h | 2 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlextendedoutput.cpp | 34 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlextendedoutput.h | 7 | ||||
-rw-r--r-- | src/plugins/platforms/wayland/qwaylandextendedoutput.cpp | 14 | ||||
-rw-r--r-- | src/plugins/platforms/wayland/qwaylandextendedoutput.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/wayland/qwaylandscreen.cpp | 6 | ||||
-rw-r--r-- | src/plugins/platforms/wayland/qwaylandscreen.h | 2 |
11 files changed, 88 insertions, 1 deletions
diff --git a/extensions/output-extension.xml b/extensions/output-extension.xml index b07f2b65..e3f3389b 100644 --- a/extensions/output-extension.xml +++ b/extensions/output-extension.xml @@ -56,5 +56,9 @@ <event name="set_screen_rotation"> <arg name="rotation" type="int"/> </event> + + <request name="set_orientation_update_mask"> + <arg name="orientation" type="int"/> + </request> </interface> </protocol> diff --git a/src/compositor/compositor_api/waylandsurface.cpp b/src/compositor/compositor_api/waylandsurface.cpp index 1b56566e..08b92919 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<wl_client *>(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 fe38ba3c..c271e2eb 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 2364c084..61ec91eb 100644 --- a/src/compositor/wayland_wrapper/wlcompositor.cpp +++ b/src/compositor/wayland_wrapper/wlcompositor.cpp @@ -387,6 +387,15 @@ QList<struct wl_client *> 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 e3acad93..3f0f9361 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 c3b2dbc0..d6a6d238 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<ExtendedOutput *>(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<Surface*> 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 2d6bf510..12d90db5 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 96eb0ad4..c0e011ad 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 6ca6220b..5f39d959 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 0373239e..14b8f4ea 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 b76b0ed0..d5d267cd 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; |