[Tizen] Move KeyGrab from internal tizen to public API
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / key-grab.h
1 #ifndef __DALI_KEY_GRAB_H__
2 #define __DALI_KEY_GRAB_H__
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/public-api/common/dali-vector.h>
24 #include <dali/public-api/adaptor-framework/key.h>
25
26 namespace Dali
27 {
28 /**
29  * @addtogroup dali_adaptor_framework
30  * @{
31  */
32
33 class Window;
34
35 /**
36  * @brief Key grab functions.
37  * @SINCE_1_0.0
38  */
39 namespace KeyGrab
40 {
41
42 /**
43  * @brief Grabs the key specified by @a key for @a window only when @a window is the topmost window.
44  *
45  * This function can be used for following example scenarios:
46  * - Mobile - Using volume up/down as zoom up/down in camera apps.
47  *
48  * @SINCE_1_0.0
49  * @param[in] window The window to set
50  * @param[in] daliKey The key code to grab (defined in key.h)
51  * @return true if the grab succeeds
52  */
53 DALI_IMPORT_API bool GrabKeyTopmost( Window window, Dali::KEY daliKey );
54
55 /**
56  * @brief Ungrabs the key specified by @a key for @a window.
57  *
58  * @SINCE_1_0.0
59  * @param[in] window The window to set
60  * @param[in] daliKey The key code to ungrab (defined in key.h)
61  * @return true if the ungrab succeeds
62  * @note If this function is called between key down and up events of a grabbed key,
63  * an application doesn't receive the key up event.
64  */
65 DALI_IMPORT_API bool UngrabKeyTopmost( Window window, Dali::KEY daliKey );
66
67 /**
68  * @brief Enumeration for key grab mode for platform-level APIs.
69  * @SINCE_1_0.0
70  */
71 enum KeyGrabMode
72 {
73   TOPMOST = 0,             ///< Grab a key only when on the top of the grabbing-window stack mode. @SINCE_1_0.0
74   SHARED,                  ///< Grab a key together with the other client window(s) mode. @SINCE_1_0.0
75   OVERRIDE_EXCLUSIVE,      ///< Grab a key exclusively regardless of the grabbing-window's position on the window stack with the possibility of overriding the grab by the other client window mode. @SINCE_1_0.0
76   EXCLUSIVE                ///< Grab a key exclusively regardless of the grabbing-window's position on the window stack mode. @SINCE_1_0.0
77 };
78
79 /**
80  * @PLATFORM
81  * @brief Grabs the key specified by @a key for @a window in @a grabMode.
82  *
83  * @details This function can be used for following example scenarios:
84  * - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app.
85  * - Mobile - When a user presses Home key, the homescreen appears regardless of current foreground app.
86  * - Mobile - Using volume up/down as zoom up/down in camera apps.
87  *
88  * @SINCE_1_0.0
89  * @PRIVLEVEL_PLATFORM
90  * @PRIVILEGE_KEYGRAB
91  * @param[in] window The window to set
92  * @param[in] daliKey The key code to grab (defined in key.h)
93  * @param[in] grabMode The grab mode for the key
94  * @return true if the grab succeeds
95  */
96 DALI_IMPORT_API bool GrabKey( Window window, Dali::KEY daliKey, KeyGrabMode grabMode );
97
98 /**
99  * @PLATFORM
100  * @brief Ungrabs the key specified by @a key for @a window.
101  *
102  * @SINCE_1_0.0
103  * @PRIVLEVEL_PLATFORM
104  * @PRIVILEGE_KEYGRAB
105  * @param[in] window The window to set
106  * @param[in] daliKey The key code to ungrab (defined in key.h)
107  * @return true if the ungrab succeeds
108  * @note If this function is called between key down and up events of a grabbed key,
109  * an application doesn't receive the key up event.
110  */
111 DALI_IMPORT_API bool UngrabKey( Window window, Dali::KEY daliKey );
112
113
114 /**
115  * @PLATFORM
116  * @brief Grabs the list of keys specified by Dali::Vector of keys for @a window in Dali::Vector of grabModes.
117  *
118  * @details This function can be used for following example scenarios:
119  * - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app.
120  * - Mobile - When a user presses Home key, the homescreen appears regardless of current foreground app.
121  * - Mobile - Using volume up/down as zoom up/down in camera apps.
122  *
123  * @SINCE_1_2.0
124  * @PRIVLEVEL_PLATFORM
125  * @PRIVILEGE_KEYGRAB
126  * @param[in] window The window to set
127  * @param[in] daliKeyVector The Dali::Vector of key codes to grab (defined in key.h)
128  * @param[in] grabModeVector The Dali::Vector of grab modes for the keys
129  * @param[in] returnVector The Dali::Vector of return boolean values for the results of multiple grab succeeds/fails
130  * @return bool false when error occurs
131  */
132 DALI_IMPORT_API bool GrabKeyList( Window window, const Dali::Vector<Dali::KEY>& daliKeyVector, const Dali::Vector<KeyGrabMode>& grabModeVector, Dali::Vector<bool>& returnVector);
133
134
135 /**
136  * @PLATFORM
137  * @brief Ungrabs the list of keys specified by Dali::Vector of keys for @a window.
138  *
139  * @SINCE_1_2.0
140  * @PRIVLEVEL_PLATFORM
141  * @PRIVILEGE_KEYGRAB
142  * @param[in] window The window to set
143  * @param[in] daliKeyVector The Dali::Vector of key codes to ungrab (defined in key.h)
144  * @param[in] returnVector The Dali::Vector of return boolean values for the results of multiple ungrab succeeds/fails
145  * @return bool false when error occurs
146  * @note If this function is called between key down and up events of a grabbed key,
147  * an application doesn't receive the key up event.
148  */
149 DALI_IMPORT_API bool UngrabKeyList( Window window, const Dali::Vector<Dali::KEY>& daliKeyVector, Dali::Vector<bool>& returnVector);
150
151
152 } // namespace KeyGrab
153
154 /**
155  * @}
156  */
157 } // namespace Dali
158
159 #endif // __DALI_KEY_GRAB_H__