mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 15:00:12 +00:00
demend_raise_window_to_top
Signed-off-by: zhangkai <zhangkai324@huawei.com> Change-Id: Ic5f83b2226e437181bdc6dc3b79e992189aaba31
This commit is contained in:
parent
b4d09dc201
commit
23b137dc16
@ -334,6 +334,7 @@ public:
|
||||
virtual void SetSystemPrivacyMode(bool isSystemPrivacyMode) = 0;
|
||||
virtual WMError BindDialogTarget(sptr<IRemoteObject> targetToken) = 0;
|
||||
virtual void SetSnapshotSkip(bool isSkip) = 0;
|
||||
virtual WmErrorCode RaiseToAppTop() = 0;
|
||||
|
||||
// window effect
|
||||
virtual WMError SetCornerRadius(float cornerRadius) = 0;
|
||||
|
@ -454,6 +454,13 @@ NativeValue* JsWindow::SetSnapshotSkip(NativeEngine* engine, NativeCallbackInfo*
|
||||
return (me != nullptr) ? me->OnSetSnapshotSkip(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::RaiseToAppTop(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
WLOGI("RaiseToAppTop");
|
||||
JsWindow* me = CheckParamsAndGetThis<JsWindow>(engine, info);
|
||||
return (me != nullptr) ? me->OnRaiseToAppTop(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::DisableWindowDecor(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
WLOGI("DisableWindowDecor");
|
||||
@ -3077,6 +3084,36 @@ NativeValue* JsWindow::OnSetSnapshotSkip(NativeEngine& engine, NativeCallbackInf
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnRaiseToAppTop(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[this](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
auto window = weakToken.promote();
|
||||
if (window == nullptr) {
|
||||
WLOGFE("window is nullptr");
|
||||
task.Reject(engine, CreateJsError(engine,
|
||||
static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY)));
|
||||
return;
|
||||
}
|
||||
|
||||
WmErrorCode errCode = window->RaiseToAppTop();
|
||||
if (errCode != WmErrorCode::WM_OK) {
|
||||
WLOGFE("raise window zorder failed");
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
return;
|
||||
}
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGI("Window [%{public}u, %{public}s] zorder raise success",
|
||||
window->GetWindowId(), window->GetWindowName().c_str());
|
||||
};
|
||||
NativeValue* lastParam = nullptr;
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule("JsWindow::OnRaiseToAppTop",
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnOpacity(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
if (info.argc < 1) {
|
||||
@ -3666,6 +3703,7 @@ void BindFunctions(NativeEngine& engine, NativeObject* object, const char *modul
|
||||
BindNativeFunction(engine, *object, "setTransparent", moduleName, JsWindow::SetTransparent);
|
||||
BindNativeFunction(engine, *object, "setCallingWindow", moduleName, JsWindow::SetCallingWindow);
|
||||
BindNativeFunction(engine, *object, "setSnapshotSkip", moduleName, JsWindow::SetSnapshotSkip);
|
||||
BindNativeFunction(engine, *object, "raiseToAppTop", moduleName, JsWindow::RaiseToAppTop);
|
||||
BindNativeFunction(engine, *object, "disableWindowDecor", moduleName, JsWindow::DisableWindowDecor);
|
||||
BindNativeFunction(engine, *object, "dump", moduleName, JsWindow::Dump);
|
||||
BindNativeFunction(engine, *object, "setForbidSplitMove", moduleName, JsWindow::SetForbidSplitMove);
|
||||
|
@ -90,6 +90,7 @@ public:
|
||||
static NativeValue* SetPreferredOrientation(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* DisableWindowDecor(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* SetSnapshotSkip(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* RaiseToAppTop(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
// colorspace, gamut
|
||||
static NativeValue* IsSupportWideGamut(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* IsWindowSupportWideGamut(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
@ -153,6 +154,7 @@ private:
|
||||
NativeValue* OnIsShowing(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnIsWindowShowingSync(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnSetPreferredOrientation(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnRaiseToAppTop(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
|
||||
// colorspace, gamut
|
||||
NativeValue* OnIsSupportWideGamut(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
|
@ -188,6 +188,7 @@ public:
|
||||
virtual std::shared_ptr<Media::PixelMap> Snapshot() override;
|
||||
virtual WMError NotifyMemoryLevel(int32_t level) const override;
|
||||
virtual bool IsAllowHaveSystemSubWindow() override;
|
||||
WmErrorCode RaiseToAppTop() override;
|
||||
|
||||
private:
|
||||
static std::map<std::string, std::pair<uint32_t, sptr<Window>>> windowMap_;
|
||||
|
@ -758,5 +758,10 @@ bool WindowImpl::IsAllowHaveSystemSubWindow()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
WmErrorCode WindowImpl::RaiseToAppTop()
|
||||
{
|
||||
return WmErrorCode::WM_OK;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent));
|
||||
MOCK_METHOD1(GetVisibilityWindowInfo, WMError(std::vector<sptr<WindowVisibilityInfo>>& infos));
|
||||
MOCK_METHOD1(GetAccessibilityWindowInfo, WMError(std::vector<sptr<AccessibilityWindowInfo>>& infos));
|
||||
MOCK_METHOD1(RaiseToAppTop, WmErrorCode(uint32_t windowId));
|
||||
};
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
@ -72,6 +72,7 @@ public:
|
||||
virtual void SetAnchorAndScale(int32_t x, int32_t y, float scale);
|
||||
virtual void SetAnchorOffset(int32_t deltaX, int32_t deltaY);
|
||||
virtual void OffWindowZoom();
|
||||
virtual WmErrorCode RaiseToAppTop(uint32_t windowId);
|
||||
private:
|
||||
static inline SingletonDelegator<WindowAdapter> delegator;
|
||||
bool InitWMSProxy();
|
||||
|
@ -168,6 +168,7 @@ public:
|
||||
virtual void DisableAppWindowDecor() override;
|
||||
virtual WMError BindDialogTarget(sptr<IRemoteObject> targetToken) override;
|
||||
virtual void SetSnapshotSkip(bool isSkip) override;
|
||||
WmErrorCode RaiseToAppTop() override;
|
||||
|
||||
// window effect
|
||||
virtual WMError SetCornerRadius(float cornerRadius) override;
|
||||
|
@ -277,5 +277,12 @@ void WindowAdapter::OffWindowZoom()
|
||||
INIT_PROXY_CHECK_RETURN();
|
||||
windowManagerServiceProxy_->OffWindowZoom();
|
||||
}
|
||||
|
||||
WmErrorCode WindowAdapter::RaiseToAppTop(uint32_t windowId)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY);
|
||||
return windowManagerServiceProxy_->RaiseToAppTop(windowId);
|
||||
}
|
||||
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
@ -1699,6 +1699,27 @@ void WindowImpl::SetSnapshotSkip(bool isSkip)
|
||||
surfaceNode_->SetSecurityLayer(isSkip || property_->GetSystemPrivacyMode());
|
||||
}
|
||||
|
||||
WmErrorCode WindowImpl::RaiseToAppTop()
|
||||
{
|
||||
auto parentId = property_->GetParentId();
|
||||
if (parentId == INVALID_WINDOW_ID) {
|
||||
WLOGFE("Only the children of the main window can be raised!");
|
||||
return WmErrorCode::WM_ERROR_INVALID_PARENT;
|
||||
}
|
||||
|
||||
if (!WindowHelper::IsSubWindow(property_->GetWindowType())) {
|
||||
WLOGFE("Must be app sub window window!");
|
||||
return WmErrorCode::WM_ERROR_INVALID_CALLING;
|
||||
}
|
||||
|
||||
if (state_ != WindowState::STATE_SHOWN) {
|
||||
WLOGFE("The sub window must be shown!");
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
|
||||
return SingletonContainer::Get<WindowAdapter>().RaiseToAppTop(GetWindowId());
|
||||
}
|
||||
|
||||
void WindowImpl::DisableAppWindowDecor()
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
WMError NotifyWindowClientPointUp(uint32_t windowId, const std::shared_ptr<MMI::PointerEvent>& pointerEvent);
|
||||
WMError ChangeMouseStyle(uint32_t windowId, sptr<MoveDragProperty>& moveDragProperty);
|
||||
void RecoverDefaultMouseStyle(uint32_t windowId);
|
||||
|
||||
WmErrorCode RaiseToAppTop(uint32_t windowId);
|
||||
private:
|
||||
uint32_t GenWindowId();
|
||||
void FlushWindowInfo(uint32_t windowId);
|
||||
@ -111,6 +111,8 @@ private:
|
||||
void RelayoutKeyboard(const sptr<WindowNode>& node);
|
||||
bool CheckParentWindowValid(const sptr<WindowProperty>& property);
|
||||
|
||||
void UpdateFocusIfNeededWhenRaiseWindow(const sptr<WindowNode>& node);
|
||||
|
||||
sptr<WindowRoot> windowRoot_;
|
||||
sptr<InputWindowMonitor> inputWindowMonitor_;
|
||||
sptr<AccessibilityConnection> accessibilityConnection_;
|
||||
|
@ -105,6 +105,7 @@ public:
|
||||
bool isAsyncTask = false) override;
|
||||
WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos) override;
|
||||
WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) override;
|
||||
WmErrorCode RaiseToAppTop(uint32_t windowId) override;
|
||||
|
||||
bool RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent) override;
|
||||
|
@ -44,7 +44,7 @@ private:
|
||||
// system-specific window
|
||||
{ WindowType::WINDOW_TYPE_WALLPAPER, 0 },
|
||||
{ WindowType::WINDOW_TYPE_DESKTOP, 1 },
|
||||
{ WindowType::WINDOW_TYPE_DIALOG, 1 },
|
||||
{ WindowType::WINDOW_TYPE_DIALOG, 2 },
|
||||
{ WindowType::WINDOW_TYPE_APP_LAUNCHING, 101 },
|
||||
{ WindowType::WINDOW_TYPE_DOCK_SLICE, 0 },
|
||||
{ WindowType::WINDOW_TYPE_PLACEHOLDER, 0 },
|
||||
|
@ -67,6 +67,7 @@ public:
|
||||
TRANS_ID_SET_ANCHOR_AND_SCALE,
|
||||
TRANS_ID_SET_ANCHOR_OFFSET,
|
||||
TRANS_ID_OFF_WINDOW_ZOOM,
|
||||
TRANS_ID_RAISE_WINDOW_Z_ORDER,
|
||||
};
|
||||
virtual WMError CreateWindow(sptr<IWindow>& window, sptr<WindowProperty>& property,
|
||||
const std::shared_ptr<RSSurfaceNode>& surfaceNode,
|
||||
@ -105,6 +106,7 @@ public:
|
||||
virtual void SetAnchorAndScale(int32_t x, int32_t y, float scale) = 0;
|
||||
virtual void SetAnchorOffset(int32_t deltaX, int32_t deltaY) = 0;
|
||||
virtual void OffWindowZoom() = 0;
|
||||
virtual WmErrorCode RaiseToAppTop(uint32_t windowId) = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
void SetAnchorAndScale(int32_t x, int32_t y, float scale) override;
|
||||
void SetAnchorOffset(int32_t deltaX, int32_t deltaY) override;
|
||||
void OffWindowZoom() override;
|
||||
WmErrorCode RaiseToAppTop(uint32_t windowId) override;
|
||||
private:
|
||||
static inline BrokerDelegator<WindowManagerProxy> delegator_;
|
||||
};
|
||||
|
@ -1063,6 +1063,50 @@ void WindowController::RecoverDefaultMouseStyle(uint32_t windowId)
|
||||
};
|
||||
WindowInnerManager::GetInstance().PostTask(task, "RecoverDefaultMouseStyle");
|
||||
}
|
||||
WmErrorCode WindowController::RaiseToAppTop(uint32_t windowId)
|
||||
{
|
||||
auto node = windowRoot_->GetWindowNode(windowId);
|
||||
if (node == nullptr) {
|
||||
WLOGFW("could not find window");
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
|
||||
auto parentNode = node->parent_;
|
||||
if (parentNode == nullptr) {
|
||||
WLOGFW("could not find parent");
|
||||
return WmErrorCode::WM_ERROR_INVALID_PARENT;
|
||||
}
|
||||
|
||||
WMError zOrderRes = windowRoot_->RaiseZOrderForAppWindow(node);
|
||||
if (zOrderRes != WMError::WM_OK) {
|
||||
WLOGFE("raise subwindow zorder faile with error code [%{public}d]", zOrderRes);
|
||||
return WmErrorCode::WM_ERROR_STAGE_ABNORMALLY;
|
||||
}
|
||||
|
||||
UpdateFocusIfNeededWhenRaiseWindow(node);
|
||||
FlushWindowInfo(windowId);
|
||||
return WmErrorCode::WM_OK;
|
||||
}
|
||||
|
||||
void WindowController::UpdateFocusIfNeededWhenRaiseWindow(const sptr<WindowNode>& node)
|
||||
{
|
||||
auto property = node->GetWindowProperty();
|
||||
if (!property->GetFocusable()) {
|
||||
return;
|
||||
}
|
||||
uint32_t windowId = node->GetWindowId();
|
||||
sptr<WindowNode> focusWindow = nullptr;
|
||||
WMError res = GetFocusWindowNode(node->GetDisplayId(), focusWindow);
|
||||
if (res != WMError::WM_OK || focusWindow == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (node->parent_->GetWindowId() == focusWindow->GetWindowId() ||
|
||||
node->parent_->GetWindowId() == focusWindow->GetParentId()) {
|
||||
windowRoot_->RequestFocus(windowId);
|
||||
windowRoot_->RequestActiveWindow(windowId);
|
||||
windowRoot_->FocusFaultDetection();
|
||||
}
|
||||
}
|
||||
|
||||
WMError WindowController::NotifyWindowClientPointUp(uint32_t windowId,
|
||||
const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
|
@ -1090,6 +1090,17 @@ WMError WindowManagerService::GetVisibilityWindowInfo(std::vector<sptr<WindowVis
|
||||
});
|
||||
}
|
||||
|
||||
WmErrorCode WindowManagerService::RaiseToAppTop(uint32_t windowId)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
WLOGFE("window raise to app top permission denied!");
|
||||
return WmErrorCode::WM_ERROR_NO_PERMISSION;
|
||||
}
|
||||
return PostSyncTask([this, windowId]() {
|
||||
return windowController_->RaiseToAppTop(windowId);
|
||||
});
|
||||
}
|
||||
|
||||
WMError WindowManagerService::GetSystemConfig(SystemConfig& systemConfig)
|
||||
{
|
||||
systemConfig = systemConfig_;
|
||||
|
@ -785,5 +785,29 @@ void WindowManagerProxy::OffWindowZoom()
|
||||
WLOGFE("SendRequest failed");
|
||||
}
|
||||
}
|
||||
|
||||
WmErrorCode WindowManagerProxy::RaiseToAppTop(uint32_t windowId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY;
|
||||
}
|
||||
|
||||
if (!data.WriteUint32(windowId)) {
|
||||
WLOGFE("Write anchor delatX failed");
|
||||
return WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY;
|
||||
}
|
||||
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerMessage::TRANS_ID_RAISE_WINDOW_Z_ORDER),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
return WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY;
|
||||
}
|
||||
return WmErrorCode::WM_OK;
|
||||
}
|
||||
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
@ -272,6 +272,12 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M
|
||||
OffWindowZoom();
|
||||
break;
|
||||
}
|
||||
case WindowManagerMessage::TRANS_ID_RAISE_WINDOW_Z_ORDER: {
|
||||
uint32_t windowId = data.ReadUint32();
|
||||
WmErrorCode errCode = RaiseToAppTop(windowId);
|
||||
reply.WriteInt32(static_cast<int32_t>(errCode));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
WLOGFW("unknown transaction code %{public}d", code);
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
|
@ -123,6 +123,10 @@ WMError BindDialogTarget(uint32_t& windowId, sptr<IRemoteObject> targetToken)
|
||||
void SetAnchorAndScale(int32_t x, int32_t y, float scale){};
|
||||
void SetAnchorOffset(int32_t deltaX, int32_t deltaY){};
|
||||
void OffWindowZoom(){};
|
||||
WmErrorCode RaiseToAppTop(uint32_t windowId)
|
||||
{
|
||||
return WmErrorCode::WM_OK;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user