DSWindow: add API for set/get DSWindowShell 04/241804/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Thu, 13 Aug 2020 03:44:22 +0000 (12:44 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:11:26 +0000 (19:11 +0900)
Change-Id: Ie8fd7437694604fce63c28e36df5c344ed3e3a41

src/DSWindow/DSWindow.cpp
src/DSWindow/DSWindow.h
src/DSWindow/DSWindowPrivate.h
src/DSZone/DSZone.cpp
tests/DSWindow-test.cpp

index 3b55f25..4ae3746 100644 (file)
@@ -36,7 +36,8 @@ DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr)
          __h(1),
          __created(false),
          __hasFocus(false),
-         __waylandSurface(nullptr)
+         __waylandSurface(nullptr),
+         __winShell(nullptr)
 {
 }
 
@@ -98,6 +99,23 @@ bool DSWindowPrivate::isCreated()
        return __created;
 }
 
+bool DSWindowPrivate::setWindowShell(DSWindowShell *winShell)
+{
+       if (__winShell)
+       {
+               DSLOG_ERR("DSWindow", "Already exist DSWindowShell...");
+               return false;
+       }
+
+       __winShell = winShell;
+       return true;
+}
+
+DSWindowShell *DSWindowPrivate::getWindowShell(void)
+{
+       return __winShell;
+}
+
 void DSWindowPrivate::__onSurfaceCommitted(std::shared_ptr<DSWaylandSurfaceCommitInfo> waylandSurfaceCommitInfo)
 {
        DS_GET_PUB(DSWindow);
@@ -242,6 +260,19 @@ DSWaylandSurface *DSWindow::surface()
        return priv->__waylandSurface.get();
 }
 
+
+bool DSWindow::setWindowShell(DSWindowShell *winShell)
+{
+       DS_GET_PRIV(DSWindow);
+       return priv->setWindowShell(winShell);
+}
+
+DSWindowShell *DSWindow::getWindowShell(void)
+{
+       DS_GET_PRIV(DSWindow);
+       return priv->getWindowShell();
+}
+
 void DSWindow::registerCallbackSizeChanged(DSObject *slot, std::function<void(std::shared_ptr<stSize>)> func)
 {
        __sizeChangedSignal.connect(slot, func);
index ec89151..e7ff5d7 100644 (file)
@@ -29,6 +29,7 @@
 #include "DSObject.h"
 #include "DSSignal.h"
 #include "IDSBuffer.h"
+#include "DSWindowShell.h"
 
 namespace display_server
 {
@@ -65,6 +66,9 @@ public:
 
        DSWaylandSurface *surface();
 
+       bool setWindowShell(DSWindowShell *winShell);
+       DSWindowShell *getWindowShell(void);
+
        void registerCallbackSizeChanged(DSObject *slot, std::function<void(std::shared_ptr<stSize>)> func);
        void registerCallbackBufferChanged(DSObject *slot, std::function<void(std::shared_ptr<IDSBuffer>)> func);
 
index f29dc14..c19592f 100644 (file)
@@ -27,6 +27,7 @@
 #include "DSCore.h"
 #include "DSObjectPrivate.h"
 #include "DSWaylandSurface.h"
+#include "DSWindowShell.h"
 
 namespace display_server
 {
@@ -56,6 +57,9 @@ public:
        bool setFocus(void);
        bool isCreated();
 
+       bool setWindowShell(DSWindowShell *winShell);
+       DSWindowShell *getWindowShell(void);
+
 private:
        void __onSurfaceCommitted(std::shared_ptr<DSWaylandSurfaceCommitInfo> waylandSurfaceCommitInfo);
 
@@ -64,6 +68,7 @@ private:
        bool __created;
        bool __hasFocus;
        std::shared_ptr<DSWaylandSurface> __waylandSurface;
+       DSWindowShell *__winShell;
 };
 
 }
index 2970658..9cce347 100644 (file)
@@ -103,6 +103,9 @@ void DSZone::__onSurfaceCreated(std::shared_ptr<DSWaylandSurface> waylandSurface
 
        // create DSWindowShell
        std::shared_ptr<DSWindowShell> shell = __createWindowShell(window);
+
+       // set DSWindowShell to DSWindow
+       window->setWindowShell(shell.get());
 }
 
 void DSZone::__onShellSurfaceCreated(IDSWaylandShellSurface *waylandShellSurface)
index 971aeea..f8e16ae 100644 (file)
@@ -24,6 +24,7 @@
 #include "libds-tests.h"
 #include "DSObject.h"
 #include "DSWindow.h"
+#include "DSWindowShell.h"
 #include "DSStruct.h"
 
 using namespace display_server;
@@ -86,3 +87,18 @@ TEST_F(DSWindowTest, BasicMethods)
        EXPECT_TRUE(win->setFocus() == true);
        EXPECT_TRUE(win->hasFocus() == true);
 }
+
+TEST_F(DSWindowTest, WindowShellTest)
+{
+       auto win = new DSWindow();
+       EXPECT_TRUE(win != nullptr);
+
+       auto winShell = new DSWindowShell(win);
+       EXPECT_TRUE(winShell != nullptr);
+
+       EXPECT_TRUE(win->setWindowShell(winShell) == true);
+
+       DSWindowShell *getWinShell = nullptr;
+       getWinShell = win->getWindowShell();
+       EXPECT_TRUE(winShell == getWinShell);
+}
\ No newline at end of file