From: choimunseok Date: Wed, 4 Dec 2013 07:33:09 +0000 (+0900) Subject: Added the sub class _EcoreX X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e7eb5c9954fe1432c0329044d67885ad23d10e15;p=framework%2Fosp%2Fuifw.git Added the sub class _EcoreX Change-Id: I93d7c795bf295b1ef3617094a2582e4c716b1de6 Signed-off-by: choimunseok --- diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 7eee8af..f64e0b5 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -64,6 +64,7 @@ SET (${this_target}_SOURCE_FILES animations/platform/FUiAnim_NativeWindow.cpp animations/platform/FUiAnim_X11Window.cpp animations/platform/FUiAnim_X11.cpp + animations/platform/FUiAnim_EcoreX.cpp animations/platform/FUiAnim_GlContext.cpp animations/platform/FUiAnim_Egl.cpp animations/platform/FUiAnim_Wgl.cpp diff --git a/src/ui/animations/FUiAnim_Looper.cpp b/src/ui/animations/FUiAnim_Looper.cpp index d0a5b8c..7856e96 100644 --- a/src/ui/animations/FUiAnim_Looper.cpp +++ b/src/ui/animations/FUiAnim_Looper.cpp @@ -67,7 +67,7 @@ OnWakeup(void* pData, int type, void* pEvent) Eina_Bool OnIdleEntered(void* pData) { - +#if !defined(USE_ECORE_X) _Looper* pLooper = _Looper::GetInstance(); PRINT("OnIdleEntered\n"); @@ -83,6 +83,7 @@ OnIdleEntered(void* pData) pLooper->DispatchRawEvent(rawEvent); } } while (event == true); +#endif return EINA_TRUE; } @@ -90,9 +91,11 @@ OnIdleEntered(void* pData) Eina_Bool OnFdEventOccured(void *data, Ecore_Fd_Handler *fd_handler) { +#if !defined(USE_ECORE_X) _Looper* pLooper = _Looper::GetInstance(); PRINT("OnFdEventOccured\n"); pLooper->CallEventProducer(data); +#endif return EINA_TRUE; diff --git a/src/ui/animations/platform/FUiAnim_EcoreX.cpp b/src/ui/animations/platform/FUiAnim_EcoreX.cpp new file mode 100644 index 0000000..5a7eff9 --- /dev/null +++ b/src/ui/animations/platform/FUiAnim_EcoreX.cpp @@ -0,0 +1,167 @@ +#include +#include "FUiAnim_EcoreX.h" +#include "FUiAnim_GlLayer.h" +#include "FUiAnim_X11Window.h" +#include "FUiAnim_DisplayManager.h" + +using namespace Tizen::Ui::Animations; + +namespace +{ + +Eina_Bool +OnXShown(void* pData, int type, void* pEventInfo) +{ + if ((!pData) || (!pEventInfo)) + { + return EINA_TRUE; + } + + Ecore_X_Event_Window_Show* pEvent = (Ecore_X_Event_Window_Show*)pEventInfo; + + _EcoreX* pEcoreX = (_EcoreX*)pData; + + if (pEvent->win != 0) + { + _GlLayer* pGlLayer = pEcoreX->GetLayer(pEvent->win); + + if (pGlLayer) + { + _RawEvent rawEvent; + + rawEvent.type = _RawEvent::RAWEVENT_FLUSH; + rawEvent.rawWindow = pEvent->win; + + _X11Window* pWindow = static_cast<_X11Window *>(pGlLayer->GetWindow()); + if (pWindow) + { + XEvent xEvent; + xEvent.type = MapNotify; + + pWindow->ProcessEvent(pGlLayer, xEvent); + } + + rawEvent.data.flush.layerWindowHandle = pGlLayer->GetWindowHandle(); + rawEvent.data.flush.layerId = pGlLayer->GetId(); + + pEcoreX->ProcessRawEvent(rawEvent); + } + } + + return EINA_TRUE; +} + +} // Anonymous + +namespace Tizen { namespace Ui { namespace Animations { + +_EcoreX* _EcoreX::__pInstance = null; + +_EcoreX* +_EcoreX::GetInstance(void) +{ + return _EcoreX::__pInstance; +} + +void +_EcoreX::Init(void) +{ + if(!_EcoreX::__pInstance) + { + _EcoreX::__pInstance = new (std::nothrow) _EcoreX; + } +} + +void +_EcoreX::Destroy(void) +{ + if(_EcoreX::__pInstance) + { + delete _EcoreX::__pInstance; + _EcoreX::__pInstance = null; + } +} + +_EcoreX::_EcoreX(void) + : __pShowHandler(NULL) +{ + __pDisplay = (Display*)ecore_x_display_get(); + SysAssertf(__pDisplay, "Cannot initialize X display"); + + __XColormap = DefaultColormap(__pDisplay, DefaultScreen(__pDisplay)); + + __pShowHandler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, OnXShown, (void*) this); +} + +_EcoreX::~_EcoreX(void) +{ + if (__pShowHandler) + { + ecore_event_handler_del(__pShowHandler); + __pShowHandler = NULL; + } +} + +Display* +_EcoreX::GetXDisplay(void) const +{ + return __pDisplay; +} + +bool +_EcoreX::MonitorRawEvents(void) +{ + return true; +} + +bool +_EcoreX::ProduceRawEvents(int fd) +{ + return true; +} + +_GlLayer* +_EcoreX::GetLayer(Window window) +{ + _DisplayManager* pDisplayManager = _DisplayManager::GetInstance(); + + int count = pDisplayManager->GetLayerCount(); + + for (int i = 0; i < count; i++) + { + _NativeLayer* pLayer = pDisplayManager->GetLayer(i); + if (likely(pLayer)) + { + if (pLayer->GetWindowHandle() == window) + { + return dynamic_cast<_GlLayer*>(pLayer); + } + } + } + + return null; +} + +void +_EcoreX::ProcessRawEvent(_RawEvent& rawEvent) +{ + _Looper* pLooper = _Looper::GetInstance(); + + pLooper->PostRawEvent(rawEvent); + + _RawEvent peekRawEvent; + bool event = true; + + SysLog(NID_UI_ANIM, "%d 0x%x", rawEvent.type, rawEvent.rawWindow); + + do + { + event = pLooper->PeekRawEvent(peekRawEvent, true); + if (event) + { + pLooper->DispatchRawEvent(peekRawEvent); + } + } while (event == true); +} + +}}} // Tizen::Ui::Animations diff --git a/src/ui/animations/platform/FUiAnim_EcoreX.h b/src/ui/animations/platform/FUiAnim_EcoreX.h new file mode 100644 index 0000000..00a5360 --- /dev/null +++ b/src/ui/animations/platform/FUiAnim_EcoreX.h @@ -0,0 +1,70 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FUiAnim_EcoreX.h + * @brief This is the header file for the _EcoreX class. + * + * This header file contains the declarations of the _EcoreX class. @n + */ + +#ifndef _FUI_ANIM_INTERNAL_ECORE_X_H_ +#define _FUI_ANIM_INTERNAL_ECORE_X_H_ + +#include +#include "FUiAnim_Looper.h" +#include "FUiAnim_NativeWindow.h" + +namespace Tizen { namespace Ui { namespace Animations { + +class _GlLayer; + +class _EcoreX + : public _IRawEventProducer + , public _IRawEventMonitor +{ +public: + static _EcoreX* GetInstance(void); + + static void Init(void); + static void Destroy(void); + +public: + virtual bool MonitorRawEvents(void); + virtual bool ProduceRawEvents(int fd); + + void ProcessRawEvent(_RawEvent& rawEvent); + + Display* GetXDisplay(void) const; + + _GlLayer* GetLayer(Window window); + +private: + _EcoreX(void); + virtual ~_EcoreX(void); + +private: + Display* __pDisplay; + Colormap __XColormap; + static _EcoreX* __pInstance; + + Ecore_Event_Handler* __pShowHandler; +}; // _EcoreX + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_ECORE_X_H_ diff --git a/src/ui/animations/platform/FUiAnim_X11Window.cpp b/src/ui/animations/platform/FUiAnim_X11Window.cpp index ecf79d2..f3e1d0a 100644 --- a/src/ui/animations/platform/FUiAnim_X11Window.cpp +++ b/src/ui/animations/platform/FUiAnim_X11Window.cpp @@ -10,6 +10,7 @@ #include "FUiAnim_GlRenderManager.h" #include "FUiAnim_X11Window.h" #include "FUiAnim_X11.h" +#include "FUiAnim_EcoreX.h" using namespace Tizen::Base; using namespace Tizen::Graphics; @@ -23,34 +24,57 @@ namespace Tizen { namespace Ui { namespace Animations { bool _X11Window::X11WindowSystemInit() { +#if defined(USE_ECORE_X) + if(_EcoreX::GetInstance()) +#else if(_X11::GetInstance()) +#endif { return false; } +#if defined(USE_ECORE_X) + _EcoreX::Init(); +#else _X11::Init(); +#endif return true; } bool _X11Window::X11WindowSystemDestroy() { +#if defined(USE_ECORE_X) + if(!_EcoreX::GetInstance()) +#else if(!_X11::GetInstance()) +#endif { return false; } +#if defined(USE_ECORE_X) + _EcoreX::Destroy(); +#else _X11::Destroy(); +#endif return true; } Handle _X11Window::X11WindowSystemGetDisplay() { +#if defined(USE_ECORE_X) + if(_EcoreX::GetInstance()) + { + return (Handle)_EcoreX::GetInstance()->GetXDisplay(); + } +#else if(_X11::GetInstance()) { return (Handle)_X11::GetInstance()->GetXDisplay(); } +#endif return (Handle)0; } @@ -91,7 +115,11 @@ _X11Window::OnConstructing() void _X11Window::OnDestructing() { +#if defined(USE_ECORE_X) + ::XDestroyWindow(_EcoreX::GetInstance()->GetXDisplay(), GetHandle()); +#else ::XDestroyWindow(_X11::GetInstance()->GetXDisplay(), GetHandle()); +#endif } void @@ -101,7 +129,11 @@ _X11Window::OnBoundsChanging(const Tizen::Graphics::FloatRectangle& newBounds) if (window) { FloatRectangle bounds = newBounds; +#if defined(USE_ECORE_X) + Display* pDisplay =_EcoreX::GetInstance()->GetXDisplay(); +#else Display* pDisplay =_X11::GetInstance()->GetXDisplay(); +#endif // CHECKME: float --> int ? int x = (int)bounds.x; int y = (int)bounds.y; @@ -121,7 +153,11 @@ _X11Window::OnShowStateChanging(bool newShowState) Handle window = GetHandle(); if (window) { +#if defined(USE_ECORE_X) + Display* pDisplay = _EcoreX::GetInstance()->GetXDisplay(); +#else Display* pDisplay = _X11::GetInstance()->GetXDisplay(); +#endif if (newShowState) { @@ -182,7 +218,11 @@ _X11Window::XCreateWindow(Handle hParent, int x, int y, unsigned int width, unsi { Window parent = hParent; +#if defined(USE_ECORE_X) + Display* pDisplay = _EcoreX::GetInstance()->GetXDisplay(); +#else Display* pDisplay = _X11::GetInstance()->GetXDisplay(); +#endif XSetWindowAttributes winAttributes; if(hParent == 0) @@ -233,7 +273,11 @@ _X11Window::GetVisual(Handle parent) XRenderPictFormat *fmt; Visual *vis; +#if defined(USE_ECORE_X) + Display* pDisplay = _EcoreX::GetInstance()->GetXDisplay(); +#else Display* pDisplay = _X11::GetInstance()->GetXDisplay(); +#endif if (parent == 0) { parent = DefaultRootWindow(pDisplay); @@ -289,7 +333,11 @@ _X11Window::GetWindowGeometry(void) const Handle dummyWin; int x, y; unsigned int w, h, dummyBorder, dummyDepth; +#if defined(USE_ECORE_X) + if (!XGetGeometry(_EcoreX::GetInstance()->GetXDisplay(), (Window)window, (Window*)&dummyWin, &x, &y, &w, &h, &dummyBorder, &dummyDepth)) +#else if (!XGetGeometry(_X11::GetInstance()->GetXDisplay(), (Window)window, (Window*)&dummyWin, &x, &y, &w, &h, &dummyBorder, &dummyDepth)) +#endif { x = 0; y = 0; @@ -312,7 +360,11 @@ _X11Window::GetWindowShowState(void) const { XWindowAttributes attr; +#if defined(USE_ECORE_X) + return XGetWindowAttributes(_EcoreX::GetInstance()->GetXDisplay(), window, &attr) && (attr.map_state == IsViewable); +#else return XGetWindowAttributes(_X11::GetInstance()->GetXDisplay(), window, &attr) && (attr.map_state == IsViewable); +#endif } return false; @@ -324,7 +376,11 @@ _X11Window::XCreateArgbWindow(Handle hParent, int x, int y, unsigned int width, #ifdef GLX_USE #else Window parent = hParent; +#if defined(USE_ECORE_X) + Display* pDisplay = _EcoreX::GetInstance()->GetXDisplay(); +#else Display* pDisplay = _X11::GetInstance()->GetXDisplay(); +#endif XSetWindowAttributes winAttributes; if(hParent == 0) diff --git a/src/ui/animations/platform/FUiAnim_X11Window.h b/src/ui/animations/platform/FUiAnim_X11Window.h index 7ec2a17..0df9d55 100644 --- a/src/ui/animations/platform/FUiAnim_X11Window.h +++ b/src/ui/animations/platform/FUiAnim_X11Window.h @@ -45,6 +45,8 @@ public: bool GetWindowShowState(void) const; Tizen::Graphics::FloatRectangle GetWindowGeometry(void) const; + void ProcessEvent(_GlLayer* pLayer, XEvent& xEvent); + private: // README!! // We cannot use Window type, which is declared in X lib, because it makes a conflict with Tizen::Ui::Window @@ -53,8 +55,6 @@ private: void XDestroyWindow(Handle window); Handle GetVisual(Handle parent); - void ProcessEvent(_GlLayer* pLayer, XEvent& xEvent); - protected: virtual Handle OnConstructing(void); virtual void OnDestructing(void); diff --git a/src/uifw/CMakeLists.txt b/src/uifw/CMakeLists.txt old mode 100755 new mode 100644 index bd68a19..c487b1e --- a/src/uifw/CMakeLists.txt +++ b/src/uifw/CMakeLists.txt @@ -62,6 +62,7 @@ TARGET_LINK_LIBRARIES(${this_target} "-lvconf" ) TARGET_LINK_LIBRARIES(${this_target} "-ldlog" ) TARGET_LINK_LIBRARIES(${this_target} "-lpthread" ) TARGET_LINK_LIBRARIES(${this_target} "-lecore" ) +TARGET_LINK_LIBRARIES(${this_target} "-lecore_x" ) TARGET_LINK_LIBRARIES(${this_target} "-lxml2" ) TARGET_LINK_LIBRARIES(${this_target} "-lfontconfig" ) TARGET_LINK_LIBRARIES(${this_target} "-lcairo" )