DSWindowShell: add APIs for set/getGeometry 03/241803/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Thu, 13 Aug 2020 02:46:40 +0000 (11:46 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:11:26 +0000 (19:11 +0900)
Change-Id: I50f486d4b8fdd81e786214b54af90225e39b1a67

src/DSWindowShell/DSWindowShell.cpp
src/DSWindowShell/DSWindowShell.h
src/DSWindowShell/DSWindowShellPrivate.cpp
src/DSWindowShell/DSWindowShellPrivate.h
src/DSZone/DSZone.cpp
tests/DSWindowShell-test.cpp

index a493b0f..8431fb8 100644 (file)
@@ -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)
 {
index 5cca5ca..4522c2c 100644 (file)
@@ -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);
index b946146..1673c5f 100644 (file)
@@ -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)
 {
index a797a61..4915c53 100644 (file)
@@ -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;
 };
 
 }
index 3030bbc..2970658 100644 (file)
@@ -192,6 +192,8 @@ std::shared_ptr<DSWindowShell> DSZone::__createWindowShell(std::shared_ptr<DSWin
        __windowShellList.push_front(shell);
        __windowShellMap.insert(std::make_pair(ptrWindow->surface(), shell.get()));
 
+       shell->setGeometry(__position.x, __position.y, __size.w, __size.h);
+
        // emit a signal of the shell created
        __windowShellCreatedSignal.emit(shell);
 
index 1ab4547..dcd84ce 100644 (file)
@@ -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<DSWindow>();
+       std::unique_ptr<DSWindowShell> shell = std::make_unique<DSWindowShell>(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<DSWindow>();