• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_WINDOW_MANAGER_INTERFACE_H
17 #define OHOS_WINDOW_MANAGER_INTERFACE_H
18 
19 #include <iremote_broker.h>
20 #include <rs_iwindow_animation_finished_callback.h>
21 
22 #include "common/include/window_session_property.h"
23 #include "interfaces/include/ws_common_inner.h"
24 #include "pixel_map.h"
25 #include "session/container/include/zidl/session_stage_interface.h"
26 #include "session/container/include/zidl/window_event_channel_interface.h"
27 #include "window_property.h"
28 #include "window_transition_info.h"
29 #include "mission_snapshot.h"
30 #include "zidl/window_interface.h"
31 #include "zidl/window_manager_agent_interface.h"
32 #include "interfaces/include/ws_common.h"
33 
34 namespace OHOS {
35 namespace Rosen {
36 class RSIWindowAnimationController;
37 class RSSurfaceNode;
38 
39 class IWindowManager : public IRemoteBroker {
40 public:
41     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IWindowManager");
42 
43     enum class WindowManagerMessage : uint32_t {
44         TRANS_ID_CREATE_WINDOW,
45         TRANS_ID_ADD_WINDOW,
46         TRANS_ID_REMOVE_WINDOW,
47         TRANS_ID_DESTROY_WINDOW,
48         TRANS_ID_REQUEST_FOCUS,
49         TRANS_ID_REGISTER_FOCUS_CHANGED_LISTENER,
50         TRANS_ID_UNREGISTER_FOCUS_CHANGED_LISTENER,
51         TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT,
52         TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT,
53         TRANS_ID_GET_AVOID_AREA,
54         TRANS_ID_GET_TOP_WINDOW_ID,
55         TRANS_ID_PROCESS_POINT_DOWN,
56         TRANS_ID_PROCESS_POINT_UP,
57         TRANS_ID_MINIMIZE_ALL_APP_WINDOWS,
58         TRANS_ID_TOGGLE_SHOWN_STATE_FOR_ALL_APP_WINDOWS,
59         TRANS_ID_SET_BACKGROUND_BLUR,
60         TRANS_ID_SET_ALPHA,
61         TRANS_ID_UPDATE_LAYOUT_MODE,
62         TRANS_ID_UPDATE_PROPERTY,
63         TRANS_ID_GET_ACCESSIBILITY_WINDOW_INFO_ID,
64         TRANS_ID_GET_WINDOW_LAYOUT_INFO,
65         TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID,
66         TRANS_ID_ANIMATION_SET_CONTROLLER,
67         TRANS_ID_GET_SYSTEM_CONFIG,
68         TRANS_ID_NOTIFY_WINDOW_TRANSITION,
69         TRANS_ID_GET_FULLSCREEN_AND_SPLIT_HOT_ZONE,
70         TRANS_ID_GET_ANIMATION_CALLBACK,
71         TRANS_ID_UPDATE_AVOIDAREA_LISTENER,
72         TRANS_ID_UPDATE_RS_TREE,
73         TRANS_ID_BIND_DIALOG_TARGET,
74         TRANS_ID_NOTIFY_READY_MOVE_OR_DRAG,
75         TRANS_ID_SET_ANCHOR_AND_SCALE,
76         TRANS_ID_SET_ANCHOR_OFFSET,
77         TRANS_ID_OFF_WINDOW_ZOOM,
78         TRANS_ID_RAISE_WINDOW_Z_ORDER,
79         TRANS_ID_GET_SNAPSHOT,
80         TRANS_ID_GESTURE_NAVIGATION_ENABLED,
81         TRANS_ID_SET_WINDOW_GRAVITY,
82         TRANS_ID_DISPATCH_KEY_EVENT,
83         TRANS_ID_NOTIFY_DUMP_INFO_RESULT,
84         TRANS_ID_GET_WINDOW_ANIMATION_TARGETS,
85         TRANS_ID_SET_MAXIMIZE_MODE,
86         TRANS_ID_GET_MAXIMIZE_MODE,
87         TRANS_ID_GET_FOCUS_WINDOW_INFO,
88         TRANS_ID_ADD_EXTENSION_WINDOW_STAGE_TO_SCB,
89         TRANS_ID_UPDATE_MODALEXTENSION_RECT_TO_SCB,
90         TRANS_ID_PROCESS_MODALEXTENSION_POINTDOWN_TO_SCB,
91         TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS,
92         TRANS_ID_GET_HOST_WINDOW_RECT,
93         TRANS_ID_GET_UNRELIABLE_WINDOW_INFO_ID,
94         TRANS_ID_GET_FREE_MULTI_WINDOW_ENABLE_STATE,
95     };
96     virtual WMError CreateWindow(sptr<IWindow>& window, sptr<WindowProperty>& property,
97         const std::shared_ptr<RSSurfaceNode>& surfaceNode,
98         uint32_t& windowId, sptr<IRemoteObject> token) = 0;
99     virtual WMError AddWindow(sptr<WindowProperty>& property) = 0;
100     virtual WMError RemoveWindow(uint32_t windowId, bool isFromInnerkits) = 0;
101     virtual WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) = 0;
102     virtual WMError RequestFocus(uint32_t windowId) = 0;
103     virtual AvoidArea GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type) = 0;
104     virtual WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) = 0;
105     virtual void NotifyServerReadyToMoveOrDrag(uint32_t windowId, sptr<WindowProperty>& windowProperty,
106         sptr<MoveDragProperty>& moveDragProperty) = 0;
107     virtual void ProcessPointDown(uint32_t windowId, bool isPointDown) = 0;
108     virtual void ProcessPointUp(uint32_t windowId) = 0;
109     virtual WMError MinimizeAllAppWindows(DisplayId displayId) = 0;
110     virtual WMError ToggleShownStateForAllAppWindows() = 0;
111     virtual WMError SetWindowLayoutMode(WindowLayoutMode mode) = 0;
112     virtual WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action,
113         bool isAsyncTask = false) = 0;
114     virtual WMError SetWindowGravity(uint32_t windowId, WindowGravity gravity, uint32_t percent) = 0;
115     virtual WMError RegisterWindowManagerAgent(WindowManagerAgentType type,
116         const sptr<IWindowManagerAgent>& windowManagerAgent) = 0;
117     virtual WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
118         const sptr<IWindowManagerAgent>& windowManagerAgent) = 0;
119     virtual WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos) = 0;
120     virtual WMError GetUnreliableWindowInfo(int32_t windowId, std::vector<sptr<UnreliableWindowInfo>>& infos) = 0;
GetAllWindowLayoutInfo(DisplayId displayId,std::vector<sptr<WindowLayoutInfo>> & infos)121     virtual WMError GetAllWindowLayoutInfo(DisplayId displayId,
122         std::vector<sptr<WindowLayoutInfo>>& infos) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
123     virtual WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) = 0;
124     virtual WMError SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller) = 0;
125     virtual WMError GetSystemConfig(SystemConfig& systemConfig) = 0;
126     virtual WMError NotifyWindowTransition(sptr<WindowTransitionInfo>& from, sptr<WindowTransitionInfo>& to,
127         bool isFromClient = false) = 0;
128     virtual WMError GetModeChangeHotZones(DisplayId displayId, ModeChangeHotZones& hotZones) = 0;
129     virtual void MinimizeWindowsByLauncher(std::vector<uint32_t> windowIds, bool isAnimated,
130         sptr<RSIWindowAnimationFinishedCallback>& finishCallback) = 0;
131     virtual WMError UpdateAvoidAreaListener(uint32_t windowId, bool haveListener) = 0;
132     virtual WMError UpdateRsTree(uint32_t windowId, bool isAdd) = 0;
133     virtual WMError BindDialogTarget(uint32_t& windowId, sptr<IRemoteObject> targetToken) = 0;
134     virtual void SetAnchorAndScale(int32_t x, int32_t y, float scale) = 0;
135     virtual void SetAnchorOffset(int32_t deltaX, int32_t deltaY) = 0;
136     virtual void OffWindowZoom() = 0;
137     virtual WMError RaiseToAppTop(uint32_t windowId) = 0;
138     virtual std::shared_ptr<Media::PixelMap> GetSnapshot(int32_t windowId) = 0;
139     virtual WMError SetGestureNavigaionEnabled(bool enable) = 0;
140     virtual void DispatchKeyEvent(uint32_t windowId, std::shared_ptr<MMI::KeyEvent> event) = 0;
NotifyDumpInfoResult(const std::vector<std::string> & info)141     virtual void NotifyDumpInfoResult(const std::vector<std::string>& info) {};
DumpSessionAll(std::vector<std::string> & infos)142     virtual WSError DumpSessionAll(std::vector<std::string> &infos) { return WSError::WS_OK; }
DumpSessionWithId(int32_t persistentId,std::vector<std::string> & infos)143     virtual WSError DumpSessionWithId(int32_t persistentId, std::vector<std::string> &infos) { return WSError::WS_OK; }
GetUIContentRemoteObj(int32_t persistentId,sptr<IRemoteObject> & uiContentRemoteObj)144     virtual WSError GetUIContentRemoteObj(int32_t persistentId, sptr<IRemoteObject>& uiContentRemoteObj)
145     {
146         return WSError::WS_OK;
147     }
148     virtual WMError GetWindowAnimationTargets(std::vector<uint32_t> missionIds,
149         std::vector<sptr<RSWindowAnimationTarget>>& targets) = 0;
150     virtual void SetMaximizeMode(MaximizeMode maximizeMode) = 0;
151     virtual MaximizeMode GetMaximizeMode() = 0;
152     virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo) = 0;
CheckWindowId(int32_t windowId,int32_t & pid)153     virtual WMError CheckWindowId(int32_t windowId, int32_t& pid) { return WMError::WM_OK; }
UpdateSessionAvoidAreaListener(int32_t & persistentId,bool haveListener)154     virtual WSError UpdateSessionAvoidAreaListener(int32_t& persistentId, bool haveListener) { return WSError::WS_OK; }
UpdateSessionTouchOutsideListener(int32_t & persistentId,bool haveListener)155     virtual WSError UpdateSessionTouchOutsideListener(int32_t& persistentId, bool haveListener)
156     {
157         return WSError::WS_OK;
158     }
NotifyWindowExtensionVisibilityChange(int32_t pid,int32_t uid,bool visible)159     virtual WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible)
160     {
161         return WSError::WS_OK;
162     }
RaiseWindowToTop(int32_t persistentId)163     virtual WSError RaiseWindowToTop(int32_t persistentId) { return WSError::WS_OK; }
UpdateSessionWindowVisibilityListener(int32_t persistentId,bool haveListener)164     virtual WSError UpdateSessionWindowVisibilityListener(int32_t persistentId, bool haveListener)
165     {
166         return WSError::WS_OK;
167     }
ShiftAppWindowFocus(int32_t sourcePersistentId,int32_t targetPersistentId)168     virtual WSError ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId)
169     {
170         return WSError::WS_ERROR_DEVICE_NOT_SUPPORT;
171     }
172     virtual WSError CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
173         const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
174         sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session,
175         SystemSessionConfig& systemConfig, sptr<IRemoteObject> token = nullptr) { return WSError::WS_OK; }
176     virtual WSError RecoverAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
177         const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
178         sptr<WindowSessionProperty> property, sptr<ISession>& session, sptr<IRemoteObject> token = nullptr)
179     {
180         return WSError::WS_OK;
181     }
DestroyAndDisconnectSpecificSession(const int32_t persistentId)182     virtual WSError DestroyAndDisconnectSpecificSession(const int32_t persistentId) { return WSError::WS_OK; }
DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId,const sptr<IRemoteObject> & callback)183     virtual WSError DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId,
184         const sptr<IRemoteObject>& callback) { return WSError::WS_OK; }
185     virtual WSError RecoverAndReconnectSceneSession(const sptr<ISessionStage>& sessionStage,
186         const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
187         sptr<ISession>& session, sptr<WindowSessionProperty> property, sptr<IRemoteObject> token = nullptr)
188     {
189         return WSError::WS_OK;
190     }
BindDialogSessionTarget(uint64_t persistentId,sptr<IRemoteObject> targetToken)191     virtual WSError BindDialogSessionTarget(uint64_t persistentId, sptr<IRemoteObject> targetToken)
192     {
193         return WSError::WS_OK;
194     }
SetSessionGravity(int32_t persistentId,SessionGravity gravity,uint32_t percent)195     virtual WSError SetSessionGravity(int32_t persistentId, SessionGravity gravity, uint32_t percent)
196     {
197         return WSError::WS_OK;
198     }
199     virtual WMError RequestFocusStatus(int32_t persistentId, bool isFocused, bool byForeground = true,
200         FocusChangeReason reason = FocusChangeReason::DEFAULT)
201     {
202         return WMError::WM_OK;
203     }
GetSnapshotByWindowId(int32_t persistentId,std::shared_ptr<Media::PixelMap> & pixelMap)204     virtual WMError GetSnapshotByWindowId(int32_t persistentId, std::shared_ptr<Media::PixelMap>& pixelMap)
205     {
206         return WMError::WM_OK;
207     }
208     virtual void AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage,
209         const sptr<IRemoteObject>& token, uint64_t surfaceNodeId, bool isConstrainedModal = false) {}
210     virtual void RemoveExtensionWindowStageFromSCB(const sptr<ISessionStage>& sessionStage,
211         const sptr<IRemoteObject>& token, bool isConstrainedModal = false) {}
UpdateModalExtensionRect(const sptr<IRemoteObject> & token,Rect rect)212     virtual void UpdateModalExtensionRect(const sptr<IRemoteObject>& token, Rect rect) {}
ProcessModalExtensionPointDown(const sptr<IRemoteObject> & token,int32_t posX,int32_t posY)213     virtual void ProcessModalExtensionPointDown(const sptr<IRemoteObject>& token, int32_t posX, int32_t posY) {}
AddOrRemoveSecureSession(int32_t persistentId,bool shouldHide)214     virtual WSError AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide)
215     {
216         return WSError::WS_OK;
217     }
UpdateExtWindowFlags(const sptr<IRemoteObject> & token,uint32_t extWindowFlags,uint32_t extWindowActions)218     virtual WSError UpdateExtWindowFlags(const sptr<IRemoteObject>& token, uint32_t extWindowFlags,
219         uint32_t extWindowActions)
220     {
221         return WSError::WS_OK;
222     }
GetHostWindowRect(int32_t hostWindowId,Rect & rect)223     virtual WSError GetHostWindowRect(int32_t hostWindowId, Rect& rect)
224     {
225         return WSError::WS_OK;
226     }
GetFreeMultiWindowEnableState(bool & enable)227     virtual WSError GetFreeMultiWindowEnableState(bool& enable)
228     {
229         return WSError::WS_OK;
230     }
GetCallingWindowWindowStatus(int32_t persistentId,WindowStatus & windowStatus)231     virtual WMError GetCallingWindowWindowStatus(int32_t persistentId, WindowStatus& windowStatus)
232     {
233         return WMError::WM_OK;
234     }
GetCallingWindowRect(int32_t persistentId,Rect & rect)235     virtual WMError GetCallingWindowRect(int32_t persistentId, Rect& rect)
236     {
237         return WMError::WM_OK;
238     }
GetWindowModeType(WindowModeType & windowModeType)239     virtual WMError GetWindowModeType(WindowModeType& windowModeType)
240     {
241         return WMError::WM_OK;
242     };
GetWindowStyleType(WindowStyleType & windowStyleType)243     virtual WMError GetWindowStyleType(WindowStyleType& windowStyleType)
244     {
245         return WMError::WM_OK;
246     };
IsWindowRectAutoSave(const std::string & key,bool & enabled)247     virtual WMError IsWindowRectAutoSave(const std::string& key, bool& enabled) { return WMError::WM_OK; }
GetParentMainWindowId(int32_t windowId,int32_t & mainWindowId)248     virtual WMError GetParentMainWindowId(int32_t windowId, int32_t& mainWindowId) { return WMError::WM_OK; }
GetWindowIdsByCoordinate(DisplayId displayId,int32_t windowNumber,int32_t x,int32_t y,std::vector<int32_t> & windowIds)249     virtual WMError GetWindowIdsByCoordinate(DisplayId displayId, int32_t windowNumber,
250         int32_t x, int32_t y, std::vector<int32_t>& windowIds) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
ReleaseForegroundSessionScreenLock()251     virtual WMError ReleaseForegroundSessionScreenLock() { return WMError::WM_OK; }
GetDisplayIdByWindowId(const std::vector<uint64_t> & windowIds,std::unordered_map<uint64_t,DisplayId> & windowDisplayIdMap)252     virtual WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
253         std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap) { return WMError::WM_OK; }
IsPcWindow(bool & isPcWindow)254     virtual WMError IsPcWindow(bool& isPcWindow) { return WMError::WM_OK; }
IsPcOrPadFreeMultiWindowMode(bool & isPcOrPadFreeMultiWindowMode)255     virtual WMError IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFreeMultiWindowMode) { return WMError::WM_OK; }
SetGlobalDragResizeType(DragResizeType dragResizeType)256     virtual WMError SetGlobalDragResizeType(DragResizeType dragResizeType) { return WMError::WM_OK; }
GetGlobalDragResizeType(DragResizeType & dragResizeType)257     virtual WMError GetGlobalDragResizeType(DragResizeType& dragResizeType) { return WMError::WM_OK; }
SetAppDragResizeType(const std::string & bundleName,DragResizeType dragResizeType)258     virtual WMError SetAppDragResizeType(const std::string& bundleName,
259         DragResizeType dragResizeType) { return WMError::WM_OK; }
GetAppDragResizeType(const std::string & bundleName,DragResizeType & dragResizeType)260     virtual WMError GetAppDragResizeType(const std::string& bundleName,
261         DragResizeType& dragResizeType) { return WMError::WM_OK; }
ShiftAppWindowPointerEvent(int32_t sourcePersistentId,int32_t targetPersistentId)262     virtual WMError ShiftAppWindowPointerEvent(int32_t sourcePersistentId,
263         int32_t targetPersistentId) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
HasFloatingWindowForeground(const sptr<IRemoteObject> & abilityToken,bool & hasOrNot)264     virtual WMError HasFloatingWindowForeground(const sptr<IRemoteObject>& abilityToken,
265         bool& hasOrNot) { return WMError::WM_OK; }
266 };
267 }
268 }
269 #endif // OHOS_WINDOW_MANAGER_INTERFACE_H
270