DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr)
: DSObjectPrivate(p_ptr),
__p_ptr(p_ptr),
+ __parent(nullptr),
__x(0),
__y(0),
__w(0),
{
}
+void DSWindowPrivate::setParent(DSWindow *parent)
+{
+ __parent = parent;
+}
+
+DSWindow *DSWindowPrivate::getParent(void)
+{
+ return __parent;
+}
+
bool DSWindowPrivate::show(void)
{
return true;
priv->destroy();
}
+void DSWindow::setParent(DSWindow *parent)
+{
+ if (parent == this) return;
+
+ DS_GET_PRIV(DSWindow);
+ priv->setParent(parent);
+}
+
+DSWindow *DSWindow::getParent(void)
+{
+ DS_GET_PRIV(DSWindow);
+ return priv->getParent();
+}
+
bool DSWindow::show(void)
{
DS_GET_PRIV(DSWindow);
bool create(std::shared_ptr<DSWaylandSurface> waylandSurface);
void destroy(void);
+ void setParent(DSWindow *parent);
+ DSWindow *getParent(void);
+
bool show(void);
bool hide(bool autoFocus = true);
int showState(void);
bool create(std::shared_ptr<DSWaylandSurface> waylandSurface);
void destroy(void);
+ void setParent(DSWindow *parent);
+ DSWindow *getParent(void);
+
bool show(void);
bool hide(bool autoFocus);
int showState(void);
private:
void __onSurfaceCommitted(std::shared_ptr<DSWaylandSurfaceCommitInfo> waylandSurfaceCommitInfo);
+ DSWindow *__parent;
+ std::list<DSWindow*> __childList;
int __x, __y;
unsigned int __w;
unsigned int __h;
return priv->getShellSurface();
}
+DSWindow *DSWindowShell::getWindow(void)
+{
+ DS_GET_PRIV(DSWindowShell);
+ return priv->getWindow();
+}
+
+bool DSWindowShell::setParent(DSWindowShell *parentWinShell)
+{
+ if (parentWinShell == this)
+ return false;
+
+ DS_GET_PRIV(DSWindowShell);
+ return priv->setParent(parentWinShell);
+}
+
+DSWindowShell *DSWindowShell::getParent(void)
+{
+ DS_GET_PRIV(DSWindowShell);
+ return priv->getParent();
+}
+
+bool DSWindowShell::addChild(DSWindowShell *childWinShell)
+{
+ DS_GET_PRIV(DSWindowShell);
+ return priv->addChild(childWinShell);
+}
+
+void DSWindowShell::removeChild(DSWindowShell *childWinShell)
+{
+ DS_GET_PRIV(DSWindowShell);
+ priv->removeChild(childWinShell);
+}
+
bool DSWindowShell::setTitle(const std::string &title)
{
DS_GET_PRIV(DSWindowShell);
bool DSWindowShell::setLayer(int layer)
{
- return true;
+ DS_GET_PRIV(DSWindowShell);
+ return priv->setLayer(layer);
}
int DSWindowShell::getLayer(void)
void setShellSurface(IDSWaylandShellSurface *zxdgSurface);
IDSWaylandShellSurface *getShellSurface(void);
+ DSWindow *getWindow(void);
+
+ bool setParent(DSWindowShell *parentWinShell);
+ DSWindowShell *getParent(void);
+
+ bool addChild(DSWindowShell *childWinShell);
+ void removeChild(DSWindowShell *childWinShell);
+
bool setTitle(const std::string &title);
bool setSkipFocus(bool set);
__x(0), __y(0),
__w(0), __h(0),
__reqX(0), __reqY(0),
- __reqW(0), __reqH(0)
+ __reqW(0), __reqH(0),
+ __parent(nullptr)
{
}
}
+bool DSWindowShellPrivate::__findInChildList(DSWindowShell *parentWinShell)
+{
+ for (auto ws : __childList)
+ {
+ if (ws == parentWinShell)
+ return true;
+ }
+
+ return false;
+}
+
+bool DSWindowShellPrivate::__setParent(DSWindowShell *parentWinShell)
+{
+ DS_GET_PUB(DSWindowShell);
+
+ if (__parent == parentWinShell)
+ return true;
+
+ if (__findInChildList(parentWinShell))
+ {
+ DSLOG_ERR("DSWindowShell", "Fatal error. Set parent each other. winShell:%p, parentWinShell:%p", pub, parentWinShell);
+ return false;
+ }
+
+ if (__parent)
+ {
+ // remove this from old parent's child list
+ __parent->removeChild(pub);
+ }
+
+ __parent = parentWinShell;
+ if (__parent)
+ {
+ __parent->addChild(pub);
+ }
+
+ if (__window)
+ {
+ if (__parent)
+ {
+ DSWindow *parentWin = __parent->getWindow();
+ __window->setParent(parentWin);
+ }
+ else
+ __window->setParent(nullptr);
+ }
+
+ return true;
+}
+
bool DSWindowShellPrivate::create(DSWindowShell *pParent)
{
return __shellSurface;
}
+DSWindow *DSWindowShellPrivate::getWindow(void)
+{
+ return __window;
+}
+
+bool DSWindowShellPrivate::setParent(DSWindowShell *parentWinShell)
+{
+ return __setParent(parentWinShell);
+}
+
+DSWindowShell *DSWindowShellPrivate::getParent(void)
+{
+ return __parent;
+}
+
+bool DSWindowShellPrivate::addChild(DSWindowShell *childWinShell)
+{
+ __childList.push_back(childWinShell);
+ return true;
+}
+
+void DSWindowShellPrivate::removeChild(DSWindowShell *childWinShell)
+{
+ __childList.remove(childWinShell);
+}
+
bool DSWindowShellPrivate::setTitle(const std::string &title)
{
if (__window)
bool DSWindowShellPrivate::setLayer(int layer)
{
+ __layer = layer;
return true;
}
int DSWindowShellPrivate::getLayer(void)
{
- return 0;
+ return __layer;
}
void setShellSurface(IDSWaylandShellSurface *shellSurface);
IDSWaylandShellSurface *getShellSurface(void);
+ DSWindow *getWindow(void);
+
+ bool setParent(DSWindowShell *parentWinShell);
+ DSWindowShell *getParent(void);
+
+ bool addChild(DSWindowShell *childWinShell);
+ void removeChild(DSWindowShell *childWinShell);
+
bool setTitle(const std::string &title);
bool setSkipFocus(bool set);
private:
bool __create(int x, int y, unsigned int w, unsigned int h, DSWindowShell *pWin, DSWindowShell *pParent);
+ bool __findInChildList(DSWindowShell *parentWinShell);
+ bool __setParent(DSWindowShell *parentWinShell);
private:
DSWindow *__window;
IDSWaylandShellSurface *__shellSurface;
int __x, __y;
unsigned int __w, __h;
+ int __layer;
int __reqX, __reqY;
unsigned int __reqW, __reqH;
+ DSWindowShell *__parent;
+ std::list<DSWindowShell*> __childList;
};
}
EXPECT_TRUE(skip == false);
}
+TEST_F(DSWindowTest, ParentTest)
+{
+ auto parent = std::make_shared<DSWindow>();
+ EXPECT_TRUE(parent != nullptr);
+ EXPECT_TRUE(parent->getParent() == nullptr);
+
+ auto child = std::make_shared<DSWindow>();
+ EXPECT_TRUE(child != nullptr);
+ EXPECT_TRUE(child->getParent() == nullptr);
+
+ child->setParent(parent.get());
+ EXPECT_TRUE(child->getParent() == parent.get());
+
+ child->setParent(nullptr);
+ EXPECT_TRUE(child->getParent() == nullptr);
+
+ child->setParent(child.get());
+ EXPECT_TRUE(child->getParent() == nullptr);
+}
+
EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true);
}
+TEST_F(DSWindowShellTest, parent_P1)
+{
+ auto window = std::make_shared<DSWindow>();
+ std::unique_ptr<DSWindowShell> shell = std::make_unique<DSWindowShell>(window.get());
+ EXPECT_TRUE(shell != nullptr);
+
+ EXPECT_TRUE(shell->getParent() == nullptr);
+
+ auto childWindow = std::make_shared<DSWindow>();
+ std::unique_ptr<DSWindowShell> childShell = std::make_unique<DSWindowShell>(childWindow.get());
+ EXPECT_TRUE(childShell != nullptr);
+
+ EXPECT_TRUE(childShell->setParent(shell.get()) == true);
+ EXPECT_TRUE(childShell->getParent() == shell.get());
+
+ // test for set parent each other
+ EXPECT_TRUE(shell->setParent(childShell.get()) == false);
+
+ // test for set parent itself
+ EXPECT_TRUE(childShell->setParent(childShell.get()) == false);
+
+ EXPECT_TRUE(childShell->setParent(nullptr) == true);
+ EXPECT_TRUE(childShell->getParent() == nullptr);
+}
+
TEST_F(DSWindowShellTest, setPosition_P1)
{
auto window = std::make_shared<DSWindow>();