add for keyboard animation

Signed-off-by: l00574490 <liuqi149@huawei.com>
Change-Id: I1b52f44783f820c8123455a6747c156194ba7bcd
This commit is contained in:
l00574490 2023-03-30 21:21:20 +08:00
parent 66216748a3
commit 24f58c2077
29 changed files with 437 additions and 115 deletions

View File

@ -69,7 +69,7 @@ public:
class IWindowChangeListener : virtual public RefBase {
public:
virtual void OnSizeChange(Rect rect, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction = nullptr) {}
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) {}
virtual void OnModeChange(WindowMode mode, bool hasDeco = true) {}
};
@ -98,6 +98,8 @@ class OccupiedAreaChangeInfo : public Parcelable {
public:
OccupiedAreaChangeInfo() = default;
OccupiedAreaChangeInfo(OccupiedAreaType type, Rect rect) : type_(type), rect_(rect) {};
OccupiedAreaChangeInfo(OccupiedAreaType type, Rect rect, uint32_t safeHeight)
: type_(type), rect_(rect), safeHeight_(safeHeight) {};
~OccupiedAreaChangeInfo() = default;
virtual bool Marshalling(Parcel& parcel) const override;
@ -105,11 +107,13 @@ public:
OccupiedAreaType type_ = OccupiedAreaType::TYPE_INPUT;
Rect rect_ = { 0, 0, 0, 0 };
uint32_t safeHeight_ = 0;
};
class IOccupiedAreaChangeListener : virtual public RefBase {
public:
virtual void OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info) {}
virtual void OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) {}
};
class IAceAbilityHandler : virtual public RefBase {
@ -501,6 +505,11 @@ public:
* @return WMError
*/
virtual WMError ResetAspectRatio() = 0;
/**
* @brief Get keyboard animation config
* @return KeyboardAnimationConfig
*/
virtual KeyboardAnimationConfig GetKeyboardAnimationConfig() = 0;
};
}
}

View File

@ -462,6 +462,60 @@ using OnCallback = std::function<void(int64_t)>;
struct VsyncCallback {
OnCallback onCallback;
};
/*
* Config of keyboard animation
*/
class KeyboardAnimationConfig : public Parcelable {
public:
std::string curveType_ = "";
std::vector<float> curveParams_ = {};
uint32_t durationIn_ = 0;
uint32_t durationOut_ = 0;
virtual bool Marshalling(Parcel& parcel) const override
{
if (!parcel.WriteString(curveType_)) {
return false;
}
auto paramSize = curveParams_.size();
if (paramSize == 4) { // 4: param size
if (!parcel.WriteUint32(static_cast<uint32_t>(paramSize))) {
return false;
}
for (auto& param : curveParams_) {
if (!parcel.WriteFloat(param)) {
return false;
}
}
} else {
if (!parcel.WriteUint32(0)) {
return false;
}
}
if (!parcel.WriteUint32(durationIn_) || !parcel.WriteUint32(durationOut_)) {
return false;
}
return true;
}
static KeyboardAnimationConfig* Unmarshalling(Parcel& parcel)
{
KeyboardAnimationConfig* config = new KeyboardAnimationConfig;
config->curveType_ = parcel.ReadString();
auto paramSize = parcel.ReadUint32();
if (paramSize == 4) { // 4: param size
for (uint32_t i = 0; i < paramSize; i++) {
config->curveParams_.push_back(parcel.ReadFloat());
}
}
config->durationIn_ = parcel.ReadUint32();
config->durationOut_ = parcel.ReadUint32();
return config;
}
};
}
}
#endif // OHOS_ROSEN_WM_COMMON_H

View File

@ -44,7 +44,7 @@ void JsWindowListener::CallJsMethod(const char* methodName, NativeValue* const*
}
void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction)
const std::shared_ptr<RSTransaction>& rsTransaction)
{
WLOGI("[NAPI]OnSizeChange, wh[%{public}u, %{public}u], reason = %{public}u", rect.width_, rect.height_, reason);
// js callback should run in js thread
@ -202,7 +202,8 @@ void JsWindowListener::AfterUnfocused()
LifeCycleCallBack(LifeCycleEventType::INACTIVE);
}
void JsWindowListener::OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info)
void JsWindowListener::OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction)
{
WLOGI("[NAPI]OccupiedAreaChangeInfo, type: %{public}u, " \
"input rect: [%{public}d, %{public}d, %{public}u, %{public}u]", static_cast<uint32_t>(info->type_),

View File

@ -60,14 +60,15 @@ public:
~JsWindowListener();
void OnSystemBarPropertyChange(DisplayId displayId, const SystemBarRegionTints& tints) override;
void OnSizeChange(Rect rect, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction = nullptr) override;
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override;
void OnModeChange(WindowMode mode, bool hasDeco) override;
void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) override;
void AfterForeground() override;
void AfterBackground() override;
void AfterFocused() override;
void AfterUnfocused() override;
void OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info) override;
void OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override;
void OnTouchOutside() const override;
void OnScreenshot() override;
void OnDialogTargetTouch() const override;

View File

@ -193,6 +193,7 @@ public:
WmErrorCode RaiseToAppTop() override;
virtual WMError SetAspectRatio(float ratio) override;
virtual WMError ResetAspectRatio() override;
virtual KeyboardAnimationConfig GetKeyboardAnimationConfig() override;
private:
static std::map<std::string, std::pair<uint32_t, sptr<Window>>> windowMap_;
@ -201,6 +202,7 @@ private:
WindowState state_ { WindowState::STATE_INITIAL };
std::string name_;
std::unique_ptr<Ace::UIContent> uiContent_;
KeyboardAnimationConfig keyboardAnimationConfig_;
};
} // namespace Rosen
} // namespace OHOS

View File

@ -66,18 +66,29 @@ public:
bool WriteBool(bool value);
bool ReadBool();
template<typename T>
bool WriteObject(const sptr<T> &object)
{
return true;
}
template <typename T>
sptr<T> ReadObject()
{
return nullptr;
}
bool WriteParcelable(const Parcelable *object)
{
return true;
}
template <typename T>
T* ReadParcelable() const
{
return nullptr;
}
};
} // namespace OHOS
#endif // OHOS_UTILS_PARCEL_H

