• 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 "zidl/window_interface.h"
30 #include "zidl/window_manager_agent_interface.h"
31 #include "interfaces/include/ws_common.h"
32 
33 namespace OHOS {
34 namespace Rosen {
35 class RSIWindowAnimationController;
36 class RSSurfaceNode;
37 
38 class IWindowManager : public IRemoteBroker {
39 public:
40     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IWindowManager");
41 
42     enum class WindowManagerMessage : uint32_t {
43         TRANS_ID_CREATE_WINDOW,
44         TRANS_ID_ADD_WINDOW,
45         TRANS_ID_REMOVE_WINDOW,
46         TRANS_ID_DESTROY_WINDOW,
47         TRANS_ID_REQUEST_FOCUS,
48         TRANS_ID_REGISTER_FOCUS_CHANGED_LISTENER,
49         TRANS_ID_UNREGISTER_FOCUS_CHANGED_LISTENER,
50         TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT,
51         TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT,
52         TRANS_ID_GET_AVOID_AREA,
53         TRANS_ID_GET_TOP_WINDOW_ID,
54         TRANS_ID_PROCESS_POINT_DOWN,
55         TRANS_ID_PROCESS_POINT_UP,
56         TRANS_ID_MINIMIZE_ALL_APP_WINDOWS,
57         TRANS_ID_TOGGLE_SHOWN_STATE_FOR_ALL_APP_WINDOWS,
58         TRANS_ID_SET_BACKGROUND_BLUR,
59         TRANS_ID_SET_ALPHA,
60         TRANS_ID_UPDATE_LAYOUT_MODE,
61         TRANS_ID_UPDATE_PROPERTY,
62         TRANS_ID_GET_ACCESSIBILITY_WINDOW_INFO_ID,
63         TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID,
64         TRANS_ID_ANIMATION_SET_CONTROLLER,
65         TRANS_ID_GET_SYSTEM_CONFIG,
66         TRANS_ID_NOTIFY_WINDOW_TRANSITION,
67         TRANS_ID_GET_FULLSCREEN_AND_SPLIT_HOT_ZONE,
68         TRANS_ID_GET_ANIMATION_CALLBACK,
69         TRANS_ID_UPDATE_AVOIDAREA_LISTENER,
70         TRANS_ID_UPDATE_RS_TREE,
71         TRANS_ID_BIND_DIALOG_TARGET,
72         TRANS_ID_NOTIFY_READY_MOVE_OR_DRAG,
73         TRANS_ID_SET_ANCHOR_AND_SCALE,
74         TRANS_ID_SET_ANCHOR_OFFSET,
75         TRANS_ID_OFF_WINDOW_ZOOM,
76         TRANS_ID_RAISE_WINDOW_Z_ORDER,
77         TRANS_ID_GET_SNAPSHOT,
78         TRANS_ID_GESTURE_NAVIGATION_ENABLED,
79         TRANS_ID_SET_WINDOW_GRAVITY,
80         TRANS_ID_DISPATCH_KEY_EVENT,
81         TRANS_ID_NOTIFY_DUMP_INFO_RESULT,
82         TRANS_ID_GET_WINDOW_ANIMATION_TARGETS,
83         TRANS_ID_SET_MAXIMIZE_MODE,
84         TRANS_ID_GET_MAXIMIZE_MODE,
85         TRANS_ID_GET_FOCUS_WINDOW_INFO,
86         TRANS_ID_HIDE_NON_SECURE_WINDOWS,
87     };
88     virtual WMError CreateWindow(sptr<IWindow>& window, sptr<WindowProperty>& property,
89         const std::shared_ptr<RSSurfaceNode>& surfaceNode,
90         uint32_t& windowId, sptr<IRemoteObject> token) = 0;
91     virtual WMError AddWindow(sptr<WindowProperty>& property) = 0;
92     virtual WMError RemoveWindow(uint32_t windowId, bool isFromInnerkits) = 0;
93     virtual WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) = 0;
94     virtual WMError RequestFocus(uint32_t windowId) = 0;
95     virtual AvoidArea GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type) = 0;
96     virtual WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) = 0;
97     virtual void NotifyServerReadyToMoveOrDrag(uint32_t windowId, sptr<WindowProperty>& windowProperty,
98         sptr<MoveDragProperty>& moveDragProperty) = 0;
99     virtual void ProcessPointDown(uint32_t windowId, bool isPointDown) = 0;
100     virtual void ProcessPointUp(uint32_t windowId) = 0;
101     virtual WMError MinimizeAllAppWindows(DisplayId displayId) = 0;
102     virtual WMError ToggleShownStateForAllAppWindows() = 0;
103     virtual WMError SetWindowLayoutMode(WindowLayoutMode mode) = 0;
104     virtual WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action,
105         bool isAsyncTask = false) = 0;
106     virtual WMError SetWindowGravity(uint32_t windowId, WindowGravity gravity, uint32_t percent) = 0;
107     virtual WMError RegisterWindowManagerAgent(WindowManagerAgentType type,
108         const sptr<IWindowManagerAgent>& windowManagerAgent) = 0;
109     virtual WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
110         const sptr<IWindowManagerAgent>& windowManagerAgent) = 0;
111     virtual WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos) = 0;
112     virtual WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) = 0;
113     virtual WMError SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller) = 0;
114     virtual WMError GetSystemConfig(SystemConfig& systemConfig) = 0;
115     virtual WMError NotifyWindowTransition(sptr<WindowTransitionInfo>& from, sptr<WindowTransitionInfo>& to,
116         bool isFromClient = false) = 0;
117     virtual WMError GetModeChangeHotZones(DisplayId displayId, ModeChangeHotZones& hotZones) = 0;
118     virtual void MinimizeWindowsByLauncher(std::vector<uint32_t> windowIds, bool isAnimated,
119         sptr<RSIWindowAnimationFinishedCallback>& finishCallback) = 0;
120     virtual WMError UpdateAvoidAreaListener(uint32_t windowId, bool haveListener) = 0;
121     virtual WMError UpdateRsTree(uint32_t windowId, bool isAdd) = 0;
122     virtual WMError BindDialogTarget(uint32_t& windowId, sptr<IRemoteObject> targetToken) = 0;
123     virtual void SetAnchorAndScale(int32_t x, int32_t y, float scale) = 0;
124     virtual void SetAnchorOffset(int32_t deltaX, int32_t deltaY) = 0;
125     virtual void OffWindowZoom() = 0;
126     virtual WmErrorCode RaiseToAppTop(uint32_t windowId) = 0;
127     virtual std::shared_ptr<Media::PixelMap> GetSnapshot(int32_t windowId) = 0;
128     virtual WMError SetGestureNavigaionEnabled(bool enable) = 0;
129     virtual void DispatchKeyEvent(uint32_t windowId, std::shared_ptr<MMI::KeyEvent> event) = 0;
NotifyDumpInfoResult(const std::vector<std::string> & info)130     virtual void NotifyDumpInfoResult(const std::vector<std::string>& info) {};
DumpSessionAll(std::vector<std::string> & infos)131     virtual WSError DumpSessionAll(std::vector<std::string> &infos) { return WSError::WS_OK; }
DumpSessionWithId(int32_t persistentId,std::vector<std::string> & infos)132     virtual WSError DumpSessionWithId(int32_t persistentId, std::vector<std::string> &infos) { return WSError::WS_OK; }
133     virtual WMError GetWindowAnimationTargets(std::vector<uint32_t> missionIds,
134         std::vector<sptr<RSWindowAnimationTarget>>& targets) = 0;
135     virtual void SetMaximizeMode(MaximizeMode maximizeMode) = 0;
136     virtual MaximizeMode GetMaximizeMode() = 0;
137     virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo) = 0;
CheckWindowId(int32_t windowId,int32_t & pid)138     virtual WMError CheckWindowId(int32_t windowId, int32_t &pid) { return WMError::WM_OK; }
UpdateSessionAvoidAreaListener(int32_t & persistentId,bool haveListener)139     virtual WSError UpdateSessionAvoidAreaListener(int32_t& persistentId, bool haveListener) { return WSError::WS_OK; }
UpdateSessionTouchOutsideListener(int32_t & persistentId,bool haveListener)140     virtual WSError UpdateSessionTouchOutsideListener(int32_t& persistentId, bool haveListener)
141     {
142         return WSError::WS_OK;
143     }
144     virtual WSError CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
145         const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
146         sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session,
147         sptr<IRemoteObject> token = nullptr) { return WSError::WS_OK; }
148     virtual WSError RecoverAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
149         const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
150         sptr<WindowSessionProperty> property, sptr<ISession>& session, sptr<IRemoteObject> token = nullptr)
151     {
152         return WSError::WS_OK;
153     }
DestroyAndDisconnectSpecificSession(const int32_t & persistentId)154     virtual WSError DestroyAndDisconnectSpecificSession(const int32_t& persistentId) { return WSError::WS_OK; };
155     virtual WSError RecoverAndReconnectSceneSession(const sptr<ISessionStage>& sessionStage,
156         const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
157         sptr<ISession>& session, sptr<WindowSessionProperty> property, sptr<IRemoteObject> token = nullptr)
158     {
159         return WSError::WS_OK;
160     }
UpdateSessionProperty(const sptr<WindowSessionProperty> & property,WSPropertyChangeAction action)161     virtual WMError UpdateSessionProperty(const sptr<WindowSessionProperty>& property, WSPropertyChangeAction action)
162     {
163         return WMError::WM_OK;
164     }
BindDialogSessionTarget(uint64_t persistentId,sptr<IRemoteObject> targetToken)165     virtual WSError BindDialogSessionTarget(uint64_t persistentId, sptr<IRemoteObject> targetToken)
166     {
167         return WSError::WS_OK;
168     }
SetSessionGravity(int32_t persistentId,SessionGravity gravity,uint32_t percent)169     virtual WSError SetSessionGravity(int32_t persistentId, SessionGravity gravity, uint32_t percent)
170     {
171         return WSError::WS_OK;
172     }
173     virtual WMError RequestFocusStatus(int32_t persistentId, bool isFocused, bool byForeground = true)
174     {
175         return WMError::WM_OK;
176     }
RaiseWindowToTop(int32_t persistentId)177     virtual WSError RaiseWindowToTop(int32_t persistentId) { return WSError::WS_OK; }
NotifyWindowExtensionVisibilityChange(int32_t pid,int32_t uid,bool visible)178     virtual WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible)
179     {
180         return WSError::WS_OK;
181     }
UpdateSessionWindowVisibilityListener(int32_t persistendId,bool haveListener)182     virtual WSError UpdateSessionWindowVisibilityListener(int32_t persistendId, bool haveListener)
183     {
184         return WSError::WS_OK;
185     }
ShiftAppWindowFocus(int32_t sourcePersistentId,int32_t targetPersistentId)186     virtual WSError ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId)
187     {
188         return WSError::WS_ERROR_DEVICE_NOT_SUPPORT;
189     }
HideNonSecureWindows(bool shouldHide)190     virtual WSError HideNonSecureWindows(bool shouldHide)
191     {
192         return WSError::WS_OK;
193     }
194 };
195 }
196 }
197 #endif // OHOS_WINDOW_MANAGER_INTERFACE_H
198