This repository was archived by the owner on Oct 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathlayercontroller.h
More file actions
115 lines (84 loc) · 3.05 KB
/
layercontroller.h
File metadata and controls
115 lines (84 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#ifndef LAYERCONTROLLER_H
#define LAYERCONTROLLER_H
#include <list>
#include <string>
#include <vector>
#include <QObject>
#include <appmanager.h>
#include <QMap>
//TODO Move AppManager and Layer Controller to HMI Controller DBUS service
class LayerController : public QObject
{
Q_OBJECT
public:
LayerController(AppManager& appManager);
virtual ~LayerController();
std::string currentAppID() const;
bool raiseApp(const std::string& appID);
void setLauncherPid(unsigned int pid);
void setBackgroundSurfaceId(unsigned int backgroundId);
void setAppArea(int x, int y, int width, int height);
void stackLauncherOnTop(bool onTop);
void addAppProcess(const AppManager::AppInfo app, const pid_t pid);
signals: // These may map to DBUS in the future
void applicationReady(const std::string& appID);
void applicationClosed(const std::string& appID);
void currentAppIDChanged(const std::string& appID);
/**
* @brief backgroundLoaded called when the HMI background is fully loaded
*
* This means that there it is possible to execute applications.
*/
void backgroundLoaded();
protected:
void setCurrentAppID(const std::string& appID);
void raiseLayer(unsigned int layerId);
bool initIlm();
bool cleanupIlm();
bool initScreen();
void resizeAppSurfaces();
bool resizeFullScreenSurface(unsigned int surfaceId);
bool resizeAppSurface(unsigned int surfaceId);
void setSurfaceVisible(unsigned int surfaceId);
void setLayerVisible(unsigned int layerId);
bool createLayer(unsigned int &layerId);
bool destroyLayer(unsigned int layerId);
void focusOnLayer(unsigned int layerId);
void addSurface(unsigned int surfaceId);
void removeSurface(unsigned int surfaceId);
void addBackgroundSurface(unsigned int surfaceId);
protected slots:
void surfaceCallback_onGuiThread(unsigned int surfaceId, bool created);
void surfaceConfiguredCallback_onGuiThread(unsigned int surfaceId, unsigned int pid);
private:
struct ProcessInfo{
ProcessInfo() : processId(0) {}
bool operator == (const ProcessInfo& other) { return processId == other.processId; } //PID is unique enough
std::string appID;
pid_t processId;
pid_t graphicProcessId;
std::vector<unsigned int> surfaceList;
};
ProcessInfo* processInfoFromPid(pid_t pid);
ProcessInfo* processInfoFromSurfaceId(pid_t surfaceId);
// TODO only necessary because systemd reports the user unit
// for user slice services rather than the actual service path
std::string appIDFromPid(pid_t pid);
private:
AppManager& m_appManager;
QMap<pid_t, ProcessInfo> m_processMap;
unsigned int m_screenId;
int m_screenWidth;
int m_screenHeight;
int m_appX;
int m_appY;
int m_appWidth;
int m_appHeight;
unsigned int m_launcherPid;
unsigned int m_backgroundSurfaceId;
std::string m_currentAppID;
unsigned int m_currentLayer;
bool m_launcherOnTop;
bool m_backgroundLoaded = false;
};
#endif /* LAYERCONTROLLER_H */