View File

@ -778,5 +778,10 @@ WMError WindowImpl::ResetAspectRatio()
{
return WMError::WM_OK;
}
KeyboardAnimationConfig WindowImpl::GetKeyboardAnimationConfig()
{
return keyboardAnimationConfig_;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -29,7 +29,7 @@ public:
IWindowMocker() {};
~IWindowMocker() {};
MOCK_METHOD4(UpdateWindowRect, WMError(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction));
const std::shared_ptr<RSTransaction>& rsTransaction));
MOCK_METHOD1(UpdateWindowMode, WMError(WindowMode mode));
MOCK_METHOD1(UpdateWindowModeSupportInfo, WMError(uint32_t modeSupportInfo));
MOCK_METHOD1(UpdateFocusStatus, WMError(bool focused));
@ -37,7 +37,10 @@ public:
MOCK_METHOD1(UpdateWindowState, WMError(WindowState state));
MOCK_METHOD2(UpdateWindowDragInfo, WMError(const PointInfo& point, DragEvent event));
MOCK_METHOD2(UpdateDisplayId, WMError(DisplayId from, DisplayId to));
MOCK_METHOD1(UpdateOccupiedAreaChangeInfo, WMError(const sptr<OccupiedAreaChangeInfo>& info));
MOCK_METHOD2(UpdateOccupiedAreaChangeInfo, WMError(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction));
MOCK_METHOD3(UpdateOccupiedAreaAndRect, WMError(const sptr<OccupiedAreaChangeInfo>& info,
const Rect& rect, const std::shared_ptr<RSTransaction>& rsTransaction));
MOCK_METHOD1(UpdateActiveStatus, WMError(bool isActive));
MOCK_METHOD0(GetWindowProperty, sptr<WindowProperty>());
MOCK_METHOD0(NotifyTouchOutside, WMError());

View File

@ -60,7 +60,7 @@ public:
MOCK_METHOD1(ProcessVsyncEvent, bool(uint64_t timeStampNanos));
MOCK_METHOD1(UpdateConfiguration, void(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config));
MOCK_METHOD3(UpdateViewportConfig, void(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason,
const std::shared_ptr<OHOS::Rosen::RSTransaction> rsTransaction));
const std::shared_ptr<OHOS::Rosen::RSTransaction>& rsTransaction));
MOCK_METHOD2(UpdateWindowMode, void(OHOS::Rosen::WindowMode mode, bool hasDeco));
MOCK_METHOD3(HideWindowTitleButton, void(bool hideSplit, bool hideMaximize, bool hideMinimize));
MOCK_METHOD0(GetBackgroundColor, uint32_t());

View File

