mirror of
https://gitee.com/openharmony/window_window_manager
synced 2025-02-14 12:39:11 +00:00
!11826 获取全部窗口信息
Merge pull request !11826 from 卢宇豪/getallwindowlayoutinfo
This commit is contained in:
commit
9a1cd5035b
@ -730,6 +730,14 @@ public:
|
||||
WMError GetUnreliableWindowInfo(int32_t windowId,
|
||||
std::vector<sptr<UnreliableWindowInfo>>& infos) const;
|
||||
|
||||
/**
|
||||
* @brief Get window layout info.
|
||||
*
|
||||
* @param infos window layout infos
|
||||
* @return WM_OK means get success, others means get failed.
|
||||
*/
|
||||
WMError GetAllWindowLayoutInfo(DisplayId displayId, std::vector<sptr<WindowLayoutInfo>>& infos) const;
|
||||
|
||||
/**
|
||||
* @brief Get visibility window info.
|
||||
*
|
||||
|
@ -1189,6 +1189,34 @@ struct TitleButtonRect {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* @struct WindowLayoutInfo
|
||||
*
|
||||
* @brief Layout info for all windows on the screen.
|
||||
*/
|
||||
struct WindowLayoutInfo : public Parcelable {
|
||||
Rect rect = { 0, 0, 0, 0 };
|
||||
|
||||
bool Marshalling(Parcel& parcel) const override
|
||||
{
|
||||
return parcel.WriteInt32(rect.posX_) && parcel.WriteInt32(rect.posY_) &&
|
||||
parcel.WriteUint32(rect.width_) && parcel.WriteUint32(rect.height_);
|
||||
}
|
||||
|
||||
static WindowLayoutInfo* Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
WindowLayoutInfo* windowLayoutInfo = new WindowLayoutInfo;
|
||||
if (!parcel.ReadInt32(windowLayoutInfo->rect.posX_) ||
|
||||
!parcel.ReadInt32(windowLayoutInfo->rect.posY_) ||
|
||||
!parcel.ReadUint32(windowLayoutInfo->rect.width_) ||
|
||||
!parcel.ReadUint32(windowLayoutInfo->rect.height_)) {
|
||||
delete windowLayoutInfo;
|
||||
return nullptr;
|
||||
}
|
||||
return windowLayoutInfo;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Config of keyboard animation
|
||||
*/
|
||||
|
@ -153,6 +153,12 @@ napi_value JsWindowManager::ShiftAppWindowFocus(napi_env env, napi_callback_info
|
||||
return (me != nullptr) ? me->OnShiftAppWindowFocus(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsWindowManager::GetAllWindowLayoutInfo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
JsWindowManager* me = CheckParamsAndGetThis<JsWindowManager>(env, info);
|
||||
return (me != nullptr) ? me->OnGetAllWindowLayoutInfo(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsWindowManager::GetVisibleWindowInfo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
JsWindowManager* me = CheckParamsAndGetThis<JsWindowManager>(env, info);
|
||||
@ -1189,6 +1195,46 @@ napi_value JsWindowManager::OnShiftAppWindowFocus(napi_env env, napi_callback_in
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value JsWindowManager::OnGetAllWindowLayoutInfo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = ARGC_FOUR;
|
||||
napi_value argv[ARGC_FOUR] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc != ARGC_ONE) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Argc is invalid: %{public}zu", argc);
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
int64_t displayId = static_cast<int64_t>(DISPLAY_ID_INVALID);
|
||||
if (!ConvertFromJsValue(env, argv[INDEX_ZERO], displayId)) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to convert parameter to displayId");
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
if (displayId < 0 ||
|
||||
SingletonContainer::Get<DisplayManager>().GetDisplayById(static_cast<uint64_t>(displayId)) == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "invalid displayId");
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
}
|
||||
napi_value result = nullptr;
|
||||
std::shared_ptr<NapiAsyncTask> napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result);
|
||||
auto asyncTask = [env, task = napiAsyncTask, displayId, where = __func__] {
|
||||
std::vector<sptr<WindowLayoutInfo>> infos;
|
||||
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(
|
||||
SingletonContainer::Get<WindowManager>().GetAllWindowLayoutInfo(static_cast<uint64_t>(displayId), infos));
|
||||
if (ret == WmErrorCode::WM_OK) {
|
||||
task->Resolve(env, CreateJsWindowLayoutInfoArrayObject(env, infos));
|
||||
TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s success", where);
|
||||
} else {
|
||||
task->Reject(env, JsErrUtils::CreateJsError(env, ret, "failed"));
|
||||
TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s failed", where);
|
||||
}
|
||||
};
|
||||
if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) {
|
||||
napiAsyncTask->Reject(env,
|
||||
CreateJsError(env, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value JsWindowManager::OnGetVisibleWindowInfo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = 4;
|
||||
@ -1353,6 +1399,7 @@ napi_value JsWindowManagerInit(napi_env env, napi_value exportObj)
|
||||
JsWindowManager::SetGestureNavigationEnabled);
|
||||
BindNativeFunction(env, exportObj, "setWaterMarkImage", moduleName, JsWindowManager::SetWaterMarkImage);
|
||||
BindNativeFunction(env, exportObj, "shiftAppWindowFocus", moduleName, JsWindowManager::ShiftAppWindowFocus);
|
||||
BindNativeFunction(env, exportObj, "getAllWindowLayoutInfo", moduleName, JsWindowManager::GetAllWindowLayoutInfo);
|
||||
BindNativeFunction(env, exportObj, "getVisibleWindowInfo", moduleName, JsWindowManager::GetVisibleWindowInfo);
|
||||
BindNativeFunction(env, exportObj, "getWindowsByCoordinate", moduleName, JsWindowManager::GetWindowsByCoordinate);
|
||||
BindNativeFunction(env, exportObj, "shiftAppWindowPointerEvent", moduleName,
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
static napi_value SetGestureNavigationEnabled(napi_env env, napi_callback_info info);
|
||||
static napi_value SetWaterMarkImage(napi_env env, napi_callback_info info);
|
||||
static napi_value ShiftAppWindowFocus(napi_env env, napi_callback_info info);
|
||||
static napi_value GetAllWindowLayoutInfo(napi_env env, napi_callback_info info);
|
||||
static napi_value GetVisibleWindowInfo(napi_env env, napi_callback_info info);
|
||||
static napi_value GetWindowsByCoordinate(napi_env env, napi_callback_info info);
|
||||
static napi_value ShiftAppWindowPointerEvent(napi_env env, napi_callback_info info);
|
||||
@ -66,6 +67,7 @@ private:
|
||||
static napi_value OnSetGestureNavigationEnabled(napi_env env, napi_callback_info info);
|
||||
static napi_value OnSetWaterMarkImage(napi_env env, napi_callback_info info);
|
||||
static napi_value OnShiftAppWindowFocus(napi_env env, napi_callback_info info);
|
||||
static napi_value OnGetAllWindowLayoutInfo(napi_env env, napi_callback_info info);
|
||||
static napi_value OnGetVisibleWindowInfo(napi_env env, napi_callback_info info);
|
||||
static napi_value OnGetWindowsByCoordinate(napi_env env, napi_callback_info info);
|
||||
static napi_value OnShiftAppWindowPointerEvent(napi_env env, napi_callback_info info);
|
||||
|
@ -544,6 +544,20 @@ static napi_value CreateJsSystemBarRegionTintObject(napi_env env, const SystemBa
|
||||
return objValue;
|
||||
}
|
||||
|
||||
napi_value CreateJsWindowLayoutInfoArrayObject(napi_env env, const std::vector<sptr<WindowLayoutInfo>>& infos)
|
||||
{
|
||||
napi_value arrayValue = nullptr;
|
||||
napi_create_array_with_length(env, infos.size(), &arrayValue);
|
||||
if (arrayValue == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "arrayValue is null");
|
||||
return nullptr;
|
||||
}
|
||||
for (size_t i = 0; i < infos.size(); i++) {
|
||||
napi_set_element(env, arrayValue, i, CreateJsWindowLayoutInfoObject(env, infos[i]));
|
||||
}
|
||||
return arrayValue;
|
||||
}
|
||||
|
||||
napi_value CreateJsWindowInfoArrayObject(napi_env env, const std::vector<sptr<WindowVisibilityInfo>>& infos)
|
||||
{
|
||||
napi_value arrayValue = nullptr;
|
||||
@ -603,6 +617,14 @@ bool ConvertDecorButtonStyleFromJs(napi_env env, napi_value jsObject, DecorButto
|
||||
return !emptyParam;
|
||||
}
|
||||
|
||||
napi_value CreateJsWindowLayoutInfoObject(napi_env env, const sptr<WindowLayoutInfo>& info)
|
||||
{
|
||||
napi_value objValue = nullptr;
|
||||
CHECK_NAPI_CREATE_OBJECT_RETURN_IF_NULL(env, objValue);
|
||||
napi_set_named_property(env, objValue, "rect", GetRectAndConvertToJsValue(env, info->rect));
|
||||
return objValue;
|
||||
}
|
||||
|
||||
napi_value CreateJsWindowInfoObject(napi_env env, const sptr<WindowVisibilityInfo>& info)
|
||||
{
|
||||
napi_value objValue = nullptr;
|
||||
|
@ -286,6 +286,8 @@ inline const std::map<ApiModalityType, ModalityType> JS_TO_NATIVE_MODALITY_TYPE_
|
||||
{ ApiModalityType::APPLICATION_MODALITY, ModalityType::APPLICATION_MODALITY },
|
||||
};
|
||||
|
||||
napi_value CreateJsWindowLayoutInfoArrayObject(napi_env env, const std::vector<sptr<WindowLayoutInfo>>& infos);
|
||||
napi_value CreateJsWindowLayoutInfoObject(napi_env env, const sptr<WindowLayoutInfo>& info);
|
||||
napi_value CreateJsWindowInfoArrayObject(napi_env env, const std::vector<sptr<WindowVisibilityInfo>>& infos);
|
||||
napi_value CreateJsWindowInfoObject(napi_env env, const sptr<WindowVisibilityInfo>& window);
|
||||
napi_value GetRectAndConvertToJsValue(napi_env env, const Rect& rect);
|
||||
|
@ -797,6 +797,34 @@ struct TitleButtonRect {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* @struct WindowLayoutInfo
|
||||
*
|
||||
* @brief Layout info for all windows on the screen.
|
||||
*/
|
||||
struct WindowLayoutInfo : public Parcelable {
|
||||
Rect rect = { 0, 0, 0, 0 };
|
||||
|
||||
bool Marshalling(Parcel& parcel) const override
|
||||
{
|
||||
return parcel.WriteInt32(rect.posX_) && parcel.WriteInt32(rect.posY_) &&
|
||||
parcel.WriteUint32(rect.width_) && parcel.WriteUint32(rect.height_);
|
||||
}
|
||||
|
||||
static WindowLayoutInfo* Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
WindowLayoutInfo* windowLayoutInfo = new WindowLayoutInfo;
|
||||
if (!parcel.ReadInt32(windowLayoutInfo->rect.posX_) ||
|
||||
!parcel.ReadInt32(windowLayoutInfo->rect.posY_) ||
|
||||
!parcel.ReadUint32(windowLayoutInfo->rect.width_) ||
|
||||
!parcel.ReadUint32(windowLayoutInfo->rect.height_)) {
|
||||
delete windowLayoutInfo;
|
||||
return nullptr;
|
||||
}
|
||||
return windowLayoutInfo;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Config of keyboard animation
|
||||
*/
|
||||
|
@ -104,6 +104,12 @@ napi_value JsWindowManager::ToggleShownStateForAllAppWindows(napi_env env, napi_
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value JsWindowManager::GetAllWindowLayoutInfo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TLOGI(WmsLogTag::WMS_ATTRIBUTE, "mock");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value JsWindowManager::SetWindowLayoutMode(napi_env env, napi_callback_info info)
|
||||
{
|
||||
WLOGI("mock: SetWindowLayoutMode");
|
||||
@ -242,6 +248,7 @@ napi_value JsWindowManagerInit(napi_env env, napi_value exportObj)
|
||||
BindNativeFunction(env, exportObj, "minimizeAll", moduleName, JsWindowManager::MinimizeAll);
|
||||
BindNativeFunction(env, exportObj, "toggleShownStateForAllAppWindows", moduleName,
|
||||
JsWindowManager::ToggleShownStateForAllAppWindows);
|
||||
BindNativeFunction(env, exportObj, "getAllWindowLayoutInfo", moduleName, JsWindowManager::GetAllWindowLayoutInfo);
|
||||
BindNativeFunction(env, exportObj, "setWindowLayoutMode", moduleName, JsWindowManager::SetWindowLayoutMode);
|
||||
BindNativeFunction(env, exportObj, "setGestureNavigationEnabled", moduleName,
|
||||
JsWindowManager::SetGestureNavigationEnabled);
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
static napi_value UnregisterWindowMangerCallback(napi_env env, napi_callback_info info);
|
||||
static napi_value GetTopWindow(napi_env env, napi_callback_info info);
|
||||
static napi_value GetLastWindow(napi_env env, napi_callback_info info);
|
||||
static napi_value GetAllWindowLayoutInfo(napi_env env, napi_callback_info info);
|
||||
static napi_value SetWindowLayoutMode(napi_env env, napi_callback_info info);
|
||||
static napi_value SetGestureNavigationEnabled(napi_env env, napi_callback_info info);
|
||||
static napi_value SetWaterMarkImage(napi_env env, napi_callback_info info);
|
||||
|
@ -459,6 +459,7 @@ public:
|
||||
*/
|
||||
WMError ReleaseForegroundSessionScreenLock() override;
|
||||
void DealwithDrawingContentChange(const std::vector<std::pair<uint64_t, bool>>& drawingContentChangeInfo);
|
||||
WMError GetAllWindowLayoutInfo(DisplayId displayId, std::vector<sptr<WindowLayoutInfo>>& infos) override;
|
||||
|
||||
/*
|
||||
* Multi Window
|
||||
@ -758,6 +759,10 @@ private:
|
||||
void UpdateWindowDrawingData(uint64_t surfaceId, int32_t pid, int32_t uid);
|
||||
bool GetSpecifiedDrawingData(uint64_t surfaceId, int32_t& pid, int32_t& uid);
|
||||
void RemoveSpecifiedDrawingData(uint64_t surfaceId);
|
||||
void FilterForGetAllWindowLayoutInfo(DisplayId displayId, bool isVirtualDisplay,
|
||||
std::vector<sptr<SceneSession>>& filteredSessions);
|
||||
bool IsGetWindowLayoutInfoNeeded(const sptr<SceneSession>& session) const;
|
||||
int32_t GetFoldLowerScreenPosY() const;
|
||||
|
||||
/*
|
||||
* Window Rotate Animation
|
||||
|
@ -96,6 +96,7 @@ public:
|
||||
TRANS_ID_GET_UI_CONTENT_REMOTE_OBJ,
|
||||
TRANS_ID_UPDATE_WINDOW_VISIBILITY_LISTENER,
|
||||
TRANS_ID_SHIFT_APP_WINDOW_FOCUS,
|
||||
TRANS_ID_GET_WINDOW_LAYOUT_INFO,
|
||||
TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID,
|
||||
TRANS_ID_ADD_EXTENSION_WINDOW_STAGE_TO_SCB,
|
||||
TRANS_ID_REMOVE_EXTENSION_WINDOW_STAGE_FROM_SCB,
|
||||
@ -248,6 +249,8 @@ public:
|
||||
{
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
WMError GetAllWindowLayoutInfo(DisplayId displayId,
|
||||
std::vector<sptr<WindowLayoutInfo>>& infos) override { return WMError::WM_OK; }
|
||||
WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) override { return WMError::WM_OK; }
|
||||
WMError SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller) override
|
||||
{
|
||||
|
@ -101,6 +101,7 @@ public:
|
||||
WMError NotifyWatchGestureConsumeResult(int32_t keyCode, bool isConsumed) override;
|
||||
WMError NotifyWatchFocusActiveChange(bool isActive) override;
|
||||
WMError GetParentMainWindowId(int32_t windowId, int32_t& mainWindowId) override;
|
||||
WMError GetAllWindowLayoutInfo(DisplayId displayId, std::vector<sptr<WindowLayoutInfo>>& infos) override;
|
||||
WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) override;
|
||||
WSError ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId) override;
|
||||
void AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage,
|
||||
|
@ -87,6 +87,7 @@ private:
|
||||
int HandleGetParentMainWindowId(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleUpdateSessionWindowVisibilityListener(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleShiftAppWindowFocus(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleGetAllWindowLayoutInfo(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleAddExtensionWindowStageToSCB(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleRemoveExtensionWindowStageFromSCB(MessageParcel& data, MessageParcel& reply);
|
||||
|
@ -64,6 +64,7 @@
|
||||
#include "anomaly_detection.h"
|
||||
#include "session/host/include/ability_info_manager.h"
|
||||
#include "session/host/include/multi_instance_manager.h"
|
||||
#include "common/include/fold_screen_state_internel.h"
|
||||
|
||||
#include "hidump_controller.h"
|
||||
|
||||
@ -123,6 +124,8 @@ const int32_t LOGICAL_DISPLACEMENT_32 = 32;
|
||||
constexpr int32_t GET_TOP_WINDOW_DELAY = 100;
|
||||
constexpr char SMALL_FOLD_PRODUCT_TYPE = '2';
|
||||
constexpr uint32_t MAX_SUB_WINDOW_LEVEL = 10;
|
||||
constexpr uint64_t DEFAULT_DISPLAY_ID = 0;
|
||||
constexpr uint64_t VIRTUAL_DISPLAY_ID = 999;
|
||||
|
||||
const std::map<std::string, OHOS::AppExecFwk::DisplayOrientation> STRING_TO_DISPLAY_ORIENTATION_MAP = {
|
||||
{"unspecified", OHOS::AppExecFwk::DisplayOrientation::UNSPECIFIED},
|
||||
@ -142,6 +145,11 @@ const std::map<std::string, OHOS::AppExecFwk::DisplayOrientation> STRING_TO_DISP
|
||||
{"follow_desktop", OHOS::AppExecFwk::DisplayOrientation::FOLLOW_DESKTOP},
|
||||
};
|
||||
|
||||
const std::unordered_set<std::string> LAYOUT_INFO_WHITELIST = {
|
||||
"SCBSmartDock",
|
||||
"SCBExtScreenDock"
|
||||
};
|
||||
|
||||
const std::chrono::milliseconds WAIT_TIME(10 * 1000); // 10 * 1000 wait for 10s
|
||||
|
||||
std::string GetCurrentTime()
|
||||
@ -10539,6 +10547,87 @@ void SceneSessionManager::NotifyUpdateRectAfterLayout()
|
||||
taskScheduler_->PostAsyncTask(task, __func__);
|
||||
}
|
||||
|
||||
WMError SceneSessionManager::GetAllWindowLayoutInfo(DisplayId displayId,
|
||||
std::vector<sptr<WindowLayoutInfo>>& infos)
|
||||
{
|
||||
auto task = [this, displayId, &infos]() mutable {
|
||||
bool isVirtualDisplay = false;
|
||||
if (displayId == VIRTUAL_DISPLAY_ID) {
|
||||
displayId = DEFAULT_DISPLAY_ID;
|
||||
isVirtualDisplay = true;
|
||||
}
|
||||
std::vector<sptr<SceneSession>> filteredSessions;
|
||||
FilterForGetAllWindowLayoutInfo(displayId, isVirtualDisplay, filteredSessions);
|
||||
for (const auto& session : filteredSessions) {
|
||||
Rect globalScaledRect;
|
||||
session->GetGlobalScaledRect(globalScaledRect);
|
||||
if (isVirtualDisplay) {
|
||||
globalScaledRect.posY_ -= GetFoldLowerScreenPosY();
|
||||
}
|
||||
auto windowLayoutInfo = sptr<WindowLayoutInfo>::MakeSptr();
|
||||
windowLayoutInfo->rect = globalScaledRect;
|
||||
infos.emplace_back(windowLayoutInfo);
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
};
|
||||
return taskScheduler_->PostSyncTask(task, __func__);
|
||||
}
|
||||
|
||||
void SceneSessionManager::FilterForGetAllWindowLayoutInfo(DisplayId displayId, bool isVirtualDisplay,
|
||||
std::vector<sptr<SceneSession>>& filteredSessions)
|
||||
{
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(sceneSessionMapMutex_);
|
||||
for (const auto& [_, session] : sceneSessionMap_) {
|
||||
if (session == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (session->GetSessionRect().IsInvalid()) {
|
||||
continue;
|
||||
}
|
||||
if (PcFoldScreenManager::GetInstance().GetScreenFoldStatus() == SuperFoldStatus::HALF_FOLDED &&
|
||||
session->GetSessionProperty()->GetDisplayId() == DEFAULT_DISPLAY_ID &&
|
||||
displayId == DEFAULT_DISPLAY_ID) {
|
||||
if (isVirtualDisplay &&
|
||||
session->GetSessionRect().posY_ + session->GetSessionRect().height_ < GetFoldLowerScreenPosY()) {
|
||||
continue;
|
||||
}
|
||||
if (!isVirtualDisplay && session->GetSessionRect().posY_ >= GetFoldLowerScreenPosY()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (IsGetWindowLayoutInfoNeeded(session) && session->GetSessionProperty()->GetDisplayId() == displayId &&
|
||||
session->GetVisibilityState() != WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION) {
|
||||
filteredSessions.emplace_back(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
std::sort(filteredSessions.begin(), filteredSessions.end(),
|
||||
[](const sptr<SceneSession>& lhs, const sptr<SceneSession>& rhs) {
|
||||
return lhs->GetZOrder() > rhs->GetZOrder();
|
||||
});
|
||||
}
|
||||
|
||||
int32_t SceneSessionManager::GetFoldLowerScreenPosY() const
|
||||
{
|
||||
const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] =
|
||||
PcFoldScreenManager::GetInstance().GetDisplayRects();
|
||||
constexpr int32_t SUPER_FOLD_DIVIDE_FACTOR = 2;
|
||||
return foldCreaseRect.height_ != 0 ?
|
||||
defaultDisplayRect.height_ - foldCreaseRect.height_ / SUPER_FOLD_DIVIDE_FACTOR + foldCreaseRect.height_ :
|
||||
defaultDisplayRect.height_;
|
||||
}
|
||||
|
||||
bool SceneSessionManager::IsGetWindowLayoutInfoNeeded(const sptr<SceneSession>& session) const
|
||||
{
|
||||
constexpr int32_t GROUP_ONE = 1;
|
||||
std::string name = session->GetWindowName();
|
||||
std::regex pattern("^(.*?)(\\d*)$"); // Remove last digit
|
||||
std::smatch matches;
|
||||
name = std::regex_search(name, matches, pattern) ? matches[GROUP_ONE] : name;
|
||||
return !session->GetSessionInfo().isSystem_ || LAYOUT_INFO_WHITELIST.find(name) != LAYOUT_INFO_WHITELIST.end();
|
||||
}
|
||||
|
||||
WMError SceneSessionManager::GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos)
|
||||
{
|
||||
if (!SessionPermission::IsSystemCalling()) {
|
||||
|
@ -1840,6 +1840,41 @@ WMError SceneSessionManagerProxy::GetParentMainWindowId(int32_t windowId, int32_
|
||||
return static_cast<WMError>(ret);
|
||||
}
|
||||
|
||||
WMError SceneSessionManagerProxy::GetAllWindowLayoutInfo(DisplayId displayId,
|
||||
std::vector<sptr<WindowLayoutInfo>>& infos)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write interfaceToken failed");
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (!data.WriteUint64(displayId)) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write displayId failed");
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (remote->SendRequest(static_cast<uint32_t>(
|
||||
SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_LAYOUT_INFO), data, reply, option) != ERR_NONE) {
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (!MarshallingHelper::UnmarshallingVectorParcelableObj<WindowLayoutInfo>(reply, infos)) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read window layout info failed");
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
int32_t errCode = 0;
|
||||
if (!reply.ReadInt32(errCode)) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read errcode failed");
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
return static_cast<WMError>(errCode);
|
||||
}
|
||||
|
||||
WMError SceneSessionManagerProxy::GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos)
|
||||
{
|
||||
MessageParcel data;
|
||||
|
@ -142,6 +142,8 @@ int SceneSessionManagerStub::ProcessRemoteRequest(uint32_t code, MessageParcel&
|
||||
return HandleUpdateSessionWindowVisibilityListener(data, reply);
|
||||
case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SHIFT_APP_WINDOW_FOCUS):
|
||||
return HandleShiftAppWindowFocus(data, reply);
|
||||
case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_LAYOUT_INFO):
|
||||
return HandleGetAllWindowLayoutInfo(data, reply);
|
||||
case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID):
|
||||
return HandleGetVisibilityWindowInfo(data, reply);
|
||||
case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_ADD_EXTENSION_WINDOW_STAGE_TO_SCB):
|
||||
@ -1137,6 +1139,26 @@ int SceneSessionManagerStub::HandleShiftAppWindowFocus(MessageParcel& data, Mess
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int SceneSessionManagerStub::HandleGetAllWindowLayoutInfo(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
uint64_t displayId = 0;
|
||||
if (!data.ReadUint64(displayId)) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to read displayId");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
std::vector<sptr<WindowLayoutInfo>> infos;
|
||||
WMError errCode = GetAllWindowLayoutInfo(displayId, infos);
|
||||
if (!MarshallingHelper::MarshallingVectorParcelableObj<WindowLayoutInfo>(reply, infos)) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to write window layout info");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write errCode fail");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int SceneSessionManagerStub::HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
std::vector<sptr<WindowVisibilityInfo>> infos;
|
||||
|
@ -75,6 +75,7 @@ public:
|
||||
|
||||
virtual WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos);
|
||||
virtual WMError GetUnreliableWindowInfo(int32_t windowId, std::vector<sptr<UnreliableWindowInfo>>& infos);
|
||||
virtual WMError GetAllWindowLayoutInfo(DisplayId displayId, std::vector<sptr<WindowLayoutInfo>>& infos);
|
||||
virtual WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos);
|
||||
virtual void MinimizeWindowsByLauncher(std::vector<uint32_t> windowIds, bool isAnimated,
|
||||
sptr<RSIWindowAnimationFinishedCallback>& finishCallback);
|
||||
|
@ -185,6 +185,14 @@ WMError WindowAdapter::GetUnreliableWindowInfo(int32_t windowId,
|
||||
return wmsProxy->GetUnreliableWindowInfo(windowId, infos);
|
||||
}
|
||||
|
||||
WMError WindowAdapter::GetAllWindowLayoutInfo(DisplayId displayId, std::vector<sptr<WindowLayoutInfo>>& infos)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
|
||||
auto wmsProxy = GetWindowManagerServiceProxy();
|
||||
CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
|
||||
return wmsProxy->GetAllWindowLayoutInfo(displayId, infos);
|
||||
}
|
||||
|
||||
WMError WindowAdapter::GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
|
||||
|
@ -1119,6 +1119,15 @@ WMError WindowManager::GetUnreliableWindowInfo(int32_t windowId,
|
||||
return ret;
|
||||
}
|
||||
|
||||
WMError WindowManager::GetAllWindowLayoutInfo(DisplayId displayId, std::vector<sptr<WindowLayoutInfo>>& infos) const
|
||||
{
|
||||
WMError ret = SingletonContainer::Get<WindowAdapter>().GetAllWindowLayoutInfo(displayId, infos);
|
||||
if (ret != WMError::WM_OK) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "failed");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
WMError WindowManager::GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) const
|
||||
{
|
||||
WMError ret = SingletonContainer::Get<WindowAdapter>().GetVisibilityWindowInfo(infos);
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
TRANS_ID_UPDATE_LAYOUT_MODE,
|
||||
TRANS_ID_UPDATE_PROPERTY,
|
||||
TRANS_ID_GET_ACCESSIBILITY_WINDOW_INFO_ID,
|
||||
TRANS_ID_GET_WINDOW_LAYOUT_INFO,
|
||||
TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID,
|
||||
TRANS_ID_ANIMATION_SET_CONTROLLER,
|
||||
TRANS_ID_GET_SYSTEM_CONFIG,
|
||||
@ -117,6 +118,8 @@ public:
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent) = 0;
|
||||
virtual WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos) = 0;
|
||||
virtual WMError GetUnreliableWindowInfo(int32_t windowId, std::vector<sptr<UnreliableWindowInfo>>& infos) = 0;
|
||||
virtual WMError GetAllWindowLayoutInfo(DisplayId displayId,
|
||||
std::vector<sptr<WindowLayoutInfo>>& infos) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
|
||||
virtual WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) = 0;
|
||||
virtual WMError SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller) = 0;
|
||||
virtual WMError GetSystemConfig(SystemConfig& systemConfig) = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user