add sample code to handle request (set title) 43/241843/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Tue, 18 Aug 2020 07:36:24 +0000 (16:36 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:12:01 +0000 (19:12 +0900)
Change-Id: I6e95c415675585ea4188df166644610413d6298d

src/DSWaylandServer/DSWaylandZxdgShellV6.cpp
src/DSWindow/DSWindow.cpp
src/DSWindow/DSWindow.h
src/DSWindow/DSWindowPrivate.h
src/DSWindowManager/DSWindowManager.cpp
src/DSWindowManager/DSWindowManager.h
src/DSWindowManager/DSWindowManagerPrivate.h
src/DSZone/DSZone.cpp
src/DSZone/DSZone.h
tests/DSWindow-test.cpp

index 47d3b0d..76b3758 100644 (file)
@@ -21,6 +21,7 @@
 * DEALINGS IN THE SOFTWARE.
 */
 
+#include "DSWindowManager.h"
 #include "DSWaylandZxdgShellV6.h"
 #include "DSWaylandZxdgShellV6Private.h"
 #include "DSWaylandCompositor.h"
@@ -420,8 +421,11 @@ void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_ack_configure(zxdg_surface_v
 void DSWaylandZxdgSurfaceV6Private::setWindowTitle(const std::string &title)
 {
        // TODO: needs DSWindow title set method
-       //__window->setTitle(title);
        __title = title;
+
+       DSWindowManager *wm = DSWindowManager::getInstance();
+       wm->setWindowTitle(__dsSurface, __title);
+       DSWindowManager::releaseInstance();
 }
 
 void DSWaylandZxdgSurfaceV6Private::setAppID(const std::string &appId)
index d210e16..434d134 100644 (file)
@@ -42,7 +42,8 @@ DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr)
          __hasFocus(false),
          __waylandSurface(nullptr),
          __winShell(nullptr),
-         __firstCommit(true)
+         __firstCommit(true),
+         __title("")
 {
 }
 
@@ -79,6 +80,17 @@ int  DSWindowPrivate::showState(void)
        return 0;
 }
 
+bool DSWindowPrivate::setTitle(const std::string &title)
+{
+       __title.replace(__title.begin(), __title.end(), title);
+       return true;
+}
+
+const std::string DSWindowPrivate::getTitle(void)
+{
+       return __title;
+}
+
 bool DSWindowPrivate::setLayer(int layer)
 {
        return true;
@@ -219,6 +231,19 @@ int  DSWindow::showState(void)
        return priv->showState();
 }
 
+bool DSWindow::setTitle(const std::string &title)
+{
+       DSLOG_DBG("DSWindow", "title:%s", title.c_str());
+
+       DS_GET_PRIV(DSWindow);
+       return priv->setTitle(title);
+}
+
+const std::string DSWindow::getTitle(void)
+{
+       DS_GET_PRIV(DSWindow);
+       return priv->getTitle();
+}
 
 bool DSWindow::setLayer(int layer)
 {
index ec94e12..04bfa9f 100644 (file)
@@ -53,6 +53,9 @@ public:
        bool hide(bool autoFocus = true);
        int  showState(void);
 
+       bool setTitle(const std::string &title);
+       const std::string getTitle(void);
+
        bool setLayer(int layer);
        bool raise(void);
        bool lower(void);
index 249c5b0..d532ad0 100644 (file)
@@ -50,6 +50,9 @@ public:
        bool hide(bool autoFocus);
        int  showState(void);
 
+       bool setTitle(const std::string &title);
+       const std::string getTitle(void);
+
        bool setLayer(int layer);
        bool raise(void);
        bool lower(void);
@@ -74,6 +77,7 @@ private:
        std::shared_ptr<DSWaylandSurface> __waylandSurface;
        DSWindowShell *__winShell;
        bool __firstCommit;
+       std::string __title;
 };
 
 }
index 5eaa293..4a5761c 100644 (file)
@@ -202,6 +202,20 @@ DSZone *DSWindowManagerPrivate::getZone(DSWaylandSurface *surface)
 }
 
 
+void DSWindowManagerPrivate::setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title)
+{
+       // find dsSurface's window
+       DSZone *zone = __getZone(dsSurface);
+       if (zone)
+       {
+               zone->setWindowTitle(dsSurface, title);
+       }
+       else
+       {
+               // Do something if there is no zone
+       }
+}
+
 
 DSWindowManager::DSWindowManager(DSObject *parent)
     : DS_INIT_PRIVATE_PTR(DSWindowManager)
@@ -301,5 +315,11 @@ DSZone *DSWindowManager::getZone(DSWaylandSurface *surface)
        return priv->getZone(surface);
 }
 
