Reworking layer/surface management
[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 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
27 #include <ilm/ilm_control.h>
28 #endif
29 class WindowManager : public QObject
30 {
31     Q_OBJECT
32
33 public:
34     explicit WindowManager(int displayId, QObject *parent = 0);
35     ~WindowManager();
36
37     void start();
38 private:
39     WindowmanagerAdaptor *mp_windowManagerAdaptor;
40     QList<Layout> m_layouts;
41     QMap<int, unsigned int> *mp_layoutAreaToSurfaceIdAssignment;
42
43     int m_currentLayout;
44
45     int m_screenId;
46     unsigned int m_screenWidth;
47     unsigned int m_screenHeight;
48
49     void dumpScene();
50
51 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
52     t_ilm_layer* m_showLayers;
53     QMap<pid_t, t_ilm_surface> m_appSurfaces;
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 addSurface(const t_ilm_surface surfaceId);
64     t_ilm_layer addSurfaceToAppLayer(pid_t pid, const int surfaceId);
65     void addSurfaceToLayer(const int surfaceId, const int layerId);
66
67     void configureHomeScreenMainSurface(const t_ilm_surface surface, const t_ilm_int width, const t_ilm_int height);
68     void configureAppSurface(const pid_t pid, const t_ilm_surface surface, const t_ilm_int width, const t_ilm_int height);
69 #endif
70     void updateScreen();
71
72
73 public:
74     static void* myThis;
75
76 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
77     // for general notifications
78     void notificationFunc_non_static(ilmObjectType object,
79                                         t_ilm_uint id,
80                                         t_ilm_bool created);
81     static void notificationFunc_static(ilmObjectType object,
82                                         t_ilm_uint id,
83                                         t_ilm_bool created,
84                                         void* user_data);
85
86
87     // for surface notifications
88     void surfaceCallbackFunction_non_static(t_ilm_surface surface,
89                                         struct ilmSurfaceProperties* surfaceProperties,
90                                         t_ilm_notification_mask mask);
91     static void surfaceCallbackFunction_static(t_ilm_surface surface,
92                                         struct ilmSurfaceProperties* surfaceProperties,
93                                         t_ilm_notification_mask mask);
94
95 #endif
96 public slots:
97
98
99 // from windowmanager_adaptor.h
100 public: // PROPERTIES
101     Q_PROPERTY(int layoutId READ layoutId)
102     int layoutId() const;
103
104     Q_PROPERTY(QString layoutName READ layoutName)
105     QString layoutName() const;
106
107 public Q_SLOTS: // METHODS
108     int addLayout(int layoutId, const QString &layoutName, const QList<LayoutArea> &surfaceAreas);
109     int deleteLayoutById(int layoutId);
110     QList<Layout> getAllLayouts();
111   //    QList<int> getAllSurfacesOfProcess(int pid);
112     QList<int> getAvailableLayouts(int numberOfAppSurfaces);
113   //    QList<int> getAvailableSurfaces();
114     QString getLayoutName(int layoutId);
115     void hideLayer(int layer);
116     int setLayoutById(int layoutId);
117     int setLayoutByName(const QString &layoutName);
118     int setSurfaceToLayoutArea(int surfaceId, int layoutAreaId);
119     void showLayer(int layer);
120     void showAppLayer(int pid);
121
122 Q_SIGNALS: // SIGNALS
123     void surfaceVisibilityChanged(int surfaceId, bool visible);
124 };
125
126 #endif // WINDOWMANAGER_HPP