d2c9c9b83ea121f516aefc3e21642dc7abf04877
[staging/HomeScreen.git] / WindowManager / src / windowmanager.hpp
1 /*
2  * Copyright (C) 2016 Mentor Graphics Development (Deutschland) GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef WINDOWMANAGER_HPP
18 #define WINDOWMANAGER_HPP
19
20 #include <QObject>
21 #include <QList>
22 #include <QMap>
23
24 #include "windowmanager_adaptor.h"
25
26
27 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
28 #include <ilm/ilm_control.h>
29 #endif
30 class WindowManager : public QObject
31 {
32     Q_OBJECT
33
34 public:
35     explicit WindowManager(int displayId, QObject *parent = 0);
36     ~WindowManager();
37
38     void start();
39 private:
40     WindowmanagerAdaptor *mp_windowManagerAdaptor;
41     QList<Layout> m_layouts;
42     QMap<int, unsigned int> *mp_layoutAreaToSurfaceIdAssignment;
43
44     int m_currentLayout;
45
46     int m_screenId;
47     unsigned int m_screenWidth;
48     unsigned int m_screenHeight;
49
50     void dumpScene();
51
52 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
53     t_ilm_layer* m_showLayers;
54     QMap<pid_t, t_ilm_layer> m_appLayers;
55     int getLayerRenderOrder(t_ilm_layer* id_array);
56
57     void createNewLayer(const int layerId);
58
59     t_ilm_layer getAppLayerID(const pid_t pid);
60
61     pid_t m_pending_to_show;
62
63     void addSurfaceToAppLayer(const int surfaceID);
64     void addSurfaceToLayer(const int surfaceId, const int layerId);
65 #endif
66     void updateScreen();
67
68
69 public:
70     static void* myThis;
71
72 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
73     // for general notifications
74     void notificationFunc_non_static(ilmObjectType object,
75                                         t_ilm_uint id,
76                                         t_ilm_bool created);
77     static void notificationFunc_static(ilmObjectType object,
78                                         t_ilm_uint id,
79                                         t_ilm_bool created,
80                                         void* user_data);
81
82
83     // for surface notifications
84     void surfaceCallbackFunction_non_static(t_ilm_surface surface,
85                                         struct ilmSurfaceProperties* surfaceProperties,
86                                         t_ilm_notification_mask mask);
87     static void surfaceCallbackFunction_static(t_ilm_surface surface,
88                                         struct ilmSurfaceProperties* surfaceProperties,
89                                         t_ilm_notification_mask mask);
90
91 #endif
92 public slots:
93
94
95 // from windowmanager_adaptor.h
96 public: // PROPERTIES
97     Q_PROPERTY(int layoutId READ layoutId)
98     int layoutId() const;
99
100     Q_PROPERTY(QString layoutName READ layoutName)
101     QString layoutName() const;
102
103 public Q_SLOTS: // METHODS
104     int addLayout(int layoutId, const QString &layoutName, const QList<LayoutArea> &surfaceAreas);
105     int deleteLayoutById(int layoutId);
106     QList<Layout> getAllLayouts();
107   //    QList<int> getAllSurfacesOfProcess(int pid);
108     QList<int> getAvailableLayouts(int numberOfAppSurfaces);
109   //    QList<int> getAvailableSurfaces();
110     QString getLayoutName(int layoutId);
111     void hideLayer(int layer);
112     int setLayoutById(int layoutId);
113     int setLayoutByName(const QString &layoutName);
114     int setSurfaceToLayoutArea(int surfaceId, int layoutAreaId);
115     void showLayer(int layer);
116     void showAppLayer(int pid);
117
118 Q_SIGNALS: // SIGNALS
119     void surfaceVisibilityChanged(int surfaceId, bool visible);
120 };
121
122
123 #endif // WINDOWMANAGER_HPP