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 INTERFACES_INNERKITS_WMCLIENT_WM_COMMON_H 17 #define INTERFACES_INNERKITS_WMCLIENT_WM_COMMON_H 18 19 #ifdef __cplusplus 20 #include <functional> 21 #include <string> 22 #include <map> 23 #endif 24 25 #include "../common/graphic_common.h" 26 27 #ifdef __cplusplus 28 namespace OHOS { 29 #endif 30 31 #define WINDOW_TYPE_LIST(macro) \ 32 macro(WINDOW_TYPE_NORMAL), \ 33 macro(WINDOW_TYPE_STATUS_BAR), \ 34 macro(WINDOW_TYPE_NAVI_BAR), \ 35 macro(WINDOW_TYPE_ALARM_SCREEN), \ 36 macro(WINDOW_TYPE_SYSTEM_UI), \ 37 macro(WINDOW_TYPE_LAUNCHER), \ 38 macro(WINDOW_TYPE_VIDEO), \ 39 macro(WINDOW_TYPE_INPUT_METHOD), \ 40 macro(WINDOW_TYPE_INPUT_METHOD_SELECTOR), \ 41 macro(WINDOW_TYPE_VOLUME_OVERLAY), \ 42 macro(WINDOW_TYPE_NOTIFICATION_SHADE), \ 43 macro(WINDOW_TYPE_FLOAT), \ 44 macro(WINDOW_TYPE_CALLING), \ 45 macro(WINDOW_TYPE_FULL_SCREEN), \ 46 macro(WINDOW_TYPE_POPUP), \ 47 macro(WINDOW_TYPE_SAFE_OVERLAY), \ 48 macro(WINDOW_TYPE_SCREENSAVER_CALLING), \ 49 macro(WINDOW_TYPE_SCREENSAVER_DIALOG), \ 50 macro(WINDOW_TYPE_SCREENSAVER), \ 51 macro(WINDOW_TYPE_SEARCHER), \ 52 macro(WINDOW_TYPE_STATUS_SCREEN), \ 53 macro(WINDOW_TYPE_SYSTEM_ERROR), \ 54 macro(WINDOW_TYPE_TOAST), \ 55 macro(WINDOW_TYPE_WALLPAPER), \ 56 macro(WINDOW_TYPE_ANIMATION), \ 57 macro(WINDOW_TYPE_SPLIT_LINE), \ 58 macro(WINDOW_TYPE_LAUNCH_PAGE), \ 59 macro(WINDOW_TYPE_CURSOR), \ 60 macro(WINDOW_TYPE_APPLICATION_BASE), \ 61 macro(WINDOW_TYPE_APPLICATION_FIRST), \ 62 macro(WINDOW_TYPE_APPLICATION_NORMAL), \ 63 macro(WINDOW_TYPE_TOP), \ 64 macro(WINDOW_TYPE_MAX), 65 66 #define DEFINE_ENUM_WINDOW_TYPE(id) id 67 #define DEFINE_STRMAP_WINDOW_TYPE(id) { #id, id, } 68 69 enum WindowType { WINDOW_TYPE_LIST(DEFINE_ENUM_WINDOW_TYPE) }; 70 71 #ifdef __cplusplus 72 static const std::map<std::string, enum WindowType> windowTypeStrs = { 73 WINDOW_TYPE_LIST(DEFINE_STRMAP_WINDOW_TYPE) 74 }; 75 #endif 76 77 enum SubWindowType { 78 WM_WINDOW_TYPE_SUB_NORMAL = 0, 79 WM_WINDOW_TYPE_SUB_VIDEO = 1, 80 }; 81 82 enum rotateType { 83 /** 84 * no transform 85 */ 86 WM_ROTATE_TYPE_NORMAL = 0, 87 /** 88 * 90 degrees counter-clockwise 89 */ 90 WM_ROTATE_TYPE_90 = 1, 91 /** 92 * 180 degrees counter-clockwise 93 */ 94 WM_ROTATE_TYPE_180 = 2, 95 /** 96 * 270 degrees counter-clockwise 97 */ 98 WM_ROTATE_TYPE_270 = 3, 99 /** 100 * 180 degree flip around a vertical axis 101 */ 102 WM_ROTATE_TYPE_FLIPPED = 4, 103 /** 104 * flip and rotate 90 degrees counter-clockwise 105 */ 106 WM_ROTATE_TYPE_FLIPPED_90 = 5, 107 /** 108 * flip and rotate 180 degrees counter-clockwise 109 */ 110 WM_ROTATE_TYPE_FLIPPED_180 = 6, 111 /** 112 * flip and rotate 270 degrees counter-clockwise 113 */ 114 WM_ROTATE_TYPE_FLIPPED_270 = 7, 115 }; 116 117 struct WMImageInfo { 118 enum GSError wret; 119 uint32_t width; 120 uint32_t height; 121 uint32_t format; 122 uint32_t size; 123 const void *data; 124 }; 125 126 struct WindowInfo { 127 int32_t width; 128 int32_t height; 129 int32_t pos_x; 130 int32_t pos_y; 131 }; 132 133 #ifdef __cplusplus 134 135 using funcWindowInfoChange = std::function<void(WindowInfo &info)>; 136 using WindowPositionChangeFunc = std::function<void(int32_t x, int32_t y)>; 137 using WindowSizeChangeFunc = std::function<void(uint32_t width, uint32_t height)>; 138 using WindowVisibilityChangeFunc = std::function<void(bool visibility)>; 139 using WindowTypeChangeFunc = std::function<void(WindowType type)>; 140 using WindowPIPModeChangeFunc = std::function<void(bool inPIPMode)>; 141 #endif 142 143 typedef void (*FuncSync)(uint64_t timestamp); 144 struct WindowConfig { 145 int32_t width; 146 int32_t height; 147 int32_t pos_x; 148 int32_t pos_y; 149 int32_t format; 150 int32_t stride; 151 int32_t type; 152 int32_t parentid; 153 bool subwindow; 154 FuncSync sync; 155 }; 156 #ifdef __cplusplus 157 } // namespace OHOS 158 #endif // __cplusplus 159 160 #endif // INTERFACES_INNERKITS_WMCLIENT_WM_COMMON_H 161