check ivi-layermanagement-api availability
[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 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
28 extern "C" {
29 #include <ilm/ilm_control.h>
30 }
31 #endif
32
33 class WindowManager : public QObject
34 {
35     Q_OBJECT
36
37 public:
38     explicit WindowManager(QObject *parent = 0);
39     ~WindowManager();
40
41     void start();
42 private:
43     WindowmanagerAdaptor *mp_windowManagerAdaptor;
44     QList<Layout> m_layouts;
45     QList<int> m_surfaces;
46     QMap<int, unsigned int> *mp_layoutAreaToSurfaceIdAssignment;
47
48     int m_currentLayout;
49
50     void dumpScene();
51
52 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
53     void createNewLayer(int layerId);
54     void addSurfaceToLayer(int surfaceId, int layerId);
55 #endif
56     void updateScreen();
57
58
59 public:
60     static void* myThis;
61
62 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
63     // for general notifications
64     void notificationFunc_non_static(ilmObjectType object,
65                                         t_ilm_uint id,
66                                         t_ilm_bool created);
67     static void notificationFunc_static(ilmObjectType object,
68                                         t_ilm_uint id,
69                                         t_ilm_bool created,
70                                         void* user_data);
71
72
73     // for surface notifications
74     void surfaceCallbackFunction_non_static(t_ilm_surface surface,
75                                         struct ilmSurfaceProperties* surfaceProperties,
76                                         t_ilm_notification_mask mask);
77     static void surfaceCallbackFunction_static(t_ilm_surface surface,
78                                         struct ilmSurfaceProperties* surfaceProperties,
79                                         t_ilm_notification_mask mask);
80
81 #endif
82 public slots:
83
84
85 // from windowmanager_adapter.h
86 public: // PROPERTIES
87     Q_PROPERTY(int layoutId READ layoutId)
88     int layoutId() const;
89
90     Q_PROPERTY(QString layoutName READ layoutName)
91     QString layoutName() const;
92
93 public Q_SLOTS: // METHODS
94     int addLayout(int layoutId, const QString &layoutName, const QList<LayoutArea> &surfaceAreas);
95     int deleteLayoutById(int layoutId);
96     QList<Layout> getAllLayouts();
97     QList<int> getAllSurfacesOfProcess(int pid);
98     QList<int> getAvailableLayouts(int numberOfAppSurfaces);
99     QList<int> getAvailableSurfaces();
100     QString getLayoutName(int layoutId);
101     void hideLayer(int layer);
102     int setLayoutById(int layoutId);
103     int setLayoutByName(const QString &layoutName);
104     int setSurfaceToLayoutArea(int surfaceId, int layoutAreaId);
105     void showLayer(int layer);
106
107 Q_SIGNALS: // SIGNALS
108     void surfaceVisibilityChanged(int surfaceId, bool visible);
109 };
110
111
112 #endif // WINDOWMANAGER_HPP