+void DSWindowManager::setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title)
+{
+       DS_GET_PRIV(DSWindowManager);
+       priv->setWindowTitle(dsSurface, title);
+}
+
 
 } // namespace display_server
index 7ad2f0d..9ae0af6 100644 (file)
@@ -55,6 +55,8 @@ public:
        void unregisterSurface(DSZone *zone, DSWaylandSurface *surface);
        DSZone *getZone(DSWaylandSurface *surface);
 
+       void setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title);
+
 protected:
 
 private:
index f92b0d7..9f6bed1 100644 (file)
@@ -50,6 +50,8 @@ public:
        void unregisterSurface(DSZone *zone, DSWaylandSurface *surface);
        DSZone *getZone(DSWaylandSurface *surface);
 
+       void setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title);
+
 private:
        DSZone *__getZone(DSWindow *window);
        DSZone *__getZone(DSWaylandSurface *surface);
index a838a28..0b0f043 100644 (file)
@@ -261,4 +261,10 @@ void DSZone::__destroyWindowShell(DSWindowShell* windowShell, DSWaylandSurface *
        }
 }
 
+bool DSZone::setWindowTitle(DSWaylandSurface *dswSurface, const std::string &title)
+{
+       std::shared_ptr<DSWindow> window = __findWindow(dswSurface);
+       return window->setTitle(title);
+}
+
 } //  namespace display_server
index 5bbf38f..f89893b 100644 (file)
@@ -58,6 +58,9 @@ public:
        void callCallbackWindowCreated();
        void callCallbackWindowShellCreated();
 
+       // for window property
+       bool setWindowTitle(DSWaylandSurface *dswSurface, const std::string &title);
+
        std::list<std::shared_ptr<DSWindow>> getWindowList();
        std::list<std::shared_ptr<DSWindowShell>> getWindowShellList();
 
index e10385e..7f33bd3 100644 (file)
@@ -40,7 +40,7 @@ public:
 
 TEST_F(DSWindowTest, NewDSWindow)
 {
-       DSWindow *win = new DSWindow();
+       auto win = std::make_shared<DSWindow>();
        EXPECT_TRUE(win != nullptr);
 }
 
@@ -54,7 +54,7 @@ TEST_F(DSWindowTest, NewDSWindowWithDSWaylandSurface)
 
 TEST_F(DSWindowTest, BasicMethods)
 {
-       auto win = new DSWindow();
+       auto win = std::make_shared<DSWindow>();
        EXPECT_TRUE(win != nullptr);
 
        EXPECT_TRUE(win->show() == true);
@@ -66,13 +66,13 @@ TEST_F(DSWindowTest, BasicMethods)
        EXPECT_TRUE(win->raise() == true);
        EXPECT_TRUE(win->lower() == true);
 
+       EXPECT_TRUE(win->hasFocus() == false);
        EXPECT_TRUE(win->setFocus() == true);
-       EXPECT_TRUE(win->hasFocus() == true);
 }
 
 TEST_F(DSWindowTest, SizeTest)
 {
-       auto win = new DSWindow();
+       auto win = std::make_shared<DSWindow>();
        EXPECT_TRUE(win != nullptr);
 
        stSize size = win->getSize();
@@ -96,7 +96,7 @@ TEST_F(DSWindowTest, SizeTest)
 
 TEST_F(DSWindowTest, PositionTest)
 {
-       auto win = new DSWindow();
+       auto win = std::make_shared<DSWindow>();
        EXPECT_TRUE(win != nullptr);
 
        stPosition pos = win->getPosition();
@@ -111,15 +111,29 @@ TEST_F(DSWindowTest, PositionTest)
 
 TEST_F(DSWindowTest, WindowShellTest)
 {
-       auto win = new DSWindow();
+       auto win = std::make_shared<DSWindow>();
        EXPECT_TRUE(win != nullptr);
 
-       auto winShell = new DSWindowShell(win);
+       auto winShell = std::make_shared<DSWindowShell>(win.get());
        EXPECT_TRUE(winShell != nullptr);
 
-       EXPECT_TRUE(win->setWindowShell(winShell) == true);
+       EXPECT_TRUE(win->setWindowShell(winShell.get()) == true);
 
        DSWindowShell *getWinShell = nullptr;
        getWinShell = win->getWindowShell();
-       EXPECT_TRUE(winShell == getWinShell);
+       EXPECT_TRUE(winShell.get() == getWinShell);
 }
+
+TEST_F(DSWindowTest, TitleTest)
+{
+       auto win = std::make_shared<DSWindow>();
+       EXPECT_TRUE(win != nullptr);
+
+       bool ret = false;
+       ret = win->setTitle("test title");
+       EXPECT_TRUE(ret == true);
+
+       std::string title = win->getTitle();
+       EXPECT_TRUE(title.compare("test title") == 0);
+}
+