mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
add WindowName for debug
Signed-off-by: maojiangping <maojiangping@huawei.com> Change-Id: Ic633ded829724b068670348110938451aa5805df Signed-off-by: maojiangping <maojiangping@huawei.com>
This commit is contained in:
@@ -58,6 +58,7 @@ private:
|
||||
DisplayId displayId_ = DEFAULT_DISPLAY_ID;
|
||||
|
||||
std::shared_ptr<AbilityRuntime::Context> context_ = nullptr;
|
||||
std::string GenerateMainWindowName(const std::shared_ptr<AbilityRuntime::Context>& context) const;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
WindowProperty() = default;
|
||||
~WindowProperty() = default;
|
||||
|
||||
void SetWindowName(const std::string& name);
|
||||
void SetWindowRect(const struct Rect& rect);
|
||||
void SetWindowType(WindowType type);
|
||||
void SetWindowMode(WindowMode mode);
|
||||
@@ -46,6 +47,7 @@ public:
|
||||
void SetSystemBarProperty(WindowType type, const SystemBarProperty& state);
|
||||
void SetDecorEnable(bool decorEnable);
|
||||
|
||||
const std::string& GetWindowName() const;
|
||||
Rect GetWindowRect() const;
|
||||
WindowType GetWindowType() const;
|
||||
WindowMode GetWindowMode() const;
|
||||
@@ -65,6 +67,7 @@ public:
|
||||
virtual bool Marshalling(Parcel& parcel) const override;
|
||||
static sptr<WindowProperty> Unmarshalling(Parcel& parcel);
|
||||
private:
|
||||
std::string windowName_;
|
||||
Rect windowRect_ { 0, 0, 0, 0 };
|
||||
WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW };
|
||||
WindowMode mode_ { WindowMode::WINDOW_MODE_FULLSCREEN };
|
||||
|
||||
@@ -18,6 +18,11 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
void WindowProperty::SetWindowName(const std::string& name)
|
||||
{
|
||||
windowName_ = name;
|
||||
}
|
||||
|
||||
void WindowProperty::SetWindowRect(const struct Rect& rect)
|
||||
{
|
||||
windowRect_ = rect;
|
||||
@@ -96,6 +101,11 @@ void WindowProperty::ResumeLastWindowMode()
|
||||
mode_ = lastMode_;
|
||||
}
|
||||
|
||||
const std::string& WindowProperty::GetWindowName() const
|
||||
{
|
||||
return windowName_ ;
|
||||
}
|
||||
|
||||
Rect WindowProperty::GetWindowRect() const
|
||||
{
|
||||
return windowRect_;
|
||||
@@ -212,6 +222,11 @@ void WindowProperty::MapUnmarshalling(Parcel& parcel, sptr<WindowProperty>& prop
|
||||
|
||||
bool WindowProperty::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
// write windowName_
|
||||
if (!parcel.WriteString(windowName_)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// write windowRect_
|
||||
if (!(parcel.WriteInt32(windowRect_.posX_) && parcel.WriteInt32(windowRect_.posY_) &&
|
||||
parcel.WriteUint32(windowRect_.width_) && parcel.WriteUint32(windowRect_.height_))) {
|
||||
@@ -293,6 +308,7 @@ bool WindowProperty::Marshalling(Parcel& parcel) const
|
||||
sptr<WindowProperty> WindowProperty::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sptr<WindowProperty> property(new WindowProperty());
|
||||
property->SetWindowName(parcel.ReadString());
|
||||
Rect rect = { parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadUint32(), parcel.ReadUint32() };
|
||||
property->SetWindowRect(rect);
|
||||
property->SetWindowType(static_cast<WindowType>(parcel.ReadUint32()));
|
||||
|
||||
@@ -39,6 +39,7 @@ std::map<uint32_t, std::vector<sptr<Window>>> WindowImpl::subWindowMap_;
|
||||
WindowImpl::WindowImpl(const sptr<WindowOption>& option)
|
||||
{
|
||||
property_ = new WindowProperty();
|
||||
property_->SetWindowName(option->GetWindowName());
|
||||
property_->SetWindowRect(option->GetWindowRect());
|
||||
property_->SetWindowType(option->GetWindowType());
|
||||
property_->SetWindowMode(option->GetWindowMode());
|
||||
@@ -55,6 +56,7 @@ WindowImpl::WindowImpl(const sptr<WindowOption>& option)
|
||||
callback_->onCallback = std::bind(&WindowImpl::OnVsync, this, std::placeholders::_1);
|
||||
|
||||
struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
|
||||
rsSurfaceNodeConfig.SurfaceNodeName = property_->GetWindowName();
|
||||
surfaceNode_ = RSSurfaceNode::Create(rsSurfaceNodeConfig);
|
||||
}
|
||||
|
||||
|
||||
+13
-1
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "window_scene.h"
|
||||
|
||||
#include <configuration.h>
|
||||
|
||||
#include "static_call.h"
|
||||
@@ -47,7 +48,7 @@ WMError WindowScene::Init(DisplayId displayId, const std::shared_ptr<AbilityRunt
|
||||
option->SetDisplayId(displayId);
|
||||
|
||||
mainWindow_ = SingletonContainer::Get<StaticCall>().CreateWindow(
|
||||
MAIN_WINDOW_ID + std::to_string(count++), option, context);
|
||||
GenerateMainWindowName(context), option, context);
|
||||
if (mainWindow_ == nullptr) {
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
@@ -56,6 +57,17 @@ WMError WindowScene::Init(DisplayId displayId, const std::shared_ptr<AbilityRunt
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
std::string WindowScene::GenerateMainWindowName(const std::shared_ptr<AbilityRuntime::Context>& context) const
|
||||
{
|
||||
if (context == nullptr) {
|
||||
return MAIN_WINDOW_ID + std::to_string(count++);
|
||||
} else {
|
||||
std::string windowName = context->GetBundleName() + std::to_string(count++);
|
||||
std::size_t pos = windowName.find_last_of('.');
|
||||
return (pos < 0) ? windowName : windowName.substr(pos + 1); // skip '.'
|
||||
}
|
||||
}
|
||||
|
||||
sptr<Window> WindowScene::CreateWindow(const std::string& windowName, sptr<WindowOption>& option) const
|
||||
{
|
||||
if (windowName.empty() || mainWindow_ == nullptr || option == nullptr) {
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
const sptr<IWindow>& GetWindowToken() const;
|
||||
uint32_t GetWindowId() const;
|
||||
uint32_t GetParentId() const;
|
||||
const std::string& GetWindowName() const;
|
||||
DisplayId GetDisplayId() const;
|
||||
const Rect& GetLayoutRect() const;
|
||||
WindowType GetWindowType() const;
|
||||
|
||||
@@ -58,6 +58,11 @@ DisplayId WindowNode::GetDisplayId() const
|
||||
return property_->GetDisplayId();
|
||||
}
|
||||
|
||||
const std::string& WindowNode::GetWindowName() const
|
||||
{
|
||||
return property_->GetWindowName();
|
||||
}
|
||||
|
||||
uint32_t WindowNode::GetWindowId() const
|
||||
{
|
||||
return property_->GetWindowId();
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "WindowNodeContainer"};
|
||||
constexpr int WINDOW_NAME_MAX_LENGTH = 10;
|
||||
}
|
||||
|
||||
WindowNodeContainer::WindowNodeContainer(uint64_t screenId, uint32_t width, uint32_t height) : screenId_(screenId)
|
||||
@@ -644,15 +645,18 @@ void WindowNodeContainer::OnAvoidAreaChange(const std::vector<Rect>& avoidArea)
|
||||
void WindowNodeContainer::DumpScreenWindowTree()
|
||||
{
|
||||
WLOGFI("-------- Screen %{public}" PRIu64" dump window info begin---------", screenId_);
|
||||
WLOGFI("WinId Type Mode Flag ZOrd [ x y w h]");
|
||||
WLOGFI("WindowName WinId Type Mode Flag ZOrd [ x y w h]");
|
||||
std::vector<sptr<WindowNode>> windowNodes;
|
||||
TraverseContainer(windowNodes);
|
||||
int zOrder = windowNodes.size();
|
||||
for (auto node : windowNodes) {
|
||||
Rect rect = node->GetLayoutRect();
|
||||
WLOGFI("%{public}5d %{public}4d %{public}4d %{public}4d %{public}4d [%{public}4d %{public}4d " \
|
||||
"%{public}4d %{public}4d]", node->GetWindowId(), node->GetWindowType(), node->GetWindowMode(),
|
||||
node->GetWindowFlags(), --zOrder, rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
const std::string& windowName = node->GetWindowName().size() < WINDOW_NAME_MAX_LENGTH ?
|
||||
node->GetWindowName() : node->GetWindowName().substr(0, WINDOW_NAME_MAX_LENGTH);
|
||||
WLOGFI("%{public}10s %{public}5d %{public}4d %{public}4d %{public}4d %{public}4d [%{public}4d %{public}4d " \
|
||||
"%{public}4d %{public}4d]", windowName.c_str(), node->GetWindowId(), node->GetWindowType(),
|
||||
node->GetWindowMode(), node->GetWindowFlags(),
|
||||
--zOrder, rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
}
|
||||
WLOGFI("-------- Screen %{public}" PRIu64" dump window info end ---------", screenId_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user