• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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_ROSEN_WM_COMMON_H
17 #define OHOS_ROSEN_WM_COMMON_H
18 
19 namespace OHOS {
20 namespace Rosen {
21 using DisplayId = uint64_t;
22 enum class WindowType : uint32_t {
23     APP_WINDOW_BASE = 1,
24     APP_MAIN_WINDOW_BASE = APP_WINDOW_BASE,
25     WINDOW_TYPE_APP_MAIN_WINDOW = APP_MAIN_WINDOW_BASE,
26     APP_MAIN_WINDOW_END,
27 
28     APP_SUB_WINDOW_BASE = 1000,
29     WINDOW_TYPE_MEDIA = APP_SUB_WINDOW_BASE,
30     WINDOW_TYPE_APP_SUB_WINDOW,
31     APP_SUB_WINDOW_END,
32     APP_WINDOW_END = APP_SUB_WINDOW_END,
33 
34     SYSTEM_WINDOW_BASE = 2000,
35     BELOW_APP_SYSTEM_WINDOW_BASE = SYSTEM_WINDOW_BASE,
36     WINDOW_TYPE_WALLPAPER = SYSTEM_WINDOW_BASE,
37     WINDOW_TYPE_DESKTOP,
38     BELOW_APP_SYSTEM_WINDOW_END,
39 
40     ABOVE_APP_SYSTEM_WINDOW_BASE = 2100,
41     WINDOW_TYPE_APP_LAUNCHING = ABOVE_APP_SYSTEM_WINDOW_BASE,
42     WINDOW_TYPE_DOCK_SLICE,
43     WINDOW_TYPE_INCOMING_CALL,
44     WINDOW_TYPE_SEARCHING_BAR,
45     WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
46     WINDOW_TYPE_INPUT_METHOD_FLOAT,
47     WINDOW_TYPE_FLOAT,
48     WINDOW_TYPE_TOAST,
49     WINDOW_TYPE_STATUS_BAR,
50     WINDOW_TYPE_PANEL,
51     WINDOW_TYPE_KEYGUARD,
52     WINDOW_TYPE_VOLUME_OVERLAY,
53     WINDOW_TYPE_NAVIGATION_BAR,
54     WINDOW_TYPE_DRAGGING_EFFECT,
55     WINDOW_TYPE_POINTER,
56     WINDOW_TYPE_LAUNCHER_RECENT,
57     WINDOW_TYPE_LAUNCHER_DOCK,
58     WINDOW_TYPE_BOOT_ANIMATION,
59     WINDOW_TYPE_FREEZE_DISPLAY,
60     ABOVE_APP_SYSTEM_WINDOW_END,
61 
62     SYSTEM_WINDOW_END = ABOVE_APP_SYSTEM_WINDOW_END,
63 };
64 
65 enum class WindowMode : uint32_t {
66     WINDOW_MODE_UNDEFINED = 0,
67     WINDOW_MODE_FULLSCREEN = 1,
68     WINDOW_MODE_SPLIT_PRIMARY = 100,
69     WINDOW_MODE_SPLIT_SECONDARY,
70     WINDOW_MODE_FLOATING,
71     WINDOW_MODE_PIP
72 };
73 
74 enum class WindowBlurLevel : uint32_t {
75     WINDOW_BLUR_OFF = 0,
76     WINDOW_BLUR_LOW,
77     WINDOW_BLUR_MEDIUM,
78     WINDOW_BLUR_HIGH
79 };
80 
81 enum class WMError : int32_t {
82     WM_OK = 0,
83     WM_DO_NOTHING = 1,
84     WM_ERROR_SAMGR = 100,
85     WM_ERROR_IPC_FAILED = 101,
86     WM_ERROR_NO_MEM = 110,
87     WM_ERROR_NULLPTR = 120,
88     WM_ERROR_INVALID_PARAM = 130,
89     WM_ERROR_DESTROYED_OBJECT = 140,
90     WM_ERROR_DEATH_RECIPIENT = 150,
91     WM_ERROR_INVALID_WINDOW = 160,
92     WM_ERROR_INVALID_OPERATION = 170,
93     WM_ERROR_INVALID_TYPE = 180,
94     WM_ERROR_INVALID_PERMISSION = 190,
95     WM_ERROR_UNKNOWN,
96     WM_ERROR_DEVICE_NOT_SUPPORT = 801, // the value do not change.It is defined on all system
97 };
98 
99 enum class WindowFlag : uint32_t {
100     WINDOW_FLAG_NEED_AVOID = 1,
101     WINDOW_FLAG_PARENT_LIMIT = 1 << 1,
102     WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2,
103     WINDOW_FLAG_END = 1 << 3,
104 };
105 
106 enum class WindowSizeChangeReason : uint32_t {
107     UNDEFINED = 0,
108     MAXIMIZE,
109     RECOVER,
110     ROTATION,
111     DRAG,
112     DRAG_START,
113     DRAG_END,
114     RESIZE,
115     MOVE,
116     HIDE,
117 };
118 
119 enum class WindowLayoutMode : uint32_t {
120     BASE = 0,
121     CASCADE = BASE,
122     TILE = 1,
123     END,
124 };
125 
126 enum class DragEvent : uint32_t {
127     DRAG_EVENT_IN  = 1,
128     DRAG_EVENT_OUT,
129     DRAG_EVENT_MOVE,
130     DRAG_EVENT_END,
131 };
132 
133 enum class WindowTag : uint32_t {
134     MAIN_WINDOW = 0,
135     SUB_WINDOW = 1,
136     SYSTEM_WINDOW = 2,
137 };
138 
139 struct Rect {
140     int32_t posX_;
141     int32_t posY_;
142     uint32_t width_;
143     uint32_t height_;
144 
145     bool operator==(const Rect& a) const
146     {
147         return (posX_ == a.posX_ && posY_ == a.posY_ && width_ == a.width_ && height_ == a.height_);
148     }
149 
150     bool operator!=(const Rect& a) const
151     {
152         return !this->operator==(a);
153     }
154 
IsInsideOfRect155     bool IsInsideOf(const Rect& a) const
156     {
157         return (posX_ >= a.posX_ && posY_ >= a.posY_ &&
158             posX_ + width_ <= a.posX_ + a.width_ && posY_ + height_ <= a.posY_ + a.height_);
159     }
160 };
161 
162 struct PointInfo {
163     int32_t x;
164     int32_t y;
165 };
166 
167 namespace {
168     constexpr uint32_t SYSTEM_COLOR_WHITE = 0xE5FFFFFF;
169     constexpr uint32_t SYSTEM_COLOR_BLACK = 0x66000000;
170     constexpr uint32_t INVALID_WINDOW_ID = 0;
171     constexpr float UNDEFINED_BRIGHTNESS = -1.0f;
172     constexpr float MINIMUM_BRIGHTNESS = 0.0f;
173     constexpr float MAXIMUM_BRIGHTNESS = 1.0f;
174 }
175 
176 struct SystemBarProperty {
177     bool enable_;
178     uint32_t backgroundColor_;
179     uint32_t contentColor_;
SystemBarPropertySystemBarProperty180     SystemBarProperty() : enable_(true), backgroundColor_(SYSTEM_COLOR_BLACK), contentColor_(SYSTEM_COLOR_WHITE) {}
SystemBarPropertySystemBarProperty181     SystemBarProperty(bool enable, uint32_t background, uint32_t content)
182         : enable_(enable), backgroundColor_(background), contentColor_(content) {}
183     bool operator == (const SystemBarProperty& a) const
184     {
185         return (enable_ == a.enable_ && backgroundColor_ == a.backgroundColor_ && contentColor_ == a.contentColor_);
186     }
187 };
188 
189 enum class AvoidAreaType : uint32_t {
190     TYPE_SYSTEM,           // area of SystemUI
191     TYPE_CUTOUT,           // cutout of screen
192     TYPE_SYSTEM_GESTURE,   // area for system gesture
193 };
194 
195 enum class OccupiedAreaType : uint32_t {
196     TYPE_INPUT, // area of input window
197 };
198 
199 enum class ColorSpace : uint32_t {
200     COLOR_SPACE_DEFAULT = 0, // Default color space.
201     COLOR_SPACE_WIDE_GAMUT,  // Wide gamut color space. The specific wide color gamut depends on the screen.
202 };
203 
204 enum class WindowAnimation : uint32_t {
205     NONE,
206     DEFAULT,
207 };
208 
209 struct AvoidArea {
210     Rect leftRect;
211     Rect topRect;
212     Rect rightRect;
213     Rect bottomRect;
214 };
215 
216 enum class WindowUpdateType : int32_t {
217     WINDOW_UPDATE_ADDED = 1,
218     WINDOW_UPDATE_REMOVED,
219     WINDOW_UPDATE_FOCUSED,
220     WINDOW_UPDATE_BOUNDS,
221     WINDOW_UPDATE_ACTIVE,
222 };
223 }
224 }
225 #endif // OHOS_ROSEN_WM_COMMON_H
226