Propagate screen orientation changes through wayland
[profile/ivi/qtwayland.git] / src / qt-compositor / windowmanagerprotocol / waylandwindowmanagerintegration.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the Qt Compositor.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file.  Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23 **
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef WAYLANDWINDOWMANAGERINTEGRATION_H
43 #define WAYLANDWINDOWMANAGERINTEGRATION_H
44
45 #include <qwindowdefs.h>
46 #include <stdint.h>
47 #include "wayland_wrapper/wldisplay.h"
48
49 #include <QObject>
50 #include <QMap>
51
52
53 struct wl_client;
54
55 class WindowManagerObject;
56 class WaylandManagedClient;
57
58 class WindowManagerServerIntegration : public QObject
59 {
60     Q_OBJECT
61 public:
62     WindowManagerServerIntegration(QObject *parent = 0);
63     static WindowManagerServerIntegration *instance();
64     void initialize(Wayland::Display *waylandDisplay);
65     void removeClient(wl_client *client);
66
67     WaylandManagedClient *managedClient(wl_client *client) const;
68
69     void changeScreenVisibility(wl_client *client, int visible);
70     void setScreenOrientation(wl_client *client, qint32 orientationInDegrees);
71     void updateOrientation(wl_client *client);
72
73 private:
74     void mapClientToProcess(wl_client *client, uint32_t processId);
75     void authenticateWithToken(wl_client *client, const char *token);
76
77 private:
78     QMap<wl_client*, WaylandManagedClient*> m_managedClients;
79     static WindowManagerServerIntegration *m_instance;
80
81     WindowManagerObject *m_windowManagerObject;
82     qint32 m_orientationInDegrees;
83
84     friend class WindowManagerObject;
85 };
86
87 class WaylandManagedClient
88 {
89 public:
90     WaylandManagedClient();
91     qint64 processId() const;
92     QByteArray authenticationToken() const;
93     bool isVisibleOnScreen() const { return m_isVisibleOnScreen; }
94     qint32 orientation() const;
95
96 private:
97     qint64 m_processId;
98     QByteArray m_authenticationToken;
99     bool m_isVisibleOnScreen;
100
101     friend class WindowManagerServerIntegration;
102 };
103
104 #endif // WAYLANDWINDOWMANAGERINTEGRATION_H