mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 06:50:40 +00:00
commit
ad886b30dd
@ -727,15 +727,15 @@ HWTEST_F(WindowLayoutTest, ResizeDataRoute, Function | MediumTest | Level3)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FixRectByAspectRatio
|
||||
* @tc.desc: test FixRectByAspectRatio
|
||||
* @tc.name: AdjustRectByAspectRatio
|
||||
* @tc.desc: test AdjustRectByAspectRatio
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowLayoutTest, FixRectByAspectRatio, Function | MediumTest | Level0)
|
||||
HWTEST_F(WindowLayoutTest, AdjustRectByAspectRatio, Function | MediumTest | Level0)
|
||||
{
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::FixRectByAspectRatio begin ###");
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::AdjustRectByAspectRatio begin ###");
|
||||
sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
|
||||
option->SetWindowName("FixRectByAspectRatio");
|
||||
option->SetWindowName("AdjustRectByAspectRatio");
|
||||
option->SetWindowType(WindowType::APP_WINDOW_BASE);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
sptr<WindowSceneSessionImpl> windowSceneSessionImpl = sptr<WindowSceneSessionImpl>::MakeSptr(option);
|
||||
@ -775,12 +775,12 @@ HWTEST_F(WindowLayoutTest, FixRectByAspectRatio, Function | MediumTest | Level0)
|
||||
WSError wsRet2 = session->UpdateSessionRect(wsRect, SizeChangeReason::RESIZE, false);
|
||||
EXPECT_EQ(WSError::WS_OK, wsRet2);
|
||||
usleep(WAIT_SERVERAL_FRAMES);
|
||||
WSError wsRet3 = session->UpdateRect(wsRect, SizeChangeReason::RESIZE, "FixRectByAspectRatio", nullptr);
|
||||
WSError wsRet3 = session->UpdateRect(wsRect, SizeChangeReason::RESIZE, "AdjustRectByAspectRatio", nullptr);
|
||||
EXPECT_EQ(WSError::WS_OK, wsRet3);
|
||||
usleep(WAIT_SERVERAL_FRAMES);
|
||||
WSError wsRet4 = session->SetAspectRatio(ratio);
|
||||
EXPECT_EQ(WSError::WS_OK, wsRet4);
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::FixRectByAspectRatio end ###");
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::AdjustRectByAspectRatio end ###");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -362,8 +362,6 @@ public:
|
||||
bool GetShowWhenLockedFlagValue() const;
|
||||
bool IsFloatingWindowAppType() const;
|
||||
bool IsNeedDefaultAnimation() const;
|
||||
bool IsDirtyWindow();
|
||||
bool IsDirtyDragWindow();
|
||||
void SetSystemTouchable(bool touchable) override;
|
||||
bool IsVisibleForAccessibility() const;
|
||||
void SetStartingWindowExitAnimationFlag(bool enable);
|
||||
@ -528,13 +526,14 @@ public:
|
||||
*/
|
||||
WSError SetSplitButtonVisible(bool isVisible);
|
||||
|
||||
void SetRequestNextVsyncFunc(const RequestVsyncFunc& func);
|
||||
void OnNextVsyncDragReceived();
|
||||
|
||||
/**
|
||||
* Window Layout
|
||||
*/
|
||||
bool IsDirtyWindow();
|
||||
bool IsDirtyDragWindow();
|
||||
void ResetSizeChangeReasonIfDirty();
|
||||
void SetRequestNextVsyncFunc(RequestVsyncFunc&& func);
|
||||
void OnNextVsyncReceivedWhenDrag();
|
||||
void RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreenChangeFunc&& callback);
|
||||
bool SetFrameGravity(Gravity gravity);
|
||||
|
||||
@ -687,9 +686,6 @@ private:
|
||||
bool isSupportDragInPcCompatibleMode, bool isGlobal, bool needFlush = true);
|
||||
void HandleCompatibleModeDrag(WSRect& rect, SizeChangeReason reason,
|
||||
bool isSupportDragInPcCompatibleMode, bool isGlobal, bool needFlush);
|
||||
void FixRectByLimits(WindowLimits limits, WSRect& rect, float ratio, bool isDecor, float vpr);
|
||||
bool FixRectByAspectRatio(WSRect& rect);
|
||||
bool SaveAspectRatio(float ratio);
|
||||
void NotifyPropertyWhenConnect();
|
||||
WSError RaiseAppMainWindowToTop() override;
|
||||
void UpdateWinRectForSystemBar(WSRect& rect);
|
||||
@ -698,8 +694,6 @@ private:
|
||||
bool IsFullScreenMovable();
|
||||
bool IsMovable();
|
||||
void HandleCastScreenConnection(SessionInfo& info, sptr<SceneSession> session);
|
||||
void UpdateSessionRectInner(const WSRect& rect, SizeChangeReason reason);
|
||||
void UpdateRectForDrag(WSRect& rect);
|
||||
WMError HandleUpdatePropertyByAction(const sptr<WindowSessionProperty>& property,
|
||||
WSPropertyChangeAction action);
|
||||
WMError HandleActionUpdateTurnScreenOn(const sptr<WindowSessionProperty>& property,
|
||||
@ -795,6 +789,15 @@ private:
|
||||
std::map<int32_t, ExtensionWindowFlags> extWindowFlagsMap_;
|
||||
std::vector<UIExtensionTokenInfo> extensionTokenInfos_;
|
||||
|
||||
/**
|
||||
* Window Layout
|
||||
*/
|
||||
void AdjustRectByLimits(WindowLimits limits, float ratio, bool isDecor, float vpr, WSRect& rect);
|
||||
bool AdjustRectByAspectRatio(WSRect& rect);
|
||||
bool SaveAspectRatio(float ratio);
|
||||
void UpdateSessionRectInner(const WSRect& rect, SizeChangeReason reason);
|
||||
WSError UpdateRectForDrag(const WSRect& rect);
|
||||
|
||||
/**
|
||||
* Window Decor
|
||||
*/
|
||||
|
@ -23,14 +23,14 @@
|
||||
#include <event_handler.h>
|
||||
|
||||
#include "interfaces/include/ws_common.h"
|
||||
#include "occupied_area_change_info.h"
|
||||
#include "pattern_detach_callback_interface.h"
|
||||
#include "session/container/include/zidl/session_stage_interface.h"
|
||||
#include "session/host/include/zidl/session_stub.h"
|
||||
#include "session/host/include/scene_persistence.h"
|
||||
#include "wm_common.h"
|
||||
#include "occupied_area_change_info.h"
|
||||
#include "window_visibility_info.h"
|
||||
#include "pattern_detach_callback_interface.h"
|
||||
#include "vsync_station.h"
|
||||
#include "window_visibility_info.h"
|
||||
#include "wm_common.h"
|
||||
|
||||
namespace OHOS::MMI {
|
||||
class PointerEvent;
|
||||
@ -88,7 +88,7 @@ using NotifyFrameLayoutFinishFunc = std::function<void()>;
|
||||
using VisibilityChangedDetectFunc = std::function<void(const int32_t pid, const bool isVisible,
|
||||
const bool newIsVisible)>;
|
||||
using AcquireRotateAnimationConfigFunc = std::function<void(RotateAnimationConfig& config)>;
|
||||
using RequestVsyncFunc = std::function<void(std::shared_ptr<VsyncCallback>& callback)>;
|
||||
using RequestVsyncFunc = std::function<void(const std::shared_ptr<VsyncCallback>& callback)>;
|
||||
|
||||
class ILifecycleListener {
|
||||
public:
|
||||
@ -244,8 +244,6 @@ public:
|
||||
std::string GetWindowName() const;
|
||||
WSRect GetLastLayoutRect() const;
|
||||
WSRect GetLayoutRect() const;
|
||||
void SetClientRect(const WSRect& rect);
|
||||
WSRect GetClientRect() const;
|
||||
|
||||
virtual WSError SetActive(bool active);
|
||||
virtual WSError UpdateSizeChangeReason(SizeChangeReason reason);
|
||||
@ -513,8 +511,6 @@ public:
|
||||
void SetUIStateDirty(bool dirty);
|
||||
void SetMainSessionUIStateDirty(bool dirty);
|
||||
bool GetUIStateDirty() const;
|
||||
void ResetDirtyFlags();
|
||||
void ResetDragDirtyFlags();
|
||||
static bool IsScbCoreEnabled();
|
||||
static void SetScbCoreEnabled(bool enabled);
|
||||
bool IsVisible() const;
|
||||
@ -542,6 +538,10 @@ public:
|
||||
/**
|
||||
* Window Layout
|
||||
*/
|
||||
void SetClientRect(const WSRect& rect);
|
||||
WSRect GetClientRect() const;
|
||||
void ResetDirtyFlags();
|
||||
void ResetDragDirtyFlags();
|
||||
void SetClientDragEnable(bool dragEnable);
|
||||
std::optional<bool> GetClientDragEnable() const;
|
||||
|
||||
@ -611,11 +611,6 @@ protected:
|
||||
std::list<sptr<SessionLifeCycleTask>> lifeCycleTaskQueue_;
|
||||
bool isActive_ = false;
|
||||
bool isSystemActive_ = false;
|
||||
WSRect winRect_;
|
||||
WSRect clientRect_; // rect saved when prelayout or notify client to update rect
|
||||
WSRect lastLayoutRect_; // rect saved when go background
|
||||
WSRect layoutRect_; // rect of root view
|
||||
WSRect globalRect_; // globalRect include translate
|
||||
mutable std::mutex globalRectMutex_;
|
||||
WSRectF bounds_;
|
||||
Rotation rotation_;
|
||||
@ -623,9 +618,7 @@ protected:
|
||||
float offsetY_ = 0.0f;
|
||||
std::atomic_bool isExitSplitOnBackground_ = false;
|
||||
bool isVisible_ = false;
|
||||
SizeChangeReason reason_ = SizeChangeReason::UNDEFINED;
|
||||
|
||||
NotifySessionRectChangeFunc sessionRectChangeFunc_;
|
||||
NotifyChangeSessionVisibilityWithStatusBarFunc changeSessionVisibilityWithStatusBarFunc_;
|
||||
NotifySessionStateChangeFunc sessionStateChangeFunc_;
|
||||
NotifyBufferAvailableChangeFunc bufferAvailableChangeFunc_;
|
||||
@ -668,8 +661,6 @@ protected:
|
||||
*/
|
||||
AcquireRotateAnimationConfigFunc acquireRotateAnimationConfigFunc_;
|
||||
|
||||
RequestVsyncFunc requestNextVsyncFunc_;
|
||||
|
||||
SystemSessionConfig systemConfig_;
|
||||
bool needSnapshot_ = false;
|
||||
float snapshotScale_ = 0.5;
|
||||
@ -678,6 +669,14 @@ protected:
|
||||
/**
|
||||
* Window Layout
|
||||
*/
|
||||
RequestVsyncFunc requestNextVsyncFunc_;
|
||||
WSRect winRect_;
|
||||
WSRect clientRect_; // rect saved when prelayout or notify client to update rect
|
||||
WSRect lastLayoutRect_; // rect saved when go background
|
||||
WSRect layoutRect_; // rect of root view
|
||||
WSRect globalRect_; // globalRect include translate
|
||||
SizeChangeReason reason_ = SizeChangeReason::UNDEFINED;
|
||||
NotifySessionRectChangeFunc sessionRectChangeFunc_;
|
||||
float clientScaleX_ = 1.0f;
|
||||
float clientScaleY_ = 1.0f;
|
||||
float clientPivotX_ = 0.0f;
|
||||
|
@ -338,13 +338,13 @@ WSError SceneSession::Foreground(
|
||||
return ForegroundTask(property);
|
||||
}
|
||||
|
||||
void SceneSession::SetRequestNextVsyncFunc(const RequestVsyncFunc& func)
|
||||
void SceneSession::SetRequestNextVsyncFunc(RequestVsyncFunc&& func)
|
||||
{
|
||||
if (func == nullptr) {
|
||||
TLOGI(WmsLogTag::DEFAULT, "func is nullptr");
|
||||
return;
|
||||
}
|
||||
requestNextVsyncFunc_ = func;
|
||||
requestNextVsyncFunc_ = std::move(func);
|
||||
}
|
||||
|
||||
WSError SceneSession::ForegroundTask(const sptr<WindowSessionProperty>& property)
|
||||
@ -964,7 +964,7 @@ static WSError CheckAspectRatioValid(const sptr<SceneSession>& session, float ra
|
||||
/** @note @window.layout */
|
||||
WSError SceneSession::SetAspectRatio(float ratio)
|
||||
{
|
||||
auto task = [weakThis = wptr(this), ratio]() {
|
||||
auto task = [weakThis = wptr(this), ratio] {
|
||||
auto session = weakThis.promote();
|
||||
if (!session) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "session is null");
|
||||
@ -989,13 +989,13 @@ WSError SceneSession::SetAspectRatio(float ratio)
|
||||
session->moveDragController_->SetAspectRatio(ratio);
|
||||
}
|
||||
session->SaveAspectRatio(session->aspectRatio_);
|
||||
WSRect fixedRect = session->winRect_;
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "Before fixing, the id:%{public}d, the current rect: %{public}s, "
|
||||
"ratio: %{public}f", session->GetPersistentId(), fixedRect.ToString().c_str(), ratio);
|
||||
if (session->FixRectByAspectRatio(fixedRect)) {
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "After fixing, the id:%{public}d, the fixed rect: %{public}s",
|
||||
session->GetPersistentId(), fixedRect.ToString().c_str());
|
||||
session->NotifySessionRectChange(fixedRect, SizeChangeReason::RESIZE);
|
||||
WSRect adjustedRect = session->winRect_;
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "Before adjusting, the id:%{public}d, the current rect:%{public}s, "
|
||||
"ratio:%{public}f", session->GetPersistentId(), adjustedRect.ToString().c_str(), ratio);
|
||||
if (session->AdjustRectByAspectRatio(adjustedRect)) {
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "After adjusting, the id:%{public}d, the adjusted rect:%{public}s",
|
||||
session->GetPersistentId(), adjustedRect.ToString().c_str());
|
||||
session->NotifySessionRectChange(adjustedRect, SizeChangeReason::RESIZE);
|
||||
}
|
||||
return WSError::WS_OK;
|
||||
};
|
||||
@ -1006,39 +1006,44 @@ WSError SceneSession::SetAspectRatio(float ratio)
|
||||
WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason,
|
||||
const std::string& updateReason, const std::shared_ptr<RSTransaction>& rsTransaction)
|
||||
{
|
||||
auto task = [weakThis = wptr(this), rect, reason, rsTransaction, updateReason]() {
|
||||
const char* const funcName = __func__;
|
||||
auto task = [weakThis = wptr(this), rect, reason, rsTransaction, updateReason, funcName] {
|
||||
auto session = weakThis.promote();
|
||||
if (!session) {
|
||||
WLOGFE("session is null");
|
||||
return WSError::WS_ERROR_DESTROYED_OBJECT;
|
||||
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: session is null", funcName);
|
||||
return;
|
||||
}
|
||||
if (session->reason_ == SizeChangeReason::DRAG) {
|
||||
TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: skip drag reason update id:%{public}d rect:%{public}s",
|
||||
funcName, session->GetPersistentId(), rect.ToString().c_str());
|
||||
return;
|
||||
}
|
||||
if (session->winRect_ == rect && session->reason_ != SizeChangeReason::DRAG_END &&
|
||||
(session->GetWindowType() != WindowType::WINDOW_TYPE_KEYBOARD_PANEL &&
|
||||
session->GetWindowType() != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT)) {
|
||||
if (!session->sessionStage_) {
|
||||
TLOGD(WmsLogTag::WMS_LAYOUT, "skip same rect update id:%{public}d rect:%{public}s",
|
||||
session->GetPersistentId(), rect.ToString().c_str());
|
||||
return WSError::WS_OK;
|
||||
TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: skip same rect update id:%{public}d rect:%{public}s",
|
||||
funcName, session->GetPersistentId(), rect.ToString().c_str());
|
||||
return;
|
||||
} else if (session->GetClientRect() == rect) {
|
||||
TLOGD(WmsLogTag::WMS_LAYOUT, "skip same rect update id:%{public}d rect:%{public}s "
|
||||
"clientRect:%{public}s", session->GetPersistentId(), rect.ToString().c_str(),
|
||||
TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: skip same rect update id:%{public}d rect:%{public}s "
|
||||
"clientRect:%{public}s", funcName, session->GetPersistentId(), rect.ToString().c_str(),
|
||||
session->GetClientRect().ToString().c_str());
|
||||
return WSError::WS_OK;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (rect.IsInvalid()) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "id:%{public}d rect:%{public}s is invalid",
|
||||
session->GetPersistentId(), rect.ToString().c_str());
|
||||
return WSError::WS_ERROR_INVALID_PARAM;
|
||||
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: id:%{public}d rect:%{public}s is invalid",
|
||||
funcName, session->GetPersistentId(), rect.ToString().c_str());
|
||||
return;
|
||||
}
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER,
|
||||
"SceneSession::UpdateRect%d [%d, %d, %u, %u]",
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::UpdateRect %d [%d, %d, %u, %u]",
|
||||
session->GetPersistentId(), rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
// position change no need to notify client, since frame layout finish will notify
|
||||
if (NearEqual(rect.width_, session->winRect_.width_) && NearEqual(rect.height_, session->winRect_.height_) &&
|
||||
(session->reason_ != SizeChangeReason::MOVE || !session->rectChangeListenerRegistered_)) {
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "position change no need notify client id:%{public}d, rect:%{public}s, "
|
||||
"preRect: %{public}s",
|
||||
TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s: position change no need notify client id:%{public}d, "
|
||||
"rect:%{public}s, preRect:%{public}s", funcName,
|
||||
session->GetPersistentId(), rect.ToString().c_str(), session->winRect_.ToString().c_str());
|
||||
session->winRect_ = rect;
|
||||
} else {
|
||||
@ -1046,13 +1051,12 @@ WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason,
|
||||
session->NotifyClientToUpdateRect(updateReason, rsTransaction);
|
||||
}
|
||||
session->dirtyFlags_ |= static_cast<uint32_t>(SessionUIDirtyFlag::RECT);
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "UpdateRect id:%{public}d, reason:%{public}d %{public}s, rect:%{public}s, "
|
||||
"clientRect:%{public}s", session->GetPersistentId(), session->reason_, updateReason.c_str(),
|
||||
TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s: id:%{public}d, reason:%{public}d %{public}s, "
|
||||
"rect:%{public}s, clientRect:%{public}s",
|
||||
funcName, session->GetPersistentId(), session->reason_, updateReason.c_str(),
|
||||
rect.ToString().c_str(), session->GetClientRect().ToString().c_str());
|
||||
|
||||
return WSError::WS_OK;
|
||||
};
|
||||
PostTask(task, "UpdateRect" + GetRectInfo(rect));
|
||||
PostTask(task, funcName + GetRectInfo(rect));
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
@ -1454,22 +1458,21 @@ WSError SceneSession::UpdateClientRect(const WSRect& rect)
|
||||
auto session = weakThis.promote();
|
||||
if (!session) {
|
||||
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: session is null", funcName);
|
||||
return WSError::WS_ERROR_DESTROYED_OBJECT;
|
||||
return;
|
||||
}
|
||||
if (rect.IsInvalid()) {
|
||||
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: id:%{public}d rect:%{public}s is invalid",
|
||||
funcName, session->GetPersistentId(), rect.ToString().c_str());
|
||||
return WSError::WS_ERROR_INVALID_PARAM;
|
||||
return;
|
||||
}
|
||||
if (rect == session->GetClientRect()) {
|
||||
TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: id:%{public}d skip same rect",
|
||||
funcName, session->GetPersistentId());
|
||||
return WSError::WS_DO_NOTHING;
|
||||
return;
|
||||
}
|
||||
session->SetClientRect(rect);
|
||||
return WSError::WS_OK;
|
||||
};
|
||||
PostTask(task, "UpdateClientRect" + GetRectInfo(rect));
|
||||
PostTask(task, funcName + GetRectInfo(rect));
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
@ -2463,7 +2466,7 @@ bool SceneSession::SaveAspectRatio(float ratio)
|
||||
return false;
|
||||
}
|
||||
|
||||
void SceneSession::FixRectByLimits(WindowLimits limits, WSRect& rect, float ratio, bool isDecor, float vpr)
|
||||
void SceneSession::AdjustRectByLimits(WindowLimits limits, float ratio, bool isDecor, float vpr, WSRect& rect)
|
||||
{
|
||||
if (isDecor) {
|
||||
rect.width_ = SessionUtils::ToLayoutWidth(rect.width_, vpr);
|
||||
@ -2491,7 +2494,7 @@ void SceneSession::FixRectByLimits(WindowLimits limits, WSRect& rect, float rati
|
||||
rect.width_ = SessionUtils::ToWinWidth(rect.width_, vpr);
|
||||
}
|
||||
}
|
||||
bool SceneSession::FixRectByAspectRatio(WSRect& rect)
|
||||
bool SceneSession::AdjustRectByAspectRatio(WSRect& rect)
|
||||
{
|
||||
const int tolerancePx = 2; // 2: tolerance delta pixel value, unit: px
|
||||
WSRect originalRect = rect;
|
||||
@ -2533,7 +2536,7 @@ bool SceneSession::FixRectByAspectRatio(WSRect& rect)
|
||||
rect.height_ = rect.width_ / aspectRatio_;
|
||||
}
|
||||
}
|
||||
FixRectByLimits(property->GetWindowLimits(), rect, aspectRatio_, IsDecorEnable(), vpr);
|
||||
AdjustRectByLimits(property->GetWindowLimits(), aspectRatio_, IsDecorEnable(), vpr, rect);
|
||||
if (std::abs(static_cast<int32_t>(originalRect.width_) - static_cast<int32_t>(rect.width_)) <= tolerancePx &&
|
||||
std::abs(static_cast<int32_t>(originalRect.height_) - static_cast<int32_t>(rect.height_)) <= tolerancePx) {
|
||||
rect = originalRect;
|
||||
@ -2660,21 +2663,25 @@ void SceneSession::HandleMoveDragSurfaceBounds(WSRect& rect, WSRect& globalRect,
|
||||
if (reason != SizeChangeReason::MOVE) {
|
||||
UpdateRectForDrag(rect);
|
||||
std::shared_ptr<VsyncCallback> nextVsyncDragCallback = std::make_shared<VsyncCallback>();
|
||||
nextVsyncDragCallback ->onCallback = [weakThis = wptr(this), funcName = __func__](int64_t, int64_t) {
|
||||
nextVsyncDragCallback->onCallback = [weakThis = wptr(this), funcName = __func__](int64_t, int64_t) {
|
||||
auto session = weakThis.promote();
|
||||
if (!session) {
|
||||
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s, session is null", funcName);
|
||||
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: session is null", funcName);
|
||||
return;
|
||||
}
|
||||
session->OnNextVsyncDragReceived();
|
||||
session->OnNextVsyncReceivedWhenDrag();
|
||||
};
|
||||
requestNextVsyncFunc_(nextVsyncDragCallback);
|
||||
if (requestNextVsyncFunc_) {
|
||||
requestNextVsyncFunc_(nextVsyncDragCallback);
|
||||
} else {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "Func is null, could not request vsync");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSession::OnNextVsyncDragReceived()
|
||||
void SceneSession::OnNextVsyncReceivedWhenDrag()
|
||||
{
|
||||
PostTask([weakThis = wptr(this)]() {
|
||||
PostTask([weakThis = wptr(this)] {
|
||||
auto session = weakThis.promote();
|
||||
if (!session) {
|
||||
TLOGNE(WmsLogTag::WMS_LAYOUT, "session is null");
|
||||
@ -2839,10 +2846,19 @@ void SceneSession::HandleMoveDragSurfaceNode(SizeChangeReason reason)
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSession::UpdateRectForDrag(WSRect& rect)
|
||||
WSError SceneSession::UpdateRectForDrag(const WSRect& rect)
|
||||
{
|
||||
winRect_ = rect;
|
||||
dirtyFlags_ |= static_cast<uint32_t>(SessionUIDirtyFlag::DRAG_RECT);
|
||||
const char* const funcName = __func__;
|
||||
return PostSyncTask([weakThis = wptr(this), rect, funcName] {
|
||||
auto sceneSession = weakThis.promote();
|
||||
if (!sceneSession) {
|
||||
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: session is null", funcName);
|
||||
return WSError::WS_ERROR_DESTROYED_OBJECT;
|
||||
}
|
||||
sceneSession->winRect_ = rect;
|
||||
sceneSession->dirtyFlags_ |= static_cast<uint32_t>(SessionUIDirtyFlag::DRAG_RECT);
|
||||
return WSError::WS_OK;
|
||||
}, funcName);
|
||||
}
|
||||
|
||||
void SceneSession::UpdateWinRectForSystemBar(WSRect& rect)
|
||||
|
@ -847,7 +847,7 @@ WMError SessionProxy::GetGlobalScaledRect(Rect& globalScaledRect)
|
||||
/** @note @window.layout */
|
||||
WSError SessionProxy::UpdateClientRect(const WSRect& rect)
|
||||
{
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "rect:[%{public}d, %{public}d, %{public}u, %{public}u]",
|
||||
TLOGD(WmsLogTag::WMS_LAYOUT, "rect:[%{public}d, %{public}d, %{public}d, %{public}d]",
|
||||
rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -856,10 +856,10 @@ WSError SessionProxy::UpdateClientRect(const WSRect& rect)
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (!((data.WriteInt32(static_cast<int32_t>(rect.posX_))) &&
|
||||
(data.WriteInt32(static_cast<int32_t>(rect.posY_))) &&
|
||||
(data.WriteUint32(static_cast<uint32_t>(rect.width_))) &&
|
||||
(data.WriteUint32(static_cast<uint32_t>(rect.height_))))) {
|
||||
if (!data.WriteInt32(rect.posX_) ||
|
||||
!data.WriteInt32(rect.posY_) ||
|
||||
!data.WriteInt32(rect.width_) ||
|
||||
!data.WriteInt32(rect.height_)) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "Write rect failed");
|
||||
return WSError::WS_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
@ -735,15 +735,15 @@ int SessionStub::HandleUpdateClientRect(MessageParcel& data, MessageParcel& repl
|
||||
TLOGD(WmsLogTag::WMS_LAYOUT, "In");
|
||||
int32_t posX = 0;
|
||||
int32_t posY = 0;
|
||||
uint32_t width = 0;
|
||||
uint32_t height = 0;
|
||||
if (!data.ReadInt32(posX) || !data.ReadInt32(posY) || !data.ReadUint32(width) || !data.ReadUint32(height)) {
|
||||
int32_t width = 0;
|
||||
int32_t height = 0;
|
||||
if (!data.ReadInt32(posX) || !data.ReadInt32(posY) || !data.ReadInt32(width) || !data.ReadInt32(height)) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "read rect failed");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
WSRect rect = { posX, posY, width, height };
|
||||
WSError errCode = UpdateClientRect(rect);
|
||||
reply.WriteUint32(static_cast<uint32_t>(errCode));
|
||||
reply.WriteInt32(static_cast<int32_t>(errCode));
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
|
@ -515,8 +515,6 @@ public:
|
||||
WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
|
||||
std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap) override;
|
||||
|
||||
std::shared_ptr<VsyncCallback> vsyncCallback_ = nullptr;
|
||||
|
||||
/*
|
||||
* Specific Window
|
||||
*/
|
||||
@ -557,9 +555,6 @@ private:
|
||||
void ConfigSnapshotScale();
|
||||
void ConfigFreeMultiWindow();
|
||||
void LoadFreeMultiWindowConfig(bool enable);
|
||||
void RegisterRequestVsyncFunc(const sptr<SceneSession>& sceneSession);
|
||||
std::shared_ptr<VsyncStation> vsyncStation_ = nullptr;
|
||||
void InitVsyncStation();
|
||||
|
||||
std::tuple<std::string, std::vector<float>> CreateCurve(const WindowSceneConfig::ConfigItem& curveConfig);
|
||||
void LoadKeyboardAnimation(const WindowSceneConfig::ConfigItem& item, KeyboardSceneAnimationConfig& config);
|
||||
@ -1011,6 +1006,14 @@ private:
|
||||
void RemoveProcessWatermarkPid(int32_t pid);
|
||||
|
||||
/**
|
||||
* Window Layout
|
||||
*/
|
||||
std::shared_ptr<VsyncCallback> vsyncCallback_ = nullptr;
|
||||
std::shared_ptr<VsyncStation> vsyncStation_ = nullptr;
|
||||
void InitVsyncStation();
|
||||
void RegisterRequestVsyncFunc(const sptr<SceneSession>& sceneSession);
|
||||
|
||||
/*
|
||||
* Window Snapshot
|
||||
*/
|
||||
std::unordered_set<int32_t> snapshotSkipPidSet_ GUARDED_BY(SCENE_GUARD); // ONLY Accessed on OS_sceneSession thread
|
||||
|
@ -4343,11 +4343,10 @@ void SceneSessionManager::RegisterRequestVsyncFunc(const sptr<SceneSession>& sce
|
||||
TLOGE(WmsLogTag::DEFAULT, "session is nullptr");
|
||||
return;
|
||||
}
|
||||
RequestVsyncFunc requestVsyncFunc = [this](std::shared_ptr<VsyncCallback> callback) {
|
||||
sceneSession->SetRequestNextVsyncFunc([this](const std::shared_ptr<VsyncCallback>& callback) {
|
||||
vsyncStation_->RequestVsync(callback);
|
||||
};
|
||||
sceneSession->SetRequestNextVsyncFunc(requestVsyncFunc);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
void SceneSessionManager::RegisterAcquireRotateAnimationConfigFunc(const sptr<SceneSession>& sceneSession)
|
||||
{
|
||||
|
@ -886,11 +886,11 @@ HWTEST_F(SceneSessionTest, NotifySessionRectChange, Function | SmallTest | Level
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FixRectByAspectRatio
|
||||
* @tc.desc: FixRectByAspectRatio
|
||||
* @tc.name: AdjustRectByAspectRatio
|
||||
* @tc.desc: AdjustRectByAspectRatio
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SceneSessionTest, FixRectByAspectRatio, Function | SmallTest | Level2)
|
||||
HWTEST_F(SceneSessionTest, AdjustRectByAspectRatio, Function | SmallTest | Level2)
|
||||
{
|
||||
SessionInfo info;
|
||||
info.abilityName_ = "Background01";
|
||||
@ -904,7 +904,7 @@ HWTEST_F(SceneSessionTest, FixRectByAspectRatio, Function | SmallTest | Level2)
|
||||
sceneSession = new (std::nothrow) SceneSession(info, nullptr);
|
||||
EXPECT_NE(sceneSession, nullptr);
|
||||
WSRect originalRect_ = { 0, 0, 0, 0 };
|
||||
ASSERT_EQ(false, sceneSession->FixRectByAspectRatio(originalRect_));
|
||||
ASSERT_EQ(false, sceneSession->AdjustRectByAspectRatio(originalRect_));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1648,7 +1648,7 @@ HWTEST_F(SceneSessionTest2, TransferPointerEvent03, Function | SmallTest | Level
|
||||
float ratio = 0.0;
|
||||
bool isDecor = true;
|
||||
float vpr = 0.0;
|
||||
sceneSession->FixRectByLimits(limits, rect, ratio, isDecor, vpr);
|
||||
sceneSession->AdjustRectByLimits(limits, ratio, isDecor, vpr, rect);
|
||||
sceneSession->SetPipActionEvent("pointerEvent", 0);
|
||||
|
||||
auto property = sptr<WindowSessionProperty>::MakeSptr();
|
||||
@ -1660,7 +1660,7 @@ HWTEST_F(SceneSessionTest2, TransferPointerEvent03, Function | SmallTest | Level
|
||||
sceneSession->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
|
||||
property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
|
||||
property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
|
||||
sceneSession->FixRectByLimits(limits, rect, ratio, false, vpr);
|
||||
sceneSession->AdjustRectByLimits(limits, ratio, false, vpr, rect);
|
||||
ASSERT_EQ(WSError::WS_OK, sceneSession->SetPipActionEvent("pointerEvent", 0));
|
||||
}
|
||||
|
||||
|
@ -742,42 +742,42 @@ HWTEST_F(SceneSessionTest5, GetSystemAvoidArea02, Function | SmallTest | Level2)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FixRectByAspectRatio
|
||||
* @tc.desc: FixRectByAspectRatio function01
|
||||
* @tc.name: AdjustRectByAspectRatio
|
||||
* @tc.desc: AdjustRectByAspectRatio function01
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SceneSessionTest5, FixRectByAspectRatio, Function | SmallTest | Level2)
|
||||
HWTEST_F(SceneSessionTest5, AdjustRectByAspectRatio, Function | SmallTest | Level2)
|
||||
{
|
||||
SessionInfo info;
|
||||
info.abilityName_ = "FixRectByAspectRatio";
|
||||
info.bundleName_ = "FixRectByAspectRatio";
|
||||
info.abilityName_ = "AdjustRectByAspectRatio";
|
||||
info.bundleName_ = "AdjustRectByAspectRatio";
|
||||
info.isSystem_ = false;
|
||||
sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
|
||||
EXPECT_NE(session, nullptr);
|
||||
sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
|
||||
session->SetSessionProperty(nullptr);
|
||||
WSRect rect;
|
||||
EXPECT_EQ(false, session->FixRectByAspectRatio(rect));
|
||||
EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
|
||||
session->SetSessionProperty(property);
|
||||
property->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
|
||||
EXPECT_EQ(false, session->FixRectByAspectRatio(rect));
|
||||
EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
|
||||
property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
property->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
|
||||
EXPECT_EQ(false, session->FixRectByAspectRatio(rect));
|
||||
EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
|
||||
property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
|
||||
EXPECT_EQ(true, session->FixRectByAspectRatio(rect));
|
||||
EXPECT_EQ(true, session->AdjustRectByAspectRatio(rect));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FixRectByAspectRatio01
|
||||
* @tc.desc: FixRectByAspectRatio function01
|
||||
* @tc.name: AdjustRectByAspectRatio01
|
||||
* @tc.desc: AdjustRectByAspectRatio function01
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SceneSessionTest5, FixRectByAspectRatio01, Function | SmallTest | Level2)
|
||||
HWTEST_F(SceneSessionTest5, AdjustRectByAspectRatio01, Function | SmallTest | Level2)
|
||||
{
|
||||
SessionInfo info;
|
||||
info.abilityName_ = "FixRectByAspectRatio01";
|
||||
info.bundleName_ = "FixRectByAspectRatio01";
|
||||
info.abilityName_ = "AdjustRectByAspectRatio01";
|
||||
info.bundleName_ = "AdjustRectByAspectRatio01";
|
||||
info.isSystem_ = false;
|
||||
sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
|
||||
EXPECT_NE(session, nullptr);
|
||||
@ -791,14 +791,14 @@ HWTEST_F(SceneSessionTest5, FixRectByAspectRatio01, Function | SmallTest | Level
|
||||
systemConfig.isSystemDecorEnable_ = true;
|
||||
systemConfig.decorWindowModeSupportType_ = 2;
|
||||
session->SetSystemConfig(systemConfig);
|
||||
EXPECT_EQ(true, session->FixRectByAspectRatio(rect));
|
||||
EXPECT_EQ(true, session->AdjustRectByAspectRatio(rect));
|
||||
|
||||
systemConfig.isSystemDecorEnable_ = false;
|
||||
EXPECT_EQ(false, session->FixRectByAspectRatio(rect));
|
||||
EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
|
||||
|
||||
systemConfig.isSystemDecorEnable_ = true;
|
||||
session->SetSessionProperty(nullptr);
|
||||
EXPECT_EQ(false, session->FixRectByAspectRatio(rect));
|
||||
EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -813,9 +813,7 @@ HWTEST_F(SceneSessionTest5, OnMoveDragCallback, Function | SmallTest | Level2)
|
||||
info.bundleName_ = "OnMoveDragCallback";
|
||||
info.isSystem_ = false;
|
||||
sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
|
||||
EXPECT_NE(session, nullptr);
|
||||
RequestVsyncFunc requestVsyncFunc = [](std::shared_ptr<VsyncCallback>& callback){};
|
||||
session->SetRequestNextVsyncFunc(requestVsyncFunc);
|
||||
session->SetRequestNextVsyncFunc([](const std::shared_ptr<VsyncCallback>& callback) {});
|
||||
EXPECT_NE(nullptr, session->requestNextVsyncFunc_);
|
||||
session->moveDragController_ = nullptr;
|
||||
SizeChangeReason reason = { SizeChangeReason::DRAG };
|
||||
@ -1663,18 +1661,15 @@ HWTEST_F(SceneSessionTest5, SetRequestNextVsyncFunc01, Function | SmallTest | Le
|
||||
info.abilityName_ = "test1";
|
||||
info.bundleName_ = "test1";
|
||||
sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
|
||||
EXPECT_NE(session, nullptr);
|
||||
|
||||
RequestVsyncFunc requestVsyncFunc;
|
||||
session->SetRequestNextVsyncFunc(requestVsyncFunc);
|
||||
session->SetRequestNextVsyncFunc(nullptr);
|
||||
ASSERT_EQ(nullptr, session->requestNextVsyncFunc_);
|
||||
|
||||
RequestVsyncFunc requestVsyncFunc1 = [](std::shared_ptr<VsyncCallback>& callback) {
|
||||
session->SetRequestNextVsyncFunc([](const std::shared_ptr<VsyncCallback>& callback) {
|
||||
SessionInfo info1;
|
||||
info1.abilityName_ = "test2";
|
||||
info1.bundleName_ = "test2";
|
||||
};
|
||||
session->SetRequestNextVsyncFunc(requestVsyncFunc1);
|
||||
});
|
||||
ASSERT_NE(nullptr, session->requestNextVsyncFunc_);
|
||||
}
|
||||
|
||||
|
@ -859,8 +859,8 @@ HWTEST_F(SessionStubTest, HandleUpdateClientRect01, Function | SmallTest | Level
|
||||
|
||||
data.WriteInt32(100);
|
||||
data.WriteInt32(100);
|
||||
data.WriteUint32(800);
|
||||
data.WriteUint32(800);
|
||||
data.WriteInt32(800);
|
||||
data.WriteInt32(800);
|
||||
res = session_->HandleUpdateClientRect(data, reply);
|
||||
ASSERT_EQ(ERR_NONE, res);
|
||||
}
|
||||
|
@ -388,7 +388,6 @@ protected:
|
||||
bool useUniqueDensity_ { false };
|
||||
float virtualPixelRatio_ { 1.0f };
|
||||
bool escKeyEventTriggered_ = false;
|
||||
std::atomic_bool isDragTaskUpdateDone_ = true;
|
||||
// Check whether the UIExtensionAbility process is started
|
||||
static bool isUIExtensionAbilityProcess_;
|
||||
virtual WMError SetKeyEventFilter(KeyEventFilterFunc filter) override;
|
||||
@ -421,6 +420,7 @@ protected:
|
||||
/**
|
||||
* Window Layout
|
||||
*/
|
||||
std::atomic_bool isDragTaskPostDone_ = true;
|
||||
void FlushLayoutSize(int32_t width, int32_t height) override;
|
||||
sptr<FutureCallback> layoutCallback_ = nullptr;
|
||||
void UpdateVirtualPixelRatio(const sptr<Display>& display);
|
||||
|
@ -1065,8 +1065,7 @@ void WindowSceneSessionImpl::PreLayoutOnShow(WindowType type, const sptr<Display
|
||||
property_->GetWindowName().c_str(), GetPersistentId(), type, requestRect.ToString().c_str());
|
||||
if (requestRect.width_ != 0 && requestRect.height_ != 0) {
|
||||
UpdateViewportConfig(requestRect, WindowSizeChangeReason::RESIZE, nullptr, info);
|
||||
auto hostSession = GetHostSession();
|
||||
if (hostSession) {
|
||||
if (auto hostSession = GetHostSession()) {
|
||||
WSRect wsRect = { requestRect.posX_, requestRect.posY_, requestRect.width_, requestRect.height_ };
|
||||
property_->SetWindowRect(requestRect);
|
||||
hostSession->UpdateClientRect(wsRect);
|
||||
|
@ -812,7 +812,7 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect&
|
||||
}
|
||||
if (wmReason == WindowSizeChangeReason::DRAG) {
|
||||
window->UpdateRectForOtherReasonTask(window->GetRect(), preRect, wmReason, rsTransaction);
|
||||
window->isDragTaskUpdateDone_ = true;
|
||||
window->isDragTaskPostDone_.store(true);
|
||||
} else {
|
||||
window->UpdateRectForOtherReasonTask(wmRect, preRect, wmReason, rsTransaction);
|
||||
}
|
||||
@ -821,9 +821,9 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect&
|
||||
}
|
||||
};
|
||||
if (wmReason == WindowSizeChangeReason::DRAG) {
|
||||
if (isDragTaskUpdateDone_) {
|
||||
bool isDragTaskPostDone = true;
|
||||
if (isDragTaskPostDone_.compare_exchange_strong(isDragTaskPostDone, false)) {
|
||||
handler_->PostTask(task, "WMS_WindowSessionImpl_UpdateRectForOtherReason");
|
||||
isDragTaskUpdateDone_ = false;
|
||||
}
|
||||
} else {
|
||||
handler_->PostTask(task, "WMS_WindowSessionImpl_UpdateRectForOtherReason");
|
||||
|
Loading…
Reference in New Issue
Block a user