!5 支持产品配置默认窗口模式(3.2-Beta2)

Merge pull request !5 from xukunkun/OpenHarmony-3.2-Beta2
This commit is contained in:
openharmony_ci
2022-08-17 13:43:24 +00:00
committed by Gitee
12 changed files with 97 additions and 19 deletions
+1 -1
View File
@@ -71,7 +71,7 @@ public:
private:
Rect windowRect_ { 0, 0, 0, 0 };
WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW };
WindowMode mode_ { WindowMode::WINDOW_MODE_FULLSCREEN };
WindowMode mode_ { WindowMode::WINDOW_MODE_UNDEFINED };
WindowBlurLevel level_ { WindowBlurLevel::WINDOW_BLUR_OFF };
bool focusable_ { true };
bool touchable_ { true };
+1
View File
@@ -359,6 +359,7 @@ enum class WindowUpdateType : int32_t {
struct SystemConfig {
bool isSystemDecorEnable_ = true;
bool isStretchable_ = false;
WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
};
}
}
@@ -28,4 +28,6 @@
<exitSplitRatios>0.1 0.9</exitSplitRatios>
<!--split screen ratios config-->
<splitRatios>0.5 0.33 0.67</splitRatios>
<!--default window mode config-->
<defaultWindowMode>1</defaultWindowMode>
</Configs>
+2 -2
View File
@@ -138,9 +138,9 @@ private:
Rect windowRect_ { 0, 0, 0, 0 }; // actual window rect
bool decoStatus_ { false }; // window has been decorated or not
WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW };
WindowMode mode_ { WindowMode::WINDOW_MODE_FULLSCREEN };
WindowMode mode_ { WindowMode::WINDOW_MODE_UNDEFINED };
WindowBlurLevel level_ { WindowBlurLevel::WINDOW_BLUR_OFF };
WindowMode lastMode_ { WindowMode::WINDOW_MODE_FULLSCREEN };
WindowMode lastMode_ { WindowMode::WINDOW_MODE_UNDEFINED };
uint32_t flags_ { 0 };
bool isFullScreen_ { true };
bool focusable_ { true };
+4
View File
@@ -377,6 +377,9 @@ private:
uint32_t GetModeSupportInfo() const;
WMError PreProcessShow(uint32_t reason, bool withAnimation);
bool NeedToStopShowing();
bool WindowCreateCheck(const std::string& parentName);
bool IsAppMainOrSubOrFloatingWindow();
void SetSystemConfig();
// colorspace, gamut
using ColorSpaceConvertMap = struct {
@@ -433,6 +436,7 @@ private:
bool isWaitingFrame_ = false;
bool needRemoveWindowInputChannel_ = false;
bool isListenerHandlerRunning_ = false;
bool isAppFloatingWindow_ = false;
};
} // namespace Rosen
} // namespace OHOS
+62 -13
View File
@@ -756,19 +756,62 @@ void WindowImpl::UpdateTitleButtonVisibility()
uiContent_->HideWindowTitleButton(hideSplitButton, hideMaximizeButton, false);
}
WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr<AbilityRuntime::Context>& context)
bool WindowImpl::IsAppMainOrSubOrFloatingWindow()
{
// App main window need decor config, stretchable config and effect config
// App sub window and float window need effect config
if (WindowHelper::IsAppWindow(GetType())) {
return true;
}
if (WindowHelper::IsAppFloatingWindow(GetType())) {
for (auto& winPair : windowMap_) {
auto win = winPair.second.second;
if (win != nullptr && win->GetType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW &&
context_.get() == win->GetContext().get()) {
isAppFloatingWindow_ = true;
return true;
}
}
}
return false;
}
void WindowImpl::SetSystemConfig()
{
if (!IsAppMainOrSubOrFloatingWindow()) {
return;
}
if (SingletonContainer::Get<WindowAdapter>().GetSystemConfig(windowSystemConfig_) == WMError::WM_OK) {
if (WindowHelper::IsMainWindow(property_->GetWindowType())) {
WLOGFI("get system decor enable:%{public}d", windowSystemConfig_.isSystemDecorEnable_);
property_->SetDecorEnable(windowSystemConfig_.isSystemDecorEnable_);
WLOGFI("get stretchable enable:%{public}d", windowSystemConfig_.isStretchable_);
property_->SetStretchable(windowSystemConfig_.isStretchable_);
// if window mode is undefined, set it from configuration
if (property_->GetWindowMode() == WindowMode::WINDOW_MODE_UNDEFINED) {
WLOGFI("get default window mode:%{public}u", windowSystemConfig_.defaultWindowMode_);
property_->SetWindowMode(windowSystemConfig_.defaultWindowMode_);
}
if (property_->GetLastWindowMode() == WindowMode::WINDOW_MODE_UNDEFINED) {
property_->SetLastWindowMode(windowSystemConfig_.defaultWindowMode_);
}
}
}
}
bool WindowImpl::WindowCreateCheck(const std::string& parentName)
{
WLOGFI("[Client] Window [name:%{public}s] Create", name_.c_str());
// check window name, same window names are forbidden
if (windowMap_.find(name_) != windowMap_.end()) {
WLOGFE("WindowName(%{public}s) already exists.", name_.c_str());
return WMError::WM_ERROR_INVALID_PARAM;
return false;
}
// check parent name, if create sub window and there is not exist parent Window, then return
if (parentName != "") {
if (windowMap_.find(parentName) == windowMap_.end()) {
WLOGFE("ParentName is empty or valid. ParentName is %{public}s", parentName.c_str());
return WMError::WM_ERROR_INVALID_PARAM;
return false;
} else {
uint32_t parentId = windowMap_[parentName].first;
property_->SetParentId(parentId);
@@ -777,7 +820,16 @@ WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr<
if (CheckCameraFloatingWindowMultiCreated(property_->GetWindowType())) {
WLOGFE("Camera Floating Window already exists.");
return WMError::WM_ERROR_INVALID_WINDOW;
return false;
}
return true;
}
WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr<AbilityRuntime::Context>& context)
{
WLOGFI("[Client] Window [name:%{public}s] Create", name_.c_str());
if (!WindowCreateCheck(parentName)) {
return WMError::WM_ERROR_INVALID_PARAM;
}
context_ = context;
@@ -792,17 +844,14 @@ WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr<
property_->SetTokenState(true);
}
}
SetSystemConfig();
if (WindowHelper::IsMainWindow(property_->GetWindowType())) {
if (SingletonContainer::Get<WindowAdapter>().GetSystemConfig(windowSystemConfig_) == WMError::WM_OK) {
WLOGFE("get system decor enable:%{public}d", windowSystemConfig_.isSystemDecorEnable_);
if (windowSystemConfig_.isSystemDecorEnable_) {
property_->SetDecorEnable(true);
}
WLOGFI("get stretchable enable:%{public}d", windowSystemConfig_.isStretchable_);
property_->SetStretchable(windowSystemConfig_.isStretchable_);
}
GetConfigurationFromAbilityInfo();
} else if (property_->GetWindowMode() == WindowMode::WINDOW_MODE_UNDEFINED) {
property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
}
WMError ret = SingletonContainer::Get<WindowAdapter>().CreateWindow(windowAgent, property_, surfaceNode_,
windowId, token);
RecordLifeCycleExceptionEvent(LifeCycleEvent::CREATE_EVENT, ret);
+2
View File
@@ -40,11 +40,13 @@ public:
static void ReleaseStartWinSurfaceNode(sptr<WindowNode>& node);
static bool NeedToStopStartingWindow(WindowMode winMode, uint32_t modeSupportInfo,
const sptr<WindowTransitionInfo>& info);
static void SetDefaultWindowMode(WindowMode defaultMode);
private:
static WMError CreateLeashAndStartingSurfaceNode(sptr<WindowNode>& node);
static SurfaceDraw surfaceDraw_;
static std::recursive_mutex mutex_;
static WindowMode defaultMode_;
};
} // Rosen
} // OHOS
+7
View File
@@ -30,6 +30,7 @@ namespace {
}
std::recursive_mutex StartingWindow::mutex_;
WindowMode StartingWindow::defaultMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
bool StartingWindow::NeedToStopStartingWindow(WindowMode winMode, uint32_t modeSupportInfo,
const sptr<WindowTransitionInfo>& info)
@@ -56,6 +57,8 @@ sptr<WindowNode> StartingWindow::CreateWindowNode(const sptr<WindowTransitionInf
property->SetRequestRect(info->GetWindowRect());
if (WindowHelper::IsValidWindowMode(info->GetWindowMode())) {
property->SetWindowMode(info->GetWindowMode());
} else {
property->SetWindowMode(defaultMode_);
}
property->SetDisplayId(info->GetDisplayId());
@@ -220,5 +223,9 @@ void StartingWindow::UpdateRSTree(sptr<WindowNode>& node)
updateRSTreeFunc();
}
}
void StartingWindow::SetDefaultWindowMode(WindowMode defaultMode)
{
defaultMode_ = defaultMode;
}
} // Rosen
} // OHOS
+2 -1
View File
@@ -73,7 +73,8 @@ 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*>("modeChangeHotZones")) ||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("defaultWindowMode"))) {
ReadIntNumbersConfigInfo(curNodePtr);
continue;
}
+12 -2
View File
@@ -30,6 +30,7 @@
#include "permission.h"
#include "remote_animation.h"
#include "singleton_container.h"
#include "starting_window.h"
#include "ui/rs_ui_director.h"
#include "window_helper.h"
#include "window_inner_manager.h"
@@ -279,6 +280,16 @@ void WindowManagerService::ConfigureWindowManagerService()
systemConfig_.isStretchable_ = enableConfig.at("stretchable");
}
if (intNumbersConfig.count("defaultWindowMode") != 0) {
auto numbers = intNumbersConfig.at("defaultWindowMode");
if (numbers.size() == 1 &&
(numbers[0] == static_cast<uint32_t>(WindowMode::WINDOW_MODE_FULLSCREEN) ||
numbers[0] == static_cast<uint32_t>(WindowMode::WINDOW_MODE_FLOATING))) {
systemConfig_.defaultWindowMode_ = static_cast<WindowMode>(static_cast<uint32_t>(numbers[0]));
StartingWindow::SetDefaultWindowMode(systemConfig_.defaultWindowMode_);
}
}
if (intNumbersConfig.count("maxAppWindowNumber") != 0) {
auto numbers = intNumbersConfig.at("maxAppWindowNumber");
if (numbers.size() == 1) {
@@ -641,8 +652,7 @@ WMError WindowManagerService::GetAccessibilityWindowInfo(sptr<AccessibilityWindo
WMError WindowManagerService::GetSystemConfig(SystemConfig& systemConfig)
{
systemConfig.isSystemDecorEnable_ = systemConfig_.isSystemDecorEnable_;
systemConfig.isStretchable_ = systemConfig_.isStretchable_;
systemConfig = systemConfig_;
return WMError::WM_OK;
}
@@ -501,6 +501,7 @@ WMError WindowManagerProxy::GetSystemConfig(SystemConfig& systemConfig)
}
systemConfig.isSystemDecorEnable_ = reply.ReadBool();
systemConfig.isStretchable_ = reply.ReadBool();
systemConfig.defaultWindowMode_ = static_cast<WindowMode>(reply.ReadUint32());
int32_t ret = reply.ReadInt32();
return static_cast<WMError>(ret);
}
@@ -166,6 +166,7 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M
WMError errCode = GetSystemConfig(config);
reply.WriteBool(config.isSystemDecorEnable_);
reply.WriteBool(config.isStretchable_);
reply.WriteUint32(static_cast<uint32_t>(config.defaultWindowMode_));
reply.WriteInt32(static_cast<int32_t>(errCode));
break;
}