mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 06:50:40 +00:00
commit
e7582e5ffa
@ -28,6 +28,7 @@ using ScreenId = uint64_t;
|
||||
namespace {
|
||||
constexpr DisplayId DISPLAY_ID_INVALID = -1ULL;
|
||||
constexpr ScreenId SCREEN_ID_INVALID = -1ULL;
|
||||
constexpr ScreenId SCREEN_ID_FAKE = 999;
|
||||
constexpr ScreenId ERROR_ID_NOT_SYSTEM_APP = -202ULL;
|
||||
constexpr int DOT_PER_INCH = 160;
|
||||
const static std::string DEFAULT_SCREEN_NAME = "buildIn";
|
||||
@ -35,6 +36,7 @@ constexpr int DOT_PER_INCH_MAXIMUM_VALUE = 1000;
|
||||
constexpr int DOT_PER_INCH_MINIMUM_VALUE = 80;
|
||||
constexpr uint32_t BASELINE_DENSITY = 160;
|
||||
constexpr float INCH_TO_MM = 25.4f;
|
||||
constexpr uint32_t HALF_SCREEN_PARAM = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -317,6 +319,7 @@ enum class DisplayChangeEvent : uint32_t {
|
||||
UPDATE_ORIENTATION_FROM_WINDOW,
|
||||
UPDATE_ROTATION_FROM_WINDOW,
|
||||
UPDATE_REFRESHRATE,
|
||||
SUPER_FOLD_RESOLUTION_CHANGED,
|
||||
UNKNOWN,
|
||||
};
|
||||
|
||||
|
@ -60,6 +60,8 @@ napi_value JsScreenUtils::CreateJsScreenProperty(napi_env env, const ScreenPrope
|
||||
CreateJsValue(env, screenProperty.GetPropertyChangeReason()));
|
||||
napi_set_named_property(env, objValue, "rotation", CreateJsValue(env, screenProperty.GetRotation()));
|
||||
napi_set_named_property(env, objValue, "bounds", CreateJsRRect(env, screenProperty.GetBounds()));
|
||||
napi_set_named_property(env, objValue, "fakeBounds", CreateJsRRect(env, screenProperty.GetFakeBounds()));
|
||||
napi_set_named_property(env, objValue, "isFakeInUse", CreateJsValue(env, screenProperty.GetIsFakeInUse()));
|
||||
return objValue;
|
||||
}
|
||||
|
||||
@ -119,6 +121,10 @@ napi_value JsScreenUtils::CreateJsScreenPropertyChangeReason(napi_env env)
|
||||
static_cast<int32_t>(ScreenPropertyChangeReason::FOLD_SCREEN_FOLDING)));
|
||||
napi_set_named_property(env, objValue, "VIRTUAL_SCREEN_RESIZE", CreateJsValue(env,
|
||||
static_cast<int32_t>(ScreenPropertyChangeReason::VIRTUAL_SCREEN_RESIZE)));
|
||||
napi_set_named_property(env, objValue, "RELATIVE_POSITION_CHANGE", CreateJsValue(env,
|
||||
static_cast<int32_t>(ScreenPropertyChangeReason::RELATIVE_POSITION_CHANGE)));
|
||||
napi_set_named_property(env, objValue, "SUPER_FOLD_STATUS_CHANGE", CreateJsValue(env,
|
||||
static_cast<int32_t>(ScreenPropertyChangeReason::SUPER_FOLD_STATUS_CHANGE)));
|
||||
return objValue;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <atomic>
|
||||
#include "session/screen/include/screen_session.h"
|
||||
|
||||
#include "dm_common.h"
|
||||
#include "wm_single_instance.h"
|
||||
@ -74,6 +75,12 @@ private:
|
||||
static void DoExpandedToKeyboard(SuperFoldStatusChangeEvents event);
|
||||
|
||||
void SetCurrentStatus(SuperFoldStatus curState);
|
||||
|
||||
void HandleDisplayNotify(SuperFoldStatusChangeEvents changeEvent);
|
||||
void HandleExtendToHalfFoldDisplayNotify(sptr<ScreenSession> screenSession);
|
||||
void HandleHalfFoldToExtendDisplayNotify(sptr<ScreenSession> screenSession);
|
||||
void HandleKeyboardOnDisplayNotify(sptr<ScreenSession> screenSession);
|
||||
void HandleKeyboardOffDisplayNotify(sptr<ScreenSession> screenSession);
|
||||
};
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
|
@ -207,6 +207,8 @@ public:
|
||||
void ScreenOffCVNotify(void);
|
||||
void DisablePowerOffRenderControl(ScreenId screenId) override;
|
||||
bool SetVirtualScreenStatus(ScreenId screenId, VirtualScreenStatus screenStatus) override;
|
||||
sptr<ScreenSession> GetOrCreateFakeScreenSession(sptr<ScreenSession> screenSession);
|
||||
void InitFakeScreenSession(sptr<ScreenSession> screenSession);
|
||||
|
||||
// Fold Screen
|
||||
void SetFoldDisplayMode(const FoldDisplayMode displayMode) override;
|
||||
|
@ -90,7 +90,7 @@ SuperFoldStateManager::SuperFoldStateManager()
|
||||
|
||||
AddStateManagerMap(SuperFoldStatus::EXPANDED,
|
||||
SuperFoldStatusChangeEvents::KEYBOARD_ON,
|
||||
SuperFoldStatus::KEYBOARD,
|
||||
SuperFoldStatus::HALF_FOLDED,
|
||||
&SuperFoldStateManager::DoExpandedToKeyboard);
|
||||
|
||||
AddStateManagerMap(SuperFoldStatus::KEYBOARD,
|
||||
@ -147,6 +147,7 @@ void SuperFoldStateManager::HandleSuperFoldStatusChange(SuperFoldStatusChangeEve
|
||||
|
||||
if (isTransfer && action) {
|
||||
action(event);
|
||||
HandleDisplayNotify(event);
|
||||
TransferState(nextState);
|
||||
// notify
|
||||
auto screenSession = ScreenSessionManager::GetInstance().GetDefaultScreenSession();
|
||||
@ -171,5 +172,103 @@ void SuperFoldStateManager::SetCurrentStatus(SuperFoldStatus curState)
|
||||
curState_.store(curState);
|
||||
}
|
||||
|
||||
void SuperFoldStateManager::HandleDisplayNotify(SuperFoldStatusChangeEvents changeEvent)
|
||||
{
|
||||
TLOGI(WmsLogTag::DMS, "changeEvent: %{public}d", static_cast<uint32_t>(changeEvent));
|
||||
sptr<ScreenSession> screenSession =
|
||||
ScreenSessionManager::GetInstance().GetDefaultScreenSession();
|
||||
if (screenSession == nullptr) {
|
||||
TLOGE(WmsLogTag::DMS, "screen session is null");
|
||||
return;
|
||||
}
|
||||
if (screenSession->GetFakeScreenSession() == nullptr) {
|
||||
TLOGE(WmsLogTag::DMS, "fake screen session is null");
|
||||
return;
|
||||
}
|
||||
switch (changeEvent) {
|
||||
case SuperFoldStatusChangeEvents::ANGLE_CHANGE_HALF_FOLDED:
|
||||
HandleExtendToHalfFoldDisplayNotify(screenSession);
|
||||
TLOGI(WmsLogTag::DMS, "handle extend change to half fold");
|
||||
break;
|
||||
case SuperFoldStatusChangeEvents::ANGLE_CHANGE_EXPANDED:
|
||||
HandleHalfFoldToExtendDisplayNotify(screenSession);
|
||||
TLOGI(WmsLogTag::DMS, "handle half fold change to extend");
|
||||
break;
|
||||
case SuperFoldStatusChangeEvents::KEYBOARD_ON:
|
||||
HandleKeyboardOnDisplayNotify(screenSession);
|
||||
TLOGI(WmsLogTag::DMS, "handle keyboard on");
|
||||
break;
|
||||
case SuperFoldStatusChangeEvents::KEYBOARD_OFF:
|
||||
HandleKeyboardOffDisplayNotify(screenSession);
|
||||
TLOGI(WmsLogTag::DMS, "handle keyboard off");
|
||||
break;
|
||||
default:
|
||||
TLOGE(WmsLogTag::DMS, "nothing to handle");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void SuperFoldStateManager::HandleExtendToHalfFoldDisplayNotify(sptr<ScreenSession> screenSession)
|
||||
{
|
||||
ScreenProperty screenProperty = screenSession->GetScreenProperty();
|
||||
uint32_t screenWidth = screenProperty.GetFakeBounds().rect_.GetWidth();
|
||||
uint32_t screenHeight = screenProperty.GetFakeBounds().rect_.GetHeight();
|
||||
screenSession->UpdatePropertyByResolution(screenWidth, screenHeight);
|
||||
screenSession->UpdatePropertyByFakeInUse(true);
|
||||
ScreenSessionManager::GetInstance().NotifyDisplayChanged(
|
||||
screenSession->ConvertToDisplayInfo(), DisplayChangeEvent::SUPER_FOLD_RESOLUTION_CHANGED);
|
||||
sptr<ScreenSession> fakeScreenSession = screenSession->GetFakeScreenSession();
|
||||
ScreenSessionManager::GetInstance().NotifyDisplayCreate(
|
||||
fakeScreenSession->ConvertToDisplayInfo());
|
||||
screenSession->PropertyChange(screenSession->GetScreenProperty(),
|
||||
ScreenPropertyChangeReason::SUPER_FOLD_STATUS_CHANGE);
|
||||
}
|
||||
|
||||
void SuperFoldStateManager::HandleHalfFoldToExtendDisplayNotify(sptr<ScreenSession> screenSession)
|
||||
{
|
||||
ScreenProperty screenProperty = screenSession->GetScreenProperty();
|
||||
uint32_t screenWidth = screenProperty.GetFakeBounds().rect_.GetWidth();
|
||||
uint32_t screenHeight = screenProperty.GetFakeBounds().rect_.GetHeight();
|
||||
screenSession->UpdatePropertyByResolution(screenWidth, screenHeight * HALF_SCREEN_PARAM);
|
||||
screenSession->UpdatePropertyByFakeInUse(false);
|
||||
sptr<ScreenSession> fakeScreenSession = screenSession->GetFakeScreenSession();
|
||||
sptr<DisplayInfo> fakeDisplayInfo = fakeScreenSession->ConvertToDisplayInfo();
|
||||
if (fakeDisplayInfo == nullptr) {
|
||||
TLOGE(WmsLogTag::DMS, "get fake display failed");
|
||||
return;
|
||||
}
|
||||
DisplayId fakeDisplayId = fakeDisplayInfo->GetDisplayId();
|
||||
ScreenSessionManager::GetInstance().NotifyDisplayDestroy(fakeDisplayId);
|
||||
ScreenSessionManager::GetInstance().NotifyDisplayChanged(
|
||||
screenSession->ConvertToDisplayInfo(),
|
||||
DisplayChangeEvent::SUPER_FOLD_RESOLUTION_CHANGED);
|
||||
screenSession->PropertyChange(screenSession->GetScreenProperty(),
|
||||
ScreenPropertyChangeReason::SUPER_FOLD_STATUS_CHANGE);
|
||||
}
|
||||
|
||||
void SuperFoldStateManager::HandleKeyboardOnDisplayNotify(sptr<ScreenSession> screenSession)
|
||||
{
|
||||
screenSession->UpdatePropertyByFakeInUse(false);
|
||||
sptr<ScreenSession> fakeScreenSession = screenSession->GetFakeScreenSession();
|
||||
sptr<DisplayInfo> fakeDisplayInfo = fakeScreenSession->ConvertToDisplayInfo();
|
||||
if (fakeDisplayInfo == nullptr) {
|
||||
TLOGE(WmsLogTag::DMS, "get fake display failed");
|
||||
return;
|
||||
}
|
||||
DisplayId fakeDisplayId = fakeDisplayInfo->GetDisplayId();
|
||||
ScreenSessionManager::GetInstance().NotifyDisplayDestroy(fakeDisplayId);
|
||||
screenSession->PropertyChange(screenSession->GetScreenProperty(),
|
||||
ScreenPropertyChangeReason::SUPER_FOLD_STATUS_CHANGE);
|
||||
}
|
||||
|
||||
void SuperFoldStateManager::HandleKeyboardOffDisplayNotify(sptr<ScreenSession> screenSession)
|
||||
{
|
||||
screenSession->UpdatePropertyByFakeInUse(true);
|
||||
sptr<ScreenSession> fakeScreenSession = screenSession->GetFakeScreenSession();
|
||||
ScreenSessionManager::GetInstance().NotifyDisplayCreate(
|
||||
fakeScreenSession->ConvertToDisplayInfo());
|
||||
screenSession->PropertyChange(screenSession->GetScreenProperty(),
|
||||
ScreenPropertyChangeReason::SUPER_FOLD_STATUS_CHANGE);
|
||||
}
|
||||
} // Rosen
|
||||
} // OHOS
|
@ -1466,6 +1466,9 @@ sptr<ScreenSession> ScreenSessionManager::GetScreenSessionInner(ScreenId screenI
|
||||
screenSession->SetScreenCombination(ScreenCombination::SCREEN_MAIN);
|
||||
screenSession->SetIsInternal(true);
|
||||
screenSession->SetIsCurrentInUse(true);
|
||||
if (FoldScreenStateInternel::IsSuperFoldDisplayDevice()) {
|
||||
InitFakeScreenSession(screenSession);
|
||||
}
|
||||
return screenSession;
|
||||
}
|
||||
|
||||
@ -5960,6 +5963,38 @@ bool ScreenSessionManager::SetVirtualScreenStatus(ScreenId screenId, VirtualScre
|
||||
return rsInterface_.SetVirtualScreenStatus(rsScreenId, screenStatus);
|
||||
}
|
||||
|
||||
sptr<ScreenSession> ScreenSessionManager::GetOrCreateFakeScreenSession(sptr<ScreenSession> screenSession)
|
||||
{
|
||||
sptr<ScreenSession> fakeScreenSession = screenSession->GetFakeScreenSession();
|
||||
if (fakeScreenSession != nullptr) {
|
||||
TLOGI(WmsLogTag::DMS, "fake screen session has exist");
|
||||
return fakeScreenSession;
|
||||
}
|
||||
ScreenProperty screenProperty = screenSession->GetScreenProperty();
|
||||
fakeScreenSession = new ScreenSession(SCREEN_ID_FAKE, screenProperty, SCREEN_ID_INVALID);
|
||||
return fakeScreenSession;
|
||||
}
|
||||
|
||||
void ScreenSessionManager::InitFakeScreenSession(sptr<ScreenSession> screenSession)
|
||||
{
|
||||
if (screenSession == nullptr) {
|
||||
TLOGE(WmsLogTag::DMS, "screen session is null");
|
||||
return;
|
||||
}
|
||||
sptr<ScreenSession> fakeScreenSession = GetOrCreateFakeScreenSession(screenSession);
|
||||
if (fakeScreenSession == nullptr) {
|
||||
TLOGE(WmsLogTag::DMS, "get or create fake screen session failed");
|
||||
return;
|
||||
}
|
||||
ScreenProperty screenProperty = screenSession->GetScreenProperty();
|
||||
uint32_t screenWidth = screenProperty.GetBounds().rect_.GetWidth();
|
||||
uint32_t screenHeight = screenProperty.GetBounds().rect_.GetHeight();
|
||||
screenSession->UpdatePropertyByFakeBounds(screenWidth, screenHeight / HALF_SCREEN_PARAM);
|
||||
screenSession->UpdatePropertyByFakeInUse(true);
|
||||
screenSession->SetFakeScreenSession(fakeScreenSession);
|
||||
screenSession->SetIsFakeInUse(true);
|
||||
}
|
||||
|
||||
DMError ScreenSessionManager::SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid,
|
||||
std::vector<uint64_t>& windowIdList)
|
||||
{
|
||||
|
@ -33,6 +33,7 @@ enum class ScreenPropertyChangeReason : uint32_t {
|
||||
FOLD_SCREEN_FOLDING,
|
||||
VIRTUAL_SCREEN_RESIZE,
|
||||
RELATIVE_POSITION_CHANGE,
|
||||
SUPER_FOLD_STATUS_CHANGE,
|
||||
};
|
||||
class ScreenProperty {
|
||||
public:
|
||||
@ -48,6 +49,12 @@ public:
|
||||
void SetPhyBounds(const RRect& phyBounds);
|
||||
RRect GetPhyBounds() const;
|
||||
|
||||
void SetFakeBounds(const RRect& fakeBounds);
|
||||
RRect GetFakeBounds() const;
|
||||
|
||||
void SetIsFakeInUse(bool isFakeInUse);
|
||||
bool GetIsFakeInUse() const;
|
||||
|
||||
void SetScaleX(float scaleX);
|
||||
float GetScaleX() const;
|
||||
|
||||
@ -155,6 +162,8 @@ private:
|
||||
float physicalRotation_ { 0.0f };
|
||||
RRect bounds_;
|
||||
RRect phyBounds_;
|
||||
RRect fakeBounds_;
|
||||
bool isFakeInUse_ = false;
|
||||
|
||||
float scaleX_ { 1.0f };
|
||||
float scaleY_ { 1.0f };
|
||||
|
@ -135,6 +135,8 @@ public:
|
||||
ScreenId GetScreenId();
|
||||
ScreenId GetRSScreenId();
|
||||
ScreenProperty GetScreenProperty() const;
|
||||
void SetFakeScreenSession(sptr<ScreenSession> screenSession);
|
||||
sptr<ScreenSession> GetFakeScreenSession() const;
|
||||
void UpdatePropertyByActiveMode();
|
||||
std::shared_ptr<RSDisplayNode> GetDisplayNode() const;
|
||||
void ReleaseDisplayNode();
|
||||
@ -176,11 +178,13 @@ public:
|
||||
void UpdateToInputManager(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode);
|
||||
void UpdatePropertyAfterRotation(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode);
|
||||
void UpdatePropertyOnly(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode);
|
||||
void UpdatePropertyByFakeInUse(bool isFakeInUse);
|
||||
ScreenProperty UpdatePropertyByFoldControl(const ScreenProperty& updatedProperty);
|
||||
void UpdateDisplayState(DisplayState displayState);
|
||||
void UpdateRefreshRate(uint32_t refreshRate);
|
||||
uint32_t GetRefreshRate();
|
||||
void UpdatePropertyByResolution(uint32_t width, uint32_t height);
|
||||
void UpdatePropertyByFakeBounds(uint32_t width, uint32_t height);
|
||||
void SetName(std::string name);
|
||||
void Resize(uint32_t width, uint32_t height);
|
||||
|
||||
@ -201,6 +205,8 @@ public:
|
||||
bool GetIsInternal() const;
|
||||
void SetIsCurrentInUse(bool isInUse);
|
||||
bool GetIsCurrentInUse() const;
|
||||
void SetIsFakeInUse(bool isFakeInUse);
|
||||
bool GetIsFakeInUse() const;
|
||||
|
||||
bool isPrimary_ { false };
|
||||
bool isInternal_ { false };
|
||||
@ -253,6 +259,7 @@ private:
|
||||
ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE };
|
||||
VirtualScreenFlag screenFlag_ { VirtualScreenFlag::DEFAULT };
|
||||
bool hasPrivateWindowForeground_ = false;
|
||||
bool isFakeInUse_ = false;
|
||||
mutable std::shared_mutex displayNodeMutex_;
|
||||
std::atomic<bool> touchEnabled_ { true };
|
||||
std::function<void(float)> updateToInputManagerCallback_ = nullptr;
|
||||
@ -266,6 +273,7 @@ private:
|
||||
SetScreenSceneDpiFunc setScreenSceneDpiCallback_ = nullptr;
|
||||
DestroyScreenSceneFunc destroyScreenSceneCallback_ = nullptr;
|
||||
void ReportNotifyModeChange(DisplayOrientation displayOrientation);
|
||||
sptr<ScreenSession> fakeScreenSession_ = nullptr;
|
||||
};
|
||||
|
||||
class ScreenSessionGroup : public ScreenSession {
|
||||
|
@ -59,6 +59,26 @@ RRect ScreenProperty::GetBounds() const
|
||||
return bounds_;
|
||||
}
|
||||
|
||||
void ScreenProperty::SetFakeBounds(const RRect& fakeBounds)
|
||||
{
|
||||
fakeBounds_ = fakeBounds;
|
||||
}
|
||||
|
||||
RRect ScreenProperty::GetFakeBounds() const
|
||||
{
|
||||
return fakeBounds_;
|
||||
}
|
||||
|
||||
void ScreenProperty::SetIsFakeInUse(bool isFakeInUse)
|
||||
{
|
||||
isFakeInUse_ = isFakeInUse;
|
||||
}
|
||||
|
||||
bool ScreenProperty::GetIsFakeInUse() const
|
||||
{
|
||||
return isFakeInUse_;
|
||||
}
|
||||
|
||||
void ScreenProperty::SetScaleX(float scaleX)
|
||||
{
|
||||
scaleX_ = scaleX;
|
||||
|
@ -300,6 +300,26 @@ bool ScreenSession::GetIsCurrentInUse() const
|
||||
return isInUse_;
|
||||
}
|
||||
|
||||
void ScreenSession::SetIsFakeInUse(bool isFakeInUse)
|
||||
{
|
||||
isFakeInUse_ = isFakeInUse;
|
||||
}
|
||||
|
||||
bool ScreenSession::GetIsFakeInUse() const
|
||||
{
|
||||
return isFakeInUse_;
|
||||
}
|
||||
|
||||
void ScreenSession::SetFakeScreenSession(sptr<ScreenSession> fakeScreenSession)
|
||||
{
|
||||
fakeScreenSession_ = fakeScreenSession;
|
||||
}
|
||||
|
||||
sptr<ScreenSession> ScreenSession::GetFakeScreenSession() const
|
||||
{
|
||||
return fakeScreenSession_;
|
||||
}
|
||||
|
||||
std::string ScreenSession::GetName()
|
||||
{
|
||||
return name_;
|
||||
@ -394,6 +414,14 @@ void ScreenSession::UpdatePropertyByResolution(uint32_t width, uint32_t height)
|
||||
property_.SetBounds(screenBounds);
|
||||
}
|
||||
|
||||
void ScreenSession::UpdatePropertyByFakeBounds(uint32_t width, uint32_t height)
|
||||
{
|
||||
auto screenFakeBounds = property_.GetFakeBounds();
|
||||
screenFakeBounds.rect_.width_ = width;
|
||||
screenFakeBounds.rect_.height_ = height;
|
||||
property_.SetFakeBounds(screenFakeBounds);
|
||||
}
|
||||
|
||||
std::shared_ptr<RSDisplayNode> ScreenSession::GetDisplayNode() const
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> displayNodeLock(displayNodeMutex_);
|
||||
@ -657,6 +685,11 @@ void ScreenSession::UpdatePropertyOnly(RRect bounds, int rotation, FoldDisplayMo
|
||||
rotation, displayOrientation);
|
||||
}
|
||||
|
||||
void ScreenSession::UpdatePropertyByFakeInUse(bool isFakeInUse)
|
||||
{
|
||||
property_.SetIsFakeInUse(isFakeInUse);
|
||||
}
|
||||
|
||||
void ScreenSession::ReportNotifyModeChange(DisplayOrientation displayOrientation)
|
||||
{
|
||||
int32_t vhMode = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user