From 4ceb0ea7a56359dfe9541a90d24a0ee3889e6145 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Thu, 27 Aug 2020 10:59:48 +0900 Subject: [PATCH] DSZone: add DSWaylandSurface destroyed callback function Change-Id: I4a6f59a68b5850dad82644c2bd6a492fbf19acdb --- src/DSZone/DSZone.cpp | 32 +++++++++++++++++++++++++++++--- src/DSZone/DSZone.h | 1 + 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index f8774da..58ce34c 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -57,7 +57,10 @@ DSZone::DSZone() __waylandShell = __waylandCompositor->getShell(); if (__waylandShell) + { __waylandShell->registerCallbackShellSurfaceCreated(this, std::bind(&DSZone::__onShellSurfaceCreated, this, std::placeholders::_1)); + __waylandShell->registerCallbackShellSurfaceDestroyed(this, std::bind(&DSZone::__onShellSurfaceDestroyed, this, std::placeholders::_1)); + } } __setSupportAuxHints(); @@ -179,7 +182,7 @@ void DSZone::__onSurfaceDestroy(std::shared_ptr waylandSurface void DSZone::__onShellSurfaceCreated(IDSWaylandShellSurface *waylandShellSurface) { - DSLOG_DBG("DSZone", "waylandShellSurface:(pure:%p)", waylandShellSurface); + DSLOG_DBG("DSZone", "Created waylandShellSurface:(pure:%p)", waylandShellSurface); if (waylandShellSurface) { @@ -202,6 +205,31 @@ void DSZone::__onShellSurfaceCreated(IDSWaylandShellSurface *waylandShellSurface } } +void DSZone::__onShellSurfaceDestroyed(IDSWaylandShellSurface *waylandShellSurface) +{ + DSLOG_DBG("DSZone", "Destroyed waylandShellSurface:(pure:%p)", waylandShellSurface); + + if (waylandShellSurface) + { + struct ::wl_resource *wlSurface = waylandShellSurface->getWlSurface(); + DSLOG_DBG("DSZone", "get wl_surface:%p", wlSurface); + + DSWaylandSurface *dsSurface = waylandShellSurface->getSurface(); + DSLOG_DBG("DSZone", "get DSWaylandSurface:%p", dsSurface); + + if (dsSurface) + { + // find DSWindowShell associated with DSWaylandSurface + DSWindowShell *dsWinShell = __findWindowShell(dsSurface); + if (dsWinShell) + { + DSLOG_DBG("DSZONE", "Find DSWindowShell (%p)... setShellSurface to nullptr!", dsWinShell); + dsWinShell->setShellSurface(nullptr); + } + } + } +} + // for Test void DSZone::callCallbackWindowShellCreated(std::shared_ptr winShell) { @@ -278,8 +306,6 @@ DSWindowShell *DSZone::__findWindowShell(DSWaylandSurface *dswlSurface) } dsWinShell = iter->second; - DSLOG_DBG("DSZone", "Find DSWindowShell(%p)... DSWaylandSurface(%p)", dsWinShell, dswlSurface); - return dsWinShell; } diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h index 48df95a..338d070 100644 --- a/src/DSZone/DSZone.h +++ b/src/DSZone/DSZone.h @@ -95,6 +95,7 @@ private: void __onSurfaceDestroy(std::shared_ptr waylandSurface); void __onShellSurfaceCreated(IDSWaylandShellSurface *waylandShellSurface); + void __onShellSurfaceDestroyed(IDSWaylandShellSurface *waylandShellSurface); std::shared_ptr __createWindow(std::shared_ptr waylandSurface); void __destroyWindow(std::shared_ptr window); -- 2.7.4