From d9fab56595c5f2f1f4db596c4b125c44a4756860 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Thu, 13 Aug 2020 11:46:40 +0900 Subject: [PATCH] DSWindowShell: add APIs for set/getGeometry Change-Id: I50f486d4b8fdd81e786214b54af90225e39b1a67 --- src/DSWindowShell/DSWindowShell.cpp | 13 +++++++- src/DSWindowShell/DSWindowShell.h | 5 +++- src/DSWindowShell/DSWindowShellPrivate.cpp | 48 +++++++++++++++++++++++++++--- src/DSWindowShell/DSWindowShellPrivate.h | 9 +++++- src/DSZone/DSZone.cpp | 2 ++ tests/DSWindowShell-test.cpp | 19 ++++++++++++ 6 files changed, 89 insertions(+), 7 deletions(-) diff --git a/src/DSWindowShell/DSWindowShell.cpp b/src/DSWindowShell/DSWindowShell.cpp index a493b0f..8431fb8 100644 --- a/src/DSWindowShell/DSWindowShell.cpp +++ b/src/DSWindowShell/DSWindowShell.cpp @@ -69,13 +69,24 @@ stPosition DSWindowShell::getPosition(void) return priv->getPosition(); } -bool DSWindowShell::setSize(int w, int h) +bool DSWindowShell::setSize(unsigned int w, unsigned int h) { DS_GET_PRIV(DSWindowShell); return priv->setSize(w, h); } +void DSWindowShell::setGeometry(int x, int y, unsigned int w, unsigned int h) +{ + DS_GET_PRIV(DSWindowShell); + return priv->setGeometry(x, y, w, h); +} + +stGeometry DSWindowShell::getGeometry(void) +{ + DS_GET_PRIV(DSWindowShell); + return priv->getGeometry(); +} bool DSWindowShell::show(void) { diff --git a/src/DSWindowShell/DSWindowShell.h b/src/DSWindowShell/DSWindowShell.h index 5cca5ca..4522c2c 100644 --- a/src/DSWindowShell/DSWindowShell.h +++ b/src/DSWindowShell/DSWindowShell.h @@ -49,7 +49,10 @@ public: bool setPosition(int x, int y); stPosition getPosition(void); - bool setSize(int w, int h); + bool setSize(unsigned int w, unsigned int h); + + void setGeometry(int x, int y, unsigned int w, unsigned int h); + stGeometry getGeometry(void); bool show(void); bool hide(bool autoFocus = true); diff --git a/src/DSWindowShell/DSWindowShellPrivate.cpp b/src/DSWindowShell/DSWindowShellPrivate.cpp index b946146..1673c5f 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.cpp +++ b/src/DSWindowShell/DSWindowShellPrivate.cpp @@ -33,7 +33,9 @@ struct DTWindowShell DSWindowShellPrivate::DSWindowShellPrivate(DSWindowShell *p_ptr, DSWindow *window) : __p_ptr(p_ptr), - __window(window) + __window(window), + __x(0), __y(0), + __w(1), __h(1) { } @@ -50,6 +52,14 @@ bool DSWindowShellPrivate::create(DSWindowShell *pParent) bool DSWindowShellPrivate::create(int x, int y, unsigned int w, unsigned int h, DSWindowShell *pParent) { + __x = x; + __y = y; + __w = w; + __h = h; + + if (__window) + __window->setSize(__w, __h); + return true; } @@ -62,6 +72,9 @@ void DSWindowShellPrivate::destroy(void) bool DSWindowShellPrivate::setPosition(int x, int y) { + __x = x; + __y = y; + return true; } @@ -69,17 +82,44 @@ stPosition DSWindowShellPrivate::getPosition(void) { stPosition pos; - pos.x = 0; - pos.y = 0; + pos.x = __x; + pos.y = __y; return pos; } -bool DSWindowShellPrivate::setSize(int w, int h) +bool DSWindowShellPrivate::setSize(unsigned int w, unsigned int h) { + __w = w; + __h = h; + + if (__window) + __window->setSize(__w, __h); + return true; } +void DSWindowShellPrivate::setGeometry(int x, int y, unsigned int w, unsigned int h) +{ + __x = x; + __y = y; + __w = w; + __h = h; + + if (__window) + __window->setSize(__w, __h); +} + +stGeometry DSWindowShellPrivate::getGeometry(void) +{ + stGeometry geo; + geo.x = __x; + geo.y = __y; + geo.w = __w; + geo.h = __h; + return geo; +} + bool DSWindowShellPrivate::show(void) { diff --git a/src/DSWindowShell/DSWindowShellPrivate.h b/src/DSWindowShell/DSWindowShellPrivate.h index a797a61..4915c53 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.h +++ b/src/DSWindowShell/DSWindowShellPrivate.h @@ -24,6 +24,8 @@ #ifndef _DS_WINDOW_SHELL_PRIVATE_H_ #define _DS_WINDOW_SHELL_PRIVATE_H_ +#include "DSWindow.h" + namespace display_server { @@ -44,7 +46,10 @@ public: bool setPosition(int x, int y); stPosition getPosition(void); - bool setSize(int w, int h); + bool setSize(unsigned int w, unsigned int h); + + void setGeometry(int x, int y, unsigned int w, unsigned int h); + stGeometry getGeometry(void); bool show(void); bool hide(bool autoFocus = true); @@ -85,6 +90,8 @@ private: private: DSWindow *__window; + int __x, __y; + unsigned int __w, __h; }; } diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index 3030bbc..2970658 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -192,6 +192,8 @@ std::shared_ptr DSZone::__createWindowShell(std::shared_ptrsurface(), shell.get())); + shell->setGeometry(__position.x, __position.y, __size.w, __size.h); + // emit a signal of the shell created __windowShellCreatedSignal.emit(shell); diff --git a/tests/DSWindowShell-test.cpp b/tests/DSWindowShell-test.cpp index 1ab4547..dcd84ce 100644 --- a/tests/DSWindowShell-test.cpp +++ b/tests/DSWindowShell-test.cpp @@ -98,6 +98,25 @@ TEST_F(DSWindowShellTest, setSize_P1) EXPECT_TRUE(shell->setSize(720, 1280) == true); } +TEST_F(DSWindowShellTest, Geometry_P1) +{ + stGeometry geo; + + auto window = std::make_shared(); + std::unique_ptr shell = std::make_unique(window.get()); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + + shell->setGeometry(100, 150, 480, 800); + geo = shell->getGeometry(); + + EXPECT_TRUE(geo.x == 100); + EXPECT_TRUE(geo.y == 150); + EXPECT_TRUE(geo.w == 480); + EXPECT_TRUE(geo.h == 800); +} + TEST_F(DSWindowShellTest, show_P1) { auto window = std::make_shared(); -- 2.7.4