1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/integration-api/events/key-event-integ.h>
23 #include <dali/integration-api/events/point.h>
24 #include <dali/integration-api/events/wheel-event-integ.h>
30 #include <dali/devel-api/adaptor-framework/mouse-in-out-event.h>
31 #include <dali/devel-api/adaptor-framework/window-devel.h>
32 #include <dali/internal/graphics/gles/egl-implementation.h>
33 #include <dali/internal/window-system/common/damage-observer.h>
34 #include <dali/internal/window-system/common/rotation-event.h>
35 #include <dali/public-api/adaptor-framework/key-grab.h>
36 #include <dali/public-api/adaptor-framework/style-change.h>
37 #include <dali/public-api/adaptor-framework/window-enumerations.h>
38 #include <dali/public-api/adaptor-framework/window.h>
47 * WindowBase interface
53 * @brief Struct used to retrieve accessibility information
55 struct AccessibilityInfo
67 typedef Signal<void(bool)> IconifySignalType;
68 typedef Signal<void(bool)> MaximizeSignalType;
69 typedef Signal<void(bool)> FocusSignalType;
70 typedef Signal<void()> OutputSignalType;
71 typedef Signal<void()> DeleteSignalType;
72 typedef Signal<void(const DamageArea&)> DamageSignalType;
73 typedef Signal<void(const RotationEvent&)> RotationSignalType;
74 typedef Signal<void(WindowEffectState, WindowEffectType)> TransitionEffectEventSignalType;
75 typedef Signal<void()> KeyboardRepeatSettingsChangedSignalType;
76 typedef Signal<void()> WindowRedrawRequestSignalType;
77 typedef Signal<void(Dali::PositionSize&)> UpdatePositionSizeType;
78 typedef Signal<void(const std::string&, const std::string&, const Property::Array&)> AuxiliaryMessageSignalType;
79 typedef Signal<void(const Dali::DevelWindow::MouseInOutEvent&)> MouseInOutEventSignalType;
80 typedef Signal<void(const Dali::DevelWindow::MouseRelativeEvent&)> MouseRelativeEventSignalType;
81 typedef Signal<void(Dali::Int32Pair&)> MoveCompletedSignalType;
82 typedef Signal<void(Dali::Uint16Pair&)> ResizeCompletedSignalType;
83 typedef Signal<void(WindowInsetsPartType, WindowInsetsPartState, const Extents&)> InsetsChangedSignalType;
84 typedef Signal<void(const Dali::Int32Pair&, bool, bool)> PointerConstraintsSignalType;
87 typedef Signal<void(Integration::Point&, uint32_t)> TouchEventSignalType;
88 typedef Signal<void(Integration::WheelEvent&)> WheelEventSignalType;
89 typedef Signal<void(Integration::KeyEvent&)> KeyEventSignalType;
92 typedef Signal<void(void*)> SelectionSignalType;
95 typedef Signal<void(StyleChange::Type)> StyleSignalType;
98 * @brief Default constructor
105 virtual ~WindowBase();
109 * @brief Get the native window handle
110 * @return The native window handle
112 virtual Any GetNativeWindow() = 0;
115 * @brief Get the native window id
116 * @return The native window id
118 virtual int GetNativeWindowId() = 0;
121 * @brief Get the native window resource id assinged by window manager
122 * @return The native window resource id
124 virtual std::string GetNativeWindowResourceId() = 0;
127 * @brief Create the egl window
129 virtual EGLNativeWindowType CreateEglWindow(int width, int height) = 0;
132 * @brief Destroy the egl window
134 virtual void DestroyEglWindow() = 0;
137 * @brief Set the egl window rotation
139 virtual void SetEglWindowRotation(int angle) = 0;
142 * @brief Set the egl window buffer transform
144 virtual void SetEglWindowBufferTransform(int angle) = 0;
147 * @brief Set the egl window transform
149 virtual void SetEglWindowTransform(int angle) = 0;
152 * @brief Resize the egl window
154 virtual void ResizeEglWindow(Dali::PositionSize positionSize) = 0;
157 * @brief Returns whether the egl window support rotation or not
159 virtual bool IsEglWindowRotationSupported() = 0;
162 * @brief Move the window
164 virtual void Move(Dali::PositionSize positionSize) = 0;
167 * @brief Resize the window
169 virtual void Resize(Dali::PositionSize positionSize) = 0;
172 * @brief Move and resize the window
174 virtual void MoveResize(Dali::PositionSize positionSize) = 0;
177 * @copydoc Dali::Window::SetLayout()
179 virtual void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) = 0;
182 * @copydoc Dali::Window::SetClass()
184 virtual void SetClass(const std::string& name, const std::string& className) = 0;
187 * @copydoc Dali::Window::Raise()
189 virtual void Raise() = 0;
192 * @copydoc Dali::Window::Lower()
194 virtual void Lower() = 0;
197 * @copydoc Dali::Window::Activate()
199 virtual void Activate() = 0;
202 * @copydoc Dali::DevelWindow::Maximize()
204 virtual void Maximize(bool maximize) = 0;
207 * @copydoc Dali::DevelWindow::IsMaximized()
209 virtual bool IsMaximized() const = 0;
212 * @copydoc Dali::DevelWindow::SetMaximumSize()
214 virtual void SetMaximumSize(Dali::Window::WindowSize size) = 0;
217 * @copydoc Dali::DevelWindow::Minimize()
219 virtual void Minimize(bool minimize) = 0;
222 * @copydoc Dali::DevelWindow::IsMinimized()
224 virtual bool IsMinimized() const = 0;
227 * @copydoc Dali::DevelWindow::SetMimimumSize()
229 virtual void SetMimimumSize(Dali::Window::WindowSize size) = 0;
232 * @copydoc Dali::Window::SetAvailableOrientations()
234 virtual void SetAvailableAnlges(const std::vector<int>& angles) = 0;
237 * @copydoc Dali::Window::SetPreferredOrientation()
239 virtual void SetPreferredAngle(int angle) = 0;
242 * @copydoc Dali::Window::SetAcceptFocus()
244 virtual void SetAcceptFocus(bool accept) = 0;
247 * @copydoc Dali::Window::Show()
249 virtual void Show() = 0;
252 * @copydoc Dali::Window::Hide()
254 virtual void Hide() = 0;
257 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
259 virtual unsigned int GetSupportedAuxiliaryHintCount() const = 0;
262 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
264 virtual std::string GetSupportedAuxiliaryHint(unsigned int index) const = 0;
267 * @copydoc Dali::Window::AddAuxiliaryHint()
269 virtual unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) = 0;
272 * @copydoc Dali::Window::RemoveAuxiliaryHint()
274 virtual bool RemoveAuxiliaryHint(unsigned int id) = 0;
277 * @copydoc Dali::Window::SetAuxiliaryHintValue()
279 virtual bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) = 0;
282 * @copydoc Dali::Window::GetAuxiliaryHintValue()
284 virtual std::string GetAuxiliaryHintValue(unsigned int id) const = 0;
287 * @copydoc Dali::Window::GetAuxiliaryHintId()
289 virtual unsigned int GetAuxiliaryHintId(const std::string& hint) const = 0;
292 * @copydoc Dali::Window::SetInputRegion()
294 virtual void SetInputRegion(const Rect<int>& inputRegion) = 0;
297 * @copydoc Dali::Window::SetType()
299 virtual void SetType(Dali::WindowType type) = 0;
302 * @copydoc Dali::Window::GetType()
304 virtual Dali::WindowType GetType() const = 0;
307 * @copydoc Dali::Window::SetNotificationLevel()
309 virtual Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) = 0;
312 * @copydoc Dali::Window::GetNotificationLevel()
314 virtual Dali::WindowNotificationLevel GetNotificationLevel() const = 0;
317 * @copydoc Dali::Window::SetOpaqueState()
319 virtual void SetOpaqueState(bool opaque) = 0;
322 * @copydoc Dali::Window::SetScreenOffMode()
324 virtual Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) = 0;
327 * @copydoc Dali::Window::GetScreenOffMode()
329 virtual WindowScreenOffMode GetScreenOffMode() const = 0;
332 * @copydoc Dali::Window::SetBrightness()
334 virtual Dali::WindowOperationResult SetBrightness(int brightness) = 0;
337 * @copydoc Dali::Window::GetBrightness()
339 virtual int GetBrightness() const = 0;
342 * @copydoc Dali::KeyGrab::GrabKey()
344 virtual bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) = 0;
347 * @copydoc Dali::KeyGrab::UngrabKey()
349 virtual bool UngrabKey(Dali::KEY key) = 0;
352 * @copydoc Dali::KeyGrab::GrabKeyList()
354 virtual bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) = 0;
357 * @copydoc Dali::KeyGrab::UngrabKeyList()
359 virtual bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) = 0;
363 * @param[out] dpiHorizontal set to the horizontal dpi
364 * @param[out] dpiVertical set to the vertical dpi
366 virtual void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) = 0;
369 * @brief Return the angle of the window's rotation.
370 * @return The window orientation
372 virtual int GetWindowRotationAngle() const = 0;
375 * @brief Get the angle of screen rotation for the window
376 * @return The screen orientation
378 virtual int GetScreenRotationAngle() = 0;
381 * @brief Set the screen rotation angle of the window
383 virtual void SetWindowRotationAngle(int degree) = 0;
386 * @brief Inform the window rotation is completed
388 virtual void WindowRotationCompleted(int degree, int width, int height) = 0;
391 * @brief starts the window is moved by display server
393 virtual void RequestMoveToServer() = 0;
396 * @brief starts the window is resized by display server
398 * @param[in] direction It is direction of the started edge/side.
400 virtual void RequestResizeToServer(WindowResizeDirection direction) = 0;
403 * @brief Enables the floating mode of window.
405 * The floating mode is to support making partial size window easliy.
406 * It is useful to make popup style window
407 * and this window is always upper than the other normal window.
409 * A special display server(as a Tizen display server) supports this mode.
411 * @param[in] enable Enable floating mode or not.
413 virtual void EnableFloatingMode(bool enable) = 0;
416 * @brief Gets whether floating mode is enabled or not.
418 virtual bool IsFloatingModeEnabled() const = 0;
421 * @copydoc Dali::Window::SetTransparency()
423 virtual void SetTransparency(bool transparent) = 0;
426 * @copydoc Dali::Window::SetParent()
428 virtual void SetParent(WindowBase* parentWinBase, bool belowParent) = 0;
431 * @brief Create a sync fence that can tell the frame is rendered by the graphics driver.
432 * @return The file descriptor that tells when it is rendered.
434 virtual int CreateFrameRenderedSyncFence() = 0;
437 * @brief Create a sync fence that can tell the frame is presented by the display server.
438 * @return The file descriptor that tells when it is presented.
440 virtual int CreateFramePresentedSyncFence() = 0;
443 * @copydoc Dali::Window::SetPositionSizeWithAngle()
445 virtual void SetPositionSizeWithAngle(PositionSize positionSize, int angle) = 0;
448 * @brief Initialize for Ime window.
449 * It should be called when the window is only used for Ime keyboard window.
451 virtual void InitializeIme() = 0;
454 * @brief Send the signal to display server for Ime Window is ready to render.
455 * It is used for compositing by display server.
457 virtual void ImeWindowReadyToRender() = 0;
460 * @brief Includes input region.
461 * @param[in] inputRegion The added region to accept input events.
463 virtual void IncludeInputRegion(const Rect<int>& inputRegion) = 0;
466 * @brief Excludes input region.
467 * @param[in] inputRegion The subtracted region to except input events.
469 virtual void ExcludeInputRegion(const Rect<int>& inputRegion) = 0;
472 * @brief Sets the pointer constraints lock.
473 * @return Returns true if PointerConstraintsLock succeeds.
475 virtual bool PointerConstraintsLock() = 0;
478 * @brief Sets the pointer constraints unlock.
479 * @return Returns true if PointerConstraintsUnlock succeeds.
481 virtual bool PointerConstraintsUnlock() = 0;
484 * @brief Sets the locked pointer region
486 * @param[in] x The x position.
487 * @param[in] y The y position.
488 * @param[in] width The width.
489 * @param[in] height The height
491 virtual void LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height) = 0;
494 * @brief Sets the locked pointer cursor position hintset
496 * @param[in] x The x position.
497 * @param[in] y The y position.
499 virtual void LockedPointerCursorPositionHintSet(int32_t x, int32_t y) = 0;
502 * @brief Sets the pointer warp. The pointer moves to the set coordinates.
504 * @param[in] x The x position.
505 * @param[in] y The y position.
506 * @return Returns true if PointerWarp succeeds.
508 virtual bool PointerWarp(int32_t x, int32_t y) = 0;
511 * @brief Sets visibility on/off of cursor
513 * @param[in] visible The visibility of cursor
515 virtual void CursorVisibleSet(bool visible) = 0;
518 * @brief Requests grab key events according to the requested device subtype
520 * @param[in] deviceSubclass The deviceSubclass type.
521 * @return Returns true if KeyboardGrab succeeds.
523 virtual bool KeyboardGrab(Device::Subclass::Type deviceSubclass) = 0;
526 * @brief Requests ungrab key events
528 * @param[in] window The window instance.
529 * @return Returns true if KeyboardUnGrab succeeds.
531 virtual bool KeyboardUnGrab() = 0;
534 * @brief Sets full screen sized window.
535 * If full screen size is set for the window,
536 * window will be resized with full screen size.
537 * In addition, the full screen sized window's z-order is the highest.
539 * @param[in] fullscreen true to set fullscreen, false to unset.
541 virtual void SetFullScreen(bool fullscreen) = 0;
544 * @brief Gets whether the full screen sized window or not
546 * @return Returns true if the full screen sized window is.
548 virtual bool GetFullScreen() = 0;
551 * @brief Enables or disables front buffer rendering.
552 * @param[in] enable true to enable front buffer rendering, false to disable.
554 virtual void SetFrontBufferRendering(bool enable) = 0;
557 * @brief Enables or disables front buffer rendering.
558 * @return Returns whether front buffer rendering has been enabled or not.
560 virtual bool GetFrontBufferRendering() = 0;
563 * @brief Sets front buffer rendering to the egl window.
564 * @param[in] enable True to enable front buffer rendering mode, False to otherwise.
566 virtual void SetEglWindowFrontBufferMode(bool enable) = 0;
571 * @brief This signal is emitted when the window becomes iconified or deiconified.
573 IconifySignalType& IconifyChangedSignal();
576 * @brief This signal is emitted when the window becomes maximized or unmaximized.
578 MaximizeSignalType& MaximizeChangedSignal();
581 * @brief This signal is emitted when the window focus is changed.
583 FocusSignalType& FocusChangedSignal();
586 * @brief This signal is emitted when the output is transformed.
588 OutputSignalType& OutputTransformedSignal();
591 * @brief This signal is emitted when the window receives a delete request.
593 DeleteSignalType& DeleteRequestSignal();
596 * @brief This signal is emitted when the window is damaged.
598 DamageSignalType& WindowDamagedSignal();
601 * @brief This signal is emitted when a rotation event is recevied.
603 RotationSignalType& RotationSignal();
606 * @brief This signal is emitted when a touch event is received.
608 TouchEventSignalType& TouchEventSignal();
611 * @brief This signal is emitted when a mouse wheel is received.
613 WheelEventSignalType& WheelEventSignal();
616 * @brief This signal is emitted when a key event is received.
618 KeyEventSignalType& KeyEventSignal();
621 * @brief This signal is emitted when the source window notifies us the content in clipboard is selected.
623 SelectionSignalType& SelectionDataSendSignal();
626 * @brief This signal is emitted when the source window sends us about the selected content.
628 SelectionSignalType& SelectionDataReceivedSignal();
631 * @brief This signal is emitted when the style is changed.
633 StyleSignalType& StyleChangedSignal();
636 * @brief This signal is emitted when window's transition animation is started or ended.
638 TransitionEffectEventSignalType& TransitionEffectEventSignal();
641 * @brief This signal is emitted when the keyboard repeat is changed.
643 KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal();
646 * @brief This signal is emitted when the window redraw is requested.
648 WindowRedrawRequestSignalType& WindowRedrawRequestSignal();
651 * @brief This signal is emitted when the window's geometry data is changed by display server or client.
652 * It is based on configure noification event.
654 UpdatePositionSizeType& UpdatePositionSizeSignal();
657 * @brief This signal is emitted when the window is received the auxiliary message from display server.
659 AuxiliaryMessageSignalType& AuxiliaryMessageSignal();
662 * @brief This signal is emitted when a mouse in or out event is recevied.
664 MouseInOutEventSignalType& MouseInOutEventSignal();
667 * @brief This signal is emitted when a mouse relative event is recevied.
669 MouseRelativeEventSignalType& MouseRelativeEventSignal();
672 * @brief This signal is emitted when window has been moved by then display server.
673 * To be moved the window by display server, RequestMoveToServer() should be called.
674 * After the moving job is finished, this function will be called.
676 MoveCompletedSignalType& MoveCompletedSignal();
679 * @brief This signal is emitted when window has been resized by then display server.
680 * To be resized the window by display server, RequestResizeToServer() should be called.
681 * After the resizing job is finished, this function will be called.
683 ResizeCompletedSignalType& ResizeCompletedSignal();
686 * @brief This signal is emitted when window insets are changed by appearing or disappearing indicator, virtual keyboard, or clipboard.
688 InsetsChangedSignalType& InsetsChangedSignal();
691 * @brief This signal is emitted when window pointer is locked/unlocked
693 PointerConstraintsSignalType& PointerConstraintsSignal();
697 WindowBase(const WindowBase&) = delete;
700 WindowBase& operator=(const WindowBase& rhs) = delete;
703 IconifySignalType mIconifyChangedSignal;
704 MaximizeSignalType mMaximizeChangedSignal;
705 FocusSignalType mFocusChangedSignal;
706 OutputSignalType mOutputTransformedSignal;
707 DeleteSignalType mDeleteRequestSignal;
708 DamageSignalType mWindowDamagedSignal;
709 RotationSignalType mRotationSignal;
710 TouchEventSignalType mTouchEventSignal;
711 WheelEventSignalType mWheelEventSignal;
712 KeyEventSignalType mKeyEventSignal;
713 SelectionSignalType mSelectionDataSendSignal;
714 SelectionSignalType mSelectionDataReceivedSignal;
715 StyleSignalType mStyleChangedSignal;
716 TransitionEffectEventSignalType mTransitionEffectEventSignal;
717 KeyboardRepeatSettingsChangedSignalType mKeyboardRepeatSettingsChangedSignal;
718 WindowRedrawRequestSignalType mWindowRedrawRequestSignal;
719 UpdatePositionSizeType mUpdatePositionSizeSignal;
720 AuxiliaryMessageSignalType mAuxiliaryMessageSignal;
721 MouseInOutEventSignalType mMouseInOutEventSignal;
722 MouseRelativeEventSignalType mMouseRelativeEventSignal;
723 MoveCompletedSignalType mMoveCompletedSignal;
724 ResizeCompletedSignalType mResizeCompletedSignal;
725 InsetsChangedSignalType mInsetsChangedSignal;
726 PointerConstraintsSignalType mPointerConstraintsSignal;
729 } // namespace Adaptor
731 } // namespace Internal
735 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H