forked from rdkcentral/RDKShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrdkcompositor.h
104 lines (96 loc) · 3.93 KB
/
rdkcompositor.h
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
/**
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
#ifndef RDKSHELL_RDK_COMPOSITOR_H
#define RDKSHELL_RDK_COMPOSITOR_H
#include <string>
#include <thread>
#include <mutex>
#include <mutex>
#include <functional>
#include <unordered_map>
#include "westeros-compositor.h"
#include "inputevent.h"
#include "application.h"
namespace RdkShell
{
class RdkCompositor
{
public:
RdkCompositor();
~RdkCompositor();
bool createDisplay(const std::string& displayName, uint32_t width, uint32_t height);
void draw();
void onKeyPress(uint32_t keycode, uint32_t flags, uint64_t metadata);
void onKeyRelease(uint32_t keycode, uint32_t flags, uint64_t metadata);
void setPosition(int32_t x, int32_t y);
void position(int32_t &x, int32_t &y);
void setSize(uint32_t width, uint32_t height);
void size(uint32_t &width, uint32_t &height);
void setOpacity(double opacity);
void scale(double &scaleX, double &scaleY);
void setScale(double scaleX, double scaleY);
void opacity(double& opacity);
void setVisible(bool visible);
void visible(bool &visible);
void setAnimating(bool animating);
void keyMetadataEnabled(bool &enabled);
void setKeyMetadataEnabled(bool enable);
int registerInputEventListener(std::function<void(const RdkShell::InputEvent&)> listener);
void unregisterInputEventListener(int tag);
void displayName(std::string& name) const;
void closeApplication();
void launchApplication();
bool resumeApplication();
bool suspendApplication();
void setApplication(const std::string& application);
private:
static void invalidate(WstCompositor *context, void *userData);
static void clientStatus(WstCompositor *context, int status, int pid, int detail, void *userData);
void onInvalidate();
void onClientStatus(int status, int pid, int detail);
void processKeyEvent(bool keyPressed, uint32_t keycode, uint32_t flags, uint64_t metadata);
void broadcastInputEvent(const RdkShell::InputEvent &inputEvent);
void launchApplicationInBackground();
void shutdownApplication();
std::string mDisplayName;
WstCompositor *mWstContext;
uint32_t mWidth;
uint32_t mHeight;
int32_t mPositionX;
int32_t mPositionY;
float mMatrix[16];
double mOpacity;
bool mVisible;
bool mAnimating;
double mScaleX;
double mScaleY;
bool mEnableKeyMetadata;
int mInputListenerTags;
std::mutex mInputLock;
std::unordered_map<int, std::function<void(const RdkShell::InputEvent&)>> mInputListeners;
std::string mApplicationName;
std::thread mApplicationThread;
RdkShell::ApplicationState mApplicationState;
int32_t mApplicationPid;
bool mApplicationThreadStarted;
bool mApplicationClosedByCompositor;
std::recursive_mutex mApplicationMutex;
};
}
#endif //RDKSHELL_RDK_COMPOSITOR_H