mirror of
https://gitee.com/openharmony/msdp_device_status
synced 2024-11-23 07:29:52 +00:00
Modifying drag window by horizontal and vertical
Signed-off-by: xing-jiangpan <xingjiangpan2@huawei.com> Change-Id: I701515df31c45d8975409436e490584ef44a3328
This commit is contained in:
parent
e2145cf8d9
commit
592b494ba5
@ -19,6 +19,7 @@
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
|
||||
#include <display_manager.h>
|
||||
#include <input_manager.h>
|
||||
|
||||
#include "drag_data.h"
|
||||
@ -48,6 +49,7 @@ public:
|
||||
virtual int32_t UpdatePreviewStyleWithAnimation(const PreviewStyle &previewStyle,
|
||||
const PreviewAnimation &animation) = 0;
|
||||
virtual void GetAllowDragState(bool &isAllowDrag) = 0;
|
||||
virtual int32_t RotateDragWindow(Rosen::Rotation rotation) = 0;
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
|
@ -62,6 +62,7 @@ ohos_source_set("intention_device_manager") {
|
||||
"hilog:libhilog",
|
||||
"image_framework:image_native",
|
||||
"input:libmmi-client",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
subsystem_name = "${device_status_subsystem_name}"
|
||||
|
1
libs/test/unittest/BUILD.gn
Executable file → Normal file
1
libs/test/unittest/BUILD.gn
Executable file → Normal file
@ -62,6 +62,7 @@ ohos_unittest("device_status_algorithm_test") {
|
||||
"ipc:ipc_single",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
defines = []
|
||||
if (device_status_sensor_enable) {
|
||||
|
1
services/BUILD.gn
Executable file → Normal file
1
services/BUILD.gn
Executable file → Normal file
@ -85,6 +85,7 @@ external_deps_set = [
|
||||
"image_framework:image_native",
|
||||
"safwk:system_ability_fwk",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
ohos_shared_library("devicestatus_service") {
|
||||
|
@ -41,6 +41,7 @@ ohos_shared_library("interaction_drag") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"src/display_change_event_listener.cpp",
|
||||
"src/drag_data_manager.cpp",
|
||||
"src/drag_drawing.cpp",
|
||||
"src/drag_hisysevent.cpp",
|
||||
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DISPLAY_CHANGE_EVENT_LISTENER_H
|
||||
#define DISPLAY_CHANGE_EVENT_LISTENER_H
|
||||
|
||||
#include "display_manager.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "system_ability_status_change_stub.h"
|
||||
|
||||
#include "i_context.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
class DisplayChangeEventListener : public Rosen::DisplayManager::IDisplayListener {
|
||||
public:
|
||||
explicit DisplayChangeEventListener(IContext *context);
|
||||
~DisplayChangeEventListener() = default;
|
||||
void OnCreate(Rosen::DisplayId displayId) override;
|
||||
void OnDestroy(Rosen::DisplayId displayId) override;
|
||||
void OnChange(Rosen::DisplayId displayId) override;
|
||||
|
||||
private:
|
||||
Rosen::Rotation lastRotation_ { Rosen::Rotation::ROTATION_0 };
|
||||
IContext *context_ { nullptr };
|
||||
};
|
||||
|
||||
class DisplayAbilityStatusChange : public SystemAbilityStatusChangeStub {
|
||||
public:
|
||||
explicit DisplayAbilityStatusChange(IContext *context);
|
||||
~DisplayAbilityStatusChange() = default;
|
||||
void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
|
||||
void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
|
||||
|
||||
private:
|
||||
sptr<DisplayChangeEventListener> displayChangeEventListener_ { nullptr };
|
||||
IContext *context_ { nullptr };
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
#endif // DISPLAY_CHANGE_EVENT_LISTENER_H
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "display_manager.h"
|
||||
#include "event_handler.h"
|
||||
#include "event_runner.h"
|
||||
#include "libxml/tree.h"
|
||||
@ -161,7 +162,7 @@ public:
|
||||
~DragDrawing() = default;
|
||||
|
||||
int32_t Init(const DragData &dragData);
|
||||
void Draw(int32_t displayId, int32_t displayX, int32_t displayY);
|
||||
void Draw(int32_t displayId, int32_t displayX, int32_t displayY, bool isNeedAdjustDisplayXY = true);
|
||||
int32_t UpdateDragStyle(DragCursorStyle style);
|
||||
int32_t UpdateShadowPic(const ShadowInfo &shadowInfo);
|
||||
int32_t UpdatePreviewStyle(const PreviewStyle &previewStyle);
|
||||
@ -185,12 +186,14 @@ public:
|
||||
int32_t EnterTextEditorArea(bool enable);
|
||||
bool GetAllowDragState();
|
||||
void SetScreenId(uint64_t screenId);
|
||||
int32_t RotateDragWindow(Rosen::Rotation rotation);
|
||||
void SetRotation(Rosen::Rotation rotation);
|
||||
|
||||
private:
|
||||
int32_t CheckDragData(const DragData &dragData);
|
||||
int32_t InitLayer();
|
||||
void InitCanvas(int32_t width, int32_t height);
|
||||
void CreateWindow(int32_t displayX, int32_t displayY);
|
||||
void CreateWindow();
|
||||
int32_t DrawShadow(std::shared_ptr<Rosen::RSCanvasNode> shadowNode);
|
||||
int32_t DrawMouseIcon();
|
||||
int32_t DrawStyle(std::shared_ptr<Rosen::RSCanvasNode> dragStyleNode,
|
||||
@ -233,6 +236,8 @@ private:
|
||||
void RemoveStyleNodeModifier(std::shared_ptr<Rosen::RSCanvasNode> styleNode);
|
||||
void StartStyleAnimation(float startScale, float endScale, int32_t duration);
|
||||
void UpdateAnimationProtocol(Rosen::RSAnimationTimingProtocol protocol);
|
||||
void RotateDisplayXY(int32_t &displayX, int32_t &displayY);
|
||||
int32_t DoRotateDragWindow(float rotation);
|
||||
|
||||
private:
|
||||
int64_t startNum_ { -1 };
|
||||
@ -255,6 +260,7 @@ private:
|
||||
void* dragExtHandle_ { nullptr };
|
||||
bool needDestroyDragWindow_ { false };
|
||||
uint64_t screenId_ { 0 };
|
||||
Rosen::Rotation rotation_ { Rosen::Rotation::ROTATION_0 };
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "input_manager.h"
|
||||
#include "pixel_map.h"
|
||||
|
||||
#include "display_change_event_listener.h"
|
||||
#include "devicestatus_define.h"
|
||||
#include "drag_data.h"
|
||||
#include "drag_drawing.h"
|
||||
@ -80,6 +81,7 @@ public:
|
||||
int32_t GetDragAction(DragAction &dragAction) const;
|
||||
int32_t GetExtraInfo(std::string &extraInfo) const;
|
||||
int32_t AddPrivilege(int32_t tokenId);
|
||||
int32_t RotateDragWindow(Rosen::Rotation rotation) override;
|
||||
#ifdef OHOS_DRAG_ENABLE_INTERCEPTOR
|
||||
class InterceptorConsumer : public MMI::IInputEventConsumer {
|
||||
public:
|
||||
@ -150,6 +152,7 @@ private:
|
||||
std::function<void(bool)> notifyPUllUpCallback_ { nullptr };
|
||||
std::shared_ptr<EventHub> eventHub_ { nullptr };
|
||||
sptr<ISystemAbilityStatusChange> statusListener_ { nullptr };
|
||||
sptr<ISystemAbilityStatusChange> displayAbilityStatusChange_ { nullptr };
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
|
104
services/interaction/drag/src/display_change_event_listener.cpp
Normal file
104
services/interaction/drag/src/display_change_event_listener.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "display_change_event_listener.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
namespace {
|
||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "DisplayChangeEventListener" };
|
||||
} // namespace
|
||||
|
||||
DisplayChangeEventListener::DisplayChangeEventListener(IContext *context)
|
||||
: context_(context)
|
||||
{
|
||||
}
|
||||
|
||||
void DisplayChangeEventListener::OnCreate(Rosen::DisplayId displayId)
|
||||
{
|
||||
FI_HILOGI("display:%{public}" PRIu64"", displayId);
|
||||
}
|
||||
|
||||
void DisplayChangeEventListener::OnDestroy(Rosen::DisplayId displayId)
|
||||
{
|
||||
FI_HILOGI("display:%{public}" PRIu64"", displayId);
|
||||
}
|
||||
|
||||
void DisplayChangeEventListener::OnChange(Rosen::DisplayId displayId)
|
||||
{
|
||||
if (Rosen::DisplayManager::GetInstance().IsFoldable()) {
|
||||
Rosen::FoldDisplayMode foldMode = Rosen::DisplayManager::GetInstance().GetFoldDisplayMode();
|
||||
if (foldMode == Rosen::FoldDisplayMode::FULL) {
|
||||
if (lastRotation_ == Rosen::Rotation::ROTATION_0) {
|
||||
FI_HILOGD("FoldDisplayMode is full");
|
||||
return;
|
||||
}
|
||||
lastRotation_ = Rosen::Rotation::ROTATION_0;
|
||||
CHKPV(context_);
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask(
|
||||
std::bind(&IDragManager::RotateDragWindow, &context_->GetDragManager(), Rosen::Rotation::ROTATION_0));
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post async task failed");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
sptr<Rosen::Display> display = Rosen::DisplayManager::GetInstance().GetDisplayById(displayId);
|
||||
if (display == nullptr) {
|
||||
FI_HILOGD("Get display info failed, display:%{public}" PRIu64"", displayId);
|
||||
display = Rosen::DisplayManager::GetInstance().GetDisplayById(0);
|
||||
if (display == nullptr) {
|
||||
FI_HILOGE("Get display info failed, display is nullptr");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Rosen::Rotation currentRotation = display->GetRotation();
|
||||
if (currentRotation == lastRotation_) {
|
||||
return;
|
||||
}
|
||||
lastRotation_ = currentRotation;
|
||||
CHKPV(context_);
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask(
|
||||
std::bind(&IDragManager::RotateDragWindow, &context_->GetDragManager(), currentRotation));
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post async task failed");
|
||||
}
|
||||
}
|
||||
|
||||
DisplayAbilityStatusChange::DisplayAbilityStatusChange(IContext *context)
|
||||
: context_(context)
|
||||
{}
|
||||
|
||||
void DisplayAbilityStatusChange::OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId)
|
||||
{
|
||||
FI_HILOGI("systemAbilityId:%{public}d", systemAbilityId);
|
||||
if (systemAbilityId != DISPLAY_MANAGER_SERVICE_SA_ID) {
|
||||
FI_HILOGE("systemAbilityId is not DISPLAY_MANAGER_SERVICE_SA_ID");
|
||||
return;
|
||||
}
|
||||
CHKPV(context_);
|
||||
displayChangeEventListener_ = sptr<DisplayChangeEventListener>::MakeSptr(context_);
|
||||
CHKPV(displayChangeEventListener_);
|
||||
Rosen::DisplayManager::GetInstance().RegisterDisplayListener(displayChangeEventListener_);
|
||||
}
|
||||
|
||||
void DisplayAbilityStatusChange::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId)
|
||||
{
|
||||
FI_HILOGI("systemAbilityId:%{public}d", systemAbilityId);
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
@ -23,7 +23,6 @@
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "display_manager.h"
|
||||
#include "include/core/SkTextBlob.h"
|
||||
#include "image_source.h"
|
||||
#include "image_type.h"
|
||||
@ -81,13 +80,12 @@ constexpr float START_STYLE_ALPHA { 1.0f };
|
||||
constexpr float END_STYLE_ALPHA { 0.0f };
|
||||
constexpr float BEGIN_SCALE { 1.0f };
|
||||
constexpr float END_SCALE_FAIL { 1.2f };
|
||||
constexpr float END_SCALE_SUCCESS { 0.1f };
|
||||
constexpr float END_SCALE_SUCCESS { 0.0f };
|
||||
constexpr float START_STYLE_SCALE { 1.0f };
|
||||
constexpr float STYLE_CHANGE_SCALE { 1.1f };
|
||||
constexpr float STYLE_MAX_SCALE { 1.2f };
|
||||
constexpr float STYLE_END_SCALE { 1.0f };
|
||||
constexpr float PIVOT_X { 0.5f };
|
||||
constexpr float PIVOT_Y { 0.5f };
|
||||
constexpr float DEFAULT_PIVOT { 0.0f };
|
||||
constexpr float SVG_ORIGINAL_SIZE { 40.0f };
|
||||
constexpr float DEFAULT_POSITION_X { 0.0f };
|
||||
constexpr float BLUR_SIGMA_SCALE { 0.57735f };
|
||||
@ -103,6 +101,10 @@ constexpr float DEFAULT_ALPHA { 1.0f };
|
||||
constexpr float FIRST_PIXELMAP_ALPHA { 0.6f };
|
||||
constexpr float SECOND_PIXELMAP_ALPHA { 0.3f };
|
||||
constexpr float HALF_RATIO { 0.5f };
|
||||
constexpr float ROTATION_DEFAULT { 0.0f };
|
||||
constexpr float ROTATION_FIRST_ORDER { -90.0f };
|
||||
constexpr float ROTATION_SECOND_ORDER { -180.0f };
|
||||
constexpr float ROTATION_THIRD_ORDER { -270.0f };
|
||||
constexpr uint32_t TRANSPARENT_COLOR_ARGB { 0x00000000 };
|
||||
constexpr int32_t DEFAULT_MOUSE_SIZE { 1 };
|
||||
constexpr int32_t DEFAULT_COLOR_VALUE { 0 };
|
||||
@ -170,7 +172,6 @@ bool CheckNodesValid()
|
||||
float GetScaling()
|
||||
{
|
||||
if (g_drawingInfo.isExistScalingValue) {
|
||||
FI_HILOGD("deviceDpi:%{public}f", g_drawingInfo.scalingValue);
|
||||
return g_drawingInfo.scalingValue;
|
||||
}
|
||||
sptr<Rosen::Display> display = Rosen::DisplayManager::GetInstance().GetDisplayById(g_drawingInfo.displayId);
|
||||
@ -203,7 +204,7 @@ int32_t DragDrawing::Init(const DragData &dragData)
|
||||
return checkDragDataResult;
|
||||
}
|
||||
InitDrawingInfo(dragData);
|
||||
CreateWindow(dragData.displayX, dragData.displayY);
|
||||
CreateWindow();
|
||||
CHKPR(g_drawingInfo.surfaceNode, INIT_FAIL);
|
||||
if (InitLayer() != RET_OK) {
|
||||
FI_HILOGE("Init layer failed");
|
||||
@ -263,12 +264,15 @@ int32_t DragDrawing::CheckDragData(const DragData &dragData)
|
||||
return INIT_SUCCESS;
|
||||
}
|
||||
|
||||
void DragDrawing::Draw(int32_t displayId, int32_t displayX, int32_t displayY)
|
||||
void DragDrawing::Draw(int32_t displayId, int32_t displayX, int32_t displayY, bool isNeedAdjustDisplayXY)
|
||||
{
|
||||
if (displayId < 0) {
|
||||
FI_HILOGE("Invalid displayId:%{public}d", displayId);
|
||||
return;
|
||||
}
|
||||
if (isNeedAdjustDisplayXY) {
|
||||
RotateDisplayXY(displayX, displayY);
|
||||
}
|
||||
g_drawingInfo.displayId = displayId;
|
||||
g_drawingInfo.displayX = displayX;
|
||||
g_drawingInfo.displayY = displayY;
|
||||
@ -283,18 +287,10 @@ void DragDrawing::Draw(int32_t displayId, int32_t displayX, int32_t displayY)
|
||||
int32_t positionY = g_drawingInfo.displayY + g_drawingInfo.pixelMapY - adjustSize;
|
||||
CHKPV(g_drawingInfo.parentNode);
|
||||
CHKPV(g_drawingInfo.pixelMap);
|
||||
if ((g_drawingInfo.currentStyle == DragCursorStyle::DEFAULT) ||
|
||||
((g_drawingInfo.currentStyle == DragCursorStyle::MOVE) && (g_drawingInfo.currentDragNum == DRAG_NUM_ONE))) {
|
||||
g_drawingInfo.parentNode->SetBounds(positionX, positionY, g_drawingInfo.pixelMap->GetWidth(),
|
||||
g_drawingInfo.pixelMap->GetHeight());
|
||||
g_drawingInfo.parentNode->SetFrame(positionX, positionY, g_drawingInfo.pixelMap->GetWidth(),
|
||||
g_drawingInfo.pixelMap->GetHeight());
|
||||
} else {
|
||||
g_drawingInfo.parentNode->SetBounds(positionX, positionY, g_drawingInfo.pixelMap->GetWidth() + adjustSize,
|
||||
g_drawingInfo.pixelMap->GetHeight() + adjustSize);
|
||||
g_drawingInfo.parentNode->SetFrame(positionX, positionY, g_drawingInfo.pixelMap->GetWidth() + adjustSize,
|
||||
g_drawingInfo.pixelMap->GetHeight() + adjustSize);
|
||||
}
|
||||
g_drawingInfo.parentNode->SetBounds(positionX, positionY, g_drawingInfo.pixelMap->GetWidth(),
|
||||
g_drawingInfo.pixelMap->GetHeight());
|
||||
g_drawingInfo.parentNode->SetFrame(positionX, positionY, g_drawingInfo.pixelMap->GetWidth(),
|
||||
g_drawingInfo.pixelMap->GetHeight());
|
||||
if (g_drawingInfo.sourceType == MMI::PointerEvent::SOURCE_TYPE_MOUSE) {
|
||||
DoDrawMouse();
|
||||
}
|
||||
@ -342,7 +338,8 @@ int32_t DragDrawing::UpdateShadowPic(const ShadowInfo &shadowInfo)
|
||||
DrawMouseIcon();
|
||||
}
|
||||
ProcessFilter();
|
||||
Draw(g_drawingInfo.displayId, g_drawingInfo.displayX, g_drawingInfo.displayY);
|
||||
Draw(g_drawingInfo.displayId, g_drawingInfo.displayX, g_drawingInfo.displayY, false);
|
||||
RotateDragWindow(rotation_);
|
||||
Rosen::RSTransaction::FlushImplicitTransaction();
|
||||
CHKPR(rsUiDirector_, RET_ERR);
|
||||
rsUiDirector_->SendMessages();
|
||||
@ -859,7 +856,6 @@ int32_t DragDrawing::InitVSync(float endAlpha, float endScale)
|
||||
drawDynamicEffectModifier_->SetScale(endScale);
|
||||
});
|
||||
CHKPR(g_drawingInfo.parentNode, RET_ERR);
|
||||
g_drawingInfo.parentNode->SetPivot(PIVOT_X, PIVOT_Y);
|
||||
Rosen::RSTransaction::FlushImplicitTransaction();
|
||||
startNum_ = START_TIME;
|
||||
needDestroyDragWindow_ = true;
|
||||
@ -944,6 +940,7 @@ void DragDrawing::InitDrawingInfo(const DragData &dragData)
|
||||
g_drawingInfo.displayId = dragData.displayId;
|
||||
g_drawingInfo.displayX = dragData.displayX;
|
||||
g_drawingInfo.displayY = dragData.displayY;
|
||||
RotateDisplayXY(g_drawingInfo.displayX, g_drawingInfo.displayY);
|
||||
g_drawingInfo.extraInfo = dragData.extraInfo;
|
||||
g_drawingInfo.filterInfo = dragData.filterInfo;
|
||||
}
|
||||
@ -992,6 +989,9 @@ int32_t DragDrawing::InitLayer()
|
||||
}
|
||||
int32_t rootNodeSize = std::max(display->GetWidth(), display->GetHeight());
|
||||
InitCanvas(rootNodeSize, rootNodeSize);
|
||||
if (rotation_ != Rosen::Rotation::ROTATION_0) {
|
||||
RotateDragWindow(rotation_);
|
||||
}
|
||||
Rosen::RSTransaction::FlushImplicitTransaction();
|
||||
return RET_OK;
|
||||
}
|
||||
@ -1047,7 +1047,7 @@ void DragDrawing::InitCanvas(int32_t width, int32_t height)
|
||||
rsUiDirector_->SetRoot(g_drawingInfo.rootNode->GetId());
|
||||
}
|
||||
|
||||
void DragDrawing::CreateWindow(int32_t displayX, int32_t displayY)
|
||||
void DragDrawing::CreateWindow()
|
||||
{
|
||||
FI_HILOGD("Parameter screen number:%{public}llu", static_cast<unsigned long long>(screenId_));
|
||||
Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
|
||||
@ -1421,6 +1421,34 @@ void DragDrawing::SetScreenId(uint64_t screenId)
|
||||
screenId_ = screenId;
|
||||
}
|
||||
|
||||
int32_t DragDrawing::RotateDragWindow(Rosen::Rotation rotation)
|
||||
{
|
||||
switch (rotation) {
|
||||
case Rosen::Rotation::ROTATION_0: {
|
||||
return DoRotateDragWindow(ROTATION_DEFAULT);
|
||||
}
|
||||
case Rosen::Rotation::ROTATION_90: {
|
||||
return DoRotateDragWindow(ROTATION_FIRST_ORDER);
|
||||
}
|
||||
case Rosen::Rotation::ROTATION_180: {
|
||||
return DoRotateDragWindow(ROTATION_SECOND_ORDER);
|
||||
}
|
||||
case Rosen::Rotation::ROTATION_270: {
|
||||
return DoRotateDragWindow(ROTATION_THIRD_ORDER);
|
||||
}
|
||||
default: {
|
||||
FI_HILOGE("Invalid parameter, rotation:%{public}d", static_cast<int32_t>(rotation));
|
||||
return RET_ERR;
|
||||
}
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void DragDrawing::SetRotation(Rosen::Rotation rotation)
|
||||
{
|
||||
rotation_ = rotation;
|
||||
}
|
||||
|
||||
void DragDrawing::ProcessFilter()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
@ -1771,6 +1799,78 @@ void DragDrawing::ClearMultiSelectedData()
|
||||
}
|
||||
}
|
||||
|
||||
void DragDrawing::RotateDisplayXY(int32_t &displayX, int32_t &displayY)
|
||||
{
|
||||
sptr<Rosen::Display> display = Rosen::DisplayManager::GetInstance().GetDisplayById(g_drawingInfo.displayId);
|
||||
if (display == nullptr) {
|
||||
FI_HILOGD("Get display info failed, display:%{public}d", g_drawingInfo.displayId);
|
||||
display = Rosen::DisplayManager::GetInstance().GetDisplayById(0);
|
||||
CHKPV(display);
|
||||
}
|
||||
switch (rotation_) {
|
||||
case Rosen::Rotation::ROTATION_0: {
|
||||
break;
|
||||
}
|
||||
case Rosen::Rotation::ROTATION_90: {
|
||||
int32_t temp = displayY;
|
||||
displayY = display->GetWidth() - displayX;
|
||||
displayX = temp;
|
||||
break;
|
||||
}
|
||||
case Rosen::Rotation::ROTATION_180: {
|
||||
displayX = display->GetWidth() - displayX;
|
||||
displayY = display->GetHeight() - displayY;
|
||||
break;
|
||||
}
|
||||
case Rosen::Rotation::ROTATION_270: {
|
||||
int32_t temp = displayX;
|
||||
displayX = display->GetHeight() - displayY;
|
||||
displayY = temp;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
FI_HILOGE("Invalid parameter, rotation:%{public}d", static_cast<int32_t>(rotation_));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t DragDrawing::DoRotateDragWindow(float rotation)
|
||||
{
|
||||
FI_HILOGD("rotation:%{public}f", rotation);
|
||||
CHKPR(g_drawingInfo.parentNode, RET_ERR);
|
||||
CHKPR(g_drawingInfo.pixelMap, RET_ERR);
|
||||
if ((g_drawingInfo.pixelMap->GetWidth() <= 0) || (g_drawingInfo.pixelMap->GetHeight() <= 0)) {
|
||||
FI_HILOGE("Invalid parameter pixelmap");
|
||||
return RET_ERR;
|
||||
}
|
||||
float pivotX = 0.0f;
|
||||
float pivotY = 0.0f;
|
||||
int32_t adjustSize = TWELVE_SIZE * GetScaling();
|
||||
if ((g_drawingInfo.currentStyle == DragCursorStyle::DEFAULT) ||
|
||||
((g_drawingInfo.currentStyle == DragCursorStyle::MOVE) && (g_drawingInfo.currentDragNum == DRAG_NUM_ONE))) {
|
||||
pivotX = -g_drawingInfo.pixelMapX * 1.0 / g_drawingInfo.pixelMap->GetWidth();
|
||||
pivotY = (-g_drawingInfo.pixelMapY + adjustSize) * 1.0 / g_drawingInfo.pixelMap->GetHeight();
|
||||
} else {
|
||||
pivotX = -g_drawingInfo.pixelMapX * 1.0 / (g_drawingInfo.pixelMap->GetWidth() + adjustSize);
|
||||
pivotY = (-g_drawingInfo.pixelMapY + adjustSize) * 1.0 / (g_drawingInfo.pixelMap->GetHeight() + adjustSize);
|
||||
}
|
||||
g_drawingInfo.parentNode->SetPivot(pivotX, pivotY);
|
||||
g_drawingInfo.parentNode->SetRotation(rotation);
|
||||
if (g_drawingInfo.sourceType == MMI::PointerEvent::SOURCE_TYPE_MOUSE) {
|
||||
if (!CheckNodesValid()) {
|
||||
FI_HILOGE("Check nodes valid failed");
|
||||
return RET_ERR;
|
||||
}
|
||||
std::shared_ptr<Rosen::RSCanvasNode> mouseIconNode = g_drawingInfo.nodes[MOUSE_ICON_INDEX];
|
||||
CHKPR(mouseIconNode, RET_ERR);
|
||||
mouseIconNode->SetPivot(DEFAULT_PIVOT, DEFAULT_PIVOT);
|
||||
mouseIconNode->SetRotation(rotation);
|
||||
}
|
||||
Rosen::RSTransaction::FlushImplicitTransaction();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
bool DragDrawing::ParserRadius(float &radius)
|
||||
{
|
||||
FI_HILOGD("ExtraInfo size:%{public}zu, extraInfo:%{public}s, filterInfo size:%{public}zu, filterInfo:%{public}s",
|
||||
@ -1834,9 +1934,10 @@ void DrawSVGModifier::Draw(Rosen::RSDrawingContext& context) const
|
||||
}
|
||||
std::shared_ptr<Rosen::RSCanvasNode> dragStyleNode = g_drawingInfo.nodes[DRAG_STYLE_INDEX];
|
||||
CHKPV(dragStyleNode);
|
||||
dragStyleNode->SetBounds(svgTouchPositionX, (TWELVE_SIZE - EIGHT_SIZE) * scalingValue, stylePixelMap_->GetWidth(),
|
||||
adjustSize = (TWELVE_SIZE - EIGHT_SIZE) * scalingValue;
|
||||
dragStyleNode->SetBounds(svgTouchPositionX, adjustSize, stylePixelMap_->GetWidth() + adjustSize,
|
||||
stylePixelMap_->GetHeight());
|
||||
dragStyleNode->SetFrame(svgTouchPositionX, (TWELVE_SIZE - EIGHT_SIZE) * scalingValue, stylePixelMap_->GetWidth(),
|
||||
dragStyleNode->SetFrame(svgTouchPositionX, adjustSize, stylePixelMap_->GetWidth() + adjustSize,
|
||||
stylePixelMap_->GetHeight());
|
||||
dragStyleNode->SetBgImageWidth(stylePixelMap_->GetWidth());
|
||||
dragStyleNode->SetBgImageHeight(stylePixelMap_->GetHeight());
|
||||
@ -1846,14 +1947,6 @@ void DrawSVGModifier::Draw(Rosen::RSDrawingContext& context) const
|
||||
rosenImage->SetPixelMap(stylePixelMap_);
|
||||
rosenImage->SetImageRepeat(0);
|
||||
dragStyleNode->SetBgImage(rosenImage);
|
||||
adjustSize = TWELVE_SIZE * scalingValue;
|
||||
int32_t positionX = g_drawingInfo.displayX + g_drawingInfo.pixelMapX;
|
||||
int32_t positionY = g_drawingInfo.displayY + g_drawingInfo.pixelMapY - adjustSize;
|
||||
CHKPV(g_drawingInfo.parentNode);
|
||||
g_drawingInfo.parentNode->SetBounds(positionX, positionY, g_drawingInfo.pixelMap->GetWidth() + adjustSize,
|
||||
g_drawingInfo.pixelMap->GetHeight() + adjustSize);
|
||||
g_drawingInfo.parentNode->SetFrame(positionX, positionY, g_drawingInfo.pixelMap->GetWidth() + adjustSize,
|
||||
g_drawingInfo.pixelMap->GetHeight() + adjustSize);
|
||||
Rosen::RSTransaction::FlushImplicitTransaction();
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,14 @@ int32_t DragManager::Init(IContext* context)
|
||||
return;
|
||||
}
|
||||
int32_t ret = samgrProxy->SubscribeSystemAbility(COMMON_EVENT_SERVICE_ID, statusListener_);
|
||||
FI_HILOGI("SubscribeSystemAbility result:%{public}d", ret);
|
||||
FI_HILOGI("SubscribeSystemAbility COMMON_EVENT_SERVICE_ID result:%{public}d", ret);
|
||||
displayAbilityStatusChange_ = new (std::nothrow) DisplayAbilityStatusChange(context_);
|
||||
if (displayAbilityStatusChange_ == nullptr) {
|
||||
FI_HILOGE("displayAbilityStatusChange is nullptr");
|
||||
return;
|
||||
}
|
||||
ret = samgrProxy->SubscribeSystemAbility(DISPLAY_MANAGER_SERVICE_SA_ID, displayAbilityStatusChange_);
|
||||
FI_HILOGI("SubscribeSystemAbility DISPLAY_MANAGER_SERVICE_SA_ID result:%{public}d", ret);
|
||||
});
|
||||
return RET_OK;
|
||||
}
|
||||
@ -1071,6 +1078,17 @@ int32_t DragManager::AddPrivilege(int32_t tokenId)
|
||||
SendDragData(tokenId, dragData.udKey);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t DragManager::RotateDragWindow(Rosen::Rotation rotation)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
dragDrawing_.SetRotation(rotation);
|
||||
if (dragState_ != DragState::START && dragState_ != DragState::MOTION_DRAGGING) {
|
||||
FI_HILOGD("Drag instance not running");
|
||||
return RET_OK;
|
||||
}
|
||||
return dragDrawing_.RotateDragWindow(rotation);
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
|
1
services/native/test/unittest/BUILD.gn
Executable file → Normal file
1
services/native/test/unittest/BUILD.gn
Executable file → Normal file
@ -114,6 +114,7 @@ ohos_unittest("DragDataManagerTest") {
|
||||
"image_framework:image_native",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -27,6 +27,7 @@ deps_ex = [
|
||||
"hitrace:hitrace_meter",
|
||||
"hilog:libhilog",
|
||||
"input:libmmi-client",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -32,6 +32,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -32,6 +32,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -32,6 +32,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -27,6 +27,7 @@ deps_ex = [
|
||||
"hitrace:hitrace_meter",
|
||||
"hilog:libhilog",
|
||||
"input:libmmi-client",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -27,6 +27,7 @@ deps_ex = [
|
||||
"hitrace:hitrace_meter",
|
||||
"hilog:libhilog",
|
||||
"input:libmmi-client",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
@ -29,6 +29,7 @@ deps_ex = [
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
|
Loading…
Reference in New Issue
Block a user