mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
Merge branch 'master' of gitee.com:openharmony/windowmanager into master
This commit is contained in:
+2
-2
@@ -45,8 +45,8 @@ ohos_shared_library("libdm") {
|
||||
public_configs = [ ":libdm_public_config" ]
|
||||
|
||||
deps = [
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_base:librender_service_base",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_base:librender_service_base",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/utils:libwmutil",
|
||||
]
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ ohos_fuzztest("DisplayManagerFuzzTest") {
|
||||
include_dirs = [
|
||||
"//foundation/windowmanager/interfaces/innerkits/dm",
|
||||
"//utils/native/base/include",
|
||||
"//foundation/graphic/graphic/interfaces/innerkits/surface",
|
||||
"//foundation/graphic/graphic_2d/interfaces/innerkits/surface",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
@@ -34,7 +34,7 @@ ohos_fuzztest("DisplayManagerFuzzTest") {
|
||||
]
|
||||
sources = [ "displaymanager_fuzzer.cpp" ]
|
||||
deps = [
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "displaymanager_fuzzer.h"
|
||||
|
||||
#include <securec.h>
|
||||
#include "display_manager.h"
|
||||
|
||||
namespace OHOS ::Rosen {
|
||||
@@ -45,8 +46,7 @@ size_t GetObject(T &object, const uint8_t *data, size_t size)
|
||||
if (objectSize > size) {
|
||||
return 0;
|
||||
}
|
||||
std::memcpy(&object, data, objectSize);
|
||||
return objectSize;
|
||||
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
|
||||
}
|
||||
|
||||
bool DisplayFuzzTest(const uint8_t* data, size_t size)
|
||||
|
||||
@@ -34,7 +34,7 @@ ohos_fuzztest("DisplayManagerIPCFuzzTest") {
|
||||
]
|
||||
sources = [ "displaymanageripc_fuzzer.cpp" ]
|
||||
deps = [
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
]
|
||||
external_deps = [ "samgr_standard:samgr_proxy" ]
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <iremote_broker.h>
|
||||
#include <iservice_registry.h>
|
||||
#include <securec.h>
|
||||
#include <system_ability_definition.h>
|
||||
|
||||
#include "display_manager_interface.h"
|
||||
@@ -33,8 +34,7 @@ size_t GetObject(T &object, const uint8_t *data, size_t size)
|
||||
if (objectSize > size) {
|
||||
return 0;
|
||||
}
|
||||
std::memcpy(&object, data, objectSize);
|
||||
return objectSize;
|
||||
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
|
||||
}
|
||||
|
||||
std::pair<sptr<IDisplayManager>, sptr<IRemoteObject>> GetProxy()
|
||||
|
||||
@@ -23,7 +23,7 @@ ohos_fuzztest("ScreenFuzzTest") {
|
||||
include_dirs = [
|
||||
"//foundation/windowmanager/interfaces/innerkits/dm",
|
||||
"//utils/native/base/include",
|
||||
"//foundation/graphic/graphic/interfaces/innerkits/surface",
|
||||
"//foundation/graphic/graphic_2d/interfaces/innerkits/surface",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
@@ -33,7 +33,7 @@ ohos_fuzztest("ScreenFuzzTest") {
|
||||
]
|
||||
sources = [ "screen_fuzzer.cpp" ]
|
||||
deps = [
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "screen_fuzzer.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <securec.h>
|
||||
|
||||
#include "display_manager.h"
|
||||
#include "display.h"
|
||||
@@ -31,8 +32,7 @@ size_t GetObject(T &object, const uint8_t *data, size_t size)
|
||||
if (objectSize > size) {
|
||||
return 0;
|
||||
}
|
||||
std::memcpy(&object, data, objectSize);
|
||||
return objectSize;
|
||||
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
|
||||
}
|
||||
|
||||
bool ScreenFuzzTest(const uint8_t *data, size_t size)
|
||||
|
||||
@@ -24,7 +24,7 @@ ohos_fuzztest("ScreenManagerFuzzTest") {
|
||||
include_dirs = [
|
||||
"//foundation/windowmanager/interfaces/innerkits/dm",
|
||||
"//utils/native/base/include",
|
||||
"//foundation/graphic/graphic/interfaces/innerkits/surface",
|
||||
"//foundation/graphic/graphic_2d/interfaces/innerkits/surface",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
@@ -34,7 +34,7 @@ ohos_fuzztest("ScreenManagerFuzzTest") {
|
||||
]
|
||||
sources = [ "screenmanager_fuzzer.cpp" ]
|
||||
deps = [
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "screenmanager_fuzzer.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <securec.h>
|
||||
|
||||
#include "dm_common.h"
|
||||
#include "screen.h"
|
||||
@@ -51,8 +52,7 @@ size_t GetObject(T &object, const uint8_t *data, size_t size)
|
||||
if (objectSize > size) {
|
||||
return 0;
|
||||
}
|
||||
std::memcpy(&object, data, objectSize);
|
||||
return objectSize;
|
||||
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
|
||||
}
|
||||
|
||||
bool ScreenPowerFuzzTest(const uint8_t *data, size_t size)
|
||||
|
||||
@@ -119,8 +119,8 @@ config("dm_systemtest_common_public_config") {
|
||||
"//foundation/windowmanager/utils/include",
|
||||
|
||||
# RSSurface
|
||||
"//foundation/graphic/graphic/interfaces/inner_api/surface",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client",
|
||||
"//foundation/graphic/graphic_2d/interfaces/inner_api/surface",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ ohos_static_library("dm_systemtest_common") {
|
||||
public_configs = [ ":dm_systemtest_common_public_config" ]
|
||||
|
||||
public_deps = [
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
"//foundation/windowmanager/dmserver:libdms",
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// gtest
|
||||
#include <cinttypes>
|
||||
#include <cstdlib>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "display_test_utils.h"
|
||||
#include "pixel_map.h"
|
||||
|
||||
@@ -51,7 +52,7 @@ void ScreenshotCmdTest::SetUpTestCase()
|
||||
WLOGFE("GetDefaultDisplay: failed!\n");
|
||||
return;
|
||||
}
|
||||
WLOGFI("GetDefaultDisplay: id %llu, w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(),
|
||||
WLOGFI("GetDefaultDisplay: id %" PRIu64", w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(),
|
||||
display->GetHeight(), display->GetRefreshRate());
|
||||
|
||||
defaultId_ = display->GetId();
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// gtest
|
||||
#include <cinttypes>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "display_test_utils.h"
|
||||
#include "pixel_map.h"
|
||||
|
||||
@@ -52,7 +53,7 @@ void ScreenshotTest::SetUpTestCase()
|
||||
WLOGFE("GetDefaultDisplay: failed!\n");
|
||||
return;
|
||||
}
|
||||
WLOGFI("GetDefaultDisplay: id %llu, w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(),
|
||||
WLOGFI("GetDefaultDisplay: id %" PRIu64", w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(),
|
||||
display->GetHeight(), display->GetRefreshRate());
|
||||
|
||||
defaultId_ = display->GetId();
|
||||
|
||||
@@ -111,7 +111,7 @@ config("dm_unittest_common_public_config") {
|
||||
"//foundation/windowmanager/snapshot",
|
||||
"//foundation/windowmanager/interfaces/innerkits/dm",
|
||||
"//foundation/windowmanager/utils/include",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client", # RSSurface
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client", # RSSurface
|
||||
]
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ ohos_static_library("dm_unittest_common") {
|
||||
public_configs = [ ":dm_unittest_common_public_config" ]
|
||||
|
||||
public_deps = [
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/multimedia/image_standard/interfaces/innerkits:image_native", # PixelMap
|
||||
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
|
||||
+3
-1
@@ -65,10 +65,12 @@ ohos_shared_library("libdms") {
|
||||
"//foundation/windowmanager/utils:libwmutil",
|
||||
|
||||
# RSSurface
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_runtime:ability_manager",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"graphic_standard:surface",
|
||||
"hilog_native:libhilog",
|
||||
"hitrace_native:hitrace_meter",
|
||||
|
||||
@@ -27,6 +27,9 @@ public:
|
||||
~DisplayManagerStub() = default;
|
||||
virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option) override;
|
||||
private:
|
||||
bool CheckCallingPermission(const std::string &permission);
|
||||
bool IsStartByHdcd();
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
|
||||
@@ -66,11 +66,12 @@ sptr<ScreenInfo> AbstractScreen::ConvertToScreenInfo() const
|
||||
|
||||
void AbstractScreen::UpdateRSTree(std::shared_ptr<RSSurfaceNode>& surfaceNode, bool isAdd)
|
||||
{
|
||||
if (rsDisplayNode_ == nullptr) {
|
||||
WLOGFE("rsDisplayNode_ is nullptr");
|
||||
if (rsDisplayNode_ == nullptr || surfaceNode == nullptr) {
|
||||
WLOGFE("node is nullptr");
|
||||
return;
|
||||
}
|
||||
WLOGFI("AbstractScreen::UpdateRSTree");
|
||||
WLOGFI("%{public}s surface: %{public}s, %{public}" PRIu64"", (isAdd ? "add" : "remove"),
|
||||
surfaceNode->GetName().c_str(), surfaceNode->GetId());
|
||||
|
||||
if (isAdd) {
|
||||
rsDisplayNode_->AddChild(surfaceNode, -1);
|
||||
|
||||
@@ -508,29 +508,24 @@ ScreenId AbstractScreenController::CreateVirtualScreen(VirtualScreenOption optio
|
||||
ScreenId dmsScreenId = SCREEN_ID_INVALID;
|
||||
if (!screenIdManager_.ConvertToDmsScreenId(rsId, dmsScreenId)) {
|
||||
dmsScreenId = screenIdManager_.CreateAndGetNewScreenId(rsId);
|
||||
if (!option.isForShot_) {
|
||||
WLOGI("CreateVirtualScreen is not shot");
|
||||
sptr<AbstractScreen> absScreen = new(std::nothrow) AbstractScreen(this, option.name_, dmsScreenId, rsId);
|
||||
sptr<SupportedScreenModes> info = new(std::nothrow) SupportedScreenModes();
|
||||
if (absScreen == nullptr || info == nullptr) {
|
||||
WLOGFI("new AbstractScreen or SupportedScreenModes failed");
|
||||
screenIdManager_.DeleteScreenId(dmsScreenId);
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
info->width_ = option.width_;
|
||||
info->height_ = option.height_;
|
||||
auto defaultScreen = GetAbstractScreen(GetDefaultAbstractScreenId());
|
||||
if (defaultScreen != nullptr && defaultScreen->GetActiveScreenMode() != nullptr) {
|
||||
info->refreshRate_ = defaultScreen->GetActiveScreenMode()->refreshRate_;
|
||||
}
|
||||
absScreen->modes_.emplace_back(info);
|
||||
absScreen->activeIdx_ = 0;
|
||||
absScreen->type_ = ScreenType::VIRTUAL;
|
||||
dmsScreenMap_.insert(std::make_pair(dmsScreenId, absScreen));
|
||||
NotifyScreenConnected(absScreen->ConvertToScreenInfo());
|
||||
} else {
|
||||
WLOGI("CreateVirtualScreen is shot");
|
||||
sptr<AbstractScreen> absScreen = new(std::nothrow) AbstractScreen(this, option.name_, dmsScreenId, rsId);
|
||||
sptr<SupportedScreenModes> info = new(std::nothrow) SupportedScreenModes();
|
||||
if (absScreen == nullptr || info == nullptr) {
|
||||
WLOGFI("new AbstractScreen or SupportedScreenModes failed");
|
||||
screenIdManager_.DeleteScreenId(dmsScreenId);
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
info->width_ = option.width_;
|
||||
info->height_ = option.height_;
|
||||
auto defaultScreen = GetAbstractScreen(GetDefaultAbstractScreenId());
|
||||
if (defaultScreen != nullptr && defaultScreen->GetActiveScreenMode() != nullptr) {
|
||||
info->refreshRate_ = defaultScreen->GetActiveScreenMode()->refreshRate_;
|
||||
}
|
||||
absScreen->modes_.emplace_back(info);
|
||||
absScreen->activeIdx_ = 0;
|
||||
absScreen->type_ = ScreenType::VIRTUAL;
|
||||
dmsScreenMap_.insert(std::make_pair(dmsScreenId, absScreen));
|
||||
NotifyScreenConnected(absScreen->ConvertToScreenInfo());
|
||||
} else {
|
||||
WLOGFI("id: %{public}" PRIu64" appears in screenIdManager_. ", rsId);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <ipc_skeleton.h>
|
||||
|
||||
#include "accesstoken_kit.h"
|
||||
#include "bundle_constants.h"
|
||||
#include "marshalling_helper.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
@@ -29,6 +31,27 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayManagerStub"};
|
||||
}
|
||||
|
||||
bool DisplayManagerStub::CheckCallingPermission(const std::string &permission)
|
||||
{
|
||||
if (Security::AccessToken::AccessTokenKit::VerifyAccessToken(IPCSkeleton::GetCallingTokenID(), permission) !=
|
||||
AppExecFwk::Constants::PERMISSION_GRANTED) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DisplayManagerStub::IsStartByHdcd()
|
||||
{
|
||||
OHOS::Security::AccessToken::NativeTokenInfo info;
|
||||
if (Security::AccessToken::AccessTokenKit::GetNativeTokenInfo(IPCSkeleton::GetCallingTokenID(), info) != 0) {
|
||||
return false;
|
||||
}
|
||||
if (info.processName.compare("hdcd") == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
{
|
||||
@@ -110,9 +133,14 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT: {
|
||||
DisplayId displayId = data.ReadUint64();
|
||||
std::shared_ptr<Media::PixelMap> displaySnapshot = GetDisplaySnapshot(displayId);
|
||||
reply.WriteParcelable(displaySnapshot == nullptr ? nullptr : displaySnapshot.get());
|
||||
if (CheckCallingPermission("ohos.permission.CAPTURE_SCREEN") || IsStartByHdcd()) {
|
||||
DisplayId displayId = data.ReadUint64();
|
||||
std::shared_ptr<Media::PixelMap> displaySnapshot = GetDisplaySnapshot(displayId);
|
||||
reply.WriteParcelable(displaySnapshot == nullptr ? nullptr : displaySnapshot.get());
|
||||
break;
|
||||
}
|
||||
WLOGFE("check permission failed!");
|
||||
reply.WriteParcelable(nullptr);
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT: {
|
||||
|
||||
@@ -41,7 +41,7 @@ ohos_shared_library("libwindow_extension_client") {
|
||||
configs = [ ":libwindow_extension_client_private_config" ]
|
||||
|
||||
deps = [
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/extension/window_extension:libwindow_extension",
|
||||
"//foundation/windowmanager/wm:libwm",
|
||||
]
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WINDOW_EXTENSION_CLIENT_INTERFACE
|
||||
#define WINDOW_EXTENSION_CLIENT_INTERFACE
|
||||
#ifndef WINDOW_EXTENSION_CLIENT_INTERFACE_H
|
||||
#define WINDOW_EXTENSION_CLIENT_INTERFACE_H
|
||||
|
||||
#include <i_input_event_consumer.h>
|
||||
#include <iremote_broker.h>
|
||||
@@ -40,4 +40,4 @@ public:
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // WINDOW_EXTENSION_CLIENT_INTERFACE
|
||||
#endif // WINDOW_EXTENSION_CLIENT_INTERFACE_H
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WINODW_EXTENSION_CLIENT_PROXY
|
||||
#define WINODW_EXTENSION_CLIENT_PROXY
|
||||
#ifndef WINODW_EXTENSION_CLIENT_PROXY_H
|
||||
#define WINODW_EXTENSION_CLIENT_PROXY_H
|
||||
|
||||
#include <iremote_proxy.h>
|
||||
#include "window_extension_client_interface.h"
|
||||
@@ -35,4 +35,4 @@ private:
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // WINODW_EXTENSION_CLIENT_PROXY
|
||||
#endif // WINODW_EXTENSION_CLIENT_PROXY_H
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WINDOW_EXTENSION_CLIENT_STUB
|
||||
#define WINDOW_EXTENSION_CLIENT_STUB
|
||||
#ifndef WINDOW_EXTENSION_CLIENT_STUB_H
|
||||
#define WINDOW_EXTENSION_CLIENT_STUB_H
|
||||
|
||||
#include <iremote_stub.h>
|
||||
#include "window_extension_client_interface.h"
|
||||
@@ -31,4 +31,4 @@ public:
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // WINDOW_EXTENSION_CLIENT_STUB
|
||||
#endif // WINDOW_EXTENSION_CLIENT_STUB_H
|
||||
@@ -196,7 +196,6 @@ void WindowExtensionConnection::Impl::OnAbilityDisconnectDone(const AppExecFwk::
|
||||
WLOGFI("end");
|
||||
}
|
||||
|
||||
// WindowExtensionConnection
|
||||
int WindowExtensionConnection::ConnectExtension(const AppExecFwk::ElementName& element,
|
||||
const Rect& rect, uint32_t uid, const sptr<IWindowExtensionCallback>& callback) const
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ ohos_shared_library("libwindow_extension") {
|
||||
|
||||
deps = [
|
||||
"//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common:napi_common",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/interfaces/kits/napi/window_runtime:window_native_kit",
|
||||
"//foundation/windowmanager/utils:libwmutil",
|
||||
"//foundation/windowmanager/wm:libwm",
|
||||
|
||||
@@ -25,7 +25,7 @@ ohos_shared_library("wm_interface") {
|
||||
|
||||
public_deps = [
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/multimedia/image_standard/interfaces/innerkits:image_native",
|
||||
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-client",
|
||||
"//utils/native/base:utils",
|
||||
|
||||
@@ -42,7 +42,7 @@ struct SupportedScreenModes : public RefBase {
|
||||
};
|
||||
|
||||
struct VirtualScreenOption {
|
||||
const std::string name_;
|
||||
std::string name_;
|
||||
uint32_t width_;
|
||||
uint32_t height_;
|
||||
float density_;
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
virtual void AfterBackground() = 0;
|
||||
virtual void AfterFocused() = 0;
|
||||
virtual void AfterUnfocused() = 0;
|
||||
virtual void ForegroundFailed() {}
|
||||
virtual void AfterActive() {}
|
||||
virtual void AfterInactive() {}
|
||||
};
|
||||
@@ -119,6 +120,11 @@ public:
|
||||
virtual void OnPointerInputEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent) = 0;
|
||||
};
|
||||
|
||||
class IOutsidePressedListener : virtual public RefBase {
|
||||
public:
|
||||
virtual void OnOutsidePressed() = 0;
|
||||
};
|
||||
|
||||
class Window : public RefBase {
|
||||
public:
|
||||
static sptr<Window> Create(const std::string& windowName,
|
||||
@@ -200,6 +206,7 @@ public:
|
||||
virtual void RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) = 0;
|
||||
virtual void RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) = 0;
|
||||
virtual void UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) = 0;
|
||||
virtual void RegisterOutsidePressedListener(const sptr<IOutsidePressedListener>& listener) = 0;
|
||||
virtual void SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler) = 0;
|
||||
virtual WMError SetUIContent(const std::string& contentInfo, NativeEngine* engine,
|
||||
NativeValue* storage, bool isdistributed = false, AppExecFwk::Ability* ability = nullptr) = 0;
|
||||
@@ -208,6 +215,7 @@ 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 bool IsDecorEnable() const = 0;
|
||||
virtual WMError Maximize() = 0;
|
||||
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
void RegisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener);
|
||||
void UnregisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener);
|
||||
void MinimizeAllAppWindows(DisplayId displayId);
|
||||
void ToggleShownStateForAllAppWindows();
|
||||
WMError ToggleShownStateForAllAppWindows();
|
||||
WMError SetWindowLayoutMode(WindowLayoutMode mode);
|
||||
WMError GetAccessibilityWindowInfo(sptr<AccessibilityWindowInfo>& windowInfo) const;
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ enum class WindowType : uint32_t {
|
||||
WINDOW_TYPE_LAUNCHER_DOCK,
|
||||
WINDOW_TYPE_BOOT_ANIMATION,
|
||||
WINDOW_TYPE_FREEZE_DISPLAY,
|
||||
WINDOW_TYPE_VOICE_INTERACTION,
|
||||
ABOVE_APP_SYSTEM_WINDOW_END,
|
||||
|
||||
SYSTEM_WINDOW_END = ABOVE_APP_SYSTEM_WINDOW_END,
|
||||
@@ -72,6 +73,19 @@ enum class WindowMode : uint32_t {
|
||||
WINDOW_MODE_PIP
|
||||
};
|
||||
|
||||
enum WindowModeSupport : uint32_t {
|
||||
WINDOW_MODE_SUPPORT_FULLSCREEN = 1 << 0,
|
||||
WINDOW_MODE_SUPPORT_FLOATING = 1 << 1,
|
||||
WINDOW_MODE_SUPPORT_SPLIT_PRIMARY = 1 << 2,
|
||||
WINDOW_MODE_SUPPORT_SPLIT_SECONDARY = 1 << 3,
|
||||
WINDOW_MODE_SUPPORT_PIP = 1 << 4,
|
||||
WINDOW_MODE_SUPPORT_ALL = WINDOW_MODE_SUPPORT_FULLSCREEN |
|
||||
WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
|
||||
WINDOW_MODE_SUPPORT_SPLIT_SECONDARY |
|
||||
WINDOW_MODE_SUPPORT_FLOATING |
|
||||
WINDOW_MODE_SUPPORT_PIP
|
||||
};
|
||||
|
||||
enum class WindowBlurLevel : uint32_t {
|
||||
WINDOW_BLUR_OFF = 0,
|
||||
WINDOW_BLUR_LOW,
|
||||
@@ -101,7 +115,8 @@ enum class WindowFlag : uint32_t {
|
||||
WINDOW_FLAG_NEED_AVOID = 1,
|
||||
WINDOW_FLAG_PARENT_LIMIT = 1 << 1,
|
||||
WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2,
|
||||
WINDOW_FLAG_END = 1 << 3,
|
||||
WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3,
|
||||
WINDOW_FLAG_END = 1 << 4,
|
||||
};
|
||||
|
||||
enum class WindowSizeChangeReason : uint32_t {
|
||||
@@ -149,6 +164,8 @@ namespace {
|
||||
constexpr float UNDEFINED_BRIGHTNESS = -1.0f;
|
||||
constexpr float MINIMUM_BRIGHTNESS = 0.0f;
|
||||
constexpr float MAXIMUM_BRIGHTNESS = 1.0f;
|
||||
constexpr int32_t INVALID_PID = -1;
|
||||
constexpr int32_t INVALID_UID = -1;
|
||||
}
|
||||
|
||||
struct SystemBarProperty {
|
||||
|
||||
@@ -39,7 +39,7 @@ ohos_shared_library("display_napi") {
|
||||
"${aafwk_kits_path}/appkit:app_context",
|
||||
"${aafwk_kits_path}/appkit:appkit_native",
|
||||
"../common:wm_napi_common",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
"//foundation/windowmanager/utils:libwmutil",
|
||||
]
|
||||
|
||||
@@ -40,7 +40,7 @@ ohos_shared_library("screen_napi") {
|
||||
"${aafwk_kits_path}/ability/native:abilitykit_native",
|
||||
"${aafwk_kits_path}/appkit:app_context",
|
||||
"${aafwk_kits_path}/appkit:appkit_native",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
"//foundation/windowmanager/dmserver:libdms",
|
||||
"//foundation/windowmanager/utils:libwmutil",
|
||||
|
||||
@@ -57,6 +57,31 @@ declare namespace screen {
|
||||
function makeMirror(mainScreen:number, mirrorScreen:Array<number>, callback: AsyncCallback<number>): void;
|
||||
function makeMirror(mainScreen:number, mirrorScreen:Array<number>): Promise<number>;
|
||||
|
||||
/**
|
||||
* Create virtual screen.
|
||||
* @param option Indicates the option of the virtual screen.
|
||||
* @since 9
|
||||
*/
|
||||
function createVirtualScreen(option:VirtualScreenOption, callback: AsyncCallback<Screen>): void;
|
||||
function createVirtualScreen(option:VirtualScreenOption): Promise<Screen>;
|
||||
|
||||
/**
|
||||
* Destroy virtual screen.
|
||||
* @param screenId Indicates the screen id of the virtual screen.
|
||||
* @since 9
|
||||
*/
|
||||
function destroyVirtualScreen(screenId:number, callback: AsyncCallback<void>): void;
|
||||
function destroyVirtualScreen(screenId:number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Set surface for the virtual screen.
|
||||
* @param screenId Indicates the screen id of the virtual screen.
|
||||
* @param surfaceId Indicates the surface id.
|
||||
* @since 9
|
||||
*/
|
||||
function setVirtualScreenSurface(screenId:number, surfaceId: string, callback: AsyncCallback<void>): void;
|
||||
function setVirtualScreenSurface(screenId:number, surfaceId: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* the parameter of making expand screen
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
@@ -79,6 +104,38 @@ declare namespace screen {
|
||||
startY: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The parameter for creating virtual screen.
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
* @since 9
|
||||
*/
|
||||
interface VirtualScreenOption {
|
||||
/**
|
||||
* Indicates the name of the virtual screen.
|
||||
*/
|
||||
name: string
|
||||
|
||||
/**
|
||||
* Indicates the width of the virtual screen.
|
||||
*/
|
||||
width: number
|
||||
|
||||
/**
|
||||
* Indicates the height of the virtual screen.
|
||||
*/
|
||||
height: number
|
||||
|
||||
/**
|
||||
* Indicates the density of the virtual screen.
|
||||
*/
|
||||
density: number
|
||||
|
||||
/**
|
||||
* Indicates the surface id of the virtual screen.
|
||||
*/
|
||||
surfaceId: string
|
||||
}
|
||||
|
||||
/**
|
||||
* interface for screen
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
|
||||
@@ -230,9 +230,12 @@ NativeValue* CreateJsScreenObject(NativeEngine& engine, sptr<Screen>& screen)
|
||||
}
|
||||
std::unique_ptr<JsScreen> jsScreen = std::make_unique<JsScreen>(screen);
|
||||
object->SetNativePointer(jsScreen.release(), JsScreen::Finalizer, nullptr);
|
||||
|
||||
object->SetProperty("id", CreateJsValue(engine, static_cast<uint32_t>(screen->GetId())));
|
||||
object->SetProperty("parent", CreateJsValue(engine, static_cast<uint32_t>(screen->GetParentId())));
|
||||
ScreenId screenId = screen->GetId();
|
||||
object->SetProperty("id",
|
||||
CreateJsValue(engine, screenId == SCREEN_ID_INVALID ? -1 : static_cast<int64_t>(screenId)));
|
||||
ScreenId parentId = screen->GetParentId();
|
||||
object->SetProperty("parent",
|
||||
CreateJsValue(engine, parentId == SCREEN_ID_INVALID ? -1 : static_cast<int64_t>(parentId)));
|
||||
object->SetProperty("orientation", CreateJsValue(engine, screen->GetOrientation()));
|
||||
object->SetProperty("activeModeIndex", CreateJsValue(engine, screen->GetModeId()));
|
||||
object->SetProperty("supportedModeInfo", CreateJsScreenModeArrayObject(engine, screen->GetSupportedModes()));
|
||||
@@ -241,7 +244,6 @@ NativeValue* CreateJsScreenObject(NativeEngine& engine, sptr<Screen>& screen)
|
||||
|
||||
std::shared_ptr<NativeReference> JsScreenRef;
|
||||
JsScreenRef.reset(engine.CreateReference(objValue, 1));
|
||||
ScreenId screenId = screen->GetId();
|
||||
std::lock_guard<std::recursive_mutex> lock(g_mutex);
|
||||
g_JsScreenMap[screenId] = JsScreenRef;
|
||||
BindNativeFunction(engine, *object, "setScreenActiveMode", JsScreen::SetScreenActiveMode);
|
||||
|
||||
@@ -19,12 +19,13 @@
|
||||
#include <new>
|
||||
#include <ability.h>
|
||||
#include "js_runtime_utils.h"
|
||||
#include "js_screen.h"
|
||||
#include "js_screen_listener.h"
|
||||
#include "native_engine/native_reference.h"
|
||||
#include "screen_manager.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "singleton_container.h"
|
||||
#include "js_screen.h"
|
||||
#include "surface_utils.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@@ -80,6 +81,23 @@ static NativeValue* MakeExpand(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
return (me != nullptr) ? me->OnMakeExpand(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
static NativeValue* CreateVirtualScreen(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsScreenManager* me = CheckParamsAndGetThis<JsScreenManager>(engine, info);
|
||||
return (me != nullptr) ? me->OnCreateVirtualScreen(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
static NativeValue* DestroyVirtualScreen(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsScreenManager* me = CheckParamsAndGetThis<JsScreenManager>(engine, info);
|
||||
return (me != nullptr) ? me->OnDestroyVirtualScreen(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
static NativeValue* SetVirtualScreenSurface(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsScreenManager* me = CheckParamsAndGetThis<JsScreenManager>(engine, info);
|
||||
return (me != nullptr) ? me->OnSetVirtualScreenSurface(*engine, *info) : nullptr;
|
||||
}
|
||||
private:
|
||||
std::map<std::string, std::map<std::unique_ptr<NativeReference>, sptr<JsScreenListener>>> jsCbMap_;
|
||||
std::mutex mtx_;
|
||||
@@ -392,6 +410,200 @@ int32_t GetExpandOptionFromJs(NativeEngine& engine, NativeObject* optionObject,
|
||||
option = {screenId, startX, startY};
|
||||
return 0;
|
||||
}
|
||||
|
||||
NativeValue* OnCreateVirtualScreen(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WLOGFI("JsScreenManager::OnCreateVirtualScreen is called");
|
||||
DMError errCode = DMError::DM_OK;
|
||||
VirtualScreenOption option;
|
||||
if (info.argc != ARGC_ONE && info.argc != ARGC_TWO) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
errCode = DMError::DM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
NativeObject* object = ConvertNativeValueTo<NativeObject>(info.argv[0]);
|
||||
if (object == nullptr) {
|
||||
WLOGFE("Failed to convert parameter to VirtualScreenOption.");
|
||||
errCode = DMError::DM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
errCode = GetVirtualScreenOptionFromJs(engine, object, option);
|
||||
}
|
||||
}
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[option, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (errCode != DMError::DM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode),
|
||||
"JsScreenManager::OnCreateVirtualScreen, Invalidate params."));
|
||||
WLOGFE("JsScreenManager::OnCreateVirtualScreen failed, Invalidate params.");
|
||||
} else {
|
||||
auto screenId = SingletonContainer::Get<ScreenManager>().CreateVirtualScreen(option);
|
||||
auto screen = SingletonContainer::Get<ScreenManager>().GetScreenById(screenId);
|
||||
if (screen == nullptr) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(DMError::DM_ERROR_UNKNOWN),
|
||||
"ScreenManager::CreateVirtualScreen failed."));
|
||||
WLOGFE("ScreenManager::CreateVirtualScreen failed.");
|
||||
return;
|
||||
}
|
||||
task.Resolve(engine, CreateJsScreenObject(engine, screen));
|
||||
WLOGFI("JsScreenManager::OnCreateVirtualScreen success");
|
||||
}
|
||||
};
|
||||
NativeValue* lastParam = nullptr;
|
||||
if (info.argc == ARGC_TWO && info.argv[ARGC_TWO - 1] != nullptr &&
|
||||
info.argv[ARGC_TWO - 1]->TypeOf() == NATIVE_FUNCTION) {
|
||||
lastParam = info.argv[ARGC_TWO - 1];
|
||||
}
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule(
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
DMError GetVirtualScreenOptionFromJs(NativeEngine& engine, NativeObject* optionObject, VirtualScreenOption& option)
|
||||
{
|
||||
NativeValue* name = optionObject->GetProperty("name");
|
||||
if (!ConvertFromJsValue(engine, name, option.name_)) {
|
||||
WLOGFE("Failed to convert parameter to name.");
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
NativeValue* width = optionObject->GetProperty("width");
|
||||
if (!ConvertFromJsValue(engine, width, option.width_)) {
|
||||
WLOGFE("Failed to convert parameter to width.");
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
NativeValue* height = optionObject->GetProperty("height");
|
||||
if (!ConvertFromJsValue(engine, height, option.height_)) {
|
||||
WLOGFE("Failed to convert parameter to height.");
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
NativeValue* density = optionObject->GetProperty("density");
|
||||
double densityValue;
|
||||
if (!ConvertFromJsValue(engine, density, densityValue)) {
|
||||
WLOGFE("Failed to convert parameter to density.");
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
option.density_ = static_cast<float>(densityValue);
|
||||
|
||||
NativeValue* surfaceIdNativeValue = optionObject->GetProperty("surfaceId");
|
||||
if (!GetSurfaceFromJs(engine, surfaceIdNativeValue, option.surface_)) {
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
bool GetSurfaceFromJs(NativeEngine& engine, NativeValue* surfaceIdNativeValue, sptr<Surface>& surface)
|
||||
{
|
||||
if (surfaceIdNativeValue == nullptr || surfaceIdNativeValue->TypeOf() != NATIVE_STRING) {
|
||||
WLOGFE("Failed to convert parameter to surface. Invalidate params.");
|
||||
return false;
|
||||
}
|
||||
char buffer[PATH_MAX];
|
||||
size_t length = 0;
|
||||
uint64_t surfaceId = 0;
|
||||
napi_env env = reinterpret_cast<napi_env>(&engine);
|
||||
napi_value surfaceIdValue = reinterpret_cast<napi_value>(surfaceIdNativeValue);
|
||||
if (napi_get_value_string_utf8(env, surfaceIdValue, buffer, PATH_MAX, &length) != napi_ok) {
|
||||
WLOGFE("Failed to convert parameter to surface.");
|
||||
return false;
|
||||
}
|
||||
std::istringstream inputStream(buffer);
|
||||
inputStream >> surfaceId;
|
||||
surface = SurfaceUtils::GetInstance()->GetSurface(surfaceId);
|
||||
if (surface == nullptr) {
|
||||
WLOGFI("GetSurfaceFromJs failed, surfaceId:%{public}" PRIu64"", surfaceId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
NativeValue* OnDestroyVirtualScreen(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WLOGFI("JsScreenManager::OnDestroyVirtualScreen is called");
|
||||
DMError errCode = DMError::DM_OK;
|
||||
int64_t screenId = -1LL;
|
||||
if (info.argc != ARGC_ONE && info.argc != ARGC_TWO) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
errCode = DMError::DM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
if (!ConvertFromJsValue(engine, info.argv[0], screenId)) {
|
||||
WLOGFE("Failed to convert parameter to screen id.");
|
||||
errCode = DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[screenId, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (errCode != DMError::DM_OK || screenId == -1LL) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(DMError::DM_ERROR_INVALID_PARAM),
|
||||
"JsScreenManager::OnDestroyVirtualScreen, Invalidate params."));
|
||||
WLOGFE("JsScreenManager::OnDestroyVirtualScreen failed, Invalidate params.");
|
||||
} else {
|
||||
auto res = SingletonContainer::Get<ScreenManager>().DestroyVirtualScreen(screenId);
|
||||
if (res != DMError::DM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(res),
|
||||
"ScreenManager::DestroyVirtualScreen failed."));
|
||||
WLOGFE("ScreenManager::DestroyVirtualScreen failed.");
|
||||
return;
|
||||
}
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGFI("JsScreenManager::OnDestroyVirtualScreen success");
|
||||
}
|
||||
};
|
||||
NativeValue* lastParam = nullptr;
|
||||
if (info.argc == ARGC_TWO && info.argv[ARGC_TWO - 1] != nullptr &&
|
||||
info.argv[ARGC_TWO - 1]->TypeOf() == NATIVE_FUNCTION) {
|
||||
lastParam = info.argv[ARGC_TWO - 1];
|
||||
}
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule(
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue* OnSetVirtualScreenSurface(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WLOGFI("JsScreenManager::OnSetVirtualScreenSurface is called");
|
||||
DMError errCode = DMError::DM_OK;
|
||||
int64_t screenId = -1LL;
|
||||
sptr<Surface> surface;
|
||||
if (info.argc != ARGC_TWO && info.argc != ARGC_THREE) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
errCode = DMError::DM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
if (!ConvertFromJsValue(engine, info.argv[0], screenId)) {
|
||||
WLOGFE("Failed to convert parameter to screen id.");
|
||||
errCode = DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
if (!GetSurfaceFromJs(engine, info.argv[1], surface)) {
|
||||
WLOGFE("Failed to convert parameter to surface");
|
||||
errCode = DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[screenId, surface, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (errCode != DMError::DM_OK || surface == nullptr) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(DMError::DM_ERROR_INVALID_PARAM),
|
||||
"JsScreenManager::OnSetVirtualScreenSurface, Invalidate params."));
|
||||
WLOGFE("JsScreenManager::OnSetVirtualScreenSurface failed, Invalidate params.");
|
||||
} else {
|
||||
auto res = SingletonContainer::Get<ScreenManager>().SetVirtualScreenSurface(screenId, surface);
|
||||
if (res != DMError::DM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(res),
|
||||
"ScreenManager::SetVirtualScreenSurface failed."));
|
||||
WLOGFE("ScreenManager::SetVirtualScreenSurface failed.");
|
||||
return;
|
||||
}
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGFI("JsScreenManager::OnSetVirtualScreenSurface success");
|
||||
}
|
||||
};
|
||||
NativeValue* lastParam = nullptr;
|
||||
if (info.argc == ARGC_THREE && info.argv[ARGC_TWO - 1] != nullptr &&
|
||||
info.argv[ARGC_THREE - 1]->TypeOf() == NATIVE_FUNCTION) {
|
||||
lastParam = info.argv[ARGC_THREE - 1];
|
||||
}
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule(
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
NativeValue* JsScreenManagerInit(NativeEngine* engine, NativeValue* exportObj)
|
||||
@@ -417,6 +629,9 @@ NativeValue* JsScreenManagerInit(NativeEngine* engine, NativeValue* exportObj)
|
||||
BindNativeFunction(*engine, *object, "off", JsScreenManager::UnregisterScreenMangerCallback);
|
||||
BindNativeFunction(*engine, *object, "makeMirror", JsScreenManager::MakeMirror);
|
||||
BindNativeFunction(*engine, *object, "makeExpand", JsScreenManager::MakeExpand);
|
||||
BindNativeFunction(*engine, *object, "createVirtualScreen", JsScreenManager::CreateVirtualScreen);
|
||||
BindNativeFunction(*engine, *object, "destroyVirtualScreen", JsScreenManager::DestroyVirtualScreen);
|
||||
BindNativeFunction(*engine, *object, "setVirtualScreenSurface", JsScreenManager::SetVirtualScreenSurface);
|
||||
return engine->CreateUndefined();
|
||||
}
|
||||
} // namespace Rosen
|
||||
|
||||
@@ -164,13 +164,6 @@ static void GetScreenshotParam(napi_env env, std::unique_ptr<Param> ¶m, napi
|
||||
|
||||
static void AsyncGetScreenshot(napi_env env, std::unique_ptr<Param> ¶m)
|
||||
{
|
||||
if (!CheckCallingPermission("ohos.permission.CAPTURE_SCREEN")) {
|
||||
WLOGFE("Get Screenshot failed. Do not have permission!");
|
||||
param->image = nullptr;
|
||||
param->wret = WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
param->errMessage = "Get Screenshot Failed: Do not have ohos.permission.CAPTURE_SCREEN";
|
||||
return;
|
||||
}
|
||||
if (!param->validInputParam) {
|
||||
WLOGFE("Invalid Input Param!");
|
||||
param->image = nullptr;
|
||||
|
||||
@@ -933,6 +933,24 @@ declare namespace window {
|
||||
* @return The dump info array.
|
||||
*/
|
||||
dump(params: Array<string>): Array<string>;
|
||||
|
||||
/**
|
||||
* set the flag of the window is forbidden to move in split screen mode
|
||||
* @param isForbidSplitMove the flag of the window is forbidden to move in split screen mode
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
* @systemapi
|
||||
* @since 9
|
||||
*/
|
||||
setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* set the flag of the window is forbidden to move in split screen mode
|
||||
* @param isForbidSplitMove the flag of the window is forbidden to move in split screen mode
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
* @systemapi
|
||||
* @since 9
|
||||
*/
|
||||
setForbidSplitMove(isForbidSplitMove: boolean): Promise<void>;
|
||||
}
|
||||
|
||||
enum WindowStageEventType {
|
||||
|
||||
@@ -370,9 +370,14 @@ NativeValue* JsWindowManager::OnToggleShownStateForAllAppWindows(NativeEngine& e
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params"));
|
||||
return;
|
||||
}
|
||||
SingletonContainer::Get<WindowManager>().ToggleShownStateForAllAppWindows();
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGFI("[NAPI]OnToggleShownStateForAllAppWindows success");
|
||||
WMError ret = SingletonContainer::Get<WindowManager>().ToggleShownStateForAllAppWindows();
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGFI("[NAPI]OnToggleShownStateForAllAppWindows success");
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret),
|
||||
"OnToggleShownStateForAllAppWindows failed"));
|
||||
}
|
||||
};
|
||||
NativeValue* lastParam = (info.argc <= 0) ? nullptr :
|
||||
(info.argv[0]->TypeOf() == NATIVE_FUNCTION ? info.argv[0] : nullptr);
|
||||
|
||||
@@ -299,6 +299,13 @@ NativeValue* JsWindow::Dump(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
return (me != nullptr) ? me->OnDump(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::SetForbidSplitMove(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
WLOGFI("[NAPI]SetForbidSplitMove");
|
||||
JsWindow* me = CheckParamsAndGetThis<JsWindow>(engine, info);
|
||||
return (me != nullptr) ? me->OnSetForbidSplitMove(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnShow(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WMError errCode = WMError::WM_OK;
|
||||
@@ -306,21 +313,23 @@ NativeValue* JsWindow::OnShow(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->Show();
|
||||
WMError ret = weakWindow->Show();
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window show failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] show end, ret = %{public}d",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), ret);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == 0) ? nullptr :
|
||||
@@ -338,22 +347,23 @@ NativeValue* JsWindow::OnDestroy(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->Destroy();
|
||||
WMError ret = weakWindow->Destroy();
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] destroy end, ret = %{public}d",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), ret);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
if (ret != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window destroy failed"));
|
||||
return;
|
||||
}
|
||||
|
||||
windowToken_ = nullptr;
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
};
|
||||
|
||||
@@ -372,21 +382,23 @@ NativeValue* JsWindow::OnHide(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->Hide();
|
||||
WMError ret = weakWindow->Hide();
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window hide failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] hide end, ret = %{public}d",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), ret);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == 0) ? nullptr :
|
||||
@@ -416,21 +428,23 @@ NativeValue* JsWindow::OnMoveTo(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, errCode, x, y](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->MoveTo(x, y);
|
||||
WMError ret = weakWindow->MoveTo(x, y);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window move failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] move end, ret = %{public}d",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), ret);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
};
|
||||
// 2: params num; 2: index of callback
|
||||
NativeValue* lastParam = (info.argc <= 2) ? nullptr :
|
||||
@@ -459,21 +473,23 @@ NativeValue* JsWindow::OnResize(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
WLOGFE("[NAPI]Failed to convert parameter to height");
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, errCode, width, height](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->Resize(width, height);
|
||||
WMError ret = weakWindow->Resize(width, height);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window resize failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] resize end, ret = %{public}d",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), ret);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
};
|
||||
// 2: params num; 2: index of callback
|
||||
NativeValue* lastParam = (info.argc <= 2) ? nullptr :
|
||||
@@ -511,21 +527,23 @@ NativeValue* JsWindow::OnSetWindowType(NativeEngine& engine, NativeCallbackInfo&
|
||||
}
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, winType, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->SetWindowType(winType);
|
||||
WMError ret = weakWindow->SetWindowType(winType);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window set type failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set type end, ret = %{public}d",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), ret);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
@@ -563,14 +581,16 @@ NativeValue* JsWindow::OnSetWindowMode(NativeEngine& engine, NativeCallbackInfo&
|
||||
}
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, winMode, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->SetWindowMode(winMode);
|
||||
WMError ret = weakWindow->SetWindowMode(winMode);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
@@ -578,7 +598,7 @@ NativeValue* JsWindow::OnSetWindowMode(NativeEngine& engine, NativeCallbackInfo&
|
||||
CreateJsError(engine, static_cast<int32_t>(ret), "Window set mode failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set type end, ret = %{public}d",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), ret);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == 1) ? nullptr :
|
||||
@@ -596,14 +616,16 @@ NativeValue* JsWindow::OnGetProperties(NativeEngine& engine, NativeCallbackInfo&
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
auto objValue = CreateJsWindowPropertiesObject(engine, windowToken_);
|
||||
auto objValue = CreateJsWindowPropertiesObject(engine, weakWindow);
|
||||
if (objValue != nullptr) {
|
||||
task.Resolve(engine, objValue);
|
||||
} else {
|
||||
@@ -611,7 +633,7 @@ NativeValue* JsWindow::OnGetProperties(NativeEngine& engine, NativeCallbackInfo&
|
||||
static_cast<int32_t>(WMError::WM_ERROR_NULLPTR), "Window get properties failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] get properties end, objValue = %{public}p",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), objValue);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), objValue);
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == 0) ? nullptr :
|
||||
@@ -675,6 +697,23 @@ NativeValue* JsWindow::OnUnregisterWindowCallback(NativeEngine& engine, NativeCa
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
static void LoadContentTask(std::weak_ptr<NativeReference> contentStorage, std::string contextUrl,
|
||||
sptr<Window> weakWindow, NativeEngine& engine, AsyncTask& task)
|
||||
{
|
||||
NativeValue* nativeStorage = (contentStorage.lock() == nullptr) ? nullptr : contentStorage.lock()->Get();
|
||||
AppExecFwk::Ability* ability = nullptr;
|
||||
GetAPI7Ability(engine, ability);
|
||||
WMError ret = weakWindow->SetUIContent(contextUrl, &engine, nativeStorage, false, ability);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window load content failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] load content end, ret = %{public}d",
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
return;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnLoadContent(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WMError errCode = WMError::WM_OK;
|
||||
@@ -701,26 +740,18 @@ NativeValue* JsWindow::OnLoadContent(NativeEngine& engine, NativeCallbackInfo& i
|
||||
// 2: index of callback
|
||||
callBack = (info.argv[2]->TypeOf() == NATIVE_FUNCTION ? info.argv[2] : nullptr);
|
||||
}
|
||||
std::shared_ptr<NativeReference> contentStorage = (storage == nullptr) ? nullptr :
|
||||
std::weak_ptr<NativeReference> contentStorage = (storage == nullptr) ? nullptr :
|
||||
std::shared_ptr<NativeReference>(engine.CreateReference(storage, 1));
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, contentStorage, contextUrl, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]Window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
NativeValue* nativeStorage = (contentStorage == nullptr) ? nullptr : contentStorage->Get();
|
||||
AppExecFwk::Ability* ability = nullptr;
|
||||
GetAPI7Ability(engine, ability);
|
||||
WMError ret = windowToken_->SetUIContent(contextUrl, &engine, nativeStorage, false, ability);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window load content failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] load content end, ret = %{public}d",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), ret);
|
||||
LoadContentTask(contentStorage, contextUrl, weakWindow, engine, task);
|
||||
};
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule(
|
||||
@@ -746,20 +777,22 @@ NativeValue* JsWindow::OnSetFullScreen(NativeEngine& engine, NativeCallbackInfo&
|
||||
}
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, isFullScreen, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->SetFullScreen(isFullScreen);
|
||||
WMError ret = weakWindow->SetFullScreen(isFullScreen);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window SetFullScreen failed."));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set full screen end, ret = %{public}d",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), ret);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
@@ -787,13 +820,15 @@ NativeValue* JsWindow::OnSetLayoutFullScreen(NativeEngine& engine, NativeCallbac
|
||||
isLayoutFullScreen = static_cast<bool>(*nativeVal);
|
||||
}
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, isLayoutFullScreen, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->SetLayoutFullScreen(isLayoutFullScreen);
|
||||
WMError ret = weakWindow->SetLayoutFullScreen(isLayoutFullScreen);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
@@ -801,7 +836,7 @@ NativeValue* JsWindow::OnSetLayoutFullScreen(NativeEngine& engine, NativeCallbac
|
||||
static_cast<int32_t>(ret), "Window OnSetLayoutFullScreen failed."));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set layout full screen end, ret = %{public}d",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), ret);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
};
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
(info.argv[1]->TypeOf() == NATIVE_FUNCTION ? info.argv[1] : nullptr);
|
||||
@@ -822,16 +857,18 @@ NativeValue* JsWindow::OnSetSystemBarEnable(NativeEngine& engine, NativeCallback
|
||||
if (errCode == WMError::WM_OK && !GetSystemBarStatus(systemBarProperties, engine, info, windowToken_)) {
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, systemBarProperties, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR,
|
||||
WMError ret = weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR,
|
||||
systemBarProperties.at(WindowType::WINDOW_TYPE_STATUS_BAR));
|
||||
ret = windowToken_->SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR,
|
||||
ret = weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR,
|
||||
systemBarProperties.at(WindowType::WINDOW_TYPE_NAVIGATION_BAR));
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
@@ -840,7 +877,7 @@ NativeValue* JsWindow::OnSetSystemBarEnable(NativeEngine& engine, NativeCallback
|
||||
static_cast<int32_t>(ret), "JsWindow::OnSetSystemBarEnable failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set system bar enable end, ret = %{public}d",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), ret);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
};
|
||||
NativeValue* lastParam = nullptr;
|
||||
if (info.argc > 0 && info.argv[0]->TypeOf() == NATIVE_FUNCTION) {
|
||||
@@ -874,15 +911,17 @@ NativeValue* JsWindow::OnSetSystemBarProperties(NativeEngine& engine, NativeCall
|
||||
}
|
||||
}
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, systemBarProperties, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
}
|
||||
WMError ret = windowToken_->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR,
|
||||
WMError ret = weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR,
|
||||
systemBarProperties.at(WindowType::WINDOW_TYPE_STATUS_BAR));
|
||||
ret = windowToken_->SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR,
|
||||
ret = weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR,
|
||||
systemBarProperties.at(WindowType::WINDOW_TYPE_NAVIGATION_BAR));
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
@@ -891,7 +930,7 @@ NativeValue* JsWindow::OnSetSystemBarProperties(NativeEngine& engine, NativeCall
|
||||
static_cast<int32_t>(WMError::WM_ERROR_NULLPTR), "JsWindow::OnSetSystemBarProperties failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set system bar properties end, ret = %{public}d",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), ret);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
@@ -920,16 +959,18 @@ NativeValue* JsWindow::OnGetAvoidArea(NativeEngine& engine, NativeCallbackInfo&
|
||||
avoidAreaType = static_cast<AvoidAreaType>(static_cast<uint32_t>(*nativeMode));
|
||||
}
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, errCode, avoidAreaType](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
// getAvoidRect by avoidAreaType
|
||||
AvoidArea avoidArea;
|
||||
WMError ret = windowToken_->GetAvoidAreaByType(avoidAreaType, avoidArea);
|
||||
WMError ret = weakWindow->GetAvoidAreaByType(avoidAreaType, avoidArea);
|
||||
if (ret != WMError::WM_OK) {
|
||||
avoidArea = { g_emptyRect, g_emptyRect, g_emptyRect, g_emptyRect }; // left, top, right, bottom
|
||||
}
|
||||
@@ -942,7 +983,7 @@ NativeValue* JsWindow::OnGetAvoidArea(NativeEngine& engine, NativeCallbackInfo&
|
||||
static_cast<int32_t>(WMError::WM_ERROR_NULLPTR), "JsWindow::OnGetAvoidArea failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] get avoid area end, ret = %{public}d",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), ret);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
};
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
(info.argv[1]->TypeOf() == NATIVE_FUNCTION ? info.argv[1] : nullptr);
|
||||
@@ -959,17 +1000,19 @@ NativeValue* JsWindow::OnIsShowing(NativeEngine& engine, NativeCallbackInfo& inf
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
bool state = windowToken_->GetShowState();
|
||||
bool state = weakWindow->GetShowState();
|
||||
task.Resolve(engine, CreateJsValue(engine, state));
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] get show state end, state = %{public}u",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), state);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), state);
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == 0) ? nullptr :
|
||||
@@ -987,17 +1030,19 @@ NativeValue* JsWindow::OnIsSupportWideGamut(NativeEngine& engine, NativeCallback
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
bool flag = windowToken_->IsSupportWideGamut();
|
||||
bool flag = weakWindow->IsSupportWideGamut();
|
||||
task.Resolve(engine, CreateJsValue(engine, flag));
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] OnIsSupportWideGamut end, ret = %{public}u",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), flag);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), flag);
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == 0) ? nullptr :
|
||||
@@ -1021,13 +1066,15 @@ NativeValue* JsWindow::OnSetBackgroundColor(NativeEngine& engine, NativeCallback
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, color, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->SetBackgroundColor(color);
|
||||
WMError ret = weakWindow->SetBackgroundColor(color);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
@@ -1035,7 +1082,7 @@ NativeValue* JsWindow::OnSetBackgroundColor(NativeEngine& engine, NativeCallback
|
||||
"Window set background color failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set background color end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str());
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
@@ -1064,20 +1111,22 @@ NativeValue* JsWindow::OnSetBrightness(NativeEngine& engine, NativeCallbackInfo&
|
||||
}
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, brightness, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->SetBrightness(brightness);
|
||||
WMError ret = weakWindow->SetBrightness(brightness);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window set brightness failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set brightness end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str());
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
@@ -1091,7 +1140,7 @@ NativeValue* JsWindow::OnSetBrightness(NativeEngine& engine, NativeCallbackInfo&
|
||||
NativeValue* JsWindow::OnSetDimBehind(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
[](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(WMError::WM_ERROR_NULLPTR)));
|
||||
};
|
||||
|
||||
@@ -1121,20 +1170,22 @@ NativeValue* JsWindow::OnSetFocusable(NativeEngine& engine, NativeCallbackInfo&
|
||||
}
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, focusable, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->SetFocusable(focusable);
|
||||
WMError ret = weakWindow->SetFocusable(focusable);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window set focusable failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set focusable end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str());
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
@@ -1163,13 +1214,15 @@ NativeValue* JsWindow::OnSetKeepScreenOn(NativeEngine& engine, NativeCallbackInf
|
||||
}
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, keepScreenOn, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->SetKeepScreenOn(keepScreenOn);
|
||||
WMError ret = weakWindow->SetKeepScreenOn(keepScreenOn);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
@@ -1177,7 +1230,7 @@ NativeValue* JsWindow::OnSetKeepScreenOn(NativeEngine& engine, NativeCallbackInf
|
||||
"Window set keep screen on failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set keep screen on end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str());
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
@@ -1191,7 +1244,7 @@ NativeValue* JsWindow::OnSetKeepScreenOn(NativeEngine& engine, NativeCallbackInf
|
||||
NativeValue* JsWindow::OnSetOutsideTouchable(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
[](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(WMError::WM_ERROR_NULLPTR)));
|
||||
};
|
||||
|
||||
@@ -1221,16 +1274,18 @@ NativeValue* JsWindow::OnSetPrivacyMode(NativeEngine& engine, NativeCallbackInfo
|
||||
}
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, isPrivacyMode, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params"));
|
||||
return;
|
||||
}
|
||||
windowToken_->SetPrivacyMode(isPrivacyMode);
|
||||
weakWindow->SetPrivacyMode(isPrivacyMode);
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set privacy mode end, mode = %{public}u",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), isPrivacyMode);
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), isPrivacyMode);
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
@@ -1259,20 +1314,22 @@ NativeValue* JsWindow::OnSetTouchable(NativeEngine& engine, NativeCallbackInfo&
|
||||
}
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, touchable, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->SetTouchable(touchable);
|
||||
WMError ret = weakWindow->SetTouchable(touchable);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window set touchable failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set touchable end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str());
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
@@ -1301,20 +1358,22 @@ NativeValue* JsWindow::OnSetTransparent(NativeEngine& engine, NativeCallbackInfo
|
||||
}
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, isTransparent, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->SetTransparent(isTransparent);
|
||||
WMError ret = weakWindow->SetTransparent(isTransparent);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window set transparent failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set transparent end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str());
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
@@ -1343,13 +1402,15 @@ NativeValue* JsWindow::OnSetCallingWindow(NativeEngine& engine, NativeCallbackIn
|
||||
}
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, callingWindow, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
WMError ret = windowToken_->SetCallingWindow(callingWindow);
|
||||
WMError ret = weakWindow->SetCallingWindow(callingWindow);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
@@ -1357,7 +1418,7 @@ NativeValue* JsWindow::OnSetCallingWindow(NativeEngine& engine, NativeCallbackIn
|
||||
"Window set calling window failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set calling window end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str());
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
@@ -1400,17 +1461,19 @@ NativeValue* JsWindow::OnSetColorSpace(NativeEngine& engine, NativeCallbackInfo&
|
||||
}
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, colorSpace, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "OnSetColorSpace failed"));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
windowToken_->SetColorSpace(colorSpace);
|
||||
weakWindow->SetColorSpace(colorSpace);
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] OnSetColorSpace end, colorSpace = %{public}u",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), static_cast<uint32_t>(colorSpace));
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), static_cast<uint32_t>(colorSpace));
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
@@ -1428,17 +1491,19 @@ NativeValue* JsWindow::OnGetColorSpace(NativeEngine& engine, NativeCallbackInfo&
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowToken_ == nullptr || errCode != WMError::WM_OK) {
|
||||
[weakToken, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
ColorSpace colorSpace = windowToken_->GetColorSpace();
|
||||
ColorSpace colorSpace = weakWindow->GetColorSpace();
|
||||
task.Resolve(engine, CreateJsValue(engine, static_cast<uint32_t>(colorSpace)));
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] OnGetColorSpace end, colorSpace = %{public}u",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), static_cast<uint32_t>(colorSpace));
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), static_cast<uint32_t>(colorSpace));
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == 0) ? nullptr :
|
||||
@@ -1473,6 +1538,54 @@ NativeValue* JsWindow::OnDump(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
return dumpInfoValue;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnSetForbidSplitMove(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WMError errCode = WMError::WM_OK;
|
||||
if (info.argc < 1 || info.argc > 2) { // 2: maximum params num
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
bool isForbidSplitMove = false;
|
||||
if (errCode == WMError::WM_OK) {
|
||||
NativeBoolean* nativeVal = ConvertNativeValueTo<NativeBoolean>(info.argv[0]);
|
||||
if (nativeVal == nullptr) {
|
||||
WLOGFE("[NAPI]Failed to convert parameter to isForbidSplitMove");
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
isForbidSplitMove = static_cast<bool>(*nativeVal);
|
||||
}
|
||||
}
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[weakToken, isForbidSplitMove, errCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
WMError ret;
|
||||
if (isForbidSplitMove) {
|
||||
ret = weakWindow->AddWindowFlag(WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE);
|
||||
} else {
|
||||
ret = weakWindow->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE);
|
||||
}
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine,
|
||||
static_cast<int32_t>(ret), "Window OnSetForbidSplitMove failed."));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set forbid split move end, ret = %{public}d",
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
};
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
(info.argv[1]->TypeOf() == NATIVE_FUNCTION ? info.argv[1] : nullptr);
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule(
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeReference> FindJsWindowObject(std::string windowName)
|
||||
{
|
||||
WLOGFI("[NAPI]Try to find window %{public}s in g_jsWindowMap", windowName.c_str());
|
||||
@@ -1533,6 +1646,7 @@ NativeValue* CreateJsWindowObject(NativeEngine& engine, sptr<Window>& window)
|
||||
BindNativeFunction(engine, *object, "setCallingWindow", JsWindow::SetCallingWindow);
|
||||
BindNativeFunction(engine, *object, "disableWindowDecor", JsWindow::DisableWindowDecor);
|
||||
BindNativeFunction(engine, *object, "dump", JsWindow::Dump);
|
||||
BindNativeFunction(engine, *object, "setForbidSplitMove", JsWindow::SetForbidSplitMove);
|
||||
|
||||
std::shared_ptr<NativeReference> jsWindowRef;
|
||||
jsWindowRef.reset(engine.CreateReference(objValue, 1));
|
||||
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
static NativeValue* SetColorSpace(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* GetColorSpace(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* Dump(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* SetForbidSplitMove(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
|
||||
private:
|
||||
std::string GetWindowName();
|
||||
@@ -103,6 +104,7 @@ private:
|
||||
NativeValue* OnSetCallingWindow(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnDisableWindowDecor(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnDump(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnSetForbidSplitMove(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
|
||||
sptr<Window> windowToken_ = nullptr;
|
||||
std::unique_ptr<JsWindowRegisterManager> registerManager_ = nullptr;
|
||||
|
||||
@@ -176,5 +176,19 @@ void JsWindowListener::OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info)
|
||||
std::unique_ptr<AsyncTask::ExecuteCallback> execute = nullptr;
|
||||
AsyncTask::Schedule(*engine_, std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
}
|
||||
|
||||
void JsWindowListener::OnOutsidePressed()
|
||||
{
|
||||
std::unique_ptr<AsyncTask::CompleteCallback> complete = std::make_unique<AsyncTask::CompleteCallback> (
|
||||
[=] (NativeEngine &engine, AsyncTask &task, int32_t status) {
|
||||
CallJsMethod(OUTSIDE_PRESSED_CB.c_str(), nullptr, 0);
|
||||
}
|
||||
);
|
||||
|
||||
NativeReference* callback = nullptr;
|
||||
std::unique_ptr<AsyncTask::ExecuteCallback> execute = nullptr;
|
||||
AsyncTask::Schedule(*engine_, std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
WLOGFI("CALLED");
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -34,12 +34,14 @@ const std::string SYSTEM_AVOID_AREA_CHANGE_CB = "systemAvoidAreaChange";
|
||||
const std::string LIFECYCLE_EVENT_CB = "lifeCycleEvent";
|
||||
const std::string WINDOW_STAGE_EVENT_CB = "windowStageEvent";
|
||||
const std::string KEYBOARD_HEIGHT_CHANGE_CB = "keyboardHeightChange";
|
||||
const std::string OUTSIDE_PRESSED_CB = "outsidePressed";
|
||||
|
||||
class JsWindowListener : public IWindowChangeListener,
|
||||
public ISystemBarChangedListener,
|
||||
public IAvoidAreaChangedListener,
|
||||
public IWindowLifeCycle,
|
||||
public IOccupiedAreaChangeListener {
|
||||
public IOccupiedAreaChangeListener,
|
||||
public IOutsidePressedListener {
|
||||
public:
|
||||
JsWindowListener(NativeEngine* engine, std::shared_ptr<NativeReference> callback)
|
||||
: engine_(engine), jsCallBack_(callback) {}
|
||||
@@ -53,6 +55,7 @@ public:
|
||||
void AfterFocused() override;
|
||||
void AfterUnfocused() override;
|
||||
void OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info) override;
|
||||
void OnOutsidePressed() override;
|
||||
private:
|
||||
void CallJsMethod(const char* methodName, NativeValue* const* argv = nullptr, size_t argc = 0);
|
||||
void LifeCycleCallBack(LifeCycleEventType eventType);
|
||||
|
||||
@@ -33,7 +33,8 @@ JsWindowRegisterManager::JsWindowRegisterManager()
|
||||
{WINDOW_SIZE_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowChangeRegister },
|
||||
{SYSTEM_AVOID_AREA_CHANGE_CB, &JsWindowRegisterManager::ProcessAvoidAreaChangeRegister },
|
||||
{LIFECYCLE_EVENT_CB, &JsWindowRegisterManager::ProcessLifeCycleEventRegister },
|
||||
{KEYBOARD_HEIGHT_CHANGE_CB, &JsWindowRegisterManager::ProcesOccupiedAreaChangeRegister }
|
||||
{KEYBOARD_HEIGHT_CHANGE_CB, &JsWindowRegisterManager::ProcesOccupiedAreaChangeRegister },
|
||||
{OUTSIDE_PRESSED_CB, &JsWindowRegisterManager::ProcessOutsidePressedRegister }
|
||||
};
|
||||
// white register list for window stage
|
||||
listenerProcess_[CaseType::CASE_STAGE] = {
|
||||
@@ -121,6 +122,22 @@ bool JsWindowRegisterManager::ProcessSystemBarChangeRegister(sptr<JsWindowListen
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JsWindowRegisterManager::ProcessOutsidePressedRegister(sptr<JsWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister)
|
||||
{
|
||||
WLOGFI("called");
|
||||
if (window == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (isRegister) {
|
||||
sptr<IOutsidePressedListener> thisListener(listener);
|
||||
window->RegisterOutsidePressedListener(thisListener);
|
||||
} else {
|
||||
window->RegisterOutsidePressedListener(nullptr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JsWindowRegisterManager::IsCallbackRegistered(std::string type, NativeValue* jsListenerObject)
|
||||
{
|
||||
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
|
||||
|
||||
@@ -44,6 +44,7 @@ private:
|
||||
bool ProcessLifeCycleEventRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
bool ProcesOccupiedAreaChangeRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
bool ProcessSystemBarChangeRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
bool ProcessOutsidePressedRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
using Func_t = bool(JsWindowRegisterManager::*)(sptr<JsWindowListener>, sptr<Window> window, bool);
|
||||
std::map<std::string, std::map<std::shared_ptr<NativeReference>, sptr<JsWindowListener>>> jsCbMap_;
|
||||
std::mutex mtx_;
|
||||
|
||||
@@ -106,6 +106,13 @@ NativeValue* JsWindowStage::SetShowOnLockScreen(NativeEngine* engine, NativeCall
|
||||
return (me != nullptr) ? me->OnSetShowOnLockScreen(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindowStage::DisableWindowDecor(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
WLOGFI("[NAPI]DisableWindowDecor");
|
||||
JsWindowStage* me = CheckParamsAndGetThis<JsWindowStage>(engine, info);
|
||||
return (me != nullptr) ? me->OnDisableWindowDecor(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindowStage::OnSetUIContent(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
if (info.argc < 2) { // 2: minimum param num
|
||||
@@ -252,9 +259,9 @@ NativeValue* JsWindowStage::OnLoadContent(NativeEngine& engine, NativeCallbackIn
|
||||
std::shared_ptr<NativeReference>(engine.CreateReference(storage, 1));
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (windowScene_ == nullptr) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(WMError::WM_ERROR_NULLPTR)));
|
||||
WLOGFE("[NAPI]windowScene_ is nullptr");
|
||||
if (windowScene_ == nullptr || errCode != WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
WLOGFE("[NAPI]Window scene is null or get invalid param");
|
||||
return;
|
||||
}
|
||||
auto win = windowScene_->GetMainWindow();
|
||||
@@ -417,6 +424,20 @@ NativeValue* JsWindowStage::OnSetShowOnLockScreen(NativeEngine& engine, NativeCa
|
||||
return CreateJsValue(engine, static_cast<int32_t>(ret));
|
||||
}
|
||||
|
||||
NativeValue* JsWindowStage::OnDisableWindowDecor(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
if (windowScene_ == nullptr || windowScene_->GetMainWindow() == nullptr) {
|
||||
WLOGFE("[NAPI]WindowScene is null or window is null");
|
||||
return CreateJsValue(engine, static_cast<int32_t>(WMError::WM_ERROR_NULLPTR));
|
||||
}
|
||||
|
||||
auto window = windowScene_->GetMainWindow();
|
||||
window->DisableAppWindowDecor();
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] disable app window decor end",
|
||||
window->GetWindowId(), window->GetWindowName().c_str());
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
NativeValue* CreateJsWindowStage(NativeEngine& engine,
|
||||
std::shared_ptr<Rosen::WindowScene> windowScene)
|
||||
{
|
||||
@@ -443,6 +464,8 @@ NativeValue* CreateJsWindowStage(NativeEngine& engine,
|
||||
BindNativeFunction(engine, *object, "off", JsWindowStage::Off);
|
||||
BindNativeFunction(engine,
|
||||
*object, "setShowOnLockScreen", JsWindowStage::SetShowOnLockScreen);
|
||||
BindNativeFunction(engine,
|
||||
*object, "disableWindowDecor", JsWindowStage::DisableWindowDecor);
|
||||
|
||||
return objValue;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
static NativeValue* CreateSubWindow(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* GetSubWindow(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* SetShowOnLockScreen(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* DisableWindowDecor(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
|
||||
private:
|
||||
NativeValue* CreateJsSubWindowArrayObject(NativeEngine& engine, std::vector<sptr<Window>> subWinVec);
|
||||
@@ -50,6 +51,7 @@ private:
|
||||
NativeValue* OnCreateSubWindow(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnGetSubWindow(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnSetShowOnLockScreen(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnDisableWindowDecor(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
|
||||
std::shared_ptr<Rosen::WindowScene> windowScene_;
|
||||
};
|
||||
|
||||
@@ -53,6 +53,10 @@ class WindowStage {
|
||||
setShowOnLockScreen(showOnLockScreen) {
|
||||
return this.__window_stage__.setShowOnLockScreen(showOnLockScreen)
|
||||
}
|
||||
|
||||
disableWindowDecor() {
|
||||
return this.__window_stage__.disableWindowDecor()
|
||||
}
|
||||
}
|
||||
|
||||
export default WindowStage
|
||||
|
||||
@@ -15,5 +15,5 @@
|
||||
-->
|
||||
<Configs>
|
||||
<!--Window display dpi, valid range is 80~640, use 0 if no configuration is requeired-->
|
||||
<dpi>160</dpi>
|
||||
</Configs>
|
||||
<dpi>240</dpi>
|
||||
</Configs>
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ ohos_executable("snapshot_virtual_screen") {
|
||||
configs = [ ":snapshot_config" ]
|
||||
|
||||
deps = [
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
"//foundation/windowmanager/utils:libwmutil",
|
||||
"//foundation/windowmanager/wm:libwm",
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/graphic/graphic/graphic_config.gni")
|
||||
import("//foundation/graphic/graphic_2d/graphic_config.gni")
|
||||
config("libwmutil_private_config") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
@@ -51,8 +51,8 @@ ohos_shared_library("libwmutil") {
|
||||
public_configs = [ ":libwmutil_public_config" ]
|
||||
|
||||
deps = [
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_base:librender_service_base",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_base:librender_service_base",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//third_party/flutter/build/skia:ace_skia_ohos",
|
||||
]
|
||||
|
||||
|
||||
@@ -59,11 +59,26 @@ public:
|
||||
return ((IsMainWindow(type)) && (mode == WindowMode::WINDOW_MODE_FLOATING));
|
||||
}
|
||||
|
||||
static inline bool IsMainFullScreenWindow(WindowType type, WindowMode mode)
|
||||
{
|
||||
return ((IsMainWindow(type)) && (mode == WindowMode::WINDOW_MODE_FULLSCREEN));
|
||||
}
|
||||
|
||||
static inline bool IsFloatintWindow(WindowMode mode)
|
||||
{
|
||||
return mode == WindowMode::WINDOW_MODE_FLOATING;
|
||||
}
|
||||
|
||||
static inline bool IsAvoidAreaWindow(WindowType type)
|
||||
{
|
||||
return (type == WindowType::WINDOW_TYPE_STATUS_BAR || type == WindowType::WINDOW_TYPE_NAVIGATION_BAR);
|
||||
}
|
||||
|
||||
static inline bool IsFullScreenWindow(WindowMode mode)
|
||||
{
|
||||
return mode == WindowMode::WINDOW_MODE_FULLSCREEN;
|
||||
}
|
||||
|
||||
static inline bool IsSplitWindowMode(WindowMode mode)
|
||||
{
|
||||
return mode == WindowMode::WINDOW_MODE_SPLIT_PRIMARY || mode == WindowMode::WINDOW_MODE_SPLIT_SECONDARY;
|
||||
@@ -86,6 +101,45 @@ public:
|
||||
return (r.posX_ == 0 && r.posY_ == 0 && r.width_ == 0 && r.height_ == 0);
|
||||
}
|
||||
|
||||
static bool IsWindowModeSupported(uint32_t modeSupportInfo, WindowMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case WindowMode::WINDOW_MODE_FULLSCREEN:
|
||||
return WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN & modeSupportInfo;
|
||||
case WindowMode::WINDOW_MODE_FLOATING:
|
||||
return WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING & modeSupportInfo;
|
||||
case WindowMode::WINDOW_MODE_SPLIT_PRIMARY:
|
||||
return WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY & modeSupportInfo;
|
||||
case WindowMode::WINDOW_MODE_SPLIT_SECONDARY:
|
||||
return WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY & modeSupportInfo;
|
||||
case WindowMode::WINDOW_MODE_PIP:
|
||||
return WindowModeSupport::WINDOW_MODE_SUPPORT_PIP & modeSupportInfo;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static WindowMode GetWindowModeFromModeSupportInfo(uint32_t modeSupportInfo)
|
||||
{
|
||||
// get the binary number consists of the last 1 and 0 behind it
|
||||
uint32_t windowModeSupport = modeSupportInfo & (~modeSupportInfo + 1);
|
||||
|
||||
switch (windowModeSupport) {
|
||||
case WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN:
|
||||
return WindowMode::WINDOW_MODE_FULLSCREEN;
|
||||
case WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING:
|
||||
return WindowMode::WINDOW_MODE_FLOATING;
|
||||
case WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY:
|
||||
return WindowMode::WINDOW_MODE_SPLIT_PRIMARY;
|
||||
case WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY:
|
||||
return WindowMode::WINDOW_MODE_SPLIT_SECONDARY;
|
||||
case WindowModeSupport::WINDOW_MODE_SUPPORT_PIP:
|
||||
return WindowMode::WINDOW_MODE_PIP;
|
||||
default:
|
||||
return WindowMode::WINDOW_MODE_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
static Rect GetFixedWindowRectByLimitSize(const Rect& oriDstRect, const Rect& lastRect, bool isVertical,
|
||||
float virtualPixelRatio)
|
||||
{
|
||||
|
||||
@@ -66,6 +66,9 @@ public:
|
||||
void SetAnimationFlag(uint32_t animationFlag);
|
||||
void SetWindowSizeChangeReason(WindowSizeChangeReason reason);
|
||||
void SetTokenState(bool hasToken);
|
||||
void SetWindowPid(int32_t pid);
|
||||
void SetWindowUid(int32_t uid);
|
||||
void SetModeSupportInfo(uint32_t modeSupportInfo);
|
||||
WindowSizeChangeReason GetWindowSizeChangeReason() const;
|
||||
|
||||
const std::string& GetWindowName() const;
|
||||
@@ -96,6 +99,9 @@ public:
|
||||
bool GetDecorEnable() const;
|
||||
const PointInfo& GetHitOffset() const;
|
||||
uint32_t GetAnimationFlag() const;
|
||||
int32_t GetWindowPid() const;
|
||||
int32_t GetWindowUid() const;
|
||||
uint32_t GetModeSupportInfo() const;
|
||||
|
||||
virtual bool Marshalling(Parcel& parcel) const override;
|
||||
static WindowProperty* Unmarshalling(Parcel& parcel);
|
||||
@@ -128,12 +134,15 @@ private:
|
||||
uint32_t parentId_ { 0 };
|
||||
PointInfo hitOffset_ { 0, 0 };
|
||||
uint32_t animationFlag_ { static_cast<uint32_t>(WindowAnimation::DEFAULT) };
|
||||
uint32_t modeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL};
|
||||
WindowSizeChangeReason windowSizeChangeReason_ = WindowSizeChangeReason::UNDEFINED;
|
||||
std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ {
|
||||
{ WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty() },
|
||||
{ WindowType::WINDOW_TYPE_NAVIGATION_BAR, SystemBarProperty() },
|
||||
};
|
||||
bool isDecorEnable_ { false };
|
||||
int32_t pid_ { INVALID_PID };
|
||||
int32_t uid_ { INVALID_UID };
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(Orientation, RequestedOrientation, requestedOrientation, Orientation::UNSPECIFIED);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ enum class PropertyChangeAction : uint32_t {
|
||||
ACTION_UPDATE_TURN_SCREEN_ON = 1 << 8,
|
||||
ACTION_UPDATE_KEEP_SCREEN_ON = 1 << 9,
|
||||
ACTION_UPDATE_SET_BRIGHTNESS = 1 << 10,
|
||||
ACTION_UPDATE_MODE_SUPPORT_INFO = 1 << 11,
|
||||
};
|
||||
|
||||
struct ModeChangeHotZonesConfig {
|
||||
|
||||
@@ -165,6 +165,16 @@ void WindowProperty::SetWindowSizeChangeReason(WindowSizeChangeReason reason)
|
||||
windowSizeChangeReason_ = reason;
|
||||
}
|
||||
|
||||
void WindowProperty::SetWindowPid(int32_t pid)
|
||||
{
|
||||
pid_ = pid;
|
||||
}
|
||||
|
||||
void WindowProperty::SetWindowUid(int32_t uid)
|
||||
{
|
||||
uid_ = uid;
|
||||
}
|
||||
|
||||
WindowSizeChangeReason WindowProperty::GetWindowSizeChangeReason() const
|
||||
{
|
||||
return windowSizeChangeReason_;
|
||||
@@ -300,6 +310,11 @@ void WindowProperty::SetTokenState(bool hasToken)
|
||||
tokenState_ = hasToken;
|
||||
}
|
||||
|
||||
void WindowProperty::SetModeSupportInfo(uint32_t modeSupportInfo)
|
||||
{
|
||||
modeSupportInfo_ = modeSupportInfo;
|
||||
}
|
||||
|
||||
uint32_t WindowProperty::GetWindowId() const
|
||||
{
|
||||
return windowId_;
|
||||
@@ -320,11 +335,26 @@ uint32_t WindowProperty::GetAnimationFlag() const
|
||||
return animationFlag_;
|
||||
}
|
||||
|
||||
uint32_t WindowProperty::GetModeSupportInfo() const
|
||||
{
|
||||
return modeSupportInfo_;
|
||||
}
|
||||
|
||||
bool WindowProperty::GetTokenState() const
|
||||
{
|
||||
return tokenState_;
|
||||
}
|
||||
|
||||
int32_t WindowProperty::GetWindowPid() const
|
||||
{
|
||||
return pid_;
|
||||
}
|
||||
|
||||
int32_t WindowProperty::GetWindowUid() const
|
||||
{
|
||||
return uid_;
|
||||
}
|
||||
|
||||
bool WindowProperty::MapMarshalling(Parcel& parcel) const
|
||||
{
|
||||
auto size = sysBarPropMap_.size();
|
||||
@@ -373,7 +403,9 @@ bool WindowProperty::Marshalling(Parcel& parcel) const
|
||||
parcel.WriteInt32(hitOffset_.x) && parcel.WriteInt32(hitOffset_.y) && parcel.WriteUint32(animationFlag_) &&
|
||||
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.WriteBool(turnScreenOn_) && parcel.WriteBool(keepScreenOn_) &&
|
||||
parcel.WriteInt32(pid_) && parcel.WriteInt32(uid_) &&
|
||||
parcel.WriteUint32(modeSupportInfo_);
|
||||
}
|
||||
|
||||
WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel)
|
||||
@@ -414,6 +446,9 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel)
|
||||
property->SetRequestedOrientation(static_cast<Orientation>(parcel.ReadUint32()));
|
||||
property->SetTurnScreenOn(parcel.ReadBool());
|
||||
property->SetKeepScreenOn(parcel.ReadBool());
|
||||
property->SetWindowPid(parcel.ReadInt32());
|
||||
property->SetWindowUid(parcel.ReadInt32());
|
||||
property->SetModeSupportInfo(parcel.ReadUint32());
|
||||
return property;
|
||||
}
|
||||
|
||||
@@ -448,6 +483,9 @@ void WindowProperty::CopyFrom(const sptr<WindowProperty>& property)
|
||||
requestedOrientation_ = property->requestedOrientation_;
|
||||
turnScreenOn_ = property->turnScreenOn_;
|
||||
keepScreenOn_ = property->keepScreenOn_;
|
||||
pid_ = property->pid_;
|
||||
uid_ = property->uid_;
|
||||
modeSupportInfo_ = property->modeSupportInfo_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -61,12 +61,12 @@ ohos_shared_library("libwm") {
|
||||
public_configs = [ ":libwm_public_config" ]
|
||||
|
||||
deps = [
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
"//foundation/windowmanager/utils:libwmutil",
|
||||
|
||||
# vsync
|
||||
"//foundation/graphic/graphic/rosen/modules/composer:libcomposer",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/composer:libcomposer",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_INPUT_TRANSFER_STATION
|
||||
#define OHOS_INPUT_TRANSFER_STATION
|
||||
#ifndef OHOS_INPUT_TRANSFER_STATION_H
|
||||
#define OHOS_INPUT_TRANSFER_STATION_H
|
||||
|
||||
#include "input_manager.h"
|
||||
#include "pointer_event.h"
|
||||
@@ -53,4 +53,4 @@ public:
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
#endif // OHOS_INPUT_TRANSFER_STATION
|
||||
#endif // OHOS_INPUT_TRANSFER_STATION_H
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
virtual void ProcessPointDown(uint32_t windowId, bool isStartDrag = false);
|
||||
virtual void ProcessPointUp(uint32_t windowId);
|
||||
virtual void MinimizeAllAppWindows(DisplayId displayId);
|
||||
virtual void ToggleShownStateForAllAppWindows();
|
||||
virtual WMError ToggleShownStateForAllAppWindows();
|
||||
virtual WMError MaxmizeWindow(uint32_t windowId);
|
||||
virtual WMError SetWindowLayoutMode(WindowLayoutMode mode);
|
||||
virtual WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action);
|
||||
|
||||
@@ -37,6 +37,8 @@ public:
|
||||
void UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info) override;
|
||||
void UpdateActiveStatus(bool isActive) override;
|
||||
sptr<WindowProperty> GetWindowProperty() override;
|
||||
void NotifyOutsidePressed() override;
|
||||
void DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) override;
|
||||
private:
|
||||
sptr<WindowImpl> window_;
|
||||
};
|
||||
|
||||
@@ -94,6 +94,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;
|
||||
inline NotifyNativeWinDestroyFunc GetNativeDestroyCallback()
|
||||
{
|
||||
return notifyNativefunc_;
|
||||
@@ -163,7 +164,9 @@ public:
|
||||
virtual void RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) override;
|
||||
virtual void RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
|
||||
virtual void UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
|
||||
virtual void RegisterOutsidePressedListener(const sptr<IOutsidePressedListener>& listener) override;
|
||||
virtual void SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler) override;
|
||||
virtual void SetModeSupportInfo(uint32_t modeSupportInfo) override;
|
||||
void UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason);
|
||||
void UpdateMode(WindowMode mode);
|
||||
virtual void ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent>& inputEvent) override;
|
||||
@@ -178,6 +181,7 @@ public:
|
||||
void UpdateDisplayId(DisplayId from, DisplayId to);
|
||||
void UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info);
|
||||
void UpdateActiveStatus(bool isActive);
|
||||
void NotifyOutsidePressed();
|
||||
|
||||
virtual WMError SetUIContent(const std::string& contentInfo, NativeEngine* engine,
|
||||
NativeValue* storage, bool isdistributed, AppExecFwk::Ability* ability) override;
|
||||
@@ -244,6 +248,10 @@ private:
|
||||
{
|
||||
CALL_LIFECYCLE_LISTENER(AfterInactive);
|
||||
}
|
||||
inline void NotifyForegroundFailed() const
|
||||
{
|
||||
CALL_LIFECYCLE_LISTENER(ForegroundFailed);
|
||||
}
|
||||
void DestroyFloatingWindow();
|
||||
void DestroySubWindow();
|
||||
void SetDefaultOption(); // for api7
|
||||
@@ -286,6 +294,7 @@ private:
|
||||
WindowState state_ { WindowState::STATE_INITIAL };
|
||||
WindowTag windowTag_;
|
||||
sptr<IAceAbilityHandler> aceAbilityHandler_;
|
||||
sptr<IOutsidePressedListener> outsidePressListener_;
|
||||
std::vector<sptr<IWindowLifeCycle>> lifecycleListeners_;
|
||||
std::vector<sptr<IWindowChangeListener>> windowChangeListeners_;
|
||||
std::vector<sptr<IAvoidAreaChangedListener>> avoidAreaChangeListeners_;
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef OHOS_WINDOW_INPUT_CHANNEL
|
||||
#define OHOS_WINDOW_INPUT_CHANNEL
|
||||
#ifndef OHOS_WINDOW_INPUT_CHANNEL_H
|
||||
#define OHOS_WINDOW_INPUT_CHANNEL_H
|
||||
|
||||
#include <window.h>
|
||||
#include <i_input_event_consumer.h>
|
||||
@@ -47,4 +47,4 @@ private:
|
||||
}
|
||||
|
||||
|
||||
#endif // OHOS_WINDOW_INPUT_CHANNEL
|
||||
#endif // OHOS_WINDOW_INPUT_CHANNEL_H
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
TRANS_ID_UPDATE_OCCUPIED_AREA,
|
||||
TRANS_ID_UPDATE_ACTIVE_STATUS,
|
||||
TRANS_ID_GET_WINDOW_PROPERTY,
|
||||
TRANS_ID_NOTIFY_OUTSIDE_PRESSED,
|
||||
TRANS_ID_DUMP_INFO,
|
||||
};
|
||||
|
||||
virtual void UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) = 0;
|
||||
@@ -51,6 +53,8 @@ public:
|
||||
virtual void UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info) = 0;
|
||||
virtual void UpdateActiveStatus(bool isActive) = 0;
|
||||
virtual sptr<WindowProperty> GetWindowProperty() = 0;
|
||||
virtual void NotifyOutsidePressed() = 0;
|
||||
virtual void DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) = 0;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -38,6 +38,8 @@ public:
|
||||
void UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info) override;
|
||||
void UpdateActiveStatus(bool isActive) override;
|
||||
sptr<WindowProperty> GetWindowProperty() override;
|
||||
void NotifyOutsidePressed() override;
|
||||
void DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) override;
|
||||
private:
|
||||
static inline BrokerDelegator<WindowProxy> delegator_;
|
||||
};
|
||||
|
||||
@@ -142,11 +142,11 @@ void WindowAdapter::MinimizeAllAppWindows(DisplayId displayId)
|
||||
windowManagerServiceProxy_->MinimizeAllAppWindows(displayId);
|
||||
}
|
||||
|
||||
void WindowAdapter::ToggleShownStateForAllAppWindows()
|
||||
WMError WindowAdapter::ToggleShownStateForAllAppWindows()
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN();
|
||||
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
|
||||
|
||||
windowManagerServiceProxy_->ToggleShownStateForAllAppWindows();
|
||||
return windowManagerServiceProxy_->ToggleShownStateForAllAppWindows();
|
||||
}
|
||||
|
||||
WMError WindowAdapter::MaxmizeWindow(uint32_t windowId)
|
||||
|
||||
@@ -117,5 +117,24 @@ sptr<WindowProperty> WindowAgent::GetWindowProperty()
|
||||
}
|
||||
return window_->GetWindowProperty();
|
||||
}
|
||||
|
||||
void WindowAgent::NotifyOutsidePressed()
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
WLOGFI("window is null");
|
||||
return;
|
||||
}
|
||||
WLOGFI("called");
|
||||
window_->NotifyOutsidePressed();
|
||||
}
|
||||
|
||||
void WindowAgent::DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
WLOGFE("window_ is nullptr");
|
||||
return;
|
||||
}
|
||||
window_->DumpInfo(params, info);
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
+63
-10
@@ -33,6 +33,7 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowImpl"};
|
||||
const std::string PARAM_DUMP_HELP = "-h";
|
||||
}
|
||||
|
||||
const WindowImpl::ColorSpaceConvertMap WindowImpl::colorSpaceConvertMap[] = {
|
||||
@@ -251,6 +252,11 @@ uint32_t WindowImpl::GetWindowFlags() const
|
||||
return property_->GetWindowFlags();
|
||||
}
|
||||
|
||||
uint32_t WindowImpl::GetModeSupportInfo() const
|
||||
{
|
||||
return property_->GetModeSupportInfo();
|
||||
}
|
||||
|
||||
SystemBarProperty WindowImpl::GetSystemBarPropertyByType(WindowType type) const
|
||||
{
|
||||
auto curProperties = property_->GetSystemBarProperty();
|
||||
@@ -303,12 +309,19 @@ WMError WindowImpl::SetWindowMode(WindowMode mode)
|
||||
if (!IsWindowValid()) {
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
if (!WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), mode)) {
|
||||
WLOGFI("window %{public}u do not support window mode: %{public}u",
|
||||
property_->GetWindowId(), static_cast<uint32_t>(mode));
|
||||
return WMError::WM_DO_NOTHING;
|
||||
}
|
||||
if (state_ == WindowState::STATE_CREATED || state_ == WindowState::STATE_HIDDEN) {
|
||||
UpdateMode(mode);
|
||||
} else if (state_ == WindowState::STATE_SHOWN) {
|
||||
WindowMode lastMode = property_->GetWindowMode();
|
||||
property_->SetWindowMode(mode);
|
||||
WMError ret = UpdateProperty(PropertyChangeAction::ACTION_UPDATE_MODE);
|
||||
if (ret != WMError::WM_OK) {
|
||||
property_->SetWindowMode(lastMode);
|
||||
return ret;
|
||||
}
|
||||
// set client window mode if success.
|
||||
@@ -490,7 +503,12 @@ ColorSpace WindowImpl::GetColorSpace()
|
||||
|
||||
void WindowImpl::DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info)
|
||||
{
|
||||
WLOGFI("Ace:DumpInfo");
|
||||
if (params.size() == 1 && params[0] == PARAM_DUMP_HELP) { // 1: params num
|
||||
WLOGFI("Dump ArkUI help Info");
|
||||
Ace::UIContent::ShowDumpHelp(info);
|
||||
return;
|
||||
}
|
||||
WLOGFI("ArkUI:DumpInfo");
|
||||
if (uiContent_ != nullptr) {
|
||||
uiContent_->DumpInfo(params, info);
|
||||
}
|
||||
@@ -752,12 +770,6 @@ WMError WindowImpl::Show(uint32_t reason)
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
|
||||
if ((GetWindowFlags() & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED)) &&
|
||||
WindowHelper::IsSplitWindowMode(GetMode())) {
|
||||
WLOGFE("show when locked window does not support split mode, windowId: %{public}u", property_->GetWindowId());
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
|
||||
WindowStateChangeReason stateChangeReason = static_cast<WindowStateChangeReason>(reason);
|
||||
if (stateChangeReason == WindowStateChangeReason::KEYGUARD ||
|
||||
stateChangeReason == WindowStateChangeReason::TOGGLING) {
|
||||
@@ -790,7 +802,8 @@ WMError WindowImpl::Show(uint32_t reason)
|
||||
state_ = WindowState::STATE_SHOWN;
|
||||
NotifyAfterForeground();
|
||||
} else {
|
||||
WLOGFE("show errCode:%{public}d for winId:%{public}u", static_cast<int32_t>(ret), property_->GetWindowId());
|
||||
NotifyForegroundFailed();
|
||||
WLOGFE("show window id:%{public}u errCode:%{public}d", property_->GetWindowId(), static_cast<int32_t>(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -1326,6 +1339,12 @@ void WindowImpl::UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaCh
|
||||
}), occupiedAreaChangeListeners_.end());
|
||||
}
|
||||
|
||||
void WindowImpl::RegisterOutsidePressedListener(const sptr<IOutsidePressedListener>& listener)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
outsidePressListener_ = listener;
|
||||
}
|
||||
|
||||
void WindowImpl::SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler)
|
||||
{
|
||||
if (handler == nullptr) {
|
||||
@@ -1335,6 +1354,22 @@ void WindowImpl::SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler)
|
||||
aceAbilityHandler_ = handler;
|
||||
}
|
||||
|
||||
void WindowImpl::SetModeSupportInfo(uint32_t modeSupportInfo)
|
||||
{
|
||||
property_->SetModeSupportInfo(modeSupportInfo);
|
||||
UpdateProperty(PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO);
|
||||
if (!WindowHelper::IsWindowModeSupported(modeSupportInfo, GetMode())) {
|
||||
WLOGFI("currunt 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)
|
||||
{
|
||||
auto display = DisplayManager::GetInstance().GetDisplayById(property_->GetDisplayId());
|
||||
@@ -1355,8 +1390,8 @@ void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSize
|
||||
|
||||
// update originRect when window show for the first time.
|
||||
if (!isStretchableSet_) {
|
||||
originRect_ = rect;
|
||||
isStretchableSet_ = true;
|
||||
originRect_ = rect;
|
||||
isStretchableSet_ = true;
|
||||
}
|
||||
|
||||
Rect rectToAce = rect;
|
||||
@@ -1884,6 +1919,20 @@ void WindowImpl::UpdateActiveStatus(bool isActive)
|
||||
}
|
||||
}
|
||||
|
||||
void WindowImpl::NotifyOutsidePressed()
|
||||
{
|
||||
sptr<IOutsidePressedListener> outsidePressListener;
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
outsidePressListener = outsidePressListener_;
|
||||
}
|
||||
|
||||
if (outsidePressListener != nullptr) {
|
||||
WLOGFI("called");
|
||||
outsidePressListener->OnOutsidePressed();
|
||||
}
|
||||
}
|
||||
|
||||
Rect WindowImpl::GetSystemAlarmWindowDefaultSize(Rect defaultRect)
|
||||
{
|
||||
auto display = DisplayManager::GetInstance().GetDisplayById(property_->GetDisplayId());
|
||||
@@ -1957,6 +2006,10 @@ void WindowImpl::SetDefaultOption()
|
||||
property_->SetFocusable(false);
|
||||
break;
|
||||
}
|
||||
case WindowType::WINDOW_TYPE_VOICE_INTERACTION: {
|
||||
property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -310,10 +310,10 @@ void WindowManager::MinimizeAllAppWindows(DisplayId displayId)
|
||||
SingletonContainer::Get<WindowAdapter>().MinimizeAllAppWindows(displayId);
|
||||
}
|
||||
|
||||
void WindowManager::ToggleShownStateForAllAppWindows()
|
||||
WMError WindowManager::ToggleShownStateForAllAppWindows()
|
||||
{
|
||||
WLOGFI("ToggleShownStateForAllAppWindows");
|
||||
SingletonContainer::Get<WindowAdapter>().ToggleShownStateForAllAppWindows();
|
||||
return SingletonContainer::Get<WindowAdapter>().ToggleShownStateForAllAppWindows();
|
||||
}
|
||||
|
||||
WMError WindowManager::SetWindowLayoutMode(WindowLayoutMode mode)
|
||||
|
||||
@@ -246,6 +246,44 @@ sptr<WindowProperty> WindowProxy::GetWindowProperty()
|
||||
}
|
||||
return reply.ReadParcelable<WindowProperty>();
|
||||
}
|
||||
|
||||
void WindowProxy::NotifyOutsidePressed()
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel replay;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_NOTIFY_OUTSIDE_PRESSED),
|
||||
data, replay, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
}
|
||||
}
|
||||
|
||||
void WindowProxy::DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteStringVector(params)) {
|
||||
WLOGFE("Write params failed");
|
||||
return;
|
||||
}
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_DUMP_INFO),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
}
|
||||
if (!reply.ReadStringVector(&info)) {
|
||||
WLOGFE("Read info failed");
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -107,6 +107,22 @@ int WindowStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParce
|
||||
reply.WriteParcelable(property.GetRefPtr());
|
||||
break;
|
||||
}
|
||||
case WindowMessage::TRANS_ID_NOTIFY_OUTSIDE_PRESSED: {
|
||||
NotifyOutsidePressed();
|
||||
break;
|
||||
}
|
||||
case WindowMessage::TRANS_ID_DUMP_INFO: {
|
||||
std::vector<std::string> params;
|
||||
if (!data.ReadStringVector(¶ms)) {
|
||||
WLOGFE("Fail to read params");
|
||||
}
|
||||
std::vector<std::string> info;
|
||||
DumpInfo(params, info);
|
||||
if (!reply.WriteStringVector(info)) {
|
||||
WLOGFE("Fail to write info");
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ ohos_fuzztest("WindowIPCFuzzTest") {
|
||||
]
|
||||
sources = [ "windowipc_fuzzer.cpp" ]
|
||||
deps = [
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/wm:libwm",
|
||||
]
|
||||
external_deps = [ "samgr_standard:samgr_proxy" ]
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <iremote_broker.h>
|
||||
#include <iservice_registry.h>
|
||||
#include <securec.h>
|
||||
#include <system_ability_definition.h>
|
||||
|
||||
#include "zidl/window_manager_proxy.h"
|
||||
@@ -33,8 +34,7 @@ size_t GetObject(T &object, const uint8_t *data, size_t size)
|
||||
if (objectSize > size) {
|
||||
return 0;
|
||||
}
|
||||
std::memcpy(&object, data, objectSize);
|
||||
return objectSize;
|
||||
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
|
||||
}
|
||||
|
||||
std::pair<sptr<IWindowManager>, sptr<IRemoteObject>> GetProxy()
|
||||
|
||||
@@ -25,7 +25,7 @@ ohos_fuzztest("WindowSceneFuzzTest") {
|
||||
"//foundation/windowmanager/wmserver/include",
|
||||
"//foundation/windowmanager/interfaces/innerkits/dm",
|
||||
"//foundation/windowmanager/interfaces/innerkits/wm",
|
||||
"//foundation/graphic/graphic/interfaces/innerkits/surface",
|
||||
"//foundation/graphic/graphic_2d/interfaces/innerkits/surface",
|
||||
"//utils/native/base/include",
|
||||
]
|
||||
cflags = [
|
||||
@@ -36,7 +36,7 @@ ohos_fuzztest("WindowSceneFuzzTest") {
|
||||
]
|
||||
sources = [ "windowscene_fuzzer.cpp" ]
|
||||
deps = [
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
"//foundation/windowmanager/wm:libwm",
|
||||
"//foundation/windowmanager/wmserver:libwms",
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "windowscene_fuzzer.h"
|
||||
|
||||
#include <securec.h>
|
||||
|
||||
#include "display_manager.h"
|
||||
#include "window.h"
|
||||
#include "window_manager.h"
|
||||
@@ -55,8 +59,7 @@ size_t GetObject(T &object, const uint8_t *data, size_t size)
|
||||
if (objectSize > size) {
|
||||
return 0;
|
||||
}
|
||||
std::memcpy(&object, data, objectSize);
|
||||
return objectSize;
|
||||
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
|
||||
}
|
||||
|
||||
size_t InitWindowOption1(WindowOption &windowOption, const uint8_t *data, size_t size)
|
||||
|
||||
@@ -255,7 +255,7 @@ ohos_static_library("wm_systemtest_common") {
|
||||
# need delete it for abilitycontext
|
||||
"${aafwk_inner_api_path}/ability_manager:ability_manager",
|
||||
"//foundation/arkui/napi:ace_napi",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
"//foundation/windowmanager/dmserver:libdms",
|
||||
|
||||
@@ -517,6 +517,38 @@ HWTEST_F(WindowImmersiveTest, OnAvoidAreaChangedTest02, Function | MediumTest |
|
||||
window->UnregisterAvoidAreaChangeListener(thisListener);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DockWindowTest01
|
||||
* @tc.desc: Add unexistavoid and remove this avoid. Test OnAvoidAreaChanged listener
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImmersiveTest, DockWindowTest01, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& dockWindow = utils::CreateDockWindow();
|
||||
ASSERT_EQ(WMError::WM_OK, dockWindow->Show());
|
||||
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
|
||||
usleep(WAIT_ASYNC_US);
|
||||
auto act = testSystemBarChangedListener_->tints_;
|
||||
for (SystemBarRegionTint tint : act) {
|
||||
if (tint.type_ == WindowType::WINDOW_TYPE_LAUNCHER_DOCK) {
|
||||
ASSERT_FALSE(tint.prop_.enable_);
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
usleep(WAIT_ASYNC_US);
|
||||
act = testSystemBarChangedListener_->tints_;
|
||||
for (SystemBarRegionTint tint : act) {
|
||||
if (tint.type_ == WindowType::WINDOW_TYPE_LAUNCHER_DOCK) {
|
||||
ASSERT_TRUE(tint.prop_.enable_);
|
||||
}
|
||||
}
|
||||
ASSERT_EQ(WMError::WM_OK, dockWindow->Destroy());
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -204,6 +204,61 @@ HWTEST_F(WindowSplitTest, SplitCreen04, Function | MediumTest | Level3)
|
||||
ASSERT_EQ(WMError::WM_OK, secWindow->Hide());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SplitCreen05
|
||||
* @tc.desc: forbid dock slive to move test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowSplitTest, SplitCreen05, Function | MediumTest | Level3)
|
||||
{
|
||||
fullInfo_.name = "fullscreen.5";
|
||||
splitInfo_.name = "primary.5";
|
||||
splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY;
|
||||
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
const sptr<Window>& priWindow = utils::CreateTestWindow(splitInfo_);
|
||||
activeWindows_.push_back(priWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, priWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, priWindow->GetMode());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, fullWindow->GetMode());
|
||||
|
||||
utils::TestWindowInfo dividerInfo;
|
||||
dividerInfo.name = "divider0";
|
||||
dividerInfo.type = WindowType::WINDOW_TYPE_DOCK_SLICE;
|
||||
dividerInfo.mode = WindowMode::WINDOW_MODE_FLOATING;
|
||||
dividerInfo.focusable_ = false;
|
||||
|
||||
const sptr<Window>& divider = utils::CreateTestWindow(dividerInfo);
|
||||
activeWindows_.push_back(divider);
|
||||
ASSERT_EQ(WMError::WM_OK, divider->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
Rect lastRect = divider->GetRect();
|
||||
WMError ret = divider->MoveTo(lastRect.posX_ + 10, lastRect.posY_ + 10);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
Rect rect = divider->GetRect();
|
||||
ASSERT_TRUE(lastRect.posX_ != rect.posX_ || lastRect.posY_ != rect.posY_);
|
||||
|
||||
ret = fullWindow->AddWindowFlag(WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
ret = divider->MoveTo(rect.posX_ + 10, rect.posY_ + 10);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
Rect NewRect = divider->GetRect();
|
||||
ASSERT_TRUE(rect.posX_ == NewRect.posX_ && rect.posY_ == NewRect.posY_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, priWindow->Hide());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -28,6 +28,7 @@ Rect WindowTestUtils::statusBarRect_ = {0, 0, 0, 0};
|
||||
Rect WindowTestUtils::naviBarRect_ = {0, 0, 0, 0};
|
||||
Rect WindowTestUtils::customAppRect_ = {0, 0, 0, 0};
|
||||
Rect WindowTestUtils::limitDisplayRect_ = {0, 0, 0, 0};
|
||||
Rect WindowTestUtils::dockWindowRect_ = {0, 0, 0, 0};
|
||||
SplitRects WindowTestUtils::splitRects_ = {
|
||||
.primaryRect = {0, 0, 0, 0},
|
||||
.secondaryRect = {0, 0, 0, 0},
|
||||
@@ -60,10 +61,29 @@ sptr<Window> WindowTestUtils::CreateTestWindow(const TestWindowInfo& info)
|
||||
} else {
|
||||
option->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_PARENT_LIMIT);
|
||||
}
|
||||
if (info.forbidSplitMove) {
|
||||
option->AddWindowFlag(WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE);
|
||||
} else {
|
||||
option->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE);
|
||||
}
|
||||
sptr<Window> window = Window::Create(info.name, option);
|
||||
return window;
|
||||
}
|
||||
|
||||
sptr<Window> WindowTestUtils::CreateDockWindow()
|
||||
{
|
||||
TestWindowInfo info = {
|
||||
.name = "dockWindow",
|
||||
.rect = dockWindowRect_,
|
||||
.type = WindowType::WINDOW_TYPE_LAUNCHER_DOCK,
|
||||
.mode = WindowMode::WINDOW_MODE_FLOATING,
|
||||
.needAvoid = false,
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
return CreateTestWindow(info);
|
||||
}
|
||||
|
||||
sptr<Window> WindowTestUtils::CreateStatusBarWindow()
|
||||
{
|
||||
TestWindowInfo info = {
|
||||
@@ -188,6 +208,7 @@ void WindowTestUtils::InitByDisplayRect(const Rect& displayRect)
|
||||
}
|
||||
statusBarRect_ = {0, 0, displayRect_.width_, displayRect_.height_ * barRatio};
|
||||
naviBarRect_ = {0, displayRect_.height_ * (1 - barRatio), displayRect_.width_, displayRect_.height_ * barRatio};
|
||||
dockWindowRect_ = {0, displayRect_.height_ * (1 - barRatio), displayRect_.width_, displayRect_.height_ * barRatio};
|
||||
customAppRect_ = {
|
||||
displayRect_.width_ * spaceRation,
|
||||
displayRect_.height_ * spaceRation,
|
||||
|
||||
@@ -40,6 +40,7 @@ public:
|
||||
WindowMode mode;
|
||||
bool needAvoid;
|
||||
bool parentLimit;
|
||||
bool forbidSplitMove {false};
|
||||
std::string parentName;
|
||||
bool focusable_ { true };
|
||||
Orientation orientation_ { Orientation::UNSPECIFIED };
|
||||
@@ -50,6 +51,7 @@ public:
|
||||
static Rect naviBarRect_;
|
||||
static Rect customAppRect_;
|
||||
static Rect customAppDecoRect_;
|
||||
static Rect dockWindowRect_;
|
||||
static SplitRects splitRects_;
|
||||
static bool isVerticalDisplay_;
|
||||
static Rect singleTileRect_;
|
||||
@@ -60,6 +62,7 @@ public:
|
||||
static sptr<Window> CreateTestWindow(const TestWindowInfo& info);
|
||||
static sptr<Window> CreateStatusBarWindow();
|
||||
static sptr<Window> CreateNavigationBarWindow();
|
||||
static sptr<Window> CreateDockWindow();
|
||||
static sptr<WindowScene> CreateWindowScene();
|
||||
static bool RectEqualTo(const sptr<Window>& window, const Rect& r);
|
||||
static bool InitSplitRects();
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
|
||||
// gtest
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
|
||||
#include "display_manager.h"
|
||||
#include "wm_common.h"
|
||||
#include "window_manager.h"
|
||||
#include "window_test_utils.h"
|
||||
@@ -29,23 +36,54 @@ namespace {
|
||||
}
|
||||
|
||||
using utils = WindowTestUtils;
|
||||
constexpr int WAIT_ASYNC_US = 200000; // 200ms
|
||||
constexpr int WAIT_ASYNC_MS_TIME_OUT = 1500; // 1500ms
|
||||
|
||||
#define CHECK_DISPLAY_POWER_STATE_RETURN() \
|
||||
do { \
|
||||
if (!displayPowerEventListener_->isDisplayPowerValid.load()) { \
|
||||
WLOGFE("isDisplayPowerValid false!"); \
|
||||
goto end; \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
class VisibilityChangedListenerImpl : public IVisibilityChangedListener {
|
||||
public:
|
||||
VisibilityChangedListenerImpl(std::mutex& mutex, std::condition_variable& cv) : mutex_(mutex), cv_(cv) {}
|
||||
void OnWindowVisibilityChanged(const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfo) override;
|
||||
std::vector<sptr<WindowVisibilityInfo>> windowVisibilityInfos_;
|
||||
bool isCallbackCalled_ { false };
|
||||
private:
|
||||
std::mutex& mutex_;
|
||||
std::condition_variable& cv_;
|
||||
};
|
||||
|
||||
class DisplayPowerEventListenerImpl : public IDisplayPowerEventListener {
|
||||
public:
|
||||
DisplayPowerEventListenerImpl()
|
||||
{
|
||||
auto displayId = DisplayManager::GetInstance().GetDefaultDisplayId();
|
||||
auto state = DisplayManager::GetInstance().GetDisplayState(displayId);
|
||||
isDisplayPowerValid = state == DisplayState::ON;
|
||||
}
|
||||
void OnDisplayPowerEvent(DisplayPowerEvent event, EventStatus status) override
|
||||
{
|
||||
isDisplayPowerValid.store(false);
|
||||
}
|
||||
std::atomic_bool isDisplayPowerValid;
|
||||
};
|
||||
|
||||
void VisibilityChangedListenerImpl::OnWindowVisibilityChanged(
|
||||
const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfo)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
isCallbackCalled_ = true;
|
||||
WLOGFI("size:%{public}zu", windowVisibilityInfo.size());
|
||||
windowVisibilityInfos_ = std::move(windowVisibilityInfo);
|
||||
for (auto& info : windowVisibilityInfos_) {
|
||||
WLOGFI("windowId:%{public}u, covered:%{public}d, pid:%{public}d, uid:%{public}d", info->windowId_,
|
||||
info->isVisible_, info->pid_, info->uid_);
|
||||
}
|
||||
cv_.notify_all();
|
||||
}
|
||||
|
||||
class WindowVisibilityInfoTest : public testing::Test {
|
||||
@@ -58,7 +96,20 @@ public:
|
||||
|
||||
virtual void TearDown() override;
|
||||
|
||||
static inline sptr<VisibilityChangedListenerImpl> visibilityChangedListener_ = new VisibilityChangedListenerImpl();
|
||||
static inline std::mutex mutex_;
|
||||
static inline std::condition_variable cv_;
|
||||
static inline sptr<VisibilityChangedListenerImpl> visibilityChangedListener_ =
|
||||
new VisibilityChangedListenerImpl(mutex_, cv_);
|
||||
static inline sptr<DisplayPowerEventListenerImpl> displayPowerEventListener_ =
|
||||
new DisplayPowerEventListenerImpl();
|
||||
|
||||
static inline void ResetCallbackCalledFLag()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
visibilityChangedListener_->isCallbackCalled_ = false;
|
||||
}
|
||||
|
||||
static void WaitForCallback();
|
||||
utils::TestWindowInfo fullScreenAppInfo_;
|
||||
utils::TestWindowInfo floatAppInfo_;
|
||||
utils::TestWindowInfo subAppInfo_;
|
||||
@@ -74,11 +125,13 @@ void WindowVisibilityInfoTest::SetUpTestCase()
|
||||
static_cast<uint32_t>(display->GetWidth()), static_cast<uint32_t>(display->GetHeight())};
|
||||
utils::InitByDisplayRect(displayRect);
|
||||
WindowManager::GetInstance().RegisterVisibilityChangedListener(visibilityChangedListener_);
|
||||
DisplayManager::GetInstance().RegisterDisplayPowerEventListener(displayPowerEventListener_);
|
||||
}
|
||||
|
||||
void WindowVisibilityInfoTest::TearDownTestCase()
|
||||
{
|
||||
WindowManager::GetInstance().UnregisterVisibilityChangedListener(visibilityChangedListener_);
|
||||
DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(displayPowerEventListener_);
|
||||
}
|
||||
|
||||
void WindowVisibilityInfoTest::SetUp()
|
||||
@@ -116,6 +169,16 @@ void WindowVisibilityInfoTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowVisibilityInfoTest::WaitForCallback()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
auto now = std::chrono::system_clock::now();
|
||||
if (!cv_.wait_until(lock, now + std::chrono::milliseconds(WAIT_ASYNC_MS_TIME_OUT),
|
||||
[]() { return visibilityChangedListener_->isCallbackCalled_; })) {
|
||||
WLOGFI("wait_until time out");
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: WindowVisibilityInfoTest01
|
||||
@@ -134,33 +197,48 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest01, Function | Medium
|
||||
sptr<Window> subWindow1 = utils::CreateTestWindow(subAppInfo_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
WaitForCallback();
|
||||
CHECK_DISPLAY_POWER_STATE_RETURN();
|
||||
ASSERT_EQ(1, visibilityChangedListener_->windowVisibilityInfos_.size());
|
||||
ResetCallbackCalledFLag();
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, subWindow1->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
WaitForCallback();
|
||||
CHECK_DISPLAY_POWER_STATE_RETURN();
|
||||
ASSERT_EQ(1, visibilityChangedListener_->windowVisibilityInfos_.size());
|
||||
ResetCallbackCalledFLag();
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Hide());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
WaitForCallback();
|
||||
CHECK_DISPLAY_POWER_STATE_RETURN();
|
||||
ASSERT_EQ(2, visibilityChangedListener_->windowVisibilityInfos_.size());
|
||||
ResetCallbackCalledFLag();
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
WaitForCallback();
|
||||
CHECK_DISPLAY_POWER_STATE_RETURN();
|
||||
ASSERT_EQ(2, visibilityChangedListener_->windowVisibilityInfos_.size());
|
||||
ResetCallbackCalledFLag();
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, subWindow1->Hide());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
WaitForCallback();
|
||||
CHECK_DISPLAY_POWER_STATE_RETURN();
|
||||
ASSERT_EQ(1, visibilityChangedListener_->windowVisibilityInfos_.size());
|
||||
ResetCallbackCalledFLag();
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Hide());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
WaitForCallback();
|
||||
CHECK_DISPLAY_POWER_STATE_RETURN();
|
||||
ASSERT_EQ(1, visibilityChangedListener_->windowVisibilityInfos_.size());
|
||||
ResetCallbackCalledFLag();
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
WaitForCallback();
|
||||
CHECK_DISPLAY_POWER_STATE_RETURN();
|
||||
ASSERT_EQ(1, visibilityChangedListener_->windowVisibilityInfos_.size());
|
||||
ResetCallbackCalledFLag();
|
||||
|
||||
end:
|
||||
window1->Destroy();
|
||||
subWindow1->Destroy();
|
||||
}
|
||||
@@ -179,13 +257,18 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest02, Function | Medium
|
||||
sptr<Window> window2 = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
WaitForCallback();
|
||||
CHECK_DISPLAY_POWER_STATE_RETURN();
|
||||
ASSERT_EQ(2, visibilityChangedListener_->windowVisibilityInfos_.size());
|
||||
ResetCallbackCalledFLag();
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window2->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
WaitForCallback();
|
||||
CHECK_DISPLAY_POWER_STATE_RETURN();
|
||||
ASSERT_EQ(2, visibilityChangedListener_->windowVisibilityInfos_.size());
|
||||
ResetCallbackCalledFLag();
|
||||
|
||||
end:
|
||||
window1->Destroy();
|
||||
window2->Destroy();
|
||||
}
|
||||
@@ -207,7 +290,6 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest03, Function | Medium
|
||||
sptr<Window> subWindow1 = utils::CreateTestWindow(subAppInfo_);
|
||||
|
||||
floatAppInfo_.name = "window2";
|
||||
floatAppInfo_.rect = {50, 150, 240, 426};
|
||||
sptr<Window> window2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
|
||||
subAppInfo_.name = "subWindow2";
|
||||
@@ -216,21 +298,30 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest03, Function | Medium
|
||||
sptr<Window> subWindow2 = utils::CreateTestWindow(subAppInfo_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window2->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
WaitForCallback();
|
||||
CHECK_DISPLAY_POWER_STATE_RETURN();
|
||||
ASSERT_EQ(1, visibilityChangedListener_->windowVisibilityInfos_.size());
|
||||
ResetCallbackCalledFLag();
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, subWindow2->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
WaitForCallback();
|
||||
CHECK_DISPLAY_POWER_STATE_RETURN();
|
||||
ASSERT_EQ(1, visibilityChangedListener_->windowVisibilityInfos_.size());
|
||||
ResetCallbackCalledFLag();
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
WaitForCallback();
|
||||
CHECK_DISPLAY_POWER_STATE_RETURN();
|
||||
ASSERT_EQ(2, visibilityChangedListener_->windowVisibilityInfos_.size());
|
||||
ResetCallbackCalledFLag();
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, subWindow1->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
WaitForCallback();
|
||||
CHECK_DISPLAY_POWER_STATE_RETURN();
|
||||
ASSERT_EQ(2, visibilityChangedListener_->windowVisibilityInfos_.size());
|
||||
ResetCallbackCalledFLag();
|
||||
|
||||
end:
|
||||
window1->Destroy();
|
||||
subWindow1->Destroy();
|
||||
window2->Destroy();
|
||||
|
||||
@@ -178,7 +178,7 @@ ohos_static_library("wm_unittest_common") {
|
||||
"//foundation/arkui/ace_engine/interfaces/inner_api/ace:ace_uicontent",
|
||||
"//foundation/arkui/napi:ace_napi",
|
||||
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
"//foundation/windowmanager/dmserver:libdms",
|
||||
|
||||
+4
-2
@@ -12,7 +12,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/graphic/graphic/graphic_config.gni")
|
||||
import("//foundation/graphic/graphic_2d/graphic_config.gni")
|
||||
|
||||
## Build libwms.so
|
||||
config("libwms_config") {
|
||||
@@ -70,6 +70,7 @@ ohos_shared_library("libwms") {
|
||||
"../wm/src/zidl/window_proxy.cpp",
|
||||
"src/avoid_area_controller.cpp",
|
||||
"src/display_group_controller.cpp",
|
||||
"src/display_group_info.cpp",
|
||||
"src/drag_controller.cpp",
|
||||
"src/freeze_controller.cpp",
|
||||
"src/input_window_monitor.cpp",
|
||||
@@ -92,6 +93,7 @@ ohos_shared_library("libwms") {
|
||||
"src/window_snapshot/snapshot_controller.cpp",
|
||||
"src/window_snapshot/snapshot_proxy.cpp",
|
||||
"src/window_snapshot/snapshot_stub.cpp",
|
||||
"src/window_task_looper.cpp",
|
||||
"src/window_zorder_policy.cpp",
|
||||
"src/zidl/window_manager_stub.cpp",
|
||||
]
|
||||
@@ -102,7 +104,7 @@ ohos_shared_library("libwms") {
|
||||
":window_divider_image",
|
||||
":window_manager_config",
|
||||
":window_starting_image",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
"//foundation/windowmanager/dmserver:libdms",
|
||||
"//foundation/windowmanager/utils:libwmutil",
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <refbase.h>
|
||||
|
||||
#include "avoid_area_controller.h"
|
||||
#include "display_group_info.h"
|
||||
#include "display_info.h"
|
||||
#include "display_manager_service_inner.h"
|
||||
#include "window_layout_policy.h"
|
||||
@@ -36,25 +37,24 @@ class WindowNodeContainer;
|
||||
class DisplayGroupController : public RefBase {
|
||||
public:
|
||||
DisplayGroupController(const sptr<WindowNodeContainer>& windowNodeContainer,
|
||||
std::map<DisplayId, Rect>& displayRectMap, std::map<DisplayId, sptr<DisplayInfo>>& displayInfosMap)
|
||||
: windowNodeContainer_(windowNodeContainer), displayRectMap_(displayRectMap),
|
||||
displayInfosMap_(displayInfosMap) {}
|
||||
const sptr<DisplayGroupInfo>& displayGroupInfo)
|
||||
: windowNodeContainer_(windowNodeContainer), displayGroupInfo_(displayGroupInfo) {}
|
||||
~DisplayGroupController() = default;
|
||||
|
||||
void InitNewDisplay(DisplayId displayId);
|
||||
void UpdateWindowNodeMaps();
|
||||
void UpdateDisplayGroupWindowTree();
|
||||
void PreProcessWindowNode(const sptr<WindowNode>& node, WindowUpdateType type);
|
||||
void ProcessDisplayCreate(DisplayId displayId,
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap);
|
||||
const std::map<DisplayId, Rect>& displayRectMap);
|
||||
void ProcessDisplayDestroy(DisplayId displayId,
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap,
|
||||
const std::map<DisplayId, Rect>& displayRectMap,
|
||||
std::vector<uint32_t>& windowIds);
|
||||
void ProcessDisplayChange(DisplayId displayId,
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap,
|
||||
const std::map<DisplayId, Rect>& displayRectMap,
|
||||
DisplayStateChangeType type);
|
||||
sptr<WindowPair> GetWindowPairByDisplayId(DisplayId displayId);
|
||||
|
||||
WindowNodeMaps windowNodeMaps_;
|
||||
DisplayGroupWindowTree displayGroupWindowTree_;
|
||||
std::map<DisplayId, SysBarNodeMap> sysBarNodeMaps_;
|
||||
std::map<DisplayId, SysBarTintMap> sysBarTintMaps_;
|
||||
|
||||
@@ -63,7 +63,7 @@ private:
|
||||
void AddWindowNodeOnWindowTree(sptr<WindowNode>& node, WindowRootNodeType rootType);
|
||||
void ProcessNotCrossNodesOnDestroiedDisplay(DisplayId displayId, std::vector<uint32_t>& windowIds);
|
||||
void ProcessDisplaySizeChangeOrRotation(DisplayId displayId,
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type);
|
||||
const std::map<DisplayId, Rect>& displayRectMap, DisplayStateChangeType type);
|
||||
void ProcessCrossNodes(DisplayStateChangeType type);
|
||||
void MoveCrossNodeToTargetDisplay(const sptr<WindowNode>& node, DisplayId targetDisplayId);
|
||||
void MoveNotCrossNodeToDefaultDisplay(const sptr<WindowNode>& node, DisplayId displayId);
|
||||
@@ -73,15 +73,11 @@ private:
|
||||
void UpdateWindowDisplayId(const sptr<WindowNode>& node, DisplayId newDisplayId);
|
||||
void ClearMapOfDestroiedDisplay(DisplayId displayId);
|
||||
void ChangeToRectInDisplayGroup(const sptr<WindowNode>& node);
|
||||
void FindMaxAndMinPosXDisplay();
|
||||
|
||||
sptr<WindowNodeContainer> windowNodeContainer_;
|
||||
std::map<DisplayId, Rect>& displayRectMap_;
|
||||
std::map<DisplayId, sptr<DisplayInfo>>& displayInfosMap_;
|
||||
sptr<DisplayGroupInfo> displayGroupInfo_;
|
||||
std::map<DisplayId, sptr<WindowPair>> windowPairMap_;
|
||||
DisplayId defaultDisplayId_ { 0 };
|
||||
DisplayId maxPosXDisplay_ { 0 };
|
||||
DisplayId minPosXDisplay_ { 0 };
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ROSEN_DISPLAY_GROUP_INFO_H
|
||||
#define OHOS_ROSEN_DISPLAY_GROUP_INFO_H
|
||||
|
||||
#include <map>
|
||||
#include <refbase.h>
|
||||
|
||||
#include "display_info.h"
|
||||
#include "wm_common.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class DisplayGroupInfo : public RefBase {
|
||||
public:
|
||||
DisplayGroupInfo(ScreenId displayGroupId, const sptr<DisplayInfo>& displayInfo);
|
||||
~DisplayGroupInfo() = default;
|
||||
void AddDisplayInfo(const sptr<DisplayInfo>& displayInfo);
|
||||
void RemoveDisplayInfo(DisplayId displayId);
|
||||
void UpdateLeftAndRightDisplayId();
|
||||
|
||||
void SetDisplayRotation(DisplayId displayId, Rotation rotation);
|
||||
void SetDisplayVirtualPixelRatio(DisplayId displayId, float vpr);
|
||||
void SetDisplayRect(DisplayId displayId, Rect displayRect);
|
||||
|
||||
Rotation GetDisplayRotation(DisplayId displayId) const;
|
||||
float GetDisplayVirtualPixelRatio(DisplayId displayId) const;
|
||||
std::map<DisplayId, Rect> GetAllDisplayRects() const;
|
||||
Rect GetDisplayRect(DisplayId displayId) const;
|
||||
sptr<DisplayInfo> GetDisplayInfo(DisplayId displayId) const;
|
||||
DisplayId GetLeftDisplayId() const;
|
||||
DisplayId GetRightDisplayId() const;
|
||||
|
||||
private:
|
||||
ScreenId displayGroupId_;
|
||||
DisplayId leftDisplayId_ { 0 };
|
||||
DisplayId rightDisplayId_ { 0 };
|
||||
mutable std::map<DisplayId, sptr<DisplayInfo>> displayInfosMap_;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ROSEN_DISPLAY_GROUP_INFO_H
|
||||
|
||||
@@ -51,7 +51,7 @@ private:
|
||||
reason == MinimizeReason::MAX_APP_COUNT || reason == MinimizeReason::LAYOUT_TILE);
|
||||
}
|
||||
|
||||
static std::map<MinimizeReason, std::vector<sptr<WindowNode>>> needMinimizeAppNodes_;
|
||||
static std::map<MinimizeReason, std::vector<wptr<WindowNode>>> needMinimizeAppNodes_;
|
||||
static bool isMinimizedByOtherWindow_;
|
||||
static std::recursive_mutex mutex_;
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
|
||||
static sptr<WindowNode> CreateWindowNode(sptr<WindowTransitionInfo> info, uint32_t winId);
|
||||
static void HandleClientWindowCreate(sptr<WindowNode>& node, sptr<IWindow>& window,
|
||||
uint32_t& windowId, const std::shared_ptr<RSSurfaceNode>& surfaceNode);
|
||||
uint32_t& windowId, const std::shared_ptr<RSSurfaceNode>& surfaceNode, sptr<WindowProperty>& property);
|
||||
static void DrawStartingWindow(sptr<WindowNode>& node, sptr<Media::PixelMap> pixelMap, uint32_t bkgColor,
|
||||
bool isColdStart);
|
||||
static void UpdateRSTree(sptr<WindowNode>& node);
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
WMError ProcessPointDown(uint32_t windowId, bool isStartDrag);
|
||||
WMError ProcessPointUp(uint32_t windowId);
|
||||
void MinimizeAllAppWindows(DisplayId displayId);
|
||||
void ToggleShownStateForAllAppWindows();
|
||||
WMError ToggleShownStateForAllAppWindows();
|
||||
WMError MaxmizeWindow(uint32_t windowId);
|
||||
WMError SetWindowLayoutMode(WindowLayoutMode mode);
|
||||
WMError UpdateProperty(sptr<WindowProperty>& property, PropertyChangeAction action);
|
||||
@@ -75,7 +75,8 @@ private:
|
||||
void ReSizeSystemBarPropertySizeIfNeed(sptr<WindowNode> node);
|
||||
void HandleTurnScreenOn(const sptr<WindowNode>& node);
|
||||
void ProcessSystemBarChange(const sptr<DisplayInfo>& displayInfo);
|
||||
|
||||
void NotifyOutsidePressed(const sptr<WindowNode>& node);
|
||||
uint32_t GetEmbedNodeId(const std::vector<sptr<WindowNode>>& windowNodes, const sptr<WindowNode>& node);
|
||||
sptr<WindowRoot> windowRoot_;
|
||||
sptr<InputWindowMonitor> inputWindowMonitor_;
|
||||
std::atomic<uint32_t> windowId_ { INVALID_WINDOW_ID };
|
||||
|
||||
@@ -23,22 +23,26 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
enum DumpType : uint32_t {
|
||||
DUMP_ALL = 0,
|
||||
|
||||
DUMP_WINDOW,
|
||||
DUMP_NONE = 100,
|
||||
};
|
||||
class WindowDumper : public RefBase {
|
||||
public:
|
||||
WindowDumper(const sptr<WindowRoot>& root, std::recursive_mutex& mutex) : windowRoot_(root), mutex_(mutex) {}
|
||||
WindowDumper(const sptr<WindowRoot>& root) : windowRoot_(root) {}
|
||||
WMError Dump(int fd, const std::vector<std::u16string>& args) const;
|
||||
|
||||
private:
|
||||
WMError DumpWindowInfo(const std::vector<std::string>& args, std::string& dumpInfo) const;
|
||||
WMError DumpAllWindowInfo(std::string& dumpInfo) const;
|
||||
WMError DumpDisplayWindowInfo(DisplayId displayId, std::string& dumpInfo) const;
|
||||
WMError DumpScreenGroupWindowInfo(ScreenId screenGroupId, const sptr<WindowNodeContainer>& windowNodeContainer,
|
||||
std::string& dumpInfo) const;
|
||||
bool IsValidDigitString(const std::string& windowIdStr) const;
|
||||
WMError DumpSpecifiedWindowInfo(uint32_t windowId, const std::vector<std::string>& params,
|
||||
std::string& dumpInfo) const;
|
||||
void ShowHelpInfo(std::string& dumpInfo) const;
|
||||
void ShowIllegalArgsInfo(std::string& dumpInfo) const;
|
||||
void ShowAceDumpHelp(std::string& dumpInfo) const;
|
||||
void ShowIllegalArgsInfo(std::string& dumpInfo, WMError errCode) const;
|
||||
const sptr<WindowRoot> windowRoot_;
|
||||
std::recursive_mutex& mutex_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <refbase.h>
|
||||
#include <set>
|
||||
|
||||
#include "display_group_info.h"
|
||||
#include "display_info.h"
|
||||
#include "window_node.h"
|
||||
#include "wm_common.h"
|
||||
@@ -27,13 +28,19 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using WindowNodeMaps = std::map<DisplayId,
|
||||
using DisplayGroupWindowTree = std::map<DisplayId,
|
||||
std::map<WindowRootNodeType, std::unique_ptr<std::vector<sptr<WindowNode>>>>>;
|
||||
enum class DockWindowShowState : uint32_t {
|
||||
NOT_SHOWN = 0,
|
||||
SHOWN_IN_BOTTOM = 1,
|
||||
SHOWN_IN_LEFT = 2,
|
||||
SHOWN_IN_RIGHT = 3,
|
||||
SHOWN_IN_TOP = 4,
|
||||
};
|
||||
class WindowLayoutPolicy : public RefBase {
|
||||
public:
|
||||
WindowLayoutPolicy() = delete;
|
||||
WindowLayoutPolicy(const std::map<DisplayId, Rect>& displayRectMap, WindowNodeMaps& windowNodeMaps,
|
||||
std::map<DisplayId, sptr<DisplayInfo>>& displayInfosMap);
|
||||
WindowLayoutPolicy(const sptr<DisplayGroupInfo>& displayGroupInfo, DisplayGroupWindowTree& displayGroupWindowTree);
|
||||
~WindowLayoutPolicy() = default;
|
||||
virtual void Launch();
|
||||
virtual void Clean();
|
||||
@@ -44,6 +51,7 @@ public:
|
||||
virtual void RemoveWindowNode(const sptr<WindowNode>& node);
|
||||
virtual void UpdateWindowNode(const sptr<WindowNode>& node, bool isAddWindow = false);
|
||||
virtual void UpdateLayoutRect(const sptr<WindowNode>& node) = 0;
|
||||
virtual void SetSplitDividerWindowRects(std::map<DisplayId, Rect> dividerWindowRects) {};
|
||||
float GetVirtualPixelRatio(DisplayId displayId) const;
|
||||
void UpdateClientRectAndResetReason(const sptr<WindowNode>& node, const Rect& lastLayoutRect, const Rect& winRect);
|
||||
Rect GetDisplayGroupRect() const;
|
||||
@@ -59,6 +67,7 @@ protected:
|
||||
AvoidPosType GetAvoidPosType(const Rect& rect, DisplayId displayId) const;
|
||||
void CalcAndSetNodeHotZone(Rect layoutOutRect, const sptr<WindowNode>& node) const;
|
||||
void LimitFloatingWindowSize(const sptr<WindowNode>& node, const Rect& displayRect, Rect& winRect) const;
|
||||
void LimitMainFloatingWindowPositionWithDrag(const sptr<WindowNode>& node, Rect& winRect) const;
|
||||
void LimitMainFloatingWindowPosition(const sptr<WindowNode>& node, Rect& winRect) const;
|
||||
void ComputeDecoratedRequestRect(const sptr<WindowNode>& node) const;
|
||||
bool IsVerticalDisplay(DisplayId displayId) const;
|
||||
@@ -66,25 +75,26 @@ protected:
|
||||
void LayoutWindowNodesByRootType(const std::vector<sptr<WindowNode>>& nodeVec);
|
||||
void UpdateSurfaceBounds(const sptr<WindowNode>& node, const Rect& winRect);
|
||||
void UpdateRectInDisplayGroupForAllNodes(DisplayId displayId,
|
||||
const Rect& srcDisplayRect,
|
||||
const Rect& dstDisplayRect);
|
||||
const Rect& oriDisplayRect,
|
||||
const Rect& newDisplayRect);
|
||||
void UpdateRectInDisplayGroup(const sptr<WindowNode>& node,
|
||||
const Rect& srcDisplayRect,
|
||||
const Rect& dstDisplayRect);
|
||||
const Rect& oriDisplayRect,
|
||||
const Rect& newDisplayRect);
|
||||
void LimitWindowToBottomRightCorner(const sptr<WindowNode>& node);
|
||||
void UpdateDisplayGroupRect();
|
||||
void UpdateDisplayGroupLimitRect_();
|
||||
void UpdateMultiDisplayFlag();
|
||||
void PostProcessWhenDisplayChange();
|
||||
void UpdateDisplayRectAndDisplayGroupInfo(const std::map<DisplayId, Rect>& displayRectMap);
|
||||
DockWindowShowState GetDockWindowShowState(DisplayId displayId, Rect& dockWinRect) const;
|
||||
|
||||
const std::set<WindowType> avoidTypes_ {
|
||||
WindowType::WINDOW_TYPE_STATUS_BAR,
|
||||
WindowType::WINDOW_TYPE_NAVIGATION_BAR,
|
||||
};
|
||||
mutable std::map<DisplayId, Rect> displayRectMap_;
|
||||
sptr<DisplayGroupInfo> displayGroupInfo_;
|
||||
mutable std::map<DisplayId, Rect> limitRectMap_;
|
||||
WindowNodeMaps& windowNodeMaps_;
|
||||
std::map<DisplayId, sptr<DisplayInfo>>& displayInfosMap_;
|
||||
DisplayGroupWindowTree& displayGroupWindowTree_;
|
||||
Rect displayGroupRect_;
|
||||
Rect displayGroupLimitRect_;
|
||||
bool isMultiDisplay_ = false;
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace Rosen {
|
||||
class WindowLayoutPolicyCascade : public WindowLayoutPolicy {
|
||||
public:
|
||||
WindowLayoutPolicyCascade() = delete;
|
||||
WindowLayoutPolicyCascade(const std::map<DisplayId, Rect>& displayRectMap,
|
||||
WindowNodeMaps& windowNodeMaps, std::map<DisplayId, sptr<DisplayInfo>>& displayInfosMap);
|
||||
WindowLayoutPolicyCascade(const sptr<DisplayGroupInfo>& displayGroupInfo,
|
||||
DisplayGroupWindowTree& displayGroupWindowTree);
|
||||
~WindowLayoutPolicyCascade() = default;
|
||||
void Launch() override;
|
||||
void Clean() override;
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
void AddWindowNode(const sptr<WindowNode>& node) override;
|
||||
void UpdateWindowNode(const sptr<WindowNode>& node, bool isAddWindow = false) override;
|
||||
void UpdateLayoutRect(const sptr<WindowNode>& node) override;
|
||||
void SetSplitDividerWindowRects(std::map<DisplayId, Rect> dividerWindowRects) override;
|
||||
void RemoveWindowNode(const sptr<WindowNode>& node) override;
|
||||
|
||||
private:
|
||||
@@ -70,6 +71,7 @@ private:
|
||||
Rect firstCascadeRect_;
|
||||
};
|
||||
mutable std::map<DisplayId, CascadeRects> cascadeRectsMap_;
|
||||
std::map<DisplayId, Rect> restoringDividerWindowRects_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace Rosen {
|
||||
class WindowLayoutPolicyTile : public WindowLayoutPolicy {
|
||||
public:
|
||||
WindowLayoutPolicyTile() = delete;
|
||||
WindowLayoutPolicyTile(const std::map<DisplayId, Rect>& displayRectMap, WindowNodeMaps& windowNodeMaps,
|
||||
std::map<DisplayId, sptr<DisplayInfo>>& displayInfosMap);
|
||||
WindowLayoutPolicyTile(const sptr<DisplayGroupInfo>& displayGroupInfo,
|
||||
DisplayGroupWindowTree& displayGroupWindowTree);
|
||||
~WindowLayoutPolicyTile() = default;
|
||||
void Launch() override;
|
||||
void AddWindowNode(const sptr<WindowNode>& node) override;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "zidl/window_manager_stub.h"
|
||||
#include "window_dumper.h"
|
||||
#include "window_root.h"
|
||||
#include "window_task_looper.h"
|
||||
#include "snapshot_controller.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -78,7 +79,7 @@ public:
|
||||
void ProcessPointUp(uint32_t windowId) override;
|
||||
WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) override;
|
||||
void MinimizeAllAppWindows(DisplayId displayId) override;
|
||||
void ToggleShownStateForAllAppWindows() override;
|
||||
WMError ToggleShownStateForAllAppWindows() override;
|
||||
WMError MaxmizeWindow(uint32_t windowId) override;
|
||||
WMError SetWindowLayoutMode(WindowLayoutMode mode) override;
|
||||
WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action) override;
|
||||
@@ -103,13 +104,12 @@ private:
|
||||
bool Init();
|
||||
void RegisterSnapshotHandler();
|
||||
void RegisterWindowManagerServiceHandler();
|
||||
void OnWindowEvent(Event event, uint32_t windowId);
|
||||
void OnWindowEvent(Event event, const sptr<IRemoteObject>& remoteObject);
|
||||
void NotifyDisplayStateChange(DisplayId id, DisplayStateChangeType type);
|
||||
WMError GetFocusWindowInfo(sptr<IRemoteObject>& abilityToken);
|
||||
void ConfigureWindowManagerService();
|
||||
|
||||
static inline SingletonDelegator<WindowManagerService> delegator;
|
||||
std::recursive_mutex mutex_;
|
||||
sptr<WindowRoot> windowRoot_;
|
||||
sptr<WindowController> windowController_;
|
||||
sptr<InputWindowMonitor> inputWindowMonitor_;
|
||||
@@ -120,6 +120,8 @@ private:
|
||||
sptr<WindowDumper> windowDumper_;
|
||||
SystemConfig systemConfig_;
|
||||
ModeChangeHotZonesConfig hotZonesConfig_ { false, 0, 0, 0 };
|
||||
std::unique_ptr<WindowTaskLooper> wmsTaskLooper_;
|
||||
bool startingOpen_ = true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,20 +31,14 @@ public:
|
||||
std::shared_ptr<RSSurfaceNode> surfaceNode)
|
||||
: surfaceNode_(surfaceNode), property_(property), windowToken_(window)
|
||||
{
|
||||
callingPid_ = IPCSkeleton::GetCallingPid();
|
||||
callingUid_ = IPCSkeleton::GetCallingUid();
|
||||
}
|
||||
WindowNode() : property_(new WindowProperty())
|
||||
{
|
||||
callingPid_ = IPCSkeleton::GetCallingPid();
|
||||
callingUid_ = IPCSkeleton::GetCallingUid();
|
||||
}
|
||||
explicit WindowNode(const sptr<WindowProperty>& property) : property_(property)
|
||||
{
|
||||
callingPid_ = IPCSkeleton::GetCallingPid();
|
||||
callingUid_ = IPCSkeleton::GetCallingUid();
|
||||
}
|
||||
~WindowNode() = default;
|
||||
~WindowNode();
|
||||
|
||||
void SetDisplayId(DisplayId displayId);
|
||||
void SetHotZoneRect(const Rect& rect);
|
||||
@@ -62,13 +56,14 @@ public:
|
||||
void SetTurnScreenOn(bool turnScreenOn);
|
||||
void SetKeepScreenOn(bool keepScreenOn);
|
||||
void SetCallingWindow(uint32_t windowId);
|
||||
void SetCallingPid();
|
||||
void SetCallingUid();
|
||||
void SetCallingPid(int32_t pid);
|
||||
void SetCallingUid(int32_t uid);
|
||||
void SetWindowToken(sptr<IWindow> window);
|
||||
uint32_t GetCallingWindow() const;
|
||||
void SetWindowSizeChangeReason(WindowSizeChangeReason reason);
|
||||
void SetRequestedOrientation(Orientation orientation);
|
||||
void SetShowingDisplays(const std::vector<DisplayId>& displayIdVec);
|
||||
void SetModeSupportInfo(uint32_t modeSupportInfo);
|
||||
const sptr<IWindow>& GetWindowToken() const;
|
||||
uint32_t GetWindowId() const;
|
||||
uint32_t GetParentId() const;
|
||||
@@ -94,6 +89,7 @@ public:
|
||||
WindowSizeChangeReason GetWindowSizeChangeReason() const;
|
||||
Orientation GetRequestedOrientation() const;
|
||||
std::vector<DisplayId> GetShowingDisplays() const;
|
||||
uint32_t GetModeSupportInfo() const;
|
||||
void ResetWindowSizeChangeReason();
|
||||
|
||||
sptr<WindowNode> parent_;
|
||||
@@ -117,8 +113,6 @@ private:
|
||||
sptr<WindowProperty> property_ = nullptr;
|
||||
sptr<IWindow> windowToken_ = nullptr;
|
||||
Rect hotZoneRect_ { 0, 0, 0, 0 };
|
||||
int32_t callingPid_;
|
||||
int32_t callingUid_;
|
||||
WindowSizeChangeReason windowSizeChangeReason_ {WindowSizeChangeReason::UNDEFINED};
|
||||
};
|
||||
} // Rosen
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "display_info.h"
|
||||
#include "minimize_app.h"
|
||||
#include "display_group_controller.h"
|
||||
#include "display_group_info.h"
|
||||
#include "window_layout_policy.h"
|
||||
#include "window_manager.h"
|
||||
#include "window_node.h"
|
||||
@@ -34,11 +35,12 @@ namespace Rosen {
|
||||
using WindowNodeOperationFunc = std::function<bool(sptr<WindowNode>)>; // return true indicates to stop traverse
|
||||
class WindowNodeContainer : public RefBase {
|
||||
public:
|
||||
WindowNodeContainer(const sptr<DisplayInfo>& displayInfo);
|
||||
WindowNodeContainer(const sptr<DisplayInfo>& displayInfo, ScreenId displayGroupId);
|
||||
~WindowNodeContainer();
|
||||
WMError ShowStartingWindow(sptr<WindowNode>& node);
|
||||
WMError AddWindowNode(sptr<WindowNode>& node, sptr<WindowNode>& parentNode);
|
||||
WMError RemoveWindowNode(sptr<WindowNode>& node);
|
||||
WMError HandleRemoveWindow(sptr<WindowNode>& node);
|
||||
WMError UpdateWindowNode(sptr<WindowNode>& node, WindowUpdateReason reason);
|
||||
WMError DestroyWindowNode(sptr<WindowNode>& node, std::vector<uint32_t>& windowIds);
|
||||
const std::vector<uint32_t>& Destroy();
|
||||
@@ -62,6 +64,7 @@ public:
|
||||
std::unordered_map<WindowType, SystemBarProperty> GetExpectImmersiveProperty() const;
|
||||
void NotifyAccessibilityWindowInfo(const sptr<WindowNode>& windowId, WindowUpdateType type) const;
|
||||
int GetWindowCountByType(WindowType windowType);
|
||||
bool IsForbidDockSliceMove(DisplayId displayId) const;
|
||||
|
||||
void OnAvoidAreaChange(const std::vector<Rect>& avoidAreas, DisplayId displayId);
|
||||
bool isVerticalDisplay(DisplayId displayId) const;
|
||||
@@ -70,7 +73,8 @@ public:
|
||||
sptr<WindowNode> GetNextActiveWindow(uint32_t windowId) const;
|
||||
void MinimizeAllAppWindows(DisplayId displayId);
|
||||
void MinimizeOldestAppWindow();
|
||||
void ToggleShownStateForAllAppWindows(std::function<bool(uint32_t)> restoreFunc, bool restore);
|
||||
void ToggleShownStateForAllAppWindows(std::function<bool(uint32_t, WindowMode)> restoreFunc, bool restore);
|
||||
void RestoreAllAppWindows(std::function<bool(uint32_t, WindowMode)> restoreFunc);
|
||||
bool IsAppWindowsEmpty() const;
|
||||
void ProcessWindowStateChange(WindowState state, WindowStateChangeReason reason);
|
||||
void NotifySystemBarTints(std::vector<DisplayId> displayIdVec);
|
||||
@@ -98,6 +102,7 @@ public:
|
||||
sptr<AvoidAreaController> GetAvoidController() const;
|
||||
sptr<DisplayGroupController> GetMutiDisplayController() const;
|
||||
sptr<WindowNode> GetRootNode(WindowRootNodeType type) const;
|
||||
void NotifyDockWindowStateChanged(sptr<WindowNode>& node, bool isEnable);
|
||||
|
||||
private:
|
||||
void TraverseWindowNode(sptr<WindowNode>& root, std::vector<sptr<WindowNode>>& windowNodes) const;
|
||||
@@ -129,8 +134,9 @@ private:
|
||||
static bool ReadIsWindowAnimationEnabledProperty();
|
||||
void DumpScreenWindowTree();
|
||||
void RaiseInputMethodWindowPriorityIfNeeded(const sptr<WindowNode>& node) const;
|
||||
void ReZOrderShowWhenLockedWindowIfNeeded(const sptr<WindowNode>& node);
|
||||
void RaiseShowWhenLockedWindowIfNeeded(const sptr<WindowNode>& node);
|
||||
void ReZOrderShowWhenLockedWindows(const sptr<WindowNode>& node, bool up);
|
||||
void ReZOrderShowWhenLockedWindows(bool up);
|
||||
|
||||
WMError AddWindowNodeOnWindowTree(sptr<WindowNode>& node, const sptr<WindowNode>& parentNode);
|
||||
void RemoveWindowNodeFromWindowTree(sptr<WindowNode>& node);
|
||||
@@ -143,8 +149,11 @@ private:
|
||||
uint32_t zOrder_ { 0 };
|
||||
uint32_t focusedWindow_ { INVALID_WINDOW_ID };
|
||||
uint32_t activeWindow_ = INVALID_WINDOW_ID;
|
||||
bool isScreenLocked_ = false;
|
||||
|
||||
std::vector<uint32_t> backupWindowIds_;
|
||||
std::map<uint32_t, WindowMode> backupWindowMode_;
|
||||
std::map<DisplayId, Rect> backupDividerWindowRect_;
|
||||
sptr<WindowZorderPolicy> zorderPolicy_ = new WindowZorderPolicy();
|
||||
std::unordered_map<WindowLayoutMode, sptr<WindowLayoutPolicy>> layoutPolicys_;
|
||||
WindowLayoutMode layoutMode_ = WindowLayoutMode::CASCADE;
|
||||
@@ -157,9 +166,7 @@ private:
|
||||
sptr<WindowLayoutPolicy> layoutPolicy_;
|
||||
sptr<AvoidAreaController> avoidController_;
|
||||
sptr<DisplayGroupController> displayGroupController_;
|
||||
|
||||
std::map<DisplayId, Rect> displayRectMap_;
|
||||
std::map<DisplayId, sptr<DisplayInfo>> displayInfosMap_;
|
||||
sptr<DisplayGroupInfo> displayGroupInfo_;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
* @param displayId the disply of window pair
|
||||
* @param appNode the window root of app window
|
||||
*/
|
||||
WindowPair(const DisplayId& displayId, WindowNodeMaps& windowNodeMaps);
|
||||
WindowPair(const DisplayId& displayId, DisplayGroupWindowTree& displayGroupWindowTree);
|
||||
|
||||
/**
|
||||
* Deconstructor used to deconstruct.
|
||||
@@ -153,6 +153,20 @@ public:
|
||||
*/
|
||||
std::vector<sptr<WindowNode>> GetPairedWindows();
|
||||
|
||||
/**
|
||||
* Get whether dock slice is forbidden to move.
|
||||
*
|
||||
* @return whether dock slice is forbidden to move
|
||||
*/
|
||||
bool IsForbidDockSliceMove() const;
|
||||
|
||||
/**
|
||||
* Set all app windows are restoring.
|
||||
*
|
||||
* @param ratio Indicates whether all app windows are restoring.
|
||||
*/
|
||||
void SetAllAppWindowsRestoring(bool isAllAppWindowsRestoring);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Gets whether the window is related to split window.
|
||||
@@ -232,7 +246,8 @@ private:
|
||||
sptr<WindowNode> secondary_;
|
||||
sptr<WindowNode> divider_;
|
||||
WindowPairStatus status_ = {WindowPairStatus::STATUS_EMPTY};
|
||||
WindowNodeMaps& windowNodeMaps_;
|
||||
DisplayGroupWindowTree& displayGroupWindowTree_;
|
||||
bool isAllAppWindowsRestoring_ { false };
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -30,10 +30,10 @@ enum class Event : uint32_t {
|
||||
};
|
||||
|
||||
class WindowRoot : public RefBase {
|
||||
using Callback = std::function<void (Event event, uint32_t windowId)>;
|
||||
using Callback = std::function<void (Event event, const sptr<IRemoteObject>& remoteObject)>;
|
||||
|
||||
public:
|
||||
WindowRoot(std::recursive_mutex& mutex, Callback callback) : mutex_(mutex), callback_(callback) {}
|
||||
explicit WindowRoot(Callback callback) : callback_(callback) {}
|
||||
~WindowRoot() = default;
|
||||
|
||||
sptr<WindowNodeContainer> GetOrCreateWindowNodeContainer(DisplayId displayId);
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
WMError DestroyWindow(uint32_t windowId, bool onlySelf);
|
||||
WMError UpdateWindowNode(uint32_t windowId, WindowUpdateReason reason);
|
||||
bool isVerticalDisplay(sptr<WindowNode>& node) const;
|
||||
bool IsForbidDockSliceMove(DisplayId displayId) const;
|
||||
|
||||
WMError RequestFocus(uint32_t windowId);
|
||||
WMError RequestActiveWindow(uint32_t windowId);
|
||||
@@ -80,7 +81,9 @@ public:
|
||||
WMError GetModeChangeHotZones(DisplayId displayId,
|
||||
ModeChangeHotZones& hotZones, const ModeChangeHotZonesConfig& config);
|
||||
std::vector<DisplayId> GetAllDisplayIds() const;
|
||||
std::map<uint32_t, sptr<WindowNode>> GetWindowNodeMap();
|
||||
uint32_t GetTotalWindowNum() const;
|
||||
uint32_t GetWindowIdByObject(const sptr<IRemoteObject>& remoteObject);
|
||||
sptr<WindowNode> GetWindowForDumpAceHelpInfo() const;
|
||||
private:
|
||||
void OnRemoteDied(const sptr<IRemoteObject>& remoteObject);
|
||||
WMError DestroyWindowInner(sptr<WindowNode>& node);
|
||||
@@ -96,9 +99,11 @@ private:
|
||||
ScreenId GetScreenGroupId(DisplayId displayId, bool& isRecordedDisplay);
|
||||
void ProcessExpandDisplayCreate(DisplayId displayId, ScreenId screenGroupId);
|
||||
std::map<DisplayId, sptr<DisplayInfo>> GetAllDisplayInfos(const std::vector<DisplayId>& displayIdVec);
|
||||
std::map<DisplayId, Rect> GetAllDisplayRects(const std::vector<DisplayId>& displayIdVec);
|
||||
void MoveNotShowingWindowToDefaultDisplay(DisplayId displayId);
|
||||
|
||||
std::recursive_mutex& mutex_;
|
||||
void DestroyLeakStartingWindow();
|
||||
WMError PostProcessAddWindowNode(sptr<WindowNode>& node, sptr<WindowNode>& parentNode,
|
||||
sptr<WindowNodeContainer>& container);
|
||||
std::map<uint32_t, sptr<WindowNode>> windowNodeMap_;
|
||||
std::map<sptr<IRemoteObject>, uint32_t> windowIdMap_;
|
||||
std::map<ScreenId, sptr<WindowNodeContainer>> windowNodeContainerMap_;
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef OHOS_ROSEN_WINDOW_TASK_LOOPER_H
|
||||
#define OHOS_ROSEN_WINDOW_TASK_LOOPER_H
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <refbase.h>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
template<typename SyncTask>
|
||||
class ScheduledTask : public RefBase {
|
||||
public:
|
||||
static auto Create(SyncTask&& task)
|
||||
{
|
||||
sptr<ScheduledTask<SyncTask>> t(new ScheduledTask(std::forward<SyncTask&&>(task)));
|
||||
return std::make_pair(t, t->task_.get_future());
|
||||
}
|
||||
|
||||
void Run()
|
||||
{
|
||||
task_();
|
||||
}
|
||||
|
||||
private:
|
||||
explicit ScheduledTask(SyncTask&& task) : task_(std::move(task)) {}
|
||||
~ScheduledTask() {}
|
||||
|
||||
using Return = std::invoke_result_t<SyncTask>;
|
||||
std::packaged_task<Return()> task_;
|
||||
};
|
||||
|
||||
class WindowTaskLooper {
|
||||
public:
|
||||
using Task = std::function<void()>;
|
||||
WindowTaskLooper() = default;
|
||||
~WindowTaskLooper();
|
||||
|
||||
template<typename SyncTask, typename RetType = std::invoke_result_t<SyncTask>>
|
||||
std::future<RetType> ScheduleTask(SyncTask&& task)
|
||||
{
|
||||
auto [scheduledTask, taskFuture] = ScheduledTask<SyncTask>::Create(std::forward<SyncTask&&>(task));
|
||||
PostTask([t(std::move(scheduledTask))]() { t->Run(); });
|
||||
return std::move(taskFuture);
|
||||
}
|
||||
void PostTask(const Task& task);
|
||||
void WakeUp();
|
||||
void Start() noexcept;
|
||||
bool IsRunning();
|
||||
|
||||
private:
|
||||
void WaitTask();
|
||||
void TaskProcessThread();
|
||||
void ExecuteAllTask();
|
||||
|
||||
private:
|
||||
mutable std::mutex mtx_;
|
||||
bool wakeUp_ = false;
|
||||
std::condition_variable taskCond_;
|
||||
mutable std::atomic<bool> running_ { false };
|
||||
std::vector<Task> taskQ_;
|
||||
std::unique_ptr<std::thread> taskProcessThread_;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
@@ -59,10 +59,11 @@ private:
|
||||
{ WindowType::WINDOW_TYPE_NAVIGATION_BAR, 113 },
|
||||
{ WindowType::WINDOW_TYPE_KEYGUARD, 114 },
|
||||
// reserve 115 for app window above keyguard, 116 for input method window above keyguard
|
||||
{ WindowType::WINDOW_TYPE_DRAGGING_EFFECT, 117 },
|
||||
{ WindowType::WINDOW_TYPE_POINTER, 118 },
|
||||
{ WindowType::WINDOW_TYPE_BOOT_ANIMATION, 119 },
|
||||
{ WindowType::WINDOW_TYPE_FREEZE_DISPLAY, 120 },
|
||||
{ WindowType::WINDOW_TYPE_VOICE_INTERACTION, 117 },
|
||||
{ WindowType::WINDOW_TYPE_DRAGGING_EFFECT, 118 },
|
||||
{ WindowType::WINDOW_TYPE_POINTER, 119 },
|
||||
{ WindowType::WINDOW_TYPE_BOOT_ANIMATION, 120 },
|
||||
{ WindowType::WINDOW_TYPE_FREEZE_DISPLAY, 121 },
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
virtual void ProcessPointDown(uint32_t windowId, bool isStartDrag) = 0;
|
||||
virtual void ProcessPointUp(uint32_t windowId) = 0;
|
||||
virtual void MinimizeAllAppWindows(DisplayId displayId) = 0;
|
||||
virtual void ToggleShownStateForAllAppWindows() = 0;
|
||||
virtual WMError ToggleShownStateForAllAppWindows() = 0;
|
||||
virtual WMError MaxmizeWindow(uint32_t windowId) = 0;
|
||||
virtual WMError SetWindowLayoutMode(WindowLayoutMode mode) = 0;
|
||||
virtual WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action) = 0;
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
void ProcessPointDown(uint32_t windowId, bool isStartDrag) override;
|
||||
void ProcessPointUp(uint32_t windowId) override;
|
||||
void MinimizeAllAppWindows(DisplayId displayId) override;
|
||||
void ToggleShownStateForAllAppWindows() override;
|
||||
WMError ToggleShownStateForAllAppWindows() override;
|
||||
WMError MaxmizeWindow(uint32_t windowId) override;
|
||||
WMError SetWindowLayoutMode(WindowLayoutMode mode) override;
|
||||
WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action) override;
|
||||
|
||||
@@ -39,27 +39,27 @@ void DisplayGroupController::InitNewDisplay(DisplayId displayId)
|
||||
sysBarTintMaps_.insert(std::make_pair(displayId, sysBarTintMap));
|
||||
|
||||
// window node maps for display
|
||||
std::map<WindowRootNodeType, std::unique_ptr<std::vector<sptr<WindowNode>>>> windowRootNodeMap;
|
||||
windowRootNodeMap.insert(std::make_pair(WindowRootNodeType::APP_WINDOW_NODE,
|
||||
std::map<WindowRootNodeType, std::unique_ptr<std::vector<sptr<WindowNode>>>> displayWindowTree;
|
||||
displayWindowTree.insert(std::make_pair(WindowRootNodeType::APP_WINDOW_NODE,
|
||||
std::make_unique<std::vector<sptr<WindowNode>>>()));
|
||||
windowRootNodeMap.insert(std::make_pair(WindowRootNodeType::ABOVE_WINDOW_NODE,
|
||||
displayWindowTree.insert(std::make_pair(WindowRootNodeType::ABOVE_WINDOW_NODE,
|
||||
std::make_unique<std::vector<sptr<WindowNode>>>()));
|
||||
windowRootNodeMap.insert(std::make_pair(WindowRootNodeType::BELOW_WINDOW_NODE,
|
||||
displayWindowTree.insert(std::make_pair(WindowRootNodeType::BELOW_WINDOW_NODE,
|
||||
std::make_unique<std::vector<sptr<WindowNode>>>()));
|
||||
windowNodeMaps_.insert(std::make_pair(displayId, std::move(windowRootNodeMap)));
|
||||
displayGroupWindowTree_.insert(std::make_pair(displayId, std::move(displayWindowTree)));
|
||||
|
||||
// window pair for display
|
||||
auto windowPair = new WindowPair(displayId, windowNodeMaps_);
|
||||
auto windowPair = new WindowPair(displayId, displayGroupWindowTree_);
|
||||
windowPairMap_.insert(std::make_pair(displayId, windowPair));
|
||||
}
|
||||
|
||||
std::vector<sptr<WindowNode>>* DisplayGroupController::GetWindowNodesByDisplayIdAndRootType(DisplayId displayId,
|
||||
WindowRootNodeType type)
|
||||
{
|
||||
if (windowNodeMaps_.find(displayId) != windowNodeMaps_.end()) {
|
||||
auto& rootNodemap = windowNodeMaps_[displayId];
|
||||
if (rootNodemap.find(type) != rootNodemap.end()) {
|
||||
return rootNodemap[type].get();
|
||||
if (displayGroupWindowTree_.find(displayId) != displayGroupWindowTree_.end()) {
|
||||
auto& displayWindowTree = displayGroupWindowTree_[displayId];
|
||||
if (displayWindowTree.find(type) != displayWindowTree.end()) {
|
||||
return displayWindowTree[type].get();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
@@ -79,10 +79,10 @@ void DisplayGroupController::AddWindowNodeOnWindowTree(sptr<WindowNode>& node, W
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayGroupController::UpdateWindowNodeMaps()
|
||||
void DisplayGroupController::UpdateDisplayGroupWindowTree()
|
||||
{
|
||||
// clear ori windowNodeMaps
|
||||
for (auto& elem : windowNodeMaps_) {
|
||||
// clear ori window tree of displayGroup
|
||||
for (auto& elem : displayGroupWindowTree_) {
|
||||
for (auto& nodeVec : elem.second) {
|
||||
auto emptyVector = std::vector<sptr<WindowNode>>();
|
||||
nodeVec.second->swap(emptyVector);
|
||||
@@ -108,7 +108,7 @@ void DisplayGroupController::UpdateWindowNodeMaps()
|
||||
void DisplayGroupController::ProcessCrossNodes(DisplayStateChangeType type)
|
||||
{
|
||||
defaultDisplayId_ = DisplayManagerServiceInner::GetInstance().GetDefaultDisplayId();
|
||||
for (auto& iter : windowNodeMaps_) {
|
||||
for (auto& iter : displayGroupWindowTree_) {
|
||||
auto& nodeVec = *(iter.second[WindowRootNodeType::APP_WINDOW_NODE]);
|
||||
for (auto& node : nodeVec) {
|
||||
if (node->isShowingOnMultiDisplays_) {
|
||||
@@ -136,28 +136,13 @@ void DisplayGroupController::ProcessCrossNodes(DisplayStateChangeType type)
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayGroupController::FindMaxAndMinPosXDisplay()
|
||||
{
|
||||
minPosXDisplay_ = displayRectMap_.begin()->first;
|
||||
maxPosXDisplay_ = displayRectMap_.begin()->first;
|
||||
for (auto& elem : displayRectMap_) {
|
||||
auto& curDisplayRect = elem.second;
|
||||
if (curDisplayRect.posX_ < displayRectMap_[minPosXDisplay_].posX_) {
|
||||
minPosXDisplay_ = elem.first;
|
||||
}
|
||||
if ((curDisplayRect.posX_ + static_cast<int32_t>(curDisplayRect.width_)) >
|
||||
(displayRectMap_[maxPosXDisplay_].posX_ + static_cast<int32_t>(displayRectMap_[maxPosXDisplay_].width_))) {
|
||||
maxPosXDisplay_ = elem.first;
|
||||
}
|
||||
}
|
||||
WLOGFI("max posX displayId: %{public}" PRIu64", min posX displayId: %{public}" PRIu64"",
|
||||
maxPosXDisplay_, minPosXDisplay_);
|
||||
}
|
||||
|
||||
void DisplayGroupController::UpdateWindowShowingDisplays(const sptr<WindowNode>& node, const Rect& requestRect)
|
||||
{
|
||||
auto leftDisplayId = displayGroupInfo_->GetLeftDisplayId();
|
||||
auto rightDisplayId = displayGroupInfo_->GetRightDisplayId();
|
||||
auto displayRectMap = displayGroupInfo_->GetAllDisplayRects();
|
||||
auto showingDisplays = std::vector<DisplayId>();
|
||||
for (auto& elem : displayRectMap_) {
|
||||
for (auto& elem : displayRectMap) {
|
||||
auto& curDisplayRect = elem.second;
|
||||
|
||||
// if window is showing in display region
|
||||
@@ -170,12 +155,12 @@ void DisplayGroupController::UpdateWindowShowingDisplays(const sptr<WindowNode>&
|
||||
// if window is not showing on any display, maybe in the left of minPosX display, or the right of maxPosX display
|
||||
if (showingDisplays.empty()) {
|
||||
if (((requestRect.posX_ + static_cast<int32_t>(requestRect.width_)) <=
|
||||
displayRectMap_[minPosXDisplay_].posX_)) {
|
||||
showingDisplays.push_back(minPosXDisplay_);
|
||||
displayRectMap[leftDisplayId].posX_)) {
|
||||
showingDisplays.push_back(leftDisplayId);
|
||||
}
|
||||
if (requestRect.posX_ >=
|
||||
(displayRectMap_[maxPosXDisplay_].posX_ + static_cast<int32_t>(displayRectMap_[maxPosXDisplay_].width_))) {
|
||||
showingDisplays.push_back(maxPosXDisplay_);
|
||||
(displayRectMap[rightDisplayId].posX_ + static_cast<int32_t>(displayRectMap[rightDisplayId].width_))) {
|
||||
showingDisplays.push_back(rightDisplayId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +182,8 @@ void DisplayGroupController::UpdateWindowDisplayIdIfNeeded(const sptr<WindowNode
|
||||
// if more than half width of the window is showing on the display, means the window belongs to this display
|
||||
const Rect& requestRect = node->GetRequestRect();
|
||||
int32_t halfWidth = static_cast<int32_t>(requestRect.width_ * 0.5);
|
||||
for (auto& elem : displayRectMap_) {
|
||||
const auto& displayRectMap = displayGroupInfo_->GetAllDisplayRects();
|
||||
for (auto& elem : displayRectMap) {
|
||||
auto& displayRect = elem.second;
|
||||
if ((requestRect.posX_ < displayRect.posX_) &&
|
||||
(requestRect.posX_ + static_cast<int32_t>(requestRect.width_) >
|
||||
@@ -227,7 +213,7 @@ void DisplayGroupController::UpdateWindowDisplayIdIfNeeded(const sptr<WindowNode
|
||||
void DisplayGroupController::ChangeToRectInDisplayGroup(const sptr<WindowNode>& node)
|
||||
{
|
||||
Rect requestRect = node->GetRequestRect();
|
||||
const Rect& displayRect = displayRectMap_[node->GetDisplayId()];
|
||||
const Rect& displayRect = displayGroupInfo_->GetDisplayRect(node->GetDisplayId());
|
||||
requestRect.posX_ += displayRect.posX_;
|
||||
requestRect.posY_ += displayRect.posY_;
|
||||
node->SetRequestRect(requestRect);
|
||||
@@ -311,8 +297,8 @@ void DisplayGroupController::MoveNotCrossNodeToDefaultDisplay(const sptr<WindowN
|
||||
WLOGFI("windowId: %{public}d, displayId: %{public}" PRIu64"", node->GetWindowId(), displayId);
|
||||
|
||||
// update new rect in display group
|
||||
Rect srcDisplayRect = displayRectMap_[displayId];
|
||||
Rect dstDisplayRect = displayRectMap_[defaultDisplayId_];
|
||||
const Rect& srcDisplayRect = displayGroupInfo_->GetDisplayRect(displayId);
|
||||
const Rect& dstDisplayRect = displayGroupInfo_->GetDisplayRect(defaultDisplayId_);
|
||||
Rect newRect = node->GetRequestRect();
|
||||
newRect.posX_ = newRect.posX_ - srcDisplayRect.posX_ + dstDisplayRect.posX_;
|
||||
newRect.posY_ = newRect.posY_ - srcDisplayRect.posY_ + dstDisplayRect.posY_;
|
||||
@@ -342,7 +328,7 @@ void DisplayGroupController::ProcessNotCrossNodesOnDestroiedDisplay(DisplayId di
|
||||
WindowRootNodeType::BELOW_WINDOW_NODE
|
||||
};
|
||||
for (size_t index = 0; index < rootNodeType.size(); ++index) {
|
||||
auto& nodesVec = *(windowNodeMaps_[displayId][rootNodeType[index]]);
|
||||
auto& nodesVec = *(displayGroupWindowTree_[displayId][rootNodeType[index]]);
|
||||
for (auto& node : nodesVec) {
|
||||
if (node->GetDisplayId() != displayId || node->isShowingOnMultiDisplays_) {
|
||||
continue;
|
||||
@@ -366,106 +352,60 @@ void DisplayGroupController::ProcessNotCrossNodesOnDestroiedDisplay(DisplayId di
|
||||
}
|
||||
|
||||
void DisplayGroupController::ProcessDisplayCreate(DisplayId displayId,
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap)
|
||||
const std::map<DisplayId, Rect>& displayRectMap)
|
||||
{
|
||||
if (displayInfosMap_.find(displayId) != displayInfosMap_.end() ||
|
||||
displayInfoMap.size() != (displayInfosMap_.size() + 1)) {
|
||||
WLOGFE("current display is exited or displayInfo map size is error, displayId: %{public}" PRIu64"", displayId);
|
||||
return;
|
||||
}
|
||||
|
||||
defaultDisplayId_ = DisplayManagerServiceInner::GetInstance().GetDefaultDisplayId();
|
||||
WLOGFI("defaultDisplay, displayId: %{public}" PRIu64"", defaultDisplayId_);
|
||||
|
||||
windowNodeContainer_->GetAvoidController()->UpdateAvoidNodesMap(displayId, true);
|
||||
InitNewDisplay(displayId);
|
||||
|
||||
// window pair for split window
|
||||
auto windowPair = new WindowPair(displayId, windowNodeMaps_);
|
||||
// add displayInfo in displayGroupInfo
|
||||
auto displayInfo = DisplayManagerServiceInner::GetInstance().GetDisplayById(displayId);
|
||||
displayGroupInfo_->AddDisplayInfo(displayInfo);
|
||||
|
||||
// create new window pair for split window
|
||||
auto windowPair = new WindowPair(displayId, displayGroupWindowTree_);
|
||||
windowPairMap_.insert(std::make_pair(displayId, windowPair));
|
||||
|
||||
// modify RSTree and windowNodeMaps for cross-display nodes
|
||||
// modify RSTree and window tree of displayGroup for cross-display nodes
|
||||
ProcessCrossNodes(DisplayStateChangeType::CREATE);
|
||||
UpdateWindowNodeMaps();
|
||||
|
||||
for (auto& elem : displayInfoMap) {
|
||||
auto iter = displayInfosMap_.find(elem.first);
|
||||
const auto& displayInfo = elem.second;
|
||||
Rect displayRect = { displayInfo->GetOffsetX(), displayInfo->GetOffsetY(),
|
||||
displayInfo->GetWidth(), displayInfo->GetHeight() };
|
||||
if (iter != displayInfosMap_.end()) {
|
||||
displayRectMap_[elem.first] = displayRect;
|
||||
displayInfosMap_[elem.first] = displayInfo;
|
||||
} else {
|
||||
displayRectMap_.insert(std::make_pair(elem.first, displayRect));
|
||||
displayInfosMap_.insert(std::make_pair(elem.first, displayInfo));
|
||||
}
|
||||
WLOGFI("displayId: %{public}" PRIu64", displayRect: [ %{public}d, %{public}d, %{public}d, %{public}d]",
|
||||
elem.first, displayRect.posX_, displayRect.posY_, displayRect.width_, displayRect.height_);
|
||||
}
|
||||
FindMaxAndMinPosXDisplay();
|
||||
windowNodeContainer_->GetLayoutPolicy()->ProcessDisplayCreate(displayId, displayRectMap_);
|
||||
UpdateDisplayGroupWindowTree();
|
||||
windowNodeContainer_->GetLayoutPolicy()->ProcessDisplayCreate(displayId, displayRectMap);
|
||||
}
|
||||
|
||||
void DisplayGroupController::ProcessDisplayDestroy(DisplayId displayId,
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap,
|
||||
const std::map<DisplayId, Rect>& displayRectMap,
|
||||
std::vector<uint32_t>& windowIds)
|
||||
{
|
||||
if (displayInfosMap_.find(displayId) == displayInfosMap_.end() ||
|
||||
(displayInfoMap.size() + 1) != displayInfosMap_.size()) {
|
||||
WLOGFE("can not find current display or displayInfo map size is error, displayId: %{public}" PRIu64"",
|
||||
displayId);
|
||||
return;
|
||||
}
|
||||
|
||||
windowNodeContainer_->GetAvoidController()->UpdateAvoidNodesMap(displayId, false);
|
||||
|
||||
// delete nodes and map element of deleted display
|
||||
ProcessNotCrossNodesOnDestroiedDisplay(displayId, windowIds);
|
||||
// modify RSTree and windowNodeMaps for cross-display nodes
|
||||
// modify RSTree and window tree of displayGroup for cross-display nodes
|
||||
ProcessCrossNodes(DisplayStateChangeType::DESTROY);
|
||||
UpdateWindowNodeMaps();
|
||||
UpdateDisplayGroupWindowTree();
|
||||
ClearMapOfDestroiedDisplay(displayId);
|
||||
|
||||
for (auto& elem : displayInfoMap) {
|
||||
auto iter = displayInfosMap_.find(elem.first);
|
||||
const auto& displayInfo = elem.second;
|
||||
Rect displayRect = { displayInfo->GetOffsetX(), displayInfo->GetOffsetY(),
|
||||
displayInfo->GetWidth(), displayInfo->GetHeight() };
|
||||
if (iter != displayInfosMap_.end()) {
|
||||
displayRectMap_[elem.first] = displayRect;
|
||||
displayInfosMap_[elem.first] = displayInfo;
|
||||
WLOGFI("displayId: %{public}" PRIu64", displayRect: [ %{public}d, %{public}d, %{public}d, %{public}d]",
|
||||
elem.first, displayRect.posX_, displayRect.posY_, displayRect.width_, displayRect.height_);
|
||||
}
|
||||
}
|
||||
FindMaxAndMinPosXDisplay();
|
||||
windowNodeContainer_->GetLayoutPolicy()->ProcessDisplayDestroy(displayId, displayRectMap_);
|
||||
windowNodeContainer_->GetLayoutPolicy()->ProcessDisplayDestroy(displayId, displayRectMap);
|
||||
}
|
||||
|
||||
void DisplayGroupController::ProcessDisplayChange(DisplayId displayId,
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap,
|
||||
const std::map<DisplayId, Rect>& displayRectMap,
|
||||
DisplayStateChangeType type)
|
||||
{
|
||||
const sptr<DisplayInfo> displayInfo = DisplayManagerServiceInner::GetInstance().GetDisplayById(displayId);
|
||||
if (displayInfosMap_.find(displayId) == displayInfosMap_.end()) {
|
||||
WLOGFE("can not find current display, displayId: %{public}" PRIu64", type: %{public}d", displayId, type);
|
||||
return;
|
||||
}
|
||||
WLOGFI("display change, displayId: %{public}" PRIu64", type: %{public}d", displayId, type);
|
||||
switch (type) {
|
||||
case DisplayStateChangeType::UPDATE_ROTATION: {
|
||||
displayInfosMap_[displayId]->SetRotation(displayInfo->GetRotation());
|
||||
displayGroupInfo_->SetDisplayRotation(displayId, displayInfo->GetRotation());
|
||||
[[fallthrough]];
|
||||
}
|
||||
case DisplayStateChangeType::SIZE_CHANGE: {
|
||||
displayInfosMap_[displayId]->SetWidth(displayInfo->GetWidth());
|
||||
displayInfosMap_[displayId]->SetHeight(displayInfo->GetHeight());
|
||||
ProcessDisplaySizeChangeOrRotation(displayId, displayInfoMap, type);
|
||||
ProcessDisplaySizeChangeOrRotation(displayId, displayRectMap, type);
|
||||
break;
|
||||
}
|
||||
case DisplayStateChangeType::VIRTUAL_PIXEL_RATIO_CHANGE: {
|
||||
displayInfosMap_[displayId]->SetVirtualPixelRatio(displayInfo->GetVirtualPixelRatio());
|
||||
displayGroupInfo_->SetDisplayVirtualPixelRatio(displayId, displayInfo->GetVirtualPixelRatio());
|
||||
windowNodeContainer_->GetLayoutPolicy()->LayoutWindowTree(displayId);
|
||||
break;
|
||||
}
|
||||
@@ -473,37 +413,23 @@ void DisplayGroupController::ProcessDisplayChange(DisplayId displayId,
|
||||
break;
|
||||
}
|
||||
}
|
||||
FindMaxAndMinPosXDisplay();
|
||||
}
|
||||
|
||||
void DisplayGroupController::ProcessDisplaySizeChangeOrRotation(DisplayId displayId,
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type)
|
||||
const std::map<DisplayId, Rect>& displayRectMap, DisplayStateChangeType type)
|
||||
{
|
||||
// modify RSTree and windowNodeMaps for cross-display nodes
|
||||
// modify RSTree and window tree of displayGroup for cross-display nodes
|
||||
ProcessCrossNodes(type);
|
||||
UpdateWindowNodeMaps();
|
||||
for (auto& elem : displayInfoMap) {
|
||||
auto iter = displayInfosMap_.find(elem.first);
|
||||
const auto& displayInfo = elem.second;
|
||||
Rect displayRect = { displayInfo->GetOffsetX(), displayInfo->GetOffsetY(),
|
||||
displayInfo->GetWidth(), displayInfo->GetHeight() };
|
||||
if (iter != displayInfosMap_.end()) {
|
||||
displayRectMap_[elem.first] = displayRect;
|
||||
displayInfosMap_[elem.first] = displayInfo;
|
||||
WLOGFI("displayId: %{public}" PRIu64", displayRect: [ %{public}d, %{public}d, %{public}d, %{public}d]",
|
||||
elem.first, displayRect.posX_, displayRect.posY_, displayRect.width_, displayRect.height_);
|
||||
}
|
||||
}
|
||||
windowNodeContainer_->GetLayoutPolicy()->ProcessDisplaySizeChangeOrRotation(displayId, displayRectMap_);
|
||||
UpdateDisplayGroupWindowTree();
|
||||
windowNodeContainer_->GetLayoutPolicy()->ProcessDisplaySizeChangeOrRotation(displayId, displayRectMap);
|
||||
}
|
||||
|
||||
void DisplayGroupController::ClearMapOfDestroiedDisplay(DisplayId displayId)
|
||||
{
|
||||
sysBarTintMaps_.erase(displayId);
|
||||
sysBarNodeMaps_.erase(displayId);
|
||||
windowNodeMaps_.erase(displayId);
|
||||
displayRectMap_.erase(displayId);
|
||||
displayInfosMap_.erase(displayId);
|
||||
displayGroupWindowTree_.erase(displayId);
|
||||
displayGroupInfo_->RemoveDisplayInfo(displayId);
|
||||
windowPairMap_.erase(displayId);
|
||||
}
|
||||
|
||||
@@ -514,5 +440,5 @@ sptr<WindowPair> DisplayGroupController::GetWindowPairByDisplayId(DisplayId disp
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "display_group_info.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "DisplayGroupInfo"};
|
||||
}
|
||||
|
||||
DisplayGroupInfo::DisplayGroupInfo(ScreenId displayGroupId, const sptr<DisplayInfo>& displayInfo)
|
||||
{
|
||||
displayGroupId_ = displayGroupId;
|
||||
AddDisplayInfo(displayInfo);
|
||||
}
|
||||
|
||||
void DisplayGroupInfo::AddDisplayInfo(const sptr<DisplayInfo>& displayInfo)
|
||||
{
|
||||
DisplayId displayId = displayInfo->GetDisplayId();
|
||||
if (displayInfosMap_.find(displayId) != displayInfosMap_.end()) {
|
||||
WLOGFE("current display is exits, displayId: %{public}" PRIu64"", displayId);
|
||||
return;
|
||||
}
|
||||
displayInfosMap_.insert(std::make_pair(displayId, displayInfo));
|
||||
}
|
||||
|
||||
void DisplayGroupInfo::RemoveDisplayInfo(DisplayId displayId)
|
||||
{
|
||||
if (displayInfosMap_.find(displayId) == displayInfosMap_.end()) {
|
||||
WLOGFE("current display is not exits, displayId: %{public}" PRIu64"", displayId);
|
||||
return;
|
||||
}
|
||||
displayInfosMap_.erase(displayId);
|
||||
}
|
||||
|
||||
void DisplayGroupInfo::UpdateLeftAndRightDisplayId()
|
||||
{
|
||||
auto displayRectMap = GetAllDisplayRects();
|
||||
leftDisplayId_ = displayRectMap.begin()->first;
|
||||
rightDisplayId_ = displayRectMap.begin()->first;
|
||||
for (auto& elem : displayRectMap) {
|
||||
auto& curDisplayRect = elem.second;
|
||||
if (curDisplayRect.posX_ < displayRectMap[leftDisplayId_].posX_) {
|
||||
leftDisplayId_ = elem.first;
|
||||
}
|
||||
if ((curDisplayRect.posX_ + static_cast<int32_t>(curDisplayRect.width_)) >
|
||||
(displayRectMap[rightDisplayId_].posX_ + static_cast<int32_t>(displayRectMap[rightDisplayId_].width_))) {
|
||||
rightDisplayId_ = elem.first;
|
||||
}
|
||||
}
|
||||
WLOGFI("max posX displayId: %{public}" PRIu64", min posX displayId: %{public}" PRIu64"",
|
||||
rightDisplayId_, leftDisplayId_);
|
||||
}
|
||||
|
||||
void DisplayGroupInfo::SetDisplayRotation(DisplayId displayId, Rotation rotation)
|
||||
{
|
||||
if (displayInfosMap_.find(displayId) == displayInfosMap_.end()) {
|
||||
WLOGFE("current display is not exits, displayId: %{public}" PRIu64"", displayId);
|
||||
return;
|
||||
}
|
||||
displayInfosMap_[displayId]->SetRotation(rotation);
|
||||
}
|
||||
|
||||
void DisplayGroupInfo::SetDisplayVirtualPixelRatio(DisplayId displayId, float vpr)
|
||||
{
|
||||
if (displayInfosMap_.find(displayId) == displayInfosMap_.end()) {
|
||||
WLOGFE("current display is not exits, displayId: %{public}" PRIu64"", displayId);
|
||||
return;
|
||||
}
|
||||
displayInfosMap_[displayId]->SetVirtualPixelRatio(vpr);
|
||||
}
|
||||
|
||||
void DisplayGroupInfo::SetDisplayRect(DisplayId displayId, Rect displayRect)
|
||||
{
|
||||
if (displayInfosMap_.find(displayId) == displayInfosMap_.end()) {
|
||||
WLOGFE("current display is not exits, displayId: %{public}" PRIu64"", displayId);
|
||||
return;
|
||||
}
|
||||
auto& displayInfo = displayInfosMap_[displayId];
|
||||
displayInfo->SetOffsetX(displayRect.posX_);
|
||||
displayInfo->SetOffsetY(displayRect.posY_);
|
||||
displayInfo->SetWidth(displayRect.width_);
|
||||
displayInfo->SetHeight(displayRect.height_);
|
||||
}
|
||||
|
||||
Rotation DisplayGroupInfo::GetDisplayRotation(DisplayId displayId) const
|
||||
{
|
||||
Rotation rotation = Rotation::ROTATION_0;
|
||||
if (displayInfosMap_.find(displayId) != displayInfosMap_.end()) {
|
||||
auto& displayInfo = displayInfosMap_[displayId];
|
||||
rotation = displayInfo->GetRotation();
|
||||
}
|
||||
return rotation;
|
||||
}
|
||||
|
||||
float DisplayGroupInfo::GetDisplayVirtualPixelRatio(DisplayId displayId) const
|
||||
{
|
||||
float vpr = 1.0;
|
||||
if (displayInfosMap_.find(displayId) != displayInfosMap_.end()) {
|
||||
auto& displayInfo = displayInfosMap_[displayId];
|
||||
vpr = displayInfo->GetVirtualPixelRatio();
|
||||
}
|
||||
return vpr;
|
||||
}
|
||||
|
||||
std::map<DisplayId, Rect> DisplayGroupInfo::GetAllDisplayRects() const
|
||||
{
|
||||
std::map<DisplayId, Rect> displayRectMap;
|
||||
for (auto elem : displayInfosMap_) {
|
||||
auto& displayInfo = elem.second;
|
||||
Rect displayRect = { displayInfo->GetOffsetX(), displayInfo->GetOffsetY(),
|
||||
displayInfo->GetWidth(), displayInfo->GetHeight() };
|
||||
displayRectMap.insert(std::make_pair(elem.first, displayRect));
|
||||
}
|
||||
return displayRectMap;
|
||||
}
|
||||
|
||||
Rect DisplayGroupInfo::GetDisplayRect(DisplayId displayId) const
|
||||
{
|
||||
Rect rect;
|
||||
if (displayInfosMap_.find(displayId) != displayInfosMap_.end()) {
|
||||
auto& displayInfo = displayInfosMap_[displayId];
|
||||
rect = { displayInfo->GetOffsetX(), displayInfo->GetOffsetY(),
|
||||
displayInfo->GetWidth(), displayInfo->GetHeight() };
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
sptr<DisplayInfo> DisplayGroupInfo::GetDisplayInfo(DisplayId displayId) const
|
||||
{
|
||||
if (displayInfosMap_.find(displayId) != displayInfosMap_.end()) {
|
||||
return displayInfosMap_[displayId];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DisplayId DisplayGroupInfo::GetLeftDisplayId() const
|
||||
{
|
||||
return leftDisplayId_;
|
||||
}
|
||||
|
||||
DisplayId DisplayGroupInfo::GetRightDisplayId() const
|
||||
{
|
||||
return rightDisplayId_;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
@@ -24,15 +24,20 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "MinimizeApp"};
|
||||
}
|
||||
|
||||
std::map<MinimizeReason, std::vector<sptr<WindowNode>>> MinimizeApp::needMinimizeAppNodes_;
|
||||
std::map<MinimizeReason, std::vector<wptr<WindowNode>>> MinimizeApp::needMinimizeAppNodes_;
|
||||
bool MinimizeApp::isMinimizedByOtherWindow_ = true;
|
||||
std::recursive_mutex MinimizeApp::mutex_;
|
||||
|
||||
void MinimizeApp::AddNeedMinimizeApp(const sptr<WindowNode>& node, MinimizeReason reason)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
bool isFromUser = IsFromUser(reason);
|
||||
if (!isMinimizedByOtherWindow_ && !isFromUser) {
|
||||
return;
|
||||
}
|
||||
wptr<WindowNode> weakNode(node);
|
||||
WLOGFI("[Minimize] Add Window %{public}u to minimize list, reason %{public}u", node->GetWindowId(), reason);
|
||||
needMinimizeAppNodes_[reason].emplace_back(node);
|
||||
needMinimizeAppNodes_[reason].emplace_back(weakNode);
|
||||
}
|
||||
|
||||
void MinimizeApp::ExecuteMinimizeAll()
|
||||
@@ -40,14 +45,12 @@ void MinimizeApp::ExecuteMinimizeAll()
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
for (auto& appNodes: needMinimizeAppNodes_) {
|
||||
bool isFromUser = IsFromUser(appNodes.first);
|
||||
if (!isMinimizedByOtherWindow_ && !isFromUser) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto& node : appNodes.second) {
|
||||
if (node->abilityToken_ != nullptr) {
|
||||
WLOGFI("[Minimize] Minimize Window %{public}u, reason %{public}u", node->GetWindowId(), appNodes.first);
|
||||
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(node->abilityToken_, isFromUser);
|
||||
auto weakNode = node.promote();
|
||||
if (weakNode != nullptr && weakNode->abilityToken_ != nullptr && !weakNode->startingWindowShown_) {
|
||||
WLOGFI("[Minimize] Minimize Window %{public}u, reason %{public}u",
|
||||
weakNode->GetWindowId(), appNodes.first);
|
||||
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(weakNode->abilityToken_, isFromUser);
|
||||
}
|
||||
}
|
||||
appNodes.second.clear();
|
||||
@@ -83,13 +86,11 @@ void MinimizeApp::ExecuteMinimizeTargetReason(MinimizeReason reason)
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (needMinimizeAppNodes_.find(reason) != needMinimizeAppNodes_.end()) {
|
||||
bool isFromUser = IsFromUser(reason);
|
||||
if (!isMinimizedByOtherWindow_ && !isFromUser) {
|
||||
return;
|
||||
}
|
||||
for (auto& node : needMinimizeAppNodes_.at(reason)) {
|
||||
if (node->abilityToken_ != nullptr) {
|
||||
WLOGFI("[Minimize] Minimize Window %{public}u, reason %{public}u", node->GetWindowId(), reason);
|
||||
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(node->abilityToken_, isFromUser);
|
||||
auto weakNode = node.promote();
|
||||
if (weakNode != nullptr && weakNode->abilityToken_ != nullptr && !weakNode->startingWindowShown_) {
|
||||
WLOGFI("[Minimize] Minimize Window %{public}u, reason %{public}u", weakNode->GetWindowId(), reason);
|
||||
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(weakNode->abilityToken_, isFromUser);
|
||||
}
|
||||
}
|
||||
needMinimizeAppNodes_.at(reason).clear();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user