mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-27 09:00:55 +00:00
support two user-defined exit-split-mode ratios
Signed-off-by: wlj <wangliangjiang1@huawei.com> Change-Id: I3303b64f104d7cc8b663ac10dc3c31913b1c55f1
This commit is contained in:
parent
3516b631c6
commit
4cd447c3b8
@ -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>
|
||||
|
@ -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>
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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, {}};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -974,7 +974,7 @@ Rect WindowLayoutPolicy::GetDisplayGroupRect() const
|
||||
return displayGroupRect_;
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::SetSplitRatioConfig(SplitRatioConfig splitRatioConfig)
|
||||
void WindowLayoutPolicy::SetSplitRatioConfig(const SplitRatioConfig& splitRatioConfig)
|
||||
{
|
||||
splitRatioConfig_ = splitRatioConfig;
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user