mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
modify drag and move
Change-Id: I6a97da44ec53428b31b0c2a0bf3e271737ccf5ed Signed-off-by: l00574490 <liuqi149@huawei.com>
This commit is contained in:
@@ -75,7 +75,6 @@ public:
|
||||
private:
|
||||
std::string windowName_;
|
||||
Rect windowRect_ { 0, 0, 0, 0 };
|
||||
Rect hotZoneRect_ { 0, 0, 0, 0 };
|
||||
WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW };
|
||||
WindowMode mode_ { WindowMode::WINDOW_MODE_FULLSCREEN };
|
||||
WindowBlurLevel level_ { WindowBlurLevel::WINDOW_BLUR_OFF };
|
||||
|
||||
@@ -29,14 +29,6 @@ void WindowProperty::SetWindowRect(const struct Rect& rect)
|
||||
windowRect_ = rect;
|
||||
}
|
||||
|
||||
void WindowProperty::SetWindowHotZoneRect(const struct Rect& rect)
|
||||
{
|
||||
hotZoneRect_.posX_ = rect.posX_ - HOTZONE;
|
||||
hotZoneRect_.posY_ = rect.posY_ - HOTZONE;
|
||||
hotZoneRect_.width_ = rect.width_ + HOTZONE + HOTZONE;
|
||||
hotZoneRect_.height_ = rect.height_ + HOTZONE + HOTZONE;
|
||||
}
|
||||
|
||||
void WindowProperty::SetWindowType(WindowType type)
|
||||
{
|
||||
type_ = type;
|
||||
@@ -133,11 +125,6 @@ Rect WindowProperty::GetWindowRect() const
|
||||
return windowRect_;
|
||||
}
|
||||
|
||||
Rect WindowProperty::GetWindowHotZoneRect() const
|
||||
{
|
||||
return hotZoneRect_;
|
||||
}
|
||||
|
||||
WindowType WindowProperty::GetWindowType() const
|
||||
{
|
||||
return type_;
|
||||
|
||||
@@ -150,7 +150,6 @@ private:
|
||||
void OnVsync(int64_t timeStamp);
|
||||
static sptr<Window> FindTopWindow(uint32_t topWinId);
|
||||
WMError Drag(const Rect& rect);
|
||||
void ConsumeDividerPointerEvent(std::shared_ptr<MMI::PointerEvent>& inputEvent);
|
||||
void ConsumeDragOrMoveEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent);
|
||||
void HandleDragEvent(const MMI::PointerEvent::PointerItem& pointerItem);
|
||||
void HandleMoveEvent(const MMI::PointerEvent::PointerItem& pointerItem);
|
||||
|
||||
+21
-48
@@ -839,24 +839,33 @@ void WindowImpl::ConsumeDragOrMoveEvent(std::shared_ptr<MMI::PointerEvent>& poin
|
||||
{
|
||||
int32_t action = pointerEvent->GetPointerAction();
|
||||
MMI::PointerEvent::PointerItem pointerItem;
|
||||
static bool hasPointDown = false;
|
||||
static int32_t startPointerId;
|
||||
int curPointerId = pointerEvent->GetPointerId();
|
||||
switch (action) {
|
||||
case MMI::PointerEvent::POINTER_ACTION_DOWN: {
|
||||
if (pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem)) {
|
||||
if (!hasPointDown && pointerEvent->GetPointerItem(curPointerId, pointerItem)) {
|
||||
startPointRect_ = GetRect();
|
||||
startPointPosX_ = pointerItem.GetGlobalX();
|
||||
startPointPosY_ = pointerItem.GetGlobalY();
|
||||
if (!WindowHelper::IsPointInWindow(startPointPosX_, startPointPosY_, startPointRect_)) {
|
||||
startPointerId = curPointerId;
|
||||
hasPointDown = true;
|
||||
if (GetType() == WindowType::WINDOW_TYPE_DOCK_SLICE) {
|
||||
startMoveFlag_ = true;
|
||||
} else if (!WindowHelper::IsPointInWindow(startPointPosX_, startPointPosY_, startPointRect_)) {
|
||||
startDragFlag_ = true;
|
||||
}
|
||||
WLOGFI("[PointDown] windowId: %{public}d, pointPos: [%{public}d, %{public}d], winRect: "
|
||||
"[%{public}d, %{public}d, %{public}d, %{public}d], startDragFlag: %{public}d",
|
||||
GetWindowId(), startPointPosX_, startPointPosY_, startPointRect_.posX_, startPointRect_.posY_,
|
||||
WLOGFI("[Point Down] windowId: %{public}d, pointerId: %{public}d, isDivider: %{public}d, "
|
||||
"pointPos: [%{public}d, %{public}d], startDragFlag: %{public}d, "
|
||||
"winRect: [%{public}d, %{public}d, %{public}d, %{public}d]",
|
||||
GetWindowId(), curPointerId, (GetType() == WindowType::WINDOW_TYPE_DOCK_SLICE),
|
||||
startPointPosX_, startPointPosY_, startPointRect_.posX_, startPointRect_.posY_,
|
||||
startPointRect_.width_, startPointRect_.height_, startDragFlag_);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MMI::PointerEvent::POINTER_ACTION_MOVE: {
|
||||
if (pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem)) {
|
||||
if ((curPointerId == startPointerId) && pointerEvent->GetPointerItem(curPointerId, pointerItem)) {
|
||||
if (startMoveFlag_) {
|
||||
HandleMoveEvent(pointerItem);
|
||||
}
|
||||
@@ -868,45 +877,13 @@ void WindowImpl::ConsumeDragOrMoveEvent(std::shared_ptr<MMI::PointerEvent>& poin
|
||||
}
|
||||
case MMI::PointerEvent::POINTER_ACTION_UP:
|
||||
case MMI::PointerEvent::POINTER_ACTION_CANCEL:
|
||||
startDragFlag_ = false;
|
||||
startMoveFlag_ = false;
|
||||
WLOGFE("[Point Up/Cancel] windowId: %{public}d", GetWindowId());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void WindowImpl::ConsumeDividerPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
int32_t action = pointerEvent->GetPointerAction();
|
||||
WLOGI("ConsumeDividerPointerEvent pointerEvent action: %{public}d, windowId: %{public}u", action, GetWindowId());
|
||||
MMI::PointerEvent::PointerItem pointerItem;
|
||||
switch (action) {
|
||||
case MMI::PointerEvent::POINTER_ACTION_DOWN: {
|
||||
if (pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem)) {
|
||||
startMoveFlag_ = true;
|
||||
startPointRect_ = GetRect();
|
||||
startPointPosX_ = pointerItem.GetGlobalX();
|
||||
startPointPosY_ = pointerItem.GetGlobalY();
|
||||
WLOGFI("[Point divider] point pos: [%{public}d, %{public}d], "
|
||||
"winRect: [%{public}d, %{public}d, %{public}d, %{public}d]",
|
||||
startPointPosX_, startPointPosY_, startPointRect_.posX_, startPointRect_.posY_,
|
||||
startPointRect_.width_, startPointRect_.height_);
|
||||
if (curPointerId == startPointerId) {
|
||||
startDragFlag_ = false;
|
||||
startMoveFlag_ = false;
|
||||
hasPointDown = false;
|
||||
WLOGFI("[Point Up/Cancel] windowId: %{public}d, pointerId: %{public}d", GetWindowId(), curPointerId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MMI::PointerEvent::POINTER_ACTION_MOVE: {
|
||||
if (startMoveFlag_ && (pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem))) {
|
||||
HandleMoveEvent(pointerItem);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MMI::PointerEvent::POINTER_ACTION_UP:
|
||||
case MMI::PointerEvent::POINTER_ACTION_CANCEL:
|
||||
startMoveFlag_ = false;
|
||||
WLOGFE("[Point divider Up/Cancel] windowId: %{public}d", GetWindowId());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -919,12 +896,8 @@ void WindowImpl::ConsumePointerEvent(std::shared_ptr<MMI::PointerEvent>& pointer
|
||||
if (action == MMI::PointerEvent::POINTER_ACTION_DOWN || action == MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN) {
|
||||
SingletonContainer::Get<WindowAdapter>().ProcessWindowTouchedEvent(property_->GetWindowId());
|
||||
}
|
||||
if (GetType() == WindowType::WINDOW_TYPE_DOCK_SLICE) {
|
||||
ConsumeDividerPointerEvent(pointerEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
if (WindowHelper::IsMainFloatingWindow(GetType(), GetMode())) {
|
||||
if (WindowHelper::IsMainFloatingWindow(GetType(), GetMode()) || GetType() == WindowType::WINDOW_TYPE_DOCK_SLICE) {
|
||||
ConsumeDragOrMoveEvent(pointerEvent);
|
||||
if (startDragFlag_ || startMoveFlag_) {
|
||||
return;
|
||||
|
||||
@@ -71,6 +71,7 @@ public:
|
||||
int32_t priority_ { 0 };
|
||||
bool requestedVisibility_ { false };
|
||||
bool currentVisibility_ { false };
|
||||
bool hasDecorated = false;
|
||||
|
||||
private:
|
||||
sptr<WindowProperty> property_;
|
||||
|
||||
@@ -152,6 +152,7 @@ WMError WindowController::Resize(uint32_t windowId, uint32_t width, uint32_t hei
|
||||
Rect lastRect = property->GetWindowRect();
|
||||
Rect newRect = { lastRect.posX_, lastRect.posY_, width, height };
|
||||
property->SetWindowRect(newRect);
|
||||
node->hasDecorated = false;
|
||||
WMError res = windowRoot_->UpdateWindowNode(windowId);
|
||||
if (res != WMError::WM_OK) {
|
||||
return res;
|
||||
@@ -177,7 +178,7 @@ WMError WindowController::Drag(uint32_t windowId, const Rect& rect)
|
||||
if (res != WMError::WM_OK) {
|
||||
return res;
|
||||
}
|
||||
RSTransaction::FlushImplicitTransaction();
|
||||
FlushWindowInfo(windowId);
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,8 +163,10 @@ void WindowLayoutPolicyCascade::UpdateLayoutRect(sptr<WindowNode>& node)
|
||||
if (!floatingWindow) { // fullscreen window
|
||||
winRect = limitRect;
|
||||
} else { // floating window
|
||||
if (node->GetWindowProperty()->GetDecorEnable()) { // is decorable
|
||||
// decorate window only once in case of changing width or height continuously
|
||||
if (!node->hasDecorated && node->GetWindowProperty()->GetDecorEnable()) {
|
||||
winRect = ComputeDecoratedWindowRect(winRect);
|
||||
node->hasDecorated = true;
|
||||
}
|
||||
if (subWindow && parentLimit) { // subwidow and limited by parent
|
||||
limitRect = node->parent_->GetLayoutRect();
|
||||
|
||||
@@ -189,11 +189,7 @@ WMError WindowManagerService::Drag(uint32_t windowId, const Rect& rect)
|
||||
windowId, rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
WM_SCOPED_TRACE("wms:Drag");
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
WMError res = windowController_->Drag(windowId, rect);
|
||||
if (res == WMError::WM_OK) {
|
||||
inputWindowMonitor_->UpdateInputWindow(windowId);
|
||||
}
|
||||
return res;
|
||||
return windowController_->Drag(windowId, rect);
|
||||
}
|
||||
|
||||
WMError WindowManagerService::RequestFocus(uint32_t windowId)
|
||||
|
||||
@@ -118,17 +118,19 @@ Rect WindowNode::GetHotZoneRect() const
|
||||
{
|
||||
Rect rect = layoutRect_;
|
||||
if (GetWindowType() == WindowType::WINDOW_TYPE_DOCK_SLICE) {
|
||||
const int32_t divTouchRegion = 20;
|
||||
const int32_t divHotZone = 20;
|
||||
if (rect.width_ < rect.height_) {
|
||||
rect.posX_ -= divTouchRegion;
|
||||
rect.width_ += (divTouchRegion + divTouchRegion);
|
||||
rect.posX_ -= divHotZone;
|
||||
rect.width_ += (divHotZone + divHotZone);
|
||||
} else {
|
||||
rect.posY_ -= divTouchRegion;
|
||||
rect.height_ += (divTouchRegion + divTouchRegion);
|
||||
rect.posY_ -= divHotZone;
|
||||
rect.height_ += (divHotZone + divHotZone);
|
||||
}
|
||||
} else if (WindowHelper::IsMainFloatingWindow(GetWindowType(), GetWindowMode())) {
|
||||
property_->SetWindowHotZoneRect(rect);
|
||||
rect = property_->GetWindowHotZoneRect();
|
||||
rect.posX_ -= HOTZONE;
|
||||
rect.posY_ -= HOTZONE;
|
||||
rect.width_ += (HOTZONE + HOTZONE);
|
||||
rect.height_ += (HOTZONE + HOTZONE);
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
@@ -222,6 +222,7 @@ WMError WindowNodeContainer::RemoveWindowNode(sptr<WindowNode>& node)
|
||||
}
|
||||
node->requestedVisibility_ = false;
|
||||
node->currentVisibility_ = false;
|
||||
node->hasDecorated = false;
|
||||
for (auto& child : node->children_) {
|
||||
child->currentVisibility_ = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user