Implemented orientationUpdateMask support in WaylandSurface.
authorSamuel Rødal <samuel.rodal@nokia.com>
Wed, 6 Jun 2012 10:22:49 +0000 (12:22 +0200)
committerSamuel Rødal <samuel.rodal@nokia.com>
Wed, 6 Jun 2012 11:53:54 +0000 (13:53 +0200)
Used to find out whether the client wants orientation updates.

Change-Id: Ibefc98df7b346cbfe13cb021c932dab3d6c5d758
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
extensions/output-extension.xml
src/compositor/compositor_api/waylandsurface.cpp
src/compositor/compositor_api/waylandsurface.h
src/compositor/wayland_wrapper/wlcompositor.cpp
src/compositor/wayland_wrapper/wlcompositor.h
src/compositor/wayland_wrapper/wlextendedoutput.cpp
src/compositor/wayland_wrapper/wlextendedoutput.h
src/plugins/platforms/wayland/qwaylandextendedoutput.cpp
src/plugins/platforms/wayland/qwaylandextendedoutput.h
src/plugins/platforms/wayland/qwaylandscreen.cpp
src/plugins/platforms/wayland/qwaylandscreen.h

index b07f2b6..e3f3389 100644 (file)
@@ -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>
index 1b56566..08b9291 100644 (file)
@@ -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);
index fe38ba3..c271e2e 100644 (file)
@@ -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();
 
index 2364c08..61ec91e 100644 (file)
@@ -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;
index e3acad9..3f0f936 100644 (file)
@@ -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; }
index c3b2dbc..d6a6d23 100644 (file)
@@ -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;
index 2d6bf51..12d90db 100644 (file)
@@ -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;
 };
 
 }
index 96eb0ad..c0e011a 100644 (file)
@@ -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);
index 6ca6220..5f39d95 100644 (file)
@@ -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;
index 0373239..14b8f4e 100644 (file)
@@ -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)
index b76b0ed..d5d267c 100644 (file)
@@ -60,6 +60,8 @@ public:
     int depth() const;
     QImage::Format format() const;
 
+    void setOrientationUpdateMask(Qt::ScreenOrientations mask);
+
     Qt::ScreenOrientation orientation() const;
     qreal refreshRate() const;