From 942b2a4c077056ca7fd75e131eefcd8dc55f9337 Mon Sep 17 00:00:00 2001 From: Duna Oh Date: Fri, 28 Aug 2020 15:33:51 +0900 Subject: [PATCH] DSTraceInfo: print out windows' infomation(pid,title,,etc.) Change-Id: Ib786d3b9139b41bbe93eec8faba071c76d749800 --- samples/exampleCompositor.cpp | 5 ++ src/DSTraceInfo/DSTraceInfo.cpp | 118 ++++++++++++++++++++++++++++++++++++++++ src/DSTraceInfo/DSTraceInfo.h | 62 +++++++++++++++++++++ src/meson.build | 3 + 4 files changed, 188 insertions(+) create mode 100644 src/DSTraceInfo/DSTraceInfo.cpp create mode 100644 src/DSTraceInfo/DSTraceInfo.h diff --git a/samples/exampleCompositor.cpp b/samples/exampleCompositor.cpp index 27787f5..a7b23a2 100644 --- a/samples/exampleCompositor.cpp +++ b/samples/exampleCompositor.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include "DSDebugLog.h" using namespace display_server; @@ -70,6 +71,9 @@ public: __textInput = std::make_shared(); + __traceInfo = std::make_shared(); + __traceInfo->attachPolicyArea(__policyArea); + return __canvas; } @@ -103,6 +107,7 @@ private: std::shared_ptr __policyArea; std::shared_ptr __displayArea; std::shared_ptr __textInput; + std::shared_ptr __traceInfo; }; int main() { diff --git a/src/DSTraceInfo/DSTraceInfo.cpp b/src/DSTraceInfo/DSTraceInfo.cpp new file mode 100644 index 0000000..608c562 --- /dev/null +++ b/src/DSTraceInfo/DSTraceInfo.cpp @@ -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 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 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 window) +{ + __windowList.remove(window); + __windowList.push_front(window); + + __windowUpdated = true; +} + +void DSTraceInfo::__onWindowStackChanged(std::shared_ptr window) +{ + __windowList = __zone->getWindowList(); + + __windowUpdated = true; +} + +void DSTraceInfo::__onWindowDestroy(std::shared_ptr 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 index 0000000..35a6516 --- /dev/null +++ b/src/DSTraceInfo/DSTraceInfo.h @@ -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 +#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 policyArea); + void printWindowsInfo(); + +private: + void __onWindowCreated(std::shared_ptr window); + void __onWindowStackChanged(std::shared_ptr window); + void __onWindowDestroy(std::shared_ptr window); + + void __onEventIdleEnterer(void *data); + + std::shared_ptr __policyArea; + std::shared_ptr __zone; + std::list> __windowList; + + DSEventLoop *__eventLoop; + bool __windowUpdated; +}; + +} + +#endif \ No newline at end of file diff --git a/src/meson.build b/src/meson.build index 62c7b30..9facc3c 100644 --- a/src/meson.build +++ b/src/meson.build @@ -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( -- 2.7.4