diff options
author | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2018-08-06 17:07:16 +0900 |
---|---|---|
committer | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2018-08-06 17:07:16 +0900 |
commit | 42ad7e7adb31abed735a8f90dceea82101d7bf13 (patch) | |
tree | e3380a2369269d3c0b7ca1c1cd223c6dc53fd83d | |
parent | b24e4295913ab94026f169e9c7d93ec994a25131 (diff) |
Fix getDisplayInfo(AGLScreenInfo*) to getScreenInfo(strcut Screen*)
Change-Id: I4ed94b76c63d4fd784da2e4be2fd28508ff62c39
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r-- | src/libwindowmanager.cpp | 85 | ||||
-rw-r--r-- | src/libwindowmanager.h | 44 |
2 files changed, 69 insertions, 60 deletions
diff --git a/src/libwindowmanager.cpp b/src/libwindowmanager.cpp index 5ed4def..7497a6c 100644 --- a/src/libwindowmanager.cpp +++ b/src/libwindowmanager.cpp @@ -67,6 +67,7 @@ class LibWindowmanager::Impl { int getDisplayInfo(json_object *object); int getAreaInfo(json_object *in_obj, json_object *out_obj); + struct Screen getScreenInfo() {return this->_screen;}; void set_event_handler(enum EventType et, handler_fun func); @@ -104,6 +105,7 @@ private: flush_draw_handler _on_flush_draw = nullptr; screen_update_handler _on_screen_updated = nullptr; error_handler _on_error = nullptr; + struct Screen _screen = {0, 0, 0, 0, 0.0}; }; namespace { @@ -470,11 +472,17 @@ int LibWindowmanager::Impl::getDisplayInfo(json_object *object) { } if (0 == rc) { - json_object_object_add(object, "width_pixel", json_object_new_int(w_px)); - json_object_object_add(object, "height_pixel", json_object_new_int(h_px)); - json_object_object_add(object, "width_mm", json_object_new_int(w_mm)); - json_object_object_add(object, "height_mm", json_object_new_int(h_mm)); - json_object_object_add(object, "scale", json_object_new_double(scale)); + json_object_object_add(object, "width_pixel", json_object_new_int(w_px)); + json_object_object_add(object, "height_pixel", json_object_new_int(h_px)); + json_object_object_add(object, "width_mm", json_object_new_int(w_mm)); + json_object_object_add(object, "height_mm", json_object_new_int(h_mm)); + json_object_object_add(object, "scale", json_object_new_double(scale)); + this->_screen = Screen{ + static_cast<unsigned long>(w_px), + static_cast<unsigned long>(h_px), + static_cast<unsigned long>(w_mm), + static_cast<unsigned long>(h_mm), + scale}; } return rc; @@ -921,11 +929,23 @@ int LibWindowmanager::Impl::runEventLoop() { * @class LibWindowmanager */ int LibWindowmanager::init(int port, char const *token) { - return this->d->init(port, token); + int ret = this->d->init(port, token); + if(ret == 0) { + json_object* j = json_object_new_object(); + ret = this->getDisplayInfo(j); // return 0 if success + json_object_put(j); + } + return ret; } int LibWindowmanager::init(int port, const std::string &token) { - return this->d->init(port, token.c_str()); + int ret = this->d->init(port, token.c_str()); + if(ret == 0) { + json_object* j = json_object_new_object(); + ret = this->getDisplayInfo(j); // return 0 if success + json_object_put(j); + } + return ret; } int LibWindowmanager::requestSurface(json_object *object) { @@ -994,30 +1014,30 @@ int LibWindowmanager::getDisplayInfo(json_object *object) { return this->d->getDisplayInfo(object); } -int LibWindowmanager::getDisplayInfo(AGLScreenInfo *out_info) { - json_object* object = json_object_new_object(); - int ret = this->d->getDisplayInfo(object); - if (!ret) { - json_object *j_val; - if (json_object_object_get_ex(object, "width_pixel", &j_val)) { - out_info->set_width_dp(json_object_get_double(j_val)); - } - if (json_object_object_get_ex(object, "height_pixel", &j_val)) { - out_info->set_height_dp(json_object_get_double(j_val)); - } - if (json_object_object_get_ex(object, "width_mm", &j_val)) { - out_info->set_width_mm(json_object_get_double(j_val)); - } - if (json_object_object_get_ex(object, "height_mm", &j_val)) { - out_info->set_height_mm(json_object_get_double(j_val)); - } - if (json_object_object_get_ex(object, "scale", &j_val)) { - out_info->set_scale_factor(json_object_get_double(j_val)); - } - } - json_object_put(object); - return ret; -} +// int LibWindowmanager::getDisplayInfo(struct Screen *out_info) { +// json_object* object = json_object_new_object(); +// int ret = this->d->getDisplayInfo(object); +// if (!ret) { +// json_object *j_val; +// if (json_object_object_get_ex(object, "width_pixel", &j_val)) { +// out_info->set_width_dp(json_object_get_double(j_val)); +// } +// if (json_object_object_get_ex(object, "height_pixel", &j_val)) { +// out_info->set_height_dp(json_object_get_double(j_val)); +// } +// if (json_object_object_get_ex(object, "width_mm", &j_val)) { +// out_info->set_width_mm(json_object_get_double(j_val)); +// } +// if (json_object_object_get_ex(object, "height_mm", &j_val)) { +// out_info->set_height_mm(json_object_get_double(j_val)); +// } +// if (json_object_object_get_ex(object, "scale", &j_val)) { +// out_info->set_scale_factor(json_object_get_double(j_val)); +// } +// } +// json_object_put(object); +// return ret; +// } int LibWindowmanager::getAreaInfo(json_object *in_obj, json_object *out_obj) { return this->d->getAreaInfo(in_obj, out_obj); @@ -1088,6 +1108,9 @@ void LibWindowmanager::setErrorHandler(error_handler f) { return this->d->setErrorHandler(f); } +struct Screen LibWindowmanager::getScreenInfo() { + return this->d->getScreenInfo(); +} LibWindowmanager::LibWindowmanager() : d(new Impl) {} diff --git a/src/libwindowmanager.h b/src/libwindowmanager.h index 0f6dbc4..7d8c674 100644 --- a/src/libwindowmanager.h +++ b/src/libwindowmanager.h @@ -27,14 +27,14 @@ class Rect { Rect(unsigned x, unsigned y, unsigned w, unsigned h) : _x(x), _y(y),_w(w), _h(h) {} ~Rect() = default; - unsigned left() const {return _x;} - unsigned top() const {return _y;} - unsigned width() const {return _w;} - unsigned height() const {return _h;} - void set_left(unsigned int x){_x = x;} - void set_top(unsigned int y){_y = y;} - void set_width(unsigned int w){_w = w;} - void set_height(unsigned int h){_h = h;} + unsigned left() const { return _x;} + unsigned top() const { return _y;} + unsigned width() const { return _w;} + unsigned height() const { return _h;} + void set_left (unsigned int x) { _x = x; } + void set_top (unsigned int y) { _y = y; } + void set_width (unsigned int w) { _w = w; } + void set_height(unsigned int h) { _h = h; } private: unsigned _x; unsigned _y; @@ -42,27 +42,13 @@ class Rect { unsigned _h; }; -class AGLScreenInfo +struct Screen { - public: - unsigned long width_dp(void) const { return _width_dp; }; - unsigned long height_dp(void) const { return _height_dp; }; - unsigned long width_mm(void) const { return _width_mm; }; - unsigned long height_mm(void) const { return _height_mm; }; - double scale_factor(void) const { return _scale; }; - - void set_width_dp(unsigned long w) { _width_dp = w; }; - void set_height_dp(unsigned long h) { _height_dp = h; }; - void set_width_mm(unsigned long w) { _width_mm = w; }; - void set_height_mm(unsigned long h) { _height_mm = h; }; - void set_scale_factor(double scale) { _scale = scale; }; - - private: - unsigned long _width_dp; - unsigned long _height_dp; - unsigned long _width_mm; - unsigned long _height_mm; - double _scale = 1.0; + unsigned long width_dp; + unsigned long height_dp; + unsigned long width_mm; + unsigned long height_mm; + double scale = 1.0; }; class LibWindowmanager { @@ -122,7 +108,7 @@ public: int activateWindow(const char* role, const char* area); int deactivateWindow(const char* role); int endDraw(const char* role); - int getDisplayInfo(AGLScreenInfo *out_info); + struct Screen getScreenInfo(); int getAreaInfo(const char* role, Rect *out_rect); void setVisibleHandler(visible_handler f); |