keygrab & ecore-wl-window-handle c# binding
[platform/core/uifw/dali-csharp-binder.git] / dali-csharp-binder / src / key-grab.cpp
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
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
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
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.
14 *
15 */
16
17 #include "common.h"
18
19 #include <dali/integration-api/debug.h>
20 #include <dali/public-api/adaptor-framework/key-grab.h>
21 #include <dali/devel-api/adaptor-framework/window-devel.h>
22
23
24 #undef LOG
25 //#define LOG DALI_LOG_ERROR
26 #define LOG(a...)
27
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33
34 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_GrabKeyTopmost(void * window, int daliKey)
35 {
36   Dali::Window *_win = (Dali::Window *)window;
37   bool ret;
38
39   LOG("CSharp_Dali_GrabKeyTopmost() [DP1] window=%d, dalikey=%d", window, daliKey);
40
41   {
42     try {
43
44     ret = Dali::KeyGrab::GrabKeyTopmost(*_win, (Dali::KEY)daliKey);
45
46     } catch (std::out_of_range& e) {
47     {
48       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
49     };
50     } catch (std::exception& e) {
51     {
52       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
53     };
54     } catch (...) {
55     {
56       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false;
57     };
58     }
59   }
60
61   LOG("CSharp_Dali_GrabKeyTopmost() [DP2] ret=%d", ret);
62
63   return ret;
64 }
65
66 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_UngrabKeyTopmost(void * window, int daliKey)
67 {
68   Dali::Window *_win = (Dali::Window *)window;
69   bool ret;
70
71   LOG("CSharp_Dali_UngrabKeyTopmost() [DP1] window=%d, dalikey=%d", window, daliKey);
72
73   {
74     try {
75
76     ret = Dali::KeyGrab::UngrabKeyTopmost(*_win, (Dali::KEY)daliKey);
77
78     } catch (std::out_of_range& e) {
79     {
80       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
81     };
82     } catch (std::exception& e) {
83     {
84       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
85     };
86     } catch (...) {
87     {
88       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false;
89     };
90     }
91   }
92
93   LOG("CSharp_Dali_UngrabKeyTopmost() [DP2] ret=%d", ret);
94
95   return ret;
96 }
97
98 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_GrabKey(void * window, int daliKey, int grabMode)
99 {
100   Dali::Window *_win = (Dali::Window *)window;
101   bool ret;
102
103   LOG("CSharp_Dali_GrabKey() [DP1] window=%d, dalikey=%d, grabmode=%d", window, daliKey, grabMode);
104
105   {
106     try {
107
108     ret = Dali::KeyGrab::GrabKey(*_win, (Dali::KEY)daliKey, (Dali::KeyGrab::KeyGrabMode)grabMode);
109
110     } catch (std::out_of_range& e) {
111     {
112       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
113     };
114     } catch (std::exception& e) {
115     {
116       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
117     };
118     } catch (...) {
119     {
120       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false;
121     };
122     }
123   }
124
125   DALI_LOG_ERROR("CSharp_Dali_GrabKey() [DP2] ret=%d", ret);
126
127   return ret;
128 }
129
130 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_UngrabKey(void * window, int daliKey)
131 {
132   Dali::Window *_win = (Dali::Window *)window;
133   bool ret;
134
135   LOG("CSharp_Dali_UngrabKey() [DP1] window=%d, dalikey=%d", window, daliKey);
136
137   {
138     try {
139
140     ret = Dali::KeyGrab::UngrabKey(*_win, (Dali::KEY)daliKey);
141
142     } catch (std::out_of_range& e) {
143     {
144       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
145     };
146     } catch (std::exception& e) {
147     {
148       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
149     };
150     } catch (...) {
151     {
152       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false;
153     };
154     }
155   }
156
157   LOG("CSharp_Dali_UngrabKey() [DP2] ret=%d", ret);
158
159   return ret;
160 }
161
162 SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_GetNativeWindowHandler( void* window )
163 {
164   Dali::Window *_win = (Dali::Window *)window;
165   void * ret;
166
167   LOG("CSharp_Dali_GetNativeWindowHandler() [DP1] window=%d", window);
168
169   {
170     try {
171
172     ret = Dali::DevelWindow::GetNativeWindowHandler(*_win);
173
174     } catch (std::out_of_range& e) {
175     {
176       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
177     };
178     } catch (std::exception& e) {
179     {
180       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
181     };
182     } catch (...) {
183     {
184       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false;
185     };
186     }
187   }
188
189   if(ret != NULL)
190   {
191     LOG("CSharp_Dali_GetNativeWindowHandler() [DP2] ret=%d", ret);
192   }
193
194   return ret;
195 }
196
197
198 #ifdef __cplusplus
199 }
200 #endif
201