mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 06:50:40 +00:00
根据检视意见做对应修改
Signed-off-by: kaicui <cuikai34@huawei.com>
This commit is contained in:
parent
41205d6b5c
commit
a2044dcfaa
@ -116,30 +116,29 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r
|
||||
currRect_ = rect;
|
||||
}
|
||||
|
||||
void JsExtensionWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason reason)
|
||||
void JsExtensionWindowListener::OnRectChange(const Rect& rect, WindowSizeChangeReason reason)
|
||||
{
|
||||
if (currRect_ == rect && reason == WindowSizeChangeReason::UNDEFINED) {
|
||||
TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]Skip redundant rect update");
|
||||
return;
|
||||
}
|
||||
RectChangeReason rectChangReason = RectChangeReason::UNDEFINED;
|
||||
RectChangeReason rectChangeReason = RectChangeReason::UNDEFINED;
|
||||
if (JS_SIZE_CHANGE_REASON.count(reason) != 0 &&
|
||||
!(reason == WindowSizeChangeReason::MAXIMIZE && rect.posX_ != 0)) {
|
||||
rectChangReason = JS_SIZE_CHANGE_REASON.at(reason);
|
||||
rectChangeReason = JS_SIZE_CHANGE_REASON.at(reason);
|
||||
}
|
||||
if (currentReason_ != RectChangeReason::DRAG && rectChangReason == RectChangeReason::DRAG_END) {
|
||||
rectChangReason = RectChangeReason::MOVE;
|
||||
if (currentRectChangeReason_ != RectChangeReason::DRAG && rectChangeReason == RectChangeReason::DRAG_END) {
|
||||
rectChangeReason = RectChangeReason::MOVE;
|
||||
}
|
||||
// js callback should run in js thread
|
||||
auto jsCallback = [self = weakRef_, rect, rectChangReason, env = env_] () {
|
||||
auto jsCallback = [self = weakRef_, rect, rectChangeReason, env = env_] {
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsExtensionWindowListener::OnRectChange");
|
||||
auto thisListener = self.promote();
|
||||
if (thisListener == nullptr || env == nullptr) {
|
||||
TLOGNE(WmsLogTag::WMS_UIEXT, "[NAPI]This listener or env is nullptr");
|
||||
return;
|
||||
}
|
||||
napi_handle_scope scope = nullptr;
|
||||
napi_open_handle_scope(env, &scope);
|
||||
HandleScope handleScope(env);
|
||||
napi_value objValue = nullptr;
|
||||
napi_create_object(env, &objValue);
|
||||
if (objValue == nullptr) {
|
||||
@ -152,10 +151,9 @@ void JsExtensionWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason r
|
||||
return;
|
||||
}
|
||||
napi_set_named_property(env, objValue, "rect", rectObjValue);
|
||||
napi_set_named_property(env, objValue, "reason", CreateJsValue(env, rectChangReason));
|
||||
napi_value argv[] = {objValue};
|
||||
napi_set_named_property(env, objValue, "reason", CreateJsValue(env, rectChangeReason));
|
||||
napi_value argv[] = { objValue };
|
||||
thisListener->CallJsMethod(WINDOW_RECT_CHANGE_CB.c_str(), argv, ArraySize(argv));
|
||||
napi_close_handle_scope(env, scope);
|
||||
};
|
||||
if (!eventHandler_) {
|
||||
TLOGE(WmsLogTag::WMS_UIEXT, "Get main event handler failed!");
|
||||
@ -164,7 +162,7 @@ void JsExtensionWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason r
|
||||
eventHandler_->PostTask(jsCallback, "wms:JsExtensionWindowListener::OnRectChange", 0,
|
||||
AppExecFwk::EventQueue::Priority::IMMEDIATE);
|
||||
currRect_ = rect;
|
||||
currentReason_ = rectChangReason;
|
||||
currentRectChangeReason_ = rectChangeReason;
|
||||
}
|
||||
|
||||
void JsExtensionWindowListener::OnModeChange(WindowMode mode, bool hasDeco)
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include "window.h"
|
||||
#include "window_manager.h"
|
||||
#include "wm_common.h"
|
||||
#include "js_window_utils.h"
|
||||
#include "js_extension_window_utils.h"
|
||||
#include "js_window_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@ -43,7 +43,7 @@ public:
|
||||
~JsExtensionWindowListener();
|
||||
void OnSizeChange(Rect rect, WindowSizeChangeReason reason,
|
||||
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override;
|
||||
void OnRectChange(Rect rect, WindowSizeChangeReason reason) override;
|
||||
void OnRectChange(const Rect& rect, WindowSizeChangeReason reason) override;
|
||||
void OnModeChange(WindowMode mode, bool hasDeco) override;
|
||||
void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) override;
|
||||
void AfterForeground() override;
|
||||
@ -59,8 +59,8 @@ public:
|
||||
void SetMainEventHandler();
|
||||
|
||||
private:
|
||||
Rect currRect_ = {};
|
||||
RectChangeReason currentReason_ = RectChangeReason::UNDEFINED;
|
||||
Rect currRect_;
|
||||
RectChangeReason currentRectChangeReason_ = RectChangeReason::UNDEFINED;
|
||||
napi_env env_ = nullptr;
|
||||
WindowState state_ {WindowState::STATE_INITIAL};
|
||||
std::shared_ptr<NativeReference> jsCallBack_;
|
||||
|
@ -63,8 +63,8 @@ WmErrorCode JsExtensionWindowRegisterManager::ProcessWindowChangeRegister(sptr<J
|
||||
return ret;
|
||||
}
|
||||
|
||||
WmErrorCode JsExtensionWindowRegisterManager::ProcessWindowRectChangeRegister(sptr<JsExtensionWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister)
|
||||
WmErrorCode JsExtensionWindowRegisterManager::ProcessWindowRectChangeRegister(const sptr<JsExtensionWindowListener>& listener,
|
||||
const sptr<Window>& window, bool isRegister)
|
||||
{
|
||||
if (window == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Window is nullptr");
|
||||
|
@ -48,8 +48,8 @@ private:
|
||||
bool IsCallbackRegistered(napi_env env, std::string type, napi_value jsListenerObject);
|
||||
WmErrorCode ProcessWindowChangeRegister(sptr<JsExtensionWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister);
|
||||
WmErrorCode ProcessWindowRectChangeRegister(sptr<JsExtensionWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister);
|
||||
WmErrorCode ProcessWindowRectChangeRegister(const sptr<JsExtensionWindowListener>& listener,
|
||||
const sptr<Window>& window, bool isRegister);
|
||||
WmErrorCode ProcessAvoidAreaChangeRegister(sptr<JsExtensionWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister);
|
||||
WmErrorCode ProcessLifeCycleEventRegister(sptr<JsExtensionWindowListener> listener,
|
||||
|
Loading…
Reference in New Issue
Block a user