DSTraceInfo: print out windows' infomation(pid,title,,etc.) 69/242769/1
authorDuna Oh <duna.oh@samsung.com>
Fri, 28 Aug 2020 06:33:51 +0000 (15:33 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Tue, 1 Sep 2020 01:29:30 +0000 (10:29 +0900)
Change-Id: Ib786d3b9139b41bbe93eec8faba071c76d749800

samples/exampleCompositor.cpp
src/DSTraceInfo/DSTraceInfo.cpp [new file with mode: 0644]
src/DSTraceInfo/DSTraceInfo.h [new file with mode: 0644]
src/meson.build

index 27787f5..a7b23a2 100644 (file)
@@ -29,6 +29,7 @@
 #include <DSPolicyArea.h>
 #include <DSDisplayArea.h>
 #include <DSTextInput.h>
+#include <DSTraceInfo.h>
 #include "DSDebugLog.h"
 
 using namespace display_server;
@@ -70,6 +71,9 @@ public:
 
                __textInput = std::make_shared<DSTextInput>();
 
+               __traceInfo = std::make_shared<DSTraceInfo>();
+               __traceInfo->attachPolicyArea(__policyArea);
+
                return __canvas;
        }
 
@@ -103,6 +107,7 @@ private:
        std::shared_ptr<DSPolicyArea> __policyArea;
        std::shared_ptr<DSDisplayArea> __displayArea;
        std::shared_ptr<DSTextInput> __textInput;
+       std::shared_ptr<DSTraceInfo> __traceInfo;
 };
 
 int main() {
diff --git a/src/DSTraceInfo/DSTraceInfo.cpp b/src/DSTraceInfo/DSTraceInfo.cpp
new file mode 100644 (file)
index 0000000..608c562
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+* 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
diff --git a/src/DSTraceInfo/DSTraceInfo.h b/src/DSTraceInfo/DSTraceInfo.h
new file mode 100644 (file)
index 0000000..35a6516
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+* 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
index 62c7b30..9facc3c 100644 (file)
@@ -78,6 +78,8 @@ libds_srcs = [
        'DSTextInput/DSTextInput.cpp',
        'DSUtil/DSUtilSocket.h',
        'DSUtil/DSUtilSocket.cpp',
+       'DSTraceInfo/DSTraceInfo.h',
+       'DSTraceInfo/DSTraceInfo.cpp',
        ]
 
 libds_wayland_srcs = [
@@ -255,6 +257,7 @@ libds_include_dirs = include_directories(
        './DSTextInput',
        './DSTizenAppinfo',
        './DSUtil',
+       './DSTraceInfo',
        )
 
 libds_lib = shared_library(