2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <Ecore_Wl2.h>
20 #include <dali/integration-api/adaptor-framework/adaptor.h>
21 #include <dali/integration-api/adaptor-framework/scene-holder.h>
22 #include <dali/integration-api/debug.h>
27 #include <dali/devel-api/adaptor-framework/keyboard.h>
28 #include <dali/internal/adaptor/common/framework-factory.h>
29 #include <dali/internal/system/common/time-service.h>
30 #include <dali/internal/window-system/common/window-system.h>
32 #define START_DURATION_CHECK() \
33 uint32_t durationMilliSeconds = static_cast<uint32_t>(-1); \
34 uint32_t startTime, endTime; \
35 startTime = TimeService::GetMilliSeconds();
37 #define FINISH_DURATION_CHECK(functionName) \
38 endTime = TimeService::GetMilliSeconds(); \
39 durationMilliSeconds = endTime - startTime; \
40 if(durationMilliSeconds > 0) \
42 DALI_LOG_DEBUG_INFO("%s : duration [%u ms]\n", functionName, durationMilliSeconds); \
51 namespace WindowSystem
55 static int32_t gScreenWidth = 0;
56 static int32_t gScreenHeight = 0;
57 static bool gGeometryHittest = false;
58 } // unnamed namespace
62 auto frameworkFactory = Dali::Internal::Adaptor::GetFrameworkFactory();
63 if(frameworkFactory == nullptr || (frameworkFactory && frameworkFactory->GetFrameworkBackend() == FrameworkBackend::DEFAULT))
65 print_log(DLOG_INFO, "DALI", "%s: %s(%d) > ecore_wl2_init()", __MODULE__, __func__, __LINE__);
72 auto frameworkFactory = Dali::Internal::Adaptor::GetFrameworkFactory();
73 if(frameworkFactory == nullptr || (frameworkFactory && frameworkFactory->GetFrameworkBackend() == FrameworkBackend::DEFAULT))
75 print_log(DLOG_INFO, "DALI", "%s: %s(%d) > ecore_wl2_shutdown()", __MODULE__, __func__, __LINE__);
80 void GetScreenSize(int32_t& width, int32_t& height)
82 auto frameworkFactory = Dali::Internal::Adaptor::GetFrameworkFactory();
83 if(frameworkFactory == nullptr || (frameworkFactory && frameworkFactory->GetFrameworkBackend() == FrameworkBackend::DEFAULT))
85 if(gScreenWidth == 0 || gScreenHeight == 0)
87 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
90 START_DURATION_CHECK();
91 ecore_wl2_display_screen_size_get(display, &gScreenWidth, &gScreenHeight);
92 FINISH_DURATION_CHECK("ecore_wl2_display_screen_size_get");
94 // Since dali adaptor doesn't initialize this time, we should use dlog.
95 print_log(DLOG_INFO, "DALI", "%s: %s(%d) > GetScreenSize() for display(%p) return %d x %d", __MODULE__, __func__, __LINE__, display, gScreenWidth, gScreenHeight);
97 DALI_ASSERT_ALWAYS((gScreenWidth > 0) && "screen width is 0");
98 DALI_ASSERT_ALWAYS((gScreenHeight > 0) && "screen height is 0");
102 // Since dali adaptor doesn't initialize this time, we should use dlog.
103 print_log(DLOG_INFO, "DALI", "%s: %s(%d) > GetScreenSize() but display is null", __MODULE__, __func__, __LINE__);
107 width = gScreenWidth;
108 height = gScreenHeight;
111 void UpdateScreenSize()
113 auto frameworkFactory = Dali::Internal::Adaptor::GetFrameworkFactory();
114 if(frameworkFactory == nullptr || (frameworkFactory && frameworkFactory->GetFrameworkBackend() == FrameworkBackend::DEFAULT))
116 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
119 START_DURATION_CHECK();
120 ecore_wl2_display_screen_size_get(display, &gScreenWidth, &gScreenHeight);
121 FINISH_DURATION_CHECK("ecore_wl2_display_screen_size_get");
123 // Since dali adaptor doesn't initialize this time, we should use dlog.
124 print_log(DLOG_INFO, "DALI", "%s: %s(%d) > UpdateScreenSize() for display(%p) return %d x %d", __MODULE__, __func__, __LINE__, display, gScreenWidth, gScreenHeight);
128 // Since dali adaptor doesn't initialize this time, we should use dlog.
129 print_log(DLOG_INFO, "DALI", "%s: %s(%d) > UpdateScreenSize() but display is null", __MODULE__, __func__, __LINE__);
134 bool SetKeyboardRepeatInfo(float rate, float delay)
136 auto frameworkFactory = Dali::Internal::Adaptor::GetFrameworkFactory();
137 if(frameworkFactory == nullptr || (frameworkFactory && frameworkFactory->GetFrameworkBackend() == FrameworkBackend::DEFAULT))
139 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
140 return ecore_wl2_input_keyboard_repeat_set(input, static_cast<double>(rate), static_cast<double>(delay));
145 bool GetKeyboardRepeatInfo(float& rate, float& delay)
147 auto frameworkFactory = Dali::Internal::Adaptor::GetFrameworkFactory();
148 if(frameworkFactory == nullptr || (frameworkFactory && frameworkFactory->GetFrameworkBackend() == FrameworkBackend::DEFAULT))
150 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
151 double rateVal, delayVal;
152 bool ret = ecore_wl2_input_keyboard_repeat_get(input, &rateVal, &delayVal);
153 rate = static_cast<float>(rateVal);
154 delay = static_cast<float>(delayVal);
161 bool SetKeyboardHorizontalRepeatInfo(float rate, float delay)
163 #ifdef OVER_TIZEN_VERSION_8
164 auto frameworkFactory = Dali::Internal::Adaptor::GetFrameworkFactory();
165 if(frameworkFactory == nullptr || (frameworkFactory && frameworkFactory->GetFrameworkBackend() == FrameworkBackend::DEFAULT))
167 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
168 return ecore_wl2_input_keyboard_horizontal_way_repeat_set(input, static_cast<double>(rate), static_cast<double>(delay));
172 return SetKeyboardRepeatInfo(rate, delay);
176 bool GetKeyboardHorizontalRepeatInfo(float& rate, float& delay)
178 #ifdef OVER_TIZEN_VERSION_8
179 auto frameworkFactory = Dali::Internal::Adaptor::GetFrameworkFactory();
180 if(frameworkFactory == nullptr || (frameworkFactory && frameworkFactory->GetFrameworkBackend() == FrameworkBackend::DEFAULT))
182 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
183 double rateVal, delayVal;
184 bool ret = ecore_wl2_input_keyboard_horizontal_way_repeat_get(input, &rateVal, &delayVal);
185 rate = static_cast<float>(rateVal);
186 delay = static_cast<float>(delayVal);
192 return GetKeyboardRepeatInfo(rate, delay);
196 bool SetKeyboardVerticalRepeatInfo(float rate, float delay)
198 #ifdef OVER_TIZEN_VERSION_8
199 auto frameworkFactory = Dali::Internal::Adaptor::GetFrameworkFactory();
200 if(frameworkFactory == nullptr || (frameworkFactory && frameworkFactory->GetFrameworkBackend() == FrameworkBackend::DEFAULT))
202 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
203 return ecore_wl2_input_keyboard_vertical_way_repeat_set(input, static_cast<double>(rate), static_cast<double>(delay));
207 return SetKeyboardRepeatInfo(rate, delay);
211 bool GetKeyboardVerticalRepeatInfo(float& rate, float& delay)
213 #ifdef OVER_TIZEN_VERSION_8
214 auto frameworkFactory = Dali::Internal::Adaptor::GetFrameworkFactory();
215 if(frameworkFactory == nullptr || (frameworkFactory && frameworkFactory->GetFrameworkBackend() == FrameworkBackend::DEFAULT))
217 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
218 double rateVal, delayVal;
219 bool ret = ecore_wl2_input_keyboard_vertical_way_repeat_get(input, &rateVal, &delayVal);
220 rate = static_cast<float>(rateVal);
221 delay = static_cast<float>(delayVal);
227 return GetKeyboardRepeatInfo(rate, delay);
231 void SetGeometryHittestEnabled(bool enable)
233 DALI_LOG_RELEASE_INFO("GeometryHittest : %d \n", enable);
234 if(gGeometryHittest != enable && Dali::Adaptor::IsAvailable())
236 Dali::SceneHolderList sceneHolders = Dali::Adaptor::Get().GetSceneHolders();
237 for(auto iter = sceneHolders.begin(); iter != sceneHolders.end(); ++iter)
241 (*iter).SetGeometryHittestEnabled(enable);
245 gGeometryHittest = enable;
248 bool IsGeometryHittestEnabled()
250 return gGeometryHittest;
253 } // namespace WindowSystem
255 } // namespace Adaptor
257 } // namespace Internal
261 #pragma GCC diagnostic pop