2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FUi_FocusManagerImpl.cpp
19 * @brief This is the implementation file for _FocusManagerImpl class.
24 #include "FUi_FocusManagerImpl.h"
25 #include "FUi_ControlImpl.h"
26 #include "FUi_WindowImpl.h"
27 #include "FUi_ControlManager.h"
30 namespace Tizen { namespace Ui
32 ////////////////////////////////////////////////////////////////////////////////
33 /// _FocusManagerImpl class Lifecycle
34 _FocusManagerImpl* _FocusManagerImpl::__pInstance = null;
36 _FocusManagerImpl::_FocusManagerImpl(void)
42 _FocusManagerImpl::~_FocusManagerImpl(void)
48 _FocusManagerImpl::Initialize(void)
50 static pthread_once_t once_block = PTHREAD_ONCE_INIT;
52 if (__pInstance == null)
54 pthread_once(&once_block, InitializeInstance);
59 _FocusManagerImpl::GetInstance(void)
65 _FocusManagerImpl::InitializeInstance(void)
69 if (__pInstance == null)
71 __pInstance = new (std::nothrow) _FocusManagerImpl;
72 SysTryReturnVoidResult(NID_UI, __pInstance != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
77 _FocusManagerImpl::ReleaseInstance(void)
86 ////////////////////////////////////////////////////////////////////////////////
87 /// _FocusManagerImpl class Operation
90 _FocusManagerImpl::GetCurrentFocusOwner(void) const
92 _Control* pFocus = _ControlManager::GetInstance()->GetFocusedControl();
98 _ControlImpl* pFocusImpl = static_cast <_ControlImpl*>(pFocus->GetUserData());
99 SysAssert(pFocusImpl);
106 _FocusManagerImpl::GetCurrentFocusedWindow(void) const
108 _Control* pFocus = _ControlManager::GetInstance()->GetFocusedControl();
113 _Window* pWindow = pFocus->GetRootWindow();
116 _WindowImpl* pWindowImpl = static_cast <_WindowImpl*>(static_cast <_ControlImpl*>(pWindow->GetUserData()));
117 SysAssert(pWindowImpl);