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 FRAMEWORKS_WMSERVICE_INCLUDE_WINDOW_MANAGER_SERVICE_CLIENT_IMPL_H 17 #define FRAMEWORKS_WMSERVICE_INCLUDE_WINDOW_MANAGER_SERVICE_CLIENT_IMPL_H 18 19 #include <memory> 20 #include <mutex> 21 #include <thread> 22 23 #include <promise.h> 24 #include <window_manager_service_client.h> 25 #include <wms-client-protocol.h> 26 27 namespace OHOS { 28 class WindowManagerServiceClientImpl : public WindowManagerServiceClient { 29 public: 30 static sptr<WindowManagerServiceClientImpl> GetInstance(); 31 32 virtual GSError Init() override; 33 virtual sptr<IWindowManagerService> GetService() const override; 34 35 private: 36 WindowManagerServiceClientImpl() = default; 37 virtual ~WindowManagerServiceClientImpl() override; 38 static inline sptr<WindowManagerServiceClientImpl> instance = nullptr; 39 40 GSError Deinit(); 41 42 void StartDispatchThread(); 43 void StopDispatchThread(); 44 void DispatchThreadMain(); 45 void InterruptDispatchThread(); 46 int32_t interruptFd = -1; 47 std::unique_ptr<std::once_flag> startOnceFlag = nullptr; 48 sptr<Promise<bool>> startPromise = nullptr; 49 50 struct wms *wms = nullptr; 51 struct wl_display *display = nullptr; 52 struct wl_registry *registry = nullptr; 53 sptr<IWindowManagerService> wmservice; 54 std::unique_ptr<std::thread> dispatchThread; 55 }; 56 } // namespace OHOS 57 58 #endif // FRAMEWORKS_WMSERVICE_INCLUDE_WINDOW_MANAGER_SERVICE_CLIENT_IMPL_H 59