@ -33,7 +33,8 @@ class TestOccupiedAreaChangeListener : public IOccupiedAreaChangeListener {
public:
OccupiedAreaType type_ = OccupiedAreaType::TYPE_INPUT;
Rect rect_ = { 0, 0, 0, 0 };
void OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info) override;
void OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override;
};
class WindowOccupiedAreaChangeTest : public testing::Test {
@ -50,7 +51,8 @@ public:
sptr<TestOccupiedAreaChangeListener> WindowOccupiedAreaChangeTest::testOccupiedAreaChangeListener_ =
new TestOccupiedAreaChangeListener();
void TestOccupiedAreaChangeListener::OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info)
void TestOccupiedAreaChangeListener::OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction)
{
WLOGI("OccupiedAreaChangeInfo: [%{public}u, {%{public}u, %{public}u}]",
info->type_, info->rect_.width_, info->rect_.height_);

View File

@ -23,6 +23,8 @@
namespace OHOS {
namespace Rosen {
class KeyboardAnimationConfig;
enum class LifeCycleEvent : uint32_t {
CREATE_EVENT,
SHOW_EVENT,
@ -95,6 +97,7 @@ struct SystemConfig : public Parcelable {
uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
bool isStretchable_ = false;
WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
KeyboardAnimationConfig keyboardAnimationConfig_;
virtual bool Marshalling(Parcel& parcel) const override
{
@ -103,7 +106,8 @@ struct SystemConfig : public Parcelable {
return false;
}
if (!parcel.WriteUint32(static_cast<uint32_t>(defaultWindowMode_))) {
if (!parcel.WriteUint32(static_cast<uint32_t>(defaultWindowMode_)) ||
!parcel.WriteParcelable(&keyboardAnimationConfig_)) {
return false;
}
@ -117,6 +121,8 @@ struct SystemConfig : public Parcelable {
config->isStretchable_ = parcel.ReadBool();
config->decorModeSupportInfo_ = parcel.ReadUint32();
config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32());
KeyboardAnimationConfig* keyboardConfig = parcel.ReadParcelable<KeyboardAnimationConfig>();
config->keyboardAnimationConfig_ = *keyboardConfig;
return config;
}
};

View File

@ -28,7 +28,7 @@ public:
explicit WindowAgent(sptr<WindowImpl>& window);
~WindowAgent() = default;
WMError UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction = nullptr) override;
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override;
WMError UpdateWindowMode(WindowMode mode) override;
WMError UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override;
WMError UpdateFocusStatus(bool focused) override;
@ -36,7 +36,10 @@ public:
WMError UpdateWindowState(WindowState state) override;
WMError UpdateWindowDragInfo(const PointInfo& point, DragEvent event) override;
WMError UpdateDisplayId(DisplayId from, DisplayId to) override;
WMError UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info) override;
WMError UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override;
WMError UpdateOccupiedAreaAndRect(const sptr<OccupiedAreaChangeInfo>& info, const Rect& rect,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override;
WMError UpdateActiveStatus(bool isActive) override;
sptr<WindowProperty> GetWindowProperty() override;
WMError NotifyTouchOutside() override;

View File

@ -227,7 +227,7 @@ public:
virtual void SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler) override;
virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) override;
void UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction = nullptr);
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr);
void UpdateMode(WindowMode mode);
void UpdateModeSupportInfo(uint32_t modeSupportInfo);
virtual void ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent>& inputEvent) override;
@ -244,7 +244,8 @@ public:
sptr<WindowProperty> GetWindowProperty();
void UpdateDragEvent(const PointInfo& point, DragEvent event);
void UpdateDisplayId(DisplayId from, DisplayId to);
void UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info);
void UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr);
void UpdateActiveStatus(bool isActive);
void NotifyTouchOutside();
void NotifyScreenshot();
@ -277,6 +278,7 @@ public:
virtual std::shared_ptr<Media::PixelMap> Snapshot() override;
virtual WMError NotifyMemoryLevel(int32_t level) const override;
virtual bool IsAllowHaveSystemSubWindow() override;
virtual KeyboardAnimationConfig GetKeyboardAnimationConfig() override;
void RestoreSplitWindowMode(uint32_t mode);
private:
template<typename T1, typename T2, typename Ret>
@ -481,10 +483,11 @@ private:
}
void ClearListenersById(uint32_t winId);
void NotifySizeChange(Rect rect, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction = nullptr);
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr);
void NotifyAvoidAreaChange(const sptr<AvoidArea>& avoidArea, AvoidAreaType type);
void NotifyDisplayMoveChange(DisplayId from, DisplayId to);
void NotifyOccupiedAreaChange(const sptr<OccupiedAreaChangeInfo>& info);
void NotifyOccupiedAreaChange(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr);
void NotifyModeChange(WindowMode mode, bool hasDeco = true);
void NotifyDragEvent(const PointInfo& point, DragEvent event);
void DestroyDialogWindow();
@ -536,7 +539,7 @@ private:
RSSurfaceNode::SharedPtr CreateSurfaceNode(std::string name, WindowType type);
void UpdateWindowStateUnfrozen();
void UpdateViewportConfig(const Rect& rect, const sptr<class Display>& display, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction = nullptr);
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr);
void UpdateDecorEnable(bool needNotify = false);
// colorspace, gamut
using ColorSpaceConvertMap = struct {

View File

@ -39,6 +39,7 @@ public:
TRANS_ID_UPDATE_DRAG_EVENT,
TRANS_ID_UPDATE_DISPLAY_ID,
TRANS_ID_UPDATE_OCCUPIED_AREA,
TRANS_ID_UPDATE_OCCUPIED_AREA_AND_RECT,
TRANS_ID_UPDATE_ACTIVE_STATUS,
TRANS_ID_GET_WINDOW_PROPERTY,
TRANS_ID_NOTIFY_OUTSIDE_PRESSED,
@ -54,7 +55,7 @@ public:
};
virtual WMError UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction = nullptr) = 0;
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) = 0;
virtual WMError UpdateWindowMode(WindowMode mode) = 0;
virtual WMError UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) = 0;
virtual WMError UpdateFocusStatus(bool focused) = 0;
@ -62,7 +63,8 @@ public:
virtual WMError UpdateWindowState(WindowState state) = 0;
virtual WMError UpdateWindowDragInfo(const PointInfo& point, DragEvent event) = 0;
virtual WMError UpdateDisplayId(DisplayId from, DisplayId to) = 0;
virtual WMError UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info) = 0;
virtual WMError UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) = 0;
virtual WMError UpdateActiveStatus(bool isActive) = 0;
virtual sptr<WindowProperty> GetWindowProperty() = 0;
virtual WMError NotifyTouchOutside() = 0;
@ -75,6 +77,8 @@ public:
virtual WMError UpdateZoomTransform(const Transform& trans, bool isDisplayZoomOn) = 0;
virtual WMError RestoreSplitWindowMode(uint32_t mode) = 0;
virtual void ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent> event) = 0;
virtual WMError UpdateOccupiedAreaAndRect(const sptr<OccupiedAreaChangeInfo>& info, const Rect& rect,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) = 0;
};
} // namespace Rosen
} // namespace OHOS

View File

@ -29,7 +29,7 @@ public:
~WindowProxy() {};
WMError UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction = nullptr) override;
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override;
WMError UpdateWindowMode(WindowMode mode) override;
WMError UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override;
WMError UpdateFocusStatus(bool focused) override;
@ -37,7 +37,10 @@ public:
WMError UpdateWindowState(WindowState state) override;
WMError UpdateWindowDragInfo(const PointInfo& point, DragEvent event) override;
WMError UpdateDisplayId(DisplayId from, DisplayId to) override;
WMError UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info) override;
WMError UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override;
WMError UpdateOccupiedAreaAndRect(const sptr<OccupiedAreaChangeInfo>& info, const Rect& rect,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override;
WMError UpdateActiveStatus(bool isActive) override;
sptr<WindowProperty> GetWindowProperty() override;
WMError NotifyTouchOutside() override;

View File

@ -94,7 +94,8 @@ bool OccupiedAreaChangeInfo::Marshalling(Parcel& parcel) const
{
return parcel.WriteInt32(rect_.posX_) && parcel.WriteInt32(rect_.posY_) &&
parcel.WriteUint32(rect_.width_) && parcel.WriteUint32(rect_.height_) &&
parcel.WriteUint32(static_cast<uint32_t>(type_));
parcel.WriteUint32(static_cast<uint32_t>(type_)) &&
parcel.WriteUint32(safeHeight_);
}
OccupiedAreaChangeInfo* OccupiedAreaChangeInfo::Unmarshalling(Parcel& parcel)
@ -109,6 +110,7 @@ OccupiedAreaChangeInfo* OccupiedAreaChangeInfo::Unmarshalling(Parcel& parcel)
return nullptr;
}
occupiedAreaChangeInfo->type_ = static_cast<OccupiedAreaType>(parcel.ReadUint32());
occupiedAreaChangeInfo->safeHeight_ = parcel.ReadUint32();
return occupiedAreaChangeInfo;
}
} // namespace Rosen

View File

