mirror of
https://gitee.com/openharmony/msdp_device_status
synced 2024-11-27 17:51:04 +00:00
Merge master
Signed-off-by: wuliangdong <wuliangdong1@huawei.com> Change-Id: I9e73b076730cb4e4be2238277c398d0e9f353de1
This commit is contained in:
commit
f6894afdec
@ -50,12 +50,13 @@ public:
|
||||
int32_t UpdateDragStyle(DragCursorStyle style);
|
||||
int32_t UpdateShadowPic(const ShadowInfo &shadowInfo);
|
||||
int32_t GetDragTargetPid();
|
||||
int32_t GetDragState(DragState &dragState);
|
||||
int32_t GetUdKey(std::string &udKey);
|
||||
int32_t GetShadowOffset(int32_t& offsetX, int32_t& offsetY, int32_t& width, int32_t& height);
|
||||
int32_t GetDragData(DragData &dragData);
|
||||
int32_t UpdateDragItemStyle(const DragItemStyle& dragItemStyle);
|
||||
int32_t GetDragSummary(std::map<std::string, int64_t> &summarys);
|
||||
int32_t GetDragState(DragState &dragState);
|
||||
int32_t GetDropType(DropType& dropType);
|
||||
|
||||
private:
|
||||
std::mutex mtx_;
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
int32_t RemoveHotAreaListener(std::shared_ptr<IHotAreaListener> listener = nullptr);
|
||||
int32_t UpdateDragItemStyle(const DragItemStyle &dragItemStyle);
|
||||
int32_t GetDragSummary(std::map<std::string, int64_t> &summarys);
|
||||
int32_t GetDropType(DropType &dropType);
|
||||
|
||||
private:
|
||||
void InitMsgHandler();
|
||||
|
@ -267,7 +267,6 @@ int32_t DragManagerImpl::GetDragState(DragState &dragState)
|
||||
|
||||
int32_t DragManagerImpl::UpdateDragItemStyle(const DragItemStyle &dragItemStyle)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
return DeviceStatusClient::GetInstance().UpdateDragItemStyle(dragItemStyle);
|
||||
}
|
||||
|
||||
@ -276,6 +275,11 @@ int32_t DragManagerImpl::GetDragSummary(std::map<std::string, int64_t> &summarys
|
||||
CALL_DEBUG_ENTER;
|
||||
return DeviceStatusClient::GetInstance().GetDragSummary(summarys);
|
||||
}
|
||||
|
||||
int32_t DragManagerImpl::GetDropType(DropType& dropType)
|
||||
{
|
||||
return DeviceStatusClient::GetInstance().GetDropType(dropType);
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
@ -157,6 +157,11 @@ int32_t InteractionManager::GetDragSummary(std::map<std::string, int64_t> &summa
|
||||
{
|
||||
return INTER_MGR_IMPL.GetDragSummary(summarys);
|
||||
}
|
||||
|
||||
int32_t InteractionManager::GetDropType(DropType &dropType)
|
||||
{
|
||||
return INTER_MGR_IMPL.GetDropType(dropType);
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
|
@ -299,6 +299,12 @@ int32_t InteractionManagerImpl::GetDragState(DragState &dragState)
|
||||
return dragManagerImpl_.GetDragState(dragState);
|
||||
}
|
||||
|
||||
int32_t InteractionManagerImpl::GetDropType(DropType &dropType)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
return dragManagerImpl_.GetDropType(dropType);
|
||||
}
|
||||
|
||||
int32_t InteractionManagerImpl::AddHotAreaListener(std::shared_ptr<IHotAreaListener> listener)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
|
@ -437,6 +437,13 @@ int32_t DeviceStatusClient::GetDragState(DragState &dragState)
|
||||
return devicestatusProxy_->GetDragState(dragState);
|
||||
}
|
||||
|
||||
int32_t DeviceStatusClient::GetDropType(DropType& dropType)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
DEV_RET_IF_NULL_WITH_RET((Connect() != RET_OK), RET_ERR);
|
||||
return devicestatusProxy_->GetDropType(dropType);
|
||||
}
|
||||
|
||||
int32_t DeviceStatusClient::AddHotAreaListener()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
@ -453,7 +460,6 @@ int32_t DeviceStatusClient::RemoveHotAreaListener()
|
||||
|
||||
int32_t DeviceStatusClient::UpdateDragItemStyle(const DragItemStyle &dragItemStyle)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
DEV_RET_IF_NULL_WITH_RET((Connect() != RET_OK), RET_ERR);
|
||||
return devicestatusProxy_->UpdateDragItemStyle(dragItemStyle);
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ public:
|
||||
int32_t UpdateShadowPic(const ShadowInfo &shadowInfo);
|
||||
int32_t GetDragData(DragData &dragData);
|
||||
int32_t GetDragState(DragState &dragState);
|
||||
int32_t GetDropType(DropType& dropType);
|
||||
int32_t AllocSocketPair(int32_t moduleType);
|
||||
int32_t GetClientSocketFdOfAllocedSocketPair() const;
|
||||
int32_t AddHotAreaListener();
|
||||
|
@ -28,6 +28,7 @@ namespace DeviceStatus {
|
||||
constexpr size_t MAX_BUFFER_SIZE { 512 };
|
||||
constexpr size_t MAX_UDKEY_SIZE { 100 };
|
||||
constexpr size_t MAX_SUMMARY_SIZE { 200 };
|
||||
constexpr size_t MAX_SHADOW_INFO_MEMO_SIZE { 10000000 }; // shadowInfo 的最大内存占用
|
||||
struct ShadowInfo {
|
||||
std::shared_ptr<OHOS::Media::PixelMap> pixelMap { nullptr };
|
||||
int32_t x { -1 };
|
||||
@ -90,6 +91,14 @@ struct DragItemStyle {
|
||||
uint32_t foregroundColor;
|
||||
int32_t radius;
|
||||
int32_t alpha;
|
||||
bool operator==(const DragItemStyle &style) const {
|
||||
return foregroundColor == style.foregroundColor &&
|
||||
radius == style.radius &&
|
||||
alpha == style.alpha;
|
||||
}
|
||||
bool operator!=(const DragItemStyle &style) const {
|
||||
return !(*this == style);
|
||||
}
|
||||
};
|
||||
|
||||
enum class DragCursorStyle {
|
||||
@ -98,6 +107,12 @@ enum class DragCursorStyle {
|
||||
COPY,
|
||||
MOVE
|
||||
};
|
||||
|
||||
enum class DropType {
|
||||
INVALID = -1,
|
||||
MOVE = 0,
|
||||
COPY = 1
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
|
@ -215,6 +215,14 @@ public:
|
||||
*/
|
||||
int32_t GetDragData(DragData &dragData);
|
||||
|
||||
/**
|
||||
* @brief Obtains the current droping type.
|
||||
* @param dropType dropping type while user pressed ctrl or not.
|
||||
* @return Returns <b>0</b> if the operation is successful; returns other values if the operation fails.
|
||||
* @since 10
|
||||
*/
|
||||
int32_t GetDropType(DropType &dropType);
|
||||
|
||||
/**
|
||||
* @brief Registers a listener for screen hot area of the mouse pointer.
|
||||
* @param listener Indicates the listener for screen hot area of the mouse pointer.
|
||||
@ -243,7 +251,7 @@ public:
|
||||
* @brief Update item style when dragging.
|
||||
* @param dragItemStyle Indicates the style param for dragged item.
|
||||
* @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise.
|
||||
* @since 10
|
||||
* @since 11
|
||||
*/
|
||||
int32_t UpdateDragItemStyle(const DragItemStyle &dragItemStyle);
|
||||
|
||||
|
@ -55,6 +55,7 @@
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::UpdateDragItemStyle(OHOS::Msdp::DeviceStatus::DragItemStyle const&)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::GetDragSummary(std::__h::map<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, long long, std::__h::less<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>, std::__h::allocator<std::__h::pair<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const, long long>>>&)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::GetDragSummary(std::__h::map<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, long, std::__h::less<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>, std::__h::allocator<std::__h::pair<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const, long>>>&)";
|
||||
"OHOS::Msdp::DeviceStatus::InteractionManager::GetDropType(OHOS::Msdp::DeviceStatus::DropType&)";
|
||||
};
|
||||
local:
|
||||
*;
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
virtual int32_t GetDragData(DragData &dragData) = 0;
|
||||
virtual int32_t GetDragState(DragState &dragState) = 0;
|
||||
virtual int32_t GetDragSummary(std::map<std::string, int64_t> &summarys) = 0;
|
||||
virtual int32_t GetDropType(DropType &dropType) = 0;
|
||||
virtual bool IsRunning() const
|
||||
{
|
||||
return true;
|
||||
|
@ -45,10 +45,11 @@ enum class DeviceInterfaceCode {
|
||||
UNREGISTER_SUBSCRIPT_MONITOR,
|
||||
GET_DRAG_STATE,
|
||||
GET_DRAG_SUMMARY,
|
||||
ALLOC_SOCKET_FD = 40,
|
||||
ADD_HOT_AREA_MONITOR = 50,
|
||||
GET_DROP_TYPE,
|
||||
UPDATE_DRAG_ITEM_STYLE,
|
||||
ALLOC_SOCKET_FD = 60,
|
||||
ADD_HOT_AREA_MONITOR = 70,
|
||||
REMOVE_HOT_AREA_MONITOR,
|
||||
UPDATE_DRAG_ITEM_STYLE
|
||||
};
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
virtual int32_t RemoveHotAreaListener() override;
|
||||
virtual int32_t UpdateDragItemStyle(const DragItemStyle &dragItemStyle) override;
|
||||
virtual int32_t GetDragSummary(std::map<std::string, int64_t> &summarys) override;
|
||||
virtual int32_t GetDropType(DropType& dropType) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<DeviceStatusSrvProxy> delegator_;
|
||||
|
@ -759,6 +759,29 @@ int32_t DeviceStatusSrvProxy::GetDragSummary(std::map<std::string, int64_t> &sum
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t DeviceStatusSrvProxy::GetDropType(DropType& dropType)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
|
||||
FI_HILOGE("Failed to write descriptor");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
CHKPR(remote, RET_ERR);
|
||||
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::GET_DROP_TYPE),
|
||||
data, reply, option);
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Send request failed, ret:%{public}d", ret);
|
||||
}
|
||||
int32_t type;
|
||||
READINT32(reply, type, IPC_PROXY_DEAD_OBJECT_ERR);
|
||||
dropType = static_cast<DropType>(type);
|
||||
return ret;
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
|
@ -64,6 +64,7 @@ private:
|
||||
int32_t UpdateShadowPicStub(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t GetDragDataStub(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t GetDragStateStub(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t GetDropTypeStub(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t AddHotAreaListenerStub(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t RemoveHotAreaListenerStub(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t UpdateDragItemStyleStub(MessageParcel& data, MessageParcel& reply);
|
||||
|
@ -113,7 +113,9 @@ void DeviceStatusSrvStub::InitDrag()
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_STATE),
|
||||
&DeviceStatusSrvStub::GetDragStateStub },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_SUMMARY),
|
||||
&DeviceStatusSrvStub::GetDragSummaryStub }
|
||||
&DeviceStatusSrvStub::GetDragSummaryStub },
|
||||
{static_cast<uint32_t>(DeviceInterfaceCode::GET_DROP_TYPE),
|
||||
&DeviceStatusSrvStub::GetDropTypeStub }
|
||||
};
|
||||
connFuncs_.insert(dragFuncs_.begin(), dragFuncs_.end());
|
||||
}
|
||||
@ -631,6 +633,18 @@ int32_t DeviceStatusSrvStub::GetDragSummaryStub(MessageParcel& data, MessageParc
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceStatusSrvStub::GetDropTypeStub(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
DropType dropType;
|
||||
int32_t ret = GetDropType(dropType);
|
||||
if (ret != RET_OK) {
|
||||
return RET_ERR;
|
||||
}
|
||||
WRITEINT32(reply, static_cast<int32_t>(dropType), IPC_STUB_WRITE_PARCEL_ERR);
|
||||
return RET_OK;
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
@ -48,6 +48,8 @@ public:
|
||||
int32_t GetTargetPid() const;
|
||||
void SetMotionDrag(bool isMotionDrag);
|
||||
bool IsMotionDrag() const;
|
||||
void SetDragItemStyle(const DragItemStyle &dragItemStyle);
|
||||
DragItemStyle GetDragItemStyle();
|
||||
private:
|
||||
DragData dragData_;
|
||||
DragCursorStyle dragStyle_ { DragCursorStyle::DEFAULT };
|
||||
@ -56,6 +58,7 @@ private:
|
||||
int32_t targetTid_ { -1 };
|
||||
int32_t targetPid_ { -1 };
|
||||
bool isMotionDrag_ { false };
|
||||
DragItemStyle dragItemStyle_;
|
||||
};
|
||||
|
||||
#define DRAG_DATA_MGR OHOS::Singleton<DragDataManager>::GetInstance()
|
||||
|
@ -16,6 +16,7 @@
|
||||
#ifndef DRAG_MANAGER_H
|
||||
#define DRAG_MANAGER_H
|
||||
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
|
||||
#include "extra_data.h"
|
||||
@ -70,34 +71,43 @@ public:
|
||||
void SetDragState(DragState state) override;
|
||||
int32_t UpdateDragItemStyle(const DragItemStyle &dragItemStyle) override;
|
||||
int32_t GetDragSummary(std::map<std::string, int64_t> &summarys);
|
||||
void DragKeyEventCallback(std::shared_ptr<MMI::KeyEvent> keyEvent);
|
||||
int32_t GetDropType(DropType& dropType) const;
|
||||
#ifdef OHOS_DRAG_ENABLE_INTERCEPTOR
|
||||
class InterceptorConsumer : public MMI::IInputEventConsumer {
|
||||
public:
|
||||
InterceptorConsumer(IContext *context,
|
||||
std::function<void (std::shared_ptr<MMI::PointerEvent>)> cb) : context_(context), callback_(cb) {}
|
||||
std::function<void (std::shared_ptr<MMI::PointerEvent>)> cb)
|
||||
: context_(context),
|
||||
pointerEventCallback_(cb) {}
|
||||
void OnInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) const override;
|
||||
void OnInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const override;
|
||||
void OnInputEvent(std::shared_ptr<MMI::AxisEvent> axisEvent) const override;
|
||||
private:
|
||||
IContext* context_ { nullptr };
|
||||
std::function<void (std::shared_ptr<MMI::PointerEvent>)> callback_ { nullptr };
|
||||
std::function<void (std::shared_ptr<MMI::PointerEvent>)> pointerEventCallback_ { nullptr };
|
||||
};
|
||||
#endif // OHOS_DRAG_ENABLE_INTERCEPTOR
|
||||
|
||||
#ifdef OHOS_DRAG_ENABLE_MONITOR
|
||||
class MonitorConsumer : public MMI::IInputEventConsumer {
|
||||
public:
|
||||
explicit MonitorConsumer(std::function<void (std::shared_ptr<MMI::PointerEvent>)> cb) : callback_(cb) {}
|
||||
explicit MonitorConsumer(
|
||||
std::function<void (std::shared_ptr<MMI::PointerEvent>)> cb) : pointerEventCallback_(cb) {}
|
||||
void OnInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) const override;
|
||||
void OnInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const override;
|
||||
void OnInputEvent(std::shared_ptr<MMI::AxisEvent> axisEvent) const override;
|
||||
private:
|
||||
std::function<void (std::shared_ptr<MMI::PointerEvent>)> callback_;
|
||||
std::function<void (std::shared_ptr<MMI::PointerEvent>)> pointerEventCallback_;
|
||||
};
|
||||
#endif //OHOS_DRAG_ENABLE_MONITOR
|
||||
private:
|
||||
void PrintDragData(const DragData &dragData);
|
||||
int32_t AddDragEventHandler(int32_t sourceType);
|
||||
int32_t AddPointerEventHandler(uint32_t deviceTags);
|
||||
int32_t AddKeyEventMointor();
|
||||
int32_t RemoveKeyEventMointor();
|
||||
int32_t RemovePointerEventHandler();
|
||||
int32_t NotifyDragResult(DragResult result);
|
||||
int32_t InitDataManager(const DragData &dragData) const;
|
||||
int32_t OnStartDrag();
|
||||
@ -113,11 +123,13 @@ private:
|
||||
StateChangeNotify stateNotify_;
|
||||
DragState dragState_ { DragState::STOP };
|
||||
DragResult dragResult_ { DragResult::DRAG_FAIL };
|
||||
int32_t keyEventMonitorId_ { -1 };
|
||||
std::atomic<DropType> dropType_ { DropType::MOVE };
|
||||
#ifdef OHOS_DRAG_ENABLE_INTERCEPTOR
|
||||
int32_t interceptorId_ { -1 };
|
||||
int32_t pointerEventInterceptorId_ { -1 };
|
||||
#endif // OHOS_DRAG_ENABLE_INTERCEPTOR
|
||||
#ifdef OHOS_DRAG_ENABLE_MONITOR
|
||||
int32_t monitorId_ { -1 };
|
||||
int32_t pointerEventMonitorId_ { -1 };
|
||||
#endif //OHOS_DRAG_ENABLE_MONITOR
|
||||
SessionPtr dragOutSession_ { nullptr };
|
||||
DragDrawing dragDrawing_;
|
||||
|
@ -126,6 +126,16 @@ bool DragDataManager::IsMotionDrag() const
|
||||
FI_HILOGD("isMotionDrag_:%{public}d", isMotionDrag_);
|
||||
return isMotionDrag_;
|
||||
}
|
||||
|
||||
void DragDataManager::SetDragItemStyle(const DragItemStyle &dragItemStyle)
|
||||
{
|
||||
dragItemStyle_ = dragItemStyle;
|
||||
}
|
||||
|
||||
DragItemStyle DragDataManager::GetDragItemStyle()
|
||||
{
|
||||
return dragItemStyle_;
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
@ -92,7 +92,6 @@ constexpr int32_t DEFAULT_COLOR_VALUE { 0 };
|
||||
constexpr int32_t INVALID_COLOR_VALUE { -1 };
|
||||
constexpr int32_t GLOBAL_WINDOW_ID { -1 };
|
||||
constexpr int32_t MOUSE_DRAG_CURSOR_CIRCLE_STYLE { 41 };
|
||||
constexpr int32_t ICON_CORNER_RADIUS { 41 };
|
||||
constexpr int32_t CURSOR_CIRCLE_MIDDLE { 2 };
|
||||
constexpr int32_t TRANSPARENT_COLOR { 0x00000000 };
|
||||
const Rosen::RSAnimationTimingCurve SHARP_CURVE = Rosen::RSAnimationTimingCurve::CreateCubicCurve(0.33, 0, 0.67, 1);
|
||||
@ -257,11 +256,6 @@ void DragDrawing::Draw(int32_t displayId, int32_t displayX, int32_t displayY)
|
||||
if (displayY < 0) {
|
||||
g_drawingInfo.displayY = 0;
|
||||
}
|
||||
// if (displayY >= 500 && displayY <= 510) {
|
||||
// FI_HILOGI("Here in GradientForegroundColor");
|
||||
// UpdateDragItemStyle(DragItemStyle());//Just use to test animation interface usage
|
||||
// FI_HILOGI("Here out GradientForegroundColor");
|
||||
// }
|
||||
int32_t adjustSize = TWELVE_SIZE * GetScaling();
|
||||
int32_t positionY = g_drawingInfo.displayY + g_drawingInfo.pixelMapY - adjustSize;
|
||||
int32_t positionX = g_drawingInfo.displayX + g_drawingInfo.pixelMapX;
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
#include "drag_manager.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include "extra_data.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "pixel_map.h"
|
||||
@ -33,6 +35,7 @@ namespace DeviceStatus {
|
||||
namespace {
|
||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "DragManager" };
|
||||
constexpr int32_t TIMEOUT_MS { 2000 };
|
||||
constexpr size_t SIGNLE_KEY_ITEM { 1 };
|
||||
#ifdef OHOS_DRAG_ENABLE_INTERCEPTOR
|
||||
constexpr int32_t DRAG_PRIORITY { 500 };
|
||||
std::atomic<int64_t> g_startFilterTime { -1 };
|
||||
@ -360,9 +363,9 @@ void DragManager::InterceptorConsumer::OnInputEvent(std::shared_ptr<MMI::Pointer
|
||||
g_startFilterTime = -1;
|
||||
}
|
||||
}
|
||||
CHKPV(callback_);
|
||||
CHKPV(pointerEventCallback_);
|
||||
CHKPV(context_);
|
||||
callback_(pointerEvent);
|
||||
pointerEventCallback_(pointerEvent);
|
||||
pointerEvent->AddFlag(MMI::InputEvent::EVENT_FLAG_NO_INTERCEPT);
|
||||
auto fun = [] (std::shared_ptr<MMI::PointerEvent> pointerEvent) -> int32_t {
|
||||
MMI::InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
|
||||
@ -394,8 +397,8 @@ void DragManager::MonitorConsumer::OnInputEvent(std::shared_ptr<MMI::PointerEven
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
CHKPV(pointerEvent);
|
||||
CHKPV(callback_);
|
||||
callback_(pointerEvent);
|
||||
CHKPV(pointerEventCallback_);
|
||||
pointerEventCallback_(pointerEvent);
|
||||
if (pointerEvent->GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_PULL_UP) {
|
||||
FI_HILOGI("Pointer button is released, appened extra data");
|
||||
MMI::InputManager::GetInstance()->AppendExtraData(DragManager::CreateExtraData(false));
|
||||
@ -418,14 +421,14 @@ void DragManager::Dump(int32_t fd) const
|
||||
dprintf(fd,
|
||||
"dragState:%s | dragResult:%s | interceptorId:%d | dragTargetPid:%d | dragTargetTid:%d | "
|
||||
"cursorStyle:%s | isWindowVisble:%s\n", GetDragState(dragState_).c_str(),
|
||||
GetDragResult(dragResult_).c_str(), interceptorId_, GetDragTargetPid(), targetTid,
|
||||
GetDragResult(dragResult_).c_str(), pointerEventInterceptorId_, GetDragTargetPid(), targetTid,
|
||||
GetDragCursorStyle(style).c_str(), DRAG_DATA_MGR.GetDragWindowVisible() ? "true" : "false");
|
||||
#endif // OHOS_DRAG_ENABLE_INTERCEPTOR
|
||||
#ifdef OHOS_DRAG_ENABLE_MONITOR
|
||||
dprintf(fd,
|
||||
"dragState:%s | dragResult:%s | monitorId:%d | dragTargetPid:%d | dragTargetTid:%d | "
|
||||
"cursorStyle:%s | isWindowVisble:%s\n", GetDragState(dragState_).c_str(),
|
||||
GetDragResult(dragResult_).c_str(), monitorId_, GetDragTargetPid(), targetTid,
|
||||
GetDragResult(dragResult_).c_str(), pointerEventMonitorId_, GetDragTargetPid(), targetTid,
|
||||
GetDragCursorStyle(style).c_str(), DRAG_DATA_MGR.GetDragWindowVisible() ? "true" : "false");
|
||||
#endif // OHOS_DRAG_ENABLE_MONITOR
|
||||
DragData dragData = DRAG_DATA_MGR.GetDragData();
|
||||
@ -531,25 +534,90 @@ int32_t DragManager::AddDragEventHandler(int32_t sourceType)
|
||||
return RET_ERR;
|
||||
}
|
||||
#endif // OHOS_DRAG_ENABLE_INTERCEPTOR
|
||||
if (AddPointerEventHandler(deviceTags) != RET_OK) {
|
||||
FI_HILOGE("Failed to add pointer event handler");
|
||||
return RET_ERR;
|
||||
}
|
||||
if (AddKeyEventMointor() != RET_OK) {
|
||||
FI_HILOGE("Failed to add key event handler");
|
||||
return RET_ERR;
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t DragManager::AddPointerEventHandler(uint32_t deviceTags)
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
#ifdef OHOS_DRAG_ENABLE_MONITOR
|
||||
auto monitor = std::make_shared<MonitorConsumer>(std::bind(&DragManager::DragCallback, this,
|
||||
std::placeholders::_1));
|
||||
FI_HILOGI("Add drag event monitor");
|
||||
monitorId_ = MMI::InputManager::GetInstance()->AddMonitor(monitor);
|
||||
if (monitorId_ <= 0) {
|
||||
FI_HILOGE("Failed to add monitor, error code:%{public}d", monitorId_);
|
||||
pointerEventMonitorId_ = MMI::InputManager::GetInstance()->AddMonitor(monitor);
|
||||
if (pointerEventMonitorId_ <= 0) {
|
||||
FI_HILOGE("Failed to add pointer event monitor");
|
||||
return RET_ERR;
|
||||
}
|
||||
#else
|
||||
auto callback = std::bind(&DragManager::DragCallback, this, std::placeholders::_1);
|
||||
auto interceptor = std::make_shared<InterceptorConsumer>(context_, callback);
|
||||
FI_HILOGI("Add drag event interceptor");
|
||||
interceptorId_ = MMI::InputManager::GetInstance()->AddInterceptor(interceptor, DRAG_PRIORITY, deviceTags);
|
||||
if (interceptorId_ <= 0) {
|
||||
FI_HILOGE("Failed to add interceptor, error code:%{public}d", interceptorId_);
|
||||
pointerEventInterceptorId_ = MMI::InputManager::GetInstance()->AddInterceptor(
|
||||
interceptor, DRAG_PRIORITY, deviceTags);
|
||||
if (pointerEventInterceptorId_ <= 0) {
|
||||
FI_HILOGE("Failed to add pointer event interceptor");
|
||||
return RET_ERR;
|
||||
}
|
||||
#endif // OHOS_DRAG_ENABLE_MONITOR
|
||||
FI_HILOGI("Add drag poniter event handle successfully");
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t DragManager::AddKeyEventMointor()
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
keyEventMonitorId_ = MMI::InputManager::GetInstance()->AddMonitor(
|
||||
std::bind(&DragManager::DragKeyEventCallback, this, std::placeholders::_1));
|
||||
if (keyEventMonitorId_ <= 0) {
|
||||
FI_HILOGE("Failed to add key event monitor");
|
||||
return RET_ERR;
|
||||
}
|
||||
FI_HILOGI("Add drag key event monitor successfully");
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t DragManager::RemovePointerEventHandler()
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
#ifdef OHOS_DRAG_ENABLE_MONITOR
|
||||
if (pointerEventMonitorId_ <= 0) {
|
||||
FI_HILOGE("Invalid pointer event monitor id:%{public}d", pointerEventMonitorId_);
|
||||
return RET_ERR;
|
||||
}
|
||||
MMI::InputManager::GetInstance()->RemoveMonitor(pointerEventMonitorId_);
|
||||
pointerEventMonitorId_ = -1;
|
||||
if (RemoveKeyEventMointor() != RET_OK) {
|
||||
FI_HILOGE("Failed to remove key event monitor");
|
||||
return RET_ERR;
|
||||
}
|
||||
#else
|
||||
if (pointerEventInterceptorId_ <= 0) {
|
||||
FI_HILOGE("Invalid pointer event interceptor id:%{public}d", pointerEventInterceptorId_);
|
||||
}
|
||||
MMI::InputManager::GetInstance()->RemoveInterceptor(pointerEventInterceptorId_);
|
||||
pointerEventInterceptorId_ = -1;
|
||||
#endif // OHOS_DRAG_ENABLE_MONITOR
|
||||
FI_HILOGI("Remove drag pointer event handler successfully");
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t DragManager::RemoveKeyEventMointor()
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
if (keyEventMonitorId_ <= 0) {
|
||||
FI_HILOGE("Invalid key event monitor id:%{public}d", keyEventMonitorId_);
|
||||
return RET_ERR;
|
||||
}
|
||||
MMI::InputManager::GetInstance()->RemoveMonitor(keyEventMonitorId_);
|
||||
keyEventMonitorId_ = -1;
|
||||
FI_HILOGI("Remove drag key event handle successfully");
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@ -573,11 +641,7 @@ int32_t DragManager::OnStartDrag()
|
||||
MMI::InputManager::GetInstance()->AppendExtraData(extraData);
|
||||
ret = AddDragEventHandler(dragData.sourceType);
|
||||
if (ret != RET_OK) {
|
||||
#ifdef OHOS_DRAG_ENABLE_MONITOR
|
||||
FI_HILOGE("Failed to add drag event monitor");
|
||||
#else
|
||||
FI_HILOGE("Failed to add drag event interceptor");
|
||||
#endif // OHOS_DRAG_ENABLE_MONITOR
|
||||
FI_HILOGE("Failed to add drag event handler");
|
||||
dragDrawing_.DestroyDragWindow();
|
||||
return RET_ERR;
|
||||
}
|
||||
@ -592,23 +656,14 @@ int32_t DragManager::OnStopDrag(DragResult result, bool hasCustomAnimation)
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
FI_HILOGI("Add custom animation:%{public}s", hasCustomAnimation ? "true" : "false");
|
||||
#ifdef OHOS_DRAG_ENABLE_MONITOR
|
||||
if (monitorId_ <= 0) {
|
||||
FI_HILOGE("Invalid monitor to be removed, monitorId_:%{public}d", monitorId_);
|
||||
if (RemovePointerEventHandler() != RET_OK) {
|
||||
FI_HILOGE("Failed to remove pointer event handler");
|
||||
return RET_ERR;
|
||||
}
|
||||
FI_HILOGI("Remove drag event monitor");
|
||||
MMI::InputManager::GetInstance()->RemoveMonitor(monitorId_);
|
||||
monitorId_ = -1;
|
||||
#else
|
||||
if (interceptorId_ <= 0) {
|
||||
FI_HILOGE("Invalid interceptorId_:%{public}d", interceptorId_);
|
||||
if (RemoveKeyEventMointor() != RET_OK) {
|
||||
FI_HILOGE("Failed to remove key event handler");
|
||||
return RET_ERR;
|
||||
}
|
||||
FI_HILOGI("Remove drag event interceptor");
|
||||
MMI::InputManager::GetInstance()->RemoveInterceptor(interceptorId_);
|
||||
interceptorId_ = -1;
|
||||
#endif // OHOS_DRAG_ENABLE_MONITOR
|
||||
DragData dragData = DRAG_DATA_MGR.GetDragData();
|
||||
if ((dragData.sourceType == MMI::PointerEvent::SOURCE_TYPE_MOUSE) && !DRAG_DATA_MGR.IsMotionDrag()) {
|
||||
dragDrawing_.EraseMouseIcon();
|
||||
@ -763,7 +818,43 @@ int32_t DragManager::UpdateDragItemStyle(const DragItemStyle &dragItemStyle)
|
||||
FI_HILOGE("Drag instance not running");
|
||||
return RET_ERR;
|
||||
}
|
||||
dragDrawing_.UpdateDragItemStyle(dragItemStyle);
|
||||
if (dragItemStyle == DRAG_DATA_MGR.GetDragItemStyle()) {
|
||||
FI_HILOGD("Not need update drag item style");
|
||||
return RET_OK;
|
||||
}
|
||||
FI_HILOGI("Update drag item style successfully");
|
||||
DRAG_DATA_MGR.SetDragItemStyle(dragItemStyle);
|
||||
return dragDrawing_.UpdateDragItemStyle(dragItemStyle);
|
||||
}
|
||||
|
||||
void DragManager::DragKeyEventCallback(std::shared_ptr<MMI::KeyEvent> keyEvent)
|
||||
{
|
||||
CHKPV(keyEvent);
|
||||
auto keys = keyEvent->GetKeyItems();
|
||||
int32_t keyCode = keyEvent->GetKeyCode();
|
||||
int32_t keyAction = keyEvent->GetKeyAction();
|
||||
if (keys.size() != SIGNLE_KEY_ITEM) {
|
||||
dropType_.store(DropType::MOVE);
|
||||
return;
|
||||
}
|
||||
if (keyAction == MMI::KeyEvent::KEY_ACTION_DOWN && (
|
||||
keyCode == MMI::KeyEvent::KEYCODE_CTRL_LEFT ||
|
||||
keyCode == MMI::KeyEvent::KEYCODE_CTRL_RIGHT)) {
|
||||
dropType_.store(DropType::COPY);
|
||||
FI_HILOGI("the current drop type is copy");
|
||||
} else {
|
||||
dropType_.store(DropType::MOVE);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t DragManager::GetDropType(DropType& dropType) const
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (dragState_ != DragState::START) {
|
||||
FI_HILOGE("No drag instance running, can not get drag drop type");
|
||||
return RET_ERR;
|
||||
}
|
||||
dropType = dropType_.load();
|
||||
return RET_OK;
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
|
@ -85,6 +85,7 @@ public:
|
||||
int32_t UpdateShadowPic(const ShadowInfo &shadowInfo) override;
|
||||
int32_t GetDragData(DragData &dragData) override;
|
||||
int32_t GetDragState(DragState &dragState) override;
|
||||
int32_t GetDropType(DropType& dropType) override;
|
||||
int32_t AllocSocketFd(const std::string &programName, int32_t moduleType,
|
||||
int32_t &toReturnClientFd, int32_t &tokenType) override;
|
||||
void OnConnected(SessionPtr s) override;
|
||||
|
@ -827,6 +827,16 @@ int32_t DeviceStatusService::GetDragTargetPid()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t DeviceStatusService::GetDropType(DropType& dropType)
|
||||
{
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::GetDropType, &dragMgr_, std::ref(dropType)));
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Get drop type failed, ret:%{public}d", ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef OHOS_BUILD_ENABLE_COORDINATION
|
||||
int32_t DeviceStatusService::OnRegisterCoordinationListener(int32_t pid)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
Loading…
Reference in New Issue
Block a user