2 * Copyright (c) 2023 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>
25 #include <dali/devel-api/adaptor-framework/keyboard.h>
26 #include <dali/internal/adaptor/common/framework-factory.h>
27 #include <dali/internal/system/common/time-service.h>
28 #include <dali/internal/window-system/common/window-system.h>
30 #define START_DURATION_CHECK() \
31 uint32_t durationMilliSeconds = static_cast<uint32_t>(-1); \
32 uint32_t startTime, endTime; \
33 startTime = TimeService::GetMilliSeconds();
35 #define FINISH_DURATION_CHECK(functionName) \
36 endTime = TimeService::GetMilliSeconds(); \
37 durationMilliSeconds = endTime - startTime; \
38 if(durationMilliSeconds > 0) \
40 DALI_LOG_DEBUG_INFO("%s : duration [%u ms]\n", functionName, durationMilliSeconds); \
49 namespace WindowSystem
53 static int32_t gScreenWidth = 0;
54 static int32_t gScreenHeight = 0;
55 static bool gGeometryHittest = false;
56 } // unnamed namespace
60 auto frameworkFactory = Dali::Internal::Adaptor::GetFrameworkFactory();
61 if(frameworkFactory == nullptr || (frameworkFactory && frameworkFactory->GetFrameworkBackend() == FrameworkBackend::DEFAULT))
69 auto backend = Dali::Internal::Adaptor::GetFrameworkFactory()->GetFrameworkBackend();
70 if(backend == FrameworkBackend::DEFAULT)
76 void GetScreenSize(int32_t& width, int32_t& height)
78 auto backend = Dali::Internal::Adaptor::GetFrameworkFactory()->GetFrameworkBackend();
79 if(backend == FrameworkBackend::DEFAULT)
81 if(gScreenWidth == 0 || gScreenHeight == 0)
83 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
86 START_DURATION_CHECK();
87 ecore_wl2_display_screen_size_get(display, &gScreenWidth, &gScreenHeight);
88 FINISH_DURATION_CHECK("ecore_wl2_display_screen_size_get");
90 DALI_ASSERT_ALWAYS((gScreenWidth > 0) && "screen width is 0");
91 DALI_ASSERT_ALWAYS((gScreenHeight > 0) && "screen height is 0");
96 height = gScreenHeight;
99 void UpdateScreenSize()
101 auto backend = Dali::Internal::Adaptor::GetFrameworkFactory()->GetFrameworkBackend();
102 if(backend == FrameworkBackend::DEFAULT)
104 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
107 START_DURATION_CHECK();
108 ecore_wl2_display_screen_size_get(display, &gScreenWidth, &gScreenHeight);
109 FINISH_DURATION_CHECK("ecore_wl2_display_screen_size_get");
114 bool SetKeyboardRepeatInfo(float rate, float delay)
116 auto backend = Dali::Internal::Adaptor::GetFrameworkFactory()->GetFrameworkBackend();
117 if(backend == FrameworkBackend::DEFAULT)
119 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
120 return ecore_wl2_input_keyboard_repeat_set(input, static_cast<double>(rate), static_cast<double>(delay));
125 bool GetKeyboardRepeatInfo(float& rate, float& delay)
127 auto backend = Dali::Internal::Adaptor::GetFrameworkFactory()->GetFrameworkBackend();
128 if(backend == FrameworkBackend::DEFAULT)
130 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
131 double rateVal, delayVal;
132 bool ret = ecore_wl2_input_keyboard_repeat_get(input, &rateVal, &delayVal);
133 rate = static_cast<float>(rateVal);
134 delay = static_cast<float>(delayVal);
141 bool SetKeyboardHorizontalRepeatInfo(float rate, float delay)
143 #ifdef OVER_TIZEN_VERSION_8
144 auto frameworkFactory = Dali::Internal::Adaptor::GetFrameworkFactory();
145 if(frameworkFactory == nullptr || (frameworkFactory && frameworkFactory->GetFrameworkBackend() == FrameworkBackend::DEFAULT))
147 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
148 return ecore_wl2_input_keyboard_horizontal_way_repeat_set(input, static_cast<double>(rate), static_cast<double>(delay));
152 return SetKeyboardRepeatInfo(rate, delay);
156 bool GetKeyboardHorizontalRepeatInfo(float& rate, float& delay)
158 #ifdef OVER_TIZEN_VERSION_8
159 auto frameworkFactory = Dali::Internal::Adaptor::GetFrameworkFactory();
160 if(frameworkFactory == nullptr || (frameworkFactory && frameworkFactory->GetFrameworkBackend() == FrameworkBackend::DEFAULT))
162 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
163 double rateVal, delayVal;
164 bool ret = ecore_wl2_input_keyboard_horizontal_way_repeat_get(input, &rateVal, &delayVal);
165 rate = static_cast<float>(rateVal);
166 delay = static_cast<float>(delayVal);
172 return GetKeyboardRepeatInfo(rate, delay);
176 bool SetKeyboardVerticalRepeatInfo(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 return ecore_wl2_input_keyboard_vertical_way_repeat_set(input, static_cast<double>(rate), static_cast<double>(delay));
187 return SetKeyboardRepeatInfo(rate, delay);
191 bool GetKeyboardVerticalRepeatInfo(float& rate, float& delay)
193 #ifdef OVER_TIZEN_VERSION_8
194 auto frameworkFactory = Dali::Internal::Adaptor::GetFrameworkFactory();
195 if(frameworkFactory == nullptr || (frameworkFactory && frameworkFactory->GetFrameworkBackend() == FrameworkBackend::DEFAULT))
197 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
198 double rateVal, delayVal;
199 bool ret = ecore_wl2_input_keyboard_vertical_way_repeat_get(input, &rateVal, &delayVal);
200 rate = static_cast<float>(rateVal);
201 delay = static_cast<float>(delayVal);
207 return GetKeyboardRepeatInfo(rate, delay);
211 void SetGeometryHittestEnabled(bool enable)
213 DALI_LOG_RELEASE_INFO("GeometryHittest : %d \n", enable);
214 gGeometryHittest = enable;
217 Dali::SceneHolderList sceneHolders = Dali::Adaptor::Get().GetSceneHolders();
218 for(auto iter = sceneHolders.begin(); iter != sceneHolders.end(); ++iter)
222 (*iter).SetGeometryHittestEnabled(enable);
228 bool IsGeometryHittestEnabled()
230 return gGeometryHittest;
233 } // namespace WindowSystem
235 } // namespace Adaptor
237 } // namespace Internal
241 #pragma GCC diagnostic pop