{
__waylandCompositor = DSWaylandCompositor::getInstance();
__waylandCompositor->registerCallbackSurfaceCreated(this, std::bind(&DSZone::__onSurfaceCreated, this, std::placeholders::_1));
+ __waylandCompositor->registerCallbackSurfaceDestroy(this, std::bind(&DSZone::__onSurfaceDestroy, this, std::placeholders::_1));
__waylandShell = __waylandCompositor->getShell();
if (__waylandShell)
window->setWindowShell(shell.get());
}
+void DSZone::__onSurfaceDestroy(std::shared_ptr<DSWaylandSurface> waylandSurface)
+{
+ DSWaylandSurface *dswSurfacePtr = waylandSurface.get();
+
+ DSWindowShell *shell = __findWindowShell(dswSurfacePtr);
+ __destroyWindowShell(shell, dswSurfacePtr);
+
+ std::shared_ptr<DSWindow> window = __findWindow(dswSurfacePtr);
+ __destroyWindow(window);
+}
+
void DSZone::__onShellSurfaceCreated(IDSWaylandShellSurface *waylandShellSurface)
{
DSLOG_DBG("DSZone", "waylandShellSurface:(pure:%p)", waylandShellSurface);
return __windowList;
}
+std::list<std::shared_ptr<DSWindowShell>> DSZone::getWindowShellList()
+{
+ return __windowShellList;
+}
+
std::shared_ptr<DSWindow> DSZone::__findWindow(DSWaylandSurface *dswlSurface)
{
std::list<std::shared_ptr<DSWindow>> wList = getWindowList();
return window;
}
+void DSZone::__destroyWindow(std::shared_ptr<DSWindow> window)
+{
+ __windowDestroySignal.emit(window);
+ __windowList.remove(window);
+}
+
std::shared_ptr<DSWindowShell> DSZone::__createWindowShell(std::shared_ptr<DSWindow> window)
{
DSWindow *ptrWindow = window.get();
std::shared_ptr<DSWindowShell> shell = std::make_shared<DSWindowShell>(ptrWindow);
__windowShellList.push_front(shell);
+
__windowShellMap.insert(std::make_pair(ptrWindow->surface(), shell.get()));
shell->setGeometry(__position.x, __position.y, __size.w, __size.h);
return shell;
}
+void DSZone::__destroyWindowShell(DSWindowShell* windowShell, DSWaylandSurface *surface)
+{
+ // remove from map
+ __windowShellMap.erase(surface);
+
+ // remove from __windowShellList
+ std::list<std::shared_ptr<DSWindowShell>> wsList = getWindowShellList();
+ for (auto ws : wsList)
+ {
+ if (ws.get() == windowShell)
+ {
+ __windowShellDestroySignal.emit(ws);
+ __windowShellList.remove(ws);
+ break;
+ }
+ }
+}
} // namespace display_server
void callCallbackWindowShellCreated();
std::list<std::shared_ptr<DSWindow>> getWindowList();
+ std::list<std::shared_ptr<DSWindowShell>> getWindowShellList();
private:
void __onSurfaceCreated(std::shared_ptr<DSWaylandSurface> waylandSurface);
+ void __onSurfaceDestroy(std::shared_ptr<DSWaylandSurface> waylandSurface);
+
void __onShellSurfaceCreated(IDSWaylandShellSurface *waylandShellSurface);
+
std::shared_ptr<DSWindow> __createWindow(std::shared_ptr<DSWaylandSurface> waylandSurface);
+ void __destroyWindow(std::shared_ptr<DSWindow> window);
+
std::shared_ptr<DSWindowShell> __createWindowShell(std::shared_ptr<DSWindow> window);
+ void __destroyWindowShell(DSWindowShell* windowShell, DSWaylandSurface *surface);
+
std::shared_ptr<DSWindow> __findWindow(DSWaylandSurface *dswlSurface);
DSWindowShell* __findWindowShell(DSWaylandSurface *dswlSurface);
// signals
DSSignal<std::shared_ptr<DSWindow>> __windowCreatedSignal;
+ DSSignal<std::shared_ptr<DSWindow>> __windowDestroySignal;
DSSignal<std::shared_ptr<DSWindowShell>> __windowShellCreatedSignal;
+ DSSignal<std::shared_ptr<DSWindowShell>> __windowShellDestroySignal;
};
}