mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
读取包管理配置
Signed-off-by: l00574490 <liuqi149@huawei.com> Change-Id: I210656846119aaa4d9179f0d9cb9c70597f9909b
This commit is contained in:
@@ -232,8 +232,8 @@ public:
|
||||
virtual void OnNewWant(const AAFwk::Want& want) = 0;
|
||||
virtual void SetRequestedOrientation(Orientation) = 0;
|
||||
virtual Orientation GetRequestedOrientation() = 0;
|
||||
virtual void SetModeSupportInfo(uint32_t modeSupportInfo) = 0;
|
||||
virtual uint32_t GetModeSupportInfo() const = 0;
|
||||
virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) = 0;
|
||||
virtual uint32_t GetRequestModeSupportInfo() const = 0;
|
||||
virtual WMError SetTouchHotAreas(const std::vector<Rect>& rects) = 0;
|
||||
virtual void GetRequestedTouchHotAreas(std::vector<Rect>& rects) const = 0;
|
||||
|
||||
|
||||
@@ -332,6 +332,30 @@ public:
|
||||
return isOk;
|
||||
}
|
||||
|
||||
static bool IsRectSatisfiedWithSizeLimits(const Rect& rect, const WindowSizeLimits& sizeLimits)
|
||||
{
|
||||
if (rect.height_ == 0) {
|
||||
return false;
|
||||
}
|
||||
auto curRatio = static_cast<float>(rect.width_) / static_cast<float>(rect.height_);
|
||||
if (sizeLimits.minWidth_ <= rect.width_ && rect.width_ <= sizeLimits.maxWidth_ &&
|
||||
sizeLimits.minHeight_ <= rect.height_ && rect.height_ <= sizeLimits.maxHeight_ &&
|
||||
sizeLimits.minRatio_ <= curRatio && curRatio <= sizeLimits.maxRatio_) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsOnlySupportSplitAndShowWhenLocked(bool isShowWhenLocked, uint32_t modeSupportInfo)
|
||||
{
|
||||
uint32_t splitModeInfo = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY);
|
||||
if (isShowWhenLocked && (splitModeInfo == modeSupportInfo)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
WindowHelper() = default;
|
||||
~WindowHelper() = default;
|
||||
|
||||
@@ -67,11 +67,13 @@ public:
|
||||
void SetWindowSizeChangeReason(WindowSizeChangeReason reason);
|
||||
void SetTokenState(bool hasToken);
|
||||
void SetModeSupportInfo(uint32_t modeSupportInfo);
|
||||
void SetRequestModeSupportInfo(uint32_t requestModeSupportInfo);
|
||||
void SetDragType(DragType dragType);
|
||||
void SetStretchable(bool stretchable);
|
||||
void SetOriginRect(const Rect& rect);
|
||||
void SetTouchHotAreas(const std::vector<Rect>& rects);
|
||||
void SetAccessTokenId(uint32_t accessTokenId);
|
||||
void SetSizeLimits(const WindowSizeLimits& sizeLimits);
|
||||
WindowSizeChangeReason GetWindowSizeChangeReason() const;
|
||||
void SetTransform(const Transform& trans);
|
||||
|
||||
@@ -104,12 +106,15 @@ public:
|
||||
const PointInfo& GetHitOffset() const;
|
||||
uint32_t GetAnimationFlag() const;
|
||||
uint32_t GetModeSupportInfo() const;
|
||||
uint32_t GetRequestModeSupportInfo() const;
|
||||
DragType GetDragType() const;
|
||||
bool GetStretchable() const;
|
||||
const Rect& GetOriginRect() const;
|
||||
void GetTouchHotAreas(std::vector<Rect>& rects) const;
|
||||
uint32_t GetAccessTokenId() const;
|
||||
Transform GetTransform() const;
|
||||
WindowSizeLimits GetSizeLimits() const;
|
||||
|
||||
virtual bool Marshalling(Parcel& parcel) const override;
|
||||
static WindowProperty* Unmarshalling(Parcel& parcel);
|
||||
|
||||
@@ -122,6 +127,9 @@ private:
|
||||
static void UnmarshallingTouchHotAreas(Parcel& parcel, WindowProperty* property);
|
||||
bool MarshallingTransform(Parcel& parcel) const;
|
||||
static void UnmarshallingTransform(Parcel& parcel, WindowProperty* property);
|
||||
bool MarshallingWindowSizeLimits(Parcel& parcel) const;
|
||||
static void UnmarshallingWindowSizeLimits(Parcel& parcel, WindowProperty* property);
|
||||
|
||||
std::string windowName_;
|
||||
Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size)
|
||||
Rect windowRect_ { 0, 0, 0, 0 }; // actual window rect
|
||||
@@ -147,7 +155,10 @@ private:
|
||||
uint32_t parentId_ { 0 };
|
||||
PointInfo hitOffset_ { 0, 0 };
|
||||
uint32_t animationFlag_ { static_cast<uint32_t>(WindowAnimation::DEFAULT) };
|
||||
// modeSupportInfo_ means supported modes in runtime, which can be changed
|
||||
uint32_t modeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL};
|
||||
// requestModeSupportInfo_ is configured in abilityInfo, usually can't be changed
|
||||
uint32_t requestModeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL};
|
||||
WindowSizeChangeReason windowSizeChangeReason_ = WindowSizeChangeReason::UNDEFINED;
|
||||
std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ {
|
||||
{ WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty() },
|
||||
@@ -162,6 +173,7 @@ private:
|
||||
Transform trans_;
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(Orientation, RequestedOrientation, requestedOrientation, Orientation::UNSPECIFIED);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(bool, CustomAnimation, isCustomAnimation, false);
|
||||
WindowSizeLimits sizeLimits_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
void SetWindowType(WindowType windowType);
|
||||
WindowType GetWindowType();
|
||||
void SetShowFlagWhenLocked(bool isShow);
|
||||
void SetWindowSupportModes(const std::vector<uint32_t> supportModes);
|
||||
std::vector<uint32_t> GetWindowSupportModes();
|
||||
bool GetShowFlagWhenLocked();
|
||||
void SetTransitionReason(TransitionReason reason);
|
||||
TransitionReason GetTransitionReason();
|
||||
@@ -68,6 +70,7 @@ private:
|
||||
bool isShowWhenLocked_ = false;
|
||||
bool isRecent_ = false;
|
||||
TransitionReason reason_ = TransitionReason::ABILITY_TRANSITION;
|
||||
std::vector<uint32_t> supportWindowModes_;
|
||||
};
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#ifndef OHOS_ROSEN_WM_COMMON_INNER_H
|
||||
#define OHOS_ROSEN_WM_COMMON_INNER_H
|
||||
|
||||
#include <cfloat>
|
||||
#include <cinttypes>
|
||||
#include "wm_common.h"
|
||||
|
||||
@@ -94,16 +95,19 @@ struct ModeChangeHotZonesConfig {
|
||||
uint32_t secondaryRange_;
|
||||
};
|
||||
|
||||
struct FloatingWindowLimitsConfig {
|
||||
bool isFloatingWindowLimitsConfigured_;
|
||||
struct WindowSizeLimits {
|
||||
uint32_t maxWidth_;
|
||||
uint32_t maxHeight_;
|
||||
uint32_t minWidth_;
|
||||
uint32_t minHeight_;
|
||||
float maxRatio_;
|
||||
float minRatio_;
|
||||
FloatingWindowLimitsConfig() : isFloatingWindowLimitsConfigured_(false), maxWidth_(0), maxHeight_(0), minWidth_(0),
|
||||
minHeight_(0), maxRatio_(0.0f), minRatio_(0.0f) {}
|
||||
WindowSizeLimits() : maxWidth_(UINT32_MAX), maxHeight_(UINT32_MAX), minWidth_(0),
|
||||
minHeight_(0), maxRatio_(FLT_MAX), minRatio_(0.0f) {}
|
||||
WindowSizeLimits(uint32_t maxWidth, uint32_t maxHeight, uint32_t minWidth,
|
||||
uint32_t minHeight, float maxRatio, float minRatio)
|
||||
: maxWidth_(maxWidth), maxHeight_(maxHeight), minWidth_(minWidth),
|
||||
minHeight_(minHeight), maxRatio_(maxRatio), minRatio_(minRatio) {}
|
||||
};
|
||||
|
||||
struct ModeChangeHotZones {
|
||||
|
||||
@@ -51,7 +51,7 @@ void WindowProperty::SetWindowType(WindowType type)
|
||||
|
||||
void WindowProperty::SetWindowMode(WindowMode mode)
|
||||
{
|
||||
if (!WindowHelper::IsValidWindowMode(mode)) {
|
||||
if (!WindowHelper::IsValidWindowMode(mode) || !WindowHelper::IsWindowModeSupported(modeSupportInfo_, mode)) {
|
||||
return;
|
||||
}
|
||||
if (!WindowHelper::IsSplitWindowMode(mode_)) {
|
||||
@@ -62,6 +62,9 @@ void WindowProperty::SetWindowMode(WindowMode mode)
|
||||
|
||||
void WindowProperty::SetLastWindowMode(WindowMode mode)
|
||||
{
|
||||
if (!WindowHelper::IsWindowModeSupported(modeSupportInfo_, mode)) {
|
||||
return;
|
||||
}
|
||||
lastMode_ = mode;
|
||||
}
|
||||
|
||||
@@ -138,6 +141,11 @@ void WindowProperty::SetWindowFlags(uint32_t flags)
|
||||
flags_ = flags;
|
||||
}
|
||||
|
||||
void WindowProperty::SetSizeLimits(const WindowSizeLimits& sizeLimits)
|
||||
{
|
||||
sizeLimits_ = sizeLimits;
|
||||
}
|
||||
|
||||
void WindowProperty::AddWindowFlag(WindowFlag flag)
|
||||
{
|
||||
flags_ |= static_cast<uint32_t>(flag);
|
||||
@@ -197,6 +205,9 @@ WindowSizeChangeReason WindowProperty::GetWindowSizeChangeReason() const
|
||||
|
||||
void WindowProperty::ResumeLastWindowMode()
|
||||
{
|
||||
if (!WindowHelper::IsWindowModeSupported(modeSupportInfo_, lastMode_)) {
|
||||
return;
|
||||
}
|
||||
mode_ = lastMode_;
|
||||
}
|
||||
|
||||
@@ -335,6 +346,11 @@ void WindowProperty::SetModeSupportInfo(uint32_t modeSupportInfo)
|
||||
modeSupportInfo_ = modeSupportInfo;
|
||||
}
|
||||
|
||||
void WindowProperty::SetRequestModeSupportInfo(uint32_t requestModeSupportInfo)
|
||||
{
|
||||
requestModeSupportInfo_ = requestModeSupportInfo;
|
||||
}
|
||||
|
||||
uint32_t WindowProperty::GetWindowId() const
|
||||
{
|
||||
return windowId_;
|
||||
@@ -360,6 +376,11 @@ uint32_t WindowProperty::GetModeSupportInfo() const
|
||||
return modeSupportInfo_;
|
||||
}
|
||||
|
||||
uint32_t WindowProperty::GetRequestModeSupportInfo() const
|
||||
{
|
||||
return requestModeSupportInfo_;
|
||||
}
|
||||
|
||||
bool WindowProperty::GetTokenState() const
|
||||
{
|
||||
return tokenState_;
|
||||
@@ -380,6 +401,11 @@ bool WindowProperty::GetStretchable() const
|
||||
return isStretchable_;
|
||||
}
|
||||
|
||||
WindowSizeLimits WindowProperty::GetSizeLimits() const
|
||||
{
|
||||
return sizeLimits_;
|
||||
}
|
||||
|
||||
void WindowProperty::SetTouchHotAreas(const std::vector<Rect>& rects)
|
||||
{
|
||||
touchHotAreas_ = rects;
|
||||
@@ -474,6 +500,23 @@ void WindowProperty::UnmarshallingTransform(Parcel& parcel, WindowProperty* prop
|
||||
property->SetTransform(trans);
|
||||
}
|
||||
|
||||
bool WindowProperty::MarshallingWindowSizeLimits(Parcel& parcel) const
|
||||
{
|
||||
if (parcel.WriteUint32(sizeLimits_.maxWidth_) && parcel.WriteUint32(sizeLimits_.maxHeight_) &&
|
||||
parcel.WriteUint32(sizeLimits_.minWidth_) && parcel.WriteUint32(sizeLimits_.minHeight_) &&
|
||||
parcel.WriteFloat(sizeLimits_.maxRatio_) && parcel.WriteFloat(sizeLimits_.minRatio_)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void WindowProperty::UnmarshallingWindowSizeLimits(Parcel& parcel, WindowProperty* property)
|
||||
{
|
||||
WindowSizeLimits sizeLimits = { parcel.ReadUint32(), parcel.ReadUint32(), parcel.ReadUint32(), parcel.ReadUint32(),
|
||||
parcel.ReadFloat(), parcel.ReadFloat() };
|
||||
property->SetSizeLimits(sizeLimits);
|
||||
}
|
||||
|
||||
bool WindowProperty::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
return parcel.WriteString(windowName_) && parcel.WriteInt32(windowRect_.posX_) &&
|
||||
@@ -492,10 +535,12 @@ bool WindowProperty::Marshalling(Parcel& parcel) const
|
||||
parcel.WriteUint32(static_cast<uint32_t>(windowSizeChangeReason_)) && parcel.WriteBool(tokenState_) &&
|
||||
parcel.WriteUint32(callingWindow_) && parcel.WriteUint32(static_cast<uint32_t>(requestedOrientation_)) &&
|
||||
parcel.WriteBool(turnScreenOn_) && parcel.WriteBool(keepScreenOn_) &&
|
||||
parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(static_cast<uint32_t>(dragType_)) &&
|
||||
parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(requestModeSupportInfo_) &&
|
||||
parcel.WriteUint32(static_cast<uint32_t>(dragType_)) &&
|
||||
parcel.WriteUint32(originRect_.width_) && parcel.WriteUint32(originRect_.height_) &&
|
||||
parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel) && parcel.WriteUint32(accessTokenId_) &&
|
||||
parcel.WriteBool(isCustomAnimation_) && MarshallingTransform(parcel);
|
||||
parcel.WriteBool(isCustomAnimation_) && MarshallingTransform(parcel) &&
|
||||
MarshallingWindowSizeLimits(parcel);
|
||||
}
|
||||
|
||||
WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel)
|
||||
@@ -537,6 +582,7 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel)
|
||||
property->SetTurnScreenOn(parcel.ReadBool());
|
||||
property->SetKeepScreenOn(parcel.ReadBool());
|
||||
property->SetModeSupportInfo(parcel.ReadUint32());
|
||||
property->SetRequestModeSupportInfo(parcel.ReadUint32());
|
||||
property->SetDragType(static_cast<DragType>(parcel.ReadUint32()));
|
||||
uint32_t w = parcel.ReadUint32();
|
||||
uint32_t h = parcel.ReadUint32();
|
||||
@@ -546,6 +592,7 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel)
|
||||
property->SetAccessTokenId(parcel.ReadUint32());
|
||||
property->SetCustomAnimation(parcel.ReadBool());
|
||||
UnmarshallingTransform(parcel, property);
|
||||
UnmarshallingWindowSizeLimits(parcel, property);
|
||||
return property;
|
||||
}
|
||||
|
||||
@@ -693,6 +740,7 @@ void WindowProperty::CopyFrom(const sptr<WindowProperty>& property)
|
||||
turnScreenOn_ = property->turnScreenOn_;
|
||||
keepScreenOn_ = property->keepScreenOn_;
|
||||
modeSupportInfo_ = property->modeSupportInfo_;
|
||||
requestModeSupportInfo_ = property->requestModeSupportInfo_;
|
||||
dragType_ = property->dragType_;
|
||||
originRect_ = property->originRect_;
|
||||
isStretchable_ = property->isStretchable_;
|
||||
@@ -700,6 +748,7 @@ void WindowProperty::CopyFrom(const sptr<WindowProperty>& property)
|
||||
accessTokenId_ = property->accessTokenId_;
|
||||
isCustomAnimation_ = property->isCustomAnimation_;
|
||||
trans_ = property->trans_;
|
||||
sizeLimits_ = property->sizeLimits_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ WindowTransitionInfo::WindowTransitionInfo(sptr<AAFwk::AbilityTransitionInfo> in
|
||||
displayId_ = info->displayId_;
|
||||
isShowWhenLocked_ = info->isShowWhenLocked_;
|
||||
isRecent_ = info->isRecent_;
|
||||
supportWindowModes_ = { 0, 1, 2 }; // 0:fullScreen 1:split 2:floating
|
||||
}
|
||||
|
||||
void WindowTransitionInfo::SetBundleName(std::string name)
|
||||
@@ -103,6 +104,16 @@ void WindowTransitionInfo::SetShowFlagWhenLocked(bool isShow)
|
||||
isShowWhenLocked_ = isShow;
|
||||
}
|
||||
|
||||
void WindowTransitionInfo::SetWindowSupportModes(const std::vector<uint32_t> supportModes)
|
||||
{
|
||||
supportWindowModes_.assign(supportModes.begin(), supportModes.end());
|
||||
}
|
||||
|
||||
std::vector<uint32_t> WindowTransitionInfo::GetWindowSupportModes()
|
||||
{
|
||||
return supportWindowModes_;
|
||||
}
|
||||
|
||||
bool WindowTransitionInfo::GetShowFlagWhenLocked()
|
||||
{
|
||||
return isShowWhenLocked_;
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
~WindowAgent() = default;
|
||||
void UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) override;
|
||||
void UpdateWindowMode(WindowMode mode) override;
|
||||
void UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override;
|
||||
void UpdateFocusStatus(bool focused) override;
|
||||
void UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) override;
|
||||
void UpdateWindowState(WindowState state) override;
|
||||
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
virtual const std::string& GetWindowName() const override;
|
||||
virtual uint32_t GetWindowId() const override;
|
||||
virtual uint32_t GetWindowFlags() const override;
|
||||
uint32_t GetModeSupportInfo() const override;
|
||||
uint32_t GetRequestModeSupportInfo() const override;
|
||||
inline NotifyNativeWinDestroyFunc GetNativeDestroyCallback()
|
||||
{
|
||||
return notifyNativefunc_;
|
||||
@@ -191,9 +191,10 @@ public:
|
||||
virtual void RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
|
||||
virtual void UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
|
||||
virtual void SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler) override;
|
||||
virtual void SetModeSupportInfo(uint32_t modeSupportInfo) override;
|
||||
virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) override;
|
||||
void UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason);
|
||||
void UpdateMode(WindowMode mode);
|
||||
void UpdateModeSupportInfo(uint32_t modeSupportInfo);
|
||||
virtual void ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent>& inputEvent) override;
|
||||
virtual void ConsumePointerEvent(std::shared_ptr<MMI::PointerEvent>& inputEvent) override;
|
||||
virtual void RequestFrame() override;
|
||||
@@ -339,7 +340,10 @@ private:
|
||||
void UpdateDragType();
|
||||
void InitListenerHandler();
|
||||
bool CheckCameraFloatingWindowMultiCreated(WindowType type);
|
||||
void SetOrientationFromAbility();
|
||||
void GetConfigurationFromAbilityInfo();
|
||||
void UpdateTitleButtonVisibility();
|
||||
void SetModeSupportInfo(uint32_t modeSupportInfo);
|
||||
uint32_t GetModeSupportInfo() const;
|
||||
|
||||
// colorspace, gamut
|
||||
using ColorSpaceConvertMap = struct {
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
enum class WindowMessage : uint32_t {
|
||||
TRANS_ID_UPDATE_WINDOW_RECT,
|
||||
TRANS_ID_UPDATE_WINDOW_MODE,
|
||||
TRANS_ID_UPDATE_MODE_SUPPORT_INFO,
|
||||
TRANS_ID_UPDATE_FOCUS_STATUS,
|
||||
TRANS_ID_UPDATE_AVOID_AREA,
|
||||
TRANS_ID_UPDATE_WINDOW_STATE,
|
||||
@@ -45,6 +46,7 @@ public:
|
||||
|
||||
virtual void UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) = 0;
|
||||
virtual void UpdateWindowMode(WindowMode mode) = 0;
|
||||
virtual void UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) = 0;
|
||||
virtual void UpdateFocusStatus(bool focused) = 0;
|
||||
virtual void UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) = 0;
|
||||
virtual void UpdateWindowState(WindowState state) = 0;
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
|
||||
void UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) override;
|
||||
void UpdateWindowMode(WindowMode mode) override;
|
||||
void UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override;
|
||||
void UpdateFocusStatus(bool focused) override;
|
||||
void UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) override;
|
||||
void UpdateWindowState(WindowState state) override;
|
||||
|
||||
@@ -46,6 +46,15 @@ void WindowAgent::UpdateWindowMode(WindowMode mode)
|
||||
window_->UpdateMode(mode);
|
||||
}
|
||||
|
||||
void WindowAgent::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
WLOGFE("window_ is nullptr");
|
||||
return;
|
||||
}
|
||||
window_->UpdateModeSupportInfo(modeSupportInfo);
|
||||
}
|
||||
|
||||
void WindowAgent::UpdateFocusStatus(bool focused)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
|
||||
+111
-42
@@ -278,6 +278,11 @@ uint32_t WindowImpl::GetWindowFlags() const
|
||||
return property_->GetWindowFlags();
|
||||
}
|
||||
|
||||
uint32_t WindowImpl::GetRequestModeSupportInfo() const
|
||||
{
|
||||
return property_->GetRequestModeSupportInfo();
|
||||
}
|
||||
|
||||
uint32_t WindowImpl::GetModeSupportInfo() const
|
||||
{
|
||||
return property_->GetModeSupportInfo();
|
||||
@@ -465,9 +470,11 @@ WMError WindowImpl::SetUIContent(const std::string& contentInfo,
|
||||
} else {
|
||||
uiContent->Initialize(this, contentInfo, storage);
|
||||
}
|
||||
// make uiContent_ available after Initialize/Restore
|
||||
// make uiContent available after Initialize/Restore
|
||||
uiContent_ = std::move(uiContent);
|
||||
|
||||
if (state_ == WindowState::STATE_SHOWN) {
|
||||
UpdateTitleButtonVisibility();
|
||||
Ace::ViewportConfig config;
|
||||
Rect rect = GetRect();
|
||||
config.SetSize(rect.width_, rect.height_);
|
||||
@@ -578,7 +585,9 @@ WMError WindowImpl::SetSystemBarProperty(WindowType type, const SystemBarPropert
|
||||
WMError WindowImpl::SetLayoutFullScreen(bool status)
|
||||
{
|
||||
WLOGFI("[Client] Window %{public}u SetLayoutFullScreen: %{public}u", property_->GetWindowId(), status);
|
||||
if (!IsWindowValid()) {
|
||||
if (!IsWindowValid() ||
|
||||
!WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) {
|
||||
WLOGFE("invalid window or fullscreen mode is not be supported, winId:%{public}u", property_->GetWindowId());
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
WMError ret = SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
@@ -608,6 +617,11 @@ WMError WindowImpl::SetLayoutFullScreen(bool status)
|
||||
WMError WindowImpl::SetFullScreen(bool status)
|
||||
{
|
||||
WLOGFI("[Client] Window %{public}u SetFullScreen: %{public}d", property_->GetWindowId(), status);
|
||||
if (!IsWindowValid() ||
|
||||
!WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) {
|
||||
WLOGFE("invalid window or fullscreen mode is not be supported, winId:%{public}u", property_->GetWindowId());
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
SystemBarProperty statusProperty = GetSystemBarPropertyByType(
|
||||
WindowType::WINDOW_TYPE_STATUS_BAR);
|
||||
SystemBarProperty naviProperty = GetSystemBarPropertyByType(
|
||||
@@ -660,6 +674,68 @@ WMError WindowImpl::UpdateProperty(PropertyChangeAction action)
|
||||
return SingletonContainer::Get<WindowAdapter>().UpdateProperty(property_, action);
|
||||
}
|
||||
|
||||
void WindowImpl::GetConfigurationFromAbilityInfo()
|
||||
{
|
||||
auto abilityContext = AbilityRuntime::Context::ConvertTo<AbilityRuntime::AbilityContext>(context_);
|
||||
if (abilityContext == nullptr) {
|
||||
WLOGFE("id:%{public}u is not ability Window", property_->GetWindowId());
|
||||
return;
|
||||
}
|
||||
auto abilityInfo = abilityContext->GetAbilityInfo();
|
||||
if (abilityInfo == nullptr) {
|
||||
WLOGFE("id:%{public}u Ability window get ability info failed", property_->GetWindowId());
|
||||
return;
|
||||
}
|
||||
|
||||
// get support modes configuration
|
||||
uint32_t modeSupportInfo = 0;
|
||||
const auto& supportModes = abilityInfo->windowModes;
|
||||
for (auto& mode : supportModes) {
|
||||
if (static_cast<uint32_t>(mode) == static_cast<uint32_t>(0)) { // 0 : fullScreen
|
||||
modeSupportInfo |= WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN;
|
||||
} else if (static_cast<uint32_t>(mode) == static_cast<uint32_t>(1)) { // 1 : split
|
||||
modeSupportInfo |= (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY);
|
||||
} else if (static_cast<uint32_t>(mode) == static_cast<uint32_t>(2)) { // 2 : floating
|
||||
modeSupportInfo |= WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING;
|
||||
}
|
||||
}
|
||||
if (modeSupportInfo == 0) {
|
||||
WLOGFI("mode config param is 0, set all modes");
|
||||
modeSupportInfo = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
|
||||
}
|
||||
SetRequestModeSupportInfo(modeSupportInfo);
|
||||
|
||||
// get window size limits configuration
|
||||
WindowSizeLimits sizeLimits;
|
||||
sizeLimits.maxWidth_ = abilityInfo->maxWindowWidth;
|
||||
sizeLimits.maxHeight_ = abilityInfo->maxWindowHeight;
|
||||
sizeLimits.minWidth_ = abilityInfo->minWindowWidth;
|
||||
sizeLimits.minHeight_ = abilityInfo->minWindowHeight;
|
||||
sizeLimits.maxRatio_ = static_cast<float>(abilityInfo->maxWindowRatio);
|
||||
sizeLimits.minRatio_ = static_cast<float>(abilityInfo->minWindowRatio);
|
||||
property_->SetSizeLimits(sizeLimits);
|
||||
|
||||
// get orientation configuration
|
||||
DisplayOrientation displayOrientation = static_cast<DisplayOrientation>(
|
||||
static_cast<uint32_t>(abilityInfo->orientation));
|
||||
if (ABILITY_TO_WMS_ORIENTATION_MAP.count(displayOrientation) == 0) {
|
||||
WLOGFE("id:%{public}u Do not support this Orientation type", property_->GetWindowId());
|
||||
return;
|
||||
}
|
||||
Orientation orientation = ABILITY_TO_WMS_ORIENTATION_MAP.at(displayOrientation);
|
||||
if (orientation < Orientation::BEGIN || orientation > Orientation::END) {
|
||||
WLOGFE("Set orientation from ability failed");
|
||||
return;
|
||||
}
|
||||
property_->SetRequestedOrientation(orientation);
|
||||
}
|
||||
|
||||
void WindowImpl::UpdateTitleButtonVisibility()
|
||||
{
|
||||
WLOGFI("[Client] UpdateTitleButtonVisibility");
|
||||
}
|
||||
|
||||
WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr<AbilityRuntime::Context>& context)
|
||||
{
|
||||
WLOGFI("[Client] Window [name:%{public}s] Create", name_.c_str());
|
||||
@@ -705,7 +781,7 @@ WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr<
|
||||
WLOGFI("get stretchable enable:%{public}d", windowSystemConfig_.isStretchable_);
|
||||
property_->SetStretchable(windowSystemConfig_.isStretchable_);
|
||||
}
|
||||
SetOrientationFromAbility();
|
||||
GetConfigurationFromAbilityInfo();
|
||||
}
|
||||
WMError ret = SingletonContainer::Get<WindowAdapter>().CreateWindow(windowAgent, property_, surfaceNode_,
|
||||
windowId, token);
|
||||
@@ -883,6 +959,19 @@ WMError WindowImpl::Show(uint32_t reason, bool isCustomAnimation)
|
||||
SetDefaultOption();
|
||||
// set true success when transitionController exist; set false when complete transition
|
||||
property_->SetCustomAnimation(isCustomAnimation);
|
||||
|
||||
// show failed when current mode is not support or window only supports split mode and can show when locked
|
||||
bool isShowWhenLocked = GetWindowFlags() & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED);
|
||||
if (!WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), GetMode()) ||
|
||||
WindowHelper::IsOnlySupportSplitAndShowWhenLocked(isShowWhenLocked, GetModeSupportInfo())) {
|
||||
WLOGFE("current mode is not be supported, windowId: %{public}u", property_->GetWindowId());
|
||||
NotifyForegroundFailed();
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
|
||||
// update title button visibility when show
|
||||
UpdateTitleButtonVisibility();
|
||||
|
||||
WMError ret = SingletonContainer::Get<WindowAdapter>().AddWindow(property_);
|
||||
RecordLifeCycleExceptionEvent(LifeCycleEvent::SHOW_EVENT, ret);
|
||||
if (ret == WMError::WM_OK || ret == WMError::WM_ERROR_DEATH_RECIPIENT) {
|
||||
@@ -1216,6 +1305,9 @@ WMError WindowImpl::NotifyWindowTransition(TransitionReason reason)
|
||||
return WMError::WM_ERROR_NO_MEM;
|
||||
}
|
||||
auto abilityInfo = abilityContext->GetAbilityInfo();
|
||||
if (abilityInfo == nullptr) {
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
fromInfo->SetBundleName(context_->GetBundleName());
|
||||
fromInfo->SetAbilityName(abilityInfo->name);
|
||||
fromInfo->SetWindowMode(property_->GetWindowMode());
|
||||
@@ -1227,32 +1319,6 @@ WMError WindowImpl::NotifyWindowTransition(TransitionReason reason)
|
||||
return SingletonContainer::Get<WindowAdapter>().NotifyWindowTransition(fromInfo, toInfo);
|
||||
}
|
||||
|
||||
void WindowImpl::SetOrientationFromAbility()
|
||||
{
|
||||
auto abilityContext = AbilityRuntime::Context::ConvertTo<AbilityRuntime::AbilityContext>(context_);
|
||||
if (abilityContext == nullptr) {
|
||||
WLOGFE("id:%{public}d is not ability Window", property_->GetWindowId());
|
||||
return;
|
||||
}
|
||||
auto abilityInfo = abilityContext->GetAbilityInfo();
|
||||
if (abilityInfo == nullptr) {
|
||||
WLOGFE("id:%{public}d Ability window get ability info failed", property_->GetWindowId());
|
||||
return;
|
||||
}
|
||||
DisplayOrientation displayOrientation = static_cast<DisplayOrientation>(
|
||||
static_cast<uint32_t>(abilityInfo->orientation));
|
||||
if (ABILITY_TO_WMS_ORIENTATION_MAP.count(displayOrientation) == 0) {
|
||||
WLOGFE("id:%{public}d Do not support this Orientation type", property_->GetWindowId());
|
||||
return;
|
||||
}
|
||||
Orientation orientation = ABILITY_TO_WMS_ORIENTATION_MAP.at(displayOrientation);
|
||||
if (orientation < Orientation::BEGIN || orientation > Orientation::END) {
|
||||
WLOGFE("Set orientation from ability failed");
|
||||
return;
|
||||
}
|
||||
property_->SetRequestedOrientation(orientation);
|
||||
}
|
||||
|
||||
WMError WindowImpl::Minimize()
|
||||
{
|
||||
WLOGFI("[Client] Window %{public}u Minimize", property_->GetWindowId());
|
||||
@@ -1546,20 +1612,15 @@ void WindowImpl::SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler)
|
||||
aceAbilityHandler_ = handler;
|
||||
}
|
||||
|
||||
void WindowImpl::SetRequestModeSupportInfo(uint32_t modeSupportInfo)
|
||||
{
|
||||
property_->SetRequestModeSupportInfo(modeSupportInfo);
|
||||
SetModeSupportInfo(modeSupportInfo);
|
||||
}
|
||||
|
||||
void WindowImpl::SetModeSupportInfo(uint32_t modeSupportInfo)
|
||||
{
|
||||
property_->SetModeSupportInfo(modeSupportInfo);
|
||||
UpdateProperty(PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO);
|
||||
if (!WindowHelper::IsWindowModeSupported(modeSupportInfo, GetMode())) {
|
||||
WLOGFI("current window mode is not supported, force to transform to appropriate mode. window id:%{public}u",
|
||||
GetWindowId());
|
||||
WindowMode mode = WindowHelper::GetWindowModeFromModeSupportInfo(modeSupportInfo);
|
||||
if (mode != WindowMode::WINDOW_MODE_UNDEFINED) {
|
||||
SetWindowMode(mode);
|
||||
} else {
|
||||
WLOGFE("invalid modeSupportInfo %{public}u", modeSupportInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason)
|
||||
@@ -1579,7 +1640,7 @@ void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSize
|
||||
return;
|
||||
}
|
||||
property_->SetWindowRect(rect);
|
||||
const Rect& originRect = property_->GetOriginRect();
|
||||
|
||||
// update originRect when floating window show for the first time.
|
||||
if (!isOriginRectSet_ && WindowHelper::IsMainFloatingWindow(GetType(), GetMode())) {
|
||||
property_->SetOriginRect(rect);
|
||||
@@ -1591,12 +1652,13 @@ void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSize
|
||||
if (reason == WindowSizeChangeReason::DRAG || reason == WindowSizeChangeReason::DRAG_END ||
|
||||
reason == WindowSizeChangeReason::DRAG_START || reason == WindowSizeChangeReason::RECOVER ||
|
||||
reason == WindowSizeChangeReason::MOVE) {
|
||||
rectToAce = originRect;
|
||||
rectToAce = property_->GetOriginRect();
|
||||
} else {
|
||||
property_->SetOriginRect(rect);
|
||||
}
|
||||
}
|
||||
WLOGFI("sizeChange callback size: %{public}lu", (unsigned long)windowChangeListeners_.size());
|
||||
|
||||
NotifySizeChange(rectToAce, reason);
|
||||
if (uiContent_ != nullptr) {
|
||||
Ace::ViewportConfig config;
|
||||
@@ -1621,6 +1683,13 @@ void WindowImpl::UpdateMode(WindowMode mode)
|
||||
}
|
||||
}
|
||||
|
||||
void WindowImpl::UpdateModeSupportInfo(uint32_t modeSupportInfo)
|
||||
{
|
||||
WLOGI("modeSupportInfo: %{public}u, winId: %{public}u", modeSupportInfo, GetWindowId());
|
||||
SetModeSupportInfo(modeSupportInfo);
|
||||
UpdateTitleButtonVisibility();
|
||||
}
|
||||
|
||||
void WindowImpl::ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
{
|
||||
NotifyKeyEvent(keyEvent);
|
||||
|
||||
@@ -76,6 +76,27 @@ void WindowProxy::UpdateWindowMode(WindowMode mode)
|
||||
return;
|
||||
}
|
||||
|
||||
void WindowProxy::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteUint32(modeSupportInfo)) {
|
||||
WLOGFE("Write WindowMode failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void WindowProxy::UpdateFocusStatus(bool focused)
|
||||
{
|
||||
MessageParcel data;
|
||||
|
||||
@@ -45,6 +45,11 @@ int WindowStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParce
|
||||
UpdateWindowMode(mode);
|
||||
break;
|
||||
}
|
||||
case WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO: {
|
||||
uint32_t modeSupportInfo = data.ReadUint32();
|
||||
UpdateWindowModeSupportInfo(modeSupportInfo);
|
||||
break;
|
||||
}
|
||||
case WindowMessage::TRANS_ID_UPDATE_FOCUS_STATUS: {
|
||||
bool focused = data.ReadBool();
|
||||
UpdateFocusStatus(focused);
|
||||
|
||||
@@ -76,15 +76,15 @@ void WindowModeSupportInfoTest::TearDown()
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: WindowModeSupportInfo01
|
||||
* @tc.desc: SetModeSupportInfo | GetModeSupportInfo
|
||||
* @tc.desc: SetRequestModeSupportInfo | GetRequestModeSupportInfo
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo01, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
|
||||
|
||||
window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetModeSupportInfo());
|
||||
window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetRequestModeSupportInfo());
|
||||
window->Destroy();
|
||||
}
|
||||
|
||||
@@ -97,26 +97,20 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTe
|
||||
{
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
|
||||
|
||||
window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
window->Destroy();
|
||||
}
|
||||
|
||||
@@ -129,56 +123,40 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTe
|
||||
{
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
|
||||
|
||||
window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN |
|
||||
window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
window->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowModeSupportInfo04
|
||||
* @tc.desc: modeSupportInfo test for single window in case current window mode is not supported.
|
||||
* @tc.desc: modeSupportInfo test for single window, window mode is not supported when show, show failed
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
|
||||
window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING |
|
||||
window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window->GetMode());
|
||||
ASSERT_NE(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->Destroy();
|
||||
}
|
||||
|
||||
@@ -190,9 +168,9 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTe
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window1 = Utils::CreateTestWindow(fullAppInfo_1_);
|
||||
window1->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
window1->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
const sptr<Window>& window2 = Utils::CreateTestWindow(fullAppInfo_2_);
|
||||
window2->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL);
|
||||
window2->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL);
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, window2->Show());
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE);
|
||||
@@ -213,7 +191,7 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTe
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
|
||||
window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE);
|
||||
usleep(WAIT_SYANC_US);
|
||||
@@ -224,30 +202,6 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTe
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE);
|
||||
usleep(WAIT_SYANC_US);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowModeSupportInfo07
|
||||
* @tc.desc: modeSupportInfo test for split
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo07, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window1 = Utils::CreateTestWindow(fullAppInfo_1_);
|
||||
window1->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL);
|
||||
const sptr<Window>& window2 = Utils::CreateTestWindow(fullAppInfo_2_);
|
||||
window2->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, window2->Show());
|
||||
usleep(WAIT_SYANC_US);
|
||||
|
||||
window1->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
|
||||
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, window1->GetMode());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window2->GetMode());
|
||||
|
||||
window1->Destroy();
|
||||
window2->Destroy();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
@@ -29,6 +29,7 @@ enum class MinimizeReason : uint32_t {
|
||||
MINIMIZE_BUTTON,
|
||||
MINIMIZE_ALL,
|
||||
LAYOUT_TILE,
|
||||
LAYOUT_CASCADE,
|
||||
MAX_APP_COUNT,
|
||||
SPLIT_REPLACE,
|
||||
SPLIT_QUIT,
|
||||
|
||||
@@ -30,7 +30,8 @@ public:
|
||||
StartingWindow() = delete;
|
||||
~StartingWindow() = default;
|
||||
|
||||
static sptr<WindowNode> CreateWindowNode(sptr<WindowTransitionInfo> info, uint32_t winId);
|
||||
static sptr<WindowNode> CreateWindowNode(sptr<WindowTransitionInfo> info,
|
||||
uint32_t winId, WindowLayoutMode layoutMode);
|
||||
static void HandleClientWindowCreate(sptr<WindowNode>& node, sptr<IWindow>& window,
|
||||
uint32_t& windowId, const std::shared_ptr<RSSurfaceNode>& surfaceNode, sptr<WindowProperty>& property,
|
||||
int32_t pid, int32_t uid);
|
||||
|
||||
@@ -61,7 +61,6 @@ public:
|
||||
void ProcessDisplayCreate(DisplayId displayId, const std::map<DisplayId, Rect>& displayRectMap);
|
||||
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(const SplitRatioConfig& splitRatioConfig);
|
||||
|
||||
protected:
|
||||
@@ -91,16 +90,15 @@ protected:
|
||||
|
||||
void UpdateFloatingWindowSizeForStretchableWindow(const sptr<WindowNode>& node,
|
||||
const Rect& displayRect, Rect& winRect) const;
|
||||
void UpdateFloatingWindowSizeByCustomizedLimits(const sptr<WindowNode>& node,
|
||||
void UpdateFloatingWindowSizeBySizeLimits(const sptr<WindowNode>& node,
|
||||
const Rect& displayRect, Rect& winRect) const;
|
||||
void UpdateFloatingWindowSizeBySystemLimits(const sptr<WindowNode>& node,
|
||||
const Rect& displayRect, Rect& winRect) const;
|
||||
void LimitWindowPositionWhenInitRectOrMove(const sptr<WindowNode>& node, Rect& winRect) const;
|
||||
void LimitWindowPositionWhenDrag(const sptr<WindowNode>& node, Rect& winRect) const;
|
||||
void FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr<WindowNode>& node, Rect& winRect,
|
||||
const FloatingWindowLimitsConfig& limitConfig);
|
||||
FloatingWindowLimitsConfig GetCustomizedLimitsConfig(const Rect& displayRect, float virtualPixelRatio);
|
||||
FloatingWindowLimitsConfig GetSystemLimitsConfig(const Rect& displayRect, float virtualPixelRatio);
|
||||
void FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr<WindowNode>& node, Rect& winRect);
|
||||
void UpdateWindowSizeLimits(const sptr<WindowNode>& node);
|
||||
WindowSizeLimits GetSystemSizeLimits(const Rect& displayRect, float virtualPixelRatio);
|
||||
|
||||
const std::set<WindowType> avoidTypes_ {
|
||||
WindowType::WINDOW_TYPE_STATUS_BAR,
|
||||
@@ -122,7 +120,6 @@ protected:
|
||||
Rect displayGroupRect_;
|
||||
Rect displayGroupLimitRect_;
|
||||
bool isMultiDisplay_ = false;
|
||||
FloatingWindowLimitsConfig floatingWindowLimitsConfig_;
|
||||
SplitRatioConfig splitRatioConfig_;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -118,7 +118,6 @@ private:
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type);
|
||||
WMError GetFocusWindowInfo(sptr<IRemoteObject>& abilityToken);
|
||||
void ConfigureWindowManagerService();
|
||||
void ConfigFloatWindowLimits();
|
||||
|
||||
static inline SingletonDelegator<WindowManagerService> delegator;
|
||||
std::map<uint32_t, uint32_t> accessTokenIdMaps_;
|
||||
|
||||
@@ -71,6 +71,7 @@ public:
|
||||
void SetDragType(DragType dragType);
|
||||
void SetOriginRect(const Rect& rect);
|
||||
void SetTouchHotAreas(const std::vector<Rect>& rects);
|
||||
void SetWindowSizeLimits(const WindowSizeLimits& sizeLimits);
|
||||
|
||||
const sptr<IWindow>& GetWindowToken() const;
|
||||
uint32_t GetWindowId() const;
|
||||
@@ -103,6 +104,7 @@ public:
|
||||
void ResetWindowSizeChangeReason();
|
||||
void GetTouchHotAreas(std::vector<Rect>& rects) const;
|
||||
uint32_t GetAccessTokenId() const;
|
||||
WindowSizeLimits GetWindowSizeLimits() const;
|
||||
|
||||
bool EnableDefaultAnimation(bool propertyEnabled, bool animationPlayed);
|
||||
sptr<WindowNode> parent_;
|
||||
|
||||
@@ -109,6 +109,7 @@ public:
|
||||
void UpdateAvoidAreaListener(sptr<WindowNode>& windowNode, bool haveAvoidAreaListener);
|
||||
void BeforeProcessWindowAvoidAreaChangeWhenDisplayChange() const;
|
||||
void ProcessWindowAvoidAreaChangeWhenDisplayChange() const;
|
||||
WindowLayoutMode GetCurrentLayoutMode() const;
|
||||
|
||||
private:
|
||||
void TraverseWindowNode(sptr<WindowNode>& root, std::vector<sptr<WindowNode>>& windowNodes) const;
|
||||
@@ -150,6 +151,7 @@ private:
|
||||
const std::vector<DisplayId>& curShowingDisplays);
|
||||
void FillWindowInfo(sptr<WindowInfo>& windowInfo, const sptr<WindowNode>& node) const;
|
||||
bool CheckWindowNodeWhetherInWindowTree(const sptr<WindowNode>& node) const;
|
||||
void UpdateModeSupportInfoWhenKeyguardChange(const sptr<WindowNode>& node, bool up);
|
||||
|
||||
float displayBrightness_ = UNDEFINED_BRIGHTNESS;
|
||||
uint32_t brightnessWindow_ = INVALID_WINDOW_ID;
|
||||
|
||||
@@ -93,10 +93,10 @@ public:
|
||||
uint32_t GetWindowIdByObject(const sptr<IRemoteObject>& remoteObject);
|
||||
sptr<WindowNode> GetWindowForDumpAceHelpInfo() const;
|
||||
void DestroyLeakStartingWindow();
|
||||
void SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig);
|
||||
void SetSplitRatios(const std::vector<float>& splitRatioNumbers);
|
||||
void SetExitSplitRatios(const std::vector<float>& exitSplitRatios);
|
||||
void MinimizeTargetWindows(std::vector<uint32_t>& windowIds);
|
||||
WindowLayoutMode GetCurrentLayoutMode(DisplayId displayId);
|
||||
private:
|
||||
void OnRemoteDied(const sptr<IRemoteObject>& remoteObject);
|
||||
WMError DestroyWindowInner(sptr<WindowNode>& node);
|
||||
@@ -134,7 +134,6 @@ private:
|
||||
this, std::placeholders::_1));
|
||||
Callback callback_;
|
||||
uint32_t maxAppWindowNumber_ = 100;
|
||||
FloatingWindowLimitsConfig floatingWindowLimitsConfig_;
|
||||
SplitRatioConfig splitRatioConfig_ = {0.1, 0.9, {}};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,12 +32,28 @@ SurfaceDraw StartingWindow::surfaceDraw_;
|
||||
static bool g_hasInit = false;
|
||||
std::recursive_mutex StartingWindow::mutex_;
|
||||
|
||||
sptr<WindowNode> StartingWindow::CreateWindowNode(sptr<WindowTransitionInfo> info, uint32_t winId)
|
||||
sptr<WindowNode> StartingWindow::CreateWindowNode(sptr<WindowTransitionInfo> info,
|
||||
uint32_t winId, WindowLayoutMode layoutMode)
|
||||
{
|
||||
sptr<WindowProperty> property = new(std::nothrow) WindowProperty();
|
||||
if (property == nullptr) {
|
||||
if (property == nullptr || info == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t modeSupportInfo = 0;
|
||||
for (auto mode : info->GetWindowSupportModes()) {
|
||||
modeSupportInfo |= mode;
|
||||
}
|
||||
|
||||
// if mode isn't be supported or don't support floating mode in tile mode, create starting window failed
|
||||
if ((!WindowHelper::IsWindowModeSupported(modeSupportInfo, info->GetWindowMode())) ||
|
||||
((!WindowHelper::IsWindowModeSupported(modeSupportInfo, WindowMode::WINDOW_MODE_FLOATING)) &&
|
||||
(layoutMode == WindowLayoutMode::TILE)) ||
|
||||
(WindowHelper::IsOnlySupportSplitAndShowWhenLocked(info->GetShowFlagWhenLocked(), modeSupportInfo))) {
|
||||
WLOGFI("window mode is not be supported or not support floating mode in tile, cancel starting window");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
property->SetRequestRect(info->GetWindowRect());
|
||||
property->SetWindowMode(info->GetWindowMode());
|
||||
property->SetDisplayId(info->GetDisplayId());
|
||||
@@ -56,7 +72,6 @@ sptr<WindowNode> StartingWindow::CreateWindowNode(sptr<WindowTransitionInfo> inf
|
||||
if (CreateLeashAndStartingSurfaceNode(node) != WMError::WM_OK) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,12 +52,13 @@ void WindowController::StartingWindow(sptr<WindowTransitionInfo> info, sptr<Medi
|
||||
}
|
||||
WM_SCOPED_ASYNC_TRACE_BEGIN(static_cast<int32_t>(TraceTaskId::STARTING_WINDOW), "wms:async:ShowStartingWindow");
|
||||
auto node = windowRoot_->FindWindowNodeWithToken(info->GetAbilityToken());
|
||||
auto layoutMode = windowRoot_->GetCurrentLayoutMode(info->GetDisplayId());
|
||||
if (node == nullptr) {
|
||||
if (!isColdStart) {
|
||||
WLOGFE("no windowNode exists but is hot start!");
|
||||
return;
|
||||
}
|
||||
node = StartingWindow::CreateWindowNode(info, GenWindowId());
|
||||
node = StartingWindow::CreateWindowNode(info, GenWindowId(), layoutMode);
|
||||
if (node == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -455,16 +455,20 @@ void WindowLayoutPolicy::CalcAndSetNodeHotZone(const Rect& winRect, const sptr<W
|
||||
node->SetTouchHotAreas(hotAreas);
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr<WindowNode>& node, Rect& winRect,
|
||||
const FloatingWindowLimitsConfig& limitConfig)
|
||||
void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr<WindowNode>& node, Rect& winRect)
|
||||
{
|
||||
if (limitConfig.maxWidth_ == limitConfig.minWidth_ &&
|
||||
limitConfig.maxHeight_ == limitConfig.minHeight_) {
|
||||
const auto& sizeLimits = node->GetWindowSizeLimits();
|
||||
if (sizeLimits.maxWidth_ == sizeLimits.minWidth_ &&
|
||||
sizeLimits.maxHeight_ == sizeLimits.minHeight_) {
|
||||
WLOGFI("window rect can not be changed");
|
||||
return;
|
||||
}
|
||||
if (winRect.height_ == 0) {
|
||||
WLOGFE("the height of window is zero");
|
||||
return;
|
||||
}
|
||||
float curRatio = static_cast<float>(winRect.width_) / static_cast<float>(winRect.height_);
|
||||
if (limitConfig.minRatio_ <= curRatio && curRatio <= limitConfig.maxRatio_) {
|
||||
if (sizeLimits.minRatio_ <= curRatio && curRatio <= sizeLimits.maxRatio_) {
|
||||
WLOGFI("window ratio is satisfied with limit ratio, curRatio: %{public}f", curRatio);
|
||||
return;
|
||||
}
|
||||
@@ -490,10 +494,10 @@ void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr<
|
||||
limitMaxPosX = dockWinRect.posX_ - static_cast<int32_t>(windowTitleBarH);
|
||||
}
|
||||
|
||||
float newRatio = curRatio < limitConfig.minRatio_ ? limitConfig.minRatio_ : limitConfig.maxRatio_;
|
||||
float newRatio = curRatio < sizeLimits.minRatio_ ? sizeLimits.minRatio_ : sizeLimits.maxRatio_;
|
||||
if ((winRect.posX_ + static_cast<int32_t>(winRect.width_) == limitMinPosX) || (winRect.posX_ == limitMaxPosX)) {
|
||||
// height can not be changed
|
||||
if (limitConfig.maxHeight_ == limitConfig.minHeight_) {
|
||||
if (sizeLimits.maxHeight_ == sizeLimits.minHeight_) {
|
||||
return;
|
||||
}
|
||||
winRect.height_ = static_cast<uint32_t>(static_cast<float>(winRect.width_) / newRatio);
|
||||
@@ -501,7 +505,7 @@ void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr<
|
||||
|
||||
if ((winRect.posY_ == limitMinPosY) || (winRect.posX_ == limitMaxPosY)) {
|
||||
// width can not be changed
|
||||
if (limitConfig.maxWidth_ == limitConfig.minWidth_) {
|
||||
if (sizeLimits.maxWidth_ == sizeLimits.minWidth_) {
|
||||
return;
|
||||
}
|
||||
winRect.width_ = static_cast<uint32_t>(static_cast<float>(winRect.height_) * newRatio);
|
||||
@@ -510,79 +514,76 @@ void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr<
|
||||
winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
|
||||
}
|
||||
|
||||
FloatingWindowLimitsConfig WindowLayoutPolicy::GetSystemLimitsConfig(const Rect& displayRect, float virtualPixelRatio)
|
||||
WindowSizeLimits WindowLayoutPolicy::GetSystemSizeLimits(const Rect& displayRect, float virtualPixelRatio)
|
||||
{
|
||||
FloatingWindowLimitsConfig limitConfig;
|
||||
limitConfig.maxWidth_ = static_cast<uint32_t>(MAX_FLOATING_SIZE * virtualPixelRatio);
|
||||
limitConfig.maxHeight_ = static_cast<uint32_t>(MAX_FLOATING_SIZE * virtualPixelRatio);
|
||||
limitConfig.minWidth_ = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_WIDTH * virtualPixelRatio);
|
||||
limitConfig.minHeight_ = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_HEIGHT * virtualPixelRatio);
|
||||
WindowSizeLimits systemLimits;
|
||||
systemLimits.maxWidth_ = static_cast<uint32_t>(MAX_FLOATING_SIZE * virtualPixelRatio);
|
||||
systemLimits.maxHeight_ = static_cast<uint32_t>(MAX_FLOATING_SIZE * virtualPixelRatio);
|
||||
systemLimits.minWidth_ = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_WIDTH * virtualPixelRatio);
|
||||
systemLimits.minHeight_ = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_HEIGHT * virtualPixelRatio);
|
||||
if (displayRect.width_ > displayRect.height_) {
|
||||
std::swap(limitConfig.minWidth_, limitConfig.minHeight_);
|
||||
std::swap(systemLimits.minWidth_, systemLimits.minHeight_);
|
||||
}
|
||||
WLOGFI("maxWidth: %{public}u, maxHeight: %{public}u, minWidth: %{public}u, minHeight: %{public}u "
|
||||
"maxRatio: %{public}f, minRatio: %{public}f", limitConfig.maxWidth_, limitConfig.maxHeight_,
|
||||
limitConfig.minWidth_, limitConfig.minHeight_, limitConfig.maxRatio_, limitConfig.minRatio_);
|
||||
return limitConfig;
|
||||
"maxRatio: %{public}f, minRatio: %{public}f", systemLimits.maxWidth_, systemLimits.maxHeight_,
|
||||
systemLimits.minWidth_, systemLimits.minHeight_, systemLimits.maxRatio_, systemLimits.minRatio_);
|
||||
return systemLimits;
|
||||
}
|
||||
|
||||
FloatingWindowLimitsConfig WindowLayoutPolicy::GetCustomizedLimitsConfig(const Rect& displayRect,
|
||||
float virtualPixelRatio)
|
||||
void WindowLayoutPolicy::UpdateWindowSizeLimits(const sptr<WindowNode>& node)
|
||||
{
|
||||
const auto& systemLimits = GetSystemLimitsConfig(displayRect, virtualPixelRatio);
|
||||
FloatingWindowLimitsConfig newLimitConfig = systemLimits;
|
||||
const auto& displayRect = displayGroupInfo_->GetDisplayRect(node->GetDisplayId());
|
||||
const auto& virtualPixelRatio = GetVirtualPixelRatio(node->GetDisplayId());
|
||||
const auto& systemLimits = GetSystemSizeLimits(displayRect, virtualPixelRatio);
|
||||
const auto& customizedLimits = node->GetWindowSizeLimits();
|
||||
WindowSizeLimits newLimits = systemLimits;
|
||||
|
||||
// configured limits of floating window
|
||||
uint32_t configuredMaxWidth = static_cast<uint32_t>(floatingWindowLimitsConfig_.maxWidth_ * virtualPixelRatio);
|
||||
uint32_t configuredMaxHeight = static_cast<uint32_t>(floatingWindowLimitsConfig_.maxHeight_ * virtualPixelRatio);
|
||||
uint32_t configuredMinWidth = static_cast<uint32_t>(floatingWindowLimitsConfig_.minWidth_ * virtualPixelRatio);
|
||||
uint32_t configuredMinHeight = static_cast<uint32_t>(floatingWindowLimitsConfig_.minHeight_ * virtualPixelRatio);
|
||||
float configuredMaxRatio = floatingWindowLimitsConfig_.maxRatio_;
|
||||
float configuredMinRatio = floatingWindowLimitsConfig_.minRatio_;
|
||||
uint32_t configuredMaxWidth = static_cast<uint32_t>(customizedLimits.maxWidth_ * virtualPixelRatio);
|
||||
uint32_t configuredMaxHeight = static_cast<uint32_t>(customizedLimits.maxHeight_ * virtualPixelRatio);
|
||||
uint32_t configuredMinWidth = static_cast<uint32_t>(customizedLimits.minWidth_ * virtualPixelRatio);
|
||||
uint32_t configuredMinHeight = static_cast<uint32_t>(customizedLimits.minHeight_ * virtualPixelRatio);
|
||||
float configuerdMaxRatio = customizedLimits.maxRatio_;
|
||||
float configuerdMinRatio = customizedLimits.minRatio_;
|
||||
|
||||
// calculate new limit size
|
||||
if (systemLimits.minWidth_ <= configuredMaxWidth && configuredMaxWidth <= systemLimits.maxWidth_) {
|
||||
newLimitConfig.maxWidth_ = configuredMaxWidth;
|
||||
newLimits.maxWidth_ = configuredMaxWidth;
|
||||
}
|
||||
if (systemLimits.minHeight_ <= configuredMaxHeight && configuredMaxHeight <= systemLimits.maxHeight_) {
|
||||
newLimitConfig.maxHeight_ = configuredMaxHeight;
|
||||
newLimits.maxHeight_ = configuredMaxHeight;
|
||||
}
|
||||
if (systemLimits.minWidth_ <= configuredMinWidth && configuredMinWidth <= newLimitConfig.maxWidth_) {
|
||||
newLimitConfig.minWidth_ = configuredMinWidth;
|
||||
if (systemLimits.minWidth_ <= configuredMinWidth && configuredMinWidth <= newLimits.maxWidth_) {
|
||||
newLimits.minWidth_ = configuredMinWidth;
|
||||
}
|
||||
if (systemLimits.minHeight_ <= configuredMinHeight && configuredMinHeight <= newLimitConfig.maxHeight_) {
|
||||
newLimitConfig.minHeight_ = configuredMinHeight;
|
||||
if (systemLimits.minHeight_ <= configuredMinHeight && configuredMinHeight <= newLimits.maxHeight_) {
|
||||
newLimits.minHeight_ = configuredMinHeight;
|
||||
}
|
||||
|
||||
// calculate new limit ratio
|
||||
newLimitConfig.maxRatio_ = static_cast<float>(newLimitConfig.maxWidth_) /
|
||||
static_cast<float>(newLimitConfig.minHeight_);
|
||||
newLimitConfig.minRatio_ = static_cast<float>(newLimitConfig.minWidth_) /
|
||||
static_cast<float>(newLimitConfig.maxHeight_);
|
||||
if (newLimitConfig.minRatio_ <= configuredMaxRatio && configuredMaxRatio <= newLimitConfig.maxRatio_) {
|
||||
newLimitConfig.maxRatio_ = configuredMaxRatio;
|
||||
newLimits.maxRatio_ = static_cast<float>(newLimits.maxWidth_) / static_cast<float>(newLimits.minHeight_);
|
||||
newLimits.minRatio_ = static_cast<float>(newLimits.minWidth_) / static_cast<float>(newLimits.maxHeight_);
|
||||
if (newLimits.minRatio_ <= configuerdMaxRatio && configuerdMaxRatio <= newLimits.maxRatio_) {
|
||||
newLimits.maxRatio_ = configuerdMaxRatio;
|
||||
}
|
||||
if (newLimitConfig.minRatio_ <= configuredMinRatio && configuredMinRatio <= newLimitConfig.maxRatio_) {
|
||||
newLimitConfig.minRatio_ = configuredMinRatio;
|
||||
if (newLimits.minRatio_ <= configuerdMinRatio && configuerdMinRatio <= newLimits.maxRatio_) {
|
||||
newLimits.minRatio_ = configuerdMinRatio;
|
||||
}
|
||||
|
||||
// recalculate limit size by new ratio
|
||||
uint32_t newMaxWidth = static_cast<uint32_t>(static_cast<float>(newLimitConfig.maxHeight_) *
|
||||
newLimitConfig.maxRatio_);
|
||||
newLimitConfig.maxWidth_ = std::min(newMaxWidth, newLimitConfig.maxWidth_);
|
||||
uint32_t newMinWidth = static_cast<uint32_t>(static_cast<float>(newLimitConfig.minHeight_) *
|
||||
newLimitConfig.minRatio_);
|
||||
newLimitConfig.minWidth_ = std::max(newMinWidth, newLimitConfig.minWidth_);
|
||||
uint32_t newMaxHeight = static_cast<uint32_t>(static_cast<float>(newLimitConfig.maxWidth_) /
|
||||
newLimitConfig.minRatio_);
|
||||
newLimitConfig.maxHeight_ = std::min(newMaxHeight, newLimitConfig.maxHeight_);
|
||||
uint32_t newMinHeight = static_cast<uint32_t>(static_cast<float>(newLimitConfig.minWidth_) /
|
||||
newLimitConfig.maxRatio_);
|
||||
newLimitConfig.minHeight_ = std::max(newMinHeight, newLimitConfig.minHeight_);
|
||||
uint32_t newMaxWidth = static_cast<uint32_t>(static_cast<float>(newLimits.maxHeight_) * newLimits.maxRatio_);
|
||||
newLimits.maxWidth_ = std::min(newMaxWidth, newLimits.maxWidth_);
|
||||
uint32_t newMinWidth = static_cast<uint32_t>(static_cast<float>(newLimits.minHeight_) * newLimits.minRatio_);
|
||||
newLimits.minWidth_ = std::max(newMinWidth, newLimits.minWidth_);
|
||||
uint32_t newMaxHeight = static_cast<uint32_t>(static_cast<float>(newLimits.maxWidth_) / newLimits.minRatio_);
|
||||
newLimits.maxHeight_ = std::min(newMaxHeight, newLimits.maxHeight_);
|
||||
uint32_t newMinHeight = static_cast<uint32_t>(static_cast<float>(newLimits.minWidth_) / newLimits.maxRatio_);
|
||||
newLimits.minHeight_ = std::max(newMinHeight, newLimits.minHeight_);
|
||||
|
||||
WLOGFI("maxWidth: %{public}u, maxHeight: %{public}u, minWidth: %{public}u, minHeight: %{public}u, "
|
||||
"maxRatio: %{public}f, minRatio: %{public}f", newLimitConfig.maxWidth_, newLimitConfig.maxHeight_,
|
||||
newLimitConfig.minWidth_, newLimitConfig.minHeight_, newLimitConfig.maxRatio_, newLimitConfig.minRatio_);
|
||||
return newLimitConfig;
|
||||
"maxRatio: %{public}f, minRatio: %{public}f", newLimits.maxWidth_, newLimits.maxHeight_,
|
||||
newLimits.minWidth_, newLimits.minHeight_, newLimits.maxRatio_, newLimits.minRatio_);
|
||||
node->SetWindowSizeLimits(newLimits);
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::UpdateFloatingWindowSizeForStretchableWindow(const sptr<WindowNode>& node,
|
||||
@@ -604,12 +605,12 @@ void WindowLayoutPolicy::UpdateFloatingWindowSizeForStretchableWindow(const sptr
|
||||
}
|
||||
}
|
||||
// limit minimum size of window
|
||||
const auto& systemLimits = const_cast<WindowLayoutPolicy*>(this)->
|
||||
GetSystemLimitsConfig(displayRect, GetVirtualPixelRatio(node->GetDisplayId()));
|
||||
float scale = std::min(static_cast<float>(winRect.width_) / systemLimits.minWidth_,
|
||||
static_cast<float>(winRect.height_) / systemLimits.minHeight_);
|
||||
|
||||
const auto& sizeLimits = node->GetWindowSizeLimits();
|
||||
float scale = std::min(static_cast<float>(winRect.width_) / sizeLimits.minWidth_,
|
||||
static_cast<float>(winRect.height_) / sizeLimits.minHeight_);
|
||||
if (scale == 0) {
|
||||
WLOGE("invalid systemLimits");
|
||||
WLOGE("invalid sizeLimits");
|
||||
return;
|
||||
}
|
||||
if (scale < 1.0f) {
|
||||
@@ -618,45 +619,47 @@ void WindowLayoutPolicy::UpdateFloatingWindowSizeForStretchableWindow(const sptr
|
||||
}
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::UpdateFloatingWindowSizeByCustomizedLimits(const sptr<WindowNode>& node,
|
||||
void WindowLayoutPolicy::UpdateFloatingWindowSizeBySizeLimits(const sptr<WindowNode>& node,
|
||||
const Rect& displayRect, Rect& winRect) const
|
||||
{
|
||||
// get new limit config with the settings of system and app
|
||||
const auto& customizedLimits = const_cast<WindowLayoutPolicy*>(this)->
|
||||
GetCustomizedLimitsConfig(displayRect, GetVirtualPixelRatio(node->GetDisplayId()));
|
||||
const auto& sizeLimits = node->GetWindowSizeLimits();
|
||||
|
||||
// limit minimum and maximum size of floating (not system type) window
|
||||
winRect.width_ = std::max(customizedLimits.minWidth_, winRect.width_);
|
||||
winRect.height_ = std::max(customizedLimits.minHeight_, winRect.height_);
|
||||
winRect.width_ = std::min(customizedLimits.maxWidth_, winRect.width_);
|
||||
winRect.height_ = std::min(customizedLimits.maxHeight_, winRect.height_);
|
||||
// limit minimum size of floating (not system type) window
|
||||
if (!WindowHelper::IsSystemWindow(node->GetWindowType()) ||
|
||||
node->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT_CAMERA) {
|
||||
winRect.width_ = std::max(sizeLimits.minWidth_, winRect.width_);
|
||||
winRect.height_ = std::max(sizeLimits.minHeight_, winRect.height_);
|
||||
}
|
||||
winRect.width_ = std::min(sizeLimits.maxWidth_, winRect.width_);
|
||||
winRect.height_ = std::min(sizeLimits.maxHeight_, winRect.height_);
|
||||
WLOGFD("After limit by size, winRect: %{public}d %{public}d %{public}u %{public}u",
|
||||
winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
|
||||
|
||||
// width and height can not be changed
|
||||
if (customizedLimits.maxWidth_ == customizedLimits.minWidth_ &&
|
||||
customizedLimits.maxHeight_ == customizedLimits.minHeight_) {
|
||||
winRect.width_ = customizedLimits.maxWidth_;
|
||||
winRect.height_ = customizedLimits.maxHeight_;
|
||||
if (sizeLimits.maxWidth_ == sizeLimits.minWidth_ &&
|
||||
sizeLimits.maxHeight_ == sizeLimits.minHeight_) {
|
||||
winRect.width_ = sizeLimits.maxWidth_;
|
||||
winRect.height_ = sizeLimits.maxHeight_;
|
||||
WLOGFD("window rect can not be changed");
|
||||
return;
|
||||
}
|
||||
|
||||
float curRatio = static_cast<float>(winRect.width_) / static_cast<float>(winRect.height_);
|
||||
if ((customizedLimits.minWidth_ <= winRect.width_ && winRect.width_ <= customizedLimits.maxWidth_) &&
|
||||
(customizedLimits.minHeight_ <= winRect.height_ && winRect.height_ <= customizedLimits.maxHeight_) &&
|
||||
(customizedLimits.minRatio_ <= curRatio && curRatio <= customizedLimits.maxRatio_)) {
|
||||
WLOGFD("window size and ratio is satisfied with limit ratio, curSize: [%{public}d, %{public}d], "
|
||||
// there is no need to fix size by ratio if this is not main floating window
|
||||
if (!WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode()) ||
|
||||
(sizeLimits.minRatio_ <= curRatio && curRatio <= sizeLimits.maxRatio_)) {
|
||||
WLOGFD("window is system window or ratio is satisfied with limits, curSize: [%{public}d, %{public}d], "
|
||||
"curRatio: %{public}f", winRect.width_, winRect.height_, curRatio);
|
||||
return;
|
||||
}
|
||||
|
||||
float newRatio = curRatio < customizedLimits.minRatio_ ? customizedLimits.minRatio_ : customizedLimits.maxRatio_;
|
||||
if (customizedLimits.maxWidth_ == customizedLimits.minWidth_) {
|
||||
float newRatio = curRatio < sizeLimits.minRatio_ ? sizeLimits.minRatio_ : sizeLimits.maxRatio_;
|
||||
if (sizeLimits.maxWidth_ == sizeLimits.minWidth_) {
|
||||
winRect.height_ = static_cast<uint32_t>(static_cast<float>(winRect.width_) / newRatio);
|
||||
return;
|
||||
}
|
||||
if (customizedLimits.maxHeight_ == customizedLimits.minHeight_) {
|
||||
if (sizeLimits.maxHeight_ == sizeLimits.minHeight_) {
|
||||
winRect.width_ = static_cast<uint32_t>(static_cast<float>(winRect.height_) * newRatio);
|
||||
return;
|
||||
}
|
||||
@@ -673,25 +676,6 @@ void WindowLayoutPolicy::UpdateFloatingWindowSizeByCustomizedLimits(const sptr<W
|
||||
winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::UpdateFloatingWindowSizeBySystemLimits(const sptr<WindowNode>& node,
|
||||
const Rect& displayRect, Rect& winRect) const
|
||||
{
|
||||
const auto& systemLimits = const_cast<WindowLayoutPolicy*>(this)->
|
||||
GetSystemLimitsConfig(displayRect, GetVirtualPixelRatio(node->GetDisplayId()));
|
||||
|
||||
// limit minimum size of floating (not system type) window
|
||||
if (!WindowHelper::IsSystemWindow(node->GetWindowType()) ||
|
||||
node->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT_CAMERA) {
|
||||
winRect.width_ = std::max(systemLimits.minWidth_, winRect.width_);
|
||||
winRect.height_ = std::max(systemLimits.minHeight_, winRect.height_);
|
||||
}
|
||||
// limit maximum size of all floating window
|
||||
winRect.width_ = std::min(systemLimits.maxWidth_, winRect.width_);
|
||||
winRect.height_ = std::min(systemLimits.maxHeight_, winRect.height_);
|
||||
WLOGFI("After limit by system config, winRect: %{public}d %{public}d %{public}u %{public}u",
|
||||
winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::LimitFloatingWindowSize(const sptr<WindowNode>& node,
|
||||
const Rect& displayRect,
|
||||
Rect& winRect) const
|
||||
@@ -700,12 +684,7 @@ void WindowLayoutPolicy::LimitFloatingWindowSize(const sptr<WindowNode>& node,
|
||||
return;
|
||||
}
|
||||
Rect oriWinRect = winRect;
|
||||
if (floatingWindowLimitsConfig_.isFloatingWindowLimitsConfigured_ &&
|
||||
(WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode()))) {
|
||||
UpdateFloatingWindowSizeByCustomizedLimits(node, displayRect, winRect);
|
||||
} else {
|
||||
UpdateFloatingWindowSizeBySystemLimits(node, displayRect, winRect);
|
||||
}
|
||||
UpdateFloatingWindowSizeBySizeLimits(node, displayRect, winRect);
|
||||
|
||||
if (node->GetStretchable() &&
|
||||
WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
@@ -736,12 +715,8 @@ void WindowLayoutPolicy::LimitMainFloatingWindowPosition(const sptr<WindowNode>&
|
||||
// if drag or move window, limit size and position
|
||||
if (reason == WindowSizeChangeReason::DRAG) {
|
||||
LimitWindowPositionWhenDrag(node, winRect);
|
||||
if (floatingWindowLimitsConfig_.isFloatingWindowLimitsConfigured_ &&
|
||||
(WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode()))) {
|
||||
const auto& limitConfig = const_cast<WindowLayoutPolicy*>(this)-> GetCustomizedLimitsConfig(
|
||||
displayGroupInfo_->GetDisplayRect(node->GetDisplayId()), GetVirtualPixelRatio(node->GetDisplayId()));
|
||||
const_cast<WindowLayoutPolicy*>(this)->
|
||||
FixWindowSizeByRatioIfDragBeyondLimitRegion(node, winRect, limitConfig);
|
||||
if (WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
const_cast<WindowLayoutPolicy*>(this)->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, winRect);
|
||||
}
|
||||
} else {
|
||||
// Limit window position, such as init window rect when show
|
||||
@@ -989,11 +964,6 @@ void WindowLayoutPolicy::SetSplitRatioConfig(const SplitRatioConfig& splitRatioC
|
||||
splitRatioConfig_ = splitRatioConfig;
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig)
|
||||
{
|
||||
floatingWindowLimitsConfig_ = floatingWindowLimitsConfig;
|
||||
}
|
||||
|
||||
Rect WindowLayoutPolicy::GetInitalDividerRect(DisplayId displayId) const
|
||||
{
|
||||
return INVALID_EMPTY_RECT;
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "window_layout_policy_cascade.h"
|
||||
|
||||
#include "minimize_app.h"
|
||||
#include "window_helper.h"
|
||||
#include "window_inner_manager.h"
|
||||
#include "window_manager_hilog.h"
|
||||
@@ -179,6 +181,10 @@ void WindowLayoutPolicyCascade::AddWindowNode(const sptr<WindowNode>& node)
|
||||
WLOGFE("window property is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
// update window size limits when add window
|
||||
UpdateWindowSizeLimits(node);
|
||||
|
||||
if (WindowHelper::IsEmptyRect(property->GetRequestRect())) {
|
||||
SetCascadeRect(node);
|
||||
}
|
||||
@@ -466,6 +472,12 @@ void WindowLayoutPolicyCascade::Reorder()
|
||||
WLOGFI("get node failed or not app window.");
|
||||
continue;
|
||||
}
|
||||
// if window don't support floating mode, or default rect of cascade is not satisfied with limits
|
||||
if (!WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING) ||
|
||||
!WindowHelper::IsRectSatisfiedWithSizeLimits(rect, node->GetWindowSizeLimits())) {
|
||||
MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_CASCADE);
|
||||
continue;
|
||||
}
|
||||
if (isFirstReorderedWindow) {
|
||||
isFirstReorderedWindow = false;
|
||||
} else {
|
||||
@@ -473,13 +485,12 @@ void WindowLayoutPolicyCascade::Reorder()
|
||||
}
|
||||
node->SetRequestRect(rect);
|
||||
node->SetDecoStatus(true);
|
||||
if (node->GetWindowMode() != WindowMode::WINDOW_MODE_FLOATING &&
|
||||
WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING)) {
|
||||
node->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
if (node->GetWindowToken()) {
|
||||
node->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
}
|
||||
if (node->GetWindowMode() != WindowMode::WINDOW_MODE_FLOATING) {
|
||||
node->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
if (node->GetWindowToken()) {
|
||||
node->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
}
|
||||
}
|
||||
WLOGFI("Cascade reorder Id: %{public}d, rect:[%{public}d, %{public}d, %{public}d, %{public}d]",
|
||||
node->GetWindowId(), rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
}
|
||||
|
||||
@@ -118,6 +118,10 @@ void WindowLayoutPolicyTile::InitTileWindowRects(DisplayId displayId)
|
||||
void WindowLayoutPolicyTile::AddWindowNode(const sptr<WindowNode>& node)
|
||||
{
|
||||
WM_FUNCTION_TRACE();
|
||||
|
||||
// update window size limits when add window
|
||||
UpdateWindowSizeLimits(node);
|
||||
|
||||
if (WindowHelper::IsMainWindow(node->GetWindowType())) {
|
||||
DisplayId displayId = node->GetDisplayId();
|
||||
ForegroundNodeQueuePushBack(node, displayId);
|
||||
@@ -206,6 +210,12 @@ void WindowLayoutPolicyTile::ForegroundNodeQueuePushBack(const sptr<WindowNode>&
|
||||
if (iter != foregroundNodes.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING)) {
|
||||
WLOGFD("window don't support tile mode, winId: %{public}d", node->GetWindowId());
|
||||
MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_TILE);
|
||||
return;
|
||||
}
|
||||
WLOGFI("add win in tile, displayId: %{public}" PRIu64", winId: %{public}d", displayId, node->GetWindowId());
|
||||
while (foregroundNodes.size() >= maxTileWinNumMap_[displayId]) {
|
||||
auto removeNode = foregroundNodes.front();
|
||||
@@ -247,7 +257,8 @@ void WindowLayoutPolicyTile::AssignNodePropertyForTileWindows(DisplayId displayI
|
||||
auto rectIt = presetRect.begin();
|
||||
for (auto node : foregroundNodesMap_[displayId]) {
|
||||
auto& rect = (*rectIt);
|
||||
if (WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING)) {
|
||||
if (WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING) &&
|
||||
WindowHelper::IsRectSatisfiedWithSizeLimits(rect, node->GetWindowSizeLimits())) {
|
||||
node->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
if (node->GetWindowToken()) {
|
||||
node->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
@@ -257,6 +268,8 @@ void WindowLayoutPolicyTile::AssignNodePropertyForTileWindows(DisplayId displayI
|
||||
WLOGFI("set rect for qwin id: %{public}d [%{public}d %{public}d %{public}d %{public}d]",
|
||||
node->GetWindowId(), rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
rectIt++;
|
||||
} else {
|
||||
MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_TILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,14 +73,12 @@ bool WindowManagerConfig::LoadConfigXml()
|
||||
continue;
|
||||
}
|
||||
if (!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("maxAppWindowNumber")) ||
|
||||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("modeChangeHotZones")) ||
|
||||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("floatingWindowLimitSize"))) {
|
||||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("modeChangeHotZones"))) {
|
||||
ReadIntNumbersConfigInfo(curNodePtr);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("floatingWindowLimitRatio")) ||
|
||||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("splitRatios")) ||
|
||||
if (!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("splitRatios")) ||
|
||||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("exitSplitRatios"))) {
|
||||
ReadFloatNumbersConfigInfo(curNodePtr);
|
||||
continue;
|
||||
|
||||
@@ -237,33 +237,6 @@ int WindowManagerService::Dump(int fd, const std::vector<std::u16string>& args)
|
||||
}).get();
|
||||
}
|
||||
|
||||
void WindowManagerService::ConfigFloatWindowLimits()
|
||||
{
|
||||
const auto& intNumbersConfig = WindowManagerConfig::GetIntNumbersConfig();
|
||||
const auto& floatNumbersConfig = WindowManagerConfig::GetFloatNumbersConfig();
|
||||
|
||||
FloatingWindowLimitsConfig floatingWindowLimitsConfig;
|
||||
if (intNumbersConfig.count("floatingWindowLimitSize") != 0) {
|
||||
auto numbers = intNumbersConfig.at("floatingWindowLimitSize");
|
||||
if (numbers.size() == 4) { // 4, limitSize
|
||||
floatingWindowLimitsConfig.maxWidth_ = static_cast<uint32_t>(numbers[0]); // 0 max width
|
||||
floatingWindowLimitsConfig.maxHeight_ = static_cast<uint32_t>(numbers[1]); // 1 max height
|
||||
floatingWindowLimitsConfig.minWidth_ = static_cast<uint32_t>(numbers[2]); // 2 min width
|
||||
floatingWindowLimitsConfig.minHeight_ = static_cast<uint32_t>(numbers[3]); // 3 min height
|
||||
floatingWindowLimitsConfig.isFloatingWindowLimitsConfigured_ = true;
|
||||
}
|
||||
}
|
||||
if (floatNumbersConfig.count("floatingWindowLimitRatio") != 0) {
|
||||
auto numbers = floatNumbersConfig.at("floatingWindowLimitRatio");
|
||||
if (numbers.size() == 2) { // 2, limitRatio
|
||||
floatingWindowLimitsConfig.maxRatio_ = static_cast<float>(numbers[0]); // 0 max ratio
|
||||
floatingWindowLimitsConfig.minRatio_ = static_cast<float>(numbers[1]); // 1 min ratio
|
||||
floatingWindowLimitsConfig.isFloatingWindowLimitsConfigured_ = true;
|
||||
}
|
||||
}
|
||||
windowRoot_->SetFloatingWindowLimitsConfig(floatingWindowLimitsConfig);
|
||||
}
|
||||
|
||||
void WindowManagerService::ConfigureWindowManagerService()
|
||||
{
|
||||
const auto& enableConfig = WindowManagerConfig::GetEnableConfig();
|
||||
@@ -301,8 +274,6 @@ void WindowManagerService::ConfigureWindowManagerService()
|
||||
}
|
||||
}
|
||||
|
||||
ConfigFloatWindowLimits();
|
||||
|
||||
if (floatNumbersConfig.count("splitRatios") != 0) {
|
||||
windowRoot_->SetSplitRatios(floatNumbersConfig.at("splitRatios"));
|
||||
}
|
||||
|
||||
@@ -196,6 +196,16 @@ void WindowNode::SetTouchHotAreas(const std::vector<Rect>& rects)
|
||||
touchHotAreas_ = rects;
|
||||
}
|
||||
|
||||
void WindowNode::SetWindowSizeLimits(const WindowSizeLimits& sizeLimits)
|
||||
{
|
||||
property_->SetSizeLimits(sizeLimits);
|
||||
}
|
||||
|
||||
WindowSizeLimits WindowNode::GetWindowSizeLimits() const
|
||||
{
|
||||
return property_->GetSizeLimits();
|
||||
}
|
||||
|
||||
DragType WindowNode::GetDragType() const
|
||||
{
|
||||
return property_->GetDragType();
|
||||
|
||||
@@ -1562,6 +1562,25 @@ WMError WindowNodeContainer::SwitchLayoutPolicy(WindowLayoutMode dstMode, Displa
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowNodeContainer::UpdateModeSupportInfoWhenKeyguardChange(const sptr<WindowNode>& node, bool up)
|
||||
{
|
||||
if (!WindowHelper::IsWindowModeSupported(node->GetWindowProperty()->GetRequestModeSupportInfo(),
|
||||
WindowMode::WINDOW_MODE_SPLIT_PRIMARY)) {
|
||||
WLOGFD("window doesn't support split mode, winId: %{public}d", node->GetWindowId());
|
||||
return;
|
||||
}
|
||||
uint32_t modeSupportInfo;
|
||||
if (up) {
|
||||
modeSupportInfo = node->GetModeSupportInfo() & (~WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY);
|
||||
} else {
|
||||
modeSupportInfo = node->GetModeSupportInfo() | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY;
|
||||
}
|
||||
node->SetModeSupportInfo(modeSupportInfo);
|
||||
if (node->GetWindowToken() != nullptr) {
|
||||
node->GetWindowToken()->UpdateWindowModeSupportInfo(modeSupportInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowNodeContainer::RaiseInputMethodWindowPriorityIfNeeded(const sptr<WindowNode>& node) const
|
||||
{
|
||||
if (node->GetWindowType() != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT || !isScreenLocked_) {
|
||||
@@ -1604,6 +1623,8 @@ void WindowNodeContainer::ReZOrderShowWhenLockedWindows(bool up)
|
||||
}
|
||||
}
|
||||
|
||||
UpdateModeSupportInfoWhenKeyguardChange(needReZOrderNode, up);
|
||||
|
||||
parentNode->children_.insert(position, needReZOrderNode);
|
||||
if (up && WindowHelper::IsSplitWindowMode(needReZOrderNode->GetWindowMode())) {
|
||||
needReZOrderNode->GetWindowProperty()->ResumeLastWindowMode();
|
||||
@@ -1617,8 +1638,7 @@ void WindowNodeContainer::ReZOrderShowWhenLockedWindows(bool up)
|
||||
}
|
||||
windowPair->UpdateIfSplitRelated(needReZOrderNode);
|
||||
}
|
||||
WLOGFI("ShowWhenLocked window %{public}u re-zorder when keyguard change %{public}u",
|
||||
needReZOrderNode->GetWindowId(), up);
|
||||
WLOGFI("window %{public}u re-zorder when keyguard change %{public}u", needReZOrderNode->GetWindowId(), up);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1867,5 +1887,10 @@ void WindowNodeContainer::UpdateCameraFloatWindowStatus(const sptr<WindowNode>&
|
||||
WindowManagerAgentController::GetInstance().UpdateCameraFloatWindowStatus(node->GetAccessTokenId(), isShowing);
|
||||
}
|
||||
}
|
||||
|
||||
WindowLayoutMode WindowNodeContainer::GetCurrentLayoutMode() const
|
||||
{
|
||||
return layoutMode_;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -183,10 +183,6 @@ void WindowPair::ExitSplitMode()
|
||||
hideWindow = secondary_;
|
||||
fullScreenWindow = primary_;
|
||||
}
|
||||
if (WindowHelper::IsWindowModeSupported(fullScreenWindow->GetModeSupportInfo(),
|
||||
WindowMode::WINDOW_MODE_FULLSCREEN)) {
|
||||
fullScreenWindow->GetWindowProperty()->SetLastWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
}
|
||||
MinimizeApp::AddNeedMinimizeApp(hideWindow, MinimizeReason::SPLIT_QUIT);
|
||||
MinimizeApp::ExecuteMinimizeTargetReason(MinimizeReason::SPLIT_QUIT);
|
||||
WLOGFI("Exit Split Mode, Minimize Window %{public}u", hideWindow->GetWindowId());
|
||||
@@ -385,16 +381,14 @@ void WindowPair::SwitchPosition()
|
||||
WLOGFI("Switch the pair pos, pri: %{public}u pri-mode: %{public}u, sec: %{public}u sec-mode: %{public}u,",
|
||||
primary_->GetWindowId(), primary_->GetWindowMode(), secondary_->GetWindowId(), secondary_->GetWindowMode());
|
||||
if (primary_->GetWindowMode() == secondary_->GetWindowMode() &&
|
||||
primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY &&
|
||||
WindowHelper::IsWindowModeSupported(primary_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_SPLIT_SECONDARY)) {
|
||||
primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY) {
|
||||
primary_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
|
||||
if (primary_->GetWindowToken() != nullptr) {
|
||||
primary_->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
|
||||
}
|
||||
std::swap(primary_, secondary_);
|
||||
} else if (primary_->GetWindowMode() == secondary_->GetWindowMode() &&
|
||||
primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_SECONDARY &&
|
||||
WindowHelper::IsWindowModeSupported(secondary_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_SPLIT_PRIMARY)) {
|
||||
primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_SECONDARY) {
|
||||
secondary_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
|
||||
if (secondary_->GetWindowToken() != nullptr) {
|
||||
secondary_->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
|
||||
|
||||
@@ -117,7 +117,6 @@ sptr<WindowNodeContainer> WindowRoot::CreateWindowNodeContainer(sptr<DisplayInfo
|
||||
WLOGFE("create container failed, displayId :%{public}" PRIu64 "", displayId);
|
||||
return nullptr;
|
||||
}
|
||||
container->GetLayoutPolicy()->SetFloatingWindowLimitsConfig(floatingWindowLimitsConfig_);
|
||||
container->GetLayoutPolicy()->SetSplitRatioConfig(splitRatioConfig_);
|
||||
return container;
|
||||
}
|
||||
@@ -481,7 +480,7 @@ WMError WindowRoot::AddWindowNode(uint32_t parentId, sptr<WindowNode>& node, boo
|
||||
return res;
|
||||
}
|
||||
// limit number of main window
|
||||
int mainWindowNumber = container->GetWindowCountByType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
uint32_t mainWindowNumber = container->GetWindowCountByType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
if (mainWindowNumber >= maxAppWindowNumber_ && node->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW) {
|
||||
container->MinimizeOldestAppWindow();
|
||||
}
|
||||
@@ -1310,9 +1309,14 @@ WMError WindowRoot::GetModeChangeHotZones(DisplayId displayId,
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowRoot::SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig)
|
||||
WindowLayoutMode WindowRoot::GetCurrentLayoutMode(DisplayId displayId)
|
||||
{
|
||||
floatingWindowLimitsConfig_ = floatingWindowLimitsConfig;
|
||||
auto container = GetOrCreateWindowNodeContainer(displayId);
|
||||
if (container == nullptr) {
|
||||
WLOGFE("GetCurrentLayoutMode failed, window container could not be found");
|
||||
return WindowLayoutMode::BASE;
|
||||
}
|
||||
return container->GetCurrentLayoutMode();
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
Reference in New Issue
Block a user