From: Doyoun Kang Date: Thu, 27 Aug 2020 01:58:00 +0000 (+0900) Subject: IDSWaylandShell/DSWaylandZxdgShellV6: send destroyed signal when DSWaylandSurface... X-Git-Tag: accepted/tizen/unified/20200901.160655~66 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6e6a2c38623754ac42ee941662d7659686589100;p=platform%2Fcore%2Fuifw%2Flibds.git IDSWaylandShell/DSWaylandZxdgShellV6: send destroyed signal when DSWaylandSurface is destroyed Change-Id: I994d1ca4e7292c4408d44473a963d52fcf2c51bf --- diff --git a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp index f72a1e7..40ba862 100644 --- a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp +++ b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp @@ -88,6 +88,10 @@ void DSWaylandZxdgShellV6::registerCallbackShellSurfaceCreated(DSObject *slot, s __zxdgSurfaceCreatedSignal.connect(slot, func); } +void DSWaylandZxdgShellV6::registerCallbackShellSurfaceDestroyed(DSObject *slot, std::function func) +{ + __zxdgSurfaceDestroyedSignal.connect(slot, func); +} DSWaylandZxdgShellV6Private::DSWaylandZxdgShellV6Private(DSWaylandZxdgShellV6 *p_ptr) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) @@ -116,7 +120,7 @@ void DSWaylandZxdgShellV6Private::zxdg_shell_v6_get_xdg_surface(zxdg_shell_v6::R DSLOG_DBG("DSWaylandZxdgShell", ""); DS_GET_PUB(DSWaylandZxdgShellV6); - DSWaylandZxdgSurfaceV6 *zxdgSurf = new DSWaylandZxdgSurfaceV6(resource->client(), id, ZXDG_SURFACE_V6_VERSION); + DSWaylandZxdgSurfaceV6 *zxdgSurf = new DSWaylandZxdgSurfaceV6(resource->client(), id, ZXDG_SURFACE_V6_VERSION, pub); if (zxdgSurf) { zxdgSurf->setWlSurface(surface); @@ -130,8 +134,6 @@ void DSWaylandZxdgShellV6Private::zxdg_shell_v6_get_xdg_surface(zxdg_shell_v6::R DSLOG_DBG("DSWaylandZxdgShell", "DSWaylandZxdgSurface:%p, DSWaylandSurface:%p, wl_surface:%p", zxdgSurf, dswlSurface, surface); pub->addSurface(zxdgSurf); - // emit a signal of the zxdg surface created - pub->__zxdgSurfaceCreatedSignal.emit(zxdgSurf); } } void DSWaylandZxdgShellV6Private::zxdg_shell_v6_pong(zxdg_shell_v6::Resource *resource, uint32_t serial) @@ -143,11 +145,17 @@ void DSWaylandZxdgShellV6Private::addSurface(DSWaylandZxdgSurfaceV6 *zxdgSurf) for (DSWaylandZxdgSurfaceV6 *surf : __surfList) if (surf == zxdgSurf) return; + DS_GET_PUB(DSWaylandZxdgShellV6); + pub->__zxdgSurfaceCreatedSignal.emit(zxdgSurf); + __surfList.push_back(zxdgSurf); } void DSWaylandZxdgShellV6Private::delSurface(DSWaylandZxdgSurfaceV6 *zxdgSurf) { + DS_GET_PUB(DSWaylandZxdgShellV6); + pub->__zxdgSurfaceDestroyedSignal.emit(zxdgSurf); + __surfList.remove(zxdgSurf); } @@ -227,19 +235,23 @@ void DSWaylandZxdgPositionerV6Private::zxdg_positioner_v6_set_offset(zxdg_positi DSWaylandZxdgSurfaceV6 *****************************************/ -DSWaylandZxdgSurfaceV6::DSWaylandZxdgSurfaceV6() - : IDSWaylandShellSurface(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgSurfaceV6) +DSWaylandZxdgSurfaceV6::DSWaylandZxdgSurfaceV6(DSWaylandZxdgShellV6 *xdgShell) + : IDSWaylandShellSurface(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgSurfaceV6), + __xdgShell(xdgShell) { } -DSWaylandZxdgSurfaceV6::DSWaylandZxdgSurfaceV6(struct ::wl_client *client, int id, int ver) - : IDSWaylandShellSurface(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgSurfaceV6) +DSWaylandZxdgSurfaceV6::DSWaylandZxdgSurfaceV6(struct ::wl_client *client, int id, int ver, DSWaylandZxdgShellV6 *xdgShell) + : IDSWaylandShellSurface(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgSurfaceV6), + __xdgShell(xdgShell) { this->init(client, id, ver); } DSWaylandZxdgSurfaceV6::~DSWaylandZxdgSurfaceV6() { + if (__xdgShell) + __xdgShell->delSurface(this); } void DSWaylandZxdgSurfaceV6::init(struct ::wl_client *client, int id, int ver) diff --git a/src/DSWaylandServer/DSWaylandZxdgShellV6.h b/src/DSWaylandServer/DSWaylandZxdgShellV6.h index 6eb6446..0ba2f2a 100644 --- a/src/DSWaylandServer/DSWaylandZxdgShellV6.h +++ b/src/DSWaylandServer/DSWaylandZxdgShellV6.h @@ -61,9 +61,11 @@ public: std::list getSurfaceList(); void registerCallbackShellSurfaceCreated(DSObject *slot, std::function func); + void registerCallbackShellSurfaceDestroyed(DSObject *slot, std::function func); public: DSSignal __zxdgSurfaceCreatedSignal; + DSSignal __zxdgSurfaceDestroyedSignal; }; class DSWaylandZxdgPositionerV6 : public DSObject @@ -92,8 +94,8 @@ public: }; public: - DSWaylandZxdgSurfaceV6(); - DSWaylandZxdgSurfaceV6(struct ::wl_client *client, int id, int ver); + DSWaylandZxdgSurfaceV6(DSWaylandZxdgShellV6 *xdgShell); + DSWaylandZxdgSurfaceV6(struct ::wl_client *client, int id, int ver, DSWaylandZxdgShellV6 *xdgShell); virtual ~DSWaylandZxdgSurfaceV6(); void init(struct ::wl_client *client, int id, int ver); @@ -113,6 +115,9 @@ public: void getGeometry(int *x, int *y, int *w, int *h); std::string getWindowTitle(); std::string getAppID(); + +private: + DSWaylandZxdgShellV6 *__xdgShell; }; class DSWaylandZxdgToplevelV6 : public DSObject diff --git a/src/DSWaylandServer/IDSWaylandShell.h b/src/DSWaylandServer/IDSWaylandShell.h index 290efe0..d64a1bc 100644 --- a/src/DSWaylandServer/IDSWaylandShell.h +++ b/src/DSWaylandServer/IDSWaylandShell.h @@ -41,6 +41,7 @@ public: virtual ~IDSWaylandShell() = default; virtual void registerCallbackShellSurfaceCreated(DSObject *slot, std::function func) = 0; + virtual void registerCallbackShellSurfaceDestroyed(DSObject *slot, std::function func) = 0; }; diff --git a/tests/DSWaylandZxdgShellV6-test.cpp b/tests/DSWaylandZxdgShellV6-test.cpp index a0b9bc0..aae14f2 100644 --- a/tests/DSWaylandZxdgShellV6-test.cpp +++ b/tests/DSWaylandZxdgShellV6-test.cpp @@ -47,18 +47,21 @@ TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgShellV6) TEST_F(DSWaylandZxdgShellV6Test, ShellAddSurface) { DSWaylandZxdgShellV6 *zxdgShell = new DSWaylandZxdgShellV6; - DSWaylandZxdgSurfaceV6 *zxdgSurf = new DSWaylandZxdgSurfaceV6; + DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6(zxdgShell); EXPECT_TRUE(zxdgShell != nullptr); - EXPECT_TRUE(zxdgSurf != nullptr); + EXPECT_TRUE(zxdgSurface != nullptr); - zxdgShell->addSurface(zxdgSurf); + zxdgShell->addSurface(zxdgSurface); EXPECT_TRUE(true); + + if (zxdgSurface) delete zxdgSurface; + if (zxdgShell) delete zxdgShell; } TEST_F(DSWaylandZxdgShellV6Test, ShellGetSurfaceList) { DSWaylandZxdgShellV6 *zxdgShell = new DSWaylandZxdgShellV6; - DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6; + DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6(zxdgShell); EXPECT_TRUE(zxdgShell != nullptr); EXPECT_TRUE(zxdgSurface != nullptr); @@ -70,10 +73,8 @@ TEST_F(DSWaylandZxdgShellV6Test, ShellGetSurfaceList) EXPECT_TRUE(*iter == zxdgSurface); } - if (zxdgShell) - delete zxdgShell; - if (zxdgSurface) - delete zxdgSurface; + if (zxdgSurface) delete zxdgSurface; + if (zxdgShell) delete zxdgShell; } TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgPositionerV6) @@ -87,7 +88,7 @@ TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgPositionerV6) TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgSurfaceV6) { - DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6; + DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6(nullptr); EXPECT_TRUE(zxdgSurface != nullptr); if (zxdgSurface) @@ -99,7 +100,7 @@ TEST_F(DSWaylandZxdgShellV6Test, SetSurface) auto dsSurface = std::make_shared(); EXPECT_TRUE(dsSurface != nullptr); - auto zxdgSurface = std::make_shared(); + auto zxdgSurface = std::make_shared(nullptr); EXPECT_TRUE(zxdgSurface != nullptr); if (zxdgSurface && dsSurface) @@ -114,7 +115,7 @@ TEST_F(DSWaylandZxdgShellV6Test, SetSurface) TEST_F(DSWaylandZxdgShellV6Test, SurfaceSetWindowTitle) { - DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6; + DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6(nullptr); std::string inputStr("test"); EXPECT_TRUE(zxdgSurface != nullptr); @@ -127,7 +128,7 @@ TEST_F(DSWaylandZxdgShellV6Test, SurfaceSetWindowTitle) TEST_F(DSWaylandZxdgShellV6Test, SurfaceSetAppID) { - DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6; + DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6(nullptr); std::string inputStr("test"); EXPECT_TRUE(zxdgSurface != nullptr);