[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / window-devel.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // EXTERNAL INCLUDES
19 #include <dali/public-api/adaptor-framework/window-enumerations.h>
20 #include <dali/public-api/events/key-event.h>
21 #include <dali/public-api/events/wheel-event.h>
22
23 // INTERNAL INCLUDES
24 #include <dali/devel-api/adaptor-framework/window-devel.h>
25 #include <dali/internal/window-system/common/window-impl.h>
26
27 namespace Dali
28 {
29 namespace DevelWindow
30 {
31 Window New(Any surface, PositionSize windowPosition, const std::string& name, bool isTransparent)
32 {
33   return DevelWindow::New(surface, windowPosition, name, "", isTransparent);
34 }
35
36 Window New(Any surface, PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent)
37 {
38   Window newWindow;
39
40   const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable();
41   bool       isNewWindowAllowed = true;
42
43   if(isAdaptorAvailable)
44   {
45     Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
46     isNewWindowAllowed     = Internal::Adaptor::Adaptor::GetImplementation(adaptor).IsMultipleWindowSupported();
47   }
48
49   if(isNewWindowAllowed)
50   {
51     WindowData windowData;
52     windowData.SetPositionSize(windowPosition);
53     windowData.SetTransparency(isTransparent);
54     windowData.SetWindowType(WindowType::NORMAL);
55     Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(surface, name, className, windowData);
56
57     Integration::SceneHolder sceneHolder = Integration::SceneHolder(window);
58     if(isAdaptorAvailable)
59     {
60       Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
61       Internal::Adaptor::Adaptor::GetImplementation(adaptor).AddWindow(sceneHolder);
62     }
63     newWindow = Window(window);
64   }
65   else
66   {
67     DALI_LOG_ERROR("This device can't support multiple windows.\n");
68   }
69
70   return newWindow;
71 }
72
73 void SetPositionSize(Window window, PositionSize positionSize)
74 {
75   GetImplementation(window).SetPositionSize(positionSize);
76 }
77
78 Window Get(Actor actor)
79 {
80   return Internal::Adaptor::Window::Get(actor);
81 }
82
83 EventProcessingFinishedSignalType& EventProcessingFinishedSignal(Window window)
84 {
85   return GetImplementation(window).EventProcessingFinishedSignal();
86 }
87
88 WheelEventSignalType& WheelEventSignal(Window window)
89 {
90   return GetImplementation(window).WheelEventSignal();
91 }
92
93 VisibilityChangedSignalType& VisibilityChangedSignal(Window window)
94 {
95   return GetImplementation(window).VisibilityChangedSignal();
96 }
97
98 TransitionEffectEventSignalType& TransitionEffectEventSignal(Window window)
99 {
100   return GetImplementation(window).TransitionEffectEventSignal();
101 }
102
103 KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal(Window window)
104 {
105   return GetImplementation(window).KeyboardRepeatSettingsChangedSignal();
106 }
107
108 AuxiliaryMessageSignalType& AuxiliaryMessageSignal(Window window)
109 {
110   return GetImplementation(window).AuxiliaryMessageSignal();
111 }
112
113 AccessibilityHighlightSignalType& AccessibilityHighlightSignal(Window window)
114 {
115   return GetImplementation(window).AccessibilityHighlightSignal();
116 }
117
118 MovedSignalType& MovedSignal(Window window)
119 {
120   return GetImplementation(window).MovedSignal();
121 }
122
123 OrientationChangedSignalType& OrientationChangedSignal(Window window)
124 {
125   return GetImplementation(window).OrientationChangedSignal();
126 }
127
128 MoveCompletedSignalType& MoveCompletedSignal(Window window)
129 {
130   return GetImplementation(window).MoveCompletedSignal();
131 }
132
133 ResizeCompletedSignalType& ResizeCompletedSignal(Window window)
134 {
135   return GetImplementation(window).ResizeCompletedSignal();
136 }
137
138 void SetParent(Window window, Window parent)
139 {
140   GetImplementation(window).SetParent(parent);
141 }
142
143 void SetParent(Window window, Window parent, bool belowParent)
144 {
145   GetImplementation(window).SetParent(parent, belowParent);
146 }
147
148 void Unparent(Window window)
149 {
150   GetImplementation(window).Unparent();
151 }
152
153 Window GetParent(Window window)
154 {
155   return GetImplementation(window).GetParent();
156 }
157
158 WindowOrientation GetCurrentOrientation(Window window)
159 {
160   return GetImplementation(window).GetCurrentOrientation();
161 }
162
163 int GetPhysicalOrientation(Window window)
164 {
165   return GetImplementation(window).GetPhysicalOrientation();
166 }
167
168 void SetAvailableOrientations(Window window, const Dali::Vector<WindowOrientation>& orientations)
169 {
170   GetImplementation(window).SetAvailableOrientations(orientations);
171 }
172
173 int32_t GetNativeId(Window window)
174 {
175   return GetImplementation(window).GetNativeId();
176 }
177
178 void AddFrameRenderedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId)
179 {
180   GetImplementation(window).AddFrameRenderedCallback(std::move(callback), frameId);
181 }
182
183 void AddFramePresentedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId)
184 {
185   GetImplementation(window).AddFramePresentedCallback(std::move(callback), frameId);
186 }
187
188 void SetPositionSizeWithOrientation(Window window, PositionSize positionSize, WindowOrientation orientation)
189 {
190   GetImplementation(window).SetPositionSizeWithOrientation(positionSize, orientation);
191 }
192
193 void RequestMoveToServer(Window window)
194 {
195   GetImplementation(window).RequestMoveToServer();
196 }
197
198 void RequestResizeToServer(Window window, WindowResizeDirection direction)
199 {
200   GetImplementation(window).RequestResizeToServer(direction);
201 }
202
203 void EnableFloatingMode(Window window, bool enable)
204 {
205   GetImplementation(window).EnableFloatingMode(enable);
206 }
207
208 bool IsFloatingModeEnabled(Window window)
209 {
210   return GetImplementation(window).IsFloatingModeEnabled();
211 }
212
213 void IncludeInputRegion(Window window, const Rect<int>& inputRegion)
214 {
215   GetImplementation(window).IncludeInputRegion(inputRegion);
216 }
217
218 void ExcludeInputRegion(Window window, const Rect<int>& inputRegion)
219 {
220   GetImplementation(window).ExcludeInputRegion(inputRegion);
221 }
222
223 void SetNeedsRotationCompletedAcknowledgement(Window window, bool needAcknowledgement)
224 {
225   GetImplementation(window).SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
226 }
227
228 void SendRotationCompletedAcknowledgement(Window window)
229 {
230   GetImplementation(window).SendRotationCompletedAcknowledgement();
231 }
232
233 void FeedTouchPoint(Window window, const Dali::TouchPoint& point, int32_t timeStamp)
234 {
235   Integration::Point convertedPoint(point);
236   GetImplementation(window).FeedTouchPoint(convertedPoint, timeStamp);
237 }
238
239 void FeedWheelEvent(Window window, const Dali::WheelEvent& wheelEvent)
240 {
241   Integration::WheelEvent convertedEvent(static_cast<Integration::WheelEvent::Type>(wheelEvent.GetType()), wheelEvent.GetDirection(), wheelEvent.GetModifiers(), wheelEvent.GetPoint(), wheelEvent.GetDelta(), wheelEvent.GetTime());
242   GetImplementation(window).FeedWheelEvent(convertedEvent);
243 }
244
245 void FeedKeyEvent(Window window, const Dali::KeyEvent& keyEvent)
246 {
247   Integration::KeyEvent convertedEvent(keyEvent.GetKeyName(), keyEvent.GetLogicalKey(), keyEvent.GetKeyString(), keyEvent.GetKeyCode(), keyEvent.GetKeyModifier(), keyEvent.GetTime(), static_cast<Integration::KeyEvent::State>(keyEvent.GetState()), keyEvent.GetCompose(), keyEvent.GetDeviceName(), keyEvent.GetDeviceClass(), keyEvent.GetDeviceSubclass());
248   GetImplementation(window).FeedKeyEvent(convertedEvent);
249 }
250
251 void FeedHoverEvent(Window window, const Dali::TouchPoint& point)
252 {
253   Integration::Point convertedPoint(point);
254   GetImplementation(window).FeedHoverEvent(convertedPoint);
255 }
256
257 void Maximize(Window window, bool maximize)
258 {
259   GetImplementation(window).Maximize(maximize);
260 }
261
262 bool IsMaximized(Window window)
263 {
264   return GetImplementation(window).IsMaximized();
265 }
266
267 void SetMaximumSize(Window window, Dali::Window::WindowSize size)
268 {
269   GetImplementation(window).SetMaximumSize(size);
270 }
271
272 void Minimize(Window window, bool miniimize)
273 {
274   GetImplementation(window).Minimize(miniimize);
275 }
276
277 bool IsMinimized(Window window)
278 {
279   return GetImplementation(window).IsMinimized();
280 }
281
282 void SetMimimumSize(Window window, Dali::Window::WindowSize size)
283 {
284   GetImplementation(window).SetMimimumSize(size);
285 }
286
287 bool IsWindowRotating(Window window)
288 {
289   return GetImplementation(window).IsWindowRotating();
290 }
291
292 const KeyEvent& GetLastKeyEvent(Window window)
293 {
294   return GetImplementation(window).GetLastKeyEvent();
295 }
296
297 const TouchEvent& GetLastTouchEvent(Window window)
298 {
299   return GetImplementation(window).GetLastTouchEvent();
300 }
301
302 const HoverEvent& GetLastHoverEvent(Window window)
303 {
304   return GetImplementation(window).GetLastHoverEvent();
305 }
306
307 bool PointerConstraintsLock(Window window)
308 {
309   return GetImplementation(window).PointerConstraintsLock();
310 }
311
312 bool PointerConstraintsUnlock(Window window)
313 {
314   return GetImplementation(window).PointerConstraintsUnlock();
315 }
316
317 void LockedPointerRegionSet(Window window, int32_t x, int32_t y, int32_t width, int32_t height)
318 {
319   GetImplementation(window).LockedPointerRegionSet(x, y, width, height);
320 }
321
322 void LockedPointerCursorPositionHintSet(Window window, int32_t x, int32_t y)
323 {
324   GetImplementation(window).LockedPointerCursorPositionHintSet(x, y);
325 }
326
327 bool PointerWarp(Window window, int32_t x, int32_t y)
328 {
329   return GetImplementation(window).PointerWarp(x, y);
330 }
331
332 void CursorVisibleSet(Window window, bool visible)
333 {
334   GetImplementation(window).CursorVisibleSet(visible);
335 }
336
337 bool KeyboardGrab(Window window, Device::Subclass::Type deviceSubclass)
338 {
339   return GetImplementation(window).KeyboardGrab(deviceSubclass);
340 }
341
342 bool KeyboardUnGrab(Window window)
343 {
344   return GetImplementation(window).KeyboardUnGrab();
345 }
346
347 void SetFullScreen(Window window, bool fullscreen)
348 {
349   GetImplementation(window).SetFullScreen(fullscreen);
350 }
351
352 bool GetFullScreen(Window window)
353 {
354   return GetImplementation(window).GetFullScreen();
355 }
356
357 void SetFrontBufferRendering(Window window, bool enable)
358 {
359   GetImplementation(window).SetFrontBufferRendering(enable);
360 }
361
362 bool GetFrontBufferRendering(Window window)
363 {
364   return GetImplementation(window).GetFrontBufferRendering();
365 }
366
367 InterceptKeyEventSignalType& InterceptKeyEventSignal(Window window)
368 {
369   return GetImplementation(window).InterceptKeyEventSignal();
370 }
371
372 MouseInOutEventSignalType& MouseInOutEventSignal(Window window)
373 {
374   return GetImplementation(window).MouseInOutEventSignal();
375 }
376
377 InsetsChangedSignalType& InsetsChangedSignal(Window window)
378 {
379   return GetImplementation(window).InsetsChangedSignal();
380 }
381
382 MouseRelativeEventSignalType& MouseRelativeEventSignal(Window window)
383 {
384   return GetImplementation(window).MouseRelativeEventSignal();
385 }
386
387 PointerConstraintsSignalType& PointerConstraintsSignal(Window window)
388 {
389   return GetImplementation(window).PointerConstraintsSignal();
390 }
391
392 } // namespace DevelWindow
393
394 } // namespace Dali