support two user-defined exit-split-mode ratios

Signed-off-by: wlj <wangliangjiang1@huawei.com>
Change-Id: I3303b64f104d7cc8b663ac10dc3c31913b1c55f1
This commit is contained in:
wlj 2022-06-09 17:36:22 +08:00
parent 3516b631c6
commit 4cd447c3b8
10 changed files with 25 additions and 17 deletions

View File

@ -19,7 +19,7 @@
<!--minimizeByOther enable is true means fullscreen window will be minmized by other fullscreen window-->
<minimizeByOther enable="true"></minimizeByOther>
<!--exit split screen mode ratio config-->
<exitSplitRatio>0.1</exitSplitRatio>
<exitSplitRatios>0.1 0.9</exitSplitRatios>
<!--split screen ratios config-->
<splitRatios>0.5 0.33 0.67</splitRatios>
</Configs>

View File

@ -25,7 +25,7 @@
<!--stretchable enable is true means all window be stretchable-->
<stretchable enable="false"></stretchable>
<!--exit split screen mode ratio config-->
<exitSplitRatio>0.1</exitSplitRatio>
<exitSplitRatios>0.1 0.9</exitSplitRatios>
<!--split screen ratios config-->
<splitRatios>0.5 0.33 0.67</splitRatios>
</Configs>

View File

@ -104,7 +104,10 @@ struct ModeChangeHotZones {
};
struct SplitRatioConfig {
float exitSplitRatio;
// when divider reaches this position, the top/left window will hide. Valid range: (0, 0.5)
float exitSplitStartRatio;
// when divider reaches this position, the bottom/right window will hide. Valid range: (0.5, 1)
float exitSplitEndRatio;
std::vector<float> splitRatios;
};

View File

@ -62,7 +62,7 @@ public:
void ProcessDisplayDestroy(DisplayId displayId, const std::map<DisplayId, Rect>& displayRectMap);
void ProcessDisplaySizeChangeOrRotation(DisplayId displayId, const std::map<DisplayId, Rect>& displayRectMap);
void SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig);
void SetSplitRatioConfig(SplitRatioConfig splitRatioConfig);
void SetSplitRatioConfig(const SplitRatioConfig& splitRatioConfig);
protected:
void UpdateFloatingLayoutRect(Rect& limitRect, Rect& winRect);

View File

@ -89,7 +89,7 @@ public:
void DestroyLeakStartingWindow();
void SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig);
void SetSplitRatios(const std::vector<float>& splitRatioNumbers);
void SetExitSplitRatio(float exitSplitRatio);
void SetExitSplitRatios(const std::vector<float>& exitSplitRatios);
void MinimizeTargetWindows(std::vector<uint32_t>& windowIds);
private:
void OnRemoteDied(const sptr<IRemoteObject>& remoteObject);
@ -122,7 +122,7 @@ private:
Callback callback_;
int maxAppWindowNumber_ = 100;
FloatingWindowLimitsConfig floatingWindowLimitsConfig_;
SplitRatioConfig splitRatioConfig_ = {0.1, {}};
SplitRatioConfig splitRatioConfig_ = {0.1, 0.9, {}};
};
}
}

View File

@ -974,7 +974,7 @@ Rect WindowLayoutPolicy::GetDisplayGroupRect() const
return displayGroupRect_;
}
void WindowLayoutPolicy::SetSplitRatioConfig(SplitRatioConfig splitRatioConfig)
void WindowLayoutPolicy::SetSplitRatioConfig(const SplitRatioConfig& splitRatioConfig)
{
splitRatioConfig_ = splitRatioConfig;
}

View File

@ -351,8 +351,8 @@ void WindowLayoutPolicyCascade::UpdateSplitRatioPoints(DisplayId displayId)
LayoutRects& cascadeRects = cascadeRectsMap_[displayId];
cascadeRects.exitSplitPoints_.clear();
cascadeRects.splitRatioPoints_.clear();
cascadeRects.exitSplitPoints_.push_back(GetSplitRatioPoint(splitRatioConfig_.exitSplitRatio, displayId));
cascadeRects.exitSplitPoints_.push_back(GetSplitRatioPoint(1 - splitRatioConfig_.exitSplitRatio, displayId));
cascadeRects.exitSplitPoints_.push_back(GetSplitRatioPoint(splitRatioConfig_.exitSplitStartRatio, displayId));
cascadeRects.exitSplitPoints_.push_back(GetSplitRatioPoint(splitRatioConfig_.exitSplitEndRatio, displayId));
for (const auto& ratio : splitRatioConfig_.splitRatios) {
cascadeRects.splitRatioPoints_.push_back(GetSplitRatioPoint(ratio, displayId));
}

View File

@ -66,7 +66,7 @@ bool WindowManagerConfig::LoadConfigXml(const std::string& configFilePath)
if (!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("floatingWindowLimitRatio")) ||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("splitRatios")) ||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("exitSplitRatio"))) {
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("exitSplitRatios"))) {
ReadFloatNumbersConfigInfo(curNodePtr);
continue;
}

View File

@ -260,11 +260,8 @@ void WindowManagerService::ConfigureWindowManagerService()
windowRoot_->SetSplitRatios(floatNumbersConfig.at("splitRatios"));
}
if (floatNumbersConfig.count("exitSplitRatio") != 0) {
auto numbers = floatNumbersConfig.at("exitSplitRatio");
if ((numbers.size() == 1) && numbers[0] > 0 && numbers[0] < 0.5) { // valid range (0, 0.5)
windowRoot_->SetExitSplitRatio(numbers[0]);
}
if (floatNumbersConfig.count("exitSplitRatios") != 0) {
windowRoot_->SetExitSplitRatios(floatNumbersConfig.at("exitSplitRatios"));
}
}

View File

@ -1170,9 +1170,17 @@ void WindowRoot::SetSplitRatios(const std::vector<float>& splitRatioNumbers)
splitRatios.erase(iter, splitRatios.end()); // remove duplitcate ratios
}
void WindowRoot::SetExitSplitRatio(float exitSplitRatio)
void WindowRoot::SetExitSplitRatios(const std::vector<float>& exitSplitRatios)
{
splitRatioConfig_.exitSplitRatio = exitSplitRatio;
if (exitSplitRatios.size() != 2) {
return;
}
if (exitSplitRatios[0] > 0 && exitSplitRatios[0] < DEFAULT_SPLIT_RATIO) {
splitRatioConfig_.exitSplitStartRatio = exitSplitRatios[0];
}
if (exitSplitRatios[1] > DEFAULT_SPLIT_RATIO && exitSplitRatios[1] < 1) {
splitRatioConfig_.exitSplitEndRatio = exitSplitRatios[1];
}
}
WMError WindowRoot::GetModeChangeHotZones(DisplayId displayId,