ef19f4e65d3e57b8528c1bc5b70e5eed7b9703d5
[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     ~WindowManager();
46
47     void start();
48 private:
49     WindowmanagerAdaptor *mp_windowManagerAdaptor;
50     QMap<int, QList<SimpleRect> > m_layouts;
51     QMap<int, QString> m_layoutNames;
52     QMap<int, bool> m_layoutFullScreen;
53     QMap<int, int> m_layoutFullScreenAssociated;
54     int m_currentLayout;
55     void dumpScene();
56     int m_homeScreenPid;
57
58 #ifdef __arm__
59     void createNewLayer(int layerId);
60     void addSurfaceToLayer(int surfaceId, int layerId);
61     void updateScreen();
62
63
64     QMap<t_ilm_uint, SurfaceInfo> *mp_surfaces;
65     /* one layer per pid is created
66     where the surfaces are added that are created by the process */
67     QList<int> *mp_processLayers;
68 #endif
69
70     QMap<int, unsigned int> *mp_layoutAreaToPidAssignment;
71
72 public:
73     static void* myThis;
74
75 #ifdef __arm__
76     // for general notifications
77     void notificationFunc_non_static(ilmObjectType object,
78                                         t_ilm_uint id,
79                                         t_ilm_bool created);
80     static void notificationFunc_static(ilmObjectType object,
81                                         t_ilm_uint id,
82                                         t_ilm_bool created,
83                                         void* user_data);
84
85
86     // for surface notifications
87     void surfaceCallbackFunction_non_static(t_ilm_surface surface,
88                                         struct ilmSurfaceProperties* surfaceProperties,
89                                         t_ilm_notification_mask mask);
90     static void surfaceCallbackFunction_static(t_ilm_surface surface,
91                                         struct ilmSurfaceProperties* surfaceProperties,
92                                         t_ilm_notification_mask mask);
93
94 #endif
95 public slots:
96
97
98 // from windowmanager_adapter.h
99 public Q_SLOTS: // METHODS
100     int addLayout(int layoutId, const QString &layoutName, bool isFullScreen, int associatedFullScreenLayout, const QList<SimpleRect> &surfaceAreas);
101     int getAssociatedFullScreenLayout(int layoutId);
102     QList<int> getAvailableLayouts(int numberOfAppSurfaces);
103     QList<SimplePoint> getAvailableSurfaces();
104     int getLayout();
105     QString getLayoutName(int layoutId);
106     bool isLayoutFullScreen(int layoutId);
107     void setLayoutById(int layoutId);
108     void setLayoutByName(const QString &layoutName);
109     void setPidToLayoutArea(int pid, int layoutAreaId);
110
111 };
112
113
114 #endif // WINDOWMANAGER_HPP