From e3d3b0d22d39557949a774917bd98cc157e353be Mon Sep 17 00:00:00 2001 From: "dongsug.song" Date: Fri, 21 Apr 2017 17:22:31 +0900 Subject: [PATCH] keygrab & ecore-wl-window-handle c# binding - this is a pair with dali-adaptor patch of https://review.tizen.org/gerrit/#/c/126398/ Change-Id: I77fe333676946936b02fd4fafcf5c909a6d14e6a Signed-off-by: dongsug.song --- dali-csharp-binder/file.list | 3 +- dali-csharp-binder/src/key-grab.cpp | 201 ++++++++++++++++++++++++++++++++++++ 2 files changed, 203 insertions(+), 1 deletion(-) create mode 100755 dali-csharp-binder/src/key-grab.cpp diff --git a/dali-csharp-binder/file.list b/dali-csharp-binder/file.list index e601e4a..c0a8a33 100755 --- a/dali-csharp-binder/file.list +++ b/dali-csharp-binder/file.list @@ -9,7 +9,8 @@ dali_csharp_binder_src_files = \ src/devel-property-wrap.cpp \ src/version-check.cpp \ src/view-wrapper-impl-wrap.cpp \ - src/event-thread-callback-wrap.cpp + src/event-thread-callback-wrap.cpp \ + src/key-grab.cpp dali_csharp_binder_header_files = \ src/common.h diff --git a/dali-csharp-binder/src/key-grab.cpp b/dali-csharp-binder/src/key-grab.cpp new file mode 100755 index 0000000..433bcb0 --- /dev/null +++ b/dali-csharp-binder/src/key-grab.cpp @@ -0,0 +1,201 @@ +/** Copyright (c) 2017 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* 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. +* +*/ + +#include "common.h" + +#include +#include +#include + + +#undef LOG +//#define LOG DALI_LOG_ERROR +#define LOG(a...) + + +#ifdef __cplusplus +extern "C" { +#endif + + +SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_GrabKeyTopmost(void * window, int daliKey) +{ + Dali::Window *_win = (Dali::Window *)window; + bool ret; + + LOG("CSharp_Dali_GrabKeyTopmost() [DP1] window=%d, dalikey=%d", window, daliKey); + + { + try { + + ret = Dali::KeyGrab::GrabKeyTopmost(*_win, (Dali::KEY)daliKey); + + } catch (std::out_of_range& e) { + { + SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); return false; + }; + } catch (std::exception& e) { + { + SWIG_CSharpException(SWIG_RuntimeError, const_cast(e.what())); return false; + }; + } catch (...) { + { + SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false; + }; + } + } + + LOG("CSharp_Dali_GrabKeyTopmost() [DP2] ret=%d", ret); + + return ret; +} + +SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_UngrabKeyTopmost(void * window, int daliKey) +{ + Dali::Window *_win = (Dali::Window *)window; + bool ret; + + LOG("CSharp_Dali_UngrabKeyTopmost() [DP1] window=%d, dalikey=%d", window, daliKey); + + { + try { + + ret = Dali::KeyGrab::UngrabKeyTopmost(*_win, (Dali::KEY)daliKey); + + } catch (std::out_of_range& e) { + { + SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); return false; + }; + } catch (std::exception& e) { + { + SWIG_CSharpException(SWIG_RuntimeError, const_cast(e.what())); return false; + }; + } catch (...) { + { + SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false; + }; + } + } + + LOG("CSharp_Dali_UngrabKeyTopmost() [DP2] ret=%d", ret); + + return ret; +} + +SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_GrabKey(void * window, int daliKey, int grabMode) +{ + Dali::Window *_win = (Dali::Window *)window; + bool ret; + + LOG("CSharp_Dali_GrabKey() [DP1] window=%d, dalikey=%d, grabmode=%d", window, daliKey, grabMode); + + { + try { + + ret = Dali::KeyGrab::GrabKey(*_win, (Dali::KEY)daliKey, (Dali::KeyGrab::KeyGrabMode)grabMode); + + } catch (std::out_of_range& e) { + { + SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); return false; + }; + } catch (std::exception& e) { + { + SWIG_CSharpException(SWIG_RuntimeError, const_cast(e.what())); return false; + }; + } catch (...) { + { + SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false; + }; + } + } + + DALI_LOG_ERROR("CSharp_Dali_GrabKey() [DP2] ret=%d", ret); + + return ret; +} + +SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_UngrabKey(void * window, int daliKey) +{ + Dali::Window *_win = (Dali::Window *)window; + bool ret; + + LOG("CSharp_Dali_UngrabKey() [DP1] window=%d, dalikey=%d", window, daliKey); + + { + try { + + ret = Dali::KeyGrab::UngrabKey(*_win, (Dali::KEY)daliKey); + + } catch (std::out_of_range& e) { + { + SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); return false; + }; + } catch (std::exception& e) { + { + SWIG_CSharpException(SWIG_RuntimeError, const_cast(e.what())); return false; + }; + } catch (...) { + { + SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false; + }; + } + } + + LOG("CSharp_Dali_UngrabKey() [DP2] ret=%d", ret); + + return ret; +} + +SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_GetNativeWindowHandler( void* window ) +{ + Dali::Window *_win = (Dali::Window *)window; + void * ret; + + LOG("CSharp_Dali_GetNativeWindowHandler() [DP1] window=%d", window); + + { + try { + + ret = Dali::DevelWindow::GetNativeWindowHandler(*_win); + + } catch (std::out_of_range& e) { + { + SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); return false; + }; + } catch (std::exception& e) { + { + SWIG_CSharpException(SWIG_RuntimeError, const_cast(e.what())); return false; + }; + } catch (...) { + { + SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false; + }; + } + } + + if(ret != NULL) + { + LOG("CSharp_Dali_GetNativeWindowHandler() [DP2] ret=%d", ret); + } + + return ret; +} + + +#ifdef __cplusplus +} +#endif + -- 2.7.4