Revert "[Tizen] Add key grab list API"
[platform/core/uifw/dali-adaptor.git] / adaptors / ecore / wayland / key-grab-ecore-wl.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <key-grab.h>
20
21 // EXTERNAL INCLUDES
22 #include <Ecore_Wayland.h>
23 #include <dali/integration-api/debug.h>
24
25 // INTERNAL INCLUDES
26 #include <window.h>
27 #include <key-impl.h>
28
29 #include <iostream>
30 using namespace std;
31
32 namespace Dali
33 {
34
35 namespace KeyGrab
36 {
37
38 bool GrabKeyTopmost( Window window, Dali::KEY daliKey )
39 {
40   return GrabKey( window, daliKey, TOPMOST);
41 }
42
43 bool UngrabKeyTopmost( Window window, Dali::KEY daliKey )
44 {
45   return UngrabKey( window, daliKey );
46 }
47
48 bool GrabKey( Window window, Dali::KEY daliKey, KeyGrabMode grabMode )
49 {
50   Ecore_Wl_Window_Keygrab_Mode wlGrabMode;
51   if( grabMode == TOPMOST )
52   {
53     wlGrabMode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
54   }
55   else if( grabMode == SHARED )
56   {
57     wlGrabMode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
58   }
59   else if( grabMode == OVERRIDE_EXCLUSIVE )
60   {
61     wlGrabMode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
62   }
63   else if( grabMode == EXCLUSIVE )
64   {
65     wlGrabMode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
66   }
67   else
68   {
69     return false;
70   }
71
72   return ecore_wl_window_keygrab_set( AnyCast<Ecore_Wl_Window*>( window.GetNativeHandle() ),
73                                       Dali::Internal::Adaptor::KeyLookup::GetKeyName( daliKey ),
74                                       0, 0, 0, wlGrabMode );
75 }
76
77 bool UngrabKey( Window window, Dali::KEY daliKey )
78 {
79   return ecore_wl_window_keygrab_unset( AnyCast<Ecore_Wl_Window*>( window.GetNativeHandle() ),
80                                       Dali::Internal::Adaptor::KeyLookup::GetKeyName( daliKey ),
81                                       0, 0 );
82 }
83
84 } // namespace KeyGrab
85
86 } // namespace Dali
87
88