floating window stretchableduring dragging

Signed-off-by: zhirong <215782872@qq.com>
Change-Id: Ie3ac3618fb9bb3e59453e9fd03be29ef14fd3d53
Signed-off-by: zhirong <215782872@qq.com>
This commit is contained in:
zhirong
2022-05-09 19:05:58 +08:00
parent ff51bbe28e
commit 731dae8f19
14 changed files with 131 additions and 11 deletions
@@ -16,9 +16,12 @@
<Configs>
<!--decor enable is true means app main window show decoration-->
<decor enable="false"></decor>
<!--max number of main window that could be shown on display-->
<maxAppWindowNumber>100</maxAppWindowNumber>
<!--minimizeByOther enable is true means fullscreen window will be minmized by other fullscreen window-->
<minimizeByOther enable="true"></minimizeByOther>
<!--window mdoe change hot zones config, fullscreen primary secondary-->
<modeChangeHotZones>50 50 50</modeChangeHotZones>
<!--stretchable enable is true means all window be stretchable-->
<stretchable enable="false"></stretchable>
</Configs>
+12
View File
@@ -228,6 +228,18 @@ public:
return result;
}
static PointInfo CalculateOriginPosition(const Rect& rOrigin, const Rect& rActial, const PointInfo& pos)
{
PointInfo ret = pos;
ret.x += rActial.posX_ - pos.x;
ret.y += rActial.posY_ - pos.y;
ret.x += rOrigin.posX_ - rActial.posX_;
ret.y += rOrigin.posY_ - rActial.posY_;
ret.x += (pos.x - rActial.posX_) * rOrigin.width_ / rActial.width_;
ret.y += (pos.y - rActial.posY_) * rOrigin.height_ / rActial.height_;
return ret;
}
private:
WindowHelper() = default;
~WindowHelper() = default;
+1
View File
@@ -36,6 +36,7 @@ public:
void UpdateDisplayId(DisplayId from, DisplayId to) override;
void UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info) override;
void UpdateActiveStatus(bool isActive) override;
void UpdateWindowStretchable(bool stretchable) override;
sptr<WindowProperty> GetWindowProperty() override;
private:
sptr<WindowImpl> window_;
+5
View File
@@ -178,6 +178,7 @@ public:
void UpdateDisplayId(DisplayId from, DisplayId to);
void UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info);
void UpdateActiveStatus(bool isActive);
void UpdateWindowStretchable(bool stretchable);
virtual WMError SetUIContent(const std::string& contentInfo, NativeEngine* engine,
NativeValue* storage, bool isdistributed, AppExecFwk::Ability* ability) override;
@@ -266,6 +267,7 @@ private:
Rect GetSystemAlarmWindowDefaultSize(Rect defaultRect);
void HandleModeChangeHotZones(int32_t posX, int32_t posY);
WMError NotifyWindowTransition(TransitionReason reason);
void UpdatePointerEventForStretchableWindow(std::shared_ptr<MMI::PointerEvent>& pointerEvent);
// colorspace, gamut
using ColorSpaceConvertMap = struct {
@@ -310,8 +312,11 @@ private:
Rect startPointRect_ = { 0, 0, 0, 0 };
Rect startRectExceptFrame_ = { 0, 0, 0, 0 };
Rect startRectExceptCorner_ = { 0, 0, 0, 0 };
Rect originRect_ = {0, 0, 0, 0};
bool isAppDecorEnbale_ = true;
bool isSystemDecorEnable_ = true;
bool isStretchable_ = false;
bool isStretchableSet_ = false;
};
}
}
+2
View File
@@ -38,6 +38,7 @@ public:
TRANS_ID_UPDATE_DISPLAY_ID,
TRANS_ID_UPDATE_OCCUPIED_AREA,
TRANS_ID_UPDATE_ACTIVE_STATUS,
TRANS_ID_UPDATE_WINDOW_STRETCHABLE,
TRANS_ID_GET_WINDOW_PROPERTY,
};
@@ -51,6 +52,7 @@ public:
virtual void UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info) = 0;
virtual void UpdateActiveStatus(bool isActive) = 0;
virtual sptr<WindowProperty> GetWindowProperty() = 0;
virtual void UpdateWindowStretchable(bool stretchable) = 0;
};
} // namespace Rosen
} // namespace OHOS
+1
View File
@@ -37,6 +37,7 @@ public:
void UpdateDisplayId(DisplayId from, DisplayId to) override;
void UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info) override;
void UpdateActiveStatus(bool isActive) override;
void UpdateWindowStretchable(bool stretchable) override;
sptr<WindowProperty> GetWindowProperty() override;
private:
static inline BrokerDelegator<WindowProxy> delegator_;
+9
View File
@@ -109,6 +109,15 @@ void WindowAgent::UpdateActiveStatus(bool isActive)
window_->UpdateActiveStatus(isActive);
}
void WindowAgent::UpdateWindowStretchable(bool stretchable)
{
if (window_ == nullptr) {
WLOGFE("window is null");
return;
}
window_->UpdateWindowStretchable(stretchable);
}
sptr<WindowProperty> WindowAgent::GetWindowProperty()
{
if (window_ == nullptr) {
+51 -4
View File
@@ -1352,19 +1352,38 @@ void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSize
return;
}
property_->SetWindowRect(rect);
// update originRect when window show for the first time.
if (!isStretchableSet_) {
originRect_ = rect;
isStretchableSet_ = true;
}
Rect rectToAce = rect;
// update rectToAce for stretchable window
if (isStretchable_ && GetMode() == WindowMode::WINDOW_MODE_FLOATING) {
if (reason == WindowSizeChangeReason::RESIZE ||
reason == WindowSizeChangeReason::RECOVER) {
originRect_ = rect;
} else {
rectToAce = originRect_;
}
}
WLOGFI("sizeChange callback size: %{public}lu", (unsigned long)windowChangeListeners_.size());
for (auto& listener : windowChangeListeners_) {
if (listener != nullptr) {
listener->OnSizeChange(rect, reason);
listener->OnSizeChange(rectToAce, reason);
}
}
if (uiContent_ != nullptr) {
Ace::ViewportConfig config;
WLOGFI("UpdateViewportConfig Id:%{public}u, windowRect:[%{public}d, %{public}d, %{public}u, %{public}u]",
property_->GetWindowId(), rect.posX_, rect.posY_, rect.width_, rect.height_);
config.SetSize(rect.width_, rect.height_);
config.SetPosition(rect.posX_, rect.posY_);
property_->GetWindowId(), rectToAce.posX_, rectToAce.posY_, rectToAce.width_, rectToAce.height_);
config.SetSize(rectToAce.width_, rectToAce.height_);
config.SetPosition(rectToAce.posX_, rectToAce.posY_);
config.SetDensity(virtualPixelRatio);
uiContent_->UpdateViewportConfig(config, reason);
WLOGFI("notify uiContent window size change end");
@@ -1514,6 +1533,24 @@ void WindowImpl::HandleModeChangeHotZones(int32_t posX, int32_t posY)
}
}
void WindowImpl::UpdatePointerEventForStretchableWindow(std::shared_ptr<MMI::PointerEvent>& pointerEvent)
{
MMI::PointerEvent::PointerItem pointerItem;
if (!pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem)) {
WLOGFW("Point item is invalid");
return;
}
PointInfo originPos =
WindowHelper::CalculateOriginPosition(originRect_, GetRect(),
{ pointerItem.GetGlobalX(), pointerItem.GetGlobalY() });
pointerItem.SetGlobalX(originPos.x);
pointerItem.SetGlobalY(originPos.y);
pointerItem.SetLocalX(originPos.x - originRect_.posX_);
pointerItem.SetLocalY(originPos.y - originRect_.posY_);
pointerEvent->UpdatePointerItem(pointerEvent->GetPointerId(), pointerItem);
}
void WindowImpl::EndMoveOrDragWindow(int32_t posX, int32_t posY, int32_t pointId)
{
if (pointId != startPointerId_) {
@@ -1670,6 +1707,10 @@ void WindowImpl::ConsumePointerEvent(std::shared_ptr<MMI::PointerEvent>& pointer
if (IsPointerEventConsumed()) {
return;
}
if (isStretchable_ && GetMode() == WindowMode::WINDOW_MODE_FLOATING) {
WLOGFI("update pointer event for stretchable window");
UpdatePointerEventForStretchableWindow(pointerEvent);
}
for (auto& listener : inputEventListeners_) {
if (listener != nullptr) {
WLOGI("ConsumePointEvent pointerEvent is old api consumed");
@@ -1843,6 +1884,12 @@ void WindowImpl::UpdateActiveStatus(bool isActive)
}
}
void WindowImpl::UpdateWindowStretchable(bool stretchable)
{
WLOGFI("window stretchable: %{public}d, id: %{public}u", stretchable, property_->GetWindowId());
isStretchable_ = stretchable;
}
Rect WindowImpl::GetSystemAlarmWindowDefaultSize(Rect defaultRect)
{
auto display = DisplayManager::GetInstance().GetDisplayById(property_->GetDisplayId());
+21
View File
@@ -231,6 +231,27 @@ void WindowProxy::UpdateActiveStatus(bool isActive)
return;
}
void WindowProxy::UpdateWindowStretchable(bool stretchable)
{
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC);
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return;
}
if (!data.WriteBool(stretchable)) {
WLOGFE("Write Focus failed");
return;
}
if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_WINDOW_STRETCHABLE),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
}
return;
}
sptr<WindowProperty> WindowProxy::GetWindowProperty()
{
MessageParcel data;
+5
View File
@@ -102,6 +102,11 @@ int WindowStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParce
UpdateActiveStatus(isActive);
break;
}
case WindowMessage::TRANS_ID_UPDATE_WINDOW_STRETCHABLE: {
bool stretchable = data.ReadBool();
UpdateWindowStretchable(stretchable);
break;
}
case WindowMessage::TRANS_ID_GET_WINDOW_PROPERTY: {
auto property = GetWindowProperty();
reply.WriteParcelable(property.GetRefPtr());
+2
View File
@@ -81,6 +81,7 @@ public:
ModeChangeHotZones& hotZones, const ModeChangeHotZonesConfig& config);
void NotifyVirtualPixelRatioChange(sptr<DisplayInfo> displayInfo);
std::vector<DisplayId> GetAllDisplayIds() const;
void SetWindowStretchable(bool stretchable);
private:
void OnRemoteDied(const sptr<IRemoteObject>& remoteObject);
@@ -112,6 +113,7 @@ private:
this, std::placeholders::_1));
Callback callback_;
int maxAppWindowNumber_ = 100;
bool isWindowStretchable_ = false;
};
}
}
+2 -1
View File
@@ -51,7 +51,8 @@ bool WindowManagerConfig::LoadConfigXml(const std::string& configFilePath)
auto nodeName = curNodePtr->name;
if (!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("decor")) ||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("minimizeByOther"))) {
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("minimizeByOther")) ||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("stretchable"))) {
ReadEnableConfigInfo(curNodePtr);
continue;
}
+10 -6
View File
@@ -163,26 +163,30 @@ int WindowManagerService::Dump(int fd, const std::vector<std::u16string>& args)
void WindowManagerService::ConfigureWindowManagerService()
{
auto enableConfig = WindowManagerConfig::GetEnableConfig();
auto numbersConfig = WindowManagerConfig::GetNumbersConfig();
const auto& enableConfig = WindowManagerConfig::GetEnableConfig();
const auto& numbersConfig = WindowManagerConfig::GetNumbersConfig();
if (enableConfig.count("decor") != 0) {
isSystemDecorEnable_ = enableConfig["decor"];
isSystemDecorEnable_ = enableConfig.at("decor");
}
if (enableConfig.count("minimizeByOther") != 0) {
windowController_->SetMinimizedByOtherWindow(enableConfig["minimizeByOther"]);
windowController_->SetMinimizedByOtherWindow(enableConfig.at("minimizeByOther"));
}
if (enableConfig.count("stretchable") != 0) {
windowRoot_->SetWindowStretchable(enableConfig.at("stretchable"));
}
if (numbersConfig.count("maxAppWindowNumber") != 0) {
auto numbers = numbersConfig["maxAppWindowNumber"];
auto numbers = numbersConfig.at("maxAppWindowNumber");
if (numbers.size() == 1) {
windowRoot_->SetMaxAppWindowNumber(numbers[0]);
}
}
if (numbersConfig.count("modeChangeHotZones") != 0) {
auto numbers = numbersConfig["modeChangeHotZones"];
auto numbers = numbersConfig.at("modeChangeHotZones");
if (numbers.size() == 3) { // 3 hot zones
hotZonesConfig_.fullscreenRange_ = static_cast<uint32_t>(numbers[0]); // 0 fullscreen
hotZonesConfig_.primaryRange_ = static_cast<uint32_t>(numbers[1]); // 1 primary
+7
View File
@@ -186,6 +186,7 @@ WMError WindowRoot::SaveWindow(const sptr<WindowNode>& node)
windowNodeMap_.insert(std::make_pair(node->GetWindowId(), node));
if (node->GetWindowToken()) {
AddDeathRecipient(node);
node->GetWindowToken()->UpdateWindowStretchable(isWindowStretchable_);
}
return WMError::WM_OK;
@@ -1016,5 +1017,11 @@ void WindowRoot::NotifyVirtualPixelRatioChange(sptr<DisplayInfo> displayInfo)
}
container->UpdateVirtualPixelRatio(displayInfo->GetDisplayId(), displayInfo->GetVirtualPixelRatio());
}
void WindowRoot::SetWindowStretchable(bool stretchable)
{
WLOGFI("set window stretchable to %{publec}d", stretchable);
isWindowStretchable_ = stretchable;
}
} // namespace Rosen
} // namespace OHOS