Propagate screen orientation changes through wayland
authorLasse Holmstedt <lasse.holmstedt@nokia.com>
Wed, 29 Jun 2011 09:50:38 +0000 (11:50 +0200)
committerLasse Holmstedt <lasse.holmstedt@nokia.com>
Mon, 4 Jul 2011 12:07:41 +0000 (14:07 +0200)
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/qt-compositor/compositor_api/waylandcompositor.cpp
src/qt-compositor/compositor_api/waylandcompositor.h
src/qt-compositor/wayland_wrapper/wlcompositor.cpp
src/qt-compositor/wayland_wrapper/wlcompositor.h
src/qt-compositor/wayland_wrapper/wlsurface.cpp
src/qt-compositor/windowmanagerprotocol/wayland-windowmanager-protocol.c
src/qt-compositor/windowmanagerprotocol/wayland-windowmanager-server-protocol.h
src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp
src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h
src/qt-compositor/windowmanagerprotocol/windowmanager.xml

index 8d22857..8a6f761 100644 (file)
@@ -140,3 +140,8 @@ const char *WaylandCompositor::socketName() const
         return 0;
     return m_socket_name.constData();
 }
+
+void WaylandCompositor::setScreenOrientation(qint32 orientationInDegrees)
+{
+    m_compositor->setScreenOrientation(orientationInDegrees);
+}
index 9fb2589..71ef657 100644 (file)
@@ -84,6 +84,8 @@ public:
 
     const char *socketName() const;
 
+    void setScreenOrientation(qint32 orientationInDegrees);
+
 private:
     static void retainedSelectionChanged(QMimeData *mimeData, void *param);
 
index 8f38450..9522001 100644 (file)
@@ -273,6 +273,7 @@ void Compositor::createSurface(struct wl_client *client, int id)
         // if there is no PID, the client does not support the protocol.
         surface->setProcessId(managedClient->processId());
         surface->setAuthenticationToken(managedClient->authenticationToken());
+        m_windowManagerWaylandProtocol->updateOrientation(client);
     }
 
     m_qt_compositor->surfaceCreated(surface->handle());
@@ -440,8 +441,17 @@ QList<struct wl_client *> Compositor::clients() const
     return list;
 }
 
+void Compositor::setScreenOrientation(qint32 orientationInDegrees)
+{
+    QList<struct wl_client*> clientList = clients();
+    for (int i = 0; i < clientList.length(); ++i) {
+        struct wl_client *client = clientList.at(i);
+        m_windowManagerWaylandProtocol->setScreenOrientation(client, orientationInDegrees);
+    }
 }
 
+} // namespace Wayland
+
 wl_input_device * Wayland::Compositor::defaultInputDevice()
 {
     return &m_input;
index 3ab4b30..21a4109 100644 (file)
@@ -105,6 +105,8 @@ public:
 
     QList<struct wl_client *> clients() const;
 
+    void setScreenOrientation(qint32 orientationInDegrees);
+
 signals:
     void clientAdded(wl_client *client);
 
index 49d4101..52d793e 100644 (file)
@@ -397,12 +397,13 @@ void Surface::setInputFocus()
     d->compositor->setInputFocus(this);
 }
 
-}
-
-void Wayland::Surface::sendOnScreenVisibilityChange(bool visible)
+void Surface::sendOnScreenVisibilityChange(bool visible)
 {
 #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
     Q_D(Surface);
     WindowManagerServerIntegration::instance()->changeScreenVisibility(d->client, visible ? 1 : 0);
 #endif
 }
+
+} // namespace Wayland
+
index e759b3a..fcafacd 100644 (file)
@@ -32,6 +32,7 @@ static const struct wl_message wl_windowmanager_requests[] = {
 
 static const struct wl_message wl_windowmanager_events[] = {
        { "client_onscreen_visibility", "i", NULL },
+       { "set_screen_rotation", "i", NULL },
 };
 
 WL_EXPORT const struct wl_interface wl_windowmanager_interface = {
index a0f4e3a..acc94ec 100644 (file)
@@ -48,6 +48,7 @@ struct wl_windowmanager_interface {
 };
 
 #define WL_WINDOWMANAGER_CLIENT_ONSCREEN_VISIBILITY    0
+#define WL_WINDOWMANAGER_SET_SCREEN_ROTATION   1
 
 #ifdef  __cplusplus
 }
index fa6d4b6..93c43e1 100644 (file)
@@ -97,6 +97,7 @@ WindowManagerServerIntegration *WindowManagerServerIntegration::m_instance = 0;
 
 WindowManagerServerIntegration::WindowManagerServerIntegration(QObject *parent)
     : QObject(parent)
+    , m_orientationInDegrees(0)
 {
     m_instance = this;
 }
@@ -137,6 +138,17 @@ void WindowManagerServerIntegration::changeScreenVisibility(wl_client *client, i
                          WL_WINDOWMANAGER_CLIENT_ONSCREEN_VISIBILITY, visible);
 }
 
+void WindowManagerServerIntegration::updateOrientation(wl_client *client)
+{
+    setScreenOrientation(client, m_orientationInDegrees);
+}
+
+void WindowManagerServerIntegration::setScreenOrientation(wl_client *client, qint32 orientationInDegrees)
+{
+    m_orientationInDegrees = orientationInDegrees;
+    wl_client_post_event(client, m_windowManagerObject->base(),
+                         WL_WINDOWMANAGER_SET_SCREEN_ROTATION, orientationInDegrees);
+}
 
 WaylandManagedClient *WindowManagerServerIntegration::managedClient(wl_client *client) const
 {
@@ -155,7 +167,6 @@ WindowManagerServerIntegration *WindowManagerServerIntegration::instance()
 WaylandManagedClient::WaylandManagedClient()
     : m_processId(0)
 {
-
 }
 
 qint64 WaylandManagedClient::processId() const
index 65eb3f3..199c96b 100644 (file)
@@ -67,6 +67,9 @@ public:
     WaylandManagedClient *managedClient(wl_client *client) const;
 
     void changeScreenVisibility(wl_client *client, int visible);
+    void setScreenOrientation(wl_client *client, qint32 orientationInDegrees);
+    void updateOrientation(wl_client *client);
+
 private:
     void mapClientToProcess(wl_client *client, uint32_t processId);
     void authenticateWithToken(wl_client *client, const char *token);
@@ -76,6 +79,7 @@ private:
     static WindowManagerServerIntegration *m_instance;
 
     WindowManagerObject *m_windowManagerObject;
+    qint32 m_orientationInDegrees;
 
     friend class WindowManagerObject;
 };
@@ -87,6 +91,7 @@ public:
     qint64 processId() const;
     QByteArray authenticationToken() const;
     bool isVisibleOnScreen() const { return m_isVisibleOnScreen; }
+    qint32 orientation() const;
 
 private:
     qint64 m_processId;
index 2d76ae0..7356e42 100644 (file)
         <event name="client_onscreen_visibility">
            <arg name="visible" type="int"/>
        </event>
+
+        <!-- Sets screen rotation, typically based on accelerometer/orientation sensor reading data -->
+        <event name="set_screen_rotation">
+            <arg name="rotation" type="int"/>
+        </event>
     </interface>
 </protocol>