From 0920c72aa60b45355f9e10257c3364c67b7f308a Mon Sep 17 00:00:00 2001 From: Choi Munseok Date: Fri, 7 Jun 2013 17:28:39 +0900 Subject: [PATCH] Fix the mini mode app when the alignment button is pressed Change-Id: I085a279b304bf9b330d3597266adef1d296d6a54 Signed-off-by: Choi Munseok --- src/ui/FUi_EcoreEvas.cpp | 148 ++++++++++++++++++++++++++++++++++++++ src/ui/controls/FUiCtrl_Frame.cpp | 11 +++ src/ui/inc/FUiCtrl_Frame.h | 4 ++ src/ui/inc/FUi_EcoreEvas.h | 1 + 4 files changed, 164 insertions(+) diff --git a/src/ui/FUi_EcoreEvas.cpp b/src/ui/FUi_EcoreEvas.cpp index 89c44dc..3fbf51b 100644 --- a/src/ui/FUi_EcoreEvas.cpp +++ b/src/ui/FUi_EcoreEvas.cpp @@ -63,6 +63,7 @@ #include "FUiCtrl_ContextMenu.h" #include "FUiAnim_DisplayContextImpl.h" #include "FUiAnimDisplayContext.h" +#include "FUi_TouchManager.h" using namespace Tizen::Base; using namespace Tizen::Base::Runtime; @@ -334,6 +335,137 @@ CATCH: return EINA_FALSE; } +int frameX = 0; +int frameY = 0; +int frameW = 0; +int frameH = 0; + +Eina_Bool +OnWindowConfigured(void* pData, int type, void* pEvent) +{ + Ecore_X_Event_Window_Configure* pEv = (Ecore_X_Event_Window_Configure*)pEvent; + if (!pEv) + { + return ECORE_CALLBACK_PASS_ON; + } + + if (pEv->from_wm == EINA_FALSE) + { + return ECORE_CALLBACK_PASS_ON; + } + + Ecore_X_Window targetWin = pEv->win; + if (targetWin == 0) + { + return ECORE_CALLBACK_PASS_ON; + } + + if ((frameX == pEv->x) && (frameY == pEv->y) && (frameW == pEv->w) && (frameH == pEv->h)) + { + return ECORE_CALLBACK_PASS_ON; + } + + frameX = pEv->x; + frameY = pEv->y; + frameW = pEv->w; + frameH = pEv->h; + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + if (!pControlManager) + { + return ECORE_CALLBACK_PASS_ON; + } + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + if (!pTouchManager) + { + return ECORE_CALLBACK_PASS_ON; + } + + if (pTouchManager->GetPointCount() > 0) + { + return ECORE_CALLBACK_PASS_ON; + } + + _Window* pWindow = pControlManager->GetCurrentFrame(); + if (!pWindow) + { + return ECORE_CALLBACK_PASS_ON; + } + + if (pWindow->IsOrientationRoot() == false) + { + return ECORE_CALLBACK_PASS_ON; + } + + _Frame* pFrame = static_cast<_Frame*>(pWindow); + if (pFrame->GetShowMode() == FRAME_SHOW_MODE_FULL_SCREEN) + { + return ECORE_CALLBACK_PASS_ON; + } + + Ecore_X_Window win = (Ecore_X_Window)pFrame->GetNativeHandle(); + if (win != targetWin) + { + return ECORE_CALLBACK_PASS_ON; + } + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + if (!pEcoreEvas) + { + return ECORE_CALLBACK_PASS_ON; + } + + Rectangle frameBounds = pFrame->GetBounds(); + int rotation = pEcoreEvas->GetWindowRotation(*pFrame); + + Dimension winSize = _CoordinateSystemUtils::InverseTransform(Dimension(pEv->w, pEv->h)); + Dimension newSize(winSize.width, winSize.height); + if ((rotation == 270) || (rotation == 90)) + { + newSize.width = winSize.height; + newSize.height = winSize.width; + } + + if ((frameBounds.width != newSize.width) || (frameBounds.height != newSize.height)) + { + return ECORE_CALLBACK_PASS_ON; + } + + Dimension screenSize = pControlManager->GetScreenSize(); + Point winPosition = _CoordinateSystemUtils::InverseTransform(Point(pEv->x, pEv->y)); + + Point newPosition(0, 0); + switch (rotation) + { + case 270: + newPosition.x = winPosition.y; + newPosition.y = screenSize.width - winPosition.x - frameBounds.height; + break; + case 180: + newPosition.x = screenSize.width - winPosition.x - frameBounds.width; + newPosition.y = screenSize.height - winPosition.y - frameBounds.height; + break; + case 90: + newPosition.x = screenSize.height - winPosition.y - frameBounds.width; + newPosition.y = winPosition.x; + break; + default: + newPosition.x = winPosition.x; + newPosition.y = winPosition.y; + break; + } + + if ((frameBounds.x != newPosition.x) || (frameBounds.y != newPosition.y)) + { + pFrame->SetChangingBoundsEnabled(false); + pFrame->SetPosition(newPosition); + pFrame->SetChangingBoundsEnabled(true); + } + + return ECORE_CALLBACK_PASS_ON; +} + Eina_Bool OnWindowShown(void* pData, int type, void* pEvent) { @@ -1057,6 +1189,7 @@ _EcoreEvas::_EcoreEvas(void) : __pWindowVisibilityChanged(null) , __pWindowPropertyChanged(null) , __pWindowShown(null) + , __pWindowConfigured(null) , __pClientMessageReceived(null) , __pClearClip(null) , __pNotifyClip(null) @@ -1092,6 +1225,9 @@ _EcoreEvas::_EcoreEvas(void) __pWindowShown = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, OnWindowShown, (void*) this); SysTryCatch(NID_UI, __pWindowShown, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + __pWindowConfigured = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CONFIGURE, OnWindowConfigured, NULL); + SysTryCatch(NID_UI, __pWindowConfigured, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + __pWindowPropertyChanged = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, OnWindowPropertyChanged, NULL); SysTryCatch(NID_UI, __pWindowPropertyChanged, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); @@ -1111,6 +1247,12 @@ CATCH: ecore_event_handler_del(__pWindowShown); __pWindowShown = null; } + + if (__pWindowConfigured) + { + ecore_event_handler_del(__pWindowConfigured); + __pWindowConfigured = null; + } } _EcoreEvas::~_EcoreEvas(void) @@ -1127,6 +1269,12 @@ _EcoreEvas::~_EcoreEvas(void) __pWindowShown = null; } + if (__pWindowConfigured) + { + ecore_event_handler_del(__pWindowConfigured); + __pWindowConfigured = null; + } + if (__pClientMessageReceived) { ecore_event_handler_del(__pClientMessageReceived); diff --git a/src/ui/controls/FUiCtrl_Frame.cpp b/src/ui/controls/FUiCtrl_Frame.cpp index 2f4de36..ba9eb5c 100644 --- a/src/ui/controls/FUiCtrl_Frame.cpp +++ b/src/ui/controls/FUiCtrl_Frame.cpp @@ -66,6 +66,7 @@ _Frame::_Frame(void) , __activated(false) , __constructed(false) , __rotation(false) + , __changingBoundsEnabled(true) , __pFormActivationChangeEventListener(null) { _FramePresenter* pPresenter = new (std::nothrow) _FramePresenter(*this); @@ -695,6 +696,11 @@ _Frame::OnBoundsChanging(const FloatRectangle& bounds) } } + if (__changingBoundsEnabled == false) + { + return E_SUCCESS; + } + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); @@ -827,6 +833,11 @@ _Frame::SetFocusControl(const _Control* pControl) } } +void +_Frame::SetChangingBoundsEnabled(bool enable) +{ + __changingBoundsEnabled = enable; +} Tizen::Base::Collection::IListT<_Control*>* _Frame::GetFocusList(void) const diff --git a/src/ui/inc/FUiCtrl_Frame.h b/src/ui/inc/FUiCtrl_Frame.h index c512913..fe6440c 100644 --- a/src/ui/inc/FUiCtrl_Frame.h +++ b/src/ui/inc/FUiCtrl_Frame.h @@ -98,6 +98,9 @@ public: virtual _Control* GetFocusControl(void) const; virtual void SetFocusControl(const _Control* pControl); +// Internal + void SetChangingBoundsEnabled(bool enable); + protected: result SetPresenter(const _FramePresenter& framePresenter); @@ -117,6 +120,7 @@ private: bool __activated; bool __constructed; bool __rotation; + bool __changingBoundsEnabled; _IFormActivationChangeEventListener* __pFormActivationChangeEventListener; }; // _Frame diff --git a/src/ui/inc/FUi_EcoreEvas.h b/src/ui/inc/FUi_EcoreEvas.h index 38682de..0b9e7d9 100644 --- a/src/ui/inc/FUi_EcoreEvas.h +++ b/src/ui/inc/FUi_EcoreEvas.h @@ -183,6 +183,7 @@ private: Ecore_Event_Handler* __pWindowVisibilityChanged; Ecore_Event_Handler* __pWindowPropertyChanged; Ecore_Event_Handler* __pWindowShown; + Ecore_Event_Handler* __pWindowConfigured; Ecore_Event_Handler* __pClientMessageReceived; Ecore_Event_Handler* __pClearClip; Ecore_Event_Handler* __pNotifyClip; -- 2.7.4