@ -29,7 +29,7 @@ WindowAgent::WindowAgent(sptr<WindowImpl>& windowImpl)
}
WMError WindowAgent::UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction)
const std::shared_ptr<RSTransaction>& rsTransaction)
{
if (window_ == nullptr) {
WLOGFE("window_ is nullptr");
@ -109,13 +109,26 @@ WMError WindowAgent::UpdateDisplayId(DisplayId from, DisplayId to)
return WMError::WM_OK;
}
WMError WindowAgent::UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info)
WMError WindowAgent::UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction)
{
if (window_ == nullptr) {
WLOGFE("window is null");
return WMError::WM_ERROR_NULLPTR;
}
window_->UpdateOccupiedAreaChangeInfo(info);
window_->UpdateOccupiedAreaChangeInfo(info, rsTransaction);
return WMError::WM_OK;
}
WMError WindowAgent::UpdateOccupiedAreaAndRect(const sptr<OccupiedAreaChangeInfo>& info, const Rect& rect,
const std::shared_ptr<RSTransaction>& rsTransaction)
{
if (window_ == nullptr) {
WLOGFE("window is null");
return WMError::WM_ERROR_NULLPTR;
}
window_->UpdateRect(rect, window_->GetWindowProperty()->GetDecoStatus(), WindowSizeChangeReason::UNDEFINED);
window_->UpdateOccupiedAreaChangeInfo(info, rsTransaction);
return WMError::WM_OK;
}

View File

@ -961,6 +961,11 @@ void WindowImpl::SetSystemConfig()
}
}
KeyboardAnimationConfig WindowImpl::GetKeyboardAnimationConfig()
{
return windowSystemConfig_.keyboardAnimationConfig_;
}
WMError WindowImpl::WindowCreateCheck(uint32_t parentId)
{
// check window name, same window names are forbidden
@ -2106,7 +2111,7 @@ void WindowImpl::SetModeSupportInfo(uint32_t modeSupportInfo)
}
void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction)
const std::shared_ptr<RSTransaction>& rsTransaction)
{
if (state_ == WindowState::STATE_DESTROYED) {
WLOGFW("invalid window state");
@ -2679,7 +2684,7 @@ void WindowImpl::UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType
}
void WindowImpl::UpdateViewportConfig(const Rect& rect, const sptr<Display>& display, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction)
const std::shared_ptr<RSTransaction>& rsTransaction)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (uiContent_ == nullptr) {
@ -2914,10 +2919,11 @@ void WindowImpl::UpdateDisplayId(DisplayId from, DisplayId to)
property_->SetDisplayId(to);
}
void WindowImpl::UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info)
void WindowImpl::UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction)
{
WLOGFD("Update OccupiedArea, id: %{public}u", property_->GetWindowId());
NotifyOccupiedAreaChange(info);
NotifyOccupiedAreaChange(info, rsTransaction);
}
void WindowImpl::UpdateActiveStatus(bool isActive)
@ -3021,7 +3027,7 @@ void WindowImpl::ClearListenersById(uint32_t winId)
}
void WindowImpl::NotifySizeChange(Rect rect, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction)
const std::shared_ptr<RSTransaction>& rsTransaction)
{
auto windowChangeListeners = GetListeners<IWindowChangeListener>();
for (auto& listener : windowChangeListeners) {
@ -3061,12 +3067,13 @@ void WindowImpl::NotifyModeChange(WindowMode mode, bool hasDeco)
}
}
void WindowImpl::NotifyOccupiedAreaChange(const sptr<OccupiedAreaChangeInfo>& info)
void WindowImpl::NotifyOccupiedAreaChange(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction)
{
auto occupiedAreaChangeListeners = GetListeners<IOccupiedAreaChangeListener>();
for (auto& listener : occupiedAreaChangeListeners) {
if (listener.GetRefPtr() != nullptr) {
listener.GetRefPtr()->OnSizeChange(info);
listener.GetRefPtr()->OnSizeChange(info, rsTransaction);
}
}
}

View File

