8fb716d38e9271c5666021fe96b1b83eaa6b6eab
[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_adapter.h"
25
26
27 typedef struct
28 {
29     int pid;
30     QString processName;
31 } SurfaceInfo;
32
33 #ifdef __arm__
34 extern "C" {
35 #include "ilm/ilm_control.h"
36 }
37 #endif
38
39 class WindowManager : public QObject
40 {
41     Q_OBJECT
42
43 public:
44     explicit WindowManager(QObject *parent = 0);
45     QMutex callbackMutex;
46
47     ~WindowManager();
48 private:
49     WindowmanagerAdaptor *mp_windowManagerAdaptor;
50     QMap<int, QList<SimpleRect> > m_layouts;
51     QMap<int, QString> m_layoutNames;
52     int m_currentLayout;
53     void dumpScene();
54
55 #ifdef __arm__
56     void createNewLayer(int layerId);
57     void addSurfaceToLayer(int surfaceId, int layerId);
58
59     QMap<t_ilm_uint, SurfaceInfo> *mp_surfaces;
60     /* one layer per pid is created
61     where the surfaces are added that are created by the process */
62     QList<int> *mp_processLayers;
63 #endif
64
65 public:
66     static void* myThis;
67
68 #ifdef __arm__
69     // for general notifications
70     void notificationFunc_non_static(ilmObjectType object,
71                                         t_ilm_uint id,
72                                         t_ilm_bool created);
73     static void notificationFunc_static(ilmObjectType object,
74                                         t_ilm_uint id,
75                                         t_ilm_bool created,
76                                         void* user_data);
77
78
79     // for surface notifications
80     void surfaceCallbackFunction_non_static(t_ilm_surface surface,
81                                         struct ilmSurfaceProperties* surfaceProperties,
82                                         t_ilm_notification_mask mask);
83     static void surfaceCallbackFunction_static(t_ilm_surface surface,
84                                         struct ilmSurfaceProperties* surfaceProperties,
85                                         t_ilm_notification_mask mask);
86
87 #endif
88 public slots:
89
90
91 // from windowmanager_adapter.h
92 public Q_SLOTS: // METHODS
93     int addLayout(int layoutId, const QString &layoutName, const QList<SimpleRect> &surfaceAreas);
94     QList<int> getAvailableLayouts(int numberOfAppSurfaces);
95     QList<SimplePoint> getAvailableSurfaces();
96     int getLayout();
97     QString getLayoutName(int layoutId);
98     void setLayoutById(int layoutId);
99     void setLayoutByName(const QString &layoutName);
100     void setSurfaceToLayoutArea(int surfaceId, int layoutAreaId);
101
102 };
103
104
105 #endif // WINDOWMANAGER_HPP