add decor function

Signed-off-by: leafly2021 <figo.yefei@huawei.com>
Change-Id: Ic2b6dae128e51598fdaa825c92eedc10e6cd499b
Signed-off-by: leafly2021 <figo.yefei@huawei.com>
This commit is contained in:
leafly2021
2022-01-20 23:12:12 +08:00
parent 2b8d18e306
commit e35acdec55
4 changed files with 86 additions and 0 deletions
+6
View File
@@ -96,6 +96,12 @@ public:
virtual WMError SetUIContent(const std::string& contentInfo, NativeEngine* engine,
NativeValue* storage, bool isdistributed = false) = 0;
virtual const std::string& GetContentInfo() = 0;
virtual bool IsDecorEnable() = 0;
virtual WMError Maximize() = 0;
virtual WMError Minimize() = 0;
virtual WMError Recover() = 0;
virtual WMError Close() = 0;
};
}
}
+1
View File
@@ -74,6 +74,7 @@ ohos_shared_library("libwm") {
"//utils/native/base:utils",
# ace
"//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager",
"//foundation/ace/ace_engine/interfaces/innerkits/ace:ace_uicontent",
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core:appexecfwk_core",
"//foundation/graphic/standard:libsurface",
+7
View File
@@ -69,6 +69,12 @@ public:
virtual WMError MoveTo(int32_t x, int32_t y) override;
virtual WMError Resize(uint32_t width, uint32_t height) override;
virtual bool IsDecorEnable() override;
virtual WMError Maximize() override;
virtual WMError Minimize() override;
virtual WMError Recover() override;
virtual WMError Close() override;
virtual WMError RequestFocus() const override;
virtual void AddInputEventListener(std::shared_ptr<MMI::IInputEventConsumer>& inputEventListener) override;
@@ -141,6 +147,7 @@ private:
std::unique_ptr<Ace::UIContent> uiContent_;
std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext_; // give up when context offer getToken
std::shared_ptr<AbilityRuntime::Context> context_;
bool isDecorEnable_ = false;
const float STATUS_BAR_RATIO = 0.07;
const float NAVIGATION_BAR_RATIO = 0.07;
const float SYSTEM_ALARM_WINDOW_WIDTH_RATIO = 0.8;
+72
View File
@@ -25,6 +25,8 @@
#include "window_helper.h"
#include "window_manager_hilog.h"
#include <ability_manager_client.h>
namespace OHOS {
namespace Rosen {
namespace {
@@ -215,6 +217,11 @@ WMError WindowImpl::SetUIContent(const std::string& contentInfo,
WLOGFE("fail to SetUIContent id: %{public}d", property_->GetWindowId());
return WMError::WM_ERROR_NULLPTR;
}
if (WindowHelper::IsMainWindow(property_->GetWindowType())) {
isDecorEnable_ = true;
} else {
isDecorEnable_ = false;
}
if (isdistributed) {
uiContent_->Restore(this, contentInfo, storage);
} else {
@@ -419,6 +426,71 @@ WMError WindowImpl::Resize(uint32_t width, uint32_t height)
return SingletonContainer::Get<WindowAdapter>().Resize(property_->GetWindowId(), width, height);
}
bool WindowImpl::IsDecorEnable()
{
return isDecorEnable_;
}
WMError WindowImpl::Maximize()
{
WLOGFI("[Client] Window %{public}d Maximize", property_->GetWindowId());
if (!IsWindowValid()) {
WLOGFI("window is already destroyed or not created! id: %{public}d", property_->GetWindowId());
return WMError::WM_ERROR_INVALID_WINDOW;
}
if (WindowHelper::IsMainWindow(property_->GetWindowType())) {
SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
}
return WMError::WM_OK;
}
WMError WindowImpl::Minimize()
{
WLOGFI("[Client] Window %{public}d Minimize", property_->GetWindowId());
if (!IsWindowValid()) {
WLOGFI("window is already destroyed or not created! id: %{public}d", property_->GetWindowId());
return WMError::WM_ERROR_INVALID_WINDOW;
}
if (WindowHelper::IsMainWindow(property_->GetWindowType())) {
if (abilityContext_ != nullptr) {
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(abilityContext_->GetAbilityToken());
} else {
Hide();
}
}
return WMError::WM_OK;
}
WMError WindowImpl::Recover()
{
WLOGFI("[Client] Window %{public}d Normalize", property_->GetWindowId());
if (!IsWindowValid()) {
WLOGFI("window is already destroyed or not created! id: %{public}d", property_->GetWindowId());
return WMError::WM_ERROR_INVALID_WINDOW;
}
if (WindowHelper::IsMainWindow(property_->GetWindowType())) {
SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
}
return WMError::WM_OK;
}
WMError WindowImpl::Close()
{
WLOGFI("[Client] Window %{public}d Close", property_->GetWindowId());
if (!IsWindowValid()) {
WLOGFI("window is already destroyed or not created! id: %{public}d", property_->GetWindowId());
return WMError::WM_ERROR_INVALID_WINDOW;
}
if (WindowHelper::IsMainWindow(property_->GetWindowType())) {
if (abilityContext_ != nullptr) {
abilityContext_->TerminateSelf();
} else {
Destroy();
}
}
return WMError::WM_OK;
}
WMError WindowImpl::RequestFocus() const
{
if (!IsWindowValid()) {