@ -30,7 +30,7 @@ namespace {
}
WMError WindowProxy::UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction)
const std::shared_ptr<RSTransaction>& rsTransaction)
{
MessageParcel data;
MessageParcel reply;
@ -234,7 +234,8 @@ WMError WindowProxy::UpdateDisplayId(DisplayId from, DisplayId to)
return WMError::WM_OK;
}
WMError WindowProxy::UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info)
WMError WindowProxy::UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction)
{
MessageParcel data;
MessageParcel reply;
@ -247,6 +248,20 @@ WMError WindowProxy::UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeI
WLOGFE("Write OccupiedAreaChangeInfo failed");
return WMError::WM_ERROR_IPC_FAILED;
}
bool hasRSTransaction = rsTransaction != nullptr;
if (!data.WriteBool(hasRSTransaction)) {
WLOGFE("Write transaction sync Id failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (hasRSTransaction) {
if (!data.WriteParcelable(rsTransaction.get())) {
WLOGFE("Write transaction sync Id failed");
return WMError::WM_ERROR_IPC_FAILED;
}
rsTransaction->MarshallTransactionSyncController(data);
}
if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
@ -255,6 +270,48 @@ WMError WindowProxy::UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeI
return WMError::WM_OK;
}
WMError WindowProxy::UpdateOccupiedAreaAndRect(const sptr<OccupiedAreaChangeInfo>& info, const Rect& rect,
const std::shared_ptr<RSTransaction>& rsTransaction)
{
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC);
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (!data.WriteParcelable(info)) {
WLOGFE("Write OccupiedAreaChangeInfo failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (!(data.WriteInt32(rect.posX_) && data.WriteInt32(rect.posY_) &&
data.WriteUint32(rect.width_) && data.WriteUint32(rect.height_))) {
WLOGFE("Write WindowRect failed");
return WMError::WM_ERROR_IPC_FAILED;
}
bool hasRSTransaction = rsTransaction != nullptr;
if (!data.WriteBool(hasRSTransaction)) {
WLOGFE("Write transaction sync Id failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (hasRSTransaction) {
if (!data.WriteParcelable(rsTransaction.get())) {
WLOGFE("Write transaction sync Id failed");
return WMError::WM_ERROR_IPC_FAILED;
}
rsTransaction->MarshallTransactionSyncController(data);
}
if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA_AND_RECT),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
return WMError::WM_ERROR_IPC_FAILED;
}
return WMError::WM_OK;
}
WMError WindowProxy::UpdateActiveStatus(bool isActive)
{
MessageParcel data;

View File

@ -100,7 +100,39 @@ int WindowStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParce
}
case WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA: {
sptr<OccupiedAreaChangeInfo> info = data.ReadParcelable<OccupiedAreaChangeInfo>();
UpdateOccupiedAreaChangeInfo(info);
bool hasRSTransaction = data.ReadBool();
if (hasRSTransaction) {
auto rsTransaction = data.ReadParcelable<RSTransaction>();
if (!rsTransaction) {
WLOGFE("RSTransaction unMarsh failed");
return -1;
}
std::shared_ptr<RSTransaction> transaction(rsTransaction);
rsTransaction->UnmarshallTransactionSyncController(data);
UpdateOccupiedAreaChangeInfo(info, transaction);
} else {
UpdateOccupiedAreaChangeInfo(info);
}
break;
}
case WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA_AND_RECT: {
sptr<OccupiedAreaChangeInfo> info = data.ReadParcelable<OccupiedAreaChangeInfo>();
struct Rect rect { data.ReadInt32(), data.ReadInt32(), data.ReadUint32(), data.ReadUint32() };
bool hasRSTransaction = data.ReadBool();
if (hasRSTransaction) {
auto rsTransaction = data.ReadParcelable<RSTransaction>();
if (!rsTransaction) {
WLOGFE("RSTransaction unMarsh failed");
return -1;
}
std::shared_ptr<RSTransaction> transaction(rsTransaction);
rsTransaction->UnmarshallTransactionSyncController(data);
UpdateOccupiedAreaAndRect(info, rect, transaction);
} else {
UpdateOccupiedAreaAndRect(info, rect);
}
break;
}
case WindowMessage::TRANS_ID_UPDATE_ACTIVE_STATUS: {

View File

@ -56,7 +56,7 @@ public:
class MockWindowChangeListener : public IWindowChangeListener {
public:
MOCK_METHOD3(OnSizeChange, void(Rect rect, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction));
const std::shared_ptr<RSTransaction>& rsTransaction));
MOCK_METHOD2(OnModeChange, void(WindowMode mode, bool hasDeco));
};

View File

@ -117,6 +117,8 @@ private:
bool CheckParentWindowValid(const sptr<WindowProperty>& property);
void UpdatePrivateStateAndNotify(const sptr<WindowNode>& node);
void UpdateFocusIfNeededWhenRaiseWindow(const sptr<WindowNode>& node);
void NotifyInputCallingWindowRectAndOccupiedAreaChange(const sptr<WindowNode>& callingWindow, const Rect& rect,
const Rect& occupiedArea);
sptr<WindowRoot> windowRoot_;
sptr<InputWindowMonitor> inputWindowMonitor_;

View File

@ -169,7 +169,7 @@ private:
void ConfigWindowAnimation(const WindowManagerConfig::ConfigItem& animeConfig);
void ConfigKeyboardAnimation(const WindowManagerConfig::ConfigItem& animeConfig);
void ConfigStartingWindowAnimation(const WindowManagerConfig::ConfigItem& animeConfig);
RSAnimationTimingCurve CreateCurve(const WindowManagerConfig::ConfigItem& curveConfig);
RSAnimationTimingCurve CreateCurve(const WindowManagerConfig::ConfigItem& curveConfig, bool isForKeyboard = false);
void RecordShowTimeEvent(int64_t costTime);
void ConfigWindowEffect(const WindowManagerConfig::ConfigItem& effectConfig);
bool ConfigAppWindowCornerRadius(const WindowManagerConfig::ConfigItem& item, float& out);

View File

@ -174,6 +174,7 @@ private:
const WindowMode& dstMode, const WindowMode& srcMode);
void ResetAllMainFloatingWindowZOrder(sptr<WindowNode>& rootNode);
void HandleRemoveWindowDisplayOrientation(sptr<WindowNode>& node, bool fromAnimation);
void OpenInputMethodSyncTransaction();
float displayBrightness_ = UNDEFINED_BRIGHTNESS;
uint32_t brightnessWindow_ = INVALID_WINDOW_ID;

View File

