mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 15:00:12 +00:00
!2433 组件自动避让适配
Merge pull request !2433 from ZhengJiangliang/temp_avoid
This commit is contained in:
commit
aa10d75daa
@ -18,20 +18,25 @@
|
||||
#include <memory>
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class Context {
|
||||
public:
|
||||
Context() = default;
|
||||
virtual ~Context() = default;
|
||||
virtual std::string GetBundleName() const = 0;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
namespace AppExecFwk {
|
||||
class ApplicationInfo {
|
||||
public:
|
||||
uint32_t apiCompatibleVersion;
|
||||
};
|
||||
class Context {
|
||||
public:
|
||||
Context() = default;
|
||||
virtual ~Context() = default;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
namespace AbilityRuntime {
|
||||
class Context {
|
||||
public:
|
||||
Context() = default;
|
||||
virtual ~Context() = default;
|
||||
virtual std::string GetBundleName() const = 0;
|
||||
virtual std::shared_ptr<AppExecFwk::ApplicationInfo> GetApplicationInfo() const = 0;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_CONTEXT_H
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "refbase.h"
|
||||
#include "context.h"
|
||||
|
||||
namespace OHOS {
|
||||
class Parcel;
|
||||
|
@ -44,6 +44,7 @@ struct AbilityTransitionInfo : public Parcelable {
|
||||
TransitionReason reason_ = TransitionReason::ABILITY_TRANSITION;
|
||||
int32_t missionId_ = -1;
|
||||
AppExecFwk::DisplayOrientation orientation_ = AppExecFwk::DisplayOrientation::UNSPECIFIED;
|
||||
uint32_t apiCompatibleVersion_ = 0;
|
||||
|
||||
virtual bool Marshalling(Parcel& parcel) const override
|
||||
{
|
||||
|
@ -79,6 +79,7 @@ public:
|
||||
MOCK_METHOD1(SetActionEventHandler, void(std::function<void(const std::string& action)>&& actionCallback));
|
||||
MOCK_METHOD1(SetErrorEventHandler,
|
||||
void(std::function<void(const std::string& code, const std::string& msg)>&& actionCallback));
|
||||
MOCK_METHOD1(SetIgnoreViewSafeArea, void(bool ignoreViewSafeArea));
|
||||
};
|
||||
} // namespace Ace
|
||||
} // namespace OHOS
|
||||
|
@ -68,6 +68,8 @@ public:
|
||||
int32_t GetMissionId() const;
|
||||
void SetOrientation(AppExecFwk::DisplayOrientation orientation);
|
||||
AppExecFwk::DisplayOrientation GetOrientation() const;
|
||||
void SetApiCompatibleVersion(uint32_t apiCompatibleVersion);
|
||||
uint32_t GetApiCompatibleVersion() const;
|
||||
private:
|
||||
std::string bundleName_;
|
||||
std::string abilityName_;
|
||||
@ -83,6 +85,7 @@ private:
|
||||
WindowSizeLimits sizeLimits_;
|
||||
int32_t missionId_ = -1;
|
||||
AppExecFwk::DisplayOrientation orientation_ = AppExecFwk::DisplayOrientation::UNSPECIFIED;
|
||||
uint32_t apiCompatibleVersion_ = 0;
|
||||
};
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
|
@ -45,6 +45,7 @@ WindowTransitionInfo::WindowTransitionInfo(sptr<AAFwk::AbilityTransitionInfo> in
|
||||
sizeLimits_.minHeight_ = info->minWindowHeight_;
|
||||
reason_ = static_cast<TransitionReason>(info->reason_);
|
||||
orientation_ = info->orientation_;
|
||||
apiCompatibleVersion_ = info->apiCompatibleVersion_;
|
||||
}
|
||||
|
||||
void WindowTransitionInfo::SetBundleName(std::string name)
|
||||
@ -182,6 +183,16 @@ AppExecFwk::DisplayOrientation WindowTransitionInfo::GetOrientation() const
|
||||
return orientation_;
|
||||
}
|
||||
|
||||
void WindowTransitionInfo::SetApiCompatibleVersion(uint32_t apiCompatibleVersion)
|
||||
{
|
||||
apiCompatibleVersion_ = apiCompatibleVersion;
|
||||
}
|
||||
|
||||
uint32_t WindowTransitionInfo::GetApiCompatibleVersion() const
|
||||
{
|
||||
return apiCompatibleVersion_;
|
||||
}
|
||||
|
||||
bool WindowTransitionInfo::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
if (!parcel.WriteString(bundleName_) || !parcel.WriteString(abilityName_)) {
|
||||
|
@ -588,6 +588,8 @@ private:
|
||||
bool isAppFloatingWindow_ = false;
|
||||
bool isFocused_ = false;
|
||||
uint32_t mouseStyleID_ = 0;
|
||||
bool isIgnoreSafeAreaNeedNotify_ = false;
|
||||
bool isIgnoreSafeArea_ = false;
|
||||
const std::map<DragType, uint32_t> STYLEID_MAP = {
|
||||
{DragType::DRAG_UNDEFINED, MMI::MOUSE_ICON::DEFAULT},
|
||||
{DragType::DRAG_BOTTOM_OR_TOP, MMI::MOUSE_ICON::NORTH_SOUTH},
|
||||
|
@ -38,6 +38,14 @@ sptr<Window> Window::Create(const std::string& windowName, sptr<WindowOption>& o
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
uint32_t version = 0;
|
||||
if ((context != nullptr) && (context->GetApplicationInfo() != nullptr)) {
|
||||
version = context->GetApplicationInfo()->apiCompatibleVersion;
|
||||
}
|
||||
// 10 ArkUI新框架适用版本API10
|
||||
if (version >= 10) {
|
||||
option->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID);
|
||||
}
|
||||
WindowType type = option->GetWindowType();
|
||||
if (!(WindowHelper::IsAppWindow(type) || WindowHelper::IsSystemWindow(type))) {
|
||||
WLOGFE("window type is invalid %{public}d", type);
|
||||
|
@ -529,6 +529,9 @@ WMError WindowImpl::SetUIContent(const std::string& contentInfo,
|
||||
}
|
||||
// make uiContent available after Initialize/Restore
|
||||
uiContent_ = std::move(uiContent);
|
||||
if (isIgnoreSafeAreaNeedNotify_) {
|
||||
uiContent->SetIgnoreViewSafeArea(isIgnoreSafeArea_);
|
||||
}
|
||||
UpdateDecorEnable(true);
|
||||
|
||||
if (state_ == WindowState::STATE_SHOWN) {
|
||||
@ -708,25 +711,40 @@ WMError WindowImpl::SetLayoutFullScreen(bool status)
|
||||
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);
|
||||
if (ret != WMError::WM_OK) {
|
||||
WLOGFE("SetWindowMode errCode:%{public}d winId:%{public}u",
|
||||
static_cast<int32_t>(ret), property_->GetWindowId());
|
||||
return ret;
|
||||
WMError ret = WMError::WM_OK;
|
||||
uint32_t version = 0;
|
||||
if ((context_ != nullptr) && (context_->GetApplicationInfo() != nullptr)) {
|
||||
version = context_->GetApplicationInfo()->apiCompatibleVersion;
|
||||
}
|
||||
if (status) {
|
||||
ret = RemoveWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID);
|
||||
// 10 ArkUI新框架适用版本API10
|
||||
if (version >= 10) {
|
||||
if (uiContent_ != nullptr) {
|
||||
uiContent_->SetIgnoreViewSafeArea(status);
|
||||
} else {
|
||||
isIgnoreSafeAreaNeedNotify_ = true;
|
||||
isIgnoreSafeArea_ = status;
|
||||
}
|
||||
} else {
|
||||
ret = SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
if (ret != WMError::WM_OK) {
|
||||
WLOGFE("RemoveWindowFlag errCode:%{public}d winId:%{public}u",
|
||||
WLOGFE("SetWindowMode errCode:%{public}d winId:%{public}u",
|
||||
static_cast<int32_t>(ret), property_->GetWindowId());
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
ret = AddWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID);
|
||||
if (ret != WMError::WM_OK) {
|
||||
WLOGFE("AddWindowFlag errCode:%{public}d winId:%{public}u",
|
||||
static_cast<int32_t>(ret), property_->GetWindowId());
|
||||
return ret;
|
||||
if (status) {
|
||||
ret = RemoveWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID);
|
||||
if (ret != WMError::WM_OK) {
|
||||
WLOGFE("RemoveWindowFlag errCode:%{public}d winId:%{public}u",
|
||||
static_cast<int32_t>(ret), property_->GetWindowId());
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
ret = AddWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID);
|
||||
if (ret != WMError::WM_OK) {
|
||||
WLOGFE("AddWindowFlag errCode:%{public}d winId:%{public}u",
|
||||
static_cast<int32_t>(ret), property_->GetWindowId());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -82,15 +82,18 @@ sptr<WindowNode> StartingWindow::CreateWindowNode(const sptr<WindowTransitionInf
|
||||
WLOGFE("Set orientation from ability failed");
|
||||
return nullptr;
|
||||
}
|
||||
WLOGFD("orientation:%{public}u", orientation);
|
||||
property->SetRequestedOrientation(orientation);
|
||||
|
||||
property->SetDisplayId(info->GetDisplayId());
|
||||
property->SetWindowType(info->GetWindowType());
|
||||
auto displayInfo = DisplayGroupInfo::GetInstance().GetDisplayInfo(info->GetDisplayId());
|
||||
if (!(displayInfo && WmsUtils::IsExpectedRotatableWindow(orientation,
|
||||
displayInfo->GetDisplayOrientation(), property->GetWindowMode(), property->GetWindowFlags(), false))) {
|
||||
property->AddWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID);
|
||||
|
||||
// 10 ArkUI新框架适用版本API10
|
||||
if (info->GetApiCompatibleVersion() < 10) {
|
||||
auto displayInfo = DisplayGroupInfo::GetInstance().GetDisplayInfo(info->GetDisplayId());
|
||||
if (!(displayInfo && WmsUtils::IsExpectedRotatableWindow(orientation,
|
||||
displayInfo->GetDisplayOrientation(), property->GetWindowMode(), property->GetWindowFlags(), false))) {
|
||||
property->AddWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID);
|
||||
}
|
||||
}
|
||||
if (info->GetShowFlagWhenLocked()) {
|
||||
property->AddWindowFlag(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED);
|
||||
|
Loading…
Reference in New Issue
Block a user