Fix the problem that touch is not working in popup & SendUserEvent
authorjisun10.lee <jisun10.lee@samsung.com>
Fri, 24 Jan 2014 07:01:21 +0000 (16:01 +0900)
committerJiSun Lee <jisun10.lee@samsung.com>
Fri, 24 Jan 2014 08:59:12 +0000 (08:59 +0000)
Change-Id: I2a7f7ebaa010e50976c86acfe20ff94f9951d7ac
Signed-off-by: jisun10.lee <jisun10.lee@samsung.com>
src/ui/FUi_ControlManager.cpp
src/ui/FUi_XUiEventManager.cpp
src/ui/FUi_XUiEventManager.h

index 7820d28..6fee729 100644 (file)
@@ -1283,7 +1283,6 @@ _ControlManager::GetClipboardOwner(void) const
 _Control*
 _ControlManager::GetTopmostTouchedControl(const Point& point)
 {
-#ifdef BUILD_BREAK     
        _Control* pControl = null;
        _Window* pTopWindow = null;
 
@@ -1340,8 +1339,8 @@ _ControlManager::GetTopmostTouchedControl(const Point& point)
 
                if (pControl != null)
                {
-               return pControl;
-       }
+                       return pControl;
+               }
        }
 
        int count = GetWindowCount();
@@ -1362,13 +1361,38 @@ _ControlManager::GetTopmostTouchedControl(const Point& point)
                                continue;
                        }
 
-                       _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer());
+                       Rectangle winDeviceBounds(0, 0, 0, 0);
 
-                       Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
-                       Ecore_X_Window win = (Ecore_X_Window)ecore_evas_window_get(pEcoreEvas);
+                       int rootW = 0, rootH = 0;
+                       int rotation = 0;
 
-                       Rectangle winDeviceBounds(0, 0, 0, 0);
-                       ecore_x_window_geometry_get(win, &winDeviceBounds.x, &winDeviceBounds.y, &winDeviceBounds.width, &winDeviceBounds.height);
+#ifdef ENABLE_VE_EFL
+                       if (pWindow->GetWindowType() == _WINDOW_TYPE_EFL)
+                       {
+                               _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer());
+
+                               Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
+                               Ecore_X_Window win = (Ecore_X_Window)ecore_evas_window_get(pEcoreEvas);
+
+                               ecore_x_window_geometry_get(win, &winDeviceBounds.x, &winDeviceBounds.y, &winDeviceBounds.width, &winDeviceBounds.height);
+
+                               ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH);
+
+                               rotation = ecore_evas_rotation_get(pEcoreEvas);
+                       }
+                       else
+#endif
+                       {
+                               _GlLayer* pLayer = static_cast<_GlLayer*>(pRootVE->GetNativeLayer());
+                               FloatRectangle layerBounds = pLayer->GetBounds();
+                               winDeviceBounds.x = layerBounds.x;
+                               winDeviceBounds.y = layerBounds.y;
+                               winDeviceBounds.width = layerBounds.width;
+                               winDeviceBounds.height = layerBounds.height;
+
+                               rootW = 720;
+                               rootH = 1280;   //need to get root window size! & rotation value
+                       }
 
                        Point winDevicePoint = _CoordinateSystemUtils::Transform(pWindow->GetPosition());
 
@@ -1376,11 +1400,6 @@ _ControlManager::GetTopmostTouchedControl(const Point& point)
                        int x = devicePoint.x;
                        int y = devicePoint.y;
 
-                       int rootW = 0;
-                       int rootH = 0;
-                       ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH);
-
-                       int rotation = ecore_evas_rotation_get(pEcoreEvas);
                        switch (rotation)
                        {
                        case 270:
@@ -1432,7 +1451,7 @@ _ControlManager::GetTopmostTouchedControl(const Point& point)
                        }
                }
        }
-#endif
+
        return null;
 }
 
index 4b8d41c..3c4206c 100644 (file)
@@ -23,6 +23,7 @@
 #ifdef KEY_CAMERA
 #undef KEY_CAMERA
 #endif
+
 #include <X11/Xlib.h>
 #include <FBaseColIEnumeratorT.h>
 #include <FBaseSysLog.h>
@@ -577,24 +578,18 @@ private:
                        SysTryReturn(NID_UI, pWindow, null, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
                        Tizen::Graphics::Rectangle winBounds = pWindow->GetBounds();
 
-                       ptf.x = static_cast<float>(x - winBounds.x);
-                       ptf.y = static_cast<float>(y - winBounds.y);
-
-                       _Window* pTouchedWindow = pControlManager->GetTopVisibleWindowAt(Point(x, y));
-                       SysTryReturn(NID_UI, pTouchedWindow, null, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
-
-                       pRootControlElement = dynamic_cast <_ControlVisualElement*>(pTouchedWindow->GetVisualElement());
+                       pRootControlElement = dynamic_cast <_ControlVisualElement*>(pWindow->GetVisualElement());
                }
 
                SysTryReturn(NID_UI, pRootControlElement, null, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
 
-//             _ControlVisualElement* pControlVisualElement = pRootControlElement->GetControlChildAtPoint(ptf);
                _RootVisualElement* pRootVisualElement = pRootControlElement->GetRoot();
                _ControlVisualElement* pControlVisualElement = null;
                if(pRootVisualElement)
                {
                        pControlVisualElement = pRootVisualElement->GetControlVisualElementFromScreen(*pRootControlElement, ptf, null);
                }
+
                SysTryReturn(NID_UI, pControlVisualElement, null, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
 
                pControl = static_cast <_Control*>(pControlVisualElement->GetUserData());
@@ -624,10 +619,10 @@ private:
 
                int rotation = ecore_evas_rotation_get(pEE);
 #else
-        const int PORTRAIT = 0;
-        const int LANDSCAPE = 270;
-        const int PORTRAIT_REVERSE = 180;
-        const int LANDSCAPE_REVERSE = 90;
+               const int PORTRAIT = 0;
+               const int LANDSCAPE = 270;
+               const int PORTRAIT_REVERSE = 180;
+               const int LANDSCAPE_REVERSE = 90;
                int rotation = PORTRAIT;
 #endif
 
@@ -686,7 +681,6 @@ public:
                {
                        case _RawEvent::RAWEVENT_TOUCHPRESS:
                        {
-
                                PRINT("RAWEVENT_TOUCHPRESS(%d,%d) \n", rawEvent.data.touchPress.x,rawEvent.data.touchPress.y);
                                _TouchEvent event(0, _TOUCH_PRESSED, rawEvent.data.touchPress.x,  rawEvent.data.touchPress.y,  rawEvent.timeStamp, null);
 
@@ -811,14 +805,48 @@ public:
        }
 };
 
+Eina_Bool
+OnNotified(void* pData __UNUSED__, int type __UNUSED__, void* pEventInfo)
+{
+       if (pEventInfo)
+       {
+               _UiEvent* pUiEvent = static_cast <_UiEvent*>(pEventInfo);
+               SysTryReturn(NID_UI, pUiEvent, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
+
+               _UiEventManager* pEventManager = _UiEventManager::GetInstance();
+               SysTryReturn(NID_UI, pEventManager, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
+
+               result r = pEventManager->SendEvent(*pUiEvent);
+               SysTryReturn(NID_UI, r == E_SUCCESS, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
+       }
+
+       SetLastResult(E_SUCCESS);
+
+       return ECORE_CALLBACK_PASS_ON;
+}
+
+void
+FreeEvent(void* pData __UNUSED__, void* pEventInfo)
+{
+       _UiEvent* pUiEvent = static_cast <_UiEvent*>(pEventInfo);
+       if (pUiEvent)
+       {
+               delete pUiEvent;
+       }
+}
 
 _XUiEventManager::_XUiEventManager(void)
        : __notificaitonEventType(-1)
 {
-
        __pEventHandler = new _XRawEventHandler;
        _Looper::GetInstance()->AddRawEventHandler(__pEventHandler);
 
+       __notificaitonEventType = ecore_event_type_new();
+       SysTryReturnVoidResult(NID_UI, __notificaitonEventType >= 1, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
+
+       __pEcoreEventHandler = ecore_event_handler_add(__notificaitonEventType, OnNotified, null);
+       SysTryReturnVoidResult(NID_UI, __pEcoreEventHandler, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
+
        PRINT("_XUiEventManager:construct\n");
 
 //     keyboardExist = XInternAtom(static_cast<Display*>(ecore_x_display_get()), "X External Keyboard Exist", 0);
@@ -828,11 +856,12 @@ _XUiEventManager::_XUiEventManager(void)
 
 _XUiEventManager::~_XUiEventManager(void)
 {
-
        PRINT("_XUiEventManager:destruct\n");
-       _Looper::GetInstance()->RemoveRawEventHandler(__pEventHandler);
 
+       _Looper::GetInstance()->RemoveRawEventHandler(__pEventHandler);
        delete __pEventHandler;
+
+       ecore_event_handler_del(__pEcoreEventHandler);
 }
 
 result
@@ -868,11 +897,11 @@ _XUiEventManager::PostEvent(const _UiEvent& event)
 
        PRINT("_XUiEventManager:PostEvent \n");
 
-//     _UiEvent* pEvent = event.CloneN();
-//     SysTryReturn(NID_UI, pEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
+       _UiEvent* pEvent = event.CloneN();
+       SysTryReturn(NID_UI, pEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
 
-//     Ecore_Event* pEcoreEvent = ecore_event_add(__notificaitonEventType, pEvent, FreeEvent, null);
-//     SysTryReturn(NID_UI, pEcoreEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
+       Ecore_Event* pEcoreEvent = ecore_event_add(__notificaitonEventType, pEvent, FreeEvent, null);
+       SysTryReturn(NID_UI, pEcoreEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
 
        return r;
 }
@@ -890,6 +919,4 @@ _XUiEventManager::ReleaseKeyCapture(const _Control& control, _KeyCode keyCode)
 
 }
 
-
-
 }} // Tizen::Ui
index 0314487..3119def 100644 (file)
@@ -24,6 +24,7 @@
 #define _FUI_INTERNAL_X_UI_EVENT_MANAGER_H_
 
 #include <unique_ptr.h>
+#include <Ecore.h>
 
 #include "FUi_UiKeyEvent.h"
 #include "FUi_IUiEventManager.h"
@@ -68,8 +69,8 @@ private:
 
 private:
        int __notificaitonEventType;
-       //std::unique_ptr<Tizen::Base::Collection::LinkedListT<Ecore_Event_Handler*> > __pEventHandlers;
        _XRawEventHandler* __pEventHandler;
+       Ecore_Event_Handler* __pEcoreEventHandler;
 }; // _XUiEventManager
 
 }} // Tizen::Ui