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 #include "js_runtime_utils.h" 17 #include "js_window_register_manager.h" 18 #include "native_engine/native_engine.h" 19 #include "native_engine/native_reference.h" 20 #include "native_engine/native_value.h" 21 #include "wm_common.h" 22 23 #ifndef OHOS_JS_WINDOW_MANAGER_H 24 #define OHOS_JS_WINDOW_MANAGER_H 25 namespace OHOS { 26 namespace Rosen { 27 NativeValue* JsWindowManagerInit(NativeEngine* engine, NativeValue* exportObj); 28 class JsWindowManager { 29 public: 30 JsWindowManager(); 31 ~JsWindowManager(); 32 static void Finalizer(NativeEngine* engine, void* data, void* hint); 33 static NativeValue* Create(NativeEngine* engine, NativeCallbackInfo* info); 34 static NativeValue* CreateWindow(NativeEngine* engine, NativeCallbackInfo* info); 35 static NativeValue* FindWindow(NativeEngine* engine, NativeCallbackInfo* info); 36 static NativeValue* FindWindowSync(NativeEngine* engine, NativeCallbackInfo* info); 37 static NativeValue* MinimizeAll(NativeEngine* engine, NativeCallbackInfo* info); 38 static NativeValue* ToggleShownStateForAllAppWindows(NativeEngine* engine, NativeCallbackInfo* info); 39 static NativeValue* RegisterWindowManagerCallback(NativeEngine* engine, NativeCallbackInfo* info); 40 static NativeValue* UnregisterWindowMangerCallback(NativeEngine* engine, NativeCallbackInfo* info); 41 static NativeValue* GetTopWindow(NativeEngine* engine, NativeCallbackInfo* info); 42 static NativeValue* GetLastWindow(NativeEngine* engine, NativeCallbackInfo* info); 43 static NativeValue* SetWindowLayoutMode(NativeEngine* engine, NativeCallbackInfo* info); 44 45 private: 46 static NativeValue* OnCreate(NativeEngine& engine, NativeCallbackInfo& info); 47 static NativeValue* OnCreateWindow(NativeEngine& engine, NativeCallbackInfo& info); 48 static NativeValue* OnFindWindow(NativeEngine& engine, NativeCallbackInfo& info); 49 static NativeValue* OnFindWindowSync(NativeEngine& engine, NativeCallbackInfo& info); 50 static NativeValue* OnMinimizeAll(NativeEngine& engine, NativeCallbackInfo& info); 51 static NativeValue* OnToggleShownStateForAllAppWindows(NativeEngine& engine, NativeCallbackInfo& info); 52 NativeValue* OnRegisterWindowMangerCallback(NativeEngine& engine, NativeCallbackInfo& info); 53 NativeValue* OnUnregisterWindowManagerCallback(NativeEngine& engine, NativeCallbackInfo& info); 54 static NativeValue* OnGetTopWindow(NativeEngine& engine, NativeCallbackInfo& info); 55 static NativeValue* OnGetLastWindow(NativeEngine& engine, NativeCallbackInfo& info); 56 static NativeValue* OnSetWindowLayoutMode(NativeEngine& engine, NativeCallbackInfo& info); 57 static bool ParseConfigOption( 58 NativeEngine& engine, NativeObject* jsObject, WindowOption& option, void*& contextPtr); 59 std::unique_ptr<JsWindowRegisterManager> registerManager_ = nullptr; 60 }; 61 } // namespace Rosen 62 } // namespace OHOS 63 64 #endif 65