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 <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>
24 #include <dali/devel-api/adaptor-framework/window-devel.h>
25 #include <dali/internal/window-system/common/window-impl.h>
31 Window New(Any surface, PositionSize windowPosition, const std::string& name, bool isTransparent)
33 return DevelWindow::New(surface, windowPosition, name, "", isTransparent);
36 Window New(Any surface, PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent)
40 const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable();
41 bool isNewWindowAllowed = true;
43 if(isAdaptorAvailable)
45 Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
46 isNewWindowAllowed = Internal::Adaptor::Adaptor::GetImplementation(adaptor).IsMultipleWindowSupported();
49 if(isNewWindowAllowed)
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);
57 Integration::SceneHolder sceneHolder = Integration::SceneHolder(window);
58 if(isAdaptorAvailable)
60 Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
61 Internal::Adaptor::Adaptor::GetImplementation(adaptor).AddWindow(sceneHolder);
63 newWindow = Window(window);
67 DALI_LOG_ERROR("This device can't support multiple windows.\n");
73 void SetPositionSize(Window window, PositionSize positionSize)
75 GetImplementation(window).SetPositionSize(positionSize);
78 Window Get(Actor actor)
80 return Internal::Adaptor::Window::Get(actor);
83 EventProcessingFinishedSignalType& EventProcessingFinishedSignal(Window window)
85 return GetImplementation(window).EventProcessingFinishedSignal();
88 WheelEventSignalType& WheelEventSignal(Window window)
90 return GetImplementation(window).WheelEventSignal();
93 VisibilityChangedSignalType& VisibilityChangedSignal(Window window)
95 return GetImplementation(window).VisibilityChangedSignal();
98 TransitionEffectEventSignalType& TransitionEffectEventSignal(Window window)
100 return GetImplementation(window).TransitionEffectEventSignal();
103 KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal(Window window)
105 return GetImplementation(window).KeyboardRepeatSettingsChangedSignal();
108 AuxiliaryMessageSignalType& AuxiliaryMessageSignal(Window window)
110 return GetImplementation(window).AuxiliaryMessageSignal();
113 AccessibilityHighlightSignalType& AccessibilityHighlightSignal(Window window)
115 return GetImplementation(window).AccessibilityHighlightSignal();
118 MovedSignalType& MovedSignal(Window window)
120 return GetImplementation(window).MovedSignal();
123 OrientationChangedSignalType& OrientationChangedSignal(Window window)
125 return GetImplementation(window).OrientationChangedSignal();
128 MoveCompletedSignalType& MoveCompletedSignal(Window window)
130 return GetImplementation(window).MoveCompletedSignal();
133 ResizeCompletedSignalType& ResizeCompletedSignal(Window window)
135 return GetImplementation(window).ResizeCompletedSignal();
138 void SetParent(Window window, Window parent)
140 GetImplementation(window).SetParent(parent);
143 void SetParent(Window window, Window parent, bool belowParent)
145 GetImplementation(window).SetParent(parent, belowParent);
148 void Unparent(Window window)
150 GetImplementation(window).Unparent();
153 Window GetParent(Window window)
155 return GetImplementation(window).GetParent();
158 WindowOrientation GetCurrentOrientation(Window window)
160 return GetImplementation(window).GetCurrentOrientation();
163 int GetPhysicalOrientation(Window window)
165 return GetImplementation(window).GetPhysicalOrientation();
168 void SetAvailableOrientations(Window window, const Dali::Vector<WindowOrientation>& orientations)
170 GetImplementation(window).SetAvailableOrientations(orientations);
173 int32_t GetNativeId(Window window)
175 return GetImplementation(window).GetNativeId();
178 void AddFrameRenderedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId)
180 GetImplementation(window).AddFrameRenderedCallback(std::move(callback), frameId);
183 void AddFramePresentedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId)
185 GetImplementation(window).AddFramePresentedCallback(std::move(callback), frameId);
188 void SetPositionSizeWithOrientation(Window window, PositionSize positionSize, WindowOrientation orientation)
190 GetImplementation(window).SetPositionSizeWithOrientation(positionSize, orientation);
193 void RequestMoveToServer(Window window)
195 GetImplementation(window).RequestMoveToServer();
198 void RequestResizeToServer(Window window, WindowResizeDirection direction)
200 GetImplementation(window).RequestResizeToServer(direction);
203 void EnableFloatingMode(Window window, bool enable)
205 GetImplementation(window).EnableFloatingMode(enable);
208 bool IsFloatingModeEnabled(Window window)
210 return GetImplementation(window).IsFloatingModeEnabled();
213 void IncludeInputRegion(Window window, const Rect<int>& inputRegion)
215 GetImplementation(window).IncludeInputRegion(inputRegion);
218 void ExcludeInputRegion(Window window, const Rect<int>& inputRegion)
220 GetImplementation(window).ExcludeInputRegion(inputRegion);
223 void SetNeedsRotationCompletedAcknowledgement(Window window, bool needAcknowledgement)
225 GetImplementation(window).SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
228 void SendRotationCompletedAcknowledgement(Window window)
230 GetImplementation(window).SendRotationCompletedAcknowledgement();
233 void FeedTouchPoint(Window window, const Dali::TouchPoint& point, int32_t timeStamp)
235 Integration::Point convertedPoint(point);
236 GetImplementation(window).FeedTouchPoint(convertedPoint, timeStamp);
239 void FeedWheelEvent(Window window, const Dali::WheelEvent& wheelEvent)
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);
245 void FeedKeyEvent(Window window, const Dali::KeyEvent& keyEvent)
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);
251 void FeedHoverEvent(Window window, const Dali::TouchPoint& point)
253 Integration::Point convertedPoint(point);
254 GetImplementation(window).FeedHoverEvent(convertedPoint);
257 void Maximize(Window window, bool maximize)
259 GetImplementation(window).Maximize(maximize);
262 bool IsMaximized(Window window)
264 return GetImplementation(window).IsMaximized();
267 void SetMaximumSize(Window window, Dali::Window::WindowSize size)
269 GetImplementation(window).SetMaximumSize(size);
272 void Minimize(Window window, bool miniimize)
274 GetImplementation(window).Minimize(miniimize);
277 bool IsMinimized(Window window)
279 return GetImplementation(window).IsMinimized();
282 void SetMimimumSize(Window window, Dali::Window::WindowSize size)
284 GetImplementation(window).SetMimimumSize(size);
287 bool IsWindowRotating(Window window)
289 return GetImplementation(window).IsWindowRotating();
292 const KeyEvent& GetLastKeyEvent(Window window)
294 return GetImplementation(window).GetLastKeyEvent();
297 const TouchEvent& GetLastTouchEvent(Window window)
299 return GetImplementation(window).GetLastTouchEvent();
302 bool PointerConstraintsLock(Window window)
304 return GetImplementation(window).PointerConstraintsLock();
307 bool PointerConstraintsUnlock(Window window)
309 return GetImplementation(window).PointerConstraintsUnlock();
312 void LockedPointerRegionSet(Window window, int32_t x, int32_t y, int32_t width, int32_t height)
314 GetImplementation(window).LockedPointerRegionSet(x, y, width, height);
317 void LockedPointerCursorPositionHintSet(Window window, int32_t x, int32_t y)
319 GetImplementation(window).LockedPointerCursorPositionHintSet(x, y);
322 bool PointerWarp(Window window, int32_t x, int32_t y)
324 return GetImplementation(window).PointerWarp(x, y);
327 void CursorVisibleSet(Window window, bool visible)
329 GetImplementation(window).CursorVisibleSet(visible);
332 bool KeyboardGrab(Window window, Device::Subclass::Type deviceSubclass)
334 return GetImplementation(window).KeyboardGrab(deviceSubclass);
337 bool KeyboardUnGrab(Window window)
339 return GetImplementation(window).KeyboardUnGrab();
342 InterceptKeyEventSignalType& InterceptKeyEventSignal(Window window)
344 return GetImplementation(window).InterceptKeyEventSignal();
347 MouseInOutEventSignalType& MouseInOutEventSignal(Window window)
349 return GetImplementation(window).MouseInOutEventSignal();
352 InsetsChangedSignalType& InsetsChangedSignal(Window window)
354 return GetImplementation(window).InsetsChangedSignal();
357 MouseRelativeEventSignalType& MouseRelativeEventSignal(Window window)
359 return GetImplementation(window).MouseRelativeEventSignal();
362 PointerConstraintsSignalType& PointerConstraintsSignal(Window window)
364 return GetImplementation(window).PointerConstraintsSignal();
367 } // namespace DevelWindow