--- /dev/null
+/*
+* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#include "DSTraceInfo.h"
+#include "DSPolicyAreaPrivate.h"
+
+namespace display_server
+{
+DSTraceInfo::DSTraceInfo()
+ : __policyArea(nullptr),
+ __zone(nullptr),
+ __eventLoop(nullptr),
+ __windowUpdated(false)
+{
+ __eventLoop = DSEventLoop::getInstance();
+ if (__eventLoop)
+ __eventLoop->registerCallbackIdleEnterer(this, std::bind(&DSTraceInfo::__onEventIdleEnterer, this, std::placeholders::_1));
+}
+
+DSTraceInfo::~DSTraceInfo()
+{
+ if (__eventLoop)
+ DSEventLoop::releaseInstance();
+}
+
+bool DSTraceInfo::attachPolicyArea(std::shared_ptr<DSPolicyArea> policyArea)
+{
+ __policyArea = policyArea;
+
+ DSPolicyAreaPrivate *policyAreaPriv = DSPolicyAreaPrivate::getPrivate(__policyArea.get());
+ __zone = policyAreaPriv->getZone();
+
+ if (__zone == nullptr) {
+ DSLOG_ERR("DSTraceInfo", "No zone attached to this policyArea(%p)", policyArea);
+ return false;
+ }
+
+ __zone->registerCallbackWindowCreated(this, std::bind(&DSTraceInfo::__onWindowCreated, this, std::placeholders::_1));
+ __zone->registerCallbackWindowStackChanged(this, std::bind(&DSTraceInfo::__onWindowStackChanged, this, std::placeholders::_1));
+ __zone->registerCallbackWindowDestroy(this, std::bind(&DSTraceInfo::__onWindowDestroy, this, std::placeholders::_1));
+
+ __windowList = __zone->getWindowList();
+
+ return true;
+}
+
+void DSTraceInfo::__onEventIdleEnterer(void *data)
+{
+ if (__windowUpdated)
+ {
+ printWindowsInfo();
+ __windowUpdated = false;
+ }
+}
+
+void DSTraceInfo::printWindowsInfo()
+{
+ DSLOG_INF("DSTraceInfo", "--------------Top level windows: %d--------------", __windowList.size());
+ DSLOG_INF("DSTraceInfo", " No Win_ID PID w h x y (S)kipFoc has(F)ocus (U)serGeom (V)kbdFloating Parent Title");
+
+ for (std::shared_ptr<DSWindow> w : __windowList)
+ {
+ stPosition pos = w->getPosition();
+ stSize sz = w->getSize();
+ DSWaylandSurface *dwlSurface = w->surface();
+ DSWaylandClient *dwClient = dwlSurface->getClient();
+ pid_t pid = dwClient->pid();
+ DSLOG_INF("DSTraceInfo", " %d: %p %d %4d %4d %4d %4d %c %c %c %c %p %s", w->getZOrder(), w.get(), pid, \
+ sz.w, sz.h, pos.x, pos.y, w->getSkipFocus()?'S':' ', w->hasFocus()?'F':' ', w->isAllowUserGeometry()?'U':' ', w->getVkbdFloating()?'V':' ', \
+ w->getParent(), (w->getTitle().compare("") == 0)?"No Title":w->getTitle().c_str());
+ }
+
+ DSLOG_INF("DSTraceInfo", "------------------------------------------------");
+}
+
+void DSTraceInfo::__onWindowCreated(std::shared_ptr<DSWindow> window)
+{
+ __windowList.remove(window);
+ __windowList.push_front(window);
+
+ __windowUpdated = true;
+}
+
+void DSTraceInfo::__onWindowStackChanged(std::shared_ptr<DSWindow> window)
+{
+ __windowList = __zone->getWindowList();
+
+ __windowUpdated = true;
+}
+
+void DSTraceInfo::__onWindowDestroy(std::shared_ptr<DSWindow> window)
+{
+ __windowList.remove(window);
+
+ __windowUpdated = true;
+}
+
+}
\ No newline at end of file
--- /dev/null
+/*
+* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __DS_TRACE_INFO_H__
+#define __DS_TRACE_INFO_H__
+
+#include <DSCore.h>
+#include "DSSignal.h"
+#include "DSWindow.h"
+#include "DSPolicyArea.h"
+#include "DSZone.h"
+#include "DSEventLoop.h"
+
+namespace display_server
+{
+
+class DSTraceInfo : public DSObject
+{
+public:
+ explicit DSTraceInfo();
+ virtual ~DSTraceInfo();
+ bool attachPolicyArea(std::shared_ptr<DSPolicyArea> policyArea);
+ void printWindowsInfo();
+
+private:
+ void __onWindowCreated(std::shared_ptr<DSWindow> window);
+ void __onWindowStackChanged(std::shared_ptr<DSWindow> window);
+ void __onWindowDestroy(std::shared_ptr<DSWindow> window);
+
+ void __onEventIdleEnterer(void *data);
+
+ std::shared_ptr<DSPolicyArea> __policyArea;
+ std::shared_ptr<DSZone> __zone;
+ std::list<std::shared_ptr<DSWindow>> __windowList;
+
+ DSEventLoop *__eventLoop;
+ bool __windowUpdated;
+};
+
+}
+
+#endif
\ No newline at end of file