@ -23,6 +23,7 @@
#include <power_mgr_client.h>
#include <rs_window_animation_finished_callback.h>
#include <transaction/rs_transaction.h>
#include <transaction/rs_sync_transaction_controller.h>
#include <sstream>
#include "display_group_info.h"
@ -298,13 +299,14 @@ WMError WindowController::AddWindowNode(sptr<WindowProperty>& property)
node->GetWindowProperty()->CopyFrom(property);
UpdateWindowAnimation(node);
RelayoutKeyboard(node);
WMError res = windowRoot_->AddWindowNode(property->GetParentId(), node);
if (res != WMError::WM_OK) {
MinimizeApp::ClearNodesWithReason(MinimizeReason::OTHER_WINDOW);
return res;
}
windowRoot_->FocusFaultDetection();
RelayoutKeyboard(node);
FlushWindowInfo(property->GetWindowId());
NotifyAfterAddWindow(node);
HandleTurnScreenOn(node);
@ -392,19 +394,69 @@ void WindowController::RelayoutKeyboard(const sptr<WindowNode>& node)
return;
}
auto previousRect = node->GetWindowRect();
WLOGFD("NavigationBarHeight: %{public}u", navigationBarHeight);
auto requestRect = node->GetRequestRect();
if (gravity == WindowGravity::WINDOW_GRAVITY_BOTTOM) {
if (percent != 0) {
previousRect.width_ = defaultDisplayInfo->GetWidth();
previousRect.height_ = defaultDisplayInfo->GetHeight() * percent / 100;
previousRect.posX_ = 0;
requestRect.width_ = defaultDisplayInfo->GetWidth();
requestRect.height_ = defaultDisplayInfo->GetHeight() * percent / 100;
requestRect.posX_ = 0;
}
}
Rect requestedRect = { previousRect.posX_,
static_cast<int32_t>(defaultDisplayInfo->GetHeight() - previousRect.height_ - navigationBarHeight),
previousRect.width_, previousRect.height_ };
ResizeRect(node->GetWindowId(), requestedRect, WindowSizeChangeReason::MOVE);
requestRect.posY_ = static_cast<int32_t>(defaultDisplayInfo->GetHeight() -
requestRect.height_ - navigationBarHeight);
node->SetRequestRect(requestRect);
}
void WindowController::NotifyInputCallingWindowRectAndOccupiedAreaChange(const sptr<WindowNode>& callingWindow,
const Rect& rect, const Rect& occupiedArea)
{
// update calling window rect
callingWindow->SetWindowRect(rect);
// set bounds and do animation for calling window
wptr<WindowNode> weakNode = callingWindow;
auto setBoundsFun = [weakNode, rect]() {
auto winNode = weakNode.promote();
if (winNode == nullptr) {
WLOGFW("Window node is nullptr");
return;
}
if (winNode->leashWinSurfaceNode_) {
winNode->leashWinSurfaceNode_->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
if (winNode->startingWinSurfaceNode_) {
winNode->startingWinSurfaceNode_->SetBounds(0, 0, rect.width_, rect.height_);
}
if (winNode->surfaceNode_) {
winNode->surfaceNode_->SetBounds(0, 0, rect.width_, rect.height_);
}
} else {
if (winNode->surfaceNode_) {
winNode->surfaceNode_->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
}
}
};
const auto& keyboardAnimationConfig = WindowNodeContainer::GetAnimationConfigRef().keyboardAnimationConfig_;
auto timingProtocol = WindowHelper::IsEmptyRect(occupiedArea) ? keyboardAnimationConfig.durationOut_ :
keyboardAnimationConfig.durationIn_;
RSNode::Animate(timingProtocol, keyboardAnimationConfig.curve_, setBoundsFun);
// if keyboard will occupy calling, notify calling window the occupied area and safe height
const Rect& safeRect = WindowHelper::GetOverlap(occupiedArea, rect, 0, 0);
sptr<OccupiedAreaChangeInfo> info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT,
occupiedArea, safeRect.height_);
auto syncTransactionController = RSSyncTransactionController::GetInstance();
if (syncTransactionController) {
callingWindow->GetWindowToken()->UpdateOccupiedAreaAndRect(info, rect,
syncTransactionController->GetRSTransaction());
} else {
callingWindow->GetWindowToken()->UpdateOccupiedAreaAndRect(info, rect);
}
FlushWindowInfo(callingWindow->GetWindowId());
WLOGFD("Calling windowId: %{public}u, calling winRect: [%{public}d, %{public}d, %{public}u, %{public}u], "
"occupiedArea: [%{public}d, %{public}d, %{public}u, %{public}u], safeHeight: %{public}u",
callingWindow->GetWindowId(), rect.posX_, rect.posY_, rect.width_, rect.height_,
occupiedArea.posX_, occupiedArea.posY_, occupiedArea.width_, occupiedArea.height_, safeRect.height_);
}
void WindowController::ResizeSoftInputCallingWindowIfNeed(const sptr<WindowNode>& node)
@ -428,34 +480,33 @@ void WindowController::ResizeSoftInputCallingWindowIfNeed(const sptr<WindowNode>
WindowGravity gravity;
uint32_t percent = 0;
node->GetWindowGravity(gravity, percent);
if (gravity == WindowGravity::WINDOW_GRAVITY_FLOAT) {
WLOGFI("input method window gtavity is float");
if (gravity != WindowGravity::WINDOW_GRAVITY_BOTTOM) {
WLOGFI("input method window gravity is not bottom, no need to raise calling window");
return;
}
if (gravity == WindowGravity::WINDOW_GRAVITY_BOTTOM) {
Rect softInputWindowRect = node->GetWindowRect();
Rect callingWindowRect = callingWindow->GetWindowRect();
Rect rect = WindowHelper::GetOverlap(softInputWindowRect, callingWindowRect, 0, 0);
if (WindowHelper::IsEmptyRect(rect)) {
WLOGFE("there is no overlap");
return;
}
Rect requestedRect = callingWindowRect;
requestedRect.posY_ = softInputWindowRect.posY_ - static_cast<int32_t>(requestedRect.height_);
Rect statusBarWindowRect = { 0, 0, 0, 0 };
auto statusbarWindow = windowRoot_->GetWindowNode(sysBarWinId_[WindowType::WINDOW_TYPE_STATUS_BAR]);
if (statusbarWindow != nullptr && statusbarWindow->parent_ != nullptr) {
statusBarWindowRect = statusbarWindow->GetWindowRect();
}
int32_t posY = std::max(requestedRect.posY_, static_cast<int32_t>(statusBarWindowRect.height_));
if (posY != requestedRect.posY_) {
requestedRect.height_ = static_cast<uint32_t>(softInputWindowRect.posY_ - posY);
requestedRect.posY_ = posY;
}
callingWindowRestoringRect_ = callingWindowRect;
callingWindowId_ = callingWindow->GetWindowId();
ResizeRectAndFlush(callingWindowId_, requestedRect, WindowSizeChangeReason::DRAG);
const Rect& softInputWindowRect = node->GetWindowRect();
const Rect& callingWindowRect = callingWindow->GetWindowRect();
if (WindowHelper::IsEmptyRect(WindowHelper::GetOverlap(softInputWindowRect, callingWindowRect, 0, 0))) {
WLOGFD("There is no overlap area");
return;
}
// calculate new rect of calling window
Rect newRect = callingWindowRect;
newRect.posY_ = softInputWindowRect.posY_ - static_cast<int32_t>(newRect.height_);
Rect statusBarWindowRect = { 0, 0, 0, 0 };
auto statusbarWindow = windowRoot_->GetWindowNode(sysBarWinId_[WindowType::WINDOW_TYPE_STATUS_BAR]);
if (statusbarWindow != nullptr && statusbarWindow->parent_ != nullptr) {
statusBarWindowRect = statusbarWindow->GetWindowRect();
}
newRect.posY_ = std::max(newRect.posY_,
statusBarWindowRect.posY_ + static_cast<int32_t>(statusBarWindowRect.height_));
callingWindowRestoringRect_ = callingWindowRect;
callingWindowId_ = callingWindow->GetWindowId();
NotifyInputCallingWindowRectAndOccupiedAreaChange(callingWindow, newRect, softInputWindowRect);
}
void WindowController::RestoreCallingWindowSizeIfNeed()
@ -463,7 +514,8 @@ void WindowController::RestoreCallingWindowSizeIfNeed()
auto callingWindow = windowRoot_->GetWindowNode(callingWindowId_);
if (!WindowHelper::IsEmptyRect(callingWindowRestoringRect_) && callingWindow != nullptr &&
callingWindow->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING) {
ResizeRectAndFlush(callingWindowId_, callingWindowRestoringRect_, WindowSizeChangeReason::DRAG);
Rect overlapRect = { 0, 0, 0, 0 };
NotifyInputCallingWindowRectAndOccupiedAreaChange(callingWindow, callingWindowRestoringRect_, overlapRect);
}
callingWindowRestoringRect_ = { 0, 0, 0, 0 };
callingWindowId_ = 0u;
@ -1258,7 +1310,7 @@ void WindowController::UpdateWindowAnimation(const sptr<WindowNode>& node)
if (!node->GetWindowRect().height_) {
translateY = static_cast<float>(node->GetRequestRect().height_);
}
effect = RSTransitionEffect::Create()->Translate(Vector3f(0, translateY, 0))->Opacity(0.0f);
effect = RSTransitionEffect::Create()->Translate(Vector3f(0, translateY, 0))->Opacity(1.0f);
};
if (node->leashWinSurfaceNode_) {
node->leashWinSurfaceNode_->SetTransitionEffect(effect);

View File

@ -455,22 +455,22 @@ void WindowManagerService::ConfigKeyboardAnimation(const WindowManagerConfig::Co
auto& animationConfig = WindowNodeContainer::GetAnimationConfigRef();
WindowManagerConfig::ConfigItem item = animeConfig["timing"];
if (item.IsMap() && item.mapValue_->count("curve")) {
animationConfig.keyboardAnimationConfig_.curve_ = CreateCurve(item["curve"]);
animationConfig.keyboardAnimationConfig_.curve_ = CreateCurve(item["curve"], true);
}
item = animeConfig["timing"]["durationIn"];
if (item.IsInts()) {
auto numbers = *item.intsValue_;
if (numbers.size() == 1) { // duration
animationConfig.keyboardAnimationConfig_.durationIn_ =
RSAnimationTimingProtocol(numbers[0]);
animationConfig.keyboardAnimationConfig_.durationIn_ = RSAnimationTimingProtocol(numbers[0]);
systemConfig_.keyboardAnimationConfig_.durationIn_ = numbers[0];
}
}
item = animeConfig["timing"]["durationOut"];
if (item.IsInts()) {
auto numbers = *item.intsValue_;
if (numbers.size() == 1) { // duration
animationConfig.keyboardAnimationConfig_.durationOut_ =
RSAnimationTimingProtocol(numbers[0]);
animationConfig.keyboardAnimationConfig_.durationOut_ = RSAnimationTimingProtocol(numbers[0]);
systemConfig_.keyboardAnimationConfig_.durationOut_ = numbers[0];
}
}
}
@ -615,37 +615,50 @@ void WindowManagerService::ConfigWindowEffect(const WindowManagerConfig::ConfigI
WindowSystemEffect::SetWindowSystemEffectConfig(systemEffectConfig);
}
RSAnimationTimingCurve WindowManagerService::CreateCurve(const WindowManagerConfig::ConfigItem& curveConfig)
RSAnimationTimingCurve WindowManagerService::CreateCurve(const WindowManagerConfig::ConfigItem& curveConfig,
bool isForKeyboard)
{
static std::map<std::string, RSAnimationTimingCurve> curveMap = {
{ "easeOut", RSAnimationTimingCurve::EASE_OUT },
{ "ease", RSAnimationTimingCurve::EASE },
{ "easeIn", RSAnimationTimingCurve::EASE_IN },
{ "easeOut", RSAnimationTimingCurve::EASE_IN_OUT },
{ "default", RSAnimationTimingCurve::DEFAULT },
{ "linear", RSAnimationTimingCurve::LINEAR },
{ "spring", RSAnimationTimingCurve::SPRING },
{ "interactiveSpring", RSAnimationTimingCurve::INTERACTIVE_SPRING }
};
RSAnimationTimingCurve curve = RSAnimationTimingCurve::EASE_OUT;
std::string keyboardCurveName = "easeOut";
std::vector<float> keyboardCurveParams = {};
const auto& nameItem = curveConfig.GetProp("name");
if (nameItem.IsString()) {
std::string name = nameItem.stringValue_;
if (name == "easeOut") {
return RSAnimationTimingCurve::EASE_OUT;
} else if (name == "ease") {
return RSAnimationTimingCurve::EASE;
} else if (name == "easeIn") {
return RSAnimationTimingCurve::EASE_IN;
} else if (name == "easeInOut") {
return RSAnimationTimingCurve::EASE_IN_OUT;
} else if (name == "default") {
return RSAnimationTimingCurve::DEFAULT;
} else if (name == "linear") {
return RSAnimationTimingCurve::LINEAR;
} else if (name == "spring") {
return RSAnimationTimingCurve::SPRING;
} else if (name == "interactiveSpring") {
return RSAnimationTimingCurve::INTERACTIVE_SPRING;
} else if (name == "cubic" && curveConfig.IsFloats() &&
if (name == "cubic" && curveConfig.IsFloats() &&
curveConfig.floatsValue_->size() == 4) { // 4 curve parameter
const auto& numbers = *curveConfig.floatsValue_;
return RSAnimationTimingCurve::CreateCubicCurve(numbers[0], // 0 ctrlX1
numbers[1], // 1 ctrlY1
numbers[2], // 2 ctrlX2
keyboardCurveName = name;
keyboardCurveParams.assign(numbers.begin(), numbers.end());
curve = RSAnimationTimingCurve::CreateCubicCurve(numbers[0], // 0 ctrlX1
numbers[1], // 1 ctrlY1
numbers[2], // 2 ctrlX2
numbers[3]); // 3 ctrlY2
} else {
auto iter = curveMap.find(name);
if (iter != curveMap.end()) {
keyboardCurveName = name;
curve = iter->second;
}
}
}
return RSAnimationTimingCurve::EASE_OUT;
if (isForKeyboard) {
systemConfig_.keyboardAnimationConfig_.curveType_ = keyboardCurveName;
systemConfig_.keyboardAnimationConfig_.curveParams_.assign(
keyboardCurveParams.begin(), keyboardCurveParams.end());
}
return curve;
}
void WindowManagerService::OnStop()

View File

@ -26,6 +26,7 @@
#include <power_mgr_client.h>
#include <transaction/rs_interfaces.h>
#include <transaction/rs_transaction.h>
#include <transaction/rs_sync_transaction_controller.h>
#include "common_event_manager.h"
#include "dm_common.h"
@ -721,6 +722,20 @@ bool WindowNodeContainer::AddAppSurfaceNodeOnRSTree(sptr<WindowNode>& node)
return true;
}
void WindowNodeContainer::OpenInputMethodSyncTransaction()
{
// Before open transaction, it must flush first.
auto transactionProxy = RSTransactionProxy::GetInstance();
if (!transactionProxy) {
return;
}
transactionProxy->FlushImplicitTransaction();
auto syncTransactionController = RSSyncTransactionController::GetInstance();
if (syncTransactionController) {
syncTransactionController->OpenSyncTransaction();
}
}
bool WindowNodeContainer::AddNodeOnRSTree(sptr<WindowNode>& node, DisplayId displayId, DisplayId parentDisplayId,
WindowUpdateType type, bool animationPlayed)
{
@ -766,6 +781,7 @@ bool WindowNodeContainer::AddNodeOnRSTree(sptr<WindowNode>& node, DisplayId disp
} else if (node->GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT &&
windowGravity != WindowGravity::WINDOW_GRAVITY_FLOAT &&
!animationPlayed) { // add keyboard with animation
OpenInputMethodSyncTransaction();
auto timingProtocol = animationConfig_.keyboardAnimationConfig_.durationIn_;
RSNode::Animate(timingProtocol, animationConfig_.keyboardAnimationConfig_.curve_, updateRSTreeFunc);
} else {
@ -823,8 +839,9 @@ bool WindowNodeContainer::RemoveNodeFromRSTree(sptr<WindowNode>& node, DisplayId
});
FinishTrace(HITRACE_TAG_WINDOW_MANAGER);
} else if (node->GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT &&
windowGravity != WindowGravity::WINDOW_GRAVITY_FLOAT &&
!animationPlayed) { // remove keyboard with animation
windowGravity != WindowGravity::WINDOW_GRAVITY_FLOAT && !animationPlayed) {
// remove keyboard with animation
OpenInputMethodSyncTransaction();
auto timingProtocol = animationConfig_.keyboardAnimationConfig_.durationOut_;
RSNode::Animate(timingProtocol, animationConfig_.keyboardAnimationConfig_.curve_, updateRSTreeFunc);
} else {
@ -1297,12 +1314,19 @@ void WindowNodeContainer::NotifyIfKeyboardRegionChanged(const sptr<WindowNode>&
overlapRect = WindowHelper::GetOverlap(keyRect, callingRect, callingRect.posX_, callingRect.posY_);
}
WLOGD("keyboard size change callingWindow: [%{public}s, %{public}u], " \
"overlap rect: [%{public}d, %{public}d, %{public}u, %{public}u]",
sptr<OccupiedAreaChangeInfo> info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, overlapRect);
auto syncTransactionController = RSSyncTransactionController::GetInstance();
if (syncTransactionController) {
callingWindow->GetWindowToken()->UpdateOccupiedAreaChangeInfo(info,
syncTransactionController->GetRSTransaction());
} else {
callingWindow->GetWindowToken()->UpdateOccupiedAreaChangeInfo(info);
}
WLOGD("keyboard size change callingWindow: [%{public}s, %{public}u], "
"overlap rect: [%{public}d, %{public}d, %{public}u, %{public}u]",
callingWindow->GetWindowName().c_str(), callingWindow->GetWindowId(),
overlapRect.posX_, overlapRect.posY_, overlapRect.width_, overlapRect.height_);
sptr<OccupiedAreaChangeInfo> info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, overlapRect);
callingWindow->GetWindowToken()->UpdateOccupiedAreaChangeInfo(info);
return;
}
WLOGFE("does not have correct callingWindowMode for input method window");

View File

@ -58,7 +58,7 @@ Rect AvoidAreaControllerTest::screenRect;
class WindowListener : public IWindow {
public:
WMError UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction = nullptr) override
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override
{
return WMError::WM_OK;
}
@ -96,7 +96,13 @@ public:
{
return WMError::WM_OK;
}
WMError UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info) override
WMError UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override
{
return WMError::WM_OK;
}
WMError UpdateOccupiedAreaAndRect(const sptr<OccupiedAreaChangeInfo>& info, const Rect& rect,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override
{
return WMError::WM_OK;
}

View File

@ -52,7 +52,7 @@ void WindowNodeTest::TearDown()
class WindowListener : public IWindow {
public:
virtual WMError UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction> rsTransaction = nullptr) override
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override
{
return WMError::WM_OK;
};
@ -84,7 +84,13 @@ public:
{
return WMError::WM_OK;
};
virtual WMError UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info) override
virtual WMError UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override
{
return WMError::WM_OK;
};
virtual WMError UpdateOccupiedAreaAndRect(const sptr<OccupiedAreaChangeInfo>& info, const Rect& rect,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override
{
return WMError::WM_OK;
};