Merge "[Tizen][AT-SPI] Rework intercepting key events" into tizen
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-impl.h
index eb3aac6..af90626 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/object/property-array.h>
 #include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/render-tasks/render-task-list.h>
 
 // INTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/window-devel.h>
@@ -50,9 +49,11 @@ class WindowRenderSurface;
 class WindowBase;
 
 class Window;
-using WindowPtr       = IntrusivePtr<Window>;
-using OrientationPtr  = IntrusivePtr<Orientation>;
-using EventHandlerPtr = IntrusivePtr<EventHandler>;
+using WindowPtr             = IntrusivePtr<Window>;
+using OrientationPtr        = IntrusivePtr<Orientation>;
+using MouseInOutEventPtr    = IntrusivePtr<Dali::DevelWindow::MouseInOutEvent>;
+using MouseRelativeEventPtr = IntrusivePtr<Dali::DevelWindow::MouseRelativeEvent>;
+using EventHandlerPtr       = IntrusivePtr<EventHandler>;
 
 /**
  * Window provides a surface to render onto with orientation & indicator properties.
@@ -68,30 +69,35 @@ public:
   typedef Dali::DevelWindow::AuxiliaryMessageSignalType              AuxiliaryMessageSignalType;
   typedef Dali::DevelWindow::AccessibilityHighlightSignalType        AccessibilityHighlightSignalType;
   typedef Dali::DevelWindow::MovedSignalType                         MovedSignalType;
+  typedef Dali::DevelWindow::OrientationChangedSignalType            OrientationChangedSignalType;
+  typedef Dali::DevelWindow::MouseInOutEventSignalType               MouseInOutEventSignalType;
+  typedef Dali::DevelWindow::MouseRelativeEventSignalType            MouseRelativeEventSignalType;
+  typedef Dali::DevelWindow::MoveCompletedSignalType                 MoveCompletedSignalType;
+  typedef Dali::DevelWindow::ResizeCompletedSignalType               ResizeCompletedSignalType;
+  typedef Dali::DevelWindow::InsetsChangedSignalType                 InsetsChangedSignalType;
+  typedef Dali::DevelWindow::PointerConstraintsSignalType            PointerConstraintsSignalType;
   typedef Signal<void()>                                             SignalType;
 
   /**
    * @brief Create a new Window. This should only be called once by the Application class
-   * @param[in] positionSize The position and size of the window
+   *
    * @param[in] name The window title
    * @param[in] className The window class name
-   * @param[in] type Window type.
-   * @param[in] isTransparent Whether window is transparent
+   * @param[in] windowData The window data
    * @return A newly allocated Window
    */
-  static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent = false);
+  static Window* New(const std::string& name, const std::string& className, const WindowData& windowData);
 
   /**
    * @brief Create a new Window. This should only be called once by the Application class
+   *
    * @param[in] surface The surface used to render on.
-   * @param[in] positionSize The position and size of the window
    * @param[in] name The window title
    * @param[in] className The window class name
-   * @param[in] type Window type.
-   * @param[in] isTransparent Whether window is transparent
+   * @param[in] windowData The window data
    * @return A newly allocated Window
    */
-  static Window* New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent = false);
+  static Window* New(Any surface, const std::string& name, const std::string& className, const WindowData& windowData);
 
   /**
    * @copydoc Dali::Window::SetClass()
@@ -100,6 +106,7 @@ public:
 
   /**
    * @brief Gets the window class name.
+   *
    * @return The class of the window
    */
   std::string GetClassName() const;
@@ -160,12 +167,23 @@ public:
   Dali::Layer GetLayer(uint32_t depth) const;
 
   /**
-   * @copydoc Dali::DevelWindow::GetRenderTaskList()
+   * @copydoc Dali::Window::KeepRendering()
+   */
+  void KeepRendering(float durationSeconds);
+
+  /**
+   * @copydoc Dali::Window::SetPartialUpdateEnabled()
+   */
+  void SetPartialUpdateEnabled(bool enabled);
+
+  /**
+   * @copydoc Dali::Window::IsPartialUpdateEnabled()
    */
-  Dali::RenderTaskList GetRenderTaskList() const;
+  bool IsPartialUpdateEnabled() const;
 
   /**
    * @brief Get window resource ID assigned by window manager
+   *
    * @return The resource ID of the window
    */
   std::string GetNativeResourceId() const;
@@ -331,6 +349,11 @@ public:
   PositionSize GetPositionSize() const;
 
   /**
+   * @copydoc Dali::Window::SetLayout()
+   */
+  void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan);
+
+  /**
    * @copydoc Dali::Window::GetRootLayer()
    */
   Dali::Layer GetRootLayer() const;
@@ -407,6 +430,7 @@ public:
 
   /**
    * @brief Emit the accessibility highlight signal.
+   *
    * The highlight indicates that it is an object to interact with the user regardless of focus.
    * After setting the highlight on the object, you can do things that the object can do, such as
    * giving or losing focus.
@@ -415,6 +439,13 @@ public:
    */
   void EmitAccessibilityHighlightSignal(bool highlight);
 
+  /**
+   * @brief Sets the render notification trigger to call when render thread is completed a frame
+   *
+   * @param[in] renderNotification to use
+   */
+  void SetRenderNotification(TriggerEventInterface* renderNotification);
+
 public: // Dali::Internal::Adaptor::SceneHolder
   /**
    * @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle
@@ -447,6 +478,11 @@ public: // Dali::Internal::Adaptor::SceneHolder
   void EnableFloatingMode(bool enable);
 
   /**
+   * @copydoc Dali::DevelWindow::IsFloatingModeEnabled()
+   */
+  bool IsFloatingModeEnabled();
+
+  /**
    * @copydoc Dali::DevelWindow::IncludeInputRegion()
    */
   void IncludeInputRegion(const Rect<int>& inputRegion);
@@ -477,13 +513,69 @@ public: // Dali::Internal::Adaptor::SceneHolder
   const Dali::KeyEvent& GetLastKeyEvent() const;
 
   /**
-   * @copydoc Dali::DevelWindow::GetLastTouchEvent()
+   * @copydoc Dali::DevelWindow::PointerConstraintsLock()
+   */
+  bool PointerConstraintsLock();
+
+  /**
+   * @copydoc Dali::DevelWindow::PointerConstraintsUnlock()
+   */
+  bool PointerConstraintsUnlock();
+
+  /**
+   * @copydoc Dali::DevelWindow::LockedPointerRegionSet()
+   */
+  void LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height);
+
+  /**
+   * @copydoc Dali::DevelWindow::LockedPointerCursorPositionHintSet()
+   */
+  void LockedPointerCursorPositionHintSet(int32_t x, int32_t y);
+
+  /**
+   * @copydoc Dali::DevelWindow::PointerWarp()
    */
-  const Dali::TouchEvent& GetLastTouchEvent() const;
+  bool PointerWarp(int32_t x, int32_t y);
+
+  /**
+   * @copydoc Dali::DevelWindow::CursorVisibleSet()
+   */
+  void CursorVisibleSet(bool visible);
+
+  /**
+   * @copydoc Dali::DevelWindow::KeyboardGrab()
+   */
+  bool KeyboardGrab(Device::Subclass::Type deviceSubclass);
+
+  /**
+   * @copydoc Dali::DevelWindow::KeyboardUnGrab()
+   */
+  bool KeyboardUnGrab();
+
+  /**
+   * @copydoc Dali::DevelWindow::SetFullScreen()
+   */
+  void SetFullScreen(bool fullscreen);
+
+  /**
+   * @copydoc Dali::DevelWindow::GetFullScreen()
+   */
+  bool GetFullScreen();
+
+  /**
+   * @copydoc Dali::DevelWindow::SetFrontBufferRendering()
+   */
+  void SetFrontBufferRendering(bool enable);
+
+  /**
+   * @copydoc Dali::DevelWindow::GetFrontBufferRendering()
+   */
+  bool GetFrontBufferRendering();
 
 private:
   /**
    * @brief Enumeration for orietation mode.
+   *
    * The Orientation Mode is related to screen size.
    * If screen width is longer than height, the Orientation Mode will have LANDSCAPE.
    * Otherwise screen width is shorter than height or same, the Orientation Mode will have PORTRAIT.
@@ -506,32 +598,54 @@ private:
   ~Window() override;
 
   /**
-   * Second stage initialization
+   * @brief Second stage initialization
+   *
+   * @param[in] surface The surface used to render on.
+   * @param[in] positionSize The window's position and size in initailized time.
+   * @param[in] name The window title
+   * @param[in] className The window class name
+   * @param[in] type window's type. Refer the WindowType in window-enumerations.h.
    */
   void Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, WindowType type);
 
   /**
-   * Called when the window becomes iconified or deiconified.
+   * @brief Called when the window becomes iconified or deiconified.
+   *
+   * @param[in] iconified true If the window is iconified, othewise false.
    */
   void OnIconifyChanged(bool iconified);
 
   /**
-   * Called when the window focus is changed.
+   * @brief Called when the window becomes maximized or unmaximized.
+   *
+   * @param[in] maximized true If the window is maximized, othewise false.
+   */
+  void OnMaximizeChanged(bool maximized);
+
+  /**
+   * @brief Called when the window focus is changed.
+   *
+   * @param[in] focusIn true If the window is focused, othewise false.
    */
   void OnFocusChanged(bool focusIn);
 
   /**
-   * Called when the output is transformed.
+   * @brief Called when the output is transformed.
    */
   void OnOutputTransformed();
 
   /**
-   * Called when the window receives a delete request.
+   * @brief Called when the window receives a delete request.
    */
   void OnDeleteRequest();
 
   /**
-   * Called when the window receives a Transition effect-start/end event.
+   * @brief Called when the window receives a Transition effect-start/end event.
+   *
+   * This event is emitted by display server.
+   *
+   * @param[in] state current window transition effect state, refer the WindowEffectState in window-enumerations.h.
+   * @param[in] type current window transition effect type, refer the WindowEffectType in window-enumerations.h.
    */
   void OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type);
 
@@ -546,7 +660,8 @@ private:
   void OnWindowRedrawRequest();
 
   /**
-   * @brief Called when the window is resized or moved by display server.
+   * @brief Called when the window's geometry data is changed by display server or client.
+   * It is based on configure noification event.
    *
    * @param[in] positionSize the updated window's position and size.
    */
@@ -576,13 +691,58 @@ private:
   void OnAccessibilityDisabled();
 
   /**
-   * Called when the window rotation is finished.
+   * @brief Called in Accessibility mode on every KeyEvent
+   *
+   * @param[in] keyEvent The key event
+   * @return Always true, meaning that the event is consumed
+   */
+  bool OnAccessibilityInterceptKeyEvent(const Dali::KeyEvent& keyEvent);
+
+  /**
+   * @brief Called when the window rotation is finished.
    *
    * This signal is emmit when window rotation is finisehd and WindowRotationCompleted() is called.
    */
   void OnRotationFinished();
 
   /**
+   * @brief Called when the mouse in or out event is received.
+   *
+   * @param[in] mouseInOutEvent the mouse event
+   */
+  void OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent);
+
+  /**
+   * @brief Called when the mouse relative event is received.
+   *
+   * @param[in] mouseRelativeEvent the mouse event
+   */
+  void OnMouseRelativeEvent(const Dali::DevelWindow::MouseRelativeEvent& mouseRelativeEvent);
+
+  /**
+   * @brief Called when the pointer is locked/unlocked
+   *
+   * @param[in] position The x, y coordinate relative to window where event happened
+   * @param[in] locked The status whether pointer is locked/unlocked
+   * @param[in] confined The status whether pointer is confined/unconfined
+   */
+  void OnPointerConstraints(const Dali::Int32Pair& position, bool locked, bool confined);
+
+  /**
+   * @brief Called when the window is moved by display server.
+   *
+   * @param[in] position the moved window's position.
+   */
+  void OnMoveCompleted(Dali::Window::WindowPosition& position);
+
+  /**
+   * @brief Called when the window is resized by display server.
+   *
+   * @param[in] positionSize the resized window's size.
+   */
+  void OnResizeCompleted(Dali::Window::WindowSize& size);
+
+  /**
    * @brief Set available orientation to window base.
    */
   void SetAvailableAnlges(const std::vector<int>& angles);
@@ -603,18 +763,22 @@ private:
   bool IsOrientationAvailable(WindowOrientation orientation) const;
 
   /**
-   * @brief Return the rect value to recalulate with the default system coordinates.
+   * @brief Sets user geometry flag when window's geometry is changed.
    *
-   * Some native window APIs work the geometry value based on the default system coordinates.
-   * IncludeInputRegion() and ExcludeInputRegion() are one of them.
-   * When the window is rotated, current window's geometry already were set with the rotated angle.
-   * If IncludeInputRegion() or ExcludeInputRegion() are called with rotated angle by application,
-   * the rect's area should be re-calcuated on the default system coordinates.
+   * Window is created with screen size or not.
+   * If window is created with screen size or the geometry is changed by user,
+   * client should inform to server setting user.geometry flag
+   */
+  void SetUserGeometryPolicy();
+
+  /**
+   * @brief Called when window insets are changed by appearing or disappearing indicator, virtual keyboard, or clipboard.
    *
-   * @param[in] rect the window's current position and size with current window rotation angle.
-   * @return the re-calculated rect on the default system coordinates.
+   * @param[in] partType the type of the part that occurs the window insets change.
+   * @param[in] partState the state of the part that occurs the window insets change.
+   * @param[in] insets the extents value of window insets.
    */
-  Rect<int> RecalculateRect(const Rect<int>& rect);
+  void OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets);
 
 private: // Dali::Internal::Adaptor::SceneHolder
   /**
@@ -638,9 +802,9 @@ private: // Dali::Internal::Adaptor::SceneHolder
   void OnResume() override;
 
   /**
-   * @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculateTouchPosition
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculatePosition
    */
-  void RecalculateTouchPosition(Integration::Point& point) override;
+  Vector2 RecalculatePosition(const Vector2& position) override;
 
 private: // Dali::Internal::Adaptor::EventHandler::Observer
   /**
@@ -681,7 +845,9 @@ public: // Signals
   }
 
   /**
-   * This signal is emitted when the window is requesting to be deleted
+   * @brief This signal is emitted when the window is requesting to be deleted
+   *
+   * It is internal signal in Dali-adaptor.
    */
   SignalType& DeleteRequestSignal()
   {
@@ -744,6 +910,62 @@ public: // Signals
     return mMovedSignal;
   }
 
+  /**
+   * @copydoc Dali::DevelWindow::OrientationChangedSignal()
+   */
+  OrientationChangedSignalType& OrientationChangedSignal()
+  {
+    return mOrientationChangedSignal;
+  }
+
+  /**
+   * @copydoc Dali::DevelWindow::MouseInOutEventSignal()
+   */
+  MouseInOutEventSignalType& MouseInOutEventSignal()
+  {
+    return mMouseInOutEventSignal;
+  }
+
+  /**
+   * @copydoc Dali::DevelWindow::MouseRelativeEventSignal()
+   */
+  MouseRelativeEventSignalType& MouseRelativeEventSignal()
+  {
+    return mMouseRelativeEventSignal;
+  }
+
+  /**
+   * @copydoc Dali::DevelWindow::PointerConstraintsSignal()
+   */
+  PointerConstraintsSignalType& PointerConstraintsSignal()
+  {
+    return mPointerConstraintsSignal;
+  }
+
+  /**
+   * @copydoc Dali::DevelWindow::MoveCompletedSignal()
+   */
+  MoveCompletedSignalType& MoveCompletedSignal()
+  {
+    return mMoveCompletedSignal;
+  }
+
+  /**
+   * @copydoc Dali::DevelWindow::ResizeCompletedSignal()
+   */
+  ResizeCompletedSignalType& ResizeCompletedSignal()
+  {
+    return mResizeCompletedSignal;
+  }
+
+  /**
+   * @copydoc Dali::DevelWindow::InsetsChangedSignal()
+   */
+  InsetsChangedSignalType& InsetsChangedSignal()
+  {
+    return mInsetsChangedSignal;
+  }
+
 private:
   WindowRenderSurface* mWindowSurface; ///< The window rendering surface
   WindowBase*          mWindowBase;
@@ -773,17 +995,27 @@ private:
   AuxiliaryMessageSignalType              mAuxiliaryMessageSignal;
   AccessibilityHighlightSignalType        mAccessibilityHighlightSignal;
   MovedSignalType                         mMovedSignal;
+  OrientationChangedSignalType            mOrientationChangedSignal;
+  MouseInOutEventSignalType               mMouseInOutEventSignal;
+  MouseRelativeEventSignalType            mMouseRelativeEventSignal;
+  MoveCompletedSignalType                 mMoveCompletedSignal;
+  ResizeCompletedSignalType               mResizeCompletedSignal;
+  InsetsChangedSignalType                 mInsetsChangedSignal;
+  PointerConstraintsSignalType            mPointerConstraintsSignal;
 
-  Dali::KeyEvent   mLastKeyEvent;
-  Dali::TouchEvent mLastTouchEvent;
+  Dali::KeyEvent mLastKeyEvent;
 
   bool mIsTransparent : 1;
   bool mIsFocusAcceptable : 1;
   bool mIconified : 1;
+  bool mMaximized : 1;
   bool mOpaqueState : 1;
   bool mWindowRotationAcknowledgement : 1;
   bool mFocused : 1;
-  bool mIsWindowRotating : 1; ///< The window rotating flag.
+  bool mIsWindowRotating : 1;      ///< The window rotating flag.
+  bool mIsEnabledUserGeometry : 1; ///< The user geometry enable flag.
+  bool mIsEmittedWindowCreatedEvent : 1; ///< The Window Created Event emit flag for accessibility.
+  bool mIsFrontBufferRendering : 1;      ///< The Front Buffer Rendering state.
 };
 
 } // namespace Adaptor