[4.0] Enhance application device signal
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / input / text / virtual-keyboard-impl-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 // HEADER
19 #include <virtual-keyboard.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23
24 // INTERNAL INCLUDES
25 #include "text-input-manager.h"
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 namespace Adaptor
34 {
35
36 namespace
37 {
38 #define TOKEN_STRING(x) #x
39
40 #if defined(DEBUG_ENABLED)
41 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_VIRTUAL_KEYBOARD");
42 #endif
43 }
44 // Current DALi Virtual Keyboard devel API has no knowledge of Seats
45 // so we use the most recently 'active' seat. If Tizen ever supports two input panels
46 // at the same time, we need to modify DALi to be aware of it.
47 namespace VirtualKeyboard
48 {
49
50 // Functions listed in order from virtual-keyboard.h
51
52 void Show()
53 {
54   TextInputManager::Get().ShowInputPanel();
55 }
56
57 void Hide()
58 {
59   TextInputManager::Get().HideInputPanel();
60 }
61
62 bool IsVisible()
63 {
64   return TextInputManager::Get().IsInputPanelVisible();
65 }
66
67
68 void SetReturnKeyType( const InputMethod::ActionButton type )
69 {
70   TextInputManager::Get().SetReturnKeyType( type );
71 }
72
73 void ApplySettings( const Property::Map& settingsMap )
74 {
75   using namespace InputMethod; // Allows exclusion of namespace in TOKEN_STRING.
76
77   for( unsigned int i = 0, count = settingsMap.Count(); i < count; ++i )
78   {
79     std::string key = settingsMap.GetKey( i );
80     Property::Value item = settingsMap.GetValue(i);
81
82     if( key == TOKEN_STRING( ACTION_BUTTON ) )
83     {
84       if( item.GetType() == Property::INTEGER )
85       {
86         int value = item.Get< int >();
87         SetReturnKeyType( static_cast<InputMethod::ActionButton>(value) );
88       }
89     }
90     else
91     {
92       DALI_LOG_INFO( gLogFilter, Debug::General, "Provided Settings Key not supported\n" );
93     }
94   }
95 }
96
97
98 InputMethod::ActionButton GetReturnKeyType()
99 {
100   TextInputManager::SeatInfo& info = TextInputManager::Get().GetLastActiveSeat();
101   return info.mReturnKeyType;
102 }
103
104 void EnablePrediction(const bool enable)
105 {
106   // currently not part of Tizen text_input protocol
107 }
108
109 bool IsPredictionEnabled()
110 {
111   return false;
112 }
113
114 Dali::Rect< int > GetSizeAndPosition()
115 {
116   TextInputManager::SeatInfo& info = TextInputManager::Get().GetLastActiveSeat();
117   return info.mInputPanelDimensions;
118 }
119
120 void RotateTo(int angle)
121 {
122   // not part of the wayland protocol
123 }
124
125 Dali::VirtualKeyboard::TextDirection GetTextDirection()
126 {
127   TextInputManager::SeatInfo& info = TextInputManager::Get().GetLastActiveSeat();
128   return info.mTextDirection;
129 }
130
131 Dali::VirtualKeyboard::StatusSignalType& StatusChangedSignal()
132 {
133   return TextInputManager::Get().StatusChangedSignal();
134 }
135
136 Dali::VirtualKeyboard::VoidSignalType& ResizedSignal()
137 {
138   return TextInputManager::Get().ResizedSignal();
139 }
140
141 Dali::VirtualKeyboard::VoidSignalType& LanguageChangedSignal()
142 {
143   return TextInputManager::Get().LanguageChangedSignal();
144 }
145
146 } // namespace VirtualKeyboard
147
148 } // namespace Adaptor
149
150 } // namespace Internal
151
152 } // namespace Dali