07f84794a22e21bdcf2fc16c932a69ce29a821e3
[apps/hvac.git] / app / qlibwindowmanager.h
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
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 QLIBWINDOWMANAGER_H
18 #define QLIBWINDOWMANAGER_H
19
20 #include <libwindowmanager.h>
21 #include <functional>
22 #include <QObject>
23 #include <QUrl>
24 #include <QVariant>
25 #include <string>
26 #include <vector>
27
28 class QLibWindowmanager : public QObject{
29 Q_OBJECT
30 public:
31     explicit QLibWindowmanager(QObject *parent = nullptr);
32     ~QLibWindowmanager();
33
34     QLibWindowmanager(const QLibWindowmanager &) = delete;
35     QLibWindowmanager &operator=(const QLibWindowmanager &) = delete;
36
37 public:
38     using handler_fun = std::function<void(json_object *object)>;
39
40     enum QEventType {
41        Event_Active = 0,
42        Event_Inactive,
43
44        Event_Visible,
45        Event_Invisible,
46
47        Event_SyncDraw,
48        Event_FlushDraw,
49     };
50
51     static QLibWindowmanager &instance();
52
53     int init(int port, const QString &token);
54
55     // WM API
56     int requestSurface(json_object *label);
57     int activateSurface(json_object *label);
58     int deactivateSurface(json_object *label);
59     int endDraw(json_object *label);
60     void set_event_handler(enum QEventType et, handler_fun f);
61
62 public slots:
63     void slotActivateSurface();
64
65 private:
66     LibWindowmanager* wm;
67     std::string applabel;
68     std::vector<int> surfaceIDs;
69     bool isActive;
70
71 };
72 #endif // LIBWINDOWMANAGER_H