Added UIThreadLoader to GLIB framework
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / windows / callback-manager-win.cpp
1 /*\r
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  * http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  *\r
16  */\r
17 \r
18 // CLASS HEADER\r
19 #include <dali/internal/system/windows/callback-manager-win.h>\r
20 \r
21 // EXTERNAL INCLUDES\r
22 #include <Windows.h>\r
23 \r
24 // Need to undef the following constants as they are defined in one of the headers in Windows.h but used in DALi (via debug.h)\r
25 #undef TRANSPARENT // Used in constants.h\r
26 #undef CopyMemory  // Used in dali-vector.h\r
27 \r
28 #include <dali/integration-api/debug.h>\r
29 \r
30 // INTERNAL INCLUDES\r
31 #include <dali/internal/window-system/windows/platform-implement-win.h>\r
32 \r
33 namespace Dali\r
34 {\r
35 namespace Internal\r
36 {\r
37 namespace Adaptor\r
38 {\r
39 WinCallbackManager::WinCallbackManager()\r
40 : mRunning(false)\r
41 {\r
42 }\r
43 \r
44 void WinCallbackManager::Start()\r
45 {\r
46   DALI_ASSERT_DEBUG(mRunning == false);\r
47   mRunning = true;\r
48 }\r
49 \r
50 void WinCallbackManager::Stop()\r
51 {\r
52   // make sure we're not called twice\r
53   DALI_ASSERT_DEBUG(mRunning == true);\r
54 \r
55   mRunning = false;\r
56 }\r
57 \r
58 bool WinCallbackManager::AddIdleCallback(CallbackBase* callback, bool hasReturnValue)\r
59 {\r
60   if(!mRunning)\r
61   {\r
62     return false;\r
63   }\r
64 \r
65   mCallbacks.insert(callback);\r
66 \r
67   WindowsPlatform::PostWinThreadMessage(WIN_CALLBACK_EVENT, reinterpret_cast<uint64_t>(callback), 0);\r
68 \r
69   return true;\r
70 }\r
71 \r
72 void WinCallbackManager::RemoveIdleCallback(CallbackBase* callback)\r
73 {\r
74   //Wait for deal\r
75 }\r
76 \r
77 bool WinCallbackManager::ProcessIdle()\r
78 {\r
79   const bool idleProcessed = !mCallbacks.empty();\r
80 \r
81   // @todo : Need to consider callback with return & don't erase callback when it return true.\r
82   for(CallbackBase* cb : mCallbacks)\r
83   {\r
84     Dali::CallbackBase::Execute(*cb);\r
85   }\r
86   mCallbacks.clear();\r
87 \r
88   return idleProcessed;\r
89 }\r
90 \r
91 void WinCallbackManager::ClearIdleCallbacks()\r
92 {\r
93   mCallbacks.clear();\r
94 }\r
95 \r
96 bool WinCallbackManager::AddIdleEntererCallback(CallbackBase* callback)\r
97 {\r
98   return AddIdleCallback(callback, true);\r
99 }\r
100 \r
101 void WinCallbackManager::RemoveIdleEntererCallback(CallbackBase* callback)\r
102 {\r
103 }\r
104 \r
105 } // namespace Adaptor\r
106 \r
107 } // namespace Internal\r
108 \r
109 } // namespace Dali\r