/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
#include <thread>
// INTERNAL HEADERS
-#include <dali/devel-api/adaptor-framework/accessibility-impl.h>
+#include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
+#include <dali/devel-api/atspi-interfaces/accessible.h>
#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
#include <dali/internal/window-system/common/event-handler.h>
mIsFocusAcceptable(true),
mIconified(false),
mOpaqueState(false),
+ mWindowRotationAcknowledgement(false),
+ mFocused(false),
mParentWindow(NULL),
mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
mRotationAngle(0),
mResizeSignal(),
mVisibilityChangedSignal(),
mTransitionEffectEventSignal(),
- mKeyboardRepeatSettingsChangedSignal()
+ mKeyboardRepeatSettingsChangedSignal(),
+ mAuxiliaryMessageSignal()
{
}
Window::~Window()
{
- if(mAdaptor)
+ if(mScene)
{
- auto bridge = Accessibility::Bridge::GetCurrentBridge();
- auto rootLayer = mScene.GetRootLayer();
- auto accessible = Accessibility::Accessible::Get(rootLayer);
+ auto bridge = Accessibility::Bridge::GetCurrentBridge();
+ auto rootLayer = mScene.GetRootLayer();
+ auto accessible = Accessibility::Accessible::Get(rootLayer, true);
bridge->RemoveTopLevelWindow(accessible);
+ }
+ if(mAdaptor)
+ {
mAdaptor->RemoveWindow(this);
}
mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
+ mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
mEventHandler->AddObserver(*this);
- auto bridge = Accessibility::Bridge::GetCurrentBridge();
- auto rootLayer = mScene.GetRootLayer();
- auto accessible = Accessibility::Accessible::Get(rootLayer, true);
- bridge->AddTopLevelWindow(accessible);
+ // Add Window to bridge for ATSPI
+ auto bridge = Accessibility::Bridge::GetCurrentBridge();
+ if (bridge->IsUp())
+ {
+ auto rootLayer = mScene.GetRootLayer();
+ auto accessible = Accessibility::Accessible::Get(rootLayer, true);
+ bridge->AddTopLevelWindow(accessible);
+ }
+
+ bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
+ bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
// If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
// The show must be called after the adaptor is initialized.
DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
}
+void Window::Maximize(bool maximize)
+{
+ mWindowBase->Maximize(maximize);
+
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Maximize: %d\n", this, mNativeWindowId, maximize);
+}
+
+bool Window::IsMaximized() const
+{
+ return mWindowBase->IsMaximized();
+}
+
+void Window::Minimize(bool minimize)
+{
+ mWindowBase->Minimize(minimize);
+
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Minimize: %d\n", this, mNativeWindowId, minimize);
+}
+
+bool Window::IsMinimized() const
+{
+ return mWindowBase->IsMinimized();
+}
+
uint32_t Window::GetLayerCount() const
{
return mScene.GetLayerCount();
return mScene.GetRenderTaskList();
}
+std::string Window::GetNativeResourceId() const
+{
+ return mWindowBase->GetNativeWindowResourceId();
+}
+
void Window::AddAvailableOrientation(WindowOrientation orientation)
{
if(IsOrientationAvailable(orientation) == false)
if(!mIconified)
{
- WindowVisibilityObserver* observer(mAdaptor);
- observer->OnWindowShown();
-
Dali::Window handle(this);
mVisibilityChangedSignal.Emit(handle, true);
+ Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
+
+ WindowVisibilityObserver* observer(mAdaptor);
+ observer->OnWindowShown();
}
mSurface->SetFullSwapNextFrame();
if(!mIconified)
{
- WindowVisibilityObserver* observer(mAdaptor);
- observer->OnWindowHidden();
-
Dali::Window handle(this);
mVisibilityChangedSignal.Emit(handle, false);
+ Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
+
+ WindowVisibilityObserver* observer(mAdaptor);
+ observer->OnWindowHidden();
}
DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
void Window::SetInputRegion(const Rect<int>& inputRegion)
{
- mWindowBase->SetInputRegion(inputRegion);
+ Rect<int> convertRegion = RecalculateRect(inputRegion);
- DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetInputRegion: x = %d, y = %d, w = %d, h = %d\n", inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
+ DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window (%p), WinId (%d), SetInputRegion, RecalculateRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, convertRegion.x, convertRegion.y, convertRegion.width, convertRegion.height);
+
+ mWindowBase->SetInputRegion(convertRegion);
}
void Window::SetType(WindowType type)
if(mVisible)
{
- WindowVisibilityObserver* observer(mAdaptor);
- observer->OnWindowHidden();
-
Dali::Window handle(this);
mVisibilityChangedSignal.Emit(handle, false);
+ Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
+
+ WindowVisibilityObserver* observer(mAdaptor);
+ observer->OnWindowHidden();
}
DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
if(mVisible)
{
- WindowVisibilityObserver* observer(mAdaptor);
- observer->OnWindowShown();
-
Dali::Window handle(this);
mVisibilityChangedSignal.Emit(handle, true);
+ Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
+
+ WindowVisibilityObserver* observer(mAdaptor);
+ observer->OnWindowShown();
}
DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
{
if(focusIn)
{
- bridge->ApplicationShown();
+ bridge->WindowFocused(handle);
}
else
{
- bridge->ApplicationHidden();
+ bridge->WindowUnfocused(handle);
}
}
+ mFocused = focusIn;
}
void Window::OnOutputTransformed()
void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
{
- SetPositionSize(positionSize);
+ PositionSize oldRect = mSurface->GetPositionSize();
+
+ mWindowSurface->UpdatePositionSize(positionSize);
+
+ PositionSize newRect = positionSize;
+
+ // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
+ if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
+ {
+ Uint16Pair newSize(newRect.width, newRect.height);
+
+ SurfaceResized();
+
+ mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
+
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Updated PositionSize by server :resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
+ Dali::Window handle(this);
+ mResizeSignal.Emit(handle, newSize);
+ mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
+ }
+
+ mSurface->SetFullSwapNextFrame();
+
+ Dali::Accessibility::Accessible::Get(mScene.GetRootLayer(), true)->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
}
void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
mSurface->SetFullSwapNextFrame();
}
+void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value, const Property::Array& options)
+{
+ mAuxiliaryMessageSignal.Emit(key, value, options);
+}
+
+void Window::OnAccessibilityEnabled()
+{
+ auto bridge = Accessibility::Bridge::GetCurrentBridge();
+ auto rootLayer = mScene.GetRootLayer();
+ auto accessible = Accessibility::Accessible::Get(rootLayer, true);
+ bridge->AddTopLevelWindow(accessible);
+
+ if(mFocused)
+ {
+ Dali::Window handle(this);
+ bridge->WindowFocused(handle);
+ }
+}
+
+void Window::OnAccessibilityDisabled()
+{
+ auto bridge = Accessibility::Bridge::GetCurrentBridge();
+ auto rootLayer = mScene.GetRootLayer();
+ auto accessible = Accessibility::Accessible::Get(rootLayer, true);
+ bridge->RemoveTopLevelWindow(accessible);
+}
+
void Window::RecalculateTouchPosition(Integration::Point& point)
{
Vector2 position = point.GetScreenPosition();
{
Dali::DevelWindow::Unparent(parent);
}
- mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase);
+ mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, false);
+ }
+}
+
+void Window::SetParent(Dali::Window& parent, bool belowParent)
+{
+ if(DALI_UNLIKELY(parent))
+ {
+ mParentWindow = parent;
+ Dali::Window self = Dali::Window(this);
+ // check circular parent window setting
+ if(Dali::DevelWindow::GetParent(parent) == self)
+ {
+ Dali::DevelWindow::Unparent(parent);
+ }
+ mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase, belowParent);
}
}
void Window::Unparent()
{
- mWindowBase->SetParent(nullptr);
+ mWindowBase->SetParent(nullptr, false);
mParentWindow.Reset();
}
mWindowBase->EnableFloatingMode(enable);
}
+Rect<int> Window::RecalculateRect(const Rect<int>& rect)
+{
+ Rect<int> newRect;
+ int screenWidth, screenHeight;
+
+ WindowSystem::GetScreenSize(screenWidth, screenHeight);
+
+ if(mRotationAngle == 90)
+ {
+ newRect.x = rect.y;
+ newRect.y = screenHeight - (rect.x + rect.width);
+ newRect.width = rect.height;
+ newRect.height = rect.width;
+ }
+ else if(mRotationAngle == 180)
+ {
+ newRect.x = screenWidth - (rect.x + rect.width);
+ newRect.y = screenHeight - (rect.y + rect.height);
+ newRect.width = rect.width;
+ newRect.height = rect.height;
+ }
+ else if(mRotationAngle == 270)
+ {
+ newRect.x = screenWidth - (rect.y + rect.height);
+ newRect.y = rect.x;
+ newRect.width = rect.height;
+ newRect.height = rect.width;
+ }
+ else
+ {
+ newRect.x = rect.x;
+ newRect.y = rect.y;
+ newRect.width = rect.width;
+ newRect.height = rect.height;
+ }
+ return newRect;
+}
+
+void Window::IncludeInputRegion(const Rect<int>& inputRegion)
+{
+ Rect<int> convertRegion = RecalculateRect(inputRegion);
+
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IncludeInputRegion, RecalculateRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, convertRegion.x, convertRegion.y, convertRegion.width, convertRegion.height);
+ mWindowBase->IncludeInputRegion(convertRegion);
+}
+
+void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
+{
+ Rect<int> convertRegion = RecalculateRect(inputRegion);
+
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), ExcludeInputRegion, RecalculateRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, convertRegion.x, convertRegion.y, convertRegion.width, convertRegion.height);
+ mWindowBase->ExcludeInputRegion(convertRegion);
+}
+
+void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
+{
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
+ mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
+ mWindowRotationAcknowledgement = needAcknowledgement;
+}
+
+void Window::SendRotationCompletedAcknowledgement()
+{
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
+ if(mWindowRotationAcknowledgement)
+ {
+ SetRotationCompletedAcknowledgement();
+ }
+}
+
} // namespace Adaptor
} // namespace Internal