Merge "Do not call SetBufferDamagedRects if the damaged rect is empty" into devel...
[platform/core/uifw/dali-adaptor.git] / dali / internal / input / ubuntu-x11 / virtual-keyboard-impl-x.cpp
1 /*
2  * Copyright (c) 2021 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 <dali/internal/input/common/virtual-keyboard-impl.h>
20
21 // EXTERNAL INCLUDES
22 #include <X11/Xlib.h>
23 #include <dali/integration-api/debug.h>
24 #include <algorithm>
25
26 // INTERNAL INCLUDES
27 #include <dali/integration-api/adaptor-framework/adaptor.h>
28 #include <dali/internal/input/ubuntu-x11/input-method-context-impl-x.h>
29 #include <dali/internal/system/common/locale-utils.h>
30 #include <dali/internal/system/linux/dali-ecore-x.h>
31
32 namespace Dali
33 {
34 namespace Internal
35 {
36 namespace Adaptor
37 {
38 namespace VirtualKeyboard
39 {
40 Dali::InputMethod::ButtonAction::Type gButtonActionFunction = Dali::InputMethod::ButtonAction::DEFAULT;
41
42 Ecore_IMF_Input_Panel_Return_Key_Type buttonActionMapping(Dali::InputMethod::ButtonAction::Type buttonAction)
43 {
44   switch(buttonAction)
45   {
46     case InputMethod::ButtonAction::DEFAULT:
47       return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
48     case InputMethod::ButtonAction::DONE:
49       return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
50     case InputMethod::ButtonAction::GO:
51       return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO;
52     case InputMethod::ButtonAction::JOIN:
53       return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN;
54     case InputMethod::ButtonAction::LOGIN:
55       return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN;
56     case InputMethod::ButtonAction::NEXT:
57       return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
58     case InputMethod::ButtonAction::SEARCH:
59       return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH;
60     case InputMethod::ButtonAction::SEND:
61       return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND;
62     case InputMethod::ButtonAction::SIGNIN:
63       return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN;
64     default:
65       return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
66   }
67 }
68
69 void RotateTo(int angle)
70 {
71   // Get focus window used by Keyboard and rotate it
72   Display* display = XOpenDisplay(0);
73   if(display)
74   {
75     ::Window focusWindow;
76     int      revert;
77     // Get Focus window
78     XGetInputFocus(display, &focusWindow, &revert);
79
80     ecore_x_window_prop_property_set(static_cast<Ecore_X_Window>(focusWindow),
81                                      ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
82                                      ECORE_X_ATOM_CARDINAL,
83                                      32,
84                                      &angle,
85                                      1);
86     XCloseDisplay(display);
87   }
88 }
89
90 void SetReturnKeyType(const InputMethod::ButtonAction::Type type)
91 {
92 }
93
94 Dali::InputMethod::ButtonAction::Type GetReturnKeyType()
95 {
96   return gButtonActionFunction;
97 }
98
99 } // namespace VirtualKeyboard
100
101 } // namespace Adaptor
102
103 } // namespace Internal
104
105 } // namespace Dali