From a98482b34dcf4c9ea3b467d8e2bab1e23c9ef9e3 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Wed, 12 Aug 2020 20:35:28 +0900 Subject: [PATCH] DSWindow: change APIs set/getGeometry to set/getSize Change-Id: I02869e0ce5361b0ee14a15dd3ef46bb4d3d45cd9 --- src/DSWindow/DSWindow.cpp | 26 +++++++++----------------- src/DSWindow/DSWindow.h | 6 +++--- src/DSWindow/DSWindowPrivate.h | 2 -- tests/DSWindow-test.cpp | 36 ++++++++++++++---------------------- 4 files changed, 26 insertions(+), 44 deletions(-) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 56e2962..3b55f25 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -32,8 +32,6 @@ namespace display_server DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), - __x(0), - __y(0), __w(1), __h(1), __created(false), @@ -210,37 +208,31 @@ bool DSWindow::hasFocus(void) return priv->__hasFocus; } -stGeometry DSWindow::getGeometry() +stSize DSWindow::getSize() { DS_GET_PRIV(DSWindow); - stGeometry geom; - geom.x = priv->__x; - geom.y = priv->__y; - geom.w = priv->__w; - geom.h = priv->__h; + stSize size; + size.w = priv->__w; + size.h = priv->__h; - return geom; + return size; } -void DSWindow::setGeometry(int x, int y, unsigned int w, unsigned int h) +void DSWindow::setSize(unsigned int w, unsigned int h) { DS_GET_PRIV(DSWindow); - priv->__x = x; - priv->__y = y; priv->__w = w; priv->__h = h; } -void DSWindow::setGeometry(stGeometry geom) +void DSWindow::setSize(stSize size) { DS_GET_PRIV(DSWindow); - priv->__x = geom.x; - priv->__y = geom.y; - priv->__w = geom.w; - priv->__h = geom.h; + priv->__w = size.w; + priv->__h = size.h; } DSWaylandSurface *DSWindow::surface() diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index 81c22a6..ec89151 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -59,9 +59,9 @@ public: bool setFocus(void); bool hasFocus(void); - stGeometry getGeometry(); - void setGeometry(int x, int y, unsigned int w, unsigned int h); - void setGeometry(stGeometry geom); + stSize getSize(void); + void setSize(unsigned int w, unsigned int h); + void setSize(stSize size); DSWaylandSurface *surface(); diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index 0cd8a09..f29dc14 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -59,8 +59,6 @@ public: private: void __onSurfaceCommitted(std::shared_ptr waylandSurfaceCommitInfo); - int __x; - int __y; unsigned int __w; unsigned int __h; bool __created; diff --git a/tests/DSWindow-test.cpp b/tests/DSWindow-test.cpp index e8ff1b5..971aeea 100644 --- a/tests/DSWindow-test.cpp +++ b/tests/DSWindow-test.cpp @@ -56,31 +56,23 @@ TEST_F(DSWindowTest, BasicMethods) auto win = new DSWindow(); EXPECT_TRUE(win != nullptr); - stGeometry geom = win->getGeometry(); - EXPECT_TRUE(geom.x == 0); - EXPECT_TRUE(geom.y == 0); - EXPECT_TRUE(geom.w == 1); - EXPECT_TRUE(geom.h == 1); + stSize size = win->getSize(); + EXPECT_TRUE(size.w == 1); + EXPECT_TRUE(size.h == 1); - win->setGeometry(100, 100, 1280, 720); - geom = win->getGeometry(); - EXPECT_TRUE(geom.x == 100); - EXPECT_TRUE(geom.y == 100); - EXPECT_TRUE(geom.w == 1280); - EXPECT_TRUE(geom.h == 720); + win->setSize(1280, 720); + size = win->getSize(); + EXPECT_TRUE(size.w == 1280); + EXPECT_TRUE(size.h == 720); - stGeometry sGeom; - sGeom.x = 50; - sGeom.y = 50; - sGeom.w = 700; - sGeom.h = 700; - win->setGeometry(sGeom); + stSize sSize; + sSize.w = 700; + sSize.h = 700; + win->setSize(sSize); - geom = win->getGeometry(); - EXPECT_TRUE(geom.x == sGeom.x); - EXPECT_TRUE(geom.y == sGeom.y); - EXPECT_TRUE(geom.w == sGeom.w); - EXPECT_TRUE(geom.h == sGeom.h); + size = win->getSize(); + EXPECT_TRUE(size.w == sSize.w); + EXPECT_TRUE(size.h == sSize.h); EXPECT_TRUE(win->show() == true); EXPECT_TRUE(win->hide(true) == true); -- 2.7.4