add minimizedbyother config

Signed-off-by: leafly2021 <figo.yefei@huawei.com>
Change-Id: Id16e5e5811bd46834fe6ffa6cd0520d2fa133f98
This commit is contained in:
leafly2021 2022-04-24 09:00:34 +08:00
parent a072edc80a
commit 19ec96658d
7 changed files with 38 additions and 5 deletions

View File

@ -16,4 +16,6 @@
<Configs>
<!--decor enable is true means app main window show decoration-->
<decor enable="true"></decor>
<!--minimizeByOther enable is true means fullscreen window will be minmized by other fullscreen window-->
<minimizeByOther enable="true"></minimizeByOther>
</Configs>

View File

@ -17,4 +17,6 @@
<!--decor enable is true means app main window show decoration-->
<decor enable="false"></decor>
<maxAppWindowNumber>100</maxAppWindowNumber>
<!--minimizeByOther enable is true means fullscreen window will be minmized by other fullscreen window-->
<minimizeByOther enable="true"></minimizeByOther>
</Configs>

View File

@ -31,7 +31,7 @@ namespace Rosen {
using WindowNodeOperationFunc = std::function<bool(sptr<WindowNode>)>; // return true indicates to stop traverse
class WindowNodeContainer : public RefBase {
public:
WindowNodeContainer(DisplayId displayId, uint32_t width, uint32_t height);
WindowNodeContainer(DisplayId displayId, uint32_t width, uint32_t height, bool isMinimizedByOther);
~WindowNodeContainer();
WMError AddWindowNode(sptr<WindowNode>& node, sptr<WindowNode>& parentNode);
WMError RemoveWindowNode(sptr<WindowNode>& node);
@ -144,6 +144,8 @@ private:
void RaiseInputMethodWindowPriorityIfNeeded(const sptr<WindowNode>& node) const;
void RaiseShowWhenLockedWindowIfNeeded(const sptr<WindowNode>& node);
void ReZOrderShowWhenLockedWindows(const sptr<WindowNode>& node, bool up);
bool isMinimizedByOther_ = true;
};
} // namespace Rosen
} // namespace OHOS

View File

@ -71,6 +71,7 @@ public:
void UpdateFocusableProperty(uint32_t windowId);
WMError GetAccessibilityWindowInfo(sptr<AccessibilityWindowInfo>& windowInfo);
void SetMaxAppWindowNumber(int windowNum);
void SetMinimizedByOtherWindow(bool isMinimizedByOtherWindow);
private:
void OnRemoteDied(const sptr<IRemoteObject>& remoteObject);
@ -90,6 +91,7 @@ private:
std::map<uint32_t, sptr<WindowNode>> windowNodeMap_;
std::map<sptr<IRemoteObject>, uint32_t> windowIdMap_;
bool needCheckFocusWindow = false;
bool isMinimizedByOtherWindow_ = true;
std::map<WindowManagerAgentType, std::vector<sptr<IWindowManagerAgent>>> windowManagerAgents_;

View File

@ -177,6 +177,18 @@ bool WindowManagerService::ParseChildNode(xmlNode* child)
} else {
windowRoot_->SetMaxAppWindowNumber(maxAppWindowNumber);
}
} else if (!xmlStrcmp(child->name, reinterpret_cast<const xmlChar*>("minimizeByOther"))) {
char* enable = reinterpret_cast<char*>(xmlGetProp(child, reinterpret_cast<const xmlChar*>("enable")));
if (!enable) {
return false;
}
if (!strcmp(enable, "false")) {
windowRoot_->SetMinimizedByOtherWindow(false);
} else if (!strcmp(enable, "true")) {
windowRoot_->SetMinimizedByOtherWindow(true);
} else {
WLOGFW("Invalid resource prop");
}
}
return true;

View File

@ -45,7 +45,8 @@ namespace {
constexpr uint32_t MAX_BRIGHTNESS = 255;
}
WindowNodeContainer::WindowNodeContainer(DisplayId displayId, uint32_t width, uint32_t height) : displayId_(displayId)
WindowNodeContainer::WindowNodeContainer(DisplayId displayId, uint32_t width, uint32_t height, bool isMinimizedByOther)
: displayId_(displayId), isMinimizedByOther_(isMinimizedByOther)
{
displayRect_ = {
.posX_ = 0,
@ -1094,6 +1095,10 @@ void WindowNodeContainer::MinimizeWindowFromAbility(const sptr<WindowNode>& node
WLOGFW("Target abilityToken is nullptr, windowId:%{public}u", node->GetWindowId());
return;
}
WLOGFI("minimize window fromUser:%{public}d, isMinimizedByOther:%{public}d", fromUser, isMinimizedByOther_);
if (!fromUser && !isMinimizedByOther_) {
return;
}
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(node->abilityToken_, fromUser);
}

View File

@ -45,10 +45,12 @@ sptr<WindowNodeContainer> WindowRoot::GetOrCreateWindowNodeContainer(DisplayId d
return nullptr;
}
WLOGFI("create new window node container display width:%{public}d, height:%{public}d, screenId:%{public}" PRIu64"",
displayInfo->GetWidth(), displayInfo->GetHeight(), displayInfo->GetDisplayId());
WLOGFI("create new window node container display width:%{public}d, height:%{public}d, " \
"isMinimized:%{public}d, screenId:%{public}" PRIu64"", displayInfo->GetWidth(),
displayInfo->GetHeight(), isMinimizedByOtherWindow_, displayInfo->GetDisplayId());
sptr<WindowNodeContainer> container = new WindowNodeContainer(displayInfo->GetDisplayId(),
static_cast<uint32_t>(displayInfo->GetWidth()), static_cast<uint32_t>(displayInfo->GetHeight()));
static_cast<uint32_t>(displayInfo->GetWidth()), static_cast<uint32_t>(displayInfo->GetHeight()),
isMinimizedByOtherWindow_);
windowNodeContainerMap_.insert(std::make_pair(displayId, container));
return container;
}
@ -826,5 +828,11 @@ void WindowRoot::SetMaxAppWindowNumber(int windowNum)
{
maxAppWindowNumber_ = windowNum;
}
void WindowRoot::SetMinimizedByOtherWindow(bool isMinimizedByOtherWindow)
{
WLOGFI("isMinimizedByOtherWindow:%{public}d", isMinimizedByOtherWindow);
isMinimizedByOtherWindow_ = isMinimizedByOtherWindow;
}
} // namespace OHOS::Rosen
} // namespace OHOS