summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qlibwindowmanager.cpp102
-rw-r--r--src/qlibwindowmanager.h18
2 files changed, 42 insertions, 78 deletions
diff --git a/src/qlibwindowmanager.cpp b/src/qlibwindowmanager.cpp
index e0ea50b..fff99c4 100644
--- a/src/qlibwindowmanager.cpp
+++ b/src/qlibwindowmanager.cpp
@@ -19,55 +19,30 @@
#include <stdlib.h>
#include <stdio.h>
#include <string>
-//#include <wrap-json.h>
-
-// TODO: write description for function
-// TODO: replace json_object creation to use wrap-json
using namespace std;
int QLibWindowmanager::init(int port, const QString &token) {
string ctoken = token.toStdString();
- int ret_init = this->wm->init(port, ctoken.c_str());
-
- // initialize dpyinfo
- json_object *obj = json_object_new_object();
-
- int ret = this->wm->getDisplayInfo(obj);
+ int ret_init = this->wm->init(port, ctoken);
this->screen_info = new AGLScreenInfoPrivate;
- if (!ret) {
- json_object *j_val;
- if (json_object_object_get_ex(obj, "width_pixel", &j_val)) {
- this->screen_info->set_width_dp(json_object_get_double(j_val));
- }
- if (json_object_object_get_ex(obj, "height_pixel", &j_val)) {
- this->screen_info->set_height_dp(json_object_get_double(j_val));
- }
- if (json_object_object_get_ex(obj, "width_mm", &j_val)) {
- this->screen_info->set_width_mm(json_object_get_double(j_val));
- }
- if (json_object_object_get_ex(obj, "height_mm", &j_val)) {
- this->screen_info->set_height_mm(json_object_get_double(j_val));
- }
- if (json_object_object_get_ex(obj, "scale", &j_val)) {
- this->screen_info->set_scale_factor(json_object_get_double(j_val));
- }
+ if(ret_init == 0) {
+ struct Screen scrn = this->wm->getScreenInfo();
+ this->screen_info->set_width_dp(scrn.width_dp);
+ this->screen_info->set_height_dp(scrn.height_dp);
+ this->screen_info->set_width_mm(scrn.width_mm);
+ this->screen_info->set_height_mm(scrn.height_mm);
+ this->screen_info->set_scale_factor(scrn.scale);
}
- json_object_put(obj);
-
return ret_init;
}
-int QLibWindowmanager::requestSurface(const QString &label) {
- string cstr = label.toStdString();
- applabel = strdup(cstr.c_str());
-
- json_object *obj = json_object_new_object();
- json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(applabel));
- int surface_id = this->wm->requestSurface(obj);
+int QLibWindowmanager::requestSurface(const QString &role) {
+ this->graphic_role = role.toStdString();
+ int surface_id = this->wm->requestSurface(this->graphic_role.c_str());
if(surface_id < 0){
qDebug("failed to get surfaceID");
return -1;
@@ -81,52 +56,41 @@ int QLibWindowmanager::requestSurface(const QString &label) {
}
}
-int QLibWindowmanager::activateWindow(const QString &label) {
- json_object *obj = json_object_new_object();
- string clabel = label.toStdString();
- // Request default drawing area "normal.full"
- string cdrawing_area = wm->kStrLayoutNormal + "." + wm->kStrAreaFull;
- json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(clabel.c_str()));
- json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string(cdrawing_area.c_str()));
- return this->wm->activateWindow(obj);
+int QLibWindowmanager::activateWindow(const QString &role) {
+ string srole = role.toStdString();
+ // Request default drawing area "normal.full" in libwindowmanager
+ return this->wm->activateWindow(srole.c_str());
}
-int QLibWindowmanager::activateWindow(const QString &label, const QString &drawing_area) {
- json_object *obj = json_object_new_object();
- string clabel = label.toStdString();
- string cdrawing_area = drawing_area.toStdString();
- json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(clabel.c_str()));
- json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string(cdrawing_area.c_str()));
- return this->wm->activateWindow(obj);
+int QLibWindowmanager::activateWindow(const QString &role, const QString &area) {
+ string srole = role.toStdString();
+ string sarea = area.toStdString();
+ return this->wm->activateWindow(srole.c_str(), sarea.c_str());
}
-int QLibWindowmanager::deactivateWindow(const QString &label) {
- json_object *obj = json_object_new_object();
- string clabel = label.toStdString();
- json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(clabel.c_str()));
- return this->wm->deactivateWindow(obj);
+int QLibWindowmanager::deactivateWindow(const QString &role) {
+ string srole = role.toStdString();
+ return this->wm->deactivateWindow(srole.c_str());
}
// This API is deprecated, please use new API
-int QLibWindowmanager::activateSurface(const QString &label) {
- return this->activateWindow(label);
+int QLibWindowmanager::activateSurface(const QString &role) {
+ return this->activateWindow(role);
}
// This API is deprecated, please use new API
-int QLibWindowmanager::activateSurface(const QString &label, const QString &drawing_area) {
- return this->activateWindow(label, drawing_area);
+int QLibWindowmanager::activateSurface(const QString &role, const QString &area) {
+ return this->activateWindow(role, area);
}
// This API is deprecated, please use new API
-int QLibWindowmanager::deactivateSurface(const QString &label) {
- return this->deactivateWindow(label);
+int QLibWindowmanager::deactivateSurface(const QString &role) {
+ return this->deactivateWindow(role);
}
-int QLibWindowmanager::endDraw(const QString &label) {
- json_object *obj = json_object_new_object();
- string clabel = label.toStdString();
- json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(clabel.c_str()));
- return this->wm->endDraw(obj);
+int QLibWindowmanager::endDraw(const QString &role) {
+ string srole = role.toStdString();
+ return this->wm->endDraw(srole.c_str());
}
void QLibWindowmanager::set_event_handler(enum QEventType et,
@@ -138,9 +102,9 @@ void QLibWindowmanager::set_event_handler(enum QEventType et,
void QLibWindowmanager::slotActivateWindow(){
// This is needed for first rendering when the app is launched
if(!isActive){
- qDebug("Let's show %s", qPrintable(applabel));
+ qDebug("Let's show %s", qPrintable(this->graphic_role.c_str()));
isActive = true;
- this->activateWindow(applabel);
+ this->activateWindow(this->graphic_role.c_str());
}
}
diff --git a/src/qlibwindowmanager.h b/src/qlibwindowmanager.h
index 3a720a1..e60f04f 100644
--- a/src/qlibwindowmanager.h
+++ b/src/qlibwindowmanager.h
@@ -89,20 +89,20 @@ public:
int init(int port, const QString &token);
// WM API
- Q_INVOKABLE int requestSurface(const QString &label);
- Q_INVOKABLE int activateWindow(const QString &label);
- Q_INVOKABLE int activateWindow(const QString &label, const QString &drawing_area);
- Q_INVOKABLE int deactivateWindow(const QString &label);
- Q_INVOKABLE int endDraw(const QString &label);
+ Q_INVOKABLE int requestSurface(const QString &role);
+ Q_INVOKABLE int activateWindow(const QString &role);
+ Q_INVOKABLE int activateWindow(const QString &role, const QString &drawing_area);
+ Q_INVOKABLE int deactivateWindow(const QString &role);
+ Q_INVOKABLE int endDraw(const QString &role);
void set_event_handler(enum QEventType et, handler_fun f);
double get_scale_factor() const { return screen_info->scale_factor(); };
// These APIs are deprecated, please use new API
- THIS_FUNCTION_IS_DEPRECATED(Q_INVOKABLE int activateSurface(const QString &label));
- THIS_FUNCTION_IS_DEPRECATED(Q_INVOKABLE int activateSurface(const QString &label, const QString &drawing_area));
- THIS_FUNCTION_IS_DEPRECATED(Q_INVOKABLE int deactivateSurface(const QString &label));
+ THIS_FUNCTION_IS_DEPRECATED(Q_INVOKABLE int activateSurface(const QString &role));
+ THIS_FUNCTION_IS_DEPRECATED(Q_INVOKABLE int activateSurface(const QString &role, const QString &drawing_area));
+ THIS_FUNCTION_IS_DEPRECATED(Q_INVOKABLE int deactivateSurface(const QString &role));
public slots:
void slotActivateWindow();
@@ -112,7 +112,7 @@ public slots:
private:
LibWindowmanager* wm;
- const char* applabel;
+ std::string graphic_role;
bool isActive;
AGLScreenInfoPrivate* screen_info;
};