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 void IncludeInputRegion(Window window, const Rect<int>& inputRegion)
210 GetImplementation(window).IncludeInputRegion(inputRegion);
213 void ExcludeInputRegion(Window window, const Rect<int>& inputRegion)
215 GetImplementation(window).ExcludeInputRegion(inputRegion);
218 void SetNeedsRotationCompletedAcknowledgement(Window window, bool needAcknowledgement)
220 GetImplementation(window).SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
223 void SendRotationCompletedAcknowledgement(Window window)
225 GetImplementation(window).SendRotationCompletedAcknowledgement();
228 void FeedTouchPoint(Window window, const Dali::TouchPoint& point, int32_t timeStamp)
230 Integration::Point convertedPoint(point);
231 GetImplementation(window).FeedTouchPoint(convertedPoint, timeStamp);
234 void FeedWheelEvent(Window window, const Dali::WheelEvent& wheelEvent)
236 Integration::WheelEvent convertedEvent(static_cast<Integration::WheelEvent::Type>(wheelEvent.GetType()), wheelEvent.GetDirection(), wheelEvent.GetModifiers(), wheelEvent.GetPoint(), wheelEvent.GetDelta(), wheelEvent.GetTime());
237 GetImplementation(window).FeedWheelEvent(convertedEvent);
240 void FeedKeyEvent(Window window, const Dali::KeyEvent& keyEvent)
242 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());
243 GetImplementation(window).FeedKeyEvent(convertedEvent);
246 void Maximize(Window window, bool maximize)
248 GetImplementation(window).Maximize(maximize);
251 bool IsMaximized(Window window)
253 return GetImplementation(window).IsMaximized();
256 void SetMaximumSize(Window window, Dali::Window::WindowSize size)
258 GetImplementation(window).SetMaximumSize(size);
261 void Minimize(Window window, bool miniimize)
263 GetImplementation(window).Minimize(miniimize);
266 bool IsMinimized(Window window)
268 return GetImplementation(window).IsMinimized();
271 void SetMimimumSize(Window window, Dali::Window::WindowSize size)
273 GetImplementation(window).SetMimimumSize(size);
276 bool IsWindowRotating(Window window)
278 return GetImplementation(window).IsWindowRotating();
281 const KeyEvent& GetLastKeyEvent(Window window)
283 return GetImplementation(window).GetLastKeyEvent();
286 const TouchEvent& GetLastTouchEvent(Window window)
288 return GetImplementation(window).GetLastTouchEvent();
291 InterceptKeyEventSignalType& InterceptKeyEventSignal(Window window)
293 return GetImplementation(window).InterceptKeyEventSignal();
296 MouseInOutEventSignalType& MouseInOutEventSignal(Window window)
298 return GetImplementation(window).MouseInOutEventSignal();
301 } // namespace DevelWindow