1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
19 #include <dali/dali.h>
20 #include <dali-toolkit/dali-toolkit.h>
21 #include <dali/public-api/common/dali-common.h>
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/adaptor-framework/key-grab.h>
24 #include <dali/public-api/adaptor-framework/window.h>
32 #include <Ecore_Wl2.h>
34 #include <Ecore_Wayland.h>
39 //#define LOG DALI_LOG_ERROR
47 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_GrabKeyTopmost(void * window, int daliKey)
49 Dali::Window *_win = (Dali::Window *)window;
52 LOG("CSharp_Dali_GrabKeyTopmost() [DP1] window=%d, dalikey=%d", window, daliKey);
56 ret = Dali::KeyGrab::GrabKeyTopmost(*_win, (Dali::KEY)daliKey);
57 } catch (std::out_of_range& e) {
59 SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
61 } catch (std::exception& e) {
63 SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
65 } catch (Dali::DaliException e) {
67 SWIG_CSharpException(SWIG_UnknownError, e.condition); return 0;
71 SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0;
77 LOG("CSharp_Dali_GrabKeyTopmost() [DP2] ret=%d", ret);
82 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_UngrabKeyTopmost(void * window, int daliKey)
84 Dali::Window *_win = (Dali::Window *)window;
87 LOG("CSharp_Dali_UngrabKeyTopmost() [DP1] window=%d, dalikey=%d", window, daliKey);
91 ret = Dali::KeyGrab::UngrabKeyTopmost(*_win, (Dali::KEY)daliKey);
92 } catch (std::out_of_range& e) {
94 SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
96 } catch (std::exception& e) {
98 SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
100 } catch (Dali::DaliException e) {
102 SWIG_CSharpException(SWIG_UnknownError, e.condition); return 0;
106 SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0;
112 LOG("CSharp_Dali_UngrabKeyTopmost() [DP2] ret=%d", ret);
117 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_GrabKey(void * window, int daliKey, int grabMode)
119 Dali::Window *_win = (Dali::Window *)window;
122 LOG("CSharp_Dali_GrabKey() [DP1] window=%d, dalikey=%d, grabmode=%d", window, daliKey, grabMode);
126 ret = Dali::KeyGrab::GrabKey(*_win, (Dali::KEY)daliKey, (Dali::KeyGrab::KeyGrabMode)grabMode);
127 } catch (std::out_of_range& e) {
129 SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
131 } catch (std::exception& e) {
133 SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
135 } catch (Dali::DaliException e) {
137 SWIG_CSharpException(SWIG_UnknownError, e.condition); return 0;
141 SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0;
147 DALI_LOG_ERROR("CSharp_Dali_GrabKey() [DP2] ret=%d", ret);
152 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_UngrabKey(void * window, int daliKey)
154 Dali::Window *_win = (Dali::Window *)window;
157 LOG("CSharp_Dali_UngrabKey() [DP1] window=%d, dalikey=%d", window, daliKey);
161 ret = Dali::KeyGrab::UngrabKey(*_win, (Dali::KEY)daliKey);
162 } catch (std::out_of_range& e) {
164 SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
166 } catch (std::exception& e) {
168 SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
170 } catch (Dali::DaliException e) {
172 SWIG_CSharpException(SWIG_UnknownError, e.condition); return 0;
176 SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0;
182 LOG("CSharp_Dali_UngrabKey() [DP2] ret=%d", ret);
187 SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_GetNativeWindowHandler( void* window )
189 Dali::Window *_win = (Dali::Window *)window;
192 LOG("CSharp_Dali_GetNativeWindowHandler() [DP1] window=%d", window);
197 result = _win->GetNativeHandle();
200 Ecore_Wl2_Window * ecore_win = Dali::AnyCast<Ecore_Wl2_Window*>(result);
202 Ecore_Wl_Window * ecore_win = Dali::AnyCast<Ecore_Wl_Window*>(result);
205 ret = (void*)ecore_win;
207 } catch (std::out_of_range& e) {
209 SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return NULL;
211 } catch (std::exception& e) {
213 SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return NULL;
217 SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return NULL;
224 LOG("CSharp_Dali_GetNativeWindowHandler() [DP2] ret=%d", ret);