2 * Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #include "DSTraceInfo.h"
25 #include "DSPolicyAreaPrivate.h"
27 namespace display_server
29 DSTraceInfo::DSTraceInfo()
30 : __policyArea(nullptr),
33 __windowUpdated(false)
35 __eventLoop = DSEventLoop::getInstance();
37 __eventLoop->registerCallbackIdleEnterer(this, std::bind(&DSTraceInfo::__onEventIdleEnterer, this, std::placeholders::_1));
40 DSTraceInfo::~DSTraceInfo()
43 DSEventLoop::releaseInstance();
46 bool DSTraceInfo::attachPolicyArea(std::shared_ptr<DSPolicyArea> policyArea)
48 __policyArea = policyArea;
50 DSPolicyAreaPrivate *policyAreaPriv = DSPolicyAreaPrivate::getPrivate(__policyArea.get());
51 __zone = policyAreaPriv->getZone();
53 if (__zone == nullptr) {
54 DSLOG_ERR("DSTraceInfo", "No zone attached to this policyArea(%p)", policyArea);
58 __zone->registerCallbackWindowCreated(this, std::bind(&DSTraceInfo::__onWindowCreated, this, std::placeholders::_1));
59 __zone->registerCallbackWindowStackChanged(this, std::bind(&DSTraceInfo::__onWindowStackChanged, this, std::placeholders::_1));
60 __zone->registerCallbackWindowDestroy(this, std::bind(&DSTraceInfo::__onWindowDestroy, this, std::placeholders::_1));
62 __windowList = __zone->getWindowList();
67 void DSTraceInfo::__onEventIdleEnterer(void *data)
72 __windowUpdated = false;
76 void DSTraceInfo::printWindowsInfo()
78 DSLOG_INF("DSTraceInfo", "--------------Top level windows: %d--------------", __windowList.size());
79 DSLOG_INF("DSTraceInfo", " No Win_ID PID w h x y (S)kipFoc has(F)ocus (U)serGeom (V)kbdFloating Parent Title");
81 for (std::shared_ptr<DSWindow> w : __windowList)
83 stPosition pos = w->getPosition();
84 stSize sz = w->getSize();
85 DSWaylandSurface *dwlSurface = w->surface();
86 DSWaylandClient *dwClient = dwlSurface->getClient();
87 pid_t pid = dwClient->pid();
88 DSLOG_INF("DSTraceInfo", " %d: %p %d %4d %4d %4d %4d %c %c %c %c %p %s", w->getZOrder(), w.get(), pid, \
89 sz.w, sz.h, pos.x, pos.y, w->getSkipFocus()?'S':' ', w->hasFocus()?'F':' ', w->isAllowUserGeometry()?'U':' ', w->getVkbdFloating()?'V':' ', \
90 w->getParent(), (w->getTitle().compare("") == 0)?"No Title":w->getTitle().c_str());
93 DSLOG_INF("DSTraceInfo", "------------------------------------------------");
96 void DSTraceInfo::__onWindowCreated(std::shared_ptr<DSWindow> window)
98 __windowList.remove(window);
99 __windowList.push_front(window);
101 __windowUpdated = true;
104 void DSTraceInfo::__onWindowStackChanged(std::shared_ptr<DSWindow> window)
106 __windowList = __zone->getWindowList();
108 __windowUpdated = true;
111 void DSTraceInfo::__onWindowDestroy(std::shared_ptr<DSWindow> window)
113 __windowList.remove(window);
115 __windowUpdated = true;