__zxdgSurfaceCreatedSignal.connect(slot, func);
}
+void DSWaylandZxdgShellV6::registerCallbackShellSurfaceDestroyed(DSObject *slot, std::function<void(IDSWaylandShellSurface*)> func)
+{
+ __zxdgSurfaceDestroyedSignal.connect(slot, func);
+}
DSWaylandZxdgShellV6Private::DSWaylandZxdgShellV6Private(DSWaylandZxdgShellV6 *p_ptr)
: DSObjectPrivate(p_ptr), __p_ptr(p_ptr)
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);
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)
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);
}
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)
std::list<DSWaylandZxdgSurfaceV6 *> getSurfaceList();
void registerCallbackShellSurfaceCreated(DSObject *slot, std::function<void(IDSWaylandShellSurface*)> func);
+ void registerCallbackShellSurfaceDestroyed(DSObject *slot, std::function<void(IDSWaylandShellSurface*)> func);
public:
DSSignal<DSWaylandZxdgSurfaceV6*> __zxdgSurfaceCreatedSignal;
+ DSSignal<DSWaylandZxdgSurfaceV6*> __zxdgSurfaceDestroyedSignal;
};
class DSWaylandZxdgPositionerV6 : public DSObject
};
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);
void getGeometry(int *x, int *y, int *w, int *h);
std::string getWindowTitle();
std::string getAppID();
+
+private:
+ DSWaylandZxdgShellV6 *__xdgShell;
};
class DSWaylandZxdgToplevelV6 : public DSObject
virtual ~IDSWaylandShell() = default;
virtual void registerCallbackShellSurfaceCreated(DSObject *slot, std::function<void(IDSWaylandShellSurface*)> func) = 0;
+ virtual void registerCallbackShellSurfaceDestroyed(DSObject *slot, std::function<void(IDSWaylandShellSurface*)> func) = 0;
};
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);
EXPECT_TRUE(*iter == zxdgSurface);
}
- if (zxdgShell)
- delete zxdgShell;
- if (zxdgSurface)
- delete zxdgSurface;
+ if (zxdgSurface) delete zxdgSurface;
+ if (zxdgShell) delete zxdgShell;
}
TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgPositionerV6)
TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgSurfaceV6)
{
- DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6;
+ DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6(nullptr);
EXPECT_TRUE(zxdgSurface != nullptr);
if (zxdgSurface)
auto dsSurface = std::make_shared<DSWaylandSurface>();
EXPECT_TRUE(dsSurface != nullptr);
- auto zxdgSurface = std::make_shared<DSWaylandZxdgSurfaceV6>();
+ auto zxdgSurface = std::make_shared<DSWaylandZxdgSurfaceV6>(nullptr);
EXPECT_TRUE(zxdgSurface != nullptr);
if (zxdgSurface && dsSurface)
TEST_F(DSWaylandZxdgShellV6Test, SurfaceSetWindowTitle)
{
- DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6;
+ DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6(nullptr);
std::string inputStr("test");
EXPECT_TRUE(zxdgSurface != nullptr);
TEST_F(DSWaylandZxdgShellV6Test, SurfaceSetAppID)
{
- DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6;
+ DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6(nullptr);
std::string inputStr("test");
EXPECT_TRUE(zxdgSurface